Skip to content

Commit

Permalink
copies primal edges to dual nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
songololo committed Apr 22, 2024
1 parent f759eb6 commit 5b4628c
Show file tree
Hide file tree
Showing 15 changed files with 637 additions and 574 deletions.
238 changes: 93 additions & 145 deletions docs/src/pages/metrics/layers.md

Large diffs are not rendered by default.

217 changes: 96 additions & 121 deletions docs/src/pages/metrics/networks.md

Large diffs are not rendered by default.

85 changes: 77 additions & 8 deletions docs/src/pages/rustalgos/rustalgos.md
Original file line number Diff line number Diff line change
Expand Up @@ -1875,11 +1875,11 @@ datapoints are not located with high spatial precision.

<div class="function">

## shortest_path_tree
## dijkstra_tree_shortest


<div class="content">
<span class="name">shortest_path_tree</span><div class="signature multiline">
<span class="name">dijkstra_tree_shortest</span><div class="signature multiline">
<span class="pt">(</span>
<div class="param">
<span class="pn">self</span>
Expand All @@ -1895,9 +1895,78 @@ datapoints are not located with high spatial precision.
<span class="pa"> int</span>
</div>
<div class="param">
<span class="pn">angular</span>
<span class="pn">jitter_scale</span>
<span class="pc">:</span>
<span class="pa"> bool | None = None</span>
<span class="pa"> float | None = None</span>
</div>
<span class="pt">)-&gt;[</span>
<span class="pr">ist[int]</span>
<span class="pr">NodeVisit</span>
<span class="pt">]</span>
</div>
</div>

</div>



<div class="function">

## dijkstra_tree_simplest


<div class="content">
<span class="name">dijkstra_tree_simplest</span><div class="signature multiline">
<span class="pt">(</span>
<div class="param">
<span class="pn">self</span>
</div>
<div class="param">
<span class="pn">src_idx</span>
<span class="pc">:</span>
<span class="pa"> int</span>
</div>
<div class="param">
<span class="pn">max_dist</span>
<span class="pc">:</span>
<span class="pa"> int</span>
</div>
<div class="param">
<span class="pn">jitter_scale</span>
<span class="pc">:</span>
<span class="pa"> float | None = None</span>
</div>
<span class="pt">)-&gt;[</span>
<span class="pr">ist[int]</span>
<span class="pr">NodeVisit</span>
<span class="pt">]</span>
</div>
</div>

</div>



<div class="function">

## dijkstra_tree_segment


