Package com.vividsolutions.jts.operation.polygonize

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


    lines.add(rdr.read("LINESTRING (185 221, 88 275, 180 316)"));
    lines.add(rdr.read("LINESTRING (185 221, 292 281, 180 316)"));
    lines.add(rdr.read("LINESTRING (189 98, 83 187, 185 221)"));
    lines.add(rdr.read("LINESTRING (189 98, 325 168, 185 221)"));

    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(lines);

    Collection polys = polygonizer.getPolygons();

    System.out.println("Polygons formed (" + polys.size() + "):");
    System.out.println(polys);
  }
View Full Code Here


    assert this.gf != null : "the geometry factory can't be null"; //$NON-NLS-1$

    // use the Polygonizer to get the rings.
    List<Geometry> ringList = new ArrayList<Geometry>();
    Geometry multiLines =this.line.union();
    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(multiLines);
    Collection<Polygon> polyCollection = polygonizer.getPolygons();

    // add the rings to the ringList.
    for (Polygon pol : polyCollection) {

      Coordinate[] polCoord = pol.getExteriorRing().getCoordinates();
View Full Code Here

     */
    public static boolean isClosedLine(LineString splitLine) {

  Geometry multiLines = splitLine.union();

  Polygonizer polygonizer = new Polygonizer();
  polygonizer.add(multiLines);
  Collection<?> polyCollection = polygonizer.getPolygons();

  return polyCollection.size() != 0;
    }
View Full Code Here

     */
    private static boolean validateClosedLine( final LineString splitLine, final Geometry originalGeometry ) {

        Geometry multiLines = splitLine.union();

        Polygonizer polygonizer = new Polygonizer();
        polygonizer.add(multiLines);
        Collection<Geometry> polyCollection = polygonizer.getPolygons();

        // if any of the pieces are inside the geometry, that means the closed
        // line will end up forming new polygons, it'll produce an output.
        for( Geometry pieces : polyCollection ) {

View Full Code Here

    List<LinearRing> ringList = new ArrayList<LinearRing>();

    Geometry multiLines = line.union();

    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(multiLines);
    Collection<Polygon> polyCollection = polygonizer.getPolygons();

    // add the rings to the ringList.
    for (Polygon pol : polyCollection) {

      Coordinate[] polCoord = pol.getExteriorRing().getCoordinates();
View Full Code Here

    if (Polygon.class.equals(adaptTo)) {
      if (adaptTo.equals(geomClass)) {
        return inputGeom;
      }
      Polygonizer polygonnizer = new Polygonizer();
      polygonnizer.add(inputGeom);
      Collection<? extends Polygon> polys = polygonnizer.getPolygons();
      Polygon[] polygons = new ArrayList<Polygon>(polys).toArray(new Polygon[polys.size()]);

      if (polygons.length == 1) {
        return polygons[0];
      }
View Full Code Here

    // before create the ring, calculate the orientation of the input list.
    boolean isCCWinputList = CGAlgorithms.isCCW(inputList.toArray(new Coordinate[inputList.size()]));
    // create the rings.
    LineString inputLineString = gf.createLineString(inputList.toArray(new Coordinate[inputList.size()]));
    Geometry multiLines = inputLineString.union();
    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(multiLines);
    Collection<Polygon> polyCollection = polygonizer.getPolygons();

    // add the rings to the ringList.
    for (Polygon pol : polyCollection) {

      Coordinate[] polCoord = pol.getExteriorRing().getCoordinates();
View Full Code Here

          extRing.getCoordinates());
      Polygon solidPg = GeometryUtil.gf().createPolygon(solidRing, null);
      Geometry solidCutter = cutter.intersection(solidPg);
      Geometry solidBounds = solidRing.difference(cutter);

      Polygonizer pgzer = new Polygonizer();
      for (int i = 0, count = solidBounds.getNumGeometries(); i < count; i++) {
        pgzer.add(solidBounds.getGeometryN(i));
      }
      pgzer.add(solidCutter);
      ArrayList<Geometry> pgs = new ArrayList<Geometry>();
      for (Iterator itr = pgzer.getPolygons().iterator(); itr.hasNext();) {
        Polygon p = (Polygon) itr.next();
        pgs.add(p.intersection(pg));
      }
      split = GeometryUtil.gf().buildGeometry(pgs);
    } else {
View Full Code Here

                smooth.add(ls);
        }
       
        // apply smoothing
        LineSmoother smoother = new LineSmoother(gf);
        Polygonizer polygonizer = new Polygonizer();
       
        for (int i = 0; i < smooth.size(); i++) {
            polygonizer.add(smoother.smooth(smooth.get(i), 0.5));
        }
        polygonizer.add(keep);
       
        Collection<Polygon> polys = (Collection<Polygon>) polygonizer.getPolygons();
        poly = gf.createMultiPolygon(polys.toArray(new Polygon[polys.size()]));
       
        if(!polygonizer.getInvalidRingLines().isEmpty())
            System.err.println("invalid ring lines found!");
        if(!polygonizer.getDangles().isEmpty())
            System.err.println("dangles found!");
        if(!polygonizer.getCutEdges().isEmpty())
            System.err.println("cut edges found!");
       
        if(!poly.isValid())
            throw new RuntimeException("invalid polygon!");
       
View Full Code Here

    List nodedLinework = new GeometryNoder(pm).node(lines);
    // union the noded linework to remove duplicates
    Geometry nodedDedupedLinework = geomFact.buildGeometry(nodedLinework).union();
   
    // polygonize the result
    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(nodedDedupedLinework);
    Collection polys = polygonizer.getPolygons();
   
    // convert to collection for return
    Polygon[] polyArray = GeometryFactory.toPolygonArray(polys);
    return geomFact.createGeometryCollection(polyArray);
  }
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.