use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class MultiPolygonSegment method next.
@Override
public Segment next() {
this.segmentIndex++;
final Polygonal polygonal = this.polygonal;
final int geometryCount = polygonal.getGeometryCount();
while (this.partIndex < geometryCount) {
final Polygon polygon = getPolygon();
final int ringCount = polygon.getRingCount();
while (this.ringIndex < ringCount) {
final LinearRing ring = polygon.getRing(this.ringIndex);
if (this.segmentIndex < ring.getSegmentCount()) {
return this;
} else {
this.ringIndex++;
this.segmentIndex = 0;
}
}
this.partIndex++;
this.ringIndex = 0;
this.segmentIndex = 0;
}
throw new NoSuchElementException();
}
use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class GeometryGraph method computeSelfNodes.
/**
* Compute self-nodes, taking advantage of the Geometry type to
* minimize the number of intersection tests. (E.g. rings are
* not tested for self-intersection, since they are assumed to be valid).
* @param li the LineIntersector to use
* @param computeRingSelfNodes if <false>, intersection checks are optimized to not test rings for self-intersection
* @return the SegmentIntersector used, containing information about the intersections found
*/
public SegmentIntersector computeSelfNodes(final LineIntersector li, final boolean computeRingSelfNodes) {
final SegmentIntersector si = new SegmentIntersector(li, true, false);
final EdgeSetIntersector esi = newEdgeSetIntersector();
// optimized test for Polygons and Rings
if (!computeRingSelfNodes && (this.geometry instanceof LinearRing || this.geometry instanceof Polygonal)) {
esi.computeIntersections(this.edges, si, false);
} else {
esi.computeIntersections(this.edges, si, true);
}
// System.out.println("SegmentIntersector # tests = " + si.numTests);
addSelfIntersectionNodes(this.argIndex);
return si;
}
use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class CascadedPolygonUnion method unionOptimized.
private Polygonal unionOptimized(final Polygonal polygonal1, final Polygonal polygonal2) {
final BoundingBox boundingBox1 = polygonal1.getBoundingBox();
final BoundingBox boundingBox2 = polygonal2.getBoundingBox();
// *
if (!boundingBox1.intersects(boundingBox2)) {
final Polygonal polygonal = this.geometryFactory.geometry(polygonal1, polygonal2);
return polygonal;
} else if (polygonal1.getGeometryCount() <= 1 && polygonal2.getGeometryCount() <= 1) {
return unionActual(polygonal1, polygonal2);
} else {
final BoundingBox boundingBoxIntersection = boundingBox1.intersection(boundingBox2);
return unionUsingEnvelopeIntersection(polygonal1, polygonal2, boundingBoxIntersection);
}
}
use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class CascadedPolygonUnion method reduceToGeometries.
/**
* Reduces a tree of geometries to a list of geometries
* by recursively unioning the subtrees in the list.
*
* @param geomTree a tree-structured list of geometries
* @return a list of Geometrys
*/
private List<Polygonal> reduceToGeometries(final List<?> items) {
final List<Polygonal> geoms = new ArrayList<>();
for (final Object item : items) {
Polygonal polygon = null;
if (item instanceof List) {
final List<?> childItems = (List<?>) item;
polygon = unionTree(childItems);
} else if (item instanceof Polygonal) {
polygon = (Polygonal) item;
}
geoms.add(polygon);
}
return geoms;
}
use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class CascadedPolygonUnion method unionTree.
/**
* Recursively unions all subtrees in the list into single geometries.
* The result is a list of Geometrys only
*/
private Polygonal unionTree(final List<?> items) {
final List<Polygonal> geoms = reduceToGeometries(items);
final Polygonal union = binaryUnion(geoms);
return union;
}
Aggregations