Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.MultiPolygon


    public void testMultiSurface() throws Exception {
        GMLConfiguration gml = new GMLConfiguration(true);
        Parser p = new Parser(gml);
        Object multiSurface = p.parse(getClass().getResourceAsStream("multisurface.xml"));
        assertTrue(multiSurface instanceof MultiPolygon);
        MultiPolygon mp = (MultiPolygon) multiSurface;
        assertEquals(1, mp.getNumGeometries());
        Polygon poly = (Polygon) mp.getGeometryN(0);
        assertTrue(poly.getExteriorRing() instanceof CompoundRing);
    }
View Full Code Here


        Id startingFeatures = createFidFilter(fs);
        FilterFactory2 filterFac = CommonFactoryFinder
                .getFilterFactory2(GeoTools.getDefaultHints());
        try {
            GeometryFactory gf = new GeometryFactory();
            MultiPolygon mp = gf.createMultiPolygon(new Polygon[] { gf.createPolygon(gf
                    .createLinearRing(new Coordinate[] { new Coordinate(-88.071564, 37.51099),
                            new Coordinate(-88.467644, 37.400757),
                            new Coordinate(-90.638329, 42.509361),
                            new Coordinate(-89.834618, 42.50346),
                            new Coordinate(-88.071564, 37.51099) }), new LinearRing[] {}) });
            mp.setUserData("http://www.opengis.net/gml/srs/epsg.xml#" + EPSG_CODE);

            PropertyName geometryAttributeExpression = filterFac.property(ft
                    .getGeometryDescriptor().getLocalName());
            PropertyIsNull geomNullCheck = filterFac.isNull(geometryAttributeExpression);
            Query query = new Query(typename, filterFac.not(geomNullCheck), 1,
View Full Code Here

        SimpleFeatureCollection result = cp.execute(features, new WKTReader().read("POLYGON((0 5000, 0 10000, 10000 10000, 10000 5000, 0 5000))"), true);
        assertEquals(1, result.size());
        SimpleFeatureIterator fi = result.features();
        // check the first polygon
        SimpleFeature f = fi.next();
        MultiPolygon mp = (MultiPolygon) f.getDefaultGeometry();
        assertEquals(1, mp.getNumGeometries());
        Polygon p = (Polygon) mp.getGeometryN(0);
        assertEquals(0, p.getNumInteriorRing());
        LineString shell = p.getExteriorRing();
        CoordinateSequence cs = shell.getCoordinateSequence();
        assertEquals(5, cs.size());
        assertOrdinates(0, 5000, 1, cs, 0);
View Full Code Here

        SimpleFeatureCollection result = cp.execute(features, new WKTReader().read("POLYGON((2500 2500, 2500 7500, 7500 7500, 7500 2500, 2500 2500))"), true);
        assertEquals(2, result.size());
        SimpleFeatureIterator fi = result.features();
        // check the first polygon
        SimpleFeature f = fi.next();
        MultiPolygon mp = (MultiPolygon) f.getDefaultGeometry();
        assertEquals(1, mp.getNumGeometries());
        Polygon p = (Polygon) mp.getGeometryN(0);
        assertEquals(0, p.getNumInteriorRing());
        LineString shell = p.getExteriorRing();
        CoordinateSequence cs = shell.getCoordinateSequence();
        assertEquals(5, cs.size());
        assertOrdinates(2500, 2500, 0.411765, cs, 0);
View Full Code Here

    private void assertSquaresMetersIdentical(SimpleFeatureCollection result) {
        SimpleFeatureIterator fi = result.features();
        // check the first polygon
        SimpleFeature f = fi.next();
        MultiPolygon mp = (MultiPolygon) f.getDefaultGeometry();
        assertEquals(1, mp.getNumGeometries());
        Polygon p = (Polygon) mp.getGeometryN(0);
        assertEquals(0, p.getNumInteriorRing());
        LineString shell = p.getExteriorRing();
        CoordinateSequence cs = shell.getCoordinateSequence();
        assertEquals(5, cs.size());
        assertOrdinates(0, 0, 0, cs, 0);
        assertOrdinates(0, 10000, 2, cs, 1);
        assertOrdinates(10000, 10000, 2, cs, 2);
        assertOrdinates(10000, 0, 0, cs, 3);
        assertOrdinates(0, 0, 0, cs, 4);
        // check the second
        f = fi.next();
        mp = (MultiPolygon) f.getDefaultGeometry();
        assertEquals(1, mp.getNumGeometries());
        p = (Polygon) mp.getGeometryN(0);
        assertEquals(0, p.getNumInteriorRing());
        shell = p.getExteriorRing();
        cs = shell.getCoordinateSequence();
        assertEquals(5, cs.size());
        assertOrdinates(0, 0, Double.NaN, cs, 0);
View Full Code Here

                new Coordinate(0,10),
                new Coordinate(0,0)
            });
        Polygon polygon = factory.createPolygon(ring, new LinearRing[0]);
        polygon.setUserData("EPSG:4326");
        MultiPolygon geom = factory.createMultiPolygon(new Polygon[]{polygon});
        geom.setUserData("EPSG:4326");
        final StringWriter writer = new StringWriter();
//        DocumentWriter.writeDocument(geom, schema, writer, new HashMap());
       
        PrintHandler output=new PrintHandler(){
View Full Code Here

            LOGGER.fine("created " + multiLineString);

            return multiLineString;
        } else if (internalType.equals("Polygon")) {
            Polygon[] polygonArray = geometryFactory.toPolygonArray(geometries);
            MultiPolygon multiPolygon = geometryFactory.createMultiPolygon(polygonArray);
            multiPolygon.setUserData( getSRS() );
            multiPolygon.setSRID( getSRID() );
            LOGGER.fine("created " + multiPolygon);

            return multiPolygon;
        } else {
            return null;
View Full Code Here

        if (collectionClass == MultiPoint.class) {
            Point[] array = (Point[]) geometries.toArray(new Point[geometries.size()]);
            return gf.createMultiPoint(array);
        } else if (collectionClass == MultiPolygon.class) {
            Polygon[] array = (Polygon[]) geometries.toArray(new Polygon[geometries.size()]);
            MultiPolygon mp = gf.createMultiPolygon(array);
           
            // a collection of valid polygon does not necessarily make up a valid multipolygon
            if(array.length > 1 && !mp.isValid()) {
                Geometry g = mp.buffer(0);
                if(g instanceof Polygon) {
                    return gf.createMultiPolygon(new Polygon[] {(Polygon) g});
                } else {
                    return (GeometryCollection) g;
                }
View Full Code Here

                GeometryAttribute defaultGeometryProperty = feature.getDefaultGeometryProperty();
                assertNotNull(defaultGeometryProperty);
                final Object value = defaultGeometryProperty.getValue();
                assertNotNull(value);
                assertTrue("value: " + value, value instanceof MultiPolygon);
                MultiPolygon mp = (MultiPolygon) value;

                assertEquals(numPolygons, mp.getNumGeometries());
                for (int i = 0; i < numPolygons; i++) {
                    Polygon p = (Polygon) mp.getGeometryN(i);
                    assertEquals(expectedHoles, p.getNumInteriorRing());
                }
            }
        };
View Full Code Here

                inverted[count] = (LineString) invertGeometryCoordinates(multiLineString
                        .getGeometryN(count));
            }
            return geometryFactory.createMultiLineString(inverted);
        } else if (geom instanceof MultiPolygon) {
            MultiPolygon multiPolygon = (MultiPolygon) geom;
            Polygon[] inverted = new Polygon[multiPolygon.getNumGeometries()];
            for (int count = 0; count < multiPolygon.getNumGeometries(); count++) {
                inverted[count] = (Polygon) invertGeometryCoordinates(multiPolygon
                        .getGeometryN(count));
            }
            return geometryFactory.createMultiPolygon(inverted);
        } else if (geom instanceof GeometryCollection) {
            GeometryCollection collection = (GeometryCollection) geom;
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.MultiPolygon

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.