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);
}
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);
}
}
}
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);
}
}
}
}
}
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);
}
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;
}
Aggregations