Skip to content

Commit

Permalink
fixes consolidation test
Browse files Browse the repository at this point in the history
  • Loading branch information
songololo committed Jun 11, 2024
1 parent 9b43df0 commit a5c2580
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
1 change: 1 addition & 0 deletions pysrc/cityseer/tools/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ def recurse_child_keys(
for start_nd_key, end_nd_key, edge_idx, edge_data in gapped_edges:
edge_geom = edge_data["geom"]
# don't proceed with splits for short geoms??
# not necessarily desirable behaviour
# if edge_geom.length < 5:
# continue
# get hwy keys
Expand Down
19 changes: 5 additions & 14 deletions tests/tools/test_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def test_nx_consolidate_nodes(parallel_segments_graph):
""" """
# behaviour confirmed visually
# from cityseer.tools import plot
# plot.plot_nx(G, labels=True, node_size=80, plot_geoms=True)
# plot.plot_nx(parallel_segments_graph, labels=True, node_size=80, plot_geoms=True)
# set centroid_by_itx to False
G_merged_spatial = graphs.nx_consolidate_nodes(
parallel_segments_graph, buffer_dist=25, crawl=True, centroid_by_itx=False, merge_edges_by_midline=True
Expand All @@ -367,29 +367,20 @@ def test_nx_consolidate_nodes(parallel_segments_graph):
node_coords.append((d["x"], d["y"]))
assert node_coords == [
(660, 660),
(620.0, 710.0),
(660.0, 710.0),
(780.0, 710.0),
(620.0, 710.0),
(710.0, 800.0),
(706.6666666666666, 713.3333333333334),
(710.0, 710.0),
(710.0, 620.0),
(780.0, 710.0),
(840.0, 710.0),
]
edge_lens = []
for s, e, d in G_merged_spatial.edges(data=True):
edge_lens.append(d["geom"].length)
assert np.allclose(
edge_lens,
[
50.0,
40.0,
46.78556282539396,
86.73074554171788,
93.39283817414604,
73.40905181848417,
60.0,
147.70329614269008,
],
[50.0, 40.0, 50.0, 70.0, 60.0, 147.70329614269008, 90.0, 90.0],
)


Expand Down

0 comments on commit a5c2580

Please sign in to comment.