MCPcopy
hub / github.com/protomaps/PMTiles / tile_path

Function tile_path

serverless/shared/index.ts:13–36  ·  view source on GitHub ↗
(
  path: string
)

Source from the content-addressed store, hash-verified

11const TILESET = /^\/(?<NAME>[0-9a-zA-Z\/!\-_\.\*\'\(\)]+).json$/;
12
13export const tile_path = (
14 path: string
15): {
16 ok: boolean;
17 name: string;
18 tile?: [number, number, number];
19 ext: string;
20} => {
21 const tile_match = path.match(TILE);
22
23 if (tile_match) {
24 const g = tile_match.groups!;
25 return { ok: true, name: g.NAME, tile: [+g.Z, +g.X, +g.Y], ext: g.EXT };
26 }
27
28 const tileset_match = path.match(TILESET);
29
30 if (tileset_match) {
31 const g = tileset_match.groups!;
32 return { ok: true, name: g.NAME, ext: "json" };
33 }
34
35 return { ok: false, name: "", tile: [0, 0, 0], ext: "" };
36};

Callers 2

handlerRawFunction · 0.90
fetchFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…