use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class EdgeEndStar method propagateSideLabels.
void propagateSideLabels(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
Location startLoc = Location.NONE;
// System.out.println("finding start location");
for (final EdgeEnd e : this) {
final Label label = e.getLabel();
if (label.isArea(geomIndex) && label.getLocation(geomIndex, Position.LEFT) != Location.NONE) {
startLoc = label.getLocation(geomIndex, Position.LEFT);
}
}
// no labelled sides found, so no labels to propagate
if (startLoc == Location.NONE) {
return;
}
Location currLoc = startLoc;
for (final EdgeEnd e : this) {
final Label label = e.getLabel();
// set null ON values to be in current location
if (label.getLocation(geomIndex, Position.ON) == Location.NONE) {
label.setLocation(geomIndex, Position.ON, currLoc);
}
// set side labels (if any)
if (label.isArea(geomIndex)) {
final Location leftLoc = label.getLocation(geomIndex, Position.LEFT);
final Location rightLoc = label.getLocation(geomIndex, Position.RIGHT);
// if there is a right location, that is the next location to propagate
if (rightLoc != Location.NONE) {
// Debug.print(rightLoc != currLoc, this);
if (rightLoc != currLoc) {
throw new TopologyException("side location conflict", e.getCoordinate());
}
if (leftLoc == Location.NONE) {
Assert.shouldNeverReachHere("found single null side (at " + e.getCoordinate() + ")");
}
currLoc = leftLoc;
} else {
/**
* RHS is null - LHS must be null too.
* This must be an edge from the other geometry, which has no location
* labelling for this geometry. This edge must lie wholly inside or outside
* the other geometry (which is determined by the current location).
* Assign both sides to be the current location.
*/
if (label.getLocation(geomIndex, Position.LEFT) != Location.NONE) {
throw new IllegalStateException("found single null side");
}
label.setLocation(geomIndex, Position.RIGHT, currLoc);
label.setLocation(geomIndex, Position.LEFT, currLoc);
}
}
}
}
use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class Node method setLabelBoundary.
/**
* Updates the label of a node to BOUNDARY,
* obeying the mod-2 boundaryDetermination rule.
*/
public void setLabelBoundary(final int argIndex) {
if (this.label == null) {
return;
}
// determine the current location for the point (if any)
Location loc = Location.NONE;
if (this.label != null) {
loc = this.label.getLocation(argIndex);
}
// flip the loc
Location newLoc;
switch(loc) {
case BOUNDARY:
newLoc = Location.INTERIOR;
break;
case INTERIOR:
newLoc = Location.BOUNDARY;
break;
default:
newLoc = Location.BOUNDARY;
break;
}
this.label.setLocation(argIndex, newLoc);
}
use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class Node method mergeLabel.
/**
* To merge labels for two nodes,
* the merged location for each LabelElement is computed.
* The location for the corresponding node LabelElement is set to the result,
* as long as the location is non-null.
*/
public void mergeLabel(final Label label2) {
for (int i = 0; i < 2; i++) {
final Location loc = computeMergedLocation(label2, i);
final Location thisLoc = this.label.getLocation(i);
if (thisLoc == Location.NONE) {
this.label.setLocation(i, loc);
}
}
}
use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class Buffer method depthDelta.
/**
* Compute the change in depth as an edge is crossed from R to L
*/
private static int depthDelta(final Label label) {
final Location lLoc = label.getLocation(0, Position.LEFT);
final Location rLoc = label.getLocation(0, Position.RIGHT);
if (lLoc == Location.INTERIOR && rLoc == Location.EXTERIOR) {
return 1;
} else if (lLoc == Location.EXTERIOR && rLoc == Location.INTERIOR) {
return -1;
}
return 0;
}
use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class PointInAreaStressTester method testPIA.
/**
* @param p
* @return true if the point location is determined to be the same by both PIA locaters
*/
private boolean testPIA(final Point p) {
// System.out.println(WKTWriter.toPoint(p));
final Location loc1 = this.pia1.locate(p);
final Location loc2 = this.pia2.locate(p);
this.locationCount[loc1.getIndex()]++;
if ((loc1 == Location.BOUNDARY || loc2 == Location.BOUNDARY) && this.ignoreBoundaryResults) {
return true;
}
return loc1 == loc2;
}
Aggregations