Package org.geotools.geometry.jts

Examples of org.geotools.geometry.jts.GeometryBuilder


        Transaction tx = new DefaultTransaction();
        FeatureWriter<SimpleFeatureType, SimpleFeature> fw = dataStore.getFeatureWriterAppend(
                linesTypeName.getLocalPart(), tx);

        LineString line = new GeometryBuilder().lineString(0, 0, 1, 1);
        SimpleFeature f = (SimpleFeature) fw.next();
        f.setAttribute("sp", "foo");
        f.setAttribute("ip", 10);
        f.setAttribute("pp", line);
View Full Code Here


import com.vividsolutions.jts.geom.Polygon;

public class KMLEncodingTest extends KMLTestSupport {

    public void testEncodePoint() throws Exception {
        Point p = new GeometryBuilder().point(1,2);
        Document d = encode(p, KML.Point);
       
        assertEquals("Point", d.getDocumentElement().getLocalName());
        Element e = getElementByQName(d, KML.coordinates);
        assertNotNull(e);
View Full Code Here

        assertEquals("1.0,2.0", e.getFirstChild().getNodeValue());
    }

    public void testEncodePolygon() throws Exception {
        Polygon p = new GeometryBuilder().polygon(1, 1, 2, 2, 3, 3, 1, 1);
        Document d = encode(p, KML.Polygon);
        assertEquals("Polygon", d.getDocumentElement().getLocalName());

        Element e = getElementByQName(d, KML.outerBoundaryIs);
        assertNotNull(e);
View Full Code Here

        // prepare the rendering surface
        BufferedImage image = new BufferedImage(tileSize, tileSize, BufferedImage.TYPE_4BYTE_ABGR);
        Graphics2D g2d = image.createGraphics();

        // prepare the bounds of the tile
        Geometry tileBounds = new GeometryBuilder().box(0, 0, tileSize, tileSize);

        // prepare the bounds of the shape
        Geometry bounds = getGeometryBounds(icon, mark, shape, markSize, feature);
        Geometry conflictBounds = getConflictBounds(bounds, spaceAround);
        ReservedAreaCache rac = buildReservedAreaCache(conflictBounds);
View Full Code Here

    private Geometry getGeometryBounds(Icon icon, Mark mark, Shape shape, double markSize,
            Object feature) {
        Geometry bounds;
        if (icon != null) {
            bounds = new GeometryBuilder().box(0, 0, icon.getIconWidth(), icon.getIconHeight());
        } else {
            // the shape can be very complicated, go for the MBR. Wanted to use ShapeReader, but it
            // blindly assumes the shape is a polygon, while it may not be. Building a multipoint
            // instead
            AffineTransform at = AffineTransform.getScaleInstance(markSize, -markSize);
View Full Code Here

public class GeoPkgIOTest {

    @Test
    public void testReadWrite() throws IOException {
        Geometry g1 = new GeometryBuilder().point(0,0).buffer(10);
        byte[] bytes = new GeoPkgGeomWriter().write(g1);

        Geometry g2 = new GeoPkgGeomReader().read(bytes);
        assertTrue(g1.equals(g2));
    }
View Full Code Here

        assertTrue(g1.equals(g2));
    }

    @Test
    public void testHeader() throws IOException {
        Geometry g1 = new GeometryBuilder().point(0,0).buffer(10);
        byte[] bytes = new GeoPkgGeomWriter().write(g1);

        assertEquals(0x47, bytes[0]);
        assertEquals(0x50, bytes[1]);
        assertEquals(0x00, bytes[2]);
View Full Code Here

        runSafe("DROP TABLE ft1");
        runSafe("DROP TABLE ft2");
        runSafe("DELETE FROM gpkg_geometry_columns where f_table_name in ('ft1','ft2')");
        runSafe("DELETE FROM gpkg_contents where table_name in ('ft1','ft2')");
       
        GeometryBuilder gb = new GeometryBuilder();

        //create some data
        String sql = "CREATE TABLE ft1 (id INTEGER PRIMARY KEY, geometry BLOB)";
        run( sql );
       
        sql = "ALTER TABLE ft1 add intProperty INTEGER";
        run( sql );
       
        sql = "ALTER TABLE ft1 add doubleProperty DOUBLE";
        run( sql );
       
        sql = "ALTER TABLE ft1 add stringProperty VARCHAR(255)";
        run( sql );

        sql = "INSERT INTO ft1 VALUES ("
            + "0,X'"+toString(gb.point(0,0))+"', 0, 0.0,'zero');";
        run(sql);

        sql = "INSERT INTO ft1 VALUES ("
            + "1,X'"+toString(gb.point(1,1))+"', 1, 1.1,'one');";
        run(sql);

        sql = "INSERT INTO ft1 VALUES ("
            + "2,X'"+toString(gb.point(2,2))+"', 2, 2.2,'two');";
        run(sql);

        sql = "INSERT INTO gpkg_geometry_columns VALUES ('ft1', 'geometry', 'POINT', 2, 4326)";
        run(sql);
       
View Full Code Here

    }
   
    @Test
    public void testBinarySpatialFilter() throws IllegalFilterException {
       
        GeometryBuilder builder = new GeometryBuilder();
       
        LiteralDemultiplyingFilterVisitor visitor = new LiteralDemultiplyingFilterVisitor();
       
        Object object1 = builder.point(1,2);
        Object object2 = builder.point(3,4);
        Object object3 = builder.point(5,6);
               
        List values = new ArrayList();
        values.add(object1);
        values.add(object2);
        values.add(object3);
View Full Code Here

    SimpleFeatureStore store = (SimpleFeatureStore) dataStore.getFeatureSource( typeName );
   
    SimpleFeatureType featureType = store.getSchema();
   
    SimpleFeatureBuilder build = new SimpleFeatureBuilder(featureType);
    GeometryBuilder geom = new GeometryBuilder();
   
    List<SimpleFeature> list = new ArrayList<SimpleFeature>();
    list.add( build.buildFeature("fid1", new Object[]{ geom.point(1,1), "hello" } ) );
    list.add( build.buildFeature("fid2", new Object[]{ geom.point(2,3), "martin" } ) );
    SimpleFeatureCollection collection = new ListFeatureCollection(featureType, list);

    Transaction transaction = new DefaultTransaction("Add Example");
    store.setTransaction( transaction );
    try {
View Full Code Here

TOP

Related Classes of org.geotools.geometry.jts.GeometryBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.