private GeometryCursor prepare_for_ops_(OGCConcreteGeometryCollection collection) { assert(collection != null && !collection.isEmpty()); GeometryCursor prepared = OGCStructureInternal.prepare_for_ops_(collection.flatten().getEsriGeometryCursor(), esriSR); return removeOverlapsHelper_(toList(prepared)); } }
private GeometryCursor prepare_for_ops_(OGCConcreteGeometryCollection collection) { assert(collection != null && !collection.isEmpty()); GeometryCursor prepared = OGCStructureInternal.prepare_for_ops_(collection.flatten().getEsriGeometryCursor(), esriSR); return removeOverlapsHelper_(toList(prepared)); } }
/** * Fixes topological overlaps in the GeometryCollecion. * This is equivalent to union of the geometry collection elements. * * TODO "flattened" collection is supposed to contain only mutli-geometries, but this method may return single geometries * e.g. for GEOMETRYCOLLECTION (LINESTRING (...)) it returns GEOMETRYCOLLECTION (LINESTRING (...)) * and not GEOMETRYCOLLECTION (MULTILINESTRING (...)) * @return A geometry collection that is flattened and has no overlapping elements. */ public OGCConcreteGeometryCollection flattenAndRemoveOverlaps() { //flatten and crack/cluster GeometryCursor cursor = OGCStructureInternal.prepare_for_ops_(flatten().getEsriGeometryCursor(), esriSR); //make sure geometries don't overlap return new OGCConcreteGeometryCollection(removeOverlapsHelper_(toList(cursor)), esriSR); }
/** * Fixes topological overlaps in the GeometryCollecion. * This is equivalent to union of the geometry collection elements. * * TODO "flattened" collection is supposed to contain only mutli-geometries, but this method may return single geometries * e.g. for GEOMETRYCOLLECTION (LINESTRING (...)) it returns GEOMETRYCOLLECTION (LINESTRING (...)) * and not GEOMETRYCOLLECTION (MULTILINESTRING (...)) * @return A geometry collection that is flattened and has no overlapping elements. */ public OGCConcreteGeometryCollection flattenAndRemoveOverlaps() { //flatten and crack/cluster GeometryCursor cursor = OGCStructureInternal.prepare_for_ops_(flatten().getEsriGeometryCursor(), esriSR); //make sure geometries don't overlap return new OGCConcreteGeometryCollection(removeOverlapsHelper_(toList(cursor)), esriSR); }
@Override public OGCGeometry intersection(OGCGeometry another) { if (isEmpty() || another.isEmpty()) { return new OGCConcreteGeometryCollection(esriSR); } List<Geometry> geometries = toList(prepare_for_ops_(toGeometryCollection(this))); List<Geometry> otherGeometries = toList(prepare_for_ops_(toGeometryCollection(another))); List<OGCGeometry> result = new ArrayList<OGCGeometry>(); for (Geometry geometry : geometries) { for (Geometry otherGeometry : otherGeometries) { GeometryCursor intersectionCursor = OperatorIntersection.local().execute(new SimpleGeometryCursor(geometry), new SimpleGeometryCursor(otherGeometry), esriSR, null, 7); OGCGeometry intersection = OGCGeometry.createFromEsriCursor(intersectionCursor, esriSR, true); if (!intersection.isEmpty()) { result.add(intersection); } } } if (result.size() == 1) { return result.get(0).reduceFromMulti(); } return new OGCConcreteGeometryCollection(result, esriSR).flattenAndRemoveOverlaps(); }
@Override public OGCGeometry intersection(OGCGeometry another) { if (isEmpty() || another.isEmpty()) { return new OGCConcreteGeometryCollection(esriSR); } List<Geometry> geometries = toList(prepare_for_ops_(toGeometryCollection(this))); List<Geometry> otherGeometries = toList(prepare_for_ops_(toGeometryCollection(another))); List<OGCGeometry> result = new ArrayList<OGCGeometry>(); for (Geometry geometry : geometries) { for (Geometry otherGeometry : otherGeometries) { GeometryCursor intersectionCursor = OperatorIntersection.local().execute(new SimpleGeometryCursor(geometry), new SimpleGeometryCursor(otherGeometry), esriSR, null, 7); OGCGeometry intersection = OGCGeometry.createFromEsriCursor(intersectionCursor, esriSR, true); if (!intersection.isEmpty()) { result.add(intersection); } } } if (result.size() == 1) { return result.get(0).reduceFromMulti(); } return new OGCConcreteGeometryCollection(result, esriSR).flattenAndRemoveOverlaps(); }
@Override public OGCGeometry difference(OGCGeometry another) { if (isEmpty() || another.isEmpty()) { return this; } List<Geometry> geometries = toList(prepare_for_ops_(toGeometryCollection(this))); List<Geometry> otherGeometries = toList(prepare_for_ops_(toGeometryCollection(another))); List<OGCGeometry> result = new ArrayList<OGCGeometry>(); for (Geometry geometry : geometries) { for (Geometry otherGeometry : otherGeometries) { if (geometry.getDimension() > otherGeometry.getDimension()) { continue; //subtracting lower dimension has no effect. } geometry = OperatorDifference.local().execute(geometry, otherGeometry, esriSR, null); if (geometry.isEmpty()) { break; } } if (!geometry.isEmpty()) { result.add(OGCGeometry.createFromEsriGeometry(geometry, esriSR)); } } if (result.size() == 1) { return result.get(0).reduceFromMulti(); } return new OGCConcreteGeometryCollection(result, esriSR).flattenAndRemoveOverlaps(); }
@Override public OGCGeometry difference(OGCGeometry another) { if (isEmpty() || another.isEmpty()) { return this; } List<Geometry> geometries = toList(prepare_for_ops_(toGeometryCollection(this))); List<Geometry> otherGeometries = toList(prepare_for_ops_(toGeometryCollection(another))); List<OGCGeometry> result = new ArrayList<OGCGeometry>(); for (Geometry geometry : geometries) { for (Geometry otherGeometry : otherGeometries) { if (geometry.getDimension() > otherGeometry.getDimension()) { continue; //subtracting lower dimension has no effect. } geometry = OperatorDifference.local().execute(geometry, otherGeometry, esriSR, null); if (geometry.isEmpty()) { break; } } if (!geometry.isEmpty()) { result.add(OGCGeometry.createFromEsriGeometry(geometry, esriSR)); } } if (result.size() == 1) { return result.get(0).reduceFromMulti(); } return new OGCConcreteGeometryCollection(result, esriSR).flattenAndRemoveOverlaps(); }