use of com.revolsys.geometry.geomgraph.Edge in project com.revolsys.open by revolsys.
the class Buffer method insertUniqueEdge.
/**
* Inserted edges are checked to see if an identical edge already exists.
* If so, the edge is not inserted, but its label is merged
* with the existing edge.
*/
private static void insertUniqueEdge(final EdgeList edgeList, final Edge edge) {
// <FIX> MD 8 Oct 03 speed up identical edge lookup
// fast lookup
final Edge existingEdge = edgeList.findEqualEdge(edge);
// If an identical edge already exists, simply update its label
if (existingEdge != null) {
final Label existingLabel = existingEdge.getLabel();
Label labelToMerge = edge.getLabel();
// if so, must flip the label before merging it
if (!existingEdge.isPointwiseEqual(edge)) {
labelToMerge = new Label(edge.getLabel());
labelToMerge.flip();
}
existingLabel.merge(labelToMerge);
// compute new depth delta of sum of edges
final int mergeDelta = depthDelta(labelToMerge);
final int existingDelta = existingEdge.getDepthDelta();
final int newDelta = existingDelta + mergeDelta;
existingEdge.setDepthDelta(newDelta);
} else {
// no matching existing edge was found
// add this new edge to the list of edges in this graph
// e.setName(name + edges.size());
edgeList.add(edge);
edge.setDepthDelta(depthDelta(edge.getLabel()));
}
}
use of com.revolsys.geometry.geomgraph.Edge in project com.revolsys.open by revolsys.
the class Buffer method computeNodedEdges.
private static void computeNodedEdges(final Noder noder, final EdgeList edges, final List<NodedSegmentString> segments) {
noder.computeNodes(segments);
final Collection<NodedSegmentString> nodedSegments = noder.getNodedSubstrings();
for (final SegmentString segment : nodedSegments) {
final int vertexCount = segment.size();
if (vertexCount > 2 || vertexCount == 2 && !segment.equalsVertex2d(0, 1)) {
final Label oldLabel = (Label) segment.getData();
final Label label = new Label(oldLabel);
final LineString points = segment.getLineString();
final Edge edge = new Edge(points, label);
insertUniqueEdge(edges, edge);
}
}
}
use of com.revolsys.geometry.geomgraph.Edge 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.Edge 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.Edge in project com.revolsys.open by revolsys.
the class RightmostEdgeFinder method findRightmostEdgeAtVertex.
private void findRightmostEdgeAtVertex() {
/**
* The rightmost point is an interior vertex, so it has a segment on either side of it.
* If these segments are both above or below the rightmost point, we need to
* determine their relative orientation to decide which is rightmost.
*/
final Edge edge = this.minDe.getEdge();
Assert.isTrue(this.minIndex > 0 && this.minIndex < edge.getVertexCount(), "rightmost point expected to be interior vertex of edge");
final Point pPrev = edge.getPoint(this.minIndex - 1);
final Point pNext = edge.getPoint(this.minIndex + 1);
final int orientation = CGAlgorithmsDD.orientationIndex(this.minCoord, pNext, pPrev);
boolean usePrev = false;
// both segments are below min point
if (pPrev.getY() < this.minCoord.getY() && pNext.getY() < this.minCoord.getY() && orientation == CGAlgorithms.COUNTERCLOCKWISE) {
usePrev = true;
} else if (pPrev.getY() > this.minCoord.getY() && pNext.getY() > this.minCoord.getY() && orientation == CGAlgorithms.CLOCKWISE) {
usePrev = true;
}
// to select as a rightmost segment
if (usePrev) {
this.minIndex = this.minIndex - 1;
}
}
Aggregations