From a5c2580ab2a6d6bd9e04036057cf37266b64b039 Mon Sep 17 00:00:00 2001 From: Gareth Simons Date: Tue, 11 Jun 2024 18:36:33 +0100 Subject: [PATCH] fixes consolidation test --- pysrc/cityseer/tools/graphs.py | 1 + tests/tools/test_graphs.py | 19 +++++-------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/pysrc/cityseer/tools/graphs.py b/pysrc/cityseer/tools/graphs.py index 3df548e1..3b41e300 100644 --- a/pysrc/cityseer/tools/graphs.py +++ b/pysrc/cityseer/tools/graphs.py @@ -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 diff --git a/tests/tools/test_graphs.py b/tests/tools/test_graphs.py index d4cebe4e..3469ca4f 100644 --- a/tests/tools/test_graphs.py +++ b/tests/tools/test_graphs.py @@ -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 @@ -367,12 +367,12 @@ 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 = [] @@ -380,16 +380,7 @@ def test_nx_consolidate_nodes(parallel_segments_graph): 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], )