Two new views, picked from mockups. `sky`: a star chart of the sky over Zlín as seen lying on your back, with the planets, the moon in its phase, tonight's darkness, cloud for the next 12 hours and the next visible ISS pass. `iss`: a dotted world map with day and night, the ISS and its ground track, and the next pass over Zlín with the cloud cover for that hour. Positions are calculated locally with ephem; only the ISS orbit (CelesTrak, every 6 h, retried gently) and cloud cover (Open-Meteo) are fetched. The poller gained a per-source retry delay for that. Co-Authored-By: Claude Opus 5.5 <[email protected]>
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
"""Bake assets/world_land.png (480x240, white = land) from Natural Earth's 1:110m land polygons (public domain).
|
|
|
|
Run once by hand: .venv/bin/python tools/bake_world_map.py
|
|
"""
|
|
import json
|
|
from pathlib import Path
|
|
|
|
import requests
|
|
from PIL import Image, ImageDraw
|
|
|
|
SOURCE = "https://raw.githubusercontent.com/nvkelso/natural-earth-vector/master/geojson/ne_110m_land.geojson"
|
|
OUT = Path(__file__).resolve().parent.parent / "assets" / "world_land.png"
|
|
W, H = 480, 240 # equirectangular: 0.75° per pixel
|
|
|
|
|
|
def main() -> None:
|
|
features = requests.get(SOURCE, timeout=30).json()["features"]
|
|
mask = Image.new("1", (W, H), 0)
|
|
d = ImageDraw.Draw(mask)
|
|
for feature in features:
|
|
geometry = feature["geometry"]
|
|
polygons = geometry["coordinates"] if geometry["type"] == "MultiPolygon" else [geometry["coordinates"]]
|
|
for polygon in polygons:
|
|
d.polygon([((lon + 180) / 360 * W, (90 - lat) / 180 * H) for lon, lat in polygon[0]], fill=1)
|
|
mask.save(OUT, optimize=True)
|
|
print(OUT, OUT.stat().st_size, "bytes")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|