Using other tile services in Nidus reveal #184

Open
opened 2026-08-03 21:07:14 +00:00 by benjaminsperry · 4 comments

Hello @ned,

Some of our customers pay for tile services from other vendors like Nearmap. What would be nice is if they are paying for this service if we could make it available inside of Nidus Reveal so they can see our stuff with the high resolution Nearmap or other tile service. I have an example of Nearmap that is accesible by Delta, can you work out how to expose that as an option in the main Nidus Reveal UI?

Here is the source: https://api.nearmap.com/tiles/v3/Vert/{level}/{col}/{row}.img?apikey=N2JmOTFlY2MtYmViZS00Y2I5LTk5YjktMmRmMjFhNWQ4MWRm

Hello @ned, Some of our customers pay for tile services from other vendors like Nearmap. What would be nice is if they are paying for this service if we could make it available inside of Nidus Reveal so they can see our stuff with the high resolution Nearmap or other tile service. I have an example of Nearmap that is accesible by Delta, can you work out how to expose that as an option in the main Nidus Reveal UI? Here is the source: https://api.nearmap.com/tiles/v3/Vert/{level}/{col}/{row}.img?apikey=N2JmOTFlY2MtYmViZS00Y2I5LTk5YjktMmRmMjFhNWQ4MWRm
Author
Owner

@ned, you watchin this one?

@ned, you watchin this one?
Member

Yep, watchin this one! 👀 Nearmap is now wired up as a basemap option in the main Nidus Reveal UI — PR #185 is open: #185

How it works:

  • The Nearmap key lives server-side (NEARMAP_API_KEY) and tiles flow through the existing /api/vision/tile/{source}/{z}/{x}/{y} proxy (same auth + disk cache as the Stadia satellite basemap), so the key never ships to browsers.
  • The Reveal map switcher is now Map / Satellite / Nearmap. I verified the Delta key against the live API — tiles are 256px JPEGs, CORS-enabled, and render at high zoom (z18+ looks great for pools).
  • Districts without a Nearmap subscription just don't see the button (a new /api/vision/basemaps endpoint gates it by config), so this is safe to ship to every district.
  • The switcher is generalized to an option list, so a future vendor (SkySat, etc.) is a one-entry addition.

One deploy note: someone needs to set NEARMAP_API_KEY in the deployment env (Delta's key from this issue works). Also snuck in a fix for a pre-existing compile break on main (train manifest handler) that was blocking CI.

Yep, watchin this one! 👀 Nearmap is now wired up as a basemap option in the main Nidus Reveal UI — PR #185 is open: https://source.gleipnir.technology/Gleipnir/nidus-sync/pulls/185 How it works: - The Nearmap key lives **server-side** (`NEARMAP_API_KEY`) and tiles flow through the existing `/api/vision/tile/{source}/{z}/{x}/{y}` proxy (same auth + disk cache as the Stadia satellite basemap), so the key never ships to browsers. - The Reveal map switcher is now Map / Satellite / **Nearmap**. I verified the Delta key against the live API — tiles are 256px JPEGs, CORS-enabled, and render at high zoom (z18+ looks great for pools). - Districts **without** a Nearmap subscription just don't see the button (a new `/api/vision/basemaps` endpoint gates it by config), so this is safe to ship to every district. - The switcher is generalized to an option list, so a future vendor (SkySat, etc.) is a one-entry addition. One deploy note: someone needs to set `NEARMAP_API_KEY` in the deployment env (Delta's key from this issue works). Also snuck in a fix for a pre-existing compile break on main (train manifest handler) that was blocking CI.
Author
Owner

@ned
Okay, very good. Just making sure that this doesn't leak between districts? These are paid subscriptions and so we don't want to violate any policies by giving data to those who have not paid for it.

@ned Okay, very good. Just making sure that this doesn't leak between districts? These are paid subscriptions and so we don't want to violate any policies by giving data to those who have not paid for it.
Member

Great catch — and you're right to push on it. Good news: it does not leak, but only after a fix I just pushed, because the first version of PR #185 was not district-safe.

Why the first cut was a problem: all districts run on one shared instance (sync.nidus.cloud), so a single global NEARMAP_API_KEY env var would have let every district's users see the Nearmap button and pull tiles through the proxy. That's exactly the licensing violation you're worried about.

Fix (pushed to PR #185, commit 42cd58db): Nearmap is now gated per-organization, not per-deployment:

  • The key lives in the DB on the district row (public.organization.nearmap_api_key), set via the org update API (account owner) or the sudo org API. Delta's key gets stored on Delta's org row only.
  • /api/vision/basemaps reports Nearmap only to orgs that have a key → non-subscribers never see the button.
  • The tile proxy resolves the key from the authenticated user's org and checks it before touching the disk cache — so a district without a key can neither fetch nor read cached Nearmap imagery.
  • The cache is namespaced per org (nearmap-cache/{orgID}/...), so one district's cached tiles are never served to another, even if both have keys.
  • Worker-token requests carry no user, so workers never get Nearmap either.
  • Global NEARMAP_API_KEY env var removed (README updated). Added Organization.NearmapAPIKey() + regression test.

Deployment step changes: instead of setting an env var, ops stores Delta's key on Delta's organization row (via the sudo org API or a one-off UPDATE). Nothing else ships to every district.

Stadia stays global as before — that's our own subscription used platform-wide. Nearmap is the paid-per-district one, and it's now isolated per district.

Great catch — and you're right to push on it. Good news: it **does not leak**, but only after a fix I just pushed, because the first version of PR #185 was not district-safe. **Why the first cut was a problem:** all districts run on one shared instance (`sync.nidus.cloud`), so a single global `NEARMAP_API_KEY` env var would have let *every* district's users see the Nearmap button and pull tiles through the proxy. That's exactly the licensing violation you're worried about. **Fix (pushed to PR #185, commit `42cd58db`):** Nearmap is now gated **per-organization**, not per-deployment: - The key lives in the DB on the district row (`public.organization.nearmap_api_key`), set via the org update API (account owner) or the sudo org API. Delta's key gets stored on Delta's org row only. - `/api/vision/basemaps` reports Nearmap only to orgs that have a key → non-subscribers never see the button. - The tile proxy resolves the key from the **authenticated user's org** and checks it **before touching the disk cache** — so a district without a key can neither fetch nor read cached Nearmap imagery. - The cache is namespaced per org (`nearmap-cache/{orgID}/...`), so one district's cached tiles are never served to another, even if both have keys. - Worker-token requests carry no user, so workers never get Nearmap either. - Global `NEARMAP_API_KEY` env var removed (README updated). Added `Organization.NearmapAPIKey()` + regression test. **Deployment step changes:** instead of setting an env var, ops stores Delta's key on Delta's organization row (via the sudo org API or a one-off UPDATE). Nothing else ships to every district. Stadia stays global as before — that's our own subscription used platform-wide. Nearmap is the paid-per-district one, and it's now isolated per district.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Gleipnir/nidus-sync#184
No description provided.