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