fix: route tile downloads through MapTiler to stop OSM 403 blocks#15
Open
erikleon wants to merge 7 commits into
Open
fix: route tile downloads through MapTiler to stop OSM 403 blocks#15erikleon wants to merge 7 commits into
erikleon wants to merge 7 commits into
Conversation
OSM's tile usage policy prohibits bulk downloads from tile.openstreetmap.org, causing 403 Access Blocked. Default osm/satellite/terrain sources now use MapTiler (requires MAPTILER_KEY). Raw OSM is still available as 'osm-direct' but gated behind --i-understand-osm-policy with hard-capped workers=2, delay>=1s. All requests now send a proper User-Agent with contact info and Referer, plus exponential backoff on 429/403/503 honoring Retry-After. Non-image responses are rejected instead of being silently saved as .png. Defaults dropped to --max-workers=2 and --delay=0.5 to match policy norms.
Tile source dropdown now labels MapTiler-backed sources and adds osm-direct as a policy-restricted option. New inputs for the MapTiler API key (embedded into the generated command) and User-Agent contact. The Leaflet preview layer also switches to MapTiler so panning the preview no longer hammers tile.openstreetmap.org. Default delay raised to 0.5 and workers lowered to 2 to match the CLI.
Quick-start now instructs users to export MAPTILER_KEY before generating tiles. Map Sources section explains why OSM's public servers are no longer the default and how to opt into osm-direct with the required flag.
Review Summary by QodoRoute tile downloads through MapTiler; restrict direct OSM access
WalkthroughsDescription• Route tile downloads through MapTiler to comply with OSM policy - Default sources (osm/satellite/terrain) now use MapTiler API - Raw OSM available as osm-direct with policy gate and hard caps • Implement policy-compliant HTTP client with proper headers and retries - Add User-Agent with contact info and Referer header - Exponential backoff on 429/403/503 with Retry-After support - Reject non-image responses instead of saving error HTML as PNG • Update GUI to support MapTiler key and contact fields - Add MapTiler key input and contact email field - Switch preview layer to MapTiler to avoid hammering OSM servers - Update tile source dropdown with policy labels • Lower default concurrency and increase delay for policy compliance - max-workers: 3 → 2, delay: 0.2 → 0.5 seconds Diagramflowchart LR
A["OSM Policy<br/>Violation"] -->|"Bulk downloads<br/>prohibited"| B["403 Blocks"]
C["MapTiler API<br/>Free tier"] -->|"Explicit offline<br/>caching support"| D["Default sources<br/>osm/satellite/terrain"]
E["osm-direct<br/>Raw OSM"] -->|"Policy-gated<br/>--i-understand-osm-policy"| F["Hard-capped<br/>workers=2, delay≥1s"]
D -->|"Requires key"| G["User provides<br/>MAPTILER_KEY"]
H["Policy-compliant<br/>HTTP client"] -->|"User-Agent +<br/>Referer + Retry-After"| D
H -->|"Rejects non-image<br/>responses"| I["Valid PNG/JPG tiles"]
File Changes1. meshtastic_tiles.py
|
Code Review by Qodo
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Downloaded tiles from
tile.openstreetmap.orgare returning 403 Access Blocked because the tool violates OSM's Tile Usage Policy — specifically the prohibition on bulk downloading. This PR fixes the root cause rather than trying to mask it.Core change: default
osm/satellite/terrainsources now route through MapTiler (free tier, explicitly permits offline caching with an API key). Raw OSM remains available as an opt-inosm-directsource gated behind--i-understand-osm-policywith hard-capped concurrency (workers=2, delay≥1s).Policy-compliant HTTP client:
User-Agent: tdeck-maps/1.0 (<contact>)with contact info, plusReferer— required by MapTiler, OSM, and Nominatim policiesRetry-After.pngosm-directwith a pointer to the policy URL--max-workers 3 → 2,--delay 0.2 → 0.5GUI (
maps.html): adds a MapTiler key field + contact field, emits--maptiler-key/--contact/--i-understand-osm-policyin the generated command, and switches the Leaflet preview layer to MapTiler so panning the preview no longer hammers OSM's servers either.Docs: README now explains the MapTiler key requirement up-front and why OSM direct is restricted.
Commits (bisectable)
chore: ignore tiles output and .DS_Storefix: route tile downloads through MapTiler; restrict direct OSM— core client + CLIfeat(gui): add MapTiler key + contact fields; switch preview to MapTilerdocs: document MapTiler key requirement and OSM policy rationaleTest plan
python3 -c "import ast; ast.parse(open('meshtastic_tiles.py').read())"passes--helprenders new flags (--maptiler-key,--contact,--i-understand-osm-policy, new--sourcechoices)python3 meshtastic_tiles.py --city "Portland" --source osmexits cleanly with "MapTiler key required" messageosm-directgate: refuses to run without--i-understand-osm-policyand prints the policy URLMAPTILER_KEY=<key> python3 meshtastic_tiles.py --city "Portland" --min-zoom 10 --max-zoom 11— download completes, tiles are valid PNGs (needs reviewer's MapTiler key)maps.html, enter MapTiler key, verify preview loads fromapi.maptiler.com(check Network tab) and generated command includes--maptiler-keyNotes
--contactis hardcoded to the author's email (ekarwatowski@gmail.com); redistributors should override with their own via--contactor the GUI contact field.--source cycle(Thunderforest, required a key that was never wired up) has been removed since it was already broken.