Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.MultiPolygon


                break POLYGONS;
            }
        }

        MultiPolygon polys = gf.createMultiPolygon(toPolygonArray(list));
        polys.setSRID(SRID);

        return polys;
    }
View Full Code Here


            if(centralMeridian != 0) {
                // we need to divide geometries crossing the central antimeridian in two
                double antiMeridian = centralMeridian > 0 ? centralMeridian - 180 : centralMeridian + 180;
                Polygon beforeAntiMeridian = JTS.toGeometry(new Envelope(-180, antiMeridian - EPS, minLat, maxLat));
                Polygon afterAntiMeridian = JTS.toGeometry(new Envelope(antiMeridian + EPS, 180, minLat, maxLat));
                MultiPolygon mask = beforeAntiMeridian.getFactory().createMultiPolygon(new Polygon[] {beforeAntiMeridian, afterAntiMeridian});

                return new ProjectionHandler(sourceCrs, mask, renderingEnvelope);
            } else {
                // for this case we just need to cut on the valid area, which is the whole world
                // minus a tiny area around the dateline
View Full Code Here

        assertEquals(1, fc.size());
        SimpleFeature feature = DataUtilities.first(fc);
        Geometry g = (Geometry) feature.getDefaultGeometry();
        assertNotNull(g);
        assertTrue(g instanceof MultiPolygon);
        MultiPolygon mp = (MultiPolygon) g;
        assertEquals(2, mp.getNumGeometries());

        Polygon p1 = (Polygon) mp.getGeometryN(0);
        assertTrue(p1.getExteriorRing() instanceof CompoundCurvedGeometry<?>);
        assertEquals(2, ((CompoundCurvedGeometry<?>) p1.getExteriorRing()).getComponents().size());
        assertEquals(1, p1.getNumInteriorRing());
        assertEquals(2, ((CompoundCurvedGeometry<?>) p1.getInteriorRingN(0)).getComponents().size());

        Polygon p2 = (Polygon) mp.getGeometryN(1);
        assertTrue(p2.getExteriorRing() instanceof CompoundCurvedGeometry<?>);
        assertEquals(2, ((CompoundCurvedGeometry<?>) p2.getExteriorRing()).getComponents().size());
        assertEquals(0, p2.getNumInteriorRing());
    }
View Full Code Here

        StyleBuilder sb = new StyleBuilder();
        SimpleFeatureType pointType = DataUtilities.createType("emptyPolygon", "geom:MultiPolygon,name:String");
        Polygon p1 = gf.createPolygon(gf.createLinearRing((Coordinate[]) null), null);
        Polygon p2 = gf.createPolygon(gf.createLinearRing(new Coordinate[] {new Coordinate(0,0),
                new Coordinate(1, 1), new Coordinate(1, 0), new Coordinate(0,0)}), null);
        MultiPolygon mp = gf.createMultiPolygon(new Polygon[] {p1, p2});
        SimpleFeature f = SimpleFeatureBuilder.build(pointType, new Object[] {mp, "name" }, null);
        Style style = sb.createStyle(sb.createPolygonSymbolizer());
       
        renderEmptyGeometry(f, style);
    }
View Full Code Here

        LinearRing emptyRing = gf.createLinearRing((Coordinate[]) null);
        LinearRing realRing = gf.createLinearRing(new Coordinate[] {new Coordinate(0,0),
                        new Coordinate(1, 1), new Coordinate(1, 0), new Coordinate(0,0)});
        Polygon p1 = gf.createPolygon(realRing, new LinearRing[] {emptyRing});
        Polygon p2 = gf.createPolygon(emptyRing, new LinearRing[] {emptyRing});
        MultiPolygon mp = gf.createMultiPolygon(new Polygon[] {p1, p2});
        SimpleFeature f = SimpleFeatureBuilder.build(pointType, new Object[] {mp, "name" }, null);
        Style style = sb.createStyle(sb.createPolygonSymbolizer());
       
        renderEmptyGeometry(f, style);
    }
