@Override public boolean isMeasured() { return !isEmpty() && geometries.get(0).isMeasured(); }
@Override public boolean is3D() { return !isEmpty() && geometries.get(0).is3D(); }
@Override public boolean is3D() { return !isEmpty() && geometries.get(0).is3D(); }
@Override public boolean isMeasured() { return !isEmpty() && geometries.get(0).isMeasured(); }
@Override public int coordinateDimension() { return isEmpty() ? 2 : geometryN(0).coordinateDimension(); }
@Override public int coordinateDimension() { return isEmpty() ? 2 : geometryN(0).coordinateDimension(); }
@Override public double distance(OGCGeometry another) { if (this == another) return isEmpty() ? Double.NaN : 0; double minD = Double.NaN; for (int i = 0, n = numGeometries(); i < n; ++i) { // TODO Skip expensive distance computation if bounding boxes are further away than minD double d = geometryN(i).distance(another); if (d < minD || Double.isNaN(minD)) { minD = d; // TODO Replace zero with tolerance defined by the spatial reference if (minD == 0) { break; } } } return minD; }
@Override public boolean contains(OGCGeometry another) { if (isEmpty() || another.isEmpty()) return false; if (this == another) return true; return another.difference(this).isEmpty(); }
@Override public boolean contains(OGCGeometry another) { if (isEmpty() || another.isEmpty()) return false; if (this == another) return true; return another.difference(this).isEmpty(); }
@Override public double distance(OGCGeometry another) { if (this == another) return isEmpty() ? Double.NaN : 0; double minD = Double.NaN; for (int i = 0, n = numGeometries(); i < n; ++i) { // TODO Skip expensive distance computation if bounding boxes are further away than minD double d = geometryN(i).distance(another); if (d < minD || Double.isNaN(minD)) { minD = d; // TODO Replace zero with tolerance defined by the spatial reference if (minD == 0) { break; } } } return minD; }
@Override public boolean disjoint(OGCGeometry another) { if (isEmpty() || another.isEmpty()) return true; if (this == another) return false; //TODO: a simple envelope test OGCConcreteGeometryCollection flattened1 = flatten(); if (flattened1.isEmpty()) return true; OGCConcreteGeometryCollection otherCol = new OGCConcreteGeometryCollection(another, esriSR); OGCConcreteGeometryCollection flattened2 = otherCol.flatten(); if (flattened2.isEmpty()) return true; for (int i = 0, n1 = flattened1.numGeometries(); i < n1; ++i) { OGCGeometry g1 = flattened1.geometryN(i); for (int j = 0, n2 = flattened2.numGeometries(); j < n2; ++j) { OGCGeometry g2 = flattened2.geometryN(j); if (!g1.disjoint(g2)) return false; } } return true; }
@Override public boolean disjoint(OGCGeometry another) { if (isEmpty() || another.isEmpty()) return true; if (this == another) return false; //TODO: a simple envelope test OGCConcreteGeometryCollection flattened1 = flatten(); if (flattened1.isEmpty()) return true; OGCConcreteGeometryCollection otherCol = new OGCConcreteGeometryCollection(another, esriSR); OGCConcreteGeometryCollection flattened2 = otherCol.flatten(); if (flattened2.isEmpty()) return true; for (int i = 0, n1 = flattened1.numGeometries(); i < n1; ++i) { OGCGeometry g1 = flattened1.geometryN(i); for (int j = 0, n2 = flattened2.numGeometries(); j < n2; ++j) { OGCGeometry g2 = flattened2.geometryN(j); if (!g1.disjoint(g2)) return false; } } return true; }
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)); } }
@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(); }
@Override public boolean Equals(OGCGeometry another) { if (this == another) return !isEmpty();
@Override public boolean Equals(OGCGeometry another) { if (this == another) return !isEmpty();