From aa842979e9ffb952bb7c4f627d8c1cc008894153 Mon Sep 17 00:00:00 2001 From: s3lph Date: Sun, 9 Oct 2022 23:01:04 +0200 Subject: [PATCH] Catch the edge case where a space is returned both as an Erfa and a Chaostreff by SMW --- generate_map.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/generate_map.py b/generate_map.py index 69de5cd..c9329ef 100755 --- a/generate_map.py +++ b/generate_map.py @@ -560,15 +560,6 @@ def create_svg(ns, bbox): ts.append((xt*scalex - origin[0], origin[1] - yt*scaley)) shapes_countries.append((name, ts)) - chaostreffs = {} - with open(ns.cache_directory.chaostreff_info, 'r') as f: - ctdata = json.load(f) - for city, location in ctdata.items(): - if location is None: - continue - xt, yt = transformer.transform(*location) - chaostreffs[city] = (xt*scalex - origin[0], origin[1] - yt*scaley) - erfas = {} with open(ns.cache_directory.erfa_info, 'r') as f: ctdata = json.load(f) @@ -578,6 +569,21 @@ def create_svg(ns, bbox): xt, yt = transformer.transform(*location) erfas[city] = (xt*scalex - origin[0], origin[1] - yt*scaley) + chaostreffs = {} + with open(ns.cache_directory.chaostreff_info, 'r') as f: + ctdata = json.load(f) + for city, location in ctdata.items(): + if location is None: + continue + if city in erfas: + # There is an edge case where when a space changed states between Erfa and Chaostreff, the + # Semantic MediaWiki engine returns this space as both an Erfa and a Chaostreff, resulting + # in glitches in the rendering. As a workaround, here we simply assume that it's an Erfa. + continue + xt, yt = transformer.transform(*location) + chaostreffs[city] = (xt*scalex - origin[0], origin[1] - yt*scaley) + + rectbox = [0, 0, svg_box[0], svg_box[1]] for name, shape in shapes_states + shapes_countries: for lon, lat in shape: