Search in sources :

Example 11 with Edge

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;
}
Also used : LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Edge(com.revolsys.geometry.graph.Edge)

Example 12 with Edge

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;
}
Also used : LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Edge(com.revolsys.geometry.graph.Edge)

Example 13 with Edge

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();
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Point(com.revolsys.geometry.model.Point) Edge(com.revolsys.geometry.graph.Edge)

Example 14 with Edge

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);
    }
}
Also used : LineString(com.revolsys.geometry.model.LineString) Record(com.revolsys.record.Record) LineString(com.revolsys.geometry.model.LineString) Edge(com.revolsys.geometry.graph.Edge)

Example 15 with Edge

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);
                    }
                }
            }
        }
    }
}
Also used : Record(com.revolsys.record.Record) End(com.revolsys.geometry.model.End) Edge(com.revolsys.geometry.graph.Edge)

Aggregations

Edge (com.revolsys.geometry.graph.Edge)40 LineString (com.revolsys.geometry.model.LineString)22 Point (com.revolsys.geometry.model.Point)21 LineSegment (com.revolsys.geometry.model.segment.LineSegment)19 ArrayList (java.util.ArrayList)14 BoundingBox (com.revolsys.geometry.model.BoundingBox)10 PointOnLineSegment (com.revolsys.geometry.model.coordinates.filter.PointOnLineSegment)9 Node (com.revolsys.geometry.graph.Node)8 Geometry (com.revolsys.geometry.model.Geometry)8 LinkedHashSet (java.util.LinkedHashSet)7 Record (com.revolsys.record.Record)6 CreateListVisitor (com.revolsys.visitor.CreateListVisitor)6 HashSet (java.util.HashSet)6 EdgeAttributeValueComparator (com.revolsys.geometry.graph.comparator.EdgeAttributeValueComparator)5 List (java.util.List)5 EdgeObjectFilter (com.revolsys.geometry.graph.filter.EdgeObjectFilter)4 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 LineSegmentDoubleGF (com.revolsys.geometry.model.segment.LineSegmentDoubleGF)4 EdgeTypeNameFilter (com.revolsys.geometry.graph.filter.EdgeTypeNameFilter)2 LineStringGraph (com.revolsys.geometry.graph.linestring.LineStringGraph)2