From b417e0ba18b69d71177e810bbce0e91181037c8a Mon Sep 17 00:00:00 2001 From: Justin Kunimune Date: Mon, 8 Jan 2024 22:02:03 -0500 Subject: [PATCH] fix weird coastlines they were getting Zed by fuse_russia. --- input/Advanced/Supermap.svg | 104 +++++++++--------- src/zupplemental/compose_maps.py | 4 +- src/zupplemental/generate_indicatrices.py | 6 +- src/zupplemental/generate_orthodromes.py | 2 +- src/zupplemental/generate_political_shapes.py | 2 +- src/zupplemental/generate_shapes.py | 2 +- src/zupplemental/helpers.py | 4 +- 7 files changed, 63 insertions(+), 61 deletions(-) diff --git a/input/Advanced/Supermap.svg b/input/Advanced/Supermap.svg index b6ce461..c19accb 100644 --- a/input/Advanced/Supermap.svg +++ b/input/Advanced/Supermap.svg @@ -3410,11 +3410,11 @@ - - + + - - + + @@ -3432,10 +3432,10 @@ - - - - + + + + @@ -3529,8 +3529,8 @@ - - + + @@ -3572,13 +3572,13 @@ - + - - + + @@ -3611,14 +3611,14 @@ - - + + - - - + + + @@ -3640,8 +3640,8 @@ - - + + @@ -3659,9 +3659,9 @@ - - - + + + @@ -3687,12 +3687,12 @@ - - - + + + - + @@ -3780,7 +3780,7 @@ - + @@ -3854,7 +3854,7 @@ - + @@ -3871,10 +3871,10 @@ - - - - + + + + @@ -3891,11 +3891,11 @@ - + - - + + @@ -3915,7 +3915,7 @@ - + @@ -3923,8 +3923,8 @@ - - + + @@ -6243,7 +6243,7 @@ - + @@ -6252,12 +6252,12 @@ - + - + @@ -6412,7 +6412,7 @@ - + @@ -6926,7 +6926,7 @@ - + @@ -6957,10 +6957,10 @@ - - + + - + @@ -7293,8 +7293,8 @@ - - + + @@ -7423,10 +7423,10 @@ - - + + - + diff --git a/src/zupplemental/compose_maps.py b/src/zupplemental/compose_maps.py index 7c273d4..c916378 100644 --- a/src/zupplemental/compose_maps.py +++ b/src/zupplemental/compose_maps.py @@ -23,7 +23,7 @@ def main(): ' \n' ' \n' ' \n' - + plot_shapes('ne_50m_land', trim_antarctica=True, mark_antarctica=True) + + + plot_shapes('ne_50m_land', trim_antarctica=True, mark_antarctica=True, fuse_russia=True) + ' \n' ' \n' + plot_shapes('ne_50m_lakes', max_rank=4) + @@ -266,7 +266,7 @@ def main(): + plot_shapes('ne_10m_admin_0_boundary_lines_disputed_areas') + ' \n' ' \n' - + plot_shapes('ne_10m_coastline', trim_antarctica=True, fuse_russia=True) + + + plot_shapes('ne_10m_coastline', trim_antarctica=True) + ' \n' ' \n' + plot_shapes('ne_10m_lakes', max_rank=4) + diff --git a/src/zupplemental/generate_indicatrices.py b/src/zupplemental/generate_indicatrices.py index 70d810c..5c4fd61 100644 --- a/src/zupplemental/generate_indicatrices.py +++ b/src/zupplemental/generate_indicatrices.py @@ -11,7 +11,7 @@ def plot_indicatrix(phi0, lam0, r, res) -> str: points = [] for l in range(0, 360, 360//res): points.append(obliquify(math.pi/2-r, math.radians(l), phi0, lam0)) - return plot(points) + return plot(points, close=True) def plot_side_indicatrix(phi0, r, res, side_res=1) -> str: @@ -28,7 +28,7 @@ def plot_side_indicatrix(phi0, r, res, side_res=1) -> str: points.append((pr, lr + math.pi)) for i in range(side_res): points.append((phi0-r+(2*r)/side_res*(i+1), math.pi)) - return plot(points, midx=midx, close=False) + return plot(points, midx=midx) def plot_pole_indicatrix(north, r, res, ctr_meridian=0., side_res=1, pole_res=1) -> str: @@ -46,7 +46,7 @@ def plot_pole_indicatrix(north, r, res, ctr_meridian=0., side_res=1, pole_res=1) points.append((pr + (pp-pr)/side_res*(i+1), ctr_meridian+math.pi)) for x in range(180, -181, -360//pole_res): points.append((pp, ctr_meridian+math.radians(x))) - return plot(points) + return plot(points, close=True) def generate_indicatrices(spacing, radius, adjust_poles=False, resolution=60, ctr_meridian=0, side_res=1, pole_res=1) -> str: diff --git a/src/zupplemental/generate_orthodromes.py b/src/zupplemental/generate_orthodromes.py index e1662c0..c19a9b3 100644 --- a/src/zupplemental/generate_orthodromes.py +++ b/src/zupplemental/generate_orthodromes.py @@ -11,7 +11,7 @@ def plot_orthodrome(phi0, lam0, tht0) -> str: points = [] for p in np.linspace(-90, 90, 1001): points.append(obliquify(radians(p), tht0, phi0, lam0)) - return plot(points, close=False) + return plot(points) def generate_orthodromes() -> str: diff --git a/src/zupplemental/generate_political_shapes.py b/src/zupplemental/generate_political_shapes.py index 058c0cf..10afc33 100644 --- a/src/zupplemental/generate_political_shapes.py +++ b/src/zupplemental/generate_political_shapes.py @@ -226,7 +226,7 @@ def plot_political_shapes(data: dict[str, tuple[Shape, Optional[dict[str, Any]], # the normal polygon if mode == "normal": if has_geometry: - result += plot(shape.points, midx=shape.parts, close=False, + result += plot(shape.points, midx=shape.parts, fourmat='xd', tabs=num_tabs + 1, ident=identifier) any_content = True # or the clipped and copied thick border diff --git a/src/zupplemental/generate_shapes.py b/src/zupplemental/generate_shapes.py index ab558a1..261f2ef 100644 --- a/src/zupplemental/generate_shapes.py +++ b/src/zupplemental/generate_shapes.py @@ -38,7 +38,7 @@ def plot_shapes( if fuse_russia: shape.points, shape.parts = fuse_edges(shape.points, shape.parts) - result += plot(shape.points, midx=shape.parts, close=False, + result += plot(shape.points, midx=shape.parts, clazz=clazz_for_this_section, fourmat='xd') return result diff --git a/src/zupplemental/helpers.py b/src/zupplemental/helpers.py index faf411f..3dd70f7 100644 --- a/src/zupplemental/helpers.py +++ b/src/zupplemental/helpers.py @@ -3,7 +3,9 @@ from __future__ import annotations import random as rng from typing import Any, Iterable, Optional +import numpy as np import shapefile +from matplotlib import pyplot as plt from numpy import pi, sin, cos, tan, arcsin, arccos, degrees, ceil, radians, arctan2, hypot, cumsum from shapefile import NULL, Shape, ShapefileException @@ -74,7 +76,7 @@ def obliquify(lat1, lon1, lat0, lon0): return latf, lonf -def plot(coords: list[tuple[float, float]], midx: Optional[list[int]] = None, close=True, fourmat='pr', clazz=None, ident=None, tabs=4) -> str: +def plot(coords: list[tuple[float, float]], midx: Optional[list[int]] = None, close=False, fourmat='pr', clazz=None, ident=None, tabs=4) -> str: """ express a list of 2D points as an SVG tag :param coords: the coordinate pairs of the vertices