Search in sources :

Example 26 with Location

use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.

the class EdgeEndBundle method computeLabelOn.

/**
 * Compute the overall ON location for the list of EdgeStubs.
 * (This is essentially equivalent to computing the self-overlay of a single Geometry)
 * edgeStubs can be either on the boundary (eg Polygon edge)
 * OR in the interior (e.g. segment of a LineString)
 * of their parent Geometry.
 * In addition, GeometryCollections use a {@link BoundaryNodeRule} to determine
 * whether a segment is on the boundary or not.
 * Finally, in GeometryCollections it can occur that an edge is both
 * on the boundary and in the interior (e.g. a LineString segment lying on
 * top of a Polygon edge.) In this case the Boundary is given precendence.
 * <br>
 * These observations result in the following rules for computing the ON location:
 * <ul>
 * <li> if there are an odd number of Bdy edges, the attribute is Bdy
 * <li> if there are an even number >= 2 of Bdy edges, the attribute is Int
 * <li> if there are any Int edges, the attribute is Int
 * <li> otherwise, the attribute is NULL.
 * </ul>
 */
private void computeLabelOn(final int geomIndex, final BoundaryNodeRule boundaryNodeRule) {
    // compute the ON location value
    int boundaryCount = 0;
    boolean foundInterior = false;
    for (final EdgeEnd e : this) {
        final Location loc = e.getLabel().getLocation(geomIndex);
        if (loc == Location.BOUNDARY) {
            boundaryCount++;
        }
        if (loc == Location.INTERIOR) {
            foundInterior = true;
        }
    }
    Location loc = Location.NONE;
    if (foundInterior) {
        loc = Location.INTERIOR;
    }
    if (boundaryCount > 0) {
        loc = GeometryGraph.determineBoundary(boundaryNodeRule, boundaryCount);
    }
    getLabel().setLocation(geomIndex, loc);
}
Also used : EdgeEnd(com.revolsys.geometry.geomgraph.EdgeEnd) Location(com.revolsys.geometry.model.Location)

Aggregations

Location (com.revolsys.geometry.model.Location)26 Point (com.revolsys.geometry.model.Point)7 Geometry (com.revolsys.geometry.model.Geometry)5 PointLocator (com.revolsys.geometry.algorithm.PointLocator)2 Edge (com.revolsys.geometry.geomgraph.Edge)2 EdgeIntersection (com.revolsys.geometry.geomgraph.EdgeIntersection)2 LineString (com.revolsys.geometry.model.LineString)2 PointOnGeometryLocator (com.revolsys.geometry.algorithm.locate.PointOnGeometryLocator)1 EdgeEnd (com.revolsys.geometry.geomgraph.EdgeEnd)1 Label (com.revolsys.geometry.geomgraph.Label)1 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 TopologyException (com.revolsys.geometry.model.TopologyException)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1 Stopwatch (com.revolsys.geometry.util.Stopwatch)1 Iterator (java.util.Iterator)1