Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
29a780b641 |
@ -1,10 +1,13 @@
|
|||||||
FROM ubuntu:22.04
|
FROM ubuntu:22.04
|
||||||
|
|
||||||
ARG PLZ_DATA=Postleitzahlengebiete_-_OSM.geojson
|
ARG PLZ_DATA=Postleitzahlengebiete_-_OSM.geojson
|
||||||
ARG PLZ_HIGHLIGHT=wtf_member_plz_prefixes.json
|
ARG PLZ_HIGHLIGHT=contacts-zip-anonym.json
|
||||||
|
ARG IMG_BG_COLOR=#FFFFFF
|
||||||
|
ARG MAP_BG_COLOR=#4279BC
|
||||||
|
ARG MAP_ACCENT_COLOR=#DA532C
|
||||||
|
|
||||||
# Set up environment with dependencies
|
# Set up environment with dependencies
|
||||||
RUN apt-get update && apt-get install libblas-dev python3-pip libgeos-dev libgdal-dev wget optipng imagemagick -y
|
RUN apt-get update && apt-get install libblas-dev python3-pip libgeos-dev wget optipng imagemagick -y
|
||||||
COPY requirements.txt ./
|
COPY requirements.txt ./
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
@ -14,7 +17,7 @@ COPY $PLZ_HIGHLIGHT ./
|
|||||||
|
|
||||||
# Render map
|
# Render map
|
||||||
COPY main.py ./
|
COPY main.py ./
|
||||||
RUN python3 main.py --plz-data $PLZ_DATA --plz-highlight $PLZ_HIGHLIGHT --out /tmp/map.png
|
RUN python3 main.py --plz-data $PLZ_DATA --plz-highlight $PLZ_HIGHLIGHT --img-bg-color $IMG_BG_COLOR --map-bg-color $MAP_BG_COLOR --map-accent-color $MAP_ACCENT_COLOR --out /tmp/map.png
|
||||||
|
|
||||||
RUN convert -fuzz 5 -trim /tmp/map.png /tmp/map.png
|
RUN convert -fuzz 5 -trim /tmp/map.png /tmp/map.png
|
||||||
RUN optipng -o7 /tmp/map.png
|
RUN optipng -o7 /tmp/map.png
|
||||||
|
30
main.py
30
main.py
@ -28,23 +28,27 @@ def main(
|
|||||||
data.loc[data["plz"].str.startswith(plz_prefix), "highlighted"] = True
|
data.loc[data["plz"].str.startswith(plz_prefix), "highlighted"] = True
|
||||||
|
|
||||||
# TODO: This should instead be a proper geo spatial projection
|
# TODO: This should instead be a proper geo spatial projection
|
||||||
coordinate_transform = np.array([[1.0, 1.0]]).T
|
coordinate_transform = np.array([[1.0, 1.6]]).T
|
||||||
|
|
||||||
ax = plt.axes(aspect="equal")
|
ax = plt.axes(aspect="equal")
|
||||||
union = data.unary_union
|
for bundesland in data["bundesland"].unique():
|
||||||
for geom in getattr(union, "geoms", [union]):
|
bundesland_df = data[data["bundesland"] == bundesland]
|
||||||
ax.fill(
|
union = bundesland_df.unary_union
|
||||||
*geom.exterior.xy,
|
|
||||||
fc=map_background_color,
|
|
||||||
ec=image_background_color,
|
|
||||||
linewidth=0.1,
|
|
||||||
)
|
|
||||||
|
|
||||||
if any(data["highlighted"]):
|
|
||||||
union = data[data["highlighted"]].unary_union
|
|
||||||
for geom in getattr(union, "geoms", [union]):
|
for geom in getattr(union, "geoms", [union]):
|
||||||
ax.fill(
|
ax.fill(
|
||||||
*geom.exterior.xy,
|
*(geom.exterior.xy * coordinate_transform),
|
||||||
|
fc=map_background_color,
|
||||||
|
ec=image_background_color,
|
||||||
|
linewidth=0.1,
|
||||||
|
)
|
||||||
|
|
||||||
|
if not any(bundesland_df["highlighted"]):
|
||||||
|
continue
|
||||||
|
|
||||||
|
union = bundesland_df[bundesland_df["highlighted"]].unary_union
|
||||||
|
for geom in getattr(union, "geoms", [union]):
|
||||||
|
ax.fill(
|
||||||
|
*(geom.exterior.xy * coordinate_transform),
|
||||||
fc=map_accent_color,
|
fc=map_accent_color,
|
||||||
ec=None,
|
ec=None,
|
||||||
)
|
)
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
numpy==1.26.4
|
|
||||||
geopandas==0.11.1
|
geopandas==0.11.1
|
||||||
matplotlib==3.6.2
|
matplotlib==3.6.2
|
Loading…
Reference in New Issue
Block a user