use of com.revolsys.geometry.model.End in project com.revolsys.open by revolsys.
the class NodeRemovalVisitor method accept.
@Override
public void accept(final Node<Record> node) {
if (node.getDegree() == 2) {
final List<Edge<Record>> edges = node.getEdges();
if (edges.size() == 2) {
final Edge<Record> edge1 = edges.get(0);
final Edge<Record> edge2 = edges.get(1);
if (edge1 != edge2) {
final Record object1 = edge1.getObject();
final Record object2 = edge2.getObject();
if (DataType.equal(object1, object2, this.excludedFieldNames)) {
final End end1 = edge1.getEnd(node);
if (end1 == edge2.getEnd(node)) {
// if (!fixReversedEdges(node, reversedEdges, edge1, edge2)) {
return;
// }
}
if (end1.isFrom()) {
this.graph.merge(node, edge2, edge1);
} else {
this.graph.merge(node, edge1, edge2);
}
}
}
}
}
}
use of com.revolsys.geometry.model.End in project com.revolsys.open by revolsys.
the class PolygonNodeRemovalVisitor method accept.
@Override
public void accept(final Node<Record> node) {
final Set<Edge<Record>> edges = new LinkedHashSet<>(node.getEdges());
while (edges.size() > 1) {
final Edge<Record> edge = edges.iterator().next();
final Record object = edge.getObject();
final Set<Edge<Record>> matchedEdges = new HashSet<>();
final End end = edge.getEnd(node);
for (final Edge<Record> matchEdge : edges) {
final Record matchObject = matchEdge.getObject();
if (edge != matchEdge) {
final End matchEnd = matchEdge.getEnd(node);
if (end != matchEnd) {
if (DataType.equal(object, matchObject, this.excludedAttributes)) {
matchedEdges.add(matchEdge);
}
}
}
}
if (matchedEdges.size() == 1) {
final Edge<Record> matchedEdge = matchedEdges.iterator().next();
if (end.isFrom()) {
this.graph.merge(node, matchedEdge, edge);
} else {
this.graph.merge(node, edge, matchedEdge);
}
}
edges.removeAll(matchedEdges);
edges.remove(edge);
}
}
Aggregations