If there was a way to quickly determine what are the graph nodes and graph segments withing a given distance, irrespective of connectivity.
Proposed Workflow
1) Create a Spatial Query Object
spatialQuery <SPAN class="operator token">=</SPAN> ce<SPAN class="punctuation token">.</SPAN>createSpatialQuery<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
2) Add Objects to Spatial Query
spatialQuery<SPAN class="punctuation token">.</SPAN>addItems<SPAN class="punctuation token">(</SPAN> list_of_graph_nodes <SPAN class="punctuation token">)</SPAN>
spatialQuery<SPAN class="punctuation token">.</SPAN>addItems<SPAN class="punctuation token">(</SPAN> list_of_graph_segments <SPAN class="punctuation token">)</SPAN>
spatialQuery<SPAN class="punctuation token">.</SPAN>addItems<SPAN class="punctuation token">(</SPAN> list_of_graph_layers <SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
3) Parameterize Spatial Query
spatialQuery<SPAN class="punctuation token">.</SPAN>setDistance<SPAN class="punctuation token">(</SPAN> float <SPAN class="punctuation token">)</SPAN>
spatialQuery<SPAN class="punctuation token">.</SPAN>setExtents<SPAN class="punctuation token">(</SPAN> minx <SPAN class="operator token">=</SPAN> None <SPAN class="punctuation token">,</SPAN> <SPAN class="comment token"># determine by distance</SPAN>
miny <SPAN class="operator token">=</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">10</SPAN> <SPAN class="punctuation token">,</SPAN>
minz <SPAN class="operator token">=</SPAN> None <SPAN class="punctuation token">,</SPAN> <SPAN class="comment token"># determine by distance</SPAN>
maxx <SPAN class="operator token">=</SPAN> None <SPAN class="punctuation token">,</SPAN> <SPAN class="comment token"># determine by distance</SPAN>
maxy <SPAN class="operator token">=</SPAN> <SPAN class="number token">10</SPAN> <SPAN class="punctuation token">,</SPAN>
maxz <SPAN class="operator token">=</SPAN> None <SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># determine by distance</SPAN>
spatialQuery<SPAN class="punctuation token">.</SPAN>setFilters<SPAN class="punctuation token">(</SPAN> ce<SPAN class="punctuation token">.</SPAN>isGraphNode<SPAN class="punctuation token">,</SPAN> ce<SPAN class="punctuation token">.</SPAN>isGraphSegment <SPAN class="punctuation token">)</SPAN>
spatialQuery<SPAN class="punctuation token">.</SPAN>setMaxItems<SPAN class="punctuation token">(</SPAN> <SPAN class="number token">10</SPAN> <SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
4) Execute Query
resultList <SPAN class="operator token">=</SPAN> spatialQuery<SPAN class="punctuation token">.</SPAN>execute<SPAN class="punctuation token">(</SPAN> x<SPAN class="punctuation token">,</SPAN> y<SPAN class="punctuation token">,</SPAN> z <SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">or</SPAN>
resultList <SPAN class="operator token">=</SPAN> spatialQuery<SPAN class="punctuation token">.</SPAN>execute<SPAN class="punctuation token">(</SPAN> aGraphNodeInstance <SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">or</SPAN>
resultList <SPAN class="operator token">=</SPAN> spatialQuery<SPAN class="punctuation token">.</SPAN>execute<SPAN class="punctuation token">(</SPAN> aGraphNodeSegment <SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> len<SPAN class="punctuation token">(</SPAN> <SPAN class="punctuation token">[</SPAN> ce<SPAN class="punctuation token">.</SPAN>isGraphNode<SPAN class="punctuation token">(</SPAN> x <SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> resultList <SPAN class="punctuation token">]</SPAN> <SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Graph Nodes'</SPAN>
<SPAN class="keyword token">print</SPAN> len<SPAN class="punctuation token">(</SPAN> <SPAN class="punctuation token">[</SPAN> ce<SPAN class="punctuation token">.</SPAN>isGraphSegment<SPAN class="punctuation token">(</SPAN> x <SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> resultList <SPAN class="punctuation token">]</SPAN> <SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Graph Segments'</SPAN>
<SPAN class="operator token">></SPAN> <SPAN class="number token">40</SPAN> Graph Nodes
<SPAN class="operator token">></SPAN> <SPAN class="number token">34</SPAN> Graph Segments
<SPAN class="comment token"># the output is sorted by distance, closest to farest</SPAN>
<SPAN class="comment token"># closest to queried coord/element</SPAN>
<SPAN class="keyword token">print</SPAN> resultList<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># farest to queried coord/element</SPAN>
<SPAN class="keyword token">print</SPAN> resultList<SPAN class="punctuation token">[</SPAN><SPAN class="operator token">-</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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[3] ), the centroid position of all elements would be considered.