Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #116: Add --path-arrows option for arrow rendering #117

Merged
merged 10 commits into from
Feb 20, 2025
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ 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]
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 2 additions & 0 deletions mapmaker/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ 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'],
Expand Down
19 changes: 10 additions & 9 deletions mapmaker/routing/routedpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('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={
'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]
Expand Down Expand Up @@ -479,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
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), {
Expand Down
Loading