@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(); }