From 60744b0c86ea02a37482df38125374d573fa7b50 Mon Sep 17 00:00:00 2001 From: napakalas Date: Mon, 17 Feb 2025 17:59:35 +1300 Subject: [PATCH 01/10] Modify draw_arrow() to do nothing by default and add --path-arrows option to enable arrow rendering. --- mapmaker/__main__.py | 2 ++ mapmaker/routing/routedpath.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mapmaker/__main__.py b/mapmaker/__main__.py index 0235e4bc..760ac82c 100644 --- a/mapmaker/__main__.py +++ b/mapmaker/__main__.py @@ -63,6 +63,8 @@ def arg_parser(): help="Create a SPARC Dataset containing the map's sources and the generated map") generation_options.add_argument('--sckan-version', dest='sckanVersion', choices=['production', 'staging'], help="Overide version of SCKAN specified by map's manifest") + generation_options.add_argument('--path-arrow', dest='pathArrow', action='store_true', + help="Render arrows at the terminal nodes.") debug_options = parser.add_argument_group('Diagnostics') debug_options.add_argument('--authoring', action='store_true', diff --git a/mapmaker/routing/routedpath.py b/mapmaker/routing/routedpath.py index 3871447a..1df0436a 100644 --- a/mapmaker/routing/routedpath.py +++ b/mapmaker/routing/routedpath.py @@ -417,14 +417,15 @@ def connect_gap(node, node_points, iscentreline=False): # Draw paths to terminal nodes def draw_arrow(start_point, end_point, path_id, path_source): - heading = (end_point - start_point).angle - end_point -= BezierPoint.fromAngle(heading)*0.9*ARROW_LENGTH - path_geometry[path_id].append(GeometricShape.arrow(end_point, heading, ARROW_LENGTH, properties={ - 'type': 'arrow', - 'path-id': path_id, - 'source': path_source, - 'label': self.__graph.graph.get('label') - })) + if settings.get('pathArrow', False): + heading = (end_point - start_point).angle + end_point -= BezierPoint.fromAngle(heading)*0.9*ARROW_LENGTH + path_geometry[path_id].append(GeometricShape.arrow(end_point, heading, ARROW_LENGTH, properties={ + 'type': 'arrow', + 'path-id': path_id, + 'source': path_source, + 'label': self.__graph.graph.get('label') + })) def draw_line(node_0, node_1, tolerance=0.1, separation=2000): start_coords = self.__graph.nodes[node_0]['geometry'].centroid.coords[0] @@ -479,8 +480,7 @@ def draw_line(node_0, node_1, tolerance=0.1, separation=2000): end_coords = self.__graph.nodes[terminal_node]['geometry'].centroid.coords[0] end_point = coords_to_point(end_coords) heading = (end_point - start_point).angle - bz_end_point = end_point - BezierPoint.fromAngle(heading)*0.9*ARROW_LENGTH - bz = bezier_connect(start_point, bz_end_point, angle, heading) + bz = bezier_connect(start_point, end_point, angle, heading) path_geometry[path_id].append(GeometricShape( bezier_to_linestring(bz), { 'path-id': path_id, From 7204a22ac0c4b9299949036e72ccd1f444e0a920 Mon Sep 17 00:00:00 2001 From: napakalas Date: Mon, 17 Feb 2025 18:16:33 +1300 Subject: [PATCH 02/10] Update README to include --path-arrows argument for enabling arrow rendering. --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 655dbafd..31f39ba0 100644 --- a/README.rst +++ b/README.rst @@ -115,6 +115,7 @@ Command line help [--initial-zoom N] [--max-zoom N] [--export-features EXPORT_FILE] [--export-neurons EXPORT_FILE] [--export-svg EXPORT_FILE] [--single-file {celldl,svg}] + [--path-arrows] --output OUTPUT --source SOURCE Generate a flatmap from its source manifest. @@ -145,6 +146,7 @@ Command line help Create a SPARC Dataset containing the map's sources and the generated map --sckan-version {production,staging} Overide version of SCKAN specified by map's manifest + --path-arrows Render arrows at the terminal nodes. Diagnostics: --authoring For use when checking a new map: highlight incomplete From f64cf4cba17435336e87f4016905824f159bc7d0 Mon Sep 17 00:00:00 2001 From: napakalas Date: Thu, 20 Feb 2025 13:21:53 +1300 Subject: [PATCH 03/10] Update the argument name from --path-arrow to --path-arrows and adjust line rendering accordingly. --- mapmaker/__main__.py | 2 +- mapmaker/routing/routedpath.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mapmaker/__main__.py b/mapmaker/__main__.py index 760ac82c..747f6b9a 100644 --- a/mapmaker/__main__.py +++ b/mapmaker/__main__.py @@ -63,7 +63,7 @@ def arg_parser(): help="Create a SPARC Dataset containing the map's sources and the generated map") generation_options.add_argument('--sckan-version', dest='sckanVersion', choices=['production', 'staging'], help="Overide version of SCKAN specified by map's manifest") - generation_options.add_argument('--path-arrow', dest='pathArrow', action='store_true', + generation_options.add_argument('--path-arrows', dest='pathArrows', action='store_true', help="Render arrows at the terminal nodes.") debug_options = parser.add_argument_group('Diagnostics') diff --git a/mapmaker/routing/routedpath.py b/mapmaker/routing/routedpath.py index 1df0436a..5742ded3 100644 --- a/mapmaker/routing/routedpath.py +++ b/mapmaker/routing/routedpath.py @@ -417,7 +417,7 @@ def connect_gap(node, node_points, iscentreline=False): # Draw paths to terminal nodes def draw_arrow(start_point, end_point, path_id, path_source): - if settings.get('pathArrow', False): + if settings.get('pathArrows', False): heading = (end_point - start_point).angle end_point -= BezierPoint.fromAngle(heading)*0.9*ARROW_LENGTH path_geometry[path_id].append(GeometricShape.arrow(end_point, heading, ARROW_LENGTH, properties={ @@ -480,7 +480,8 @@ def draw_line(node_0, node_1, tolerance=0.1, separation=2000): end_coords = self.__graph.nodes[terminal_node]['geometry'].centroid.coords[0] end_point = coords_to_point(end_coords) heading = (end_point - start_point).angle - bz = bezier_connect(start_point, end_point, angle, heading) + bz_end_point = end_point - BezierPoint.fromAngle(heading) * 0.9 * ARROW_LENGTH if settings.get('pathArrows') else end_point + bz = bezier_connect(start_point, bz_end_point, angle, heading) path_geometry[path_id].append(GeometricShape( bezier_to_linestring(bz), { 'path-id': path_id, From 6a3a78048fc84b8890f668eaa564de22a371a9a2 Mon Sep 17 00:00:00 2001 From: napakalas Date: Thu, 20 Feb 2025 14:35:31 +1300 Subject: [PATCH 04/10] Update help message for --path-arrows argument and remove the full stop for consistency. --- README.rst | 2 +- mapmaker/__main__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 31f39ba0..6bd93010 100644 --- a/README.rst +++ b/README.rst @@ -146,7 +146,7 @@ Command line help Create a SPARC Dataset containing the map's sources and the generated map --sckan-version {production,staging} Overide version of SCKAN specified by map's manifest - --path-arrows Render arrows at the terminal nodes. + --path-arrows ReRender arrows at the terminal nodes of paths Diagnostics: --authoring For use when checking a new map: highlight incomplete diff --git a/mapmaker/__main__.py b/mapmaker/__main__.py index 747f6b9a..e6e6ad86 100644 --- a/mapmaker/__main__.py +++ b/mapmaker/__main__.py @@ -64,7 +64,7 @@ def arg_parser(): generation_options.add_argument('--sckan-version', dest='sckanVersion', choices=['production', 'staging'], help="Overide version of SCKAN specified by map's manifest") generation_options.add_argument('--path-arrows', dest='pathArrows', action='store_true', - help="Render arrows at the terminal nodes.") + help="Render arrows at the terminal nodes of paths") debug_options = parser.add_argument_group('Diagnostics') debug_options.add_argument('--authoring', action='store_true', From 57e2c85f9acb3f528aef1a8a7ba62a10334ecd2b Mon Sep 17 00:00:00 2001 From: napakalas Date: Thu, 20 Feb 2025 14:38:55 +1300 Subject: [PATCH 05/10] Ensure calling 'pathArrows' key from settings returns True or False. --- mapmaker/routing/routedpath.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapmaker/routing/routedpath.py b/mapmaker/routing/routedpath.py index 5742ded3..60b7fad7 100644 --- a/mapmaker/routing/routedpath.py +++ b/mapmaker/routing/routedpath.py @@ -480,7 +480,7 @@ def draw_line(node_0, node_1, tolerance=0.1, separation=2000): end_coords = self.__graph.nodes[terminal_node]['geometry'].centroid.coords[0] end_point = coords_to_point(end_coords) heading = (end_point - start_point).angle - bz_end_point = end_point - BezierPoint.fromAngle(heading) * 0.9 * ARROW_LENGTH if settings.get('pathArrows') else end_point + bz_end_point = end_point - BezierPoint.fromAngle(heading) * 0.9 * ARROW_LENGTH if settings.get('pathArrows', False) else end_point bz = bezier_connect(start_point, bz_end_point, angle, heading) path_geometry[path_id].append(GeometricShape( bezier_to_linestring(bz), { From d482c6a67ec70033fc970add30cd47abcb5453f3 Mon Sep 17 00:00:00 2001 From: napakalas Date: Thu, 20 Feb 2025 15:51:43 +1300 Subject: [PATCH 06/10] Add parentheses to the left expression of the ternary conditional for better readability. --- mapmaker/routing/routedpath.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapmaker/routing/routedpath.py b/mapmaker/routing/routedpath.py index 60b7fad7..9d59ca99 100644 --- a/mapmaker/routing/routedpath.py +++ b/mapmaker/routing/routedpath.py @@ -480,7 +480,7 @@ def draw_line(node_0, node_1, tolerance=0.1, separation=2000): end_coords = self.__graph.nodes[terminal_node]['geometry'].centroid.coords[0] end_point = coords_to_point(end_coords) heading = (end_point - start_point).angle - bz_end_point = end_point - BezierPoint.fromAngle(heading) * 0.9 * ARROW_LENGTH if settings.get('pathArrows', False) else end_point + bz_end_point = (end_point - BezierPoint.fromAngle(heading) * 0.9 * ARROW_LENGTH) if settings.get('pathArrows', False) else end_point bz = bezier_connect(start_point, bz_end_point, angle, heading) path_geometry[path_id].append(GeometricShape( bezier_to_linestring(bz), { From 0c5c50085346755843ec801f226ee6241ab99652 Mon Sep 17 00:00:00 2001 From: napakalas Date: Thu, 20 Feb 2025 16:38:36 +1300 Subject: [PATCH 07/10] Fix typo of ReRender, it should be just Render --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 6bd93010..8b571db5 100644 --- a/README.rst +++ b/README.rst @@ -146,7 +146,7 @@ Command line help Create a SPARC Dataset containing the map's sources and the generated map --sckan-version {production,staging} Overide version of SCKAN specified by map's manifest - --path-arrows ReRender arrows at the terminal nodes of paths + --path-arrows Render arrows at the terminal nodes of paths Diagnostics: --authoring For use when checking a new map: highlight incomplete From 6ffa1466669f4a4a6de9c3eff42221abc5423c9d Mon Sep 17 00:00:00 2001 From: napakalas Date: Thu, 20 Feb 2025 17:54:31 +1300 Subject: [PATCH 08/10] Order --path-arrows alphabetically in arg_parser() and README. --- README.rst | 7 +++---- mapmaker/__main__.py | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 8b571db5..38ff0abd 100644 --- a/README.rst +++ b/README.rst @@ -107,15 +107,14 @@ Command line help usage: mapmaker [-h] [-v] [--log LOG_FILE] [--silent] [--verbose] - [--background-tiles] [--clean-connectivity] [--disconnected-paths] - [--force] [--id ID] [--ignore-git] [--ignore-sckan] [--invalid-neurons] - [--no-path-layout] [--publish SPARC_DATASET] [--sckan-version {production,staging}] + [--background-tiles] [--clean-connectivity] [--disconnected-paths] [--force] + [--id ID] [--ignore-git] [--ignore-sckan] [--invalid-neurons] [--no-path-layout] + [--path-arrows] [--publish SPARC_DATASET] [--sckan-version {production,staging}] [--authoring] [--debug] [--only-networks] [--save-drawml] [--save-geojson] [--tippecanoe] [--initial-zoom N] [--max-zoom N] [--export-features EXPORT_FILE] [--export-neurons EXPORT_FILE] [--export-svg EXPORT_FILE] [--single-file {celldl,svg}] - [--path-arrows] --output OUTPUT --source SOURCE Generate a flatmap from its source manifest. diff --git a/mapmaker/__main__.py b/mapmaker/__main__.py index e6e6ad86..4e16e90d 100644 --- a/mapmaker/__main__.py +++ b/mapmaker/__main__.py @@ -59,12 +59,12 @@ def arg_parser(): help="Include functional connectivity neurons that aren't known in SCKAN") generation_options.add_argument('--no-path-layout', dest='noPathLayout', action='store_true', help="Don't do `TransitMap` optimisation of paths") + generation_options.add_argument('--path-arrows', dest='pathArrows', action='store_true', + help="Render arrows at the terminal nodes of paths") generation_options.add_argument('--publish', metavar='SPARC_DATASET', help="Create a SPARC Dataset containing the map's sources and the generated map") generation_options.add_argument('--sckan-version', dest='sckanVersion', choices=['production', 'staging'], help="Overide version of SCKAN specified by map's manifest") - generation_options.add_argument('--path-arrows', dest='pathArrows', action='store_true', - help="Render arrows at the terminal nodes of paths") debug_options = parser.add_argument_group('Diagnostics') debug_options.add_argument('--authoring', action='store_true', From 42a3581ceb339d805c4c27355a62c05469148be4 Mon Sep 17 00:00:00 2001 From: napakalas Date: Fri, 21 Feb 2025 09:33:05 +1300 Subject: [PATCH 09/10] Reorder --path-arrows at README.rst. --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 38ff0abd..273de951 100644 --- a/README.rst +++ b/README.rst @@ -141,6 +141,7 @@ Command line help --invalid-neurons Include functional connectivity neurons that aren't known in SCKAN --no-path-layout Don't do `TransitMap` optimisation of paths + --path-arrows Render arrows at the terminal nodes of paths --publish SPARC_DATASET Create a SPARC Dataset containing the map's sources and the generated map --sckan-version {production,staging} From 0ae07d68e2d1ae7d3e5cb8e42bec15bcc3ab464b Mon Sep 17 00:00:00 2001 From: napakalas Date: Fri, 21 Feb 2025 10:14:43 +1300 Subject: [PATCH 10/10] Remove duplicate argument. --- README.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/README.rst b/README.rst index 273de951..a316d234 100644 --- a/README.rst +++ b/README.rst @@ -146,7 +146,6 @@ Command line help Create a SPARC Dataset containing the map's sources and the generated map --sckan-version {production,staging} Overide version of SCKAN specified by map's manifest - --path-arrows Render arrows at the terminal nodes of paths Diagnostics: --authoring For use when checking a new map: highlight incomplete