Search in sources :

Example 1 with IdObjectIndex

use of com.revolsys.geometry.index.IdObjectIndex in project com.revolsys.open by revolsys.

the class Graph method getNodes.

/**
 * Find the nodes <= the distance of the specified geometry.
 *
 * @param geometry The geometry.
 * @param maxDistance The maximum distance.
 * @return The list of nodes.
 */
public List<Node<T>> getNodes(final Geometry geometry, final double maxDistance) {
    BoundingBox boundingBox = geometry.getBoundingBox();
    boundingBox = boundingBox.expand(maxDistance);
    final IdObjectIndex<Node<T>> nodeIndex = getNodeIndex();
    final Predicate<? super Node<T>> filter = (node) -> {
        final double distance = geometry.distancePoint(node);
        return distance <= maxDistance;
    };
    return BoundingBox.newArraySorted(nodeIndex::forEach, boundingBox, filter);
}
Also used : Arrays(java.util.Arrays) ComparatorProxy(com.revolsys.comparator.ComparatorProxy) IdObjectIndex(com.revolsys.geometry.index.IdObjectIndex) LineSegmentUtil(com.revolsys.geometry.model.coordinates.LineSegmentUtil) EdgeEvent(com.revolsys.geometry.graph.event.EdgeEvent) PreDestroy(javax.annotation.PreDestroy) GeometryFactoryProxy(com.revolsys.geometry.model.GeometryFactoryProxy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) PredicateProxy(com.revolsys.predicate.PredicateProxy) Method(java.lang.reflect.Method) PointComparators(com.revolsys.geometry.model.coordinates.comparator.PointComparators) NodeProperties(com.revolsys.geometry.graph.attribute.NodeProperties) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) IntHashMap(com.revolsys.collection.map.IntHashMap) EdgeEventListenerList(com.revolsys.geometry.graph.event.EdgeEventListenerList) PointDoubleXYZ(com.revolsys.geometry.model.impl.PointDoubleXYZ) List(java.util.List) NodeEventListener(com.revolsys.geometry.graph.event.NodeEventListener) Entry(java.util.Map.Entry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ExitLoopException(com.revolsys.util.ExitLoopException) Point(com.revolsys.geometry.model.Point) EdgeEventListener(com.revolsys.geometry.graph.event.EdgeEventListener) NodeWithinBoundingBoxVisitor(com.revolsys.geometry.graph.visitor.NodeWithinBoundingBoxVisitor) LineString(com.revolsys.geometry.model.LineString) HashMap(java.util.HashMap) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Record(com.revolsys.record.Record) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) BPlusTreeMap(com.revolsys.collection.bplus.BPlusTreeMap) CoordinatesDistanceComparator(com.revolsys.geometry.model.coordinates.comparator.CoordinatesDistanceComparator) MapEx(com.revolsys.collection.map.MapEx) SerializablePageValueManager(com.revolsys.io.page.SerializablePageValueManager) WeakReference(java.lang.ref.WeakReference) LinkedList(java.util.LinkedList) Iterator(java.util.Iterator) PageValueManager(com.revolsys.io.page.PageValueManager) IsPointOnLineEdgeFilter(com.revolsys.geometry.graph.filter.IsPointOnLineEdgeFilter) LineStringDouble(com.revolsys.geometry.model.impl.LineStringDouble) NodeEvent(com.revolsys.geometry.graph.event.NodeEvent) Consumer(java.util.function.Consumer) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) TreeMap(java.util.TreeMap) BoundingBoxProxy(com.revolsys.geometry.model.BoundingBoxProxy) Predicates(com.revolsys.predicate.Predicates) NodeDistanceComparator(com.revolsys.geometry.graph.comparator.NodeDistanceComparator) Comparator(java.util.Comparator) NodeEventListenerList(com.revolsys.geometry.graph.event.NodeEventListenerList) Geometry(com.revolsys.geometry.model.Geometry) BaseObjectWithProperties(com.revolsys.properties.BaseObjectWithProperties) Collections(java.util.Collections) BoundingBox(com.revolsys.geometry.model.BoundingBox) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Aggregations

BPlusTreeMap (com.revolsys.collection.bplus.BPlusTreeMap)1 IntHashMap (com.revolsys.collection.map.IntHashMap)1 MapEx (com.revolsys.collection.map.MapEx)1 ComparatorProxy (com.revolsys.comparator.ComparatorProxy)1 NodeProperties (com.revolsys.geometry.graph.attribute.NodeProperties)1 NodeDistanceComparator (com.revolsys.geometry.graph.comparator.NodeDistanceComparator)1 EdgeEvent (com.revolsys.geometry.graph.event.EdgeEvent)1 EdgeEventListener (com.revolsys.geometry.graph.event.EdgeEventListener)1 EdgeEventListenerList (com.revolsys.geometry.graph.event.EdgeEventListenerList)1 NodeEvent (com.revolsys.geometry.graph.event.NodeEvent)1 NodeEventListener (com.revolsys.geometry.graph.event.NodeEventListener)1 NodeEventListenerList (com.revolsys.geometry.graph.event.NodeEventListenerList)1 IsPointOnLineEdgeFilter (com.revolsys.geometry.graph.filter.IsPointOnLineEdgeFilter)1 NodeWithinBoundingBoxVisitor (com.revolsys.geometry.graph.visitor.NodeWithinBoundingBoxVisitor)1 IdObjectIndex (com.revolsys.geometry.index.IdObjectIndex)1 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 BoundingBoxProxy (com.revolsys.geometry.model.BoundingBoxProxy)1 Geometry (com.revolsys.geometry.model.Geometry)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 GeometryFactoryProxy (com.revolsys.geometry.model.GeometryFactoryProxy)1