コード例 #1
0
ファイル: GeometryEditor.java プロジェクト: ebocher/jts
  private Polygon editPolygon(Polygon polygon, GeometryEditorOperation operation) {
    Polygon newPolygon = (Polygon) operation.edit(polygon, factory);
    // create one if needed
    if (newPolygon == null) newPolygon = factory.createPolygon((CoordinateSequence) null);
    if (newPolygon.isEmpty()) {
      // RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
      return newPolygon;
    }

    LinearRing shell = (LinearRing) edit(newPolygon.getExteriorRing(), operation);
    if (shell == null || shell.isEmpty()) {
      // RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
      return factory.createPolygon(null, null);
    }

    ArrayList holes = new ArrayList();
    for (int i = 0; i < newPolygon.getNumInteriorRing(); i++) {
      LinearRing hole = (LinearRing) edit(newPolygon.getInteriorRingN(i), operation);
      if (hole == null || hole.isEmpty()) {
        continue;
      }
      holes.add(hole);
    }

    return factory.createPolygon(shell, (LinearRing[]) holes.toArray(new LinearRing[] {}));
  }
コード例 #2
0
ファイル: GeometryCombiner.java プロジェクト: dr-jts/jts
 public Polygon addHole(Polygon poly, LinearRing hole) {
   int nOrigHoles = poly.getNumInteriorRing();
   LinearRing[] newHoles = new LinearRing[nOrigHoles + 1];
   for (int i = 0; i < nOrigHoles; i++) {
     newHoles[i] = (LinearRing) poly.getInteriorRingN(i);
   }
   newHoles[nOrigHoles] = hole;
   return geomFactory.createPolygon((LinearRing) poly.getExteriorRing(), newHoles);
 }
コード例 #3
0
ファイル: DistanceToPoint.java プロジェクト: lossyrob/jts
 public static void computeDistance(Polygon poly, Coordinate pt, PointPairDistance ptDist) {
   computeDistance(poly.getExteriorRing(), pt, ptDist);
   for (int i = 0; i < poly.getNumInteriorRing(); i++) {
     computeDistance(poly.getInteriorRingN(i), pt, ptDist);
   }
 }