Skip to content

Commit

Permalink
fixes test
Browse files Browse the repository at this point in the history
  • Loading branch information
songololo committed Nov 17, 2023
1 parent ce3fe72 commit e274495
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 33 deletions.
4 changes: 2 additions & 2 deletions docs/src/pages/rustalgos/rustalgos.md
Original file line number Diff line number Diff line change
Expand Up @@ -2736,12 +2736,12 @@ datapoints are not located with high spatial precision.



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




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



Expand Down
17 changes: 1 addition & 16 deletions docs/src/pages/tools/graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,11 @@ layout: ../../layouts/PageLayout.astro


<div class="content">
<span class="name">nx_simple_geoms</span><div class="signature multiline">
<span class="name">nx_simple_geoms</span><div class="signature">
<span class="pt">(</span>
<div class="param">
<span class="pn">nx_multigraph</span>
</div>
<div class="param">
<span class="pn">simplify_dist</span>
<span class="pc">:</span>
<span class="pa"> int = 5</span>
</div>
<span class="pt">)</span>
</div>
</div>
Expand All @@ -42,16 +37,6 @@ layout: ../../layouts/PageLayout.astro
A `networkX` `MultiGraph` with `x` and `y` node attributes.</div>
</div>

<div class="param-set">
<div class="def">
<div class="name">simplify_dist</div>
<div class="type">int</div>
</div>
<div class="desc">

Simplification distance to use for simplifying the linestring geometries.</div>
</div>

### Returns
<div class="param-set">
<div class="def">
Expand Down
24 changes: 9 additions & 15 deletions tests/tools/test_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,36 +308,30 @@ def test_nx_iron_edges():
nx_multi.add_node(0, x=0, y=0)
nx_multi.add_node(1, x=0, y=2)
# 1 - straight line should be simplified
line_geom = geometry.LineString([[0, 0], [0, 100], [0, 200]])
line_geom = geometry.LineString([[0, 0], [0, 10], [0, 20]])
nx_multi.add_edge(0, 1, geom=line_geom)
nx_out = graphs.nx_iron_edges(nx_multi)
out_geom = nx_out[0][1][0]["geom"]
assert list(out_geom.coords) == [(0.0, 0.0), (0.0, 200.0)]
assert list(out_geom.coords) == [(0.0, 0.0), (0.0, 20.0)]
# 2 - jogged line should be preserved
line_geom = geometry.LineString([[0, 0], [0, 100], [100, 100], [100, 200]])
line_geom = geometry.LineString([[0, 0], [0, 10], [10, 10], [10, 20]])
nx_multi[0][1][0]["geom"] = line_geom
nx_out = graphs.nx_iron_edges(nx_multi)
out_geom = nx_out[0][1][0]["geom"]
assert list(out_geom.coords) == [(0.0, 0.0), (0.0, 100.0), (100.0, 100.0), (100.0, 200.0)]
assert list(out_geom.coords) == [(0.0, 0.0), (0.0, 10.0), (10.0, 10.0), (10.0, 20.0)]
# 3 sharply jogged line should be simplified
line_geom = geometry.LineString([[0, 0], [0, 100], [100, 50], [100, 200]])
line_geom = geometry.LineString([[0, 0], [10, 0], [15, 10], [15, 0]])
nx_multi[0][1][0]["geom"] = line_geom
nx_out = graphs.nx_iron_edges(nx_multi)
out_geom = nx_out[0][1][0]["geom"]
assert list(out_geom.coords) == [(0.0, 0.0), (100.0, 200.0)]
assert list(out_geom.coords) == [(0.0, 0.0), (15.0, 0.0)]
# 4 folded back line should be simplified
line_geom = geometry.LineString([[0, 0], [0, 300], [0, 200]])
line_geom = geometry.LineString([[0, 0], [0, 30], [0, 20]])
nx_multi[0][1][0]["geom"] = line_geom
nx_out = graphs.nx_iron_edges(nx_multi)
out_geom = nx_out[0][1][0]["geom"]
assert list(out_geom.coords) == [(0.0, 0.0), (0.0, 200.0)]
# 5 short line should be simplified
line_geom = geometry.LineString([[0, 0], [10, 100], [0, 200]])
nx_multi[0][1][0]["geom"] = line_geom
nx_out = graphs.nx_iron_edges(nx_multi)
out_geom = nx_out[0][1][0]["geom"]
assert list(out_geom.coords) == [(0.0, 0.0), (0.0, 200.0)]
# 6 loops should be left alone
assert list(out_geom.coords) == [(0.0, 0.0), (0.0, 20.0)]
# 5 loops should be left alone
nx_multi = nx.MultiGraph()
nx_multi.add_node(0, x=0, y=0)
line_geom = geometry.LineString([[0, 0], [0, 100], [100, 100], [100, 0], [0, 0]])
Expand Down

0 comments on commit e274495

Please sign in to comment.