From b42444e2745e41c20fba556c9e4f047b107fa606 Mon Sep 17 00:00:00 2001 From: napakalas Date: Mon, 4 Aug 2025 11:38:27 +1200 Subject: [PATCH] Fix selection of start and end coordinates for polygons using representative_point() (#148) --- mapmaker/routing/routedpath.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mapmaker/routing/routedpath.py b/mapmaker/routing/routedpath.py index 9d59ca99..81fb88cb 100644 --- a/mapmaker/routing/routedpath.py +++ b/mapmaker/routing/routedpath.py @@ -428,8 +428,10 @@ def draw_arrow(start_point, end_point, path_id, path_source): })) def draw_line(node_0, node_1, tolerance=0.1, separation=2000): - start_coords = self.__graph.nodes[node_0]['geometry'].centroid.coords[0] - end_coords = self.__graph.nodes[node_1]['geometry'].centroid.coords[0] + start_coords = (g.centroid.coords[0] if (g:=self.__graph.nodes[node_0]['geometry']).geom_type=='LineString' + else g.representative_point().coords[0]) + end_coords = (g.centroid.coords[0] if (g:=self.__graph.nodes[node_1]['geometry']).geom_type=='LineString' + else g.representative_point().coords[0]) offset = self.__graph.nodes[node_0]['offsets'][node_1] path_offset = separation * offset start_point = coords_to_point(start_coords)