use of com.revolsys.geometry.geomgraph.EdgeIntersection 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.geomgraph.EdgeIntersection 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.geomgraph.EdgeIntersection in project com.revolsys.open by revolsys.
the class IsValidOp method checkNoSelfIntersectingRing.
/**
* Check that a ring does not self-intersect, except at its endpoints.
* Algorithm is to count the number of times each node along edge occurs.
* If any occur more than once, that must be a self-intersection.
*/
private boolean checkNoSelfIntersectingRing(final EdgeIntersectionList eiList) {
boolean valid = true;
final Set<Point> nodeSet = new TreeSet<>();
boolean isFirst = true;
for (final EdgeIntersection ei : eiList) {
if (isFirst) {
isFirst = false;
} else if (nodeSet.contains(ei)) {
valid = false;
addError(new TopologyValidationError(TopologyValidationError.RING_SELF_INTERSECTION, ei.newPoint2D()));
if (isErrorReturn()) {
return false;
}
} else {
nodeSet.add(ei.newPoint2D());
}
}
return valid;
}
use of com.revolsys.geometry.geomgraph.EdgeIntersection in project com.revolsys.open by revolsys.
the class EdgeEndBuilder method computeEdgeEnds.
/**
* Creates stub edges for all the intersections in this
* Edge (if any) and inserts them into the graph.
*/
public void computeEdgeEnds(final Edge edge, final List<EdgeEnd> l) {
final EdgeIntersectionList eiList = edge.getEdgeIntersectionList();
// Debug.print(eiList);
// ensure that the list has entries for the first and last point of the edge
eiList.addEndpoints();
final Iterator<EdgeIntersection> it = eiList.iterator();
EdgeIntersection eiPrev = null;
EdgeIntersection eiCurr = null;
// no intersections, so there is nothing to do
if (!it.hasNext()) {
return;
}
EdgeIntersection eiNext = it.next();
do {
eiPrev = eiCurr;
eiCurr = eiNext;
eiNext = null;
if (it.hasNext()) {
eiNext = it.next();
}
if (eiCurr != null) {
newEdgeEndForPrev(edge, l, eiCurr, eiPrev);
newEdgeEndForNext(edge, l, eiCurr, eiNext);
}
} while (eiCurr != null);
}
Aggregations