From 17d7a17ad4e84e1002ac15de73ab60c85cfbd91e Mon Sep 17 00:00:00 2001 From: Gareth Simons Date: Mon, 16 Oct 2023 13:37:25 +0100 Subject: [PATCH] catches division by zero for dissolve --- pyproject.toml | 2 +- pysrc/cityseer/tools/graphs.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6bd6855a..223c51c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "cityseer" -version = '4.2.1' +version = '4.2.2' description = "Computational tools for network-based pedestrian-scale urban analysis" readme = "README.md" requires-python = ">=3.10, <3.12" diff --git a/pysrc/cityseer/tools/graphs.py b/pysrc/cityseer/tools/graphs.py index c8d39889..cfd1e126 100644 --- a/pysrc/cityseer/tools/graphs.py +++ b/pysrc/cityseer/tools/graphs.py @@ -1417,6 +1417,9 @@ def nx_weight_by_dissolved_edges(nx_multigraph: MultiGraph, dissolve_distance: i total_lens += edge_geom.length total_lens += nb_edge_data["nearby_itx_lens"] # calculate ratio - g_multi_copy.nodes[nd_key]["weight"] = adjacent_lens / total_lens + weight = 1 + if total_lens > dissolve_distance: + weight = adjacent_lens / total_lens + g_multi_copy.nodes[nd_key]["weight"] = weight return g_multi_copy