Search in sources :

Example 11 with Location

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

the class PreparedLinearRing method isPointInRing.

@Override
public boolean isPointInRing(final double x, final double y) {
    final PointOnGeometryLocator pointLocator = getPointLocator();
    final Location location = pointLocator.locate(x, y);
    return location != Location.EXTERIOR;
}
Also used : PointOnGeometryLocator(com.revolsys.geometry.algorithm.locate.PointOnGeometryLocator) Location(com.revolsys.geometry.model.Location)

Example 12 with Location

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

the class DirectedEdgeStar method findCoveredLineEdges.

/**
 * Traverse the star of edges, maintaing the current location in the result
 * area at this node (if any).
 * If any L edges are found in the interior of the result, mark them as covered.
 */
public void findCoveredLineEdges() {
    // Debug.print("findCoveredLineEdges");
    // Debug.print(this);
    // Since edges are stored in CCW order around the node,
    // as we move around the ring we move from the right to the left side of the
    // edge
    /**
     * Find first DirectedEdge of result area (if any).
     * The interior of the result is on the RHS of the edge,
     * so the start location will be:
     * - INTERIOR if the edge is outgoing
     * - EXTERIOR if the edge is incoming
     */
    Location startLoc = Location.NONE;
    for (final DirectedEdge nextOut : this) {
        final DirectedEdge nextIn = nextOut.getSym();
        if (!nextOut.isLineEdge()) {
            if (nextOut.isInResult()) {
                startLoc = Location.INTERIOR;
                break;
            }
            if (nextIn.isInResult()) {
                startLoc = Location.EXTERIOR;
                break;
            }
        }
    }
    // no A edges found, so can't determine if L edges are covered or not
    if (startLoc == Location.NONE) {
        return;
    }
    /**
     * move around ring, keeping track of the current location
     * (Interior or Exterior) for the result area.
     * If L edges are found, mark them as covered if they are in the interior
     */
    Location currLoc = startLoc;
    for (final DirectedEdge nextOut : this) {
        final DirectedEdge nextIn = nextOut.getSym();
        if (nextOut.isLineEdge()) {
            nextOut.getEdge().setCovered(currLoc == Location.INTERIOR);
        // Debug.println(nextOut);
        } else {
            // edge is an Area edge
            if (nextOut.isInResult()) {
                currLoc = Location.EXTERIOR;
            }
            if (nextIn.isInResult()) {
                currLoc = Location.INTERIOR;
            }
        }
    }
}
Also used : Location(com.revolsys.geometry.model.Location)

Example 13 with Location

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

the class DirectedEdgeStar method computeLabelling.

/**
 * Compute the labelling for all dirEdges in this star, as well
 * as the overall labelling
 */
@Override
public void computeLabelling(final GeometryGraph[] geom) {
    // Debug.print(this);
    super.computeLabelling(geom);
    // determine the overall labelling for this DirectedEdgeStar
    // (i.e. for the node it is based at)
    this.label = new Label(Location.NONE);
    for (final DirectedEdge de : this) {
        final Edge e = de.getEdge();
        final Label eLabel = e.getLabel();
        for (int i = 0; i < 2; i++) {
            final Location eLoc = eLabel.getLocation(i);
            if (eLoc == Location.INTERIOR || eLoc == Location.BOUNDARY) {
                this.label.setLocation(i, Location.INTERIOR);
            }
        }
    }
// Debug.print(this);
}
Also used : Location(com.revolsys.geometry.model.Location)

Example 14 with Location

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

the class EdgeEndStar method checkAreaLabelsConsistent.

private boolean checkAreaLabelsConsistent(final int geomIndex) {
    // Since edges are stored in CCW order around the node,
    // As we move around the ring we move from the right to the left side of the
    // edge
    final List<E> edges = getEdges();
    // if no edges, trivially consistent
    if (edges.size() <= 0) {
        return true;
    }
    // initialize startLoc to location of last L side (if any)
    final int lastEdgeIndex = edges.size() - 1;
    final Label startLabel = ((EdgeEnd) edges.get(lastEdgeIndex)).getLabel();
    final Location startLoc = startLabel.getLocation(geomIndex, Position.LEFT);
    Assert.isTrue(startLoc != Location.NONE, "Found unlabelled area edge");
    Location currLoc = startLoc;
    for (final EdgeEnd e : this) {
        final Label label = e.getLabel();
        // we assume that we are only checking a area
        Assert.isTrue(label.isArea(geomIndex), "Found non-area edge");
        final Location leftLoc = label.getLocation(geomIndex, Position.LEFT);
        final Location rightLoc = label.getLocation(geomIndex, Position.RIGHT);
        // check that edge is really a boundary between inside and outside!
        if (leftLoc == rightLoc) {
            return false;
        }
        // Assert.isTrue(rightLoc == currLoc, "side location conflict " + locStr);
        if (rightLoc != currLoc) {
            // Debug.print(this);
            return false;
        }
        currLoc = leftLoc;
    }
    return true;
}
Also used : Point(com.revolsys.geometry.model.Point) Location(com.revolsys.geometry.model.Location)

Example 15 with Location

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

the class EdgeEndStar method getLocation.

private Location getLocation(final int geomIndex, final double x, final double y, final GeometryGraph[] geom) {
    // compute location only on demand
    Location location = this.ptInAreaLocation[geomIndex];
    if (location == Location.NONE) {
        final Geometry geometry = geom[geomIndex].getGeometry();
        location = SimplePointInAreaLocator.locate(geometry, x, y);
        this.ptInAreaLocation[geomIndex] = location;
    }
    return location;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) 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