If there was a way to quickly determine what are the graph nodes and graph segments withing a given distance, irrespective of connectivity.
1) Create a Spatial Query Object
spatialQuery = ce.createSpatialQuery()
2) Add Objects to Spatial Query
spatialQuery.addItems( list_of_graph_nodes )
spatialQuery.addItems( list_of_graph_segments )
spatialQuery.addItems( list_of_graph_layers )
3) Parameterize Spatial Query
spatialQuery.setDistance( float )
spatialQuery.setExtents( minx = None , # determine by distance
miny = -10 ,
minz = None , # determine by distance
maxx = None , # determine by distance
maxy = 10 ,
maxz = None ) # determine by distance
spatialQuery.setFilters( ce.isGraphNode, ce.isGraphSegment )
spatialQuery.setMaxItems( 10 )
4) Execute Query
resultList = spatialQuery.execute( x, y, z )
resultList = spatialQuery.execute( aGraphNodeInstance )
resultList = spatialQuery.execute( aGraphNodeSegment )
print len( [ ce.isGraphNode( x ) for x in resultList ] ), 'Graph Nodes'
print len( [ ce.isGraphSegment( x ) for x in resultList ] ), 'Graph Segments'
> 40 Graph Nodes
> 34 Graph Segments
# the output is sorted by distance, closest to farest
# closest to queried coord/element
# farest to queried coord/element
5) if a graphSegment is passed as query location, we could potentially have a mode where it uses its associat. ed graph nodes as query location, or use its centroid, where this decision could be controlled by a spatial query execution argument
6) if a list of elements is passed ( graph nodes, graph segments or tuple ), the centroid position of all elements would be considered.