Exemplo n.º 1
0
  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[] {}));
  }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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);
   }
 }