Package com.vividsolutions.jts.operation.polygonize

Examples of com.vividsolutions.jts.operation.polygonize.Polygonizer


     * @param polygon
     * @return
     */
    public static List<Polygon> makeValid(Polygon polygon, boolean removeHoles) {
        // add all segments into the polygonizer
        final Polygonizer p = new Polygonizer();
        polygon.apply(new CoordinateSequenceFilter() {

            public boolean isGeometryChanged() {
                return false;
            }

            public boolean isDone() {
                return false;
            }

            public void filter(CoordinateSequence seq, int i) {
                if (i == 0) {
                    return;
                }
                p.add(new GeometryFactory().createLineString(new Coordinate[] {
                        seq.getCoordinate(i - 1), seq.getCoordinate(i) }));
            }
        });

        List<Polygon> result = new ArrayList<Polygon>(p.getPolygons());

        // if necessary throw away the holes and return just the shells
        if (removeHoles) {
            for (int i = 0; i < result.size(); i++) {
                Polygon item = result.get(i);
View Full Code Here


    @DescribeResult(description = "The collection of created polygons")
    static public Geometry polygonize(
            @DescribeParameter(name = "geom", description = "Linework to polygonize") Geometry geom) {
        @SuppressWarnings("rawtypes")
        List lines = LineStringExtracter.getLines(geom);
        Polygonizer polygonizer = new Polygonizer();
        polygonizer.add(lines);
        @SuppressWarnings("rawtypes")
        Collection polys = polygonizer.getPolygons();
        Polygon[] polyArray = GeometryFactory.toPolygonArray(polys);
        return geom.getFactory().createGeometryCollection(polyArray);
    }
View Full Code Here

  {
     if (lines.size() ==0 )
       {
         throw new Exception("polygon has no edges");
       }
         Polygonizer polyizer = new Polygonizer();
         polyizer.add(lines);
         Collection builtpolys = polyizer.getPolygons();
        
         if (polyizer.getCutEdges().size() != 0)
          {
           throw new Exception("polygon has cut edges");
        }
         if (polyizer.getDangles().size() != 0)
          {
           throw new Exception("polygon has dandgle edges");
        }
         if (polyizer.getInvalidRingLines().size() != 0)
          {
           throw new Exception("polygon has invalid edges");
         //  System.out.println("poly has invalid edges "+polyid_long);
        }
        
View Full Code Here

       ArrayList lines = (ArrayList) polyLineSet.get(polyid);
       if (lines.size() ==0 )
       {
         throw new Exception("polygon has no edges");
       }
         Polygonizer polyizer = new Polygonizer();
         polyizer.add(lines);
         Collection builtpolys = polyizer.getPolygons();
        
         if (polyizer.getCutEdges().size() != 0)
          {
           throw new Exception("polygon has cut edges");
        }
         if (polyizer.getDangles().size() != 0)
          {
           throw new Exception("polygon has dandgle edges");
        }
         if (polyizer.getInvalidRingLines().size() != 0)
          {
           throw new Exception("polygon has invalid edges");
         //  System.out.println("poly has invalid edges "+polyid_long);
        }
        
View Full Code Here

public class PolygonizeFunctions {

  public static Geometry polygonize(Geometry g)
  {
    List lines = LineStringExtracter.getLines(g);
    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(lines);
    Collection polys = polygonizer.getPolygons();
    Polygon[] polyArray = GeometryFactory.toPolygonArray(polys);
    return g.getFactory().createGeometryCollection(polyArray);
  }
View Full Code Here

    return g.getFactory().createGeometryCollection(polyArray);
  }
  public static Geometry polygonizeDangles(Geometry g)
  {
    List lines = LineStringExtracter.getLines(g);
    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(lines);
    Collection geom = polygonizer.getDangles();
    return g.getFactory().buildGeometry(geom);
  }
View Full Code Here

    return g.getFactory().buildGeometry(geom);
  }
  public static Geometry polygonizeCutEdges(Geometry g)
  {
    List lines = LineStringExtracter.getLines(g);
    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(lines);
    Collection geom = polygonizer.getCutEdges();
    return g.getFactory().buildGeometry(geom);
  }
View Full Code Here

    return g.getFactory().buildGeometry(geom);
  }
  public static Geometry polygonizeInvalidRingLines(Geometry g)
  {
    List lines = LineStringExtracter.getLines(g);
    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(lines);
    Collection geom = polygonizer.getInvalidRingLines();
    return g.getFactory().buildGeometry(geom);
  }
View Full Code Here

    return g.getFactory().buildGeometry(geom);
  }
  public static Geometry polygonizeAllErrors(Geometry g)
  {
    List lines = LineStringExtracter.getLines(g);
    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(lines);
    List errs = new ArrayList();
    errs.addAll(polygonizer.getDangles());
    errs.addAll(polygonizer.getCutEdges());
    errs.addAll(polygonizer.getInvalidRingLines());
    return g.getFactory().buildGeometry(errs);
  }
View Full Code Here

      new String[]{});
  }
*/

  private void doTest(String[] inputWKT, String[] expectedOutputWKT) {
    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(toGeometries(inputWKT));
    compare(toGeometries(expectedOutputWKT), polygonizer.getPolygons());
  }
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.operation.polygonize.Polygonizer

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.