Beispiel #1
0
  private GeometryCollection editGeometryCollection(
      GeometryCollection collection, GeometryEditorOperation operation) {
    // first edit the entire collection
    // MD - not sure why this is done - could just check original collection?
    GeometryCollection collectionForType = (GeometryCollection) operation.edit(collection, factory);

    // edit the component geometries
    ArrayList geometries = new ArrayList();
    for (int i = 0; i < collectionForType.getNumGeometries(); i++) {
      Geometry geometry = edit(collectionForType.getGeometryN(i), operation);
      if (geometry == null || geometry.isEmpty()) {
        continue;
      }
      geometries.add(geometry);
    }

    if (collectionForType.getClass() == MultiPoint.class) {
      return factory.createMultiPoint((Point[]) geometries.toArray(new Point[] {}));
    }
    if (collectionForType.getClass() == MultiLineString.class) {
      return factory.createMultiLineString((LineString[]) geometries.toArray(new LineString[] {}));
    }
    if (collectionForType.getClass() == MultiPolygon.class) {
      return factory.createMultiPolygon((Polygon[]) geometries.toArray(new Polygon[] {}));
    }
    return factory.createGeometryCollection((Geometry[]) geometries.toArray(new Geometry[] {}));
  }
Beispiel #2
0
  public static List extractElements(Geometry geom, boolean skipEmpty) {
    List elem = new ArrayList();
    if (geom == null) return elem;

    for (int i = 0; i < geom.getNumGeometries(); i++) {
      Geometry elemGeom = geom.getGeometryN(i);
      if (skipEmpty && elemGeom.isEmpty()) continue;
      elem.add(elemGeom);
    }
    return elem;
  }
  private void checkExpectedEmpty() {
    // can't check areal features
    if (input.getDimension() >= 2) return;
    // can't check positive distances
    if (distance > 0.0) return;

    // at this point can expect an empty result
    if (!result.isEmpty()) {
      isValid = false;
      errorMsg = "Result is non-empty";
      errorIndicator = result;
    }
    report("ExpectedEmpty");
  }