Search in sources :

Example 16 with Polygonal

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();
}
Also used : Polygonal(com.revolsys.geometry.model.Polygonal) Polygon(com.revolsys.geometry.model.Polygon) LinearRing(com.revolsys.geometry.model.LinearRing) NoSuchElementException(java.util.NoSuchElementException)

Example 17 with Polygonal

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;
}
Also used : Polygonal(com.revolsys.geometry.model.Polygonal) SegmentIntersector(com.revolsys.geometry.geomgraph.index.SegmentIntersector) EdgeSetIntersector(com.revolsys.geometry.geomgraph.index.EdgeSetIntersector) LinearRing(com.revolsys.geometry.model.LinearRing)

Example 18 with Polygonal

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);
    }
}
Also used : Polygonal(com.revolsys.geometry.model.Polygonal) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 19 with Polygonal

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;
}
Also used : Polygonal(com.revolsys.geometry.model.Polygonal) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 20 with Polygonal

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;
}
Also used : Polygonal(com.revolsys.geometry.model.Polygonal)

Aggregations

Polygonal (com.revolsys.geometry.model.Polygonal)41 Polygon (com.revolsys.geometry.model.Polygon)17 LinearRing (com.revolsys.geometry.model.LinearRing)12 Point (com.revolsys.geometry.model.Point)12 LineString (com.revolsys.geometry.model.LineString)9 Lineal (com.revolsys.geometry.model.Lineal)9 Punctual (com.revolsys.geometry.model.Punctual)9 Geometry (com.revolsys.geometry.model.Geometry)8 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 PolygonalEditor (com.revolsys.geometry.model.editor.PolygonalEditor)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)4 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)2 PathName (com.revolsys.io.PathName)2 Record (com.revolsys.record.Record)2 NoSuchElementException (java.util.NoSuchElementException)2 LocateFailureException (com.revolsys.elevation.tin.quadedge.LocateFailureException)1 QuadEdgeConformingDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeConformingDelaunayTinBuilder)1 IndexedPointInAreaLocator (com.revolsys.geometry.algorithm.locate.IndexedPointInAreaLocator)1