use of com.revolsys.geometry.geomgraph.Label in project com.revolsys.open by revolsys.
the class OverlayOp method computeLabelsFromDepths.
/**
* If either of the GeometryLocations for the existing label is
* exactly opposite to the one in the labelToMerge,
* this indicates a dimensional collapse has happened.
* In this case, convert the label for that Geometry to a Line label
*/
/*
* NOT NEEDED? private void checkDimensionalCollapse(Label labelToMerge, Label existingLabel) { if
* (existingLabel.isArea() && labelToMerge.isArea()) { for (int i = 0; i < 2; i++) { if (!
* labelToMerge.isNull(i) && labelToMerge.getLocation(i, Position.LEFT) ==
* existingLabel.getLocation(i, Position.RIGHT) && labelToMerge.getLocation(i, Position.RIGHT) ==
* existingLabel.getLocation(i, Position.LEFT) ) { existingLabel.toLine(i); } } } }
*/
/**
* Update the labels for edges according to their depths.
* For each edge, the depths are first normalized.
* Then, if the depths for the edge are equal,
* this edge must have collapsed into a line edge.
* If the depths are not equal, update the label
* with the locations corresponding to the depths
* (i.e. a depth of 0 corresponds to a Location of EXTERIOR,
* a depth of 1 corresponds to INTERIOR)
*/
private void computeLabelsFromDepths() {
for (final Edge e : this.edgeList) {
final Label lbl = e.getLabel();
final Depth depth = e.getDepth();
/**
* Only check edges for which there were duplicates,
* since these are the only ones which might
* be the result of dimensional collapses.
*/
if (!depth.isNull()) {
depth.normalize();
for (int i = 0; i < 2; i++) {
if (!lbl.isNull(i) && lbl.isArea() && !depth.isNull(i)) {
/**
* if the depths are equal, this edge is the result of
* the dimensional collapse of two or more edges.
* It has the same location on both sides of the edge,
* so it has collapsed to a line.
*/
if (depth.getDelta(i) == 0) {
lbl.toLine(i);
} else {
/**
* This edge may be the result of a dimensional collapse,
* but it still has different locations on both sides. The
* label of the edge must be updated to reflect the resultant
* side locations indicated by the depth values.
*/
Assert.isTrue(!depth.isNull(i, Position.LEFT), "depth of LEFT side has not been initialized");
lbl.setLocation(i, Position.LEFT, depth.getLocation(i, Position.LEFT));
Assert.isTrue(!depth.isNull(i, Position.RIGHT), "depth of RIGHT side has not been initialized");
lbl.setLocation(i, Position.RIGHT, depth.getLocation(i, Position.RIGHT));
}
}
}
}
}
}
use of com.revolsys.geometry.geomgraph.Label in project com.revolsys.open by revolsys.
the class OverlayOp method insertUniqueEdge.
/**
* Insert an edge from one of the noded input graphs.
* Checks edges that are inserted to see if an
* identical edge already exists.
* If so, the edge is not inserted, but its label is merged
* with the existing edge.
*/
protected void insertUniqueEdge(final Edge e) {
// <FIX> MD 8 Oct 03 speed up identical edge lookup
// fast lookup
final Edge existingEdge = this.edgeList.findEqualEdge(e);
// If an identical edge already exists, simply update its label
if (existingEdge != null) {
final Label existingLabel = existingEdge.getLabel();
Label labelToMerge = e.getLabel();
// if so, must flip the label before merging it
if (!existingEdge.isPointwiseEqual(e)) {
labelToMerge = new Label(e.getLabel());
labelToMerge.flip();
}
final Depth depth = existingEdge.getDepth();
// /*
if (depth.isNull()) {
depth.add(existingLabel);
}
// */
depth.add(labelToMerge);
existingLabel.merge(labelToMerge);
// Debug.print("inserted edge: "); Debug.println(e);
// Debug.print("existing edge: "); Debug.println(existingEdge);
} else {
// no matching existing edge was found
// add this new edge to the list of edges in this graph
// e.setName(name + edges.size());
// e.getDepth().add(e.getLabel());
this.edgeList.add(e);
}
}
use of com.revolsys.geometry.geomgraph.Label in project com.revolsys.open by revolsys.
the class EdgeEndBuilder method newEdgeEndForPrev.
/**
* Construct a new EdgeStub for the edge before the intersection eiCurr.
* The previous intersection is provided
* in case it is the endpoint for the stub edge.
* Otherwise, the previous point from the parent edge will be the endpoint.
* <br>
* eiCurr will always be an EdgeIntersection, but eiPrev may be null.
*/
void newEdgeEndForPrev(final Edge edge, final List<EdgeEnd> l, final EdgeIntersection eiCurr, final EdgeIntersection eiPrev) {
int iPrev = eiCurr.segmentIndex;
if (eiCurr.dist == 0.0) {
// if at the start of the edge there is no previous edge
if (iPrev == 0) {
return;
}
iPrev--;
}
Point pPrev = edge.getPoint(iPrev);
// if prev intersection is past the previous vertex, use it instead
if (eiPrev != null && eiPrev.segmentIndex >= iPrev) {
pPrev = eiPrev.newPoint2D();
}
final Label label = new Label(edge.getLabel());
// since edgeStub is oriented opposite to it's parent edge, have to flip
// sides for edge label
label.flip();
final EdgeEnd e = new EdgeEnd(edge, eiCurr.getX(), eiCurr.getY(), pPrev.getX(), pPrev.getY(), label);
// e.print(System.out); System.out.println();
l.add(e);
}
use of com.revolsys.geometry.geomgraph.Label in project com.revolsys.open by revolsys.
the class EdgeEndBuilder method newEdgeEndForNext.
/**
* Construct a new StubEdge for the edge after the intersection eiCurr.
* The next intersection is provided
* in case it is the endpoint for the stub edge.
* Otherwise, the next point from the parent edge will be the endpoint.
* <br>
* eiCurr will always be an EdgeIntersection, but eiNext may be null.
*/
void newEdgeEndForNext(final Edge edge, final List<EdgeEnd> l, final EdgeIntersection eiCurr, final EdgeIntersection eiNext) {
final int iNext = eiCurr.segmentIndex + 1;
// if there is no next edge there is nothing to do
if (iNext >= edge.getVertexCount() && eiNext == null) {
return;
}
Point pNext = edge.getPoint(iNext);
// the endpoint
if (eiNext != null && eiNext.segmentIndex == eiCurr.segmentIndex) {
pNext = eiNext.newPoint2D();
}
final EdgeEnd e = new EdgeEnd(edge, eiCurr.getX(), eiCurr.getY(), pNext.getX(), pNext.getY(), new Label(edge.getLabel()));
// Debug.println(e);
l.add(e);
}
Aggregations