Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.MultiPolygon


      obj.put("paths", arrayTemp2);
    }

    // MultiPolygon
    else if (geometry.getClass().equals(MultiPolygon.class)) {
      MultiPolygon mpg = (MultiPolygon) geometry;
      for (int i = 0, count = mpg.getNumGeometries(); i < count; i++) {
        Geometry geo = mpg.getGeometryN(i);
        if (geo.getClass().equals(Polygon.class)) {
          Polygon pg = (Polygon) geo;
          // TODO
          // If ESRI support multipolygon with hole?
          Coordinate[] coords = pg.getExteriorRing().getCoordinates();
View Full Code Here


          CoordinateReferenceSystem sourceCRS = DefaultGeographicCRS.WGS84;
          String gml = Xml.getString(geom);

          try {
            if (srs != null && !(srs.equals(""))) sourceCRS = CRS.decode(srs);
            MultiPolygon jts = parseGml(parser, gml);
             
            // if we have an srs and its not WGS84 then transform to WGS84
            if (!CRS.equalsIgnoreMetadata(sourceCRS, DefaultGeographicCRS.WGS84)) {
              MathTransform tform = CRS.findMathTransform(sourceCRS, DefaultGeographicCRS.WGS84);
              jts = (MultiPolygon)JTS.transform(jts, tform);
            }

            for (int i = 0; i < jts.getNumGeometries(); i++) {
              allPolygons.add((Polygon) jts.getGeometryN(i));
            }
          } catch (Exception e) {
            errorMessage.put("PARSE", gml + ". Error is:" + e.getMessage());
            Log.error(Geonet.INDEX_ENGINE, "Failed to convert gml to jts object: "+gml+"\n\t"+e.getMessage());
            e.printStackTrace();
View Full Code Here

   
    private static float[] getDistanceFromPerimeter(TriMesh2D mesh){
        float[] d = new float[mesh.getNodeCount()];
       
        Shape shape = mesh.createOutlinePath();
        MultiPolygon mp = JTSUtils.createMultiPolygon(shape);
        LineString[] ls = JTSUtils.getLineStrings(mp);
        MultiLineString mls = JTSUtils.getFactory().createMultiLineString(ls);
       
        for (int i = 0; i < d.length; i++) {
            Node2D n = mesh.getNode(i);
View Full Code Here

    /**
     * Creates an area set with no subareas.
     * @return A new area set that equals the shell of this area set.
     */
    public AreaSet createSingularAreaSet(){
        MultiPolygon mp = (MultiPolygon) shell.clone();
        return new AreaSet(new MultiPolygon[]{mp});
    }
View Full Code Here

     * by the filter.
     * @return a new polygon with the filter applied or the original polygon if
     * no filter was applied
     */
    private MultiPolygon applyMAFilter(MultiPolygon poly, int degree, Geometry preserve){
        MultiPolygon filtered = null;
       
        for(int deg = degree; deg > 0; deg--){
            filtered = (MultiPolygon) poly.clone();
            filtered.apply(new ComponentMovingAverageFilter(deg, preserve));
           
            if(filtered.isValid()){
                ConnectedInteriorTester t1 = new ConnectedInteriorTester(null);
               
                System.err.println("Applied filter degree: " + deg);
                break;
            }
        }
       
        if(filtered != null && filtered.isValid()){
            return filtered;
        } else {
            if(degree > 0)
                System.err.println("No filter applied to polygon");
            return poly;
View Full Code Here

           
            // infill
            for (int i = 0; i < polys.length; i++) {
                double offset = 0.5 * ew + lp.cap_length;
                Geometry g = polys[i].buffer(-offset).intersection(infillArea);
                MultiPolygon p = JTSUtils.toMultiPolygon(g);
                lines = getInfill(p, bounds, obj.getDensity(i), lp.fill_angle, ew);
                ggen.parseAll(lines, lh, ew, lp.infill_speed, t);
            }
        }
       
View Full Code Here

    private LineString[] getOutlines(Geometry poly, LayerProperties lp) throws TopologyException{
        ArrayList<LineString> lines = new ArrayList<>();
       
        for (int i = lp.perimeters-1; i >= 0; i--) {
            double offset = -lp.extrusion_width * (i + 0.5);
            MultiPolygon p = JTSUtils.toMultiPolygon(poly.buffer(offset));
            lines.addAll(Arrays.asList(JTSUtils.getLineStrings(p)));
        }
       
        return lines.toArray(new LineString[lines.size()]);
    }
View Full Code Here

        }
       
        // add small polys to higher order
        for (Polygon p : add) {
            for (int i = 1; i < polygons.length; i++) {
                MultiPolygon poly = polygons[i];
                if(!poly.disjoint(p) || i == polygons.length - 1){
                    // make sure p gets added somewhere
                    polygons[i] = JTSUtils.toMultiPolygon(polygons[i].union(p));
                    break;
                }
            }
View Full Code Here

                    new Coordinate(10, 0),
                    new Coordinate(10, 7),
                    new Coordinate(0, 7),
                    new Coordinate(0, 0),
                };
                MultiPolygon p1 = JTSUtils.toMultiPolygon(JTSUtils.getFactory().createPolygon(points));
               
                BSProperties props = new BSProperties();
                Slicer slicer = new Slicer(null);
               
                double ew = 0.37;
                double d = 0.5;
                double a = 40;
                int layers = 2;
                LayerProperties lp = new LayerProperties(0, props);
               
                MultiLineString outlines = JTSUtils.getFactory().createMultiLineString(slicer.getOutlines(p1, lp));
                System.out.println(outlines.getNumGeometries());
                
                LineString[] hl = slicer.getInfill(p1, p1.getEnvelopeInternal(), 1, lp.fill_angle, lp.extrusion_width);
                MultiLineString hatch = JTSUtils.getFactory().createMultiLineString(hl);
               
                AffineTransform t = AffineTransform.getTranslateInstance(50, 500);
                t.concatenate(AffineTransform.getScaleInstance(50, -50));
               
View Full Code Here

    }
   
    private Shape[] createShapes(MultiPolygon[] polygons){
        Shape[] shps = new Shape[polygons.length];
        for (int i = 0; i < polygons.length; i++) {
            MultiPolygon poly = polygons[i];
            shps[i] = JTSUtils.toShape(poly);
        }
        return shps;
    }
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.