feat(tile-proxy): Thunderforest Outdoors as foreign karte upstream
OpenTopoMap's hypsometric tint reads "red mountains / green flats" and looks nothing like the Swisstopo Pixelkarte the proxy hands out in-region — produced a jarring visual seam right at the CH/LI border. Thunderforest Outdoors has a muted topo palette + subtle hillshade that matches the swisstopo tile aesthetic much more closely, so use it as the abroad `karte` upstream when an API key is available. - `tile-proxy/build.rs`: reads `tile-proxy/.env` (gitignored) at build time and forwards each `KEY=VAL` line to rustc as `--env`, so the key is baked into the binary via `option_env!` and never touched at runtime. A shell env var of the same name wins over the .env entry (dotenv precedence). `cargo:rerun-if-changed=.env` + `cargo:rerun-if-env-changed` force a recompile whenever the value changes — no stale key cached in the binary. - `main.rs`: `THUNDERFOREST_API_KEY` read via `option_env!`; foreign `karte` is Thunderforest Outdoors when set, OpenTopoMap fallback when absent. Behaviour unchanged for keyless builds. - `mapTiles.ts`: page-footer attribution credits Thunderforest + OSM alongside the existing swisstopo / OpenTopoMap / Esri lines so the attribution stays correct regardless of which build is deployed. - `.gitignore`: tile-proxy build artefacts (binary, `target/`, `.env`) moved to the root gitignore with fully-qualified paths so the source tree isn't hidden by a nested gitignore quirk; the per-dir `tile-proxy/.gitignore` is removed. - README + systemd service: documentation refreshed for the new build-time key flow.
This commit is contained in:
+27
-9
@@ -27,11 +27,25 @@ is stateless.
|
||||
|
||||
## Layers & providers
|
||||
|
||||
| `{layer}` | swisstopo region (CH + LI) | elsewhere |
|
||||
|------------|----------------------------------|-----------------------|
|
||||
| `karte` | `ch.swisstopo.pixelkarte-farbe` | OpenTopoMap |
|
||||
| `luftbild` | `ch.swisstopo.swissimage` | Esri World Imagery |
|
||||
| `dufour` | `ch.swisstopo.hiks-dufour` | — (CH/LI-only) |
|
||||
| `{layer}` | swisstopo region (CH + LI) | elsewhere |
|
||||
|------------|----------------------------------|----------------------------------------|
|
||||
| `karte` | `ch.swisstopo.pixelkarte-farbe` | Thunderforest Outdoors (or OpenTopoMap)|
|
||||
| `luftbild` | `ch.swisstopo.swissimage` | Esri World Imagery |
|
||||
| `dufour` | `ch.swisstopo.hiks-dufour` | — (CH/LI-only) |
|
||||
|
||||
The `karte` upstream abroad is **Thunderforest Outdoors** when a
|
||||
`THUNDERFOREST_API_KEY` is available at **build** time — it's baked into the
|
||||
binary via `option_env!`. The key is read from `tile-proxy/.env` (gitignored)
|
||||
by `build.rs`, or from a shell env var of the same name; both are watched so
|
||||
the binary recompiles whenever the value changes. Without a key, the build
|
||||
falls back to **OpenTopoMap** (no key needed, but its hypsometric tint reads
|
||||
as "red mountains / green flats", which is why Thunderforest is preferred
|
||||
when available).
|
||||
|
||||
```sh
|
||||
# tile-proxy/.env (gitignored)
|
||||
THUNDERFOREST_API_KEY=your-key-here
|
||||
```
|
||||
|
||||
The swisstopo region is **Switzerland + Liechtenstein** (swisstopo has
|
||||
high-quality data for both). A tile is served by swisstopo when it **overlaps**
|
||||
@@ -45,13 +59,16 @@ that 404s near the edge falls back to the global provider automatically.
|
||||
## Build & run
|
||||
|
||||
```sh
|
||||
# Optional: drop a Thunderforest key in tile-proxy/.env for nicer abroad
|
||||
# `karte` tiles; the build falls back to OpenTopoMap when the file is absent.
|
||||
echo 'THUNDERFOREST_API_KEY=your-key-here' > .env
|
||||
cargo build --release
|
||||
TILE_PROXY_ADDR=127.0.0.1:8765 ./target/release/tile-proxy
|
||||
# smoke test
|
||||
curl -s -o /dev/null -w '%{http_code} %{content_type}\n' \
|
||||
http://127.0.0.1:8765/karte/9/266/180 # Bern → swisstopo (jpeg)
|
||||
curl -s -o /dev/null -w '%{http_code} %{content_type}\n' \
|
||||
http://127.0.0.1:8765/karte/9/255/171 # London → OpenTopoMap (png)
|
||||
http://127.0.0.1:8765/karte/9/255/171 # London → Thunderforest / OpenTopoMap (png)
|
||||
```
|
||||
|
||||
`TILE_PROXY_ADDR` defaults to `127.0.0.1:8765` but should be set explicitly.
|
||||
@@ -78,11 +95,12 @@ cache so old tiles aren't served by the previous provider.
|
||||
|
||||
## Attribution (required)
|
||||
|
||||
All three providers require credit — keep these on the page (the hikes pages
|
||||
show them in the footer):
|
||||
All providers require credit — keep these on the page (the hikes pages show
|
||||
them in the footer):
|
||||
|
||||
- **© swisstopo** — Swiss tiles.
|
||||
- **© OpenStreetMap contributors, SRTM | © OpenTopoMap (CC-BY-SA)** — world schematic.
|
||||
- **Maps © Thunderforest, Data © OpenStreetMap contributors** — world schematic (when the key is baked in).
|
||||
- **© OpenStreetMap contributors, SRTM | © OpenTopoMap (CC-BY-SA)** — world schematic (fallback build).
|
||||
- **© Esri, Maxar, Earthstar Geographics** — world satellite.
|
||||
|
||||
## Notes
|
||||
|
||||
Reference in New Issue
Block a user