From c014bacf4b714b9daf58a12e3cde6fabae5d9a54 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Thu, 2 Jan 2025 22:07:10 -0600 Subject: [PATCH 1/8] Add 2023 Itasca County Leaf Off Imagery --- .gitignore | 1 + Makefile | 4 ++++ map.html | 9 +++++++++ scripts/download_satellite.py | 28 ++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100755 scripts/download_satellite.py diff --git a/.gitignore b/.gitignore index ead56f2..e39f80c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ data/plats.geojson +satellite/ diff --git a/Makefile b/Makefile index 040dd87..b145c8d 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,6 @@ plats.json: scripts/get_plats.py ./scripts/get_plats.py data/plats.geojson + +.PHONY: satellite +satellite: + ./scripts/download_satellite.py diff --git a/map.html b/map.html index 475b983..947b7cb 100644 --- a/map.html +++ b/map.html @@ -68,6 +68,15 @@ // maxZoom: 19, // attribution: '© OpenStreetMap' // }).addTo(map); + L.tileLayer('./satellite/{z}/{x}/{y}.png', { + minNativeZoom: 12, + maxNativeZoom: 20, + bounds: [ + [47.517085, -93.427584], + [47.457925, -93.340026], + ], + }).addTo(map); + // Make these requests in parallel const track_req_promise = fetch('data/track.geojson'); diff --git a/scripts/download_satellite.py b/scripts/download_satellite.py new file mode 100755 index 0000000..c7622f8 --- /dev/null +++ b/scripts/download_satellite.py @@ -0,0 +1,28 @@ +#!/usr/bin/env nix-shell +#!nix-shell --quiet -p python3 -i python + +# https://svc.pictometry.com/Image/D2B06344-7A2D-5BD0-FC89-DFDDC9888C41/wmts?SERVICE=WMTS&REQUEST=GetCapabilities + +import os +import urllib.request + +MAX_ZOOM=20 + +current, total = 0, (4 ** (MAX_ZOOM - 11) - 1)//3 + +for z in range(12, MAX_ZOOM+1): + scale = 2 ** (z - 12) + start_x = 985 * scale + start_y = 1432 * scale + for x in range(start_x, start_x + scale): + for y in range(start_y, start_y + scale): + current += 1 + progress = f"[{current:0{len(str(total))}d}/{total}]" + url = f"https://svc.pictometry.com/Image/D2B06344-7A2D-5BD0-FC89-DFDDC9888C41/wmts/PICT-MNITAS23-EDVs7UTOVt/default/GoogleMapsCompatible/{z}/{x}/{y}.png" + file = os.path.normpath(os.path.join(os.path.dirname(__file__), f"../satellite/{z}/{x}/{y}.png")) + os.makedirs(os.path.dirname(file), exist_ok=True) + if os.path.isfile(file): + print(f"{progress} {file} already exists; skipping") + continue + print(f"{progress} downloading {file}") + urllib.request.urlretrieve(url, file) From 453395690212bf3a6a71c08f61bbc1560882ce12 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Thu, 2 Jan 2025 22:08:07 -0600 Subject: [PATCH 2/8] Add Makefile deploy target --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index b145c8d..363c1ef 100644 --- a/Makefile +++ b/Makefile @@ -4,3 +4,7 @@ plats.json: scripts/get_plats.py .PHONY: satellite satellite: ./scripts/download_satellite.py + +.PHONY: deploy +deploy: plats.json satellite + rsync -avz ./ bert:/srv/www/lawrencedeerclub.chandlerswift.com/ From fb1ad615d05015f4810899a6a3eb0ef6058cdcc1 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Thu, 2 Jan 2025 22:08:40 -0600 Subject: [PATCH 3/8] Constrain map Zoom and bounds --- map.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/map.html b/map.html index 947b7cb..f1a213e 100644 --- a/map.html +++ b/map.html @@ -63,7 +63,14 @@