Search in sources :

Example 21 with Location

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

the class OffsetCurveSetBuilder method addPolygonRing.

/**
 * Adds an offset curve for a polygon ring.
 * The side and left and right topological location arguments
 * assume that the ring is oriented CW.
 * If the ring is in the opposite orientation,
 * the left and right locations must be interchanged and the side flipped.
 *
 * @param points the coordinates of the ring (must not contain repeated points)
 * @param offsetDistance the distance at which to create the buffer
 * @param side the side of the ring on which to construct the buffer line
 * @param cwLeftLoc the location on the L side of the ring (if it is CW)
 * @param cwRightLoc the location on the R side of the ring (if it is CW)
 */
private void addPolygonRing(final LineString points, final boolean clockwise, final double offsetDistance, int side, final Location cwLeftLoc, final Location cwRightLoc) {
    // don't bother adding ring if it is "flat" and will disappear in the output
    if (offsetDistance == 0.0 && points.getVertexCount() < 4) {
        return;
    }
    Location leftLoc = cwLeftLoc;
    Location rightLoc = cwRightLoc;
    if (points.getVertexCount() >= 4 && !clockwise) {
        leftLoc = cwRightLoc;
        rightLoc = cwLeftLoc;
        side = Position.opposite(side);
    }
    final LineString curve = this.curveBuilder.getRingCurve(points, side, offsetDistance);
    addCurve(curve, leftLoc, rightLoc);
}
Also used : LineString(com.revolsys.geometry.model.LineString) Location(com.revolsys.geometry.model.Location)

Example 22 with Location

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

the class RelateComputer method computeIntersectionNodes.

/**
 * Insert nodes for all intersections on the edges of a Geometry.
 * Label the created nodes the same as the edge label if they do not already have a label.
 * This allows nodes created by either self-intersections or
 * mutual intersections to be labelled.
 * Endpoint nodes will already be labelled from when they were inserted.
 */
private void computeIntersectionNodes(final int argIndex) {
    for (final Iterator i = this.arg[argIndex].getEdgeIterator(); i.hasNext(); ) {
        final Edge e = (Edge) i.next();
        final Location eLoc = e.getLabel().getLocation(argIndex);
        for (final Object element : e.getEdgeIntersectionList()) {
            final EdgeIntersection ei = (EdgeIntersection) element;
            final RelateNode n = (RelateNode) this.nodes.addNode(ei.newPoint2D());
            if (eLoc == Location.BOUNDARY) {
                n.setLabelBoundary(argIndex);
            } else {
                if (n.getLabel().isNull(argIndex)) {
                    n.setLabel(argIndex, Location.INTERIOR);
                }
            }
        // Debug.println(n);
        }
    }
}
Also used : Iterator(java.util.Iterator) EdgeIntersection(com.revolsys.geometry.geomgraph.EdgeIntersection) Edge(com.revolsys.geometry.geomgraph.Edge) Location(com.revolsys.geometry.model.Location)

Example 23 with Location

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

the class RelateNodeGraph method computeIntersectionNodes.

/**
 * Insert nodes for all intersections on the edges of a Geometry.
 * Label the created nodes the same as the edge label if they do not already have a label.
 * This allows nodes created by either self-intersections or
 * mutual intersections to be labelled.
 * Endpoint nodes will already be labelled from when they were inserted.
 * <p>
 * Precondition: edge intersections have been computed.
 */
public void computeIntersectionNodes(final GeometryGraph geomGraph, final int argIndex) {
    for (final Edge edge : geomGraph.edges()) {
        final Location eLoc = edge.getLabel().getLocation(argIndex);
        for (final Object element : edge.getEdgeIntersectionList()) {
            final EdgeIntersection ei = (EdgeIntersection) element;
            final RelateNode n = (RelateNode) this.nodes.addNode(ei.newPoint2D());
            if (eLoc == Location.BOUNDARY) {
                n.setLabelBoundary(argIndex);
            } else {
                if (n.getLabel().isNull(argIndex)) {
                    n.setLabel(argIndex, Location.INTERIOR);
                }
            }
        }
    }
}
Also used : EdgeIntersection(com.revolsys.geometry.geomgraph.EdgeIntersection) Edge(com.revolsys.geometry.geomgraph.Edge) Location(com.revolsys.geometry.model.Location)

Example 24 with Location

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

the class OverlayOp method isResultOfOp.

/**
 * Tests whether a point with a given topological {@link Label}
 * relative to two geometries is contained in
 * the result of overlaying the geometries using
 * a given overlay operation.
 * <p>
 * The method handles arguments of {@link Location#NONE} correctly
 *
 * @param label the topological label of the point
 * @param opCode the code for the overlay operation to test
 * @return true if the label locations correspond to the overlayOpCode
 */
public static boolean isResultOfOp(final Label label, final int opCode) {
    final Location loc0 = label.getLocation(0);
    final Location loc1 = label.getLocation(1);
    return isResultOfOp(loc0, loc1, opCode);
}
Also used : Location(com.revolsys.geometry.model.Location)

Example 25 with Location

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

the class PointInAreaPerfTester method run.

/**
 * @return true if all point locations were computed correctly
 */
public boolean run() {
    final Stopwatch sw = new Stopwatch();
    final int ptGridWidth = (int) Math.sqrt(this.numPts);
    final BoundingBox areaEnv = this.area.getBoundingBox();
    final double xStep = areaEnv.getWidth() / (ptGridWidth - 1);
    final double yStep = areaEnv.getHeight() / (ptGridWidth - 1);
    for (int i = 0; i < ptGridWidth; i++) {
        for (int j = 0; j < ptGridWidth; j++) {
            // compute test point
            final double x = this.geomFactory.makePrecise(0, areaEnv.getMinX() + i * xStep);
            final double y = this.geomFactory.makePrecise(1, areaEnv.getMinY() + j * yStep);
            final Point pt = new PointDoubleXY(x, y);
            final Location loc = this.pia1.locate(pt);
            this.locationCount[loc.getIndex()]++;
        }
    }
    // System.out.println("Test completed in " + sw.getTimeString());
    printStats();
    return true;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) Stopwatch(com.revolsys.geometry.util.Stopwatch) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point) 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