use of com.revolsys.geometry.geomgraph.Depth 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.Depth 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);
}
}
Aggregations