<div class="content">
<span class="name">dijkstra_tree_segment</span><div class="signature multiline">
<span class="pt">(</span>
<div class="param">
<span class="pn">self</span>
</div>
<div class="param">
<span class="pn">src_idx</span>
<span class="pc">:</span>
<span class="pa"> int</span>
</div>
<div class="param">
<span class="pn">max_dist</span>
<span class="pc">:</span>
<span class="pa"> int</span>
</div>
<div class="param">
<span class="pn">jitter_scale</span>
Expand Down Expand Up @@ -2726,22 +2795,22 @@ datapoints are not located with high spatial precision.



<span class="name">node_xs</span><span class="annotation">: list[float]</span>
<span class="name">node_xys</span><span class="annotation">: list[tuple[float, float]]</span>




<span class="name">node_xys</span><span class="annotation">: list[tuple[float, float]]</span>
<span class="name">node_ys</span><span class="annotation">: list[float]</span>




<span class="name">node_lives</span><span class="annotation">: list[bool]</span>
<span class="name">node_xs</span><span class="annotation">: list[float]</span>




<span class="name">node_ys</span><span class="annotation">: list[float]</span>
<span class="name">node_lives</span><span class="annotation">: list[bool]</span>



Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/tools/graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ primal. The same type of situation does not arise in the dual because the nodes
</div>
<div class="desc">

A dual representation `networkX` graph. The new dual nodes will have `x` and `y` node attributes corresponding to the mid-points of the original primal edges. If `live` node attributes were provided, then the `live` attribute for the new dual nodes will be set to `True` if either or both of the adjacent primal nodes were set to `live=True`. Otherwise, all dual nodes wil be set to `live=True`. The primal `geom` edge attributes will be split and welded to form the new dual `geom` edge attributes. `primal_edge_node_a`, `primal_edge_node_b`, and `primal_edge_idx` attributes will be added to the new (dual) nodes, and a `primal_node_id` edge attribute will be added to the new (dual) edges. This is useful for welding the primal geometry to the dual representations where useful for purposes such as visualisation, or otherwise welding downstream metrics to source (primal) geometries.</div>
A dual representation `networkX` graph. The new dual nodes will have `x` and `y` node attributes corresponding to the mid-points of the original primal edges. If `live` node attributes were provided, then the `live` attribute for the new dual nodes will be set to `True` if either or both of the adjacent primal nodes were set to `live=True`. Otherwise, all dual nodes wil be set to `live=True`. The primal edges will be split and welded to form the new dual `geom` edges. The primal `LineString` `geom` will be saved to the dual node's `primal_edge` attribute. `primal_edge_node_a`, `primal_edge_node_b`, and `primal_edge_idx` attributes will be added to the new (dual) nodes, and a `primal_node_id` edge attribute will be added to the new (dual) edges.</div>
</div>

### Notes
Expand Down
64 changes: 63 additions & 1 deletion docs/src/pages/tools/io.md
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ out qt;
</div>
<div class="desc">

A `gpd.GeoDataFrame` with `live`, `weight`, and `geometry` attributes. The original `networkX` graph's node keys will be used for the `GeoDataFrame` index.</div>
A `gpd.GeoDataFrame` with `live`, `weight`, and `geometry` attributes. The original `networkX` graph's node keys will be used for the `GeoDataFrame` index. If `nx_multigraph` is a dual graph prepared with [`graphs.nx_to_dual`](/tools/graphs#nx-to-dual) then the corresponding primal edge `LineString` geometry will be set as the `GeoPandas` geometry for visualisation purposes using `primal_edge` for the column name. The dual node `Point` geometry will be saved in `WKT` format to the `dual_node` column.</div>
</div>

<div class="param-set">
Expand All @@ -880,6 +880,68 @@ out qt;
</div>


<div class="function">

## network_structure_from_gpd


<div class="content">
<span class="name">network_structure_from_gpd</span><div class="signature multiline">
<span class="pt">(</span>
<div class="param">
<span class="pn">nodes_gdf</span>
<span class="pc">:</span>
<span class="pa"> geopandas.geodataframe.GeoDataFrame</span>
</div>
<div class="param">
<span class="pn">edges_gdf</span>
<span class="pc">:</span>
<span class="pa"> geopandas.geodataframe.GeoDataFrame</span>
</div>
<span class="pt">)-&gt;[</span>
<span class="pr">NetworkStructure</span>
<span class="pt">]</span>
</div>
</div>


Reassembles a `NetworkStructure` from cityseer nodes and edges GeoDataFrames. This method is intended for use with "circular" workflows, where a `cityseer` NetworkX graph has been converted into `cityseer` nodes and edges GeoDataFrames using [`network_structure_from_nx`](#network_structure_from_nx). If the resultant GeoDataFrames are saved to disk and reloaded, then this method can be used to recreate the associated `NetworkStructure` which is required for optimised (`rust`) functions.
### Parameters
<div class="param-set">
<div class="def">
<div class="name">nodes_gdf</div>
<div class="type">gpd.GeoDataFrame</div>
</div>
<div class="desc">

A cityseer created nodes `gpd.GeoDataFrame` where the originating `networkX` graph's node keys have been saved as the DataFrame index, and where the columns contain `x`, `y`, `live`, and `weight` attributes.</div>
</div>

<div class="param-set">
<div class="def">
<div class="name">edges_gdf</div>
<div class="type">gpd.GeoDataFrame</div>
</div>
<div class="desc">

A cityseer created edges `gpd.GeoDataFrame` with `start_ns_node_idx`, `end_ns_node_idx`, `edge_idx`, `nx_start_node_key`, `nx_end_node_key`, `length`, `angle_sum`, `imp_factor`, `in_bearing`, `out_bearing` attributes.</div>
</div>

### Returns
<div class="param-set">
<div class="def">
<div class="name"></div>
<div class="type">rustalgos.NetworkStructure</div>
</div>
<div class="desc">

A [`rustalgos.NetworkStructure`](/rustalgos/rustalgos#networkstructure) instance.</div>
</div>


</div>


<div class="function">

## nx_from_cityseer_geopandas
Expand Down
Loading

0 comments on commit 5b4628c

Please sign in to comment.