Пример #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[] {}));
  }
Пример #2
0
  public void testIsClosed() throws Exception {
    LineString l = (LineString) reader.read("LINESTRING EMPTY");
    assertTrue(l.isEmpty());
    assertTrue(!l.isClosed());

    LinearRing r = geometryFactory.createLinearRing((CoordinateSequence) null);
    assertTrue(r.isEmpty());
    assertTrue(r.isClosed());

    MultiLineString m = geometryFactory.createMultiLineString(new LineString[] {l, r});
    assertTrue(!m.isClosed());

    MultiLineString m2 = geometryFactory.createMultiLineString(new LineString[] {r});
    assertTrue(!m2.isClosed());
  }