View Full Code Here

    }

    public void testParse() throws Exception {
        GML2MockData.multiPolygonProperty(document, document);

        MultiPolygon mp = (MultiPolygon) parse();
        assertNotNull(mp);
    }
View Full Code Here

        List<Polygon> clippedPolys = new ArrayList<Polygon>();
        Envelope displayGeomEnv = displayGeometry.getEnvelopeInternal();
        for (Polygon p : polys) {
            // If we want labels to be entirely in the display area, clip polygons
            if (!partialsEnabled) {
                MultiPolygon pp = clipPolygon(p, (Polygon) displayGeometry, displayGeomEnv);
                if ((pp != null) && (!(pp.isEmpty()))) {
                    for (int t = 0; t < pp.getNumGeometries(); t++)
                        clippedPolys.add((Polygon) pp.getGeometryN(t));
                }
            }
            // If we want to draw partial labels on border, keep the whole polygon
            else {
                clippedPolys.add(p);
View Full Code Here

     * @param mp
     *                The MultiPolygon to "niceify".
     * @return The "nicified" MultiPolygon.
     */
    public static final MultiPolygon makeGoodShapeMultiPolygon(MultiPolygon mp) {
        MultiPolygon result;
        Polygon[] ps = new Polygon[mp.getNumGeometries()];

        // check each sub-polygon
        for (int t = 0; t < mp.getNumGeometries(); t++) {
            ps[t] = makeGoodShapePolygon((Polygon) mp.getGeometryN(t));
View Full Code Here

    public ShapeType getShapeType() {
        return shapeType;
    }

    public int getLength(Object geometry) {
        MultiPolygon multi;

        if (geometry instanceof MultiPolygon) {
            multi = (MultiPolygon) geometry;
        } else {
            multi = geometryFactory
                    .createMultiPolygon(new Polygon[] { (Polygon) geometry });
        }

        int nrings = 0;

        for (int t = 0; t < multi.getNumGeometries(); t++) {
            Polygon p;
            p = (Polygon) multi.getGeometryN(t);
            nrings = nrings + 1 + p.getNumInteriorRing();
        }

        int npoints = multi.getNumPoints();
        int length;

        if (shapeType == ShapeType.POLYGONZ) {
            length = 44 + (4 * nrings) + (16 * npoints) + (8 * npoints) + 16
                    + (8 * npoints) + 16;
View Full Code Here

    private MultiPolygon createNull() {
        return geometryFactory.createMultiPolygon(null);
    }

    public void write(ByteBuffer buffer, Object geometry) {
        MultiPolygon multi;
       
        if (geometry instanceof MultiPolygon) {
          multi = (MultiPolygon) geometry;
        } else {
          multi = geometryFactory.createMultiPolygon(new Polygon[] { (Polygon) geometry });
        }
       
        Envelope box = multi.getEnvelopeInternal();
        buffer.putDouble(box.getMinX());
        buffer.putDouble(box.getMinY());
        buffer.putDouble(box.getMaxX());
        buffer.putDouble(box.getMaxY());
       
        //need to find the total number of rings and points
        final int nrings;
        final CoordinateSequence []coordinates;
        {
            List allCoords = new ArrayList();
            for (int t = 0; t < multi.getNumGeometries(); t++) {
              Polygon p;
              p = (Polygon) multi.getGeometryN(t);
              allCoords.add(p.getExteriorRing().getCoordinateSequence());
              for(int ringN = 0; ringN < p.getNumInteriorRing(); ringN++){
                  allCoords.add(p.getInteriorRingN(ringN).getCoordinateSequence());
              }
            }
            coordinates = (CoordinateSequence[])allCoords.toArray(new CoordinateSequence[allCoords.size()]);
            nrings = coordinates.length;
        }
       
        final int npoints = multi.getNumPoints();
       
        buffer.putInt(nrings);
        buffer.putInt(npoints);
       
        int count = 0;
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.