diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 2f453d26..4ac84777 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -28,21 +28,22 @@ jobs: - name: core paths: wrolpi/test - name: media - paths: modules/videos modules/zim modules/docs modules/map modules/inventory modules/flasher + paths: modules/videos modules/zim modules/docs modules/map modules/inventory modules/flasher tiles - name: files paths: wrolpi/files wrolpi/collections - name: rest paths: >- --ignore=wrolpi/test --ignore=modules/videos --ignore=modules/zim --ignore=modules/docs --ignore=modules/map - --ignore=modules/inventory --ignore=modules/flasher + --ignore=modules/inventory --ignore=modules/flasher --ignore=tiles --ignore=wrolpi/files --ignore=wrolpi/collections steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install system packages - run: sudo apt-get update && sudo apt-get install -y ffmpeg catdoc + # Mesa's EGL and GL drivers: the map tile service (tiles/) draws with them. + run: sudo apt-get update && sudo apt-get install -y ffmpeg catdoc libegl1 libegl-mesa0 libgl1-mesa-dri libgles2 - name: Setup Python uses: actions/setup-python@v5 diff --git a/app/src/components/Map.js b/app/src/components/Map.js index 839e98dd..1bf7ad24 100644 --- a/app/src/components/Map.js +++ b/app/src/components/Map.js @@ -28,6 +28,7 @@ import maplibregl from "maplibre-gl"; import {Protocol} from "pmtiles"; import layers from "protomaps-themes-base"; import {planMapFiles, pmtilesUrl} from "./mapOverlays"; +import {MapAtak} from "./MapAtak"; // Ensure PMTiles protocol is registered (may already be registered by MapViewer). try { maplibregl.addProtocol("pmtiles", new Protocol().tile); } catch (e) { /* already registered */ } @@ -860,6 +861,8 @@ export function MapRoute() { const links = [ {text: 'Map', to: '/map', key: 'map', end: true}, {text: 'Pins', to: '/map/pins', key: 'pins'}, + // Manage (and Statistics, on pages which have one) are the last tabs. + {text: 'ATAK', to: '/map/atak', key: 'atak'}, {text: 'Manage', to: '/map/manage', key: 'manage'}, ]; @@ -870,6 +873,7 @@ export function MapRoute() { }/> }/> + }/> }/> diff --git a/app/src/components/MapAtak.js b/app/src/components/MapAtak.js new file mode 100644 index 00000000..a46dceeb --- /dev/null +++ b/app/src/components/MapAtak.js @@ -0,0 +1,222 @@ +// The map's ATAK tab: how to use this WROLPi's map in ATAK (Android) and iTAK (iPhone), and what the +// tile service (tiles/, wrolpi-tiles) is doing. +import React, {useCallback, useEffect, useRef, useState} from "react"; +import {APIButton, ErrorMessage, humanFileSize, InfoMessage} from "./Common"; +import {Group, Header, Panel, Table} from "./ui"; + +// How often the status is asked for while the tab is open. +const STATUS_INTERVAL_MS = 5000; + +// The map source over plain HTTP: no certificate is needed, so it works on any phone. +export function httpMapSourceUrl(hostname = window.location.hostname) { + return `http://${hostname}:8088/tiles/wrolpi.xml`; +} + +// The map source over HTTPS: the phone must trust this WROLPi's certificate authority. +export function httpsMapSourceUrl(origin = window.location.origin) { + return `${origin}/tiles/wrolpi.xml`; +} + +// Whether this page was opened on the WROLPi itself (or through Docker's localhost): then the map +// source addresses name this computer, and a phone can not open them. +export function isLoopback(hostname = window.location.hostname) { + return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]' || hostname === '::1'; +} + +// Remove the tiles the tile service keeps; they are drawn again when a phone next asks for them. +export async function clearTileCache() { + const response = await fetch('/tiles/cache/clear', {method: 'POST'}); + if (!response.ok) { + throw new Error(`Could not clear the kept tiles: ${response.status}`); + } + return await response.json(); +} + +// The status of the tile service, and a function which asks for it now. The status is null while +// the first request is pending, undefined when the service did not answer. +// +// Only the newest request may write the status: a slow answer which settles after a newer poll (or +// after the refresh which follows clearing the kept tiles) would put an older status back. +export function useTileStatus(interval = STATUS_INTERVAL_MS) { + const [status, setStatus] = useState(null); + // Each request's number; a request writes only while it is the newest. Unmounting makes every + // request in flight old. + const generation = useRef(0); + + const fetchStatus = useCallback(async () => { + const mine = ++generation.current; + let data; + try { + const response = await fetch('/tiles/status'); + data = response.ok ? await response.json() : undefined; + } catch (e) { + data = undefined; + } + if (mine === generation.current) setStatus(data); + }, []); + + useEffect(() => { + // The counter itself (not a DOM node): on unmount every request in flight becomes old. + const requests = generation; + fetchStatus(); + const timer = setInterval(fetchStatus, interval); + return () => { + requests.current++; + clearInterval(timer); + }; + }, [interval, fetchStatus]); + + return [status, fetchStatus]; +} + +function MapSourceRow({label, name, url, note}) { + return + + {label} +
{note} Called {name} in the app.
+
+ {url} + + navigator.clipboard.writeText(url)}/> + +
; +} + +function HowTo() { + return +
Use this map in ATAK or iTAK
+

+ ATAK (Android) and iTAK (iPhone) can draw this WROLPi's map while the phone is on this + WROLPi's network, and download an area of it to use when it is not. +

+ {isLoopback() && + This page was opened on this computer ({window.location.hostname}), so these addresses only + work here. On the phone, open this page (or these addresses) with this WROLPi's address on + your network or its hotspot instead. + } + + + + + +
+
    +
  1. On the phone, open a map source address above in its browser; it downloads a small + file. +
  2. +
  3. Open that file with ATAK or iTAK (or import it with the app's import tool).
  4. +
  5. Choose WROLPi Map (or WROLPi Map (HTTPS)) in the app's list of maps.
  6. +
  7. To use the map away from this WROLPi, download an area of it with the app's map + download tool while still connected. +
  8. +
+

+ For HTTPS, the phone must first install and trust{' '} + this WROLPi's certificate. On an iPhone, after installing it, turn + it on in Settings, General, About, Certificate Trust Settings. +

+

+ The map is of the map files on the Manage tab. Map data © OpenStreetMap contributors. +

+
; +} + +function secondsAgo(timestamp) { + const seconds = Math.max(0, Math.round(Date.now() / 1000 - timestamp)); + if (seconds < 60) return `${seconds}s ago`; + if (seconds < 3600) return `${Math.round(seconds / 60)}m ago`; + return `${Math.round(seconds / 3600)}h ago`; +} + +function TileServiceStatus({status, refresh}) { + if (status === null) { + return
Tile service

Loading...

; + } + if (status === undefined) { + return +
Tile service
+ The tile service is not running. Start wrolpi-tiles on the + Controller page. +
; + } + + const basemaps = status.maps.length; + const cache = status.cache; + return +
Tile service
+ {!status.renderer && The tile service cannot draw tiles: its renderer (mapli) is not + installed.} + {basemaps === 0 && There are no map files; download some on the Manage tab.} + + + + Map files + {basemaps} + + + Tiles sent + {status.tiles_per_second} per second (last minute) + + + Waiting to be drawn + {status.queued_blocks + status.drawing_blocks} blocks of 16 tiles + + + Kept tiles + + {cache.enabled + ? + {humanFileSize(cache.bytes)} of {humanFileSize(cache.max_bytes)} + { + await clearTileCache(); + await refresh(); + }} + >Clear + + : 'Not kept'} + + + +
+
Phones (last day)
+ {status.clients.length === 0 + ?

No phone has asked for tiles.

+ : + + + Address + Tiles + Last tile + + + + {status.clients.map(client => + {client.client} + {client.tiles} + {secondsAgo(client.last_seen)} + )} + +
} +
; +} + +export function MapAtak() { + const [status, refresh] = useTileStatus(); + return <> + + + ; +} diff --git a/app/src/components/MapAtak.test.js b/app/src/components/MapAtak.test.js new file mode 100644 index 00000000..2edce416 --- /dev/null +++ b/app/src/components/MapAtak.test.js @@ -0,0 +1,171 @@ +import React from 'react'; +import {act, fireEvent, renderHook, screen, waitFor, within} from '@testing-library/react'; +import {mockFetch, renderWithProviders} from '../test-utils'; +import {humanFileSize} from './Common'; +import {clearTileCache, httpMapSourceUrl, httpsMapSourceUrl, isLoopback, MapAtak, useTileStatus} from './MapAtak'; + +const STATUS = { + renderer: true, + processes: 2, + max_zoom: 17, + maps: ['/opt/wrolpi-blobs/map-overview.pmtiles', '/media/wrolpi/map/mexico.pmtiles'], + style_id: 'abc', + queued_blocks: 3, + drawing_blocks: 2, + tiles_per_second: 31.5, + block_ms: 310, + cache: {enabled: true, bytes: 25 * 1024 * 1024, max_bytes: 1024 * 1024 * 1024}, + stats: {}, + clients: [{client: '192.0.2.34', tiles: 578, first_seen: 0, last_seen: Date.now() / 1000 - 30, queued_blocks: 0}], +}; + +describe('MapAtak', () => { + const realFetch = global.fetch; + afterEach(() => { + global.fetch = realFetch; + }); + + it('builds the map source addresses from how the browser reached this WROLPi', () => { + expect(httpMapSourceUrl('192.0.2.8')).toBe('http://192.0.2.8:8088/tiles/wrolpi.xml'); + expect(httpsMapSourceUrl('https://wrolpi.local')).toBe('https://wrolpi.local/tiles/wrolpi.xml'); + }); + + it('shows the map sources and what the tile service is doing', async () => { + global.fetch = mockFetch(STATUS); + renderWithProviders(); + + expect(screen.getByText(httpMapSourceUrl())).toHaveAttribute('href', httpMapSourceUrl()); + expect(screen.getByText(httpsMapSourceUrl())).toHaveAttribute('href', httpsMapSourceUrl()); + expect(screen.getByText("this WROLPi's certificate")).toHaveAttribute('href', '/ca.crt'); + // Both apps take an area offline (tested with iTAK on an iPhone). + expect(screen.getByText(/download an area of it with the app's map download tool/)).toBeInTheDocument(); + + expect(await screen.findByText('31.5 per second (last minute)')).toBeInTheDocument(); + expect(global.fetch).toHaveBeenCalledWith('/tiles/status'); + expect(screen.getByText('5 blocks of 16 tiles')).toBeInTheDocument(); + expect(screen.getByText(`${humanFileSize(25 * 1024 * 1024)} of ${humanFileSize(1024 * 1024 * 1024)}`)) + .toBeInTheDocument(); + expect(screen.getByText('192.0.2.34')).toBeInTheDocument(); + expect(screen.getByText('578')).toBeInTheDocument(); + expect(screen.getByText('30s ago')).toBeInTheDocument(); + }); + + it('says when the tile service is not running', async () => { + global.fetch = jest.fn(() => Promise.reject(new Error('connection refused'))); + renderWithProviders(); + expect(await screen.findByText(/The tile service is not running/)).toBeInTheDocument(); + }); + + it('says when there are no map files', async () => { + global.fetch = mockFetch({...STATUS, maps: [], clients: []}); + renderWithProviders(); + expect(await screen.findByText(/There are no map files/)).toBeInTheDocument(); + expect(screen.getByText('No phone has asked for tiles.')).toBeInTheDocument(); + }); + + it('clears the kept tiles after asking, then shows the new size', async () => { + let bytes = 25 * 1024 * 1024; + global.fetch = jest.fn(async (url, options) => { + if (url === '/tiles/cache/clear') { + expect(options).toEqual({method: 'POST'}); + const freed = bytes; + bytes = 0; + return {ok: true, status: 200, json: async () => ({freed_bytes: freed})}; + } + return {ok: true, status: 200, json: async () => ({...STATUS, cache: {...STATUS.cache, bytes}})}; + }); + renderWithProviders(); + await screen.findByText('31.5 per second (last minute)'); + + fireEvent.click(screen.getByRole('button', {name: /Clear/})); + // Nothing is removed until it is confirmed. + expect(await screen.findByText(/a phone keeps its own copy/)).toBeInTheDocument(); + expect(global.fetch).not.toHaveBeenCalledWith('/tiles/cache/clear', expect.anything()); + + const dialog = screen.getByRole('dialog'); + fireEvent.click(within(dialog).getByRole('button', {name: 'Clear'})); + await waitFor(() => expect(global.fetch).toHaveBeenCalledWith('/tiles/cache/clear', {method: 'POST'})); + expect(await screen.findByText(`${humanFileSize(0)} of ${humanFileSize(1024 * 1024 * 1024)}`)) + .toBeInTheDocument(); + }); + + it('cannot clear when no tiles are kept', async () => { + global.fetch = mockFetch({...STATUS, cache: {...STATUS.cache, bytes: 0}}); + renderWithProviders(); + await screen.findByText('31.5 per second (last minute)'); + expect(screen.getByRole('button', {name: /Clear/})).toBeDisabled(); + }); + + it('clearTileCache fails loudly when the service refuses', async () => { + global.fetch = jest.fn(async () => ({ok: false, status: 502, json: async () => ({})})); + await expect(clearTileCache()).rejects.toThrow('502'); + }); + + it('names each map source as the app will list it', async () => { + global.fetch = mockFetch(STATUS); + renderWithProviders(); + await screen.findByText('31.5 per second (last minute)'); + // The tile service names the HTTPS source differently (tiles/service.py). + expect(screen.getAllByText('WROLPi Map').length).toBeGreaterThanOrEqual(1); + expect(screen.getAllByText('WROLPi Map (HTTPS)').length).toBeGreaterThanOrEqual(1); + }); + + it('says when the addresses only work on this computer', async () => { + expect(isLoopback('localhost')).toBe(true); + expect(isLoopback('127.0.0.1')).toBe(true); + expect(isLoopback('[::1]')).toBe(true); + expect(isLoopback('wrolpi.local')).toBe(false); + expect(isLoopback('192.0.2.8')).toBe(false); + + // jsdom's page is on localhost. + global.fetch = mockFetch(STATUS); + renderWithProviders(); + expect(screen.getByText(/these addresses only\s+work here/)).toBeInTheDocument(); + await screen.findByText('31.5 per second (last minute)'); + }); + + it('does not put an older status back over a newer one', async () => { + // The first request is slow and its answer old. A newer one (as Clear's refresh makes) is + // answered first. The old answer settles last, and must not undo the newer. + let answerFirst; + let calls = 0; + global.fetch = jest.fn(() => { + calls++; + if (calls === 1) { + return new Promise(resolve => { + answerFirst = () => resolve({ok: true, status: 200, json: async () => STATUS}); + }); + } + return Promise.resolve({ok: true, status: 200, + json: async () => ({...STATUS, cache: {...STATUS.cache, bytes: 0}})}); + }); + const {result} = renderHook(() => useTileStatus(60000)); + await waitFor(() => expect(calls).toBe(1)); + + await act(async () => { + await result.current[1](); // the newer request + }); + expect(result.current[0].cache.bytes).toBe(0); + + await act(async () => { + answerFirst(); // the older one settles last + }); + expect(result.current[0].cache.bytes).toBe(0); + }); + + it('polls the status while open', async () => { + jest.useFakeTimers(); + try { + global.fetch = mockFetch(STATUS); + const {unmount} = renderWithProviders(); + await waitFor(() => expect(global.fetch).toHaveBeenCalledTimes(1)); + jest.advanceTimersByTime(5000); + await waitFor(() => expect(global.fetch).toHaveBeenCalledTimes(2)); + unmount(); + jest.advanceTimersByTime(20000); + expect(global.fetch).toHaveBeenCalledTimes(2); + } finally { + jest.useRealTimers(); + } + }); +}); diff --git a/app/src/components/mapTileStyle.test.js b/app/src/components/mapTileStyle.test.js new file mode 100644 index 00000000..20b86296 --- /dev/null +++ b/app/src/components/mapTileStyle.test.js @@ -0,0 +1,19 @@ +// The tile service (tiles/) draws the map for ATAK and iTAK with the basemap layers the web map +// draws with (MapViewer's buildStyle). It runs no JavaScript, so it reads them from a file made +// from protomaps-themes-base; this keeps that file the same as what the web map uses. +// +// After upgrading protomaps-themes-base, write the file again: +// cd app && UPDATE_TILE_STYLE=1 CI=true npm test -- --watchAll=false mapTileStyle +import fs from "fs"; +import path from "path"; +import layers from "protomaps-themes-base"; + +const FILE = path.resolve(__dirname, "../../../tiles/basemap-light.json"); +// The name of the source in the file; the tile service gives each map file a source of its own. +const SOURCE = "protomaps"; + +it("the tile service's basemap is the web map's light basemap", () => { + const expected = JSON.stringify(layers(SOURCE, "light"), null, 1) + "\n"; + if (process.env.UPDATE_TILE_STYLE) fs.writeFileSync(FILE, expected); + expect(fs.readFileSync(FILE, "utf8")).toEqual(expected); +}); diff --git a/controller/defaults.py b/controller/defaults.py index ffacffa9..64b6e360 100644 --- a/controller/defaults.py +++ b/controller/defaults.py @@ -81,6 +81,14 @@ DEFAULT_CONFIG = { "use_https": True, "description": "Kiwix/Zim server", }, + { + "name": "wrolpi-tiles", + "systemd_name": "wrolpi-tiles", + "port": 8088, + "viewable": False, + "use_https": False, + "description": "Map tiles for ATAK and iTAK", + }, { "name": "wrolpi-rsyncd", "systemd_name": "wrolpi-rsyncd", diff --git a/controller/lib/admin.py b/controller/lib/admin.py index 53c7f620..d0d4e1d2 100644 --- a/controller/lib/admin.py +++ b/controller/lib/admin.py @@ -1577,6 +1577,7 @@ async def restart_all_services() -> dict: "wrolpi-api", "wrolpi-app", "wrolpi-kiwix", + "wrolpi-tiles", "wrolpi-help", # Controller restarts itself last (scheduled after response) ] diff --git a/controller/lib/docker_services.py b/controller/lib/docker_services.py index 67cdafbc..19bd543e 100644 --- a/controller/lib/docker_services.py +++ b/controller/lib/docker_services.py @@ -27,7 +27,7 @@ except ImportError: CONTAINER_PREFIX = os.environ.get("COMPOSE_PROJECT_NAME", "wrolpi") # Containers that should not have a "View" button (non-HTTP services) -NON_VIEWABLE_CONTAINERS = {"redis", "memcached", "samba", "rsyncd"} +NON_VIEWABLE_CONTAINERS = {"redis", "memcached", "samba", "rsyncd", "tiles"} # Containers that should use HTTPS HTTPS_CONTAINERS = {"web"} diff --git a/controller/test/test_defaults.py b/controller/test/test_defaults.py index c4ba6ab3..97512dd4 100644 --- a/controller/test/test_defaults.py +++ b/controller/test/test_defaults.py @@ -57,7 +57,7 @@ class TestManagedServicesConfig: def test_managed_services_count(self): """Should have expected number of managed services.""" services = DEFAULT_CONFIG["managed_services"] - assert len(services) == 12 + assert len(services) == 13 @pytest.mark.parametrize("name,expected", [ ("wrolpi-api", @@ -65,6 +65,7 @@ class TestManagedServicesConfig: ("wrolpi-api-dev", {"systemd_name": "wrolpi-api-dev", "port": 8081, "viewable": True, "show_only_when_running": True}), ("wrolpi-app", {"port": 3000, "viewable": False}), + ("wrolpi-tiles", {"systemd_name": "wrolpi-tiles", "port": 8088, "viewable": False}), ("wrolpi-app-dev", {"port": 3000, "viewable": False, "show_only_when_running": True}), ("caddy", {"port": 443}), ("wrolpi-upgrade", {"port": None, "viewable": False, "show_only_when_running": True}), diff --git a/debian-live-config/config/includes.chroot/usr/local/sbin/wrolpi-bootstrap.sh b/debian-live-config/config/includes.chroot/usr/local/sbin/wrolpi-bootstrap.sh index bb77fdac..c2d4c5f5 100644 --- a/debian-live-config/config/includes.chroot/usr/local/sbin/wrolpi-bootstrap.sh +++ b/debian-live-config/config/includes.chroot/usr/local/sbin/wrolpi-bootstrap.sh @@ -280,8 +280,8 @@ fi # with --no-block so systemd queues the starts after we exit. progress "Starting WROLPi services..." -systemctl enable wrolpi-api.service wrolpi-app.service wrolpi-kiwix.service wrolpi-rsyncd.service -systemctl start --no-block wrolpi-api.service wrolpi-app.service wrolpi-kiwix.service wrolpi-rsyncd.service +systemctl enable wrolpi-api.service wrolpi-app.service wrolpi-kiwix.service wrolpi-tiles.service wrolpi-rsyncd.service +systemctl start --no-block wrolpi-api.service wrolpi-app.service wrolpi-kiwix.service wrolpi-tiles.service wrolpi-rsyncd.service # If we did anything notable, leave a summary for the XFCE autostart to # show as a zenity dialog once the user lands on the desktop. diff --git a/debian-live-config/config/package-lists/wrolpi.list.chroot b/debian-live-config/config/package-lists/wrolpi.list.chroot index eee4ae68..f0b07b67 100644 --- a/debian-live-config/config/package-lists/wrolpi.list.chroot +++ b/debian-live-config/config/package-lists/wrolpi.list.chroot @@ -99,3 +99,7 @@ wpasupplicant zenity zim-tools zlib1g-dev +libegl1 +libegl-mesa0 +libgl1-mesa-dri +libgles2 diff --git a/docker-compose.yml b/docker-compose.yml index eb1d2319..aab12241 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -58,6 +58,29 @@ services: test: [ 'CMD-SHELL', 'curl http://127.0.0.1:8081/api/echo' ] interval: 2m + tiles: # Map tiles for ATAK and iTAK, drawn from the map's PMTiles (tiles/). The api image, another command. + build: + context: . + dockerfile: docker/api/Dockerfile + entrypoint: [ 'python3', '-O', '-m', 'tiles', '--host', '0.0.0.0', '--port', '9088' ] + command: [ ] + environment: + - CACHE_DIRECTORY=/var/cache/wrolpi-tiles + # The page at :8088/ links to the WROLPi app, which Docker publishes on this port. + - TILES_HTTPS_PORT=${WEB_HTTPS_PORT-8443} + volumes: + - './tiles:/opt/wrolpi/tiles' + - './modules/map/static:/opt/wrolpi/modules/map/static:ro' + - './test:/media/wrolpi:ro' + user: '${UID-1000}:${GID-1000}' + # Two render processes are about 600 MB; a phone taking an area offline keeps them busy for minutes, so it + # gets less of the CPU than the API. + mem_limit: 1200m + cpu_shares: 512 + healthcheck: + test: [ 'CMD-SHELL', 'curl -f http://127.0.0.1:9088/tiles/status' ] + interval: 2m + archive: # Python/Sanic wrapper around Singlefile and Readability. build: context: . @@ -111,6 +134,7 @@ services: - app - zim - help + - tiles build: context: . dockerfile: docker/web/Dockerfile @@ -119,6 +143,7 @@ services: - '8084:8084' - '8085:8085' - '8086:8086' + - '8088:8088' volumes: - './docker/web/Caddyfile:/etc/caddy/Caddyfile' - './icon.ico:/etc/caddy/favicon.ico' diff --git a/docker/api/Dockerfile b/docker/api/Dockerfile index ac0f26dc..a93252af 100644 --- a/docker/api/Dockerfile +++ b/docker/api/Dockerfile @@ -6,7 +6,9 @@ WORKDIR /opt/wrolpi # Update dependencies for the services install. RUN apt-get update && apt-get install -y ffmpeg catdoc sysstat aria2 iputils-ping unrar-free unzip rsync \ - build-essential libsqlite3-dev zlib1g-dev git + build-essential libsqlite3-dev zlib1g-dev git \ + # Mesa's EGL and GL drivers: the map tile service (tiles/) draws with them, in software here (no GPU). + libegl1 libegl-mesa0 libgl1-mesa-dri libgles2 # Install tippecanoe (for map search index building via tippecanoe-decode). RUN git clone --depth 1 --branch 2.79.0 https://github.com/felt/tippecanoe.git /tmp/tippecanoe \ @@ -36,6 +38,14 @@ RUN DENO_VERSION="v2.8.3" \ # yt-dlp needs cache directory RUN mkdir /.cache && chown -R 1000:1000 /.cache +# The planet overview (the world at zoom 0-6) the map tile service draws under the regional maps; Raspberry Pi and +# Debian installs have it at the same path. The web image has its own copy, which Caddy serves to the web map. +RUN mkdir -p /opt/wrolpi-blobs && \ + curl -fsSL https://wrolpi.nyc3.cdn.digitaloceanspaces.com/maps/map-overview.pmtiles \ + -o /opt/wrolpi-blobs/map-overview.pmtiles && \ + [ -s /opt/wrolpi-blobs/map-overview.pmtiles ] +# Where the map tile service keeps drawn tiles (systemd's CacheDirectory on a Raspberry Pi). +RUN mkdir -p /var/cache/wrolpi-tiles && chown 1000:1000 /var/cache/wrolpi-tiles # Install dependencies from the hash-locked requirements. COPY requirements.txt requirements.lock /opt/wrolpi/ @@ -46,6 +56,7 @@ RUN /opt/wrolpi/scripts/install_python_requirements.sh pip3 /opt/wrolpi/requirem COPY main.py /opt/wrolpi/ COPY wrolpi /opt/wrolpi/wrolpi COPY modules /opt/wrolpi/modules +COPY tiles /opt/wrolpi/tiles ENTRYPOINT [ "python3", "/opt/wrolpi/main.py"] # Log level controlled by LOG_LEVEL env var or wrolpi.yaml config (default: info) diff --git a/docker/help/wrolpi-help b/docker/help/wrolpi-help index 647bc561..32d87462 160000 --- a/docker/help/wrolpi-help +++ b/docker/help/wrolpi-help @@ -1 +1 @@ -Subproject commit 647bc56138a7c7f9a8f00c107eccb97cbc32e6aa +Subproject commit 32d8746222d6b0ada3a98d2e4d35c6d9c57a1727 diff --git a/docker/web/Caddyfile b/docker/web/Caddyfile index 368d518c..cddfd919 100644 --- a/docker/web/Caddyfile +++ b/docker/web/Caddyfile @@ -63,6 +63,11 @@ } + # Map tiles for ATAK and iTAK (tiles/). Also plain HTTP on 8088, below. + handle /tiles/* { + reverse_proxy tiles:9088 + } + # WROLPi blobs (planet overview map, fonts, etc.) handle_path /blobs/* { root * /opt/wrolpi-blobs @@ -111,7 +116,18 @@ } handle_errors 502 503 504 { - redir * "http://{host}:8080/?fallback=true" 302 + # A tile is never redirected to the fallback page (the tile service is starting, restarting, or down): + # ATAK keeps whatever a tile request ends with, so the page would be stored as the tile for good. A 503 + # is tried again. + @tiles path /tiles/* + handle @tiles { + header Retry-After 1 + header Cache-Control no-store + respond 503 + } + handle { + redir * "http://{host}:8080/?fallback=true" 302 + } } } @@ -131,6 +147,22 @@ reverse_proxy help:80 } +# Map tiles for ATAK and iTAK over plain HTTP: a phone must trust WROLPi's CA for HTTPS, and only once it has +# is the HTTPS map source (/tiles/ on 443) usable. +http://:8088 { + # /: a page saying what this port is. + @tiles path / /tiles /tiles/* + handle @tiles { + reverse_proxy tiles:9088 + } + handle /favicon.ico { + root * /etc/caddy + rewrite * /favicon.ico + file_server + } + respond 404 +} + # Map viewer - serves MapLibre static assets and PMTiles data via Caddy. :8084 { tls /etc/ssl/caddy/cert.crt /etc/ssl/caddy/cert.key diff --git a/etc/raspberrypios/Caddyfile b/etc/raspberrypios/Caddyfile index 5a6f2484..0029e88e 100644 --- a/etc/raspberrypios/Caddyfile +++ b/etc/raspberrypios/Caddyfile @@ -57,6 +57,11 @@ } + # Map tiles for ATAK and iTAK (tiles/). Also plain HTTP on 8088, below. + handle /tiles/* { + reverse_proxy 127.0.0.1:9088 + } + # WROLPi blobs (planet overview map, fonts, etc.) handle_path /blobs/* { root * /opt/wrolpi-blobs @@ -105,7 +110,18 @@ } handle_errors 502 503 504 { - redir * "http://{host}/?fallback=true" 302 + # A tile is never redirected to the fallback page (the tile service is starting, restarting, or down): + # ATAK keeps whatever a tile request ends with, so the page would be stored as the tile for good. A 503 + # is tried again. + @tiles path /tiles/* + handle @tiles { + header Retry-After 1 + header Cache-Control no-store + respond 503 + } + handle { + redir * "http://{host}/?fallback=true" 302 + } } } @@ -125,6 +141,22 @@ reverse_proxy 0.0.0.0:9086 } +# Map tiles for ATAK and iTAK over plain HTTP: a phone must trust WROLPi's CA for HTTPS, and only once it has +# is the HTTPS map source (/tiles/ on 443) usable. +http://:8088 { + # /: a page saying what this port is. + @tiles path / /tiles /tiles/* + handle @tiles { + reverse_proxy 127.0.0.1:9088 + } + handle /favicon.ico { + root * /opt/wrolpi + rewrite * /icon.ico + file_server + } + respond 404 +} + # Map viewer - serves MapLibre static assets and PMTiles data via Caddy. :8084 { tls /etc/ssl/wrolpi/cert.crt /etc/ssl/wrolpi/cert.key diff --git a/etc/raspberrypios/wrolpi-tiles.service b/etc/raspberrypios/wrolpi-tiles.service new file mode 100644 index 00000000..d712dd61 --- /dev/null +++ b/etc/raspberrypios/wrolpi-tiles.service @@ -0,0 +1,30 @@ +[Unit] +Description=WROLPi map tiles for ATAK and iTAK +PartOf=wrolpi.target + +[Service] +Environment=PYTHONUNBUFFERED=1 +# Caddy serves it: HTTPS at /tiles/ on 443, plain HTTP on 8088. +ExecStart=/opt/wrolpi/venv/bin/python -O -m tiles --host 127.0.0.1 --port 9088 +Group=wrolpi +User=wrolpi +# The GPU (/dev/dri/renderD128); without it tiles are drawn in software, a little slower. +SupplementaryGroups=render +WorkingDirectory=/opt/wrolpi/ +# Drawn tiles are kept in /var/cache/wrolpi-tiles (CACHE_DIRECTORY), not on the media drive. +CacheDirectory=wrolpi-tiles +Restart=on-failure +RestartSec=5 +# A phone taking an area offline keeps this busy for minutes; the API, the App and the user come first. +Nice=10 +CPUWeight=50 +IOWeight=50 +# Two render processes are about 600 MB. Past this the service is restarted, rather than the kernel killing +# something else. Raspberry Pi OS boots with the memory cgroup disabled (cgroup_disable=memory), so there these +# do nothing; OOMScoreAdjust makes this the first the kernel kills when a 4 GB Pi runs out, not the API. +MemoryHigh=900M +MemoryMax=1200M +OOMScoreAdjust=500 + +[Install] +WantedBy=default.target diff --git a/etc/raspberrypios/wrolpi.target b/etc/raspberrypios/wrolpi.target index a330cbd1..bfc164cb 100644 --- a/etc/raspberrypios/wrolpi.target +++ b/etc/raspberrypios/wrolpi.target @@ -1,3 +1,3 @@ [Unit] Description=WROLPi services group -Wants=wrolpi-controller.service wrolpi-api.service wrolpi-app.service caddy.service wrolpi-kiwix.service wrolpi-rsyncd.service +Wants=wrolpi-controller.service wrolpi-api.service wrolpi-app.service caddy.service wrolpi-kiwix.service wrolpi-tiles.service wrolpi-rsyncd.service diff --git a/pi-gen/stage2/04-wrolpi/01-packages-nr b/pi-gen/stage2/04-wrolpi/01-packages-nr index 8d1872e5..937f547a 100644 --- a/pi-gen/stage2/04-wrolpi/01-packages-nr +++ b/pi-gen/stage2/04-wrolpi/01-packages-nr @@ -76,3 +76,7 @@ vlc wget zim-tools zlib1g-dev +libegl1 +libegl-mesa0 +libgl1-mesa-dri +libgles2 diff --git a/pytest.ini b/pytest.ini index fdeea159..51cdad0b 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,6 +3,7 @@ asyncio_mode = auto testpaths = wrolpi modules + tiles asyncio_default_fixture_loop_scope = function markers = allow_unexpected_queries: the test trips the serializer query guard on purpose (see wrolpi.db.no_db_access) diff --git a/repair.sh b/repair.sh index ac77aa01..0a9feb59 100755 --- a/repair.sh +++ b/repair.sh @@ -22,6 +22,7 @@ systemctl stop wrolpi-controller.service || : systemctl stop wrolpi-api.service || : systemctl stop wrolpi-app.service || : systemctl stop wrolpi-kiwix.service || : +systemctl stop wrolpi-tiles.service || : systemctl stop caddy || : # Clear Python bytecode cache from virtual environments to fix potential corruption. @@ -92,6 +93,7 @@ systemctl enable wrolpi-controller.service systemctl enable wrolpi-api.service systemctl enable wrolpi-app.service systemctl enable wrolpi-kiwix.service +systemctl enable wrolpi-tiles.service systemctl enable wrolpi-help.service systemctl enable wrolpi-mounts.service systemctl enable wrolpi-rsyncd.service diff --git a/requirements.lock b/requirements.lock index 18932d0a..69a00976 100644 --- a/requirements.lock +++ b/requirements.lock @@ -1558,6 +1558,11 @@ mako==1.4.3 \ --hash=sha256:723296007c870bfd6b3f0c3230dba7198096e5269297ebf5e4eff9e7ffa39d4f \ --hash=sha256:cd6537fe88d5fec315c55c2f8529bc4ce7a9a352ad7db3eeaa6a66e2dd4ec37a # via alembic +mapli==0.5.0 ; sys_platform == 'linux' \ + --hash=sha256:3233570f57df1e86b7d53910af543ca00c9a7d2b3c0c108eed7e99ccdae8c6c0 \ + --hash=sha256:a99f4a9a9855dca828220c10c9e729835b1801c132db04cb3f6c8cbfe912c24b \ + --hash=sha256:c2e2961f7a48d3bbce86c9ec93c03c7a962e6266215bf2695ad6343d5aa19b09 + # via -r requirements.txt markupsafe==3.0.4 \ --hash=sha256:007e1ffd9bf65bb6ee96df7b258fc632a4868dd5566037986c64781f35a36e98 \ --hash=sha256:02fa4acbc6a3fc5c693c34d4dd8c1130b7fe99cc915181b0ddd6f72aeb296002 \ diff --git a/requirements.txt b/requirements.txt index 11da9f15..cfbd33c6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,6 +14,8 @@ feedparser==6.0.14 jc==1.26.0 libzim==3.13.1 mock==5.2.0 +# MapLibre Native, for the map tile service (tiles/). Linux only: no wheels for macOS. +mapli==0.5.0 ; sys_platform == "linux" psutil==7.2.2 pydantic>=2.0.0 PyMuPDF>=2.0 diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh index 5788ee5b..e8d8db57 100755 --- a/scripts/upgrade.sh +++ b/scripts/upgrade.sh @@ -314,6 +314,15 @@ if ! command -v dnsmasq &>/dev/null || ! command -v iw &>/dev/null || ! command -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold dnsmasq-base iw rfkill fi +# Install Mesa's EGL and GL drivers if missing (the map tile service draws with them). +if ! ldconfig -p | grep -q 'libEGL.so.1 ' || ! ldconfig -p | grep -q libEGL_mesa \ + || ! ldconfig -p | grep -q 'libGLESv2.so.2 '; then + echo "Installing libegl1, libegl-mesa0, libgl1-mesa-dri, libgles2..." + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold libegl1 libegl-mesa0 libgl1-mesa-dri libgles2 +fi + # Clean up stale landing page (Controller now serves port 80 directly). rm -f /var/www/landing.html diff --git a/tiles/__init__.py b/tiles/__init__.py new file mode 100644 index 00000000..6e4b2725 --- /dev/null +++ b/tiles/__init__.py @@ -0,0 +1,8 @@ +"""The tile service: WROLPi's map as raster tiles, for apps which draw only those (ATAK, iTAK). + +A service of its own (wrolpi-tiles), not part of the API: a phone taking an area offline asks for thousands of +tiles, each a few dozen milliseconds of CPU, and the API on a Raspberry Pi must stay responsive meanwhile. + +Nothing here imports `wrolpi` or `modules`: importing them costs about a second and 130 MB, and every render +process would pay it. +""" diff --git a/tiles/__main__.py b/tiles/__main__.py new file mode 100644 index 00000000..65e43532 --- /dev/null +++ b/tiles/__main__.py @@ -0,0 +1,36 @@ +"""Run the tile service: `python -m tiles` (see `tiles.service`).""" +import argparse +import logging +import os +from pathlib import Path + +from tiles import maps +from tiles.cache import TileCache +from tiles.service import DEFAULT_MAX_ZOOM, TileService, create_app + + +def main(): + parser = argparse.ArgumentParser(description='WROLPi map tiles for ATAK and iTAK') + parser.add_argument('--host', default='127.0.0.1') + parser.add_argument('--port', type=int, default=9088) + parser.add_argument('--processes', type=int, default=int(os.environ.get('TILES_PROCESSES', 2)), + help='Render processes; each is about 250 MB (default 2, or TILES_PROCESSES)') + parser.add_argument('--max-zoom', type=int, default=DEFAULT_MAX_ZOOM) + parser.add_argument('--cache-directory', type=Path, + default=Path(os.environ.get('CACHE_DIRECTORY', '/var/cache/wrolpi-tiles')), + help='Where drawn tiles are kept (default: systemd CACHE_DIRECTORY)') + parser.add_argument('--cache-mb', type=int, default=int(os.environ.get('TILES_CACHE_MB', 1024)), + help='Most the cache may hold, 0 to keep nothing (default 1024, or TILES_CACHE_MB)') + parser.add_argument('--min-free-mb', type=int, default=2048, + help='Keep no tiles when the disk has less free than this (default 2048)') + args = parser.parse_args() + + logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(name)s: %(message)s') + cache = TileCache(args.cache_directory, args.cache_mb * 2 ** 20, args.min_free_mb * 2 ** 20) + service = TileService(maps.get_map_directory(), cache, processes=args.processes, max_zoom=args.max_zoom) + app = create_app(service) + app.run(host=args.host, port=args.port, single_process=True, access_log=False, motd=False) + + +if __name__ == '__main__': + main() diff --git a/tiles/basemap-light.json b/tiles/basemap-light.json new file mode 100644 index 00000000..ae87bfd3 --- /dev/null +++ b/tiles/basemap-light.json @@ -0,0 +1,10912 @@ +[ + { + "id": "background", + "type": "background", + "paint": { + "background-color": "#cccccc" + } + }, + { + "id": "earth", + "type": "fill", + "filter": [ + "==", + "$type", + "Polygon" + ], + "source": "protomaps", + "source-layer": "earth", + "paint": { + "fill-color": "#e2dfda" + } + }, + { + "id": "landcover", + "type": "fill", + "source": "protomaps", + "source-layer": "landcover", + "paint": { + "fill-color": [ + "match", + [ + "get", + "kind" + ], + "grassland", + "rgba(210, 239, 207, 1)", + "barren", + "rgba(255, 243, 215, 1)", + "urban_area", + "rgba(230, 230, 230, 1)", + "farmland", + "rgba(216, 239, 210, 1)", + "glacier", + "rgba(255, 255, 255, 1)", + "scrub", + "rgba(234, 239, 210, 1)", + "rgba(196, 231, 210, 1)" + ], + "fill-opacity": [ + "interpolate", + [ + "linear" + ], + [ + "zoom" + ], + 5, + 1, + 7, + 0 + ] + } + }, + { + "id": "landuse_park", + "type": "fill", + "source": "protomaps", + "source-layer": "landuse", + "filter": [ + "in", + "kind", + "national_park", + "park", + "cemetery", + "protected_area", + "nature_reserve", + "forest", + "golf_course", + "wood", + "nature_reserve", + "forest", + "scrub", + "grassland", + "grass", + "military", + "naval_base", + "airfield" + ], + "paint": { + "fill-opacity": [ + "interpolate", + [ + "linear" + ], + [ + "zoom" + ], + 6, + 0, + 11, + 1 + ], + "fill-color": [ + "case", + [ + "in", + [ + "get", + "kind" + ], + [ + "literal", + [ + "national_park", + "park", + "cemetery", + "protected_area", + "nature_reserve", + "forest", + "golf_course" + ] + ] + ], + "#9cd3b4", + [ + "in", + [ + "get", + "kind" + ], + [ + "literal", + [ + "wood", + "nature_reserve", + "forest" + ] + ] + ], + "#a0d9a0", + [ + "in", + [ + "get", + "kind" + ], + [ + "literal", + [ + "scrub", + "grassland", + "grass" + ] + ] + ], + "#99d2bb", + [ + "in", + [ + "get", + "kind" + ], + [ + "literal", + [ + "glacier" + ] + ] + ], + "#e7e7e7", + [ + "in", + [ + "get", + "kind" + ], + [ + "literal", + [ + "sand" + ] + ] + ], + "#e2e0d7", + [ + "in", + [ + "get", + "kind" + ], + [ + "literal", + [ + "military", + "naval_base", + "airfield" + ] + ] + ], + "#c6dcdc", + "#e2dfda" + ] + } + }, + { + "id": "landuse_urban_green", + "type": "fill", + "source": "protomaps", + "source-layer": "landuse", + "filter": [ + "in", + "kind", + "allotments", + "village_green", + "playground" + ], + "paint": { + "fill-color": "#9cd3b4", + "fill-opacity": 0.7 + } + }, + { + "id": "landuse_hospital", + "type": "fill", + "source": "protomaps", + "source-layer": "landuse", + "filter": [ + "==", + "kind", + "hospital" + ], + "paint": { + "fill-color": "#e4dad9" + } + }, + { + "id": "landuse_industrial", + "type": "fill", + "source": "protomaps", + "source-layer": "landuse", + "filter": [ + "==", + "kind", + "industrial" + ], + "paint": { + "fill-color": "#d1dde1" + } + }, + { + "id": "landuse_school", + "type": "fill", + "source": "protomaps", + "source-layer": "landuse", + "filter": [ + "in", + "kind", + "school", + "university", + "college" + ], + "paint": { + "fill-color": "#e4ded7" + } + }, + { + "id": "landuse_beach", + "type": "fill", + "source": "protomaps", + "source-layer": "landuse", + "filter": [ + "in", + "kind", + "beach" + ], + "paint": { + "fill-color": "#e8e4d0" + } + }, + { + "id": "landuse_zoo", + "type": "fill", + "source": "protomaps", + "source-layer": "landuse", + "filter": [ + "in", + "kind", + "zoo" + ], + "paint": { + "fill-color": "#c6dcdc" + } + }, + { + "id": "landuse_aerodrome", + "type": "fill", + "source": "protomaps", + "source-layer": "landuse", + "filter": [ + "in", + "kind", + "aerodrome" + ], + "paint": { + "fill-color": "#dadbdf" + } + }, + { + "id": "roads_runway", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "==", + "kind_detail", + "runway" + ], + "paint": { + "line-color": "#e9e9ed", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 10, + 0, + 12, + 4, + 18, + 30 + ] + } + }, + { + "id": "roads_taxiway", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 13, + "filter": [ + "==", + "kind_detail", + "taxiway" + ], + "paint": { + "line-color": "#e9e9ed", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 13, + 0, + 13.5, + 1, + 15, + 6 + ] + } + }, + { + "id": "landuse_runway", + "type": "fill", + "source": "protomaps", + "source-layer": "landuse", + "filter": [ + "any", + [ + "in", + "kind", + "runway", + "taxiway" + ] + ], + "paint": { + "fill-color": "#e9e9ed" + } + }, + { + "id": "water", + "type": "fill", + "filter": [ + "==", + "$type", + "Polygon" + ], + "source": "protomaps", + "source-layer": "water", + "paint": { + "fill-color": "#80deea" + } + }, + { + "id": "water_stream", + "type": "line", + "source": "protomaps", + "source-layer": "water", + "minzoom": 14, + "filter": [ + "in", + "kind", + "stream" + ], + "paint": { + "line-color": "#80deea", + "line-width": 0.5 + } + }, + { + "id": "water_river", + "type": "line", + "source": "protomaps", + "source-layer": "water", + "minzoom": 9, + "filter": [ + "in", + "kind", + "river" + ], + "paint": { + "line-color": "#80deea", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 9, + 0, + 9.5, + 1, + 18, + 12 + ] + } + }, + { + "id": "landuse_pedestrian", + "type": "fill", + "source": "protomaps", + "source-layer": "landuse", + "filter": [ + "==", + "kind", + "pedestrian" + ], + "paint": { + "fill-color": "#e3e0d4" + } + }, + { + "id": "landuse_pier", + "type": "fill", + "source": "protomaps", + "source-layer": "landuse", + "filter": [ + "==", + "kind", + "pier" + ], + "paint": { + "fill-color": "#e0e0e0" + } + }, + { + "id": "roads_tunnels_other_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "has", + "is_tunnel" + ], + [ + "in", + "kind", + "other", + "path" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 14, + 0, + 20, + 7 + ] + } + }, + { + "id": "roads_tunnels_minor_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "has", + "is_tunnel" + ], + [ + "==", + "kind", + "minor_road" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-dasharray": [ + 3, + 2 + ], + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 11, + 0, + 12.5, + 0.5, + 15, + 2, + 18, + 11 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 12, + 0, + 12.5, + 1 + ] + } + }, + { + "id": "roads_tunnels_link_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "has", + "is_tunnel" + ], + [ + "has", + "is_link" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-dasharray": [ + 3, + 2 + ], + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 13, + 0, + 13.5, + 1, + 18, + 11 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 12, + 0, + 12.5, + 1 + ] + } + }, + { + "id": "roads_tunnels_major_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "==", + "kind", + "major_road" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-dasharray": [ + 3, + 2 + ], + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 7, + 0, + 7.5, + 0.5, + 18, + 13 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 9, + 0, + 9.5, + 1 + ] + } + }, + { + "id": "roads_tunnels_highway_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "==", + "kind", + "highway" + ], + [ + "!has", + "is_link" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-dasharray": [ + 6, + 0.5 + ], + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 3, + 0, + 3.5, + 0.5, + 18, + 15 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 7, + 0, + 7.5, + 1, + 20, + 15 + ] + } + }, + { + "id": "roads_tunnels_other", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "has", + "is_tunnel" + ], + [ + "in", + "kind", + "other", + "path" + ] + ], + "paint": { + "line-color": "#d5d5d5", + "line-dasharray": [ + 4.5, + 0.5 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 14, + 0, + 20, + 7 + ] + } + }, + { + "id": "roads_tunnels_minor", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "has", + "is_tunnel" + ], + [ + "==", + "kind", + "minor_road" + ] + ], + "paint": { + "line-color": "#d5d5d5", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 11, + 0, + 12.5, + 0.5, + 15, + 2, + 18, + 11 + ] + } + }, + { + "id": "roads_tunnels_link", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "has", + "is_tunnel" + ], + [ + "has", + "is_link" + ] + ], + "paint": { + "line-color": "#d5d5d5", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 13, + 0, + 13.5, + 1, + 18, + 11 + ] + } + }, + { + "id": "roads_tunnels_major", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "has", + "is_tunnel" + ], + [ + "==", + "kind", + "major_road" + ] + ], + "paint": { + "line-color": "#d5d5d5", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 6, + 0, + 12, + 1.6, + 15, + 3, + 18, + 13 + ] + } + }, + { + "id": "roads_tunnels_highway", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "has", + "is_tunnel" + ], + [ + "==", + [ + "get", + "kind" + ], + "highway" + ], + [ + "!", + [ + "has", + "is_link" + ] + ] + ], + "paint": { + "line-color": "#d5d5d5", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 3, + 0, + 6, + 1.1, + 12, + 1.6, + 15, + 5, + 18, + 15 + ] + } + }, + { + "id": "buildings", + "type": "fill", + "source": "protomaps", + "source-layer": "buildings", + "filter": [ + "in", + "kind", + "building", + "building_part" + ], + "paint": { + "fill-color": "#cccccc", + "fill-opacity": 0.5 + } + }, + { + "id": "roads_pier", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "==", + "kind_detail", + "pier" + ], + "paint": { + "line-color": "#e0e0e0", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 12, + 0, + 12.5, + 0.5, + 20, + 16 + ] + } + }, + { + "id": "roads_minor_service_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 13, + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "==", + "kind", + "minor_road" + ], + [ + "==", + "kind_detail", + "service" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 13, + 0, + 18, + 8 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 13, + 0, + 13.5, + 0.8 + ] + } + }, + { + "id": "roads_minor_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "==", + "kind", + "minor_road" + ], + [ + "!=", + "kind_detail", + "service" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 11, + 0, + 12.5, + 0.5, + 15, + 2, + 18, + 11 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 12, + 0, + 12.5, + 1 + ] + } + }, + { + "id": "roads_link_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 13, + "filter": [ + "has", + "is_link" + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 13, + 0, + 13.5, + 1, + 18, + 11 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 13, + 0, + 13.5, + 1.5 + ] + } + }, + { + "id": "roads_major_casing_late", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 12, + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "==", + "kind", + "major_road" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 6, + 0, + 12, + 1.6, + 15, + 3, + 18, + 13 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 9, + 0, + 9.5, + 1 + ] + } + }, + { + "id": "roads_highway_casing_late", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 12, + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "==", + "kind", + "highway" + ], + [ + "!has", + "is_link" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 3, + 0, + 3.5, + 0.5, + 18, + 15 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 7, + 0, + 7.5, + 1, + 20, + 15 + ] + } + }, + { + "id": "roads_other", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "in", + "kind", + "other", + "path" + ], + [ + "!=", + "kind_detail", + "pier" + ] + ], + "paint": { + "line-color": "#ebebeb", + "line-dasharray": [ + 3, + 1 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 14, + 0, + 20, + 7 + ] + } + }, + { + "id": "roads_link", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "has", + "is_link" + ], + "paint": { + "line-color": "#ffffff", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 13, + 0, + 13.5, + 1, + 18, + 11 + ] + } + }, + { + "id": "roads_minor_service", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "==", + "kind", + "minor_road" + ], + [ + "==", + "kind_detail", + "service" + ] + ], + "paint": { + "line-color": "#ebebeb", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 13, + 0, + 18, + 8 + ] + } + }, + { + "id": "roads_minor", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "==", + "kind", + "minor_road" + ], + [ + "!=", + "kind_detail", + "service" + ] + ], + "paint": { + "line-color": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 11, + "#ebebeb", + 16, + "#ffffff" + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 11, + 0, + 12.5, + 0.5, + 15, + 2, + 18, + 11 + ] + } + }, + { + "id": "roads_major_casing_early", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "maxzoom": 12, + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "==", + "kind", + "major_road" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 7, + 0, + 7.5, + 0.5, + 18, + 13 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 9, + 0, + 9.5, + 1 + ] + } + }, + { + "id": "roads_major", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "==", + "kind", + "major_road" + ] + ], + "paint": { + "line-color": "#ffffff", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 6, + 0, + 12, + 1.6, + 15, + 3, + 18, + 13 + ] + } + }, + { + "id": "roads_highway_casing_early", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "maxzoom": 12, + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "==", + "kind", + "highway" + ], + [ + "!has", + "is_link" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 3, + 0, + 3.5, + 0.5, + 18, + 15 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 7, + 0, + 7.5, + 1 + ] + } + }, + { + "id": "roads_highway", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "!has", + "is_tunnel" + ], + [ + "!has", + "is_bridge" + ], + [ + "==", + "kind", + "highway" + ], + [ + "!has", + "is_link" + ] + ], + "paint": { + "line-color": "#ffffff", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 3, + 0, + 6, + 1.1, + 12, + 1.6, + 15, + 5, + 18, + 15 + ] + } + }, + { + "id": "roads_rail", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "==", + "kind", + "rail" + ], + "paint": { + "line-dasharray": [ + 0.3, + 0.75 + ], + "line-opacity": 0.5, + "line-color": "#a7b1b3", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 3, + 0, + 6, + 0.15, + 18, + 9 + ] + } + }, + { + "id": "boundaries_country", + "type": "line", + "source": "protomaps", + "source-layer": "boundaries", + "filter": [ + "<=", + "kind_detail", + 2 + ], + "paint": { + "line-color": "#adadad", + "line-width": 0.7, + "line-dasharray": [ + "step", + [ + "zoom" + ], + [ + "literal", + [ + 2 + ] + ], + 4, + [ + "literal", + [ + 2, + 1 + ] + ] + ] + } + }, + { + "id": "boundaries", + "type": "line", + "source": "protomaps", + "source-layer": "boundaries", + "filter": [ + ">", + "kind_detail", + 2 + ], + "paint": { + "line-color": "#adadad", + "line-width": 0.4, + "line-dasharray": [ + "step", + [ + "zoom" + ], + [ + "literal", + [ + 2 + ] + ], + 4, + [ + "literal", + [ + 2, + 1 + ] + ] + ] + } + }, + { + "id": "roads_bridges_other_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 12, + "filter": [ + "all", + [ + "has", + "is_bridge" + ], + [ + "in", + "kind", + "other", + "path" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 14, + 0, + 20, + 7 + ] + } + }, + { + "id": "roads_bridges_link_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 12, + "filter": [ + "all", + [ + "has", + "is_bridge" + ], + [ + "has", + "is_link" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 13, + 0, + 13.5, + 1, + 18, + 11 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 12, + 0, + 12.5, + 1.5 + ] + } + }, + { + "id": "roads_bridges_minor_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 12, + "filter": [ + "all", + [ + "has", + "is_bridge" + ], + [ + "==", + "kind", + "minor_road" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 11, + 0, + 12.5, + 0.5, + 15, + 2, + 18, + 11 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 13, + 0, + 13.5, + 0.8 + ] + } + }, + { + "id": "roads_bridges_major_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 12, + "filter": [ + "all", + [ + "has", + "is_bridge" + ], + [ + "==", + "kind", + "major_road" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 7, + 0, + 7.5, + 0.5, + 18, + 10 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 9, + 0, + 9.5, + 1.5 + ] + } + }, + { + "id": "roads_bridges_other", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 12, + "filter": [ + "all", + [ + "has", + "is_bridge" + ], + [ + "in", + "kind", + "other", + "path" + ] + ], + "paint": { + "line-color": "#ebebeb", + "line-dasharray": [ + 2, + 1 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 14, + 0, + 20, + 7 + ] + } + }, + { + "id": "roads_bridges_minor", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 12, + "filter": [ + "all", + [ + "has", + "is_bridge" + ], + [ + "==", + "kind", + "minor_road" + ] + ], + "paint": { + "line-color": "#ffffff", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 11, + 0, + 12.5, + 0.5, + 15, + 2, + 18, + 11 + ] + } + }, + { + "id": "roads_bridges_link", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 12, + "filter": [ + "all", + [ + "has", + "is_bridge" + ], + [ + "has", + "is_link" + ] + ], + "paint": { + "line-color": "#ffffff", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 13, + 0, + 13.5, + 1, + 18, + 11 + ] + } + }, + { + "id": "roads_bridges_major", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 12, + "filter": [ + "all", + [ + "has", + "is_bridge" + ], + [ + "==", + "kind", + "major_road" + ] + ], + "paint": { + "line-color": "#f5f5f5", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 6, + 0, + 12, + 1.6, + 15, + 3, + 18, + 13 + ] + } + }, + { + "id": "roads_bridges_highway_casing", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 12, + "filter": [ + "all", + [ + "has", + "is_bridge" + ], + [ + "==", + "kind", + "highway" + ], + [ + "!has", + "is_link" + ] + ], + "paint": { + "line-color": "#e0e0e0", + "line-gap-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 3, + 0, + 3.5, + 0.5, + 18, + 15 + ], + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 7, + 0, + 7.5, + 1, + 20, + 15 + ] + } + }, + { + "id": "roads_bridges_highway", + "type": "line", + "source": "protomaps", + "source-layer": "roads", + "filter": [ + "all", + [ + "has", + "is_bridge" + ], + [ + "==", + "kind", + "highway" + ], + [ + "!has", + "is_link" + ] + ], + "paint": { + "line-color": "#ffffff", + "line-width": [ + "interpolate", + [ + "exponential", + 1.6 + ], + [ + "zoom" + ], + 3, + 0, + 6, + 1.1, + 12, + 1.6, + 15, + 5, + 18, + 15 + ] + } + }, + { + "id": "address_label", + "type": "symbol", + "source": "protomaps", + "source-layer": "buildings", + "minzoom": 18, + "filter": [ + "==", + "kind", + "address" + ], + "layout": { + "symbol-placement": "point", + "text-font": [ + "Noto Sans Italic" + ], + "text-field": [ + "get", + "addr_housenumber" + ], + "text-size": 12 + }, + "paint": { + "text-color": "#91888b", + "text-halo-color": "#ffffff", + "text-halo-width": 1 + } + }, + { + "id": "water_waterway_label", + "type": "symbol", + "source": "protomaps", + "source-layer": "water", + "minzoom": 13, + "filter": [ + "in", + "kind", + "river", + "stream" + ], + "layout": { + "symbol-placement": "line", + "text-font": [ + "Noto Sans Italic" + ], + "text-field": [ + "case", + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "has", + "script" + ], + [ + "case", + [ + "any", + [ + "is-supported-script", + [ + "get", + "name" + ] + ], + [ + "has", + "pgf:name" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "name:en" + ] + ], + {}, + "\n", + {}, + [ + "case", + [ + "all", + [ + "!", + [ + "has", + "name:undefined" + ] + ], + [ + "has", + "name:en" + ], + [ + "!", + [ + "has", + "script" + ] + ] + ], + "", + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "get", + "name:en" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {} + ] + ], + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "has", + "script2" + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ], + [ + "has", + "script3" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "!", + [ + "has", + "script" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "!", + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ] + ], + "text-size": 12, + "text-letter-spacing": 0.2 + }, + "paint": { + "text-color": "#728dd4", + "text-halo-color": "#80deea", + "text-halo-width": 1 + } + }, + { + "id": "roads_labels_minor", + "type": "symbol", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 15, + "filter": [ + "in", + "kind", + "minor_road", + "other", + "path" + ], + "layout": { + "symbol-sort-key": [ + "get", + "min_zoom" + ], + "symbol-placement": "line", + "text-font": [ + "Noto Sans Regular" + ], + "text-field": [ + "case", + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "has", + "script" + ], + [ + "case", + [ + "any", + [ + "is-supported-script", + [ + "get", + "name" + ] + ], + [ + "has", + "pgf:name" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "name:en" + ] + ], + {}, + "\n", + {}, + [ + "case", + [ + "all", + [ + "!", + [ + "has", + "name:undefined" + ] + ], + [ + "has", + "name:en" + ], + [ + "!", + [ + "has", + "script" + ] + ] + ], + "", + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "get", + "name:en" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {} + ] + ], + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "has", + "script2" + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ], + [ + "has", + "script3" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "!", + [ + "has", + "script" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "!", + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ] + ], + "text-size": 12 + }, + "paint": { + "text-color": "#91888b", + "text-halo-color": "#ffffff", + "text-halo-width": 1 + } + }, + { + "id": "water_label_ocean", + "type": "symbol", + "source": "protomaps", + "source-layer": "water", + "filter": [ + "in", + "kind", + "sea", + "ocean", + "bay", + "strait", + "fjord" + ], + "layout": { + "text-font": [ + "Noto Sans Italic" + ], + "text-field": [ + "case", + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "has", + "script" + ], + [ + "case", + [ + "any", + [ + "is-supported-script", + [ + "get", + "name" + ] + ], + [ + "has", + "pgf:name" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "name:en" + ] + ], + {}, + "\n", + {}, + [ + "case", + [ + "all", + [ + "!", + [ + "has", + "name:undefined" + ] + ], + [ + "has", + "name:en" + ], + [ + "!", + [ + "has", + "script" + ] + ] + ], + "", + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "get", + "name:en" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {} + ] + ], + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "has", + "script2" + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ], + [ + "has", + "script3" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "!", + [ + "has", + "script" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "!", + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ] + ], + "text-size": [ + "interpolate", + [ + "linear" + ], + [ + "zoom" + ], + 3, + 10, + 10, + 12 + ], + "text-letter-spacing": 0.1, + "text-max-width": 9, + "text-transform": "uppercase" + }, + "paint": { + "text-color": "#728dd4", + "text-halo-width": 1, + "text-halo-color": "#80deea" + } + }, + { + "id": "water_label_lakes", + "type": "symbol", + "source": "protomaps", + "source-layer": "water", + "filter": [ + "in", + "kind", + "lake", + "water" + ], + "layout": { + "text-font": [ + "Noto Sans Italic" + ], + "text-field": [ + "case", + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "has", + "script" + ], + [ + "case", + [ + "any", + [ + "is-supported-script", + [ + "get", + "name" + ] + ], + [ + "has", + "pgf:name" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "name:en" + ] + ], + {}, + "\n", + {}, + [ + "case", + [ + "all", + [ + "!", + [ + "has", + "name:undefined" + ] + ], + [ + "has", + "name:en" + ], + [ + "!", + [ + "has", + "script" + ] + ] + ], + "", + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "get", + "name:en" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {} + ] + ], + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "has", + "script2" + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ], + [ + "has", + "script3" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "!", + [ + "has", + "script" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "!", + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ] + ], + "text-size": [ + "interpolate", + [ + "linear" + ], + [ + "zoom" + ], + 3, + 10, + 6, + 12, + 10, + 12 + ], + "text-letter-spacing": 0.1, + "text-max-width": 9 + }, + "paint": { + "text-color": "#728dd4", + "text-halo-color": "#80deea", + "text-halo-width": 1 + } + }, + { + "id": "roads_labels_major", + "type": "symbol", + "source": "protomaps", + "source-layer": "roads", + "minzoom": 11, + "filter": [ + "in", + "kind", + "highway", + "major_road" + ], + "layout": { + "symbol-sort-key": [ + "get", + "min_zoom" + ], + "symbol-placement": "line", + "text-font": [ + "Noto Sans Regular" + ], + "text-field": [ + "case", + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "has", + "script" + ], + [ + "case", + [ + "any", + [ + "is-supported-script", + [ + "get", + "name" + ] + ], + [ + "has", + "pgf:name" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "name:en" + ] + ], + {}, + "\n", + {}, + [ + "case", + [ + "all", + [ + "!", + [ + "has", + "name:undefined" + ] + ], + [ + "has", + "name:en" + ], + [ + "!", + [ + "has", + "script" + ] + ] + ], + "", + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "get", + "name:en" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {} + ] + ], + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "has", + "script2" + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ], + [ + "has", + "script3" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "!", + [ + "has", + "script" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "!", + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ] + ], + "text-size": 12 + }, + "paint": { + "text-color": "#938a8d", + "text-halo-color": "#ffffff", + "text-halo-width": 1 + } + }, + { + "id": "pois", + "type": "symbol", + "source": "protomaps", + "source-layer": "pois", + "filter": [ + "all", + [ + "in", + [ + "get", + "kind" + ], + [ + "literal", + [ + "beach", + "forest", + "marina", + "park", + "peak", + "zoo", + "garden", + "bench", + "aerodrome", + "station", + "bus_stop", + "ferry_terminal", + "stadium", + "university", + "library", + "school", + "animal", + "toilets", + "drinking_water" + ] + ] + ], + [ + ">=", + [ + "zoom" + ], + [ + "+", + [ + "get", + "min_zoom" + ], + 0 + ] + ] + ], + "layout": { + "icon-image": [ + "match", + [ + "get", + "kind" + ], + "station", + "train_station", + [ + "get", + "kind" + ] + ], + "text-font": [ + "Noto Sans Regular" + ], + "text-justify": "auto", + "text-field": [ + "case", + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "has", + "script" + ], + [ + "case", + [ + "any", + [ + "is-supported-script", + [ + "get", + "name" + ] + ], + [ + "has", + "pgf:name" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "name:en" + ] + ], + {}, + "\n", + {}, + [ + "case", + [ + "all", + [ + "!", + [ + "has", + "name:undefined" + ] + ], + [ + "has", + "name:en" + ], + [ + "!", + [ + "has", + "script" + ] + ] + ], + "", + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "get", + "name:en" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {} + ] + ], + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "has", + "script2" + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ], + [ + "has", + "script3" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "!", + [ + "has", + "script" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "!", + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ] + ], + "text-size": [ + "interpolate", + [ + "linear" + ], + [ + "zoom" + ], + 17, + 10, + 19, + 16 + ], + "text-max-width": 8, + "text-offset": [ + 1.1, + 0 + ], + "text-variable-anchor": [ + "left", + "right" + ] + }, + "paint": { + "text-color": [ + "case", + [ + "in", + [ + "get", + "kind" + ], + [ + "literal", + [ + "beach", + "forest", + "marina", + "park", + "peak", + "zoo", + "garden", + "bench" + ] + ] + ], + "#20834D", + [ + "in", + [ + "get", + "kind" + ], + [ + "literal", + [ + "aerodrome", + "station", + "bus_stop", + "ferry_terminal" + ] + ] + ], + "#315BCF", + [ + "in", + [ + "get", + "kind" + ], + [ + "literal", + [ + "stadium", + "university", + "library", + "school", + "animal", + "toilets", + "drinking_water" + ] + ] + ], + "#6A5B8F", + "#e2dfda" + ], + "text-halo-color": "#e2dfda", + "text-halo-width": 1 + } + }, + { + "id": "places_subplace", + "type": "symbol", + "source": "protomaps", + "source-layer": "places", + "filter": [ + "==", + "kind", + "neighbourhood" + ], + "layout": { + "symbol-sort-key": [ + "get", + "min_zoom" + ], + "text-field": [ + "case", + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "has", + "script" + ], + [ + "case", + [ + "any", + [ + "is-supported-script", + [ + "get", + "name" + ] + ], + [ + "has", + "pgf:name" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "name:en" + ] + ], + {}, + "\n", + {}, + [ + "case", + [ + "all", + [ + "!", + [ + "has", + "name:undefined" + ] + ], + [ + "has", + "name:en" + ], + [ + "!", + [ + "has", + "script" + ] + ] + ], + "", + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "get", + "name:en" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {} + ] + ], + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "has", + "script2" + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ], + [ + "has", + "script3" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "!", + [ + "has", + "script" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "!", + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ] + ], + "text-font": [ + "Noto Sans Regular" + ], + "text-max-width": 7, + "text-letter-spacing": 0.1, + "text-padding": [ + "interpolate", + [ + "linear" + ], + [ + "zoom" + ], + 5, + 2, + 8, + 4, + 12, + 18, + 15, + 20 + ], + "text-size": [ + "interpolate", + [ + "exponential", + 1.2 + ], + [ + "zoom" + ], + 11, + 8, + 14, + 14, + 18, + 24 + ], + "text-transform": "uppercase" + }, + "paint": { + "text-color": "#8f8f8f", + "text-halo-color": "#e0e0e0", + "text-halo-width": 1 + } + }, + { + "id": "places_locality", + "type": "symbol", + "source": "protomaps", + "source-layer": "places", + "filter": [ + "==", + "kind", + "locality" + ], + "layout": { + "icon-image": [ + "step", + [ + "zoom" + ], + "townspot", + 8, + "" + ], + "icon-size": 0.7, + "text-field": [ + "case", + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "has", + "script" + ], + [ + "case", + [ + "any", + [ + "is-supported-script", + [ + "get", + "name" + ] + ], + [ + "has", + "pgf:name" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "name:en" + ] + ], + {}, + "\n", + {}, + [ + "case", + [ + "all", + [ + "!", + [ + "has", + "name:undefined" + ] + ], + [ + "has", + "name:en" + ], + [ + "!", + [ + "has", + "script" + ] + ] + ], + "", + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "get", + "name:en" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {} + ] + ], + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "has", + "script2" + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ], + [ + "has", + "script3" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "!", + [ + "has", + "script" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "!", + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ] + ], + "text-font": [ + "case", + [ + "<=", + [ + "get", + "min_zoom" + ], + 5 + ], + [ + "literal", + [ + "Noto Sans Medium" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ], + "text-padding": [ + "interpolate", + [ + "linear" + ], + [ + "zoom" + ], + 5, + 3, + 8, + 7, + 12, + 11 + ], + "text-size": [ + "interpolate", + [ + "linear" + ], + [ + "zoom" + ], + 2, + [ + "case", + [ + "<", + [ + "get", + "population_rank" + ], + 13 + ], + 8, + [ + ">=", + [ + "get", + "population_rank" + ], + 13 + ], + 13, + 0 + ], + 4, + [ + "case", + [ + "<", + [ + "get", + "population_rank" + ], + 13 + ], + 10, + [ + ">=", + [ + "get", + "population_rank" + ], + 13 + ], + 15, + 0 + ], + 6, + [ + "case", + [ + "<", + [ + "get", + "population_rank" + ], + 12 + ], + 11, + [ + ">=", + [ + "get", + "population_rank" + ], + 12 + ], + 17, + 0 + ], + 8, + [ + "case", + [ + "<", + [ + "get", + "population_rank" + ], + 11 + ], + 11, + [ + ">=", + [ + "get", + "population_rank" + ], + 11 + ], + 18, + 0 + ], + 10, + [ + "case", + [ + "<", + [ + "get", + "population_rank" + ], + 9 + ], + 12, + [ + ">=", + [ + "get", + "population_rank" + ], + 9 + ], + 20, + 0 + ], + 15, + [ + "case", + [ + "<", + [ + "get", + "population_rank" + ], + 8 + ], + 12, + [ + ">=", + [ + "get", + "population_rank" + ], + 8 + ], + 22, + 0 + ] + ], + "icon-padding": [ + "interpolate", + [ + "linear" + ], + [ + "zoom" + ], + 0, + 0, + 8, + 4, + 10, + 8, + 12, + 6, + 22, + 2 + ], + "text-justify": "auto", + "text-anchor": [ + "step", + [ + "zoom" + ], + "left", + 8, + "center" + ], + "text-radial-offset": 0.4 + }, + "paint": { + "text-color": "#5c5c5c", + "text-halo-color": "#e0e0e0", + "text-halo-width": 1 + } + }, + { + "id": "places_region", + "type": "symbol", + "source": "protomaps", + "source-layer": "places", + "filter": [ + "==", + "kind", + "region" + ], + "layout": { + "symbol-sort-key": [ + "get", + "min_zoom" + ], + "text-field": [ + "step", + [ + "zoom" + ], + [ + "get", + "name:short" + ], + 6, + [ + "case", + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "has", + "script" + ], + [ + "case", + [ + "any", + [ + "is-supported-script", + [ + "get", + "name" + ] + ], + [ + "has", + "pgf:name" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "name:en" + ] + ], + {}, + "\n", + {}, + [ + "case", + [ + "all", + [ + "!", + [ + "has", + "name:undefined" + ] + ], + [ + "has", + "name:en" + ], + [ + "!", + [ + "has", + "script" + ] + ] + ], + "", + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "get", + "name:en" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {} + ] + ], + [ + "all", + [ + "any", + [ + "has", + "name" + ], + [ + "has", + "pgf:name" + ] + ], + [ + "any", + [ + "has", + "name2" + ], + [ + "has", + "pgf:name2" + ] + ], + [ + "!", + [ + "any", + [ + "has", + "name3" + ], + [ + "has", + "pgf:name3" + ] + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "has", + "script2" + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ], + [ + "case", + [ + "all", + [ + "has", + "script" + ], + [ + "has", + "script2" + ], + [ + "has", + "script3" + ] + ], + [ + "format", + [ + "get", + "name:undefined" + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "case", + [ + "!", + [ + "has", + "script" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "!", + [ + "has", + "script2" + ] + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script3" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ], + [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "pgf:name3" + ], + [ + "get", + "name3" + ] + ], + {}, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name" + ], + [ + "get", + "name" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + }, + "\n", + {}, + [ + "coalesce", + [ + "get", + "pgf:name2" + ], + [ + "get", + "name2" + ] + ], + { + "text-font": [ + "case", + [ + "==", + [ + "get", + "script2" + ], + "Devanagari" + ], + [ + "literal", + [ + "Noto Sans Devanagari Regular v1" + ] + ], + [ + "literal", + [ + "Noto Sans Regular" + ] + ] + ] + } + ] + ] + ] + ] + ], + "text-font": [ + "Noto Sans Regular" + ], + "text-size": [ + "interpolate", + [ + "linear" + ], + [ + "zoom" + ], + 3, + 11, + 7, + 16 + ], + "text-radial-offset": 0.2, + "text-anchor": "center", + "text-transform": "uppercase" + }, + "paint": { + "text-color": "#b3b3b3", + "text-halo-color": "#e0e0e0", + "text-halo-width": 1 + } + }, + { + "id": "places_country", + "type": "symbol", + "source": "protomaps", + "source-layer": "places", + "filter": [ + "==", + "kind", + "country" + ], + "layout": { + "symbol-sort-key": [ + "get", + "min_zoom" + ], + "text-field": [ + "format", + [ + "coalesce", + [ + "get", + "name:undefined" + ], + [ + "get", + "name:en" + ] + ], + {} + ], + "text-font": [ + "Noto Sans Medium" + ], + "text-size": [ + "interpolate", + [ + "linear" + ], + [ + "zoom" + ], + 2, + [ + "case", + [ + "<", + [ + "get", + "population_rank" + ], + 10 + ], + 8, + [ + ">=", + [ + "get", + "population_rank" + ], + 10 + ], + 12, + 0 + ], + 6, + [ + "case", + [ + "<", + [ + "get", + "population_rank" + ], + 8 + ], + 10, + [ + ">=", + [ + "get", + "population_rank" + ], + 8 + ], + 18, + 0 + ], + 8, + [ + "case", + [ + "<", + [ + "get", + "population_rank" + ], + 7 + ], + 11, + [ + ">=", + [ + "get", + "population_rank" + ], + 7 + ], + 20, + 0 + ] + ], + "icon-padding": [ + "interpolate", + [ + "linear" + ], + [ + "zoom" + ], + 0, + 2, + 14, + 2, + 16, + 20, + 17, + 2, + 22, + 2 + ], + "text-transform": "uppercase" + }, + "paint": { + "text-color": "#a3a3a3", + "text-halo-color": "#e2dfda", + "text-halo-width": 1 + } + } +] diff --git a/tiles/blocks.py b/tiles/blocks.py new file mode 100644 index 00000000..2912f477 --- /dev/null +++ b/tiles/blocks.py @@ -0,0 +1,49 @@ +"""Tiles and the blocks they are drawn in. + +ATAK and iTAK take 256 px tiles in the Web Mercator "XYZ" scheme. A tile is drawn as part of a block of 4x4 +tiles (one 1024 px image): ATAK asks for the tiles of an area in quadtree order, so 16 requests in a row are of +one block, and a block costs about a third of what its 16 tiles cost drawn alone. Labels are whole inside a block. +""" +import math +from typing import Iterator, NamedTuple, Tuple + +TILE_SIZE = 256 +BLOCK = 4 # tiles on a side of a block +# Below this zoom the world is fewer than 4x4 tiles: each is drawn alone (see `render`). +MIN_BLOCK_ZOOM = 2 +MAX_ZOOM = 22 + + +class Block(NamedTuple): + z: int + x: int # of the block, not of a tile + y: int + + def tiles(self) -> Iterator[Tuple[int, int]]: + """The x, y of each tile of the block.""" + side = BLOCK if self.z >= MIN_BLOCK_ZOOM else 2 ** self.z + for dy in range(side): + for dx in range(side): + yield self.x * side + dx, self.y * side + dy + + +def is_tile(z: int, x: int, y: int) -> bool: + return 0 <= z <= MAX_ZOOM and 0 <= x < 2 ** z and 0 <= y < 2 ** z + + +def block_of(z: int, x: int, y: int) -> Block: + if z < MIN_BLOCK_ZOOM: + return Block(z, 0, 0) + return Block(z, x // BLOCK, y // BLOCK) + + +def tile_corner(z: int, x: float, y: float) -> Tuple[float, float]: + """The longitude and latitude of the north-west corner of tile x, y (fractions are inside the tile).""" + n = 2 ** z + longitude = x / n * 360 - 180 + latitude = math.degrees(math.atan(math.sinh(math.pi * (1 - 2 * y / n)))) + return longitude, latitude + + +def block_center(block: Block) -> Tuple[float, float]: + return tile_corner(block.z, block.x * BLOCK + BLOCK / 2, block.y * BLOCK + BLOCK / 2) diff --git a/tiles/cache.py b/tiles/cache.py new file mode 100644 index 00000000..7842df51 --- /dev/null +++ b/tiles/cache.py @@ -0,0 +1,238 @@ +"""Tiles already drawn, on the disk. + +A phone taking an area offline asks for the same tiles a second phone will, and a block draws tiles beyond the +area asked for. A tile is a file `/ + + +
+

WROLPi Map Tiles

+

This is the map tile service of a WROLPi. It draws the WROLPi's map as tiles for +ATAK (Android) and iTAK (iPhone), which can use it as a map source and download areas of it for offline use.

+

To add the map to ATAK or iTAK, open this map source on the phone and open the file it downloads with the app:

+

{xml}

+

The map's ATAK tab on the WROLPi has the steps, and what the tile service is doing.

+

{maps} · Map data © OpenStreetMap contributors

+
+ + +''' + + +def index_html(base_url: str, map_count: int) -> str: + """The page a person finds at this port: what it is, and links to the map source and to WROLPi.""" + hostname = urlsplit(base_url).hostname or 'localhost' + if ':' in hostname: + hostname = f'[{hostname}]' # IPv6 + app = f'https://{hostname}' + (f':{HTTPS_PORT}' if HTTPS_PORT != 443 else '') + maps_text = f'Drawn from {map_count} map file{"" if map_count == 1 else "s"}' if map_count else \ + 'There are no map files yet; download some on the WROLPi\'s Map page' + return INDEX_HTML.format(app=html.escape(f'{app}/'), atak=html.escape(f'{app}/map/atak'), + xml=html.escape(f'{base_url}/tiles/wrolpi.xml'), maps=html.escape(maps_text)) + + +def create_app(service: TileService, name: str = 'wrolpi_tiles') -> Sanic: + app = Sanic(name) + # sanic-ext (installed for the API) would add OpenAPI docs and more, for nothing: seconds of startup on a Pi. + app.config.AUTO_EXTEND = False + app.ctx.service = service + + @app.before_server_start + async def start(app_): + await app_.ctx.service.start() + + @app.after_server_stop + async def stop(app_): + await app_.ctx.service.stop() + + @app.get('/tiles///') + async def get_tile(request, z: int, x: int, name: str): + y, _, suffix = name.partition('.') + if suffix != 'jpg' or not y.isdigit(): + return response.text('not found', status=404) + data, keep = await app.ctx.service.tile(z, x, int(y), client_of(request)) + if data is None: + # Not a 401 or 403: those stop an ATAK map source. + return response.text('Not drawn yet, try again', status=503, + headers={'Retry-After': '1', 'Cache-Control': 'no-store'}) + if keep: + headers = {'Cache-Control': f'max-age={EXPIRES_SECONDS}', + 'Expires': formatdate(time.time() + EXPIRES_SECONDS, usegmt=True)} + else: + headers = {'Cache-Control': 'no-store', 'Expires': formatdate(0, usegmt=True)} + return response.raw(data, content_type=render.CONTENT_TYPE, headers=headers) + + @app.get('/', name='index') + @app.get('/tiles', name='tiles_index', strict_slashes=False) + async def get_index(request): + return response.html(index_html(base_url_of(request), len(app.ctx.service.maps))) + + @app.get('/tiles/wrolpi.xml') + async def get_xml(request): + base_url = base_url_of(request) + https = base_url.startswith('https:') + name = f'{NAME} (HTTPS)' if https else NAME + filename = 'wrolpi-map-https.xml' if https else 'wrolpi-map.xml' + service_ = app.ctx.service + background = background_color(service_.style) if service_.style else '#cccccc' + return response.text(mobac_xml(base_url, name, service_.max_zoom, background), content_type='application/xml', + headers={'Content-Disposition': f'attachment; filename="{filename}"'}) + + @app.get('/tiles/status') + async def get_status(request): + return response.json(app.ctx.service.status()) + + @app.post('/tiles/cache/clear') + async def post_clear_cache(request): + freed = await asyncio.to_thread(app.ctx.service.cache.clear) + return response.json(dict(freed_bytes=freed)) + + return app diff --git a/tiles/style.py b/tiles/style.py new file mode 100644 index 00000000..215d60a8 --- /dev/null +++ b/tiles/style.py @@ -0,0 +1,85 @@ +"""The MapLibre style the tiles are drawn with: the web map's basemap (MapViewer's `buildStyle`) for map files on +the disk. + +`basemap-light.json` is the layers of the web map's light basemap, written from protomaps-themes-base (see +app/src/components/mapTileStyle.test.js), for a source named `protomaps`. Each map file gets a source and the +layers of its own. As on the web map: the first file's layers are as they are, every later file's are renamed +and leave out the background and the earth (which would cover the files before it), and every label is over the +ground of every file. +""" +import hashlib +import json +import logging +from functools import lru_cache +from pathlib import Path +from typing import List + +logger = logging.getLogger(__name__) + +LAYERS_FILE = Path(__file__).with_name('basemap-light.json') +STATIC = Path(__file__).resolve().parents[1] / 'modules/map/static' +TEMPLATE_SOURCE = 'protomaps' +SKIP_SECONDARY = frozenset({'background', 'earth'}) + + +@lru_cache +def _template() -> str: + return LAYERS_FILE.read_text() + + +def basemap_layers(source: str) -> List[dict]: + layers = json.loads(_template()) + for layer in layers: + if layer.get('source') == TEMPLATE_SOURCE: + layer['source'] = source + return layers + + +def has_fonts(static: Path = STATIC) -> bool: + """Whether the map's fonts are installed (unpacked from a blob, not in the repository).""" + return any((static / 'fonts').glob('*/0-255.pbf')) + + +def build_style(maps: List[Path], static: Path = STATIC) -> dict: + """The style which draws these PMTiles files, the first under the rest. + + Without the map's fonts a label cannot be drawn, and MapLibre fails the whole tile; the labels are left out.""" + sources = dict() + layers = [] + for index, path in enumerate(maps): + name = f'{index}-{path.stem}' + sources[name] = dict(type='vector', url=f'pmtiles://file://{path}') + for layer in basemap_layers(name): + if index == 0: + layers.append(layer) + elif layer['id'] not in SKIP_SECONDARY: + layers.append(dict(layer, id=f'{name}:{layer["id"]}')) + if not sources: + # No map files: the background alone, which every tile is drawn as. + layers = [i for i in basemap_layers(TEMPLATE_SOURCE) if i['type'] == 'background'] + labels = [i for i in layers if i['type'] == 'symbol'] + layers = [i for i in layers if i['type'] != 'symbol'] + style = dict(version=8, sprite=f'file://{static}/sprites/light', sources=sources) + if has_fonts(static): + style['glyphs'] = f'file://{static}/fonts/{{fontstack}}/{{range}}.pbf' + layers += labels # over the ground of every file + elif labels: + logger.warning(f'The map fonts are not in {static / "fonts"}: tiles are drawn without labels') + style['layers'] = layers + return style + + +def style_id(style: dict, signature) -> str: + """Names a style and the map files it draws: tiles drawn with one are never served for another.""" + digest = hashlib.sha256(json.dumps([style, signature], sort_keys=True).encode()).hexdigest() + return digest[:16] + + +def background_color(style: dict) -> str: + """The color of a tile of nowhere the map files have anything (`#rrggbb`).""" + for layer in style['layers']: + if layer['type'] == 'background': + color = layer.get('paint', {}).get('background-color') + if isinstance(color, str) and color.startswith('#') and len(color) in (4, 7): + return color + return '#cccccc' diff --git a/tiles/test/__init__.py b/tiles/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tiles/test/test_tiles.py b/tiles/test/test_tiles.py new file mode 100644 index 00000000..d3be7d6e --- /dev/null +++ b/tiles/test/test_tiles.py @@ -0,0 +1,600 @@ +import asyncio +import gzip +import io +import json +import struct +import sys +import threading +import time +import uuid +import xml.etree.ElementTree as ElementTree +from concurrent.futures import ThreadPoolExecutor +from pathlib import Path + +import pytest +from PIL import Image + +from modules.map import pmtiles as map_pmtiles +from modules.map.conftest import PROTOMAPS_LAYERS, pmtiles_bytes, vector_metadata +from tiles import maps, render, service as tile_service +from tiles.blocks import BLOCK, Block, block_center, block_of, is_tile, tile_corner +from tiles.cache import TileCache, disk_size +from tiles.service import TileService, create_app, index_html, mobac_xml +from tiles.style import SKIP_SECONDARY, background_color, basemap_layers, build_style, style_id + + +@pytest.fixture(autouse=True) +def media_directory(tmp_path, monkeypatch) -> Path: + """The tile service reads configs (wrolpi.yaml, maps.yaml) from a media directory of the test's own.""" + monkeypatch.setattr(maps, 'MEDIA_DIRECTORY', tmp_path / 'media') + return tmp_path / 'media' + + +def write_header_only(path: Path, metadata=None, **kwargs) -> Path: + """A PMTiles file with a header and metadata but no tiles (as modules.map's tests make).""" + path.parent.mkdir(parents=True, exist_ok=True) + if metadata is None and kwargs.get('tile_type', 1) == 1: + metadata = vector_metadata(*PROTOMAPS_LAYERS) + path.write_bytes(pmtiles_bytes(metadata, **kwargs)) + return path + + +def varint(n: int) -> bytes: + out = bytearray() + while True: + byte, n = n & 0x7f, n >> 7 + out.append(byte | 0x80 if n else byte) + if not n: + return bytes(out) + + +def write_pmtiles(path: Path, metadata: dict = None) -> Path: + """A PMTiles (version 3) file MapLibre can read: one empty vector tile, of the whole world at zoom 0.""" + path.parent.mkdir(parents=True, exist_ok=True) + metadata = metadata if metadata is not None else vector_metadata(*PROTOMAPS_LAYERS) + tile = gzip.compress(b'') + # One entry: tile id 0, run length 1, its length, offset 0 (written as offset + 1). + root = gzip.compress(varint(1) + varint(0) + varint(1) + varint(len(tile)) + varint(1)) + raw_metadata = gzip.compress(json.dumps(metadata).encode()) + header = bytearray(127) + header[0:7] = b'PMTiles' + header[7] = 3 + root_offset = 127 + metadata_offset = root_offset + len(root) + tiles_offset = metadata_offset + len(raw_metadata) + struct.pack_into('