use of com.revolsys.geometry.graph.Edge in project com.revolsys.open by revolsys.
the class BoundingBoxIntersectsEdgeVisitor method getEdges.
public static <T> List<Edge<T>> getEdges(final Graph<T> graph, final Edge<T> edge, final double maxDistance) {
final CreateListVisitor<Edge<T>> results = new CreateListVisitor<>();
final LineString line = edge.getLineString();
BoundingBox boundingBox = line.getBoundingBox();
boundingBox = boundingBox.expand(maxDistance);
final BoundingBoxIntersectsEdgeVisitor<T> visitor = new BoundingBoxIntersectsEdgeVisitor<>(boundingBox, results);
final IdObjectIndex<Edge<T>> index = graph.getEdgeIndex();
index.forEach(boundingBox, visitor);
final List<Edge<T>> list = results.getList();
list.remove(edge);
return list;
}
use of com.revolsys.geometry.graph.Edge in project com.revolsys.open by revolsys.
the class EdgeIntersectsLinearlyEdgeVisitor method getEdges.
public static <T> List<Edge<T>> getEdges(final Graph<T> graph, final Edge<T> edge) {
final CreateListVisitor<Edge<T>> results = new CreateListVisitor<>();
final LineString line = edge.getLineString();
final BoundingBox env = line.getBoundingBox();
final IdObjectIndex<Edge<T>> index = graph.getEdgeIndex();
index.forEach(env, new EdgeIntersectsLinearlyEdgeVisitor<>(edge, results));
final List<Edge<T>> edges = results.getList();
Collections.sort(edges);
return edges;
}
use of com.revolsys.geometry.graph.Edge in project com.revolsys.open by revolsys.
the class EdgeLessThanDistanceToNodeVisitor method edgesWithinDistance.
public static <T> List<Edge<T>> edgesWithinDistance(final Graph<T> graph, final Node<T> node, final double maxDistance) {
final CreateListVisitor<Edge<T>> results = new CreateListVisitor<>();
final Point point = node;
BoundingBox env = point.getBoundingBox();
env = env.expand(maxDistance);
graph.getEdgeIndex().forEach(env, new EdgeLessThanDistanceToNodeVisitor<>(node, maxDistance, results));
return results.getList();
}
use of com.revolsys.geometry.graph.Edge in project com.revolsys.open by revolsys.
the class EqualTypeAndLineEdgeCleanupVisitor method processEqualEdge.
private void processEqualEdge(final Edge<Record> edge1, final Edge<Record> edge2) {
final Record record1 = edge1.getObject();
final Record record2 = edge2.getObject();
final boolean equalAttributes = record1.equalValuesExclude(record2, this.equalExcludeFieldNames);
final LineString line1 = edge1.getLineString();
int compare = 0;
final Comparator<Edge<Record>> comparator = getComparator();
if (comparator != null) {
compare = comparator.compare(edge1, edge2);
}
if (compare == 0) {
if (equalAttributes) {
boolean equalExcludedAttributes = true;
for (final String name : this.equalExcludeFieldNames) {
if (!record1.equalValue(record2, name)) {
equalExcludedAttributes = false;
}
}
final LineString line2 = edge2.getLineString();
final boolean equalZ = fixMissingZValues(line1, line2);
if (equalExcludedAttributes) {
if (equalZ) {
removeDuplicate(edge2, edge1);
} else {
RecordLog.error(getClass(), "Equal geometry with different coordinates or Z-values", record1);
}
} else {
RecordLog.error(getClass(), "Equal geometry with different attributes: ", record1);
}
} else {
RecordLog.error(getClass(), "Equal geometry with different attributes: ", record1);
}
} else {
removeDuplicate(edge2, edge1);
}
}
use of com.revolsys.geometry.graph.Edge 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);
}
}
}
}
}
}
Aggregations