@Override public Geometry next() { while (m_collections != null) { if (m_current != null) { Geometry g = m_current.next(); if (g == null) { m_current = null; continue; } return g; } else { m_index++; if (m_index < m_collections.size()) { m_current = m_collections.get(m_index).flatten().getEsriGeometryCursor(); continue; } else { m_collections = null; m_index = -1; } } } return null; }
@Override public Geometry next() { while (m_collections != null) { if (m_current != null) { Geometry g = m_current.next(); if (g == null) { m_current = null; continue; } return g; } else { m_index++; if (m_index < m_collections.size()) { m_current = m_collections.get(m_index).flatten().getEsriGeometryCursor(); continue; } else { m_collections = null; m_index = -1; } } } return null; }
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 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; }