Dual-mode tile URL resolver helper (src/lib/gis/tile-url.ts) #46

Closed
opened 2026-10-14 22:28:36 +00:00 by yuris · 0 comments
Owner

What to build

Implement the client-side tile URL resolution helper in src/lib/gis/tile-url.ts so all frontend layers seamlessly route to the Anycast CDN edge in production or fallback to the local /tiles/[file] route in local development.

Technical specifications

  1. Target files:
    • src/lib/gis/tile-url.ts: Resolver function getTileUrl(archiveName: string): string.
    • src/lib/gis/__tests__/tile-url.test.ts: Unit test suite.
  2. Logic:
    • When NEXT_PUBLIC_TILES_BASE_URL is configured, return ${NEXT_PUBLIC_TILES_BASE_URL}/${archiveName}.pmtiles.
    • Otherwise, return pmtiles:///tiles/${archiveName}.pmtiles.

Acceptance criteria

  • Returns CDN URL when env var is populated.
  • Returns local route URL when env var is empty.
  • Unit tests pass 100%.

Blocked by

  • Issue 26: [Backend] Local tile streaming HTTP 206 route handler (src/app/tiles/[file]/route.ts).

Authoritative Specifications & Reference Documentation

### What to build Implement the client-side tile URL resolution helper in `src/lib/gis/tile-url.ts` so all frontend layers seamlessly route to the Anycast CDN edge in production or fallback to the local `/tiles/[file]` route in local development. ### Technical specifications 1. **Target files**: - `src/lib/gis/tile-url.ts`: Resolver function `getTileUrl(archiveName: string): string`. - `src/lib/gis/__tests__/tile-url.test.ts`: Unit test suite. 2. **Logic**: - When `NEXT_PUBLIC_TILES_BASE_URL` is configured, return `${NEXT_PUBLIC_TILES_BASE_URL}/${archiveName}.pmtiles`. - Otherwise, return `pmtiles:///tiles/${archiveName}.pmtiles`. ### Acceptance criteria - [x] Returns CDN URL when env var is populated. - [x] Returns local route URL when env var is empty. - [x] Unit tests pass 100%. ### Blocked by - Issue 26: [Backend] Local tile streaming HTTP 206 route handler (`src/app/tiles/[file]/route.ts`). --- ### Authoritative Specifications & Reference Documentation - **Titik Gambut Architecture & Subsystem Contract**: [`docs/ARCHITECTURE.md`](https://git.nokopia.com/yuris/titik-gambut-next/src/branch/main/docs/ARCHITECTURE.md) - **Protomaps PMTiles Specification**: [protomaps/PMTiles GitHub](https://github.com/protomaps/PMTiles) — cloud-optimized single-file vector/raster tile format using HTTP 206 byte-range requests. - **Protomaps Basemaps Style & Docs**: [protomaps.com/docs](https://docs.protomaps.com/basemaps/) - **Cloudflare R2 Object Storage**: [developers.cloudflare.com/r2](https://developers.cloudflare.com/r2/) — Zero-egress HTTP 206 byte-range object storage. - **Cloudflare CDN Cache-Control**: [developers.cloudflare.com/cache](https://developers.cloudflare.com/cache/) — Edge caching and Range header behavior.
yuris changed title from Issue 33: [Frontend] Dual-mode tile URL resolver helper (src/lib/gis/tile-url.ts) to [Frontend] Dual-mode tile URL resolver helper (src/lib/gis/tile-url.ts) 2026-10-14 22:31:28 +00:00
yuris changed title from [Frontend] Dual-mode tile URL resolver helper (src/lib/gis/tile-url.ts) to Dual-mode tile URL resolver helper (src/lib/gis/tile-url.ts) 2026-10-14 22:38:33 +00:00
yuris closed this issue 2026-10-15 02:55:49 +00:00
Sign in to join this conversation.
No labels
backend
frontend
No project
No assignees
1 participant
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
yuris/titik-gambut-next#46
No description provided.