@mailwoman/map-tui 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/frame.ts +170 -0
- package/index.ts +13 -0
- package/mercator.ts +55 -0
- package/mvt.ts +54 -0
- package/out/frame.d.ts +54 -0
- package/out/frame.d.ts.map +1 -0
- package/out/frame.js +117 -0
- package/out/frame.js.map +1 -0
- package/out/index.d.ts +13 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +13 -0
- package/out/index.js.map +1 -0
- package/out/mercator.d.ts +29 -0
- package/out/mercator.d.ts.map +1 -0
- package/out/mercator.js +38 -0
- package/out/mercator.js.map +1 -0
- package/out/mvt.d.ts +26 -0
- package/out/mvt.d.ts.map +1 -0
- package/out/mvt.js +29 -0
- package/out/mvt.js.map +1 -0
- package/out/raster.d.ts +61 -0
- package/out/raster.d.ts.map +1 -0
- package/out/raster.js +168 -0
- package/out/raster.js.map +1 -0
- package/out/renderer.d.ts +50 -0
- package/out/renderer.d.ts.map +1 -0
- package/out/renderer.js +168 -0
- package/out/renderer.js.map +1 -0
- package/out/style.d.ts +37 -0
- package/out/style.d.ts.map +1 -0
- package/out/style.js +28 -0
- package/out/style.js.map +1 -0
- package/out/tile-source.d.ts +28 -0
- package/out/tile-source.d.ts.map +1 -0
- package/out/tile-source.js +89 -0
- package/out/tile-source.js.map +1 -0
- package/out/tsconfig.test.tsbuildinfo +1 -0
- package/out/tsconfig.tsbuildinfo +1 -0
- package/package.json +48 -0
- package/raster.ts +213 -0
- package/renderer.ts +297 -0
- package/style.ts +62 -0
- package/tile-source.ts +130 -0
package/out/mvt.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mvt.js","sourceRoot":"","sources":["../mvt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,GAAG,MAAM,KAAK,CAAA;AAqBrB,MAAM,UAAU,SAAS,CAAC,IAAgB;IACzC,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;IAE1C,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;QACxD,MAAM,QAAQ,GAAqB,EAAE,CAAA;QAErC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YACnD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;YAEpC,QAAQ,CAAC,IAAI,CAAC;gBACb,IAAI,EAAE,OAAO,CAAC,IAAiB;gBAC/B,QAAQ,EAAE,OAAO,CAAC,YAAY,EAAE;gBAChC,UAAU,EAAE,OAAO,CAAC,UAAqC;aACzD,CAAC,CAAA;QACH,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAA;IAChD,CAAC,CAAC,CAAA;AACH,CAAC"}
|
package/out/raster.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* RGBA pixel rasterizer for map-tui's debug view.
|
|
8
|
+
*
|
|
9
|
+
* Rasterizes vector geometry (polylines, filled polygons, circles) onto a plain RGBA byte grid — the shape asciify's
|
|
10
|
+
* rasterize step consumes. Every draw call clips through {@link RGBAGrid.setPixel}, so callers never need to
|
|
11
|
+
* bounds-check geometry themselves. The polyline and circle primitives floor their coordinates to integers on entry;
|
|
12
|
+
* {@link fillPolygon} does not — its scanline edge math keeps ring vertices as given, see its own docstring.
|
|
13
|
+
*/
|
|
14
|
+
import type { RGB } from "./style.ts";
|
|
15
|
+
/**
|
|
16
|
+
* A row-major RGBA pixel buffer. Alpha starts at 0 (unlit/transparent) everywhere; drawing a pixel sets it to 255,
|
|
17
|
+
* which is how callers (including this module's own tests) distinguish "lit" from "background".
|
|
18
|
+
*/
|
|
19
|
+
export declare class RGBAGrid {
|
|
20
|
+
readonly width: number;
|
|
21
|
+
readonly height: number;
|
|
22
|
+
/**
|
|
23
|
+
* RGBA, row-major, width * height * 4 bytes — the shape asciify's rasterize consumes.
|
|
24
|
+
*/
|
|
25
|
+
readonly data: Uint8ClampedArray;
|
|
26
|
+
constructor(width: number, height: number);
|
|
27
|
+
/**
|
|
28
|
+
* Writes a pixel's RGB channels and sets alpha to fully opaque (255). Coordinates outside the grid are silently
|
|
29
|
+
* ignored — this is the one clipping boundary every drawing primitive in this module routes through, so geometry that
|
|
30
|
+
* runs off the grid (or arrives with negative/oversized coordinates) never needs special-casing upstream.
|
|
31
|
+
*/
|
|
32
|
+
setPixel(x: number, y: number, color: RGB): void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Draws a connected polyline through `points`, one Bresenham segment per consecutive pair. `width > 1` stamps a
|
|
36
|
+
* `width`-sized square at every plotted step instead of a single pixel, thickening the line. Segments that run outside
|
|
37
|
+
* the grid clip through `setPixel` rather than throwing.
|
|
38
|
+
*/
|
|
39
|
+
export declare function drawPolyline(grid: RGBAGrid, points: ReadonlyArray<{
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
}>, color: RGB, width: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Fills one or more polygon rings with the even-odd rule: a pixel is interior when a ray from it crosses an odd number
|
|
45
|
+
* of ring edges. Rings after the first behave as holes wherever they overlap the first ring, and holes nested inside
|
|
46
|
+
* holes fill again, purely as a consequence of the parity count — no explicit hole/outer distinction is tracked.
|
|
47
|
+
* Scanlines sample row centers (`y + 0.5`) rather than integer row coordinates, which is what keeps horizontal edges
|
|
48
|
+
* and grid-aligned polygon boundaries from producing degenerate (zero-width or doubled) intersections. Coordinates are
|
|
49
|
+
* floored to the grid via `setPixel`; edge math itself uses the ring vertices as given.
|
|
50
|
+
*/
|
|
51
|
+
export declare function fillPolygon(grid: RGBAGrid, rings: ReadonlyArray<ReadonlyArray<{
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
}>>, color: RGB): void;
|
|
55
|
+
/**
|
|
56
|
+
* Draws a circle's outline (ring, not a filled disc) with the midpoint circle algorithm, plotting all eight symmetric
|
|
57
|
+
* octant points per step. `centerX`/`centerY`/`radius` are floored on entry; every plotted point routes through
|
|
58
|
+
* `setPixel`, so a circle that runs off the grid clips rather than throwing.
|
|
59
|
+
*/
|
|
60
|
+
export declare function drawCircle(grid: RGBAGrid, centerX: number, centerY: number, radius: number, color: RGB): void;
|
|
61
|
+
//# sourceMappingURL=raster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raster.d.ts","sourceRoot":"","sources":["../raster.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAErC;;;GAGG;AACH,qBAAa,QAAQ;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAA;gBAEpB,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAMzC;;;;OAIG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;CAahD;AAuDD;;;;GAIG;AACH,wBAAgB,YAAY,CAC3B,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,aAAa,CAAC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EAC/C,KAAK,EAAE,GAAG,EACV,KAAK,EAAE,MAAM,GACX,IAAI,CAON;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAC1B,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,EAC7D,KAAK,EAAE,GAAG,GACR,IAAI,CAkCN;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAgC7G"}
|
package/out/raster.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A row-major RGBA pixel buffer. Alpha starts at 0 (unlit/transparent) everywhere; drawing a pixel sets it to 255,
|
|
8
|
+
* which is how callers (including this module's own tests) distinguish "lit" from "background".
|
|
9
|
+
*/
|
|
10
|
+
export class RGBAGrid {
|
|
11
|
+
width;
|
|
12
|
+
height;
|
|
13
|
+
/**
|
|
14
|
+
* RGBA, row-major, width * height * 4 bytes — the shape asciify's rasterize consumes.
|
|
15
|
+
*/
|
|
16
|
+
data;
|
|
17
|
+
constructor(width, height) {
|
|
18
|
+
this.width = width;
|
|
19
|
+
this.height = height;
|
|
20
|
+
this.data = new Uint8ClampedArray(width * height * 4);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Writes a pixel's RGB channels and sets alpha to fully opaque (255). Coordinates outside the grid are silently
|
|
24
|
+
* ignored — this is the one clipping boundary every drawing primitive in this module routes through, so geometry that
|
|
25
|
+
* runs off the grid (or arrives with negative/oversized coordinates) never needs special-casing upstream.
|
|
26
|
+
*/
|
|
27
|
+
setPixel(x, y, color) {
|
|
28
|
+
const px = Math.floor(x);
|
|
29
|
+
const py = Math.floor(y);
|
|
30
|
+
if (px < 0 || px >= this.width || py < 0 || py >= this.height)
|
|
31
|
+
return;
|
|
32
|
+
const offset = (py * this.width + px) * 4;
|
|
33
|
+
this.data[offset] = color[0];
|
|
34
|
+
this.data[offset + 1] = color[1];
|
|
35
|
+
this.data[offset + 2] = color[2];
|
|
36
|
+
this.data[offset + 3] = 255;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Stamps a `width`-sized square centered on (x, y) — used by {@link drawPolyline} for `width > 1`. `width === 1` callers
|
|
41
|
+
* should use `grid.setPixel` directly rather than pay the square-stamp loop.
|
|
42
|
+
*/
|
|
43
|
+
function stampSquare(grid, x, y, color, width) {
|
|
44
|
+
const half = Math.floor(width / 2);
|
|
45
|
+
for (let dy = 0; dy < width; dy++) {
|
|
46
|
+
for (let dx = 0; dx < width; dx++) {
|
|
47
|
+
grid.setPixel(x - half + dx, y - half + dy, color);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Draws a single line segment with the integer Bresenham algorithm. Coordinates are floored on entry; every plotted
|
|
53
|
+
* point routes through `grid.setPixel`, so segments that run partly or fully off-grid clip for free.
|
|
54
|
+
*/
|
|
55
|
+
function drawSegment(grid, x0, y0, x1, y1, color, width) {
|
|
56
|
+
let x = Math.floor(x0);
|
|
57
|
+
let y = Math.floor(y0);
|
|
58
|
+
const endX = Math.floor(x1);
|
|
59
|
+
const endY = Math.floor(y1);
|
|
60
|
+
const dx = Math.abs(endX - x);
|
|
61
|
+
const dy = -Math.abs(endY - y);
|
|
62
|
+
const stepX = x < endX ? 1 : -1;
|
|
63
|
+
const stepY = y < endY ? 1 : -1;
|
|
64
|
+
let error = dx + dy;
|
|
65
|
+
for (;;) {
|
|
66
|
+
if (width > 1) {
|
|
67
|
+
stampSquare(grid, x, y, color, width);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
grid.setPixel(x, y, color);
|
|
71
|
+
}
|
|
72
|
+
if (x === endX && y === endY)
|
|
73
|
+
break;
|
|
74
|
+
const doubleError = 2 * error;
|
|
75
|
+
if (doubleError >= dy) {
|
|
76
|
+
error += dy;
|
|
77
|
+
x += stepX;
|
|
78
|
+
}
|
|
79
|
+
if (doubleError <= dx) {
|
|
80
|
+
error += dx;
|
|
81
|
+
y += stepY;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Draws a connected polyline through `points`, one Bresenham segment per consecutive pair. `width > 1` stamps a
|
|
87
|
+
* `width`-sized square at every plotted step instead of a single pixel, thickening the line. Segments that run outside
|
|
88
|
+
* the grid clip through `setPixel` rather than throwing.
|
|
89
|
+
*/
|
|
90
|
+
export function drawPolyline(grid, points, color, width) {
|
|
91
|
+
for (let index = 0; index < points.length - 1; index++) {
|
|
92
|
+
const a = points[index];
|
|
93
|
+
const b = points[index + 1];
|
|
94
|
+
drawSegment(grid, a.x, a.y, b.x, b.y, color, width);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Fills one or more polygon rings with the even-odd rule: a pixel is interior when a ray from it crosses an odd number
|
|
99
|
+
* of ring edges. Rings after the first behave as holes wherever they overlap the first ring, and holes nested inside
|
|
100
|
+
* holes fill again, purely as a consequence of the parity count — no explicit hole/outer distinction is tracked.
|
|
101
|
+
* Scanlines sample row centers (`y + 0.5`) rather than integer row coordinates, which is what keeps horizontal edges
|
|
102
|
+
* and grid-aligned polygon boundaries from producing degenerate (zero-width or doubled) intersections. Coordinates are
|
|
103
|
+
* floored to the grid via `setPixel`; edge math itself uses the ring vertices as given.
|
|
104
|
+
*/
|
|
105
|
+
export function fillPolygon(grid, rings, color) {
|
|
106
|
+
for (let y = 0; y < grid.height; y++) {
|
|
107
|
+
const scanY = y + 0.5;
|
|
108
|
+
const intersections = [];
|
|
109
|
+
for (const ring of rings) {
|
|
110
|
+
for (let i = 0; i < ring.length; i++) {
|
|
111
|
+
const a = ring[i];
|
|
112
|
+
const b = ring[(i + 1) % ring.length];
|
|
113
|
+
// Skip horizontal edges — they contribute no crossing at any non-integer scanY.
|
|
114
|
+
if (a.y === b.y)
|
|
115
|
+
continue;
|
|
116
|
+
const yMin = Math.min(a.y, b.y);
|
|
117
|
+
const yMax = Math.max(a.y, b.y);
|
|
118
|
+
if (scanY < yMin || scanY >= yMax)
|
|
119
|
+
continue;
|
|
120
|
+
const t = (scanY - a.y) / (b.y - a.y);
|
|
121
|
+
intersections.push(a.x + t * (b.x - a.x));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
intersections.sort((left, right) => left - right);
|
|
125
|
+
for (let i = 0; i + 1 < intersections.length; i += 2) {
|
|
126
|
+
const startX = Math.ceil(intersections[i] - 0.5);
|
|
127
|
+
const endX = Math.ceil(intersections[i + 1] - 0.5);
|
|
128
|
+
for (let x = startX; x < endX; x++) {
|
|
129
|
+
grid.setPixel(x, y, color);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Draws a circle's outline (ring, not a filled disc) with the midpoint circle algorithm, plotting all eight symmetric
|
|
136
|
+
* octant points per step. `centerX`/`centerY`/`radius` are floored on entry; every plotted point routes through
|
|
137
|
+
* `setPixel`, so a circle that runs off the grid clips rather than throwing.
|
|
138
|
+
*/
|
|
139
|
+
export function drawCircle(grid, centerX, centerY, radius, color) {
|
|
140
|
+
const cx = Math.floor(centerX);
|
|
141
|
+
const cy = Math.floor(centerY);
|
|
142
|
+
const r = Math.floor(radius);
|
|
143
|
+
let x = r;
|
|
144
|
+
let y = 0;
|
|
145
|
+
let error = 1 - r;
|
|
146
|
+
const plotOctants = (px, py) => {
|
|
147
|
+
grid.setPixel(cx + px, cy + py, color);
|
|
148
|
+
grid.setPixel(cx - px, cy + py, color);
|
|
149
|
+
grid.setPixel(cx + px, cy - py, color);
|
|
150
|
+
grid.setPixel(cx - px, cy - py, color);
|
|
151
|
+
grid.setPixel(cx + py, cy + px, color);
|
|
152
|
+
grid.setPixel(cx - py, cy + px, color);
|
|
153
|
+
grid.setPixel(cx + py, cy - px, color);
|
|
154
|
+
grid.setPixel(cx - py, cy - px, color);
|
|
155
|
+
};
|
|
156
|
+
while (x >= y) {
|
|
157
|
+
plotOctants(x, y);
|
|
158
|
+
y++;
|
|
159
|
+
if (error < 0) {
|
|
160
|
+
error += 2 * y + 1;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
x--;
|
|
164
|
+
error += 2 * (y - x) + 1;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=raster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raster.js","sourceRoot":"","sources":["../raster.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACX,KAAK,CAAQ;IACb,MAAM,CAAQ;IACvB;;OAEG;IACM,IAAI,CAAmB;IAEhC,YAAY,KAAa,EAAE,MAAc;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,iBAAiB,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC,CAAA;IACtD,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,CAAS,EAAE,CAAS,EAAE,KAAU;QACxC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACxB,MAAM,EAAE,GAAG,IAAI,CAAC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CAAC,CAAA;IACvC,CAAC,CAAA;IAED,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACf,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAEjB,CAAC,EAAE,CAAA;QAEH,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACf,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACnB,CAAC;aAAM,CAAC;YACP,CAAC,EAAE,CAAA;YACH,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;QACzB,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Viewport-to-braille-frame renderer for map-tui's debug view.
|
|
8
|
+
*
|
|
9
|
+
* `MapRenderer.renderFrame` is the package's single public entry point: given a `Viewport` (center lon/lat, zoom, cell
|
|
10
|
+
* columns/rows), it fetches the covering tiles from a `TileSource`, rasterizes styled geometry (./style.ts,
|
|
11
|
+
* ./raster.ts) into a subpixel RGBA grid, converts that grid to braille cells (./frame.ts), then overlays collected
|
|
12
|
+
* labels and marker/ring annotations on top. Draw order is fill → line → label per the layer style table, with overlays
|
|
13
|
+
* (ring, labels, markers) layered afterward in that order — markers deliberately skip the label collision bitmap so a
|
|
14
|
+
* requested marker always wins the cell.
|
|
15
|
+
*/
|
|
16
|
+
import { type MapFrame } from "./frame.ts";
|
|
17
|
+
import { type RGB } from "./style.ts";
|
|
18
|
+
import type { TileSource } from "./tile-source.ts";
|
|
19
|
+
export interface Viewport {
|
|
20
|
+
centerLon: number;
|
|
21
|
+
centerLat: number;
|
|
22
|
+
zoom: number;
|
|
23
|
+
columns: number;
|
|
24
|
+
rows: number;
|
|
25
|
+
}
|
|
26
|
+
export interface MarkerSpec {
|
|
27
|
+
lon: number;
|
|
28
|
+
lat: number;
|
|
29
|
+
char?: string;
|
|
30
|
+
color?: RGB;
|
|
31
|
+
}
|
|
32
|
+
export interface RingSpec {
|
|
33
|
+
lon: number;
|
|
34
|
+
lat: number;
|
|
35
|
+
radiusMeters: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Walks a viewport's rendering pipeline: tile fetch, style-ordered rasterization, braille conversion, then overlay
|
|
39
|
+
* annotations (ring, labels, markers). One `MapRenderer` can render any number of viewports against the same
|
|
40
|
+
* `TileSource` — it holds no per-frame state itself.
|
|
41
|
+
*/
|
|
42
|
+
export declare class MapRenderer {
|
|
43
|
+
private readonly source;
|
|
44
|
+
constructor(source: TileSource);
|
|
45
|
+
renderFrame(viewport: Viewport, overlays?: {
|
|
46
|
+
markers?: MarkerSpec[];
|
|
47
|
+
ring?: RingSpec;
|
|
48
|
+
}): Promise<MapFrame>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../renderer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAA8C,MAAM,YAAY,CAAA;AAItF,OAAO,EAAmB,KAAK,GAAG,EAAa,MAAM,YAAY,CAAA;AACjE,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE/D,MAAM,WAAW,QAAQ;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,UAAU;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,GAAG,CAAA;CACX;AAED,MAAM,WAAW,QAAQ;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,CAAA;CACpB;AAgKD;;;;GAIG;AACH,qBAAa,WAAW;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAEvB,MAAM,EAAE,UAAU;IAIxB,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;QAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;CAiFhH"}
|
package/out/renderer.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Viewport-to-braille-frame renderer for map-tui's debug view.
|
|
8
|
+
*
|
|
9
|
+
* `MapRenderer.renderFrame` is the package's single public entry point: given a `Viewport` (center lon/lat, zoom, cell
|
|
10
|
+
* columns/rows), it fetches the covering tiles from a `TileSource`, rasterizes styled geometry (./style.ts,
|
|
11
|
+
* ./raster.ts) into a subpixel RGBA grid, converts that grid to braille cells (./frame.ts), then overlays collected
|
|
12
|
+
* labels and marker/ring annotations on top. Draw order is fill → line → label per the layer style table, with overlays
|
|
13
|
+
* (ring, labels, markers) layered afterward in that order — markers deliberately skip the label collision bitmap so a
|
|
14
|
+
* requested marker always wins the cell.
|
|
15
|
+
*/
|
|
16
|
+
import { overlayText, rasterizeToFrame, rgbToPacked } from "./frame.js";
|
|
17
|
+
import { lonLatToWorldPx, metersPerPixel, TILE_SIZE } from "./mercator.js";
|
|
18
|
+
import { drawCircle, drawPolyline, fillPolygon, RGBAGrid } from "./raster.js";
|
|
19
|
+
import { stylesFor } from "./style.js";
|
|
20
|
+
const DEFAULT_MARKER_CHAR = "●";
|
|
21
|
+
const DEFAULT_MARKER_COLOR = [255, 80, 80];
|
|
22
|
+
/**
|
|
23
|
+
* Subpixel dimensions per braille cell: 2 columns wide, 4 rows tall.
|
|
24
|
+
*/
|
|
25
|
+
const SUBPIXEL_COLUMNS_PER_CELL = 2;
|
|
26
|
+
const SUBPIXEL_ROWS_PER_CELL = 4;
|
|
27
|
+
/**
|
|
28
|
+
* Minimum ring radius (in device pixels) worth drawing — smaller than this, the midpoint circle algorithm degenerates
|
|
29
|
+
* to a single point or nothing useful.
|
|
30
|
+
*/
|
|
31
|
+
const MIN_RING_RADIUS_PX = 2;
|
|
32
|
+
function clamp(value, min, max) {
|
|
33
|
+
return Math.min(Math.max(value, min), max);
|
|
34
|
+
}
|
|
35
|
+
function projectPoint(projection, gx, gy) {
|
|
36
|
+
return {
|
|
37
|
+
x: projection.tileX * TILE_SIZE + gx * projection.scale - projection.origin.x,
|
|
38
|
+
y: projection.tileY * TILE_SIZE + gy * projection.scale - projection.origin.y,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function rasterizeFill(grid, feature, projection, color) {
|
|
42
|
+
const rings = feature.geometry.map((ring) => ring.map((point) => projectPoint(projection, point.x, point.y)));
|
|
43
|
+
fillPolygon(grid, rings, color);
|
|
44
|
+
}
|
|
45
|
+
function rasterizeLine(grid, feature, projection, color, width) {
|
|
46
|
+
for (const part of feature.geometry) {
|
|
47
|
+
const points = part.map((point) => projectPoint(projection, point.x, point.y));
|
|
48
|
+
drawPolyline(grid, points, color, width);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function collectLabels(feature, property, color, projection, pendingLabels) {
|
|
52
|
+
const text = String(feature.properties[property] ?? "");
|
|
53
|
+
if (!text.length)
|
|
54
|
+
return;
|
|
55
|
+
const packedColor = rgbToPacked(color);
|
|
56
|
+
for (const part of feature.geometry) {
|
|
57
|
+
for (const point of part) {
|
|
58
|
+
const projected = projectPoint(projection, point.x, point.y);
|
|
59
|
+
pendingLabels.push({
|
|
60
|
+
text,
|
|
61
|
+
column: Math.floor(projected.x / SUBPIXEL_COLUMNS_PER_CELL),
|
|
62
|
+
row: Math.floor(projected.y / SUBPIXEL_ROWS_PER_CELL),
|
|
63
|
+
color: packedColor,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Rasterizes (or, for labels, collects) one feature under one style. The `style.kind` dispatch is the only branching
|
|
70
|
+
* here — the actual per-kind work lives in {@link rasterizeFill}/{@link rasterizeLine}/{@link collectLabels} so this
|
|
71
|
+
* stays a flat one-level `if`/`else` regardless of how deeply its caller is already nested.
|
|
72
|
+
*/
|
|
73
|
+
function rasterizeFeature(grid, feature, style, renderZoom, projection, pendingLabels) {
|
|
74
|
+
if (style.kind === "fill") {
|
|
75
|
+
rasterizeFill(grid, feature, projection, style.color);
|
|
76
|
+
}
|
|
77
|
+
else if (style.kind === "line") {
|
|
78
|
+
rasterizeLine(grid, feature, projection, style.color, style.width(renderZoom));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
collectLabels(feature, style.property, style.color, projection, pendingLabels);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Rasterizes every layer/style/feature in one tile matching `kind`. Pulled out of {@link MapRenderer.renderFrame} so
|
|
86
|
+
* that method's own tile loop doesn't accumulate this function's three nested loops on top of its own.
|
|
87
|
+
*/
|
|
88
|
+
function rasterizeTileForKind(grid, tile, tileX, tileY, kind, renderZoom, origin, pendingLabels) {
|
|
89
|
+
for (const layer of tile.layers) {
|
|
90
|
+
const styles = stylesFor(layer.name, renderZoom).filter((style) => style.kind === kind);
|
|
91
|
+
if (!styles.length)
|
|
92
|
+
continue;
|
|
93
|
+
const projection = { tileX, tileY, scale: TILE_SIZE / layer.extent, origin };
|
|
94
|
+
for (const style of styles) {
|
|
95
|
+
for (const feature of layer.features) {
|
|
96
|
+
rasterizeFeature(grid, feature, style, renderZoom, projection, pendingLabels);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Walks a viewport's rendering pipeline: tile fetch, style-ordered rasterization, braille conversion, then overlay
|
|
103
|
+
* annotations (ring, labels, markers). One `MapRenderer` can render any number of viewports against the same
|
|
104
|
+
* `TileSource` — it holds no per-frame state itself.
|
|
105
|
+
*/
|
|
106
|
+
export class MapRenderer {
|
|
107
|
+
source;
|
|
108
|
+
constructor(source) {
|
|
109
|
+
this.source = source;
|
|
110
|
+
}
|
|
111
|
+
async renderFrame(viewport, overlays) {
|
|
112
|
+
const { centerLon, centerLat, columns, rows } = viewport;
|
|
113
|
+
const subpixelW = columns * SUBPIXEL_COLUMNS_PER_CELL;
|
|
114
|
+
const subpixelH = rows * SUBPIXEL_ROWS_PER_CELL;
|
|
115
|
+
const renderZoom = clamp(Math.round(viewport.zoom), this.source.minZoom, this.source.maxZoom);
|
|
116
|
+
const center = lonLatToWorldPx(centerLon, centerLat, renderZoom);
|
|
117
|
+
const origin = { x: center.x - subpixelW / 2, y: center.y - subpixelH / 2 };
|
|
118
|
+
const zoomTileCount = 2 ** renderZoom;
|
|
119
|
+
const minTileX = clamp(Math.floor(origin.x / TILE_SIZE), 0, zoomTileCount - 1);
|
|
120
|
+
const maxTileX = clamp(Math.floor((origin.x + subpixelW) / TILE_SIZE), 0, zoomTileCount - 1);
|
|
121
|
+
const minTileY = clamp(Math.floor(origin.y / TILE_SIZE), 0, zoomTileCount - 1);
|
|
122
|
+
const maxTileY = clamp(Math.floor((origin.y + subpixelH) / TILE_SIZE), 0, zoomTileCount - 1);
|
|
123
|
+
const tileCoords = [];
|
|
124
|
+
for (let tileY = minTileY; tileY <= maxTileY; tileY++) {
|
|
125
|
+
for (let tileX = minTileX; tileX <= maxTileX; tileX++) {
|
|
126
|
+
tileCoords.push({ x: tileX, y: tileY });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const tiles = await Promise.all(tileCoords.map((coord) => this.source.getTile(renderZoom, coord.x, coord.y)));
|
|
130
|
+
const grid = new RGBAGrid(subpixelW, subpixelH);
|
|
131
|
+
const pendingLabels = [];
|
|
132
|
+
for (const kind of ["fill", "line", "label"]) {
|
|
133
|
+
for (let i = 0; i < tileCoords.length; i++) {
|
|
134
|
+
const tile = tiles[i];
|
|
135
|
+
if (!tile)
|
|
136
|
+
continue;
|
|
137
|
+
const { x: tileX, y: tileY } = tileCoords[i];
|
|
138
|
+
rasterizeTileForKind(grid, tile, tileX, tileY, kind, renderZoom, origin, pendingLabels);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (overlays?.ring) {
|
|
142
|
+
const { lon, lat, radiusMeters } = overlays.ring;
|
|
143
|
+
const radiusPx = radiusMeters / metersPerPixel(lat, renderZoom);
|
|
144
|
+
if (radiusPx >= MIN_RING_RADIUS_PX) {
|
|
145
|
+
const ringCenterWorld = lonLatToWorldPx(lon, lat, renderZoom);
|
|
146
|
+
const ringColor = [255, 255, 255];
|
|
147
|
+
drawCircle(grid, ringCenterWorld.x - origin.x, ringCenterWorld.y - origin.y, radiusPx, ringColor);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const frame = rasterizeToFrame(grid, columns, rows, this.source.attribution);
|
|
151
|
+
const occupied = new Uint8Array(columns * rows);
|
|
152
|
+
for (const label of pendingLabels) {
|
|
153
|
+
overlayText(frame, label.column, label.row, label.text, label.color, occupied);
|
|
154
|
+
}
|
|
155
|
+
if (overlays?.markers) {
|
|
156
|
+
for (const marker of overlays.markers) {
|
|
157
|
+
const markerWorld = lonLatToWorldPx(marker.lon, marker.lat, renderZoom);
|
|
158
|
+
const px = markerWorld.x - origin.x;
|
|
159
|
+
const py = markerWorld.y - origin.y;
|
|
160
|
+
const column = Math.floor(px / SUBPIXEL_COLUMNS_PER_CELL);
|
|
161
|
+
const row = Math.floor(py / SUBPIXEL_ROWS_PER_CELL);
|
|
162
|
+
overlayText(frame, column, row, marker.char ?? DEFAULT_MARKER_CHAR, rgbToPacked(marker.color ?? DEFAULT_MARKER_COLOR));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return frame;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../renderer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAiB,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACtF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE1E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,EAA6B,SAAS,EAAE,MAAM,YAAY,CAAA;AAwBjE,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAC/B,MAAM,oBAAoB,GAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AAE/C;;GAEG;AACH,MAAM,yBAAyB,GAAG,CAAC,CAAA;AACnC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEhC;;;GAGG;AACH,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAoC5B,SAAS,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IACrD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;AAC3C,CAAC;AAED,SAAS,YAAY,CAAC,UAA0B,EAAE,EAAU,EAAE,EAAU;IACvE,OAAO;QACN,CAAC,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,GA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H,MAAM,CAAC,IAAI,IAAI,mBAAmB,EAClC,WAAW,CAAC,MAAM,CAAC,KAAK,IAAI,oBAAoB,CAAC,CACjD,CAAA;YACF,CAAC;QACF,CAAC;QAED,OAAO,KAAK,CAAA;IACb,CAAC;CACD"}
|
package/out/style.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Protomaps-basemap style table for the map-tui debug view.
|
|
8
|
+
*
|
|
9
|
+
* Defines fill, line, and label styles for each of the nine protomaps-basemap layers, gated by zoom level. Color
|
|
10
|
+
* palette calibrated for dark-terminal rendering: dim fills (read as stipple density via dithering), bright lines and
|
|
11
|
+
* labels.
|
|
12
|
+
*/
|
|
13
|
+
export type RGB = readonly [red: number, green: number, blue: number];
|
|
14
|
+
export interface FillStyle {
|
|
15
|
+
kind: "fill";
|
|
16
|
+
color: RGB;
|
|
17
|
+
minZoom: number;
|
|
18
|
+
}
|
|
19
|
+
export interface LineStyle {
|
|
20
|
+
kind: "line";
|
|
21
|
+
color: RGB;
|
|
22
|
+
minZoom: number;
|
|
23
|
+
width: (zoom: number) => number;
|
|
24
|
+
}
|
|
25
|
+
export interface LabelStyle {
|
|
26
|
+
kind: "label";
|
|
27
|
+
color: RGB;
|
|
28
|
+
minZoom: number;
|
|
29
|
+
property: string;
|
|
30
|
+
}
|
|
31
|
+
export type LayerStyle = FillStyle | LineStyle | LabelStyle;
|
|
32
|
+
/**
|
|
33
|
+
* Styles applying to a protomaps-basemap layer at a zoom, draw-ordered (fills < lines < labels). Empty for
|
|
34
|
+
* unstyled/gated layers.
|
|
35
|
+
*/
|
|
36
|
+
export declare function stylesFor(layerName: string, zoom: number): LayerStyle[];
|
|
37
|
+
//# sourceMappingURL=style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../style.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEH,MAAM,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;AAErE,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,GAAG,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,GAAG,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CAC/B;AAED,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,GAAG,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;AAmB3D;;;GAGG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAEvE"}
|
package/out/style.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
// Zoom level at which roads render with 2px width instead of 1px.
|
|
7
|
+
const ROAD_WIDTH_THRESHOLD = 14;
|
|
8
|
+
const STYLE_TABLE = {
|
|
9
|
+
earth: [{ kind: "fill", color: [40, 44, 36], minZoom: 0 }],
|
|
10
|
+
landcover: [{ kind: "fill", color: [36, 52, 32], minZoom: 4 }],
|
|
11
|
+
landuse: [{ kind: "fill", color: [48, 48, 40], minZoom: 10 }],
|
|
12
|
+
water: [{ kind: "fill", color: [24, 48, 90], minZoom: 0 }],
|
|
13
|
+
buildings: [{ kind: "fill", color: [70, 66, 60], minZoom: 13 }],
|
|
14
|
+
boundaries: [{ kind: "line", color: [140, 110, 160], minZoom: 0, width: () => 1 }],
|
|
15
|
+
roads: [
|
|
16
|
+
{ kind: "line", color: [170, 170, 150], minZoom: 6, width: (zoom) => (zoom >= ROAD_WIDTH_THRESHOLD ? 2 : 1) },
|
|
17
|
+
],
|
|
18
|
+
places: [{ kind: "label", color: [235, 235, 220], minZoom: 2, property: "name" }],
|
|
19
|
+
pois: [{ kind: "label", color: [180, 200, 160], minZoom: 14, property: "name" }],
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Styles applying to a protomaps-basemap layer at a zoom, draw-ordered (fills < lines < labels). Empty for
|
|
23
|
+
* unstyled/gated layers.
|
|
24
|
+
*/
|
|
25
|
+
export function stylesFor(layerName, zoom) {
|
|
26
|
+
return (STYLE_TABLE[layerName] ?? []).filter((style) => zoom >= style.minZoom);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=style.js.map
|
package/out/style.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","sourceRoot":"","sources":["../style.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkCH,kEAAkE;AAClE,MAAM,oBAAoB,GAAG,EAAE,CAAA;AAE/B,MAAM,WAAW,GAAiC;IACjD,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC1D,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC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CAChF,CAAA;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,SAAiB,EAAE,IAAY;IACxD,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;AAC/E,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { type DecodedLayer } from "./mvt.ts";
|
|
7
|
+
export interface DecodedTile {
|
|
8
|
+
layers: DecodedLayer[];
|
|
9
|
+
}
|
|
10
|
+
export declare class TileSource {
|
|
11
|
+
readonly minZoom: number;
|
|
12
|
+
readonly maxZoom: number;
|
|
13
|
+
/**
|
|
14
|
+
* Plain-text attribution from archive metadata (HTML tags stripped); empty string when absent.
|
|
15
|
+
*/
|
|
16
|
+
readonly attribution: string;
|
|
17
|
+
private readonly handle;
|
|
18
|
+
private readonly pmtiles;
|
|
19
|
+
private readonly cache;
|
|
20
|
+
private constructor();
|
|
21
|
+
static open(path: string): Promise<TileSource>;
|
|
22
|
+
/**
|
|
23
|
+
* Decoded tile, LRU-cached (64 entries). null = tile absent from the archive.
|
|
24
|
+
*/
|
|
25
|
+
getTile(z: number, x: number, y: number): Promise<DecodedTile | null>;
|
|
26
|
+
close(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=tile-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile-source.d.ts","sourceRoot":"","sources":["../tile-source.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,UAAU,CAAA;AAEvD,MAAM,WAAW,WAAW;IAC3B,MAAM,EAAE,YAAY,EAAE,CAAA;CACtB;AAkCD,qBAAa,UAAU;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAExB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAE5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgC;IAEtD,OAAO;WAQM,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAiBpD;;OAEG;IACG,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IA6BrE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
|