From 1f6f8d270d438a3d2c2a69d7915afdfc7ec6cd2e Mon Sep 17 00:00:00 2001 From: Phillip Whittlesea-Clark Date: Sat, 28 Sep 2024 19:49:24 +0100 Subject: [PATCH] Allow posts to define zoom level --- .generate_maps.py | 5 +- _includes/map.html | 2 +- assets/images/maps/london_to_auckland.svg | 58 +++++++++++------------ assets/images/maps/road_to_rotorua.svg | 52 ++++++++++---------- 4 files changed, 60 insertions(+), 57 deletions(-) diff --git a/.generate_maps.py b/.generate_maps.py index cb80bbe..02a870d 100644 --- a/.generate_maps.py +++ b/.generate_maps.py @@ -41,7 +41,7 @@ def bounds(self) -> s2sphere.LatLngRect: def extra_pixel_bounds(self) -> staticmaps.PixelBoundsT: w = len(self._text) * self._font_size h = self._font_size - return (int(-w / 2), int(-h / 2), int(w / 2), int(h / 2)) + return (int(w / 2), int(h / 2), int(w / 2), int(h / 2)) def render_svg(self, renderer: staticmaps.SvgRenderer) -> None: x, y = renderer.transformer().ll2pixel(self.latlng()) @@ -111,6 +111,9 @@ def render_svg(self, renderer: staticmaps.SvgRenderer) -> None: for label in labels: context.add_object(label) + if "zoom" in post_map: + context.set_zoom(int(post_map["zoom"])) + map_name = post_map["name"] map_path = f"{IMAGE_DIR}/{map_name}.svg" exists_already = os.path.isfile(map_path) diff --git a/_includes/map.html b/_includes/map.html index 47eb2b1..26b85ed 100644 --- a/_includes/map.html +++ b/_includes/map.html @@ -1,7 +1,7 @@ {% assign point_names = "Unknown" | split: "," %} {% for map in page.maps %} {% if map.name == include.name %} -{% assign point_names = map.points | map: "name" %} +{% assign point_names = map.points | map: "name" | compact %} {% endif %} {% endfor %} diff --git a/assets/images/maps/london_to_auckland.svg b/assets/images/maps/london_to_auckland.svg index 44fdfbc..f1fd8ab 100644 --- a/assets/images/maps/london_to_auckland.svg +++ b/assets/images/maps/london_to_auckland.svg @@ -6,113 +6,113 @@ - - - - - - - - + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - London + London - London + London - London + London - Changi - Singapore + Changi - Singapore - Changi - Singapore + Changi - Singapore - Changi - Singapore + Changi - Singapore - Auckland + Auckland - Auckland + Auckland - Auckland + Auckland diff --git a/assets/images/maps/road_to_rotorua.svg b/assets/images/maps/road_to_rotorua.svg index aff5e8b..6659b23 100644 --- a/assets/images/maps/road_to_rotorua.svg +++ b/assets/images/maps/road_to_rotorua.svg @@ -6,104 +6,104 @@ - - - - - - - - + + + + + + + + - + - + - + - + - + - + - + - + - + - Auckland + Auckland - Auckland + Auckland - Auckland + Auckland - Tīrau + Tīrau - Tīrau + Tīrau - Tīrau + Tīrau - Rotorua + Rotorua - Rotorua + Rotorua - Rotorua + Rotorua