private Geometry polygonize(Geometry geometry) {
   List lines = LineStringExtracter.getLines(geometry);
   Polygonizer polygonizer = new Polygonizer();
   polygonizer.add(lines);
   Collection polys = polygonizer.getPolygons();
   Polygon[] polyArray = GeometryFactory.toPolygonArray(polys);
   return geometry.getFactory().createGeometryCollection(polyArray);
 }
Пример #2
0
  private void process() throws Exception {
    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);
    }

    resultPolygon = builtpolys;
  }