@xylabs/geo 6.0.3 → 6.0.5
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/dist/neutral/GeoJson.d.ts +12 -12
- package/dist/neutral/GeoJson.d.ts.map +1 -1
- package/dist/neutral/GeoJsonModel.d.ts +4 -0
- package/dist/neutral/GeoJsonModel.d.ts.map +1 -1
- package/dist/neutral/LayerBase.d.ts +16 -6
- package/dist/neutral/LayerBase.d.ts.map +1 -1
- package/dist/neutral/index.mjs +61 -17
- package/dist/neutral/index.mjs.map +4 -4
- package/dist/neutral/mercator/tile/to/boundingbox.d.ts.map +1 -1
- package/dist/neutral/mercator/types.d.ts +25 -6
- package/dist/neutral/mercator/types.d.ts.map +1 -1
- package/package.json +6 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
/** Provides GeoJSON geometry and
|
|
1
|
+
import type { Feature, FeatureCollection, GeoJsonSourceSpecification, Geometry, Point, Polygon } from './GeoJsonModel.ts';
|
|
2
|
+
import { MercatorLngLat } from './mercator/index.ts';
|
|
3
|
+
/** Provides GeoJSON geometry and source generation from a quadkey. */
|
|
4
4
|
declare class GeoJson {
|
|
5
5
|
private _lngLat?;
|
|
6
6
|
private _point?;
|
|
@@ -15,35 +15,35 @@ declare class GeoJson {
|
|
|
15
15
|
*/
|
|
16
16
|
static featureCollection(features: Feature[]): FeatureCollection;
|
|
17
17
|
/**
|
|
18
|
-
* Creates a
|
|
18
|
+
* Creates a GeoJSON source specification from a FeatureCollection.
|
|
19
19
|
* @param data - The FeatureCollection to use as the source data
|
|
20
|
-
* @returns A
|
|
20
|
+
* @returns A GeoJSON source specification
|
|
21
21
|
*/
|
|
22
|
-
static featuresSource(data: FeatureCollection):
|
|
22
|
+
static featuresSource(data: FeatureCollection): GeoJsonSourceSpecification;
|
|
23
23
|
/**
|
|
24
24
|
* Wraps a geometry object in a GeoJSON Feature.
|
|
25
25
|
* @param geometry - The geometry to wrap
|
|
26
26
|
* @returns A GeoJSON Feature containing the geometry
|
|
27
27
|
*/
|
|
28
28
|
static geometryFeature(geometry: Geometry): Feature;
|
|
29
|
-
/** Computes and caches the center point of the quadkey's bounding box
|
|
30
|
-
center():
|
|
29
|
+
/** Computes and caches the center point of the quadkey's bounding box. */
|
|
30
|
+
center(): MercatorLngLat;
|
|
31
31
|
/** Returns a GeoJSON Point geometry at the center of the quadkey's bounding box. */
|
|
32
32
|
point(): Point;
|
|
33
33
|
/** Returns a GeoJSON Feature containing the center point geometry. */
|
|
34
34
|
pointFeature(): Feature;
|
|
35
35
|
/** Returns a GeoJSON FeatureCollection containing the center point feature. */
|
|
36
36
|
pointFeatureCollection(): FeatureCollection;
|
|
37
|
-
/** Returns a
|
|
38
|
-
pointSource():
|
|
37
|
+
/** Returns a GeoJSON source specification for the center point. */
|
|
38
|
+
pointSource(): GeoJsonSourceSpecification;
|
|
39
39
|
/** Returns a GeoJSON Polygon geometry representing the quadkey's bounding box. */
|
|
40
40
|
polygon(): Polygon;
|
|
41
41
|
/** Returns a GeoJSON Feature containing the polygon geometry. */
|
|
42
42
|
polygonFeature(): Feature;
|
|
43
43
|
/** Returns a GeoJSON FeatureCollection containing the polygon feature. */
|
|
44
44
|
polygonFeatureCollection(): FeatureCollection;
|
|
45
|
-
/** Returns a
|
|
46
|
-
polygonSource():
|
|
45
|
+
/** Returns a GeoJSON source specification for the polygon. */
|
|
46
|
+
polygonSource(): GeoJsonSourceSpecification;
|
|
47
47
|
/** Returns the zoom level derived from the quadkey length. */
|
|
48
48
|
zoom(): number;
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeoJson.d.ts","sourceRoot":"","sources":["../../src/GeoJson.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"GeoJson.d.ts","sourceRoot":"","sources":["../../src/GeoJson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAA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face GeoJsonSourceSpecification<TFeature extends Feature = Feature> {
|
|
21
|
+
data: FeatureCollection<TFeature>;
|
|
22
|
+
type: 'geojson';
|
|
23
|
+
}
|
|
20
24
|
//# sourceMappingURL=GeoJsonModel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeoJsonModel.d.ts","sourceRoot":"","sources":["../../src/GeoJsonModel.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAA;AAE/B,MAAM,WAAW,KAAK;IACpB,WAAW,EAAE,QAAQ,CAAA;IACrB,IAAI,EAAE,OAAO,CAAA;CACd;AAED,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,QAAQ,EAAE,EAAE,CAAA;IACzB,IAAI,EAAE,SAAS,CAAA;CAChB;AAED,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAA;AAEtC,MAAM,WAAW,OAAO,CAAC,SAAS,SAAS,QAAQ,GAAG,QAAQ;IAC5D,QAAQ,EAAE,SAAS,CAAA;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,IAAI,EAAE,SAAS,CAAA;CAChB;AAED,MAAM,WAAW,iBAAiB,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO;IACnE,QAAQ,EAAE,QAAQ,EAAE,CAAA;IACpB,IAAI,EAAE,mBAAmB,CAAA;CAC1B"}
|
|
1
|
+
{"version":3,"file":"GeoJsonModel.d.ts","sourceRoot":"","sources":["../../src/GeoJsonModel.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAA;AAE/B,MAAM,WAAW,KAAK;IACpB,WAAW,EAAE,QAAQ,CAAA;IACrB,IAAI,EAAE,OAAO,CAAA;CACd;AAED,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,QAAQ,EAAE,EAAE,CAAA;IACzB,IAAI,EAAE,SAAS,CAAA;CAChB;AAED,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAA;AAEtC,MAAM,WAAW,OAAO,CAAC,SAAS,SAAS,QAAQ,GAAG,QAAQ;IAC5D,QAAQ,EAAE,SAAS,CAAA;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,IAAI,EAAE,SAAS,CAAA;CAChB;AAED,MAAM,WAAW,iBAAiB,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO;IACnE,QAAQ,EAAE,QAAQ,EAAE,CAAA;IACpB,IAAI,EAAE,mBAAmB,CAAA;CAC1B;AAED,MAAM,WAAW,0BAA0B,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO;IAC5E,IAAI,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAA;IACjC,IAAI,EAAE,SAAS,CAAA;CAChB"}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
interface MapLayer {
|
|
2
|
+
id: string;
|
|
3
|
+
source?: string | Record<string, unknown>;
|
|
4
|
+
type?: string;
|
|
5
|
+
}
|
|
6
|
+
interface LayerMap<TLayer extends MapLayer = MapLayer> {
|
|
7
|
+
addLayer(layer: TLayer): void;
|
|
8
|
+
getLayer(id: string): TLayer | undefined;
|
|
9
|
+
removeLayer(id: string): void;
|
|
10
|
+
}
|
|
11
|
+
/** Abstract base class for managing map layers with add/remove lifecycle. */
|
|
12
|
+
export declare abstract class LayerBase<T extends MapLayer> {
|
|
4
13
|
id: string;
|
|
5
14
|
source: string;
|
|
6
15
|
constructor(id: string, source: string);
|
|
7
16
|
/**
|
|
8
17
|
* Removes and re-adds the layer on the map, optionally hiding it.
|
|
9
|
-
* @param map - The
|
|
18
|
+
* @param map - The map instance
|
|
10
19
|
* @param show - Whether to show the layer after updating (default true)
|
|
11
20
|
*/
|
|
12
|
-
update(map:
|
|
13
|
-
/** Builds the
|
|
21
|
+
update(map: LayerMap<T>, show?: boolean): void;
|
|
22
|
+
/** Builds the layer configuration object. */
|
|
14
23
|
abstract buildLayer(): T;
|
|
15
24
|
}
|
|
25
|
+
export type { LayerMap, MapLayer };
|
|
16
26
|
//# sourceMappingURL=LayerBase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayerBase.d.ts","sourceRoot":"","sources":["../../src/LayerBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"LayerBase.d.ts","sourceRoot":"","sources":["../../src/LayerBase.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzC,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,UAAU,QAAQ,CAAC,MAAM,SAAS,QAAQ,GAAG,QAAQ;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACxC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED,6EAA6E;AAC7E,8BAAsB,SAAS,CAAC,CAAC,SAAS,QAAQ;IAChD,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;gBAEF,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAKtC;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,UAAO,GAAG,IAAI;IAS3C,6CAA6C;IAC7C,QAAQ,CAAC,UAAU,IAAI,CAAC;CACzB;AAED,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// src/GeoJson.ts
|
|
2
|
-
import MapBox3 from "mapbox-gl";
|
|
3
|
-
|
|
4
1
|
// src/mercator/boundingbox/to/boundary.ts
|
|
5
2
|
var boundingBoxToBoundary = (box) => {
|
|
6
3
|
return [box.getNorthWest(), box.getNorthEast(), box.getSouthEast(), box.getSouthWest(), box.getNorthWest()];
|
|
@@ -69,14 +66,61 @@ var tileFromQuadkey = (quadkey) => {
|
|
|
69
66
|
return [x, y, z];
|
|
70
67
|
};
|
|
71
68
|
|
|
72
|
-
// src/mercator/tile/to/boundingbox.ts
|
|
73
|
-
import MapBox2 from "mapbox-gl";
|
|
74
|
-
|
|
75
69
|
// src/mercator/types.ts
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
function toMercatorLngLat(value) {
|
|
71
|
+
if (value instanceof MercatorLngLat) return value;
|
|
72
|
+
if (!value) return new MercatorLngLat(0, 0);
|
|
73
|
+
if ("lng" in value) return new MercatorLngLat(value.lng, value.lat);
|
|
74
|
+
return new MercatorLngLat(value[0], value[1]);
|
|
75
|
+
}
|
|
76
|
+
var MercatorLngLat = class {
|
|
77
|
+
lat;
|
|
78
|
+
lng;
|
|
79
|
+
constructor(lng, lat) {
|
|
80
|
+
this.lng = lng;
|
|
81
|
+
this.lat = lat;
|
|
82
|
+
}
|
|
83
|
+
toArray() {
|
|
84
|
+
return [this.lng, this.lat];
|
|
85
|
+
}
|
|
78
86
|
};
|
|
79
|
-
var
|
|
87
|
+
var MercatorBoundingBox = class {
|
|
88
|
+
ne;
|
|
89
|
+
sw;
|
|
90
|
+
constructor(sw, ne) {
|
|
91
|
+
this.sw = toMercatorLngLat(sw);
|
|
92
|
+
this.ne = toMercatorLngLat(ne);
|
|
93
|
+
}
|
|
94
|
+
getCenter() {
|
|
95
|
+
return new MercatorLngLat(
|
|
96
|
+
(this.getWest() + this.getEast()) / 2,
|
|
97
|
+
(this.getSouth() + this.getNorth()) / 2
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
getEast() {
|
|
101
|
+
return this.ne.lng;
|
|
102
|
+
}
|
|
103
|
+
getNorth() {
|
|
104
|
+
return this.ne.lat;
|
|
105
|
+
}
|
|
106
|
+
getNorthEast() {
|
|
107
|
+
return this.ne;
|
|
108
|
+
}
|
|
109
|
+
getNorthWest() {
|
|
110
|
+
return new MercatorLngLat(this.sw.lng, this.ne.lat);
|
|
111
|
+
}
|
|
112
|
+
getSouth() {
|
|
113
|
+
return this.sw.lat;
|
|
114
|
+
}
|
|
115
|
+
getSouthEast() {
|
|
116
|
+
return new MercatorLngLat(this.ne.lng, this.sw.lat);
|
|
117
|
+
}
|
|
118
|
+
getSouthWest() {
|
|
119
|
+
return this.sw;
|
|
120
|
+
}
|
|
121
|
+
getWest() {
|
|
122
|
+
return this.sw.lng;
|
|
123
|
+
}
|
|
80
124
|
};
|
|
81
125
|
|
|
82
126
|
// src/mercator/tile/to/boundingbox.ts
|
|
@@ -92,7 +136,7 @@ var tileToBoundingBox = (tile) => {
|
|
|
92
136
|
const w = toLongitude(tile[0], tile[2]);
|
|
93
137
|
const s = toLatitude(tile[1] + 1, tile[2]);
|
|
94
138
|
const n = toLatitude(tile[1], tile[2]);
|
|
95
|
-
return new MercatorBoundingBox(new
|
|
139
|
+
return new MercatorBoundingBox(new MercatorLngLat(w, s), new MercatorLngLat(e, n));
|
|
96
140
|
};
|
|
97
141
|
|
|
98
142
|
// src/mercator/tile/to/children.ts
|
|
@@ -224,9 +268,9 @@ var GeoJson = class _GeoJson {
|
|
|
224
268
|
};
|
|
225
269
|
}
|
|
226
270
|
/**
|
|
227
|
-
* Creates a
|
|
271
|
+
* Creates a GeoJSON source specification from a FeatureCollection.
|
|
228
272
|
* @param data - The FeatureCollection to use as the source data
|
|
229
|
-
* @returns A
|
|
273
|
+
* @returns A GeoJSON source specification
|
|
230
274
|
*/
|
|
231
275
|
static featuresSource(data) {
|
|
232
276
|
return {
|
|
@@ -246,13 +290,13 @@ var GeoJson = class _GeoJson {
|
|
|
246
290
|
type: "Feature"
|
|
247
291
|
};
|
|
248
292
|
}
|
|
249
|
-
/** Computes and caches the center point of the quadkey's bounding box
|
|
293
|
+
/** Computes and caches the center point of the quadkey's bounding box. */
|
|
250
294
|
center() {
|
|
251
295
|
if (!this._lngLat) {
|
|
252
296
|
const tile = tileFromQuadkey(this.quadkey);
|
|
253
297
|
const bb = tileToBoundingBox(tile);
|
|
254
298
|
const point = boundingBoxToCenter(bb);
|
|
255
|
-
this._lngLat = new
|
|
299
|
+
this._lngLat = new MercatorLngLat(point[0], point[1]);
|
|
256
300
|
}
|
|
257
301
|
return this._lngLat;
|
|
258
302
|
}
|
|
@@ -272,7 +316,7 @@ var GeoJson = class _GeoJson {
|
|
|
272
316
|
pointFeatureCollection() {
|
|
273
317
|
return _GeoJson.featureCollection([this.pointFeature()]);
|
|
274
318
|
}
|
|
275
|
-
/** Returns a
|
|
319
|
+
/** Returns a GeoJSON source specification for the center point. */
|
|
276
320
|
pointSource() {
|
|
277
321
|
return {
|
|
278
322
|
data: this.pointFeatureCollection(),
|
|
@@ -292,7 +336,7 @@ var GeoJson = class _GeoJson {
|
|
|
292
336
|
polygonFeatureCollection() {
|
|
293
337
|
return _GeoJson.featureCollection([this.polygonFeature()]);
|
|
294
338
|
}
|
|
295
|
-
/** Returns a
|
|
339
|
+
/** Returns a GeoJSON source specification for the polygon. */
|
|
296
340
|
polygonSource() {
|
|
297
341
|
return _GeoJson.featuresSource(this.polygonFeatureCollection());
|
|
298
342
|
}
|
|
@@ -313,7 +357,7 @@ var LayerBase = class {
|
|
|
313
357
|
}
|
|
314
358
|
/**
|
|
315
359
|
* Removes and re-adds the layer on the map, optionally hiding it.
|
|
316
|
-
* @param map - The
|
|
360
|
+
* @param map - The map instance
|
|
317
361
|
* @param show - Whether to show the layer after updating (default true)
|
|
318
362
|
*/
|
|
319
363
|
update(map, show = true) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/
|
|
4
|
-
"sourcesContent": ["import MapBox from 'mapbox-gl'\n\nimport type {\n Feature, FeatureCollection, Geometry, Point, Polygon,\n} from './GeoJsonModel.ts'\nimport {\n boundingBoxToCenter, boundingBoxToPolygon, tileFromQuadkey, tileToBoundingBox,\n} from './mercator/index.ts'\n\n/** Provides GeoJSON geometry and MapBox source generation from a quadkey. */\nclass GeoJson {\n private _lngLat?: MapBox.LngLat\n private _point?: Point\n private _polygon?: Polygon\n private _zoom?: number\n\n private quadkey: string\n\n constructor(quadkey: string) {\n this.quadkey = quadkey\n }\n\n /**\n * Creates a GeoJSON FeatureCollection from an array of features.\n * @param features - The features to include\n * @returns A GeoJSON FeatureCollection\n */\n static featureCollection(features: Feature[]): FeatureCollection {\n return {\n features,\n type: 'FeatureCollection',\n }\n }\n\n /**\n * Creates a MapBox GeoJSON source specification from a FeatureCollection.\n * @param data - The FeatureCollection to use as the source data\n * @returns A MapBox GeoJSON source specification\n */\n static featuresSource(data: FeatureCollection): MapBox.GeoJSONSourceSpecification {\n return {\n data,\n type: 'geojson',\n }\n }\n\n /**\n * Wraps a geometry object in a GeoJSON Feature.\n * @param geometry - The geometry to wrap\n * @returns A GeoJSON Feature containing the geometry\n */\n static geometryFeature(geometry: Geometry): Feature {\n return {\n geometry,\n properties: {},\n type: 'Feature',\n }\n }\n\n /** Computes and caches the center point of the quadkey's bounding box as a MapBox LngLat. */\n center(): MapBox.LngLat {\n if (!this._lngLat) {\n const tile = tileFromQuadkey(this.quadkey)\n const bb = tileToBoundingBox(tile)\n const point = boundingBoxToCenter(bb)\n this._lngLat = new MapBox.LngLat(point[0], point[1])\n }\n return this._lngLat\n }\n\n /** Returns a GeoJSON Point geometry at the center of the quadkey's bounding box. */\n point(): Point {\n this._point ??= {\n coordinates: this.center().toArray(),\n type: 'Point',\n }\n return this._point\n }\n\n /** Returns a GeoJSON Feature containing the center point geometry. */\n pointFeature(): Feature {\n return GeoJson.geometryFeature(this.point())\n }\n\n /** Returns a GeoJSON FeatureCollection containing the center point feature. */\n pointFeatureCollection(): FeatureCollection {\n return GeoJson.featureCollection([this.pointFeature()])\n }\n\n /** Returns a MapBox GeoJSON source specification for the center point. */\n pointSource(): MapBox.GeoJSONSourceSpecification {\n return {\n data: this.pointFeatureCollection(),\n type: 'geojson',\n }\n }\n\n /** Returns a GeoJSON Polygon geometry representing the quadkey's bounding box. */\n polygon(): Polygon {\n this._polygon ??= boundingBoxToPolygon(tileToBoundingBox(tileFromQuadkey(this.quadkey)))\n return this._polygon\n }\n\n /** Returns a GeoJSON Feature containing the polygon geometry. */\n polygonFeature(): Feature {\n return GeoJson.geometryFeature(this.polygon())\n }\n\n /** Returns a GeoJSON FeatureCollection containing the polygon feature. */\n polygonFeatureCollection(): FeatureCollection {\n return GeoJson.featureCollection([this.polygonFeature()])\n }\n\n /** Returns a MapBox GeoJSON source specification for the polygon. */\n polygonSource(): MapBox.GeoJSONSourceSpecification {\n return GeoJson.featuresSource(this.polygonFeatureCollection())\n }\n\n /** Returns the zoom level derived from the quadkey length. */\n zoom(): number {\n this._zoom = this._zoom ?? tileFromQuadkey(this.quadkey)[2]\n return this._zoom\n }\n}\n\nexport { GeoJson }\n", "import type { MercatorBoundary, MercatorBoundingBox } from '../../types.ts'\n\n/**\n * Converts a bounding box to an ordered boundary polygon (closed ring of corner points).\n * @param box - The bounding box to convert\n * @returns An array of corner points forming a closed boundary\n */\nexport const boundingBoxToBoundary = (box: MercatorBoundingBox): MercatorBoundary => {\n return [box.getNorthWest(), box.getNorthEast(), box.getSouthEast(), box.getSouthWest(), box.getNorthWest()]\n}\n", "import type { MercatorBoundingBox } from '../../types.ts'\n\n/**\n * Computes the center point of a bounding box as [lng, lat], rounded to the specified decimal places.\n * @param boundingBox - The bounding box to find the center of\n * @param decimal - Number of decimal places for rounding (default 6)\n * @returns A [longitude, latitude] tuple representing the center\n */\nexport const boundingBoxToCenter = (boundingBox: MercatorBoundingBox, decimal = 6) => {\n const west = boundingBox.getWest()\n const south = boundingBox.getSouth()\n const east = boundingBox.getEast()\n const north = boundingBox.getNorth()\n let lng = (west - east) / 2 + east\n let lat = (south - north) / 2 + north\n if (decimal !== undefined && decimal !== null) {\n lng = Number(lng.toFixed(decimal))\n lat = Number(lat.toFixed(decimal))\n }\n return [lng, lat]\n}\n", "import type { Polygon } from '../../../GeoJsonModel.ts'\nimport type { MercatorBoundingBox, MercatorLngLat } from '../../types.ts'\nimport { boundingBoxToBoundary } from './boundary.ts'\n\n/**\n * Converts a bounding box to a GeoJSON Polygon geometry.\n * @param box - The bounding box to convert\n * @returns A GeoJSON Polygon representing the bounding box\n */\nexport const boundingBoxToPolygon = (box: MercatorBoundingBox): Polygon => {\n const boundry = boundingBoxToBoundary(box)\n return {\n coordinates: [boundry.map((lnglng: MercatorLngLat) => lnglng.toArray())],\n type: 'Polygon',\n }\n}\n", "/** Conversion factor from degrees to radians. */\nconst d2r = Math.PI / 180\n/** Conversion factor from radians to degrees. */\nconst r2d = 180 / Math.PI\n\nexport { d2r, r2d }\n", "import { d2r } from '../../constants.ts'\nimport type { MercatorLngLat, MercatorTile } from '../../types.ts'\n\n/**\n * Converts a geographic point to fractional tile coordinates at the given zoom level.\n * @param point - The geographic coordinate\n * @param z - The zoom level\n * @returns A tile with fractional x and y values\n */\nconst pointToTileFraction = (point: MercatorLngLat, z: number): MercatorTile => {\n const sin = Math.sin(point.lat * d2r)\n const z2 = Math.pow(2, z)\n let x = z2 * (point.lng / 360 + 0.5)\n const y = z2 * (0.5 - (0.25 * Math.log((1 + sin) / (1 - sin))) / Math.PI)\n\n // Wrap Tile X\n x = x % z2\n if (x < 0) x = x + z2\n return [x, y, z]\n}\n\n/**\n * Converts a geographic point to the integer Mercator tile containing it at the given zoom level.\n * @param point - The geographic coordinate\n * @param z - The zoom level\n * @returns The tile as [x, y, zoom]\n */\nconst tileFromPoint = (point: MercatorLngLat, z: number): MercatorTile => {\n const [tileX, tileY, tileZoom] = pointToTileFraction(point, z)\n const x = Math.max(Math.floor(tileX), 0)\n const y = Math.max(Math.floor(tileY), 0)\n return [x, y, tileZoom]\n}\n\nexport { tileFromPoint }\n", "import type { MercatorTile } from '../../types.ts'\n\n/**\n * Converts a quadkey string to a Mercator tile [x, y, zoom].\n * @param quadkey - The quadkey string to decode\n * @returns The tile as [x, y, zoom]\n */\nconst tileFromQuadkey = (quadkey: string): MercatorTile => {\n let x = 0\n let y = 0\n const z = quadkey.length\n\n for (let i = z; i > 0; i--) {\n const mask = 1 << (i - 1)\n const q = +quadkey[z - i]\n if (q === 1) x |= mask\n if (q === 2) y |= mask\n if (q === 3) {\n x |= mask\n y |= mask\n }\n }\n return [x, y, z]\n}\n\nexport { tileFromQuadkey }\n", "import MapBox from 'mapbox-gl'\n\nimport { r2d } from '../../constants.ts'\nimport type { MercatorTile } from '../../types.ts'\nimport { MercatorBoundingBox } from '../../types.ts'\n\nconst toLongitude = (x: number, z: number): number => {\n return (x / Math.pow(2, z)) * 360 - 180\n}\n\nconst toLatitude = (y: number, z: number): number => {\n const n = Math.PI - (2 * Math.PI * y) / Math.pow(2, z)\n return r2d * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)))\n}\n\n/**\n * Converts a Mercator tile to its geographic bounding box.\n * @param tile - The tile as [x, y, zoom]\n * @returns The bounding box covering the tile's geographic extent\n */\nconst tileToBoundingBox = (tile: MercatorTile): MercatorBoundingBox => {\n const e = toLongitude(tile[0] + 1, tile[2])\n const w = toLongitude(tile[0], tile[2])\n const s = toLatitude(tile[1] + 1, tile[2])\n const n = toLatitude(tile[1], tile[2])\n return new MercatorBoundingBox(new MapBox.LngLat(w, s), new MapBox.LngLat(e, n))\n}\n\nexport { tileToBoundingBox }\n", "import MapBox from 'mapbox-gl'\n\n/** A Mercator tile represented as [x, y, zoom]. */\ntype MercatorTile = readonly [x: number, y: number, zoom: number]\n/** An ordered array of MercatorLngLat points forming a boundary. */\ntype MercatorBoundary = MercatorLngLat[]\n/** A Mercator bounding box extending MapBox LngLatBounds. */\nclass MercatorBoundingBox extends MapBox.LngLatBounds {}\n/** A Mercator coordinate extending MapBox LngLat. */\nclass MercatorLngLat extends MapBox.LngLat {}\n\nexport { MercatorBoundingBox, MercatorLngLat }\nexport type { MercatorBoundary, MercatorTile }\n", "import type { MercatorTile } from '../../types.ts'\n\n/**\n * Returns the four child tiles at one zoom level higher.\n * @param tile - The parent tile as [x, y, zoom]\n * @returns An array of four child tiles at zoom + 1\n */\nconst tileToChildren = (tile: MercatorTile): MercatorTile[] => {\n return [\n [tile[0] * 2, tile[1] * 2, tile[2] + 1],\n [tile[0] * 2 + 1, tile[1] * 2, tile[2] + 1],\n [tile[0] * 2 + 1, tile[1] * 2 + 1, tile[2] + 1],\n [tile[0] * 2, tile[1] * 2 + 1, tile[2] + 1],\n ]\n}\n\nexport { tileToChildren }\n", "import type { Polygon } from '../../../GeoJsonModel.ts'\nimport type { MercatorTile } from '../../types.ts'\nimport { tileToBoundingBox } from './boundingbox.ts'\n\n/**\n * Converts a Mercator tile to a GeoJSON Polygon geometry.\n * @param tile - The tile as [x, y, zoom]\n * @returns A GeoJSON Polygon representing the tile's geographic extent\n */\nconst tileToGeoJson = (tile: MercatorTile): Polygon => {\n const box = tileToBoundingBox(tile)\n const poly: Polygon = {\n coordinates: [\n [\n box.getNorthWest().toArray(),\n box.getNorthEast().toArray(),\n box.getSouthEast().toArray(),\n box.getSouthWest().toArray(),\n box.getNorthWest().toArray(),\n ],\n ],\n type: 'Polygon',\n }\n return poly\n}\n\nexport { tileToGeoJson }\n", "import type { MercatorTile } from '../../types.ts'\n\n/**\n * Returns the parent tile at one zoom level lower.\n * @param tile - The tile as [x, y, zoom]\n * @returns The parent tile at zoom - 1\n */\nconst tileToParent = (tile: MercatorTile): MercatorTile => {\n return [tile[0] >> 1, tile[1] >> 1, tile[2] - 1]\n}\n\nexport { tileToParent }\n", "import type { MercatorLngLat, MercatorTile } from '../../types.ts'\nimport { tileToBoundingBox } from './boundingbox.ts'\n\n/**\n * Returns the center point of a Mercator tile.\n * @param tile - The tile as [x, y, zoom]\n * @returns The center coordinate as a MercatorLngLat\n */\nconst tileToPoint = (tile: MercatorTile): MercatorLngLat => {\n const boundingBox = tileToBoundingBox(tile)\n boundingBox.getCenter()\n return boundingBox.getCenter()\n}\n\nexport { tileToPoint }\n", "import type { MercatorTile } from '../../types.ts'\n\n/**\n * Converts a Mercator tile to its quadkey string representation.\n * @param param0 - The tile as [tileX, tileY, tileZoom]\n * @returns The quadkey string encoding the tile's position and zoom\n */\nconst tileToQuadkey = ([tileX, tileY, tileZoom]: MercatorTile): string => {\n let index = ''\n for (let z = tileZoom; z > 0; z--) {\n let b = 0\n const mask = 1 << (z - 1)\n if ((tileX & mask) !== 0) b++\n if ((tileY & mask) !== 0) b += 2\n index += b.toString()\n }\n return index\n}\n\nexport { tileToQuadkey }\n", "import type { MercatorTile } from '../../types.ts'\nimport { tileToChildren } from './children.ts'\nimport { tileToParent } from './parent.ts'\n\n/**\n * Returns the four sibling tiles (children of the parent tile) for the given tile.\n * @param tile - The tile as [x, y, zoom]\n * @returns An array of four sibling tiles at the same zoom level\n */\nconst tileToSiblings = (tile: MercatorTile): MercatorTile[] => {\n return tileToChildren(tileToParent(tile))\n}\n\nexport { tileToSiblings }\n", "import type { MercatorTile } from '../types.ts'\n\n/**\n * Checks whether two Mercator tiles are equal by comparing their x, y, and zoom values.\n * @param param0 - The first tile as [x, y, zoom]\n * @param param1 - The second tile as [x, y, zoom]\n * @returns True if both tiles have identical coordinates and zoom\n */\nexport const tilesEqual = /* @__PURE__ */ ([x1, y1, zoom1]: MercatorTile, [x2, y2, zoom2]: MercatorTile): boolean => {\n return x1 === x2 && y1 === y2 && zoom1 === zoom2\n}\n", "import { tileFromPoint } from '../../tile/index.ts'\nimport type { MercatorBoundingBox, MercatorTile } from '../../types.ts'\n\n/**\n * Returns all Mercator tiles that intersect the given bounding box at the specified zoom level.\n * @param box - The geographic bounding box\n * @param zoom - The zoom level\n * @returns An array of tiles covering the bounding box\n */\nconst tilesFromBoundingBox = (box: MercatorBoundingBox, zoom: number): MercatorTile[] => {\n const nw = tileFromPoint(box.getNorthWest(), zoom)\n const se = tileFromPoint(box.getSouthEast(), zoom)\n const size = Math.pow(2, zoom)\n\n let minX = nw[0]\n let maxX = se[0]\n let minY = nw[1]\n let maxY = se[1]\n\n // in case of horizontal wrapping\n if (minX >= maxX) {\n maxX = maxX + size\n }\n\n if (zoom < 4) {\n minX = 0\n maxX = size - 1\n minY = 0\n maxY = size - 1\n }\n\n const result: MercatorTile[] = []\n\n for (let x = minX; x <= maxX; x++) {\n for (let y = minY; y <= maxY; y++) {\n result.push([x % size, y, zoom])\n }\n }\n\n return result\n}\n\nexport { tilesFromBoundingBox }\n", "import type { MercatorTile } from '../types.ts'\nimport { tilesEqual } from './equal.ts'\n\n/**\n * Checks whether a specific tile exists in the given tile array.\n * @param tiles - The array of tiles to search\n * @param tile - The tile to look for\n * @returns True if the tile is found in the array\n */\nexport const tilesHasTile = (tiles: MercatorTile[], tile: MercatorTile) => {\n for (const tileToCheck of tiles) {\n if (tilesEqual(tileToCheck, tile)) return true\n }\n return false\n}\n", "import { tileToSiblings } from '../tile/index.ts'\nimport type { MercatorTile } from '../types.ts'\nimport { tilesHasTile } from './hasTile.ts'\n\n/**\n * Checks whether all four siblings of the given tile exist in the tile array.\n * @param tiles - The array of tiles to search\n * @param tile - The tile whose siblings to check for\n * @returns True if all siblings are present in the array\n */\nexport const hasSiblings = (tiles: MercatorTile[], tile: MercatorTile) => {\n const siblings = tileToSiblings(tile)\n for (const sibling of siblings) {\n if (!tilesHasTile(tiles, sibling)) return false\n }\n return true\n}\n", "import type MapBox from 'mapbox-gl'\n\n/** Abstract base class for managing MapBox map layers with add/remove lifecycle. */\nexport abstract class LayerBase<T extends MapBox.Layer> {\n id: string\n source: string\n\n constructor(id: string, source: string) {\n this.id = id\n this.source = source\n }\n\n /**\n * Removes and re-adds the layer on the map, optionally hiding it.\n * @param map - The MapBox map instance\n * @param show - Whether to show the layer after updating (default true)\n */\n update(map: MapBox.Map, show = true) {\n if (map.getLayer(this.id)) {\n map.removeLayer(this.id)\n }\n if (show) {\n map.addLayer(this.buildLayer())\n }\n }\n\n /** Builds the MapBox layer configuration object. */\n abstract buildLayer(): T\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": [
|
|
3
|
+
"sources": ["../../src/mercator/boundingbox/to/boundary.ts", "../../src/mercator/boundingbox/to/center.ts", "../../src/mercator/boundingbox/to/polygon.ts", "../../src/mercator/constants.ts", "../../src/mercator/tile/from/point.ts", "../../src/mercator/tile/from/quadkey.ts", "../../src/mercator/types.ts", "../../src/mercator/tile/to/boundingbox.ts", "../../src/mercator/tile/to/children.ts", "../../src/mercator/tile/to/geoJson.ts", "../../src/mercator/tile/to/parent.ts", "../../src/mercator/tile/to/point.ts", "../../src/mercator/tile/to/quadkey.ts", "../../src/mercator/tile/to/siblings.ts", "../../src/mercator/tiles/equal.ts", "../../src/mercator/tiles/from/boundingbox.ts", "../../src/mercator/tiles/hasTile.ts", "../../src/mercator/tiles/hasSiblings.ts", "../../src/GeoJson.ts", "../../src/LayerBase.ts"],
|
|
4
|
+
"sourcesContent": ["import type { MercatorBoundary, MercatorBoundingBox } from '../../types.ts'\n\n/**\n * Converts a bounding box to an ordered boundary polygon (closed ring of corner points).\n * @param box - The bounding box to convert\n * @returns An array of corner points forming a closed boundary\n */\nexport const boundingBoxToBoundary = (box: MercatorBoundingBox): MercatorBoundary => {\n return [box.getNorthWest(), box.getNorthEast(), box.getSouthEast(), box.getSouthWest(), box.getNorthWest()]\n}\n", "import type { MercatorBoundingBox } from '../../types.ts'\n\n/**\n * Computes the center point of a bounding box as [lng, lat], rounded to the specified decimal places.\n * @param boundingBox - The bounding box to find the center of\n * @param decimal - Number of decimal places for rounding (default 6)\n * @returns A [longitude, latitude] tuple representing the center\n */\nexport const boundingBoxToCenter = (boundingBox: MercatorBoundingBox, decimal = 6) => {\n const west = boundingBox.getWest()\n const south = boundingBox.getSouth()\n const east = boundingBox.getEast()\n const north = boundingBox.getNorth()\n let lng = (west - east) / 2 + east\n let lat = (south - north) / 2 + north\n if (decimal !== undefined && decimal !== null) {\n lng = Number(lng.toFixed(decimal))\n lat = Number(lat.toFixed(decimal))\n }\n return [lng, lat]\n}\n", "import type { Polygon } from '../../../GeoJsonModel.ts'\nimport type { MercatorBoundingBox, MercatorLngLat } from '../../types.ts'\nimport { boundingBoxToBoundary } from './boundary.ts'\n\n/**\n * Converts a bounding box to a GeoJSON Polygon geometry.\n * @param box - The bounding box to convert\n * @returns A GeoJSON Polygon representing the bounding box\n */\nexport const boundingBoxToPolygon = (box: MercatorBoundingBox): Polygon => {\n const boundry = boundingBoxToBoundary(box)\n return {\n coordinates: [boundry.map((lnglng: MercatorLngLat) => lnglng.toArray())],\n type: 'Polygon',\n }\n}\n", "/** Conversion factor from degrees to radians. */\nconst d2r = Math.PI / 180\n/** Conversion factor from radians to degrees. */\nconst r2d = 180 / Math.PI\n\nexport { d2r, r2d }\n", "import { d2r } from '../../constants.ts'\nimport type { MercatorLngLat, MercatorTile } from '../../types.ts'\n\n/**\n * Converts a geographic point to fractional tile coordinates at the given zoom level.\n * @param point - The geographic coordinate\n * @param z - The zoom level\n * @returns A tile with fractional x and y values\n */\nconst pointToTileFraction = (point: MercatorLngLat, z: number): MercatorTile => {\n const sin = Math.sin(point.lat * d2r)\n const z2 = Math.pow(2, z)\n let x = z2 * (point.lng / 360 + 0.5)\n const y = z2 * (0.5 - (0.25 * Math.log((1 + sin) / (1 - sin))) / Math.PI)\n\n // Wrap Tile X\n x = x % z2\n if (x < 0) x = x + z2\n return [x, y, z]\n}\n\n/**\n * Converts a geographic point to the integer Mercator tile containing it at the given zoom level.\n * @param point - The geographic coordinate\n * @param z - The zoom level\n * @returns The tile as [x, y, zoom]\n */\nconst tileFromPoint = (point: MercatorLngLat, z: number): MercatorTile => {\n const [tileX, tileY, tileZoom] = pointToTileFraction(point, z)\n const x = Math.max(Math.floor(tileX), 0)\n const y = Math.max(Math.floor(tileY), 0)\n return [x, y, tileZoom]\n}\n\nexport { tileFromPoint }\n", "import type { MercatorTile } from '../../types.ts'\n\n/**\n * Converts a quadkey string to a Mercator tile [x, y, zoom].\n * @param quadkey - The quadkey string to decode\n * @returns The tile as [x, y, zoom]\n */\nconst tileFromQuadkey = (quadkey: string): MercatorTile => {\n let x = 0\n let y = 0\n const z = quadkey.length\n\n for (let i = z; i > 0; i--) {\n const mask = 1 << (i - 1)\n const q = +quadkey[z - i]\n if (q === 1) x |= mask\n if (q === 2) y |= mask\n if (q === 3) {\n x |= mask\n y |= mask\n }\n }\n return [x, y, z]\n}\n\nexport { tileFromQuadkey }\n", "/** A Mercator tile represented as [x, y, zoom]. */\ntype MercatorTile = readonly [x: number, y: number, zoom: number]\n/** An ordered array of MercatorLngLat points forming a boundary. */\ntype MercatorBoundary = MercatorLngLat[]\n\ntype MercatorLngLatLike = MercatorLngLat | readonly [lng: number, lat: number] | { lat: number; lng: number }\n\nfunction toMercatorLngLat(value: MercatorLngLatLike | undefined): MercatorLngLat {\n if (value instanceof MercatorLngLat) return value\n if (!value) return new MercatorLngLat(0, 0)\n if ('lng' in value) return new MercatorLngLat(value.lng, value.lat)\n return new MercatorLngLat(value[0], value[1])\n}\n\n/** A Mercator coordinate. */\nclass MercatorLngLat {\n lat: number\n lng: number\n\n constructor(lng: number, lat: number) {\n this.lng = lng\n this.lat = lat\n }\n\n toArray(): [lng: number, lat: number] {\n return [this.lng, this.lat]\n }\n}\n\n/** A Mercator bounding box. */\nclass MercatorBoundingBox {\n private readonly ne: MercatorLngLat\n private readonly sw: MercatorLngLat\n\n constructor(sw?: MercatorLngLatLike, ne?: MercatorLngLatLike) {\n this.sw = toMercatorLngLat(sw)\n this.ne = toMercatorLngLat(ne)\n }\n\n getCenter(): MercatorLngLat {\n return new MercatorLngLat(\n (this.getWest() + this.getEast()) / 2,\n (this.getSouth() + this.getNorth()) / 2,\n )\n }\n\n getEast(): number {\n return this.ne.lng\n }\n\n getNorth(): number {\n return this.ne.lat\n }\n\n getNorthEast(): MercatorLngLat {\n return this.ne\n }\n\n getNorthWest(): MercatorLngLat {\n return new MercatorLngLat(this.sw.lng, this.ne.lat)\n }\n\n getSouth(): number {\n return this.sw.lat\n }\n\n getSouthEast(): MercatorLngLat {\n return new MercatorLngLat(this.ne.lng, this.sw.lat)\n }\n\n getSouthWest(): MercatorLngLat {\n return this.sw\n }\n\n getWest(): number {\n return this.sw.lng\n }\n}\n\nexport { MercatorBoundingBox, MercatorLngLat }\nexport type {\n MercatorBoundary, MercatorLngLatLike, MercatorTile,\n}\n", "import { r2d } from '../../constants.ts'\nimport type { MercatorTile } from '../../types.ts'\nimport { MercatorBoundingBox, MercatorLngLat } from '../../types.ts'\n\nconst toLongitude = (x: number, z: number): number => {\n return (x / Math.pow(2, z)) * 360 - 180\n}\n\nconst toLatitude = (y: number, z: number): number => {\n const n = Math.PI - (2 * Math.PI * y) / Math.pow(2, z)\n return r2d * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)))\n}\n\n/**\n * Converts a Mercator tile to its geographic bounding box.\n * @param tile - The tile as [x, y, zoom]\n * @returns The bounding box covering the tile's geographic extent\n */\nconst tileToBoundingBox = (tile: MercatorTile): MercatorBoundingBox => {\n const e = toLongitude(tile[0] + 1, tile[2])\n const w = toLongitude(tile[0], tile[2])\n const s = toLatitude(tile[1] + 1, tile[2])\n const n = toLatitude(tile[1], tile[2])\n return new MercatorBoundingBox(new MercatorLngLat(w, s), new MercatorLngLat(e, n))\n}\n\nexport { tileToBoundingBox }\n", "import type { MercatorTile } from '../../types.ts'\n\n/**\n * Returns the four child tiles at one zoom level higher.\n * @param tile - The parent tile as [x, y, zoom]\n * @returns An array of four child tiles at zoom + 1\n */\nconst tileToChildren = (tile: MercatorTile): MercatorTile[] => {\n return [\n [tile[0] * 2, tile[1] * 2, tile[2] + 1],\n [tile[0] * 2 + 1, tile[1] * 2, tile[2] + 1],\n [tile[0] * 2 + 1, tile[1] * 2 + 1, tile[2] + 1],\n [tile[0] * 2, tile[1] * 2 + 1, tile[2] + 1],\n ]\n}\n\nexport { tileToChildren }\n", "import type { Polygon } from '../../../GeoJsonModel.ts'\nimport type { MercatorTile } from '../../types.ts'\nimport { tileToBoundingBox } from './boundingbox.ts'\n\n/**\n * Converts a Mercator tile to a GeoJSON Polygon geometry.\n * @param tile - The tile as [x, y, zoom]\n * @returns A GeoJSON Polygon representing the tile's geographic extent\n */\nconst tileToGeoJson = (tile: MercatorTile): Polygon => {\n const box = tileToBoundingBox(tile)\n const poly: Polygon = {\n coordinates: [\n [\n box.getNorthWest().toArray(),\n box.getNorthEast().toArray(),\n box.getSouthEast().toArray(),\n box.getSouthWest().toArray(),\n box.getNorthWest().toArray(),\n ],\n ],\n type: 'Polygon',\n }\n return poly\n}\n\nexport { tileToGeoJson }\n", "import type { MercatorTile } from '../../types.ts'\n\n/**\n * Returns the parent tile at one zoom level lower.\n * @param tile - The tile as [x, y, zoom]\n * @returns The parent tile at zoom - 1\n */\nconst tileToParent = (tile: MercatorTile): MercatorTile => {\n return [tile[0] >> 1, tile[1] >> 1, tile[2] - 1]\n}\n\nexport { tileToParent }\n", "import type { MercatorLngLat, MercatorTile } from '../../types.ts'\nimport { tileToBoundingBox } from './boundingbox.ts'\n\n/**\n * Returns the center point of a Mercator tile.\n * @param tile - The tile as [x, y, zoom]\n * @returns The center coordinate as a MercatorLngLat\n */\nconst tileToPoint = (tile: MercatorTile): MercatorLngLat => {\n const boundingBox = tileToBoundingBox(tile)\n boundingBox.getCenter()\n return boundingBox.getCenter()\n}\n\nexport { tileToPoint }\n", "import type { MercatorTile } from '../../types.ts'\n\n/**\n * Converts a Mercator tile to its quadkey string representation.\n * @param param0 - The tile as [tileX, tileY, tileZoom]\n * @returns The quadkey string encoding the tile's position and zoom\n */\nconst tileToQuadkey = ([tileX, tileY, tileZoom]: MercatorTile): string => {\n let index = ''\n for (let z = tileZoom; z > 0; z--) {\n let b = 0\n const mask = 1 << (z - 1)\n if ((tileX & mask) !== 0) b++\n if ((tileY & mask) !== 0) b += 2\n index += b.toString()\n }\n return index\n}\n\nexport { tileToQuadkey }\n", "import type { MercatorTile } from '../../types.ts'\nimport { tileToChildren } from './children.ts'\nimport { tileToParent } from './parent.ts'\n\n/**\n * Returns the four sibling tiles (children of the parent tile) for the given tile.\n * @param tile - The tile as [x, y, zoom]\n * @returns An array of four sibling tiles at the same zoom level\n */\nconst tileToSiblings = (tile: MercatorTile): MercatorTile[] => {\n return tileToChildren(tileToParent(tile))\n}\n\nexport { tileToSiblings }\n", "import type { MercatorTile } from '../types.ts'\n\n/**\n * Checks whether two Mercator tiles are equal by comparing their x, y, and zoom values.\n * @param param0 - The first tile as [x, y, zoom]\n * @param param1 - The second tile as [x, y, zoom]\n * @returns True if both tiles have identical coordinates and zoom\n */\nexport const tilesEqual = /* @__PURE__ */ ([x1, y1, zoom1]: MercatorTile, [x2, y2, zoom2]: MercatorTile): boolean => {\n return x1 === x2 && y1 === y2 && zoom1 === zoom2\n}\n", "import { tileFromPoint } from '../../tile/index.ts'\nimport type { MercatorBoundingBox, MercatorTile } from '../../types.ts'\n\n/**\n * Returns all Mercator tiles that intersect the given bounding box at the specified zoom level.\n * @param box - The geographic bounding box\n * @param zoom - The zoom level\n * @returns An array of tiles covering the bounding box\n */\nconst tilesFromBoundingBox = (box: MercatorBoundingBox, zoom: number): MercatorTile[] => {\n const nw = tileFromPoint(box.getNorthWest(), zoom)\n const se = tileFromPoint(box.getSouthEast(), zoom)\n const size = Math.pow(2, zoom)\n\n let minX = nw[0]\n let maxX = se[0]\n let minY = nw[1]\n let maxY = se[1]\n\n // in case of horizontal wrapping\n if (minX >= maxX) {\n maxX = maxX + size\n }\n\n if (zoom < 4) {\n minX = 0\n maxX = size - 1\n minY = 0\n maxY = size - 1\n }\n\n const result: MercatorTile[] = []\n\n for (let x = minX; x <= maxX; x++) {\n for (let y = minY; y <= maxY; y++) {\n result.push([x % size, y, zoom])\n }\n }\n\n return result\n}\n\nexport { tilesFromBoundingBox }\n", "import type { MercatorTile } from '../types.ts'\nimport { tilesEqual } from './equal.ts'\n\n/**\n * Checks whether a specific tile exists in the given tile array.\n * @param tiles - The array of tiles to search\n * @param tile - The tile to look for\n * @returns True if the tile is found in the array\n */\nexport const tilesHasTile = (tiles: MercatorTile[], tile: MercatorTile) => {\n for (const tileToCheck of tiles) {\n if (tilesEqual(tileToCheck, tile)) return true\n }\n return false\n}\n", "import { tileToSiblings } from '../tile/index.ts'\nimport type { MercatorTile } from '../types.ts'\nimport { tilesHasTile } from './hasTile.ts'\n\n/**\n * Checks whether all four siblings of the given tile exist in the tile array.\n * @param tiles - The array of tiles to search\n * @param tile - The tile whose siblings to check for\n * @returns True if all siblings are present in the array\n */\nexport const hasSiblings = (tiles: MercatorTile[], tile: MercatorTile) => {\n const siblings = tileToSiblings(tile)\n for (const sibling of siblings) {\n if (!tilesHasTile(tiles, sibling)) return false\n }\n return true\n}\n", "import type {\n Feature, FeatureCollection, GeoJsonSourceSpecification, Geometry, Point, Polygon,\n} from './GeoJsonModel.ts'\nimport {\n boundingBoxToCenter, boundingBoxToPolygon, MercatorLngLat, tileFromQuadkey, tileToBoundingBox,\n} from './mercator/index.ts'\n\n/** Provides GeoJSON geometry and source generation from a quadkey. */\nclass GeoJson {\n private _lngLat?: MercatorLngLat\n private _point?: Point\n private _polygon?: Polygon\n private _zoom?: number\n\n private quadkey: string\n\n constructor(quadkey: string) {\n this.quadkey = quadkey\n }\n\n /**\n * Creates a GeoJSON FeatureCollection from an array of features.\n * @param features - The features to include\n * @returns A GeoJSON FeatureCollection\n */\n static featureCollection(features: Feature[]): FeatureCollection {\n return {\n features,\n type: 'FeatureCollection',\n }\n }\n\n /**\n * Creates a GeoJSON source specification from a FeatureCollection.\n * @param data - The FeatureCollection to use as the source data\n * @returns A GeoJSON source specification\n */\n static featuresSource(data: FeatureCollection): GeoJsonSourceSpecification {\n return {\n data,\n type: 'geojson',\n }\n }\n\n /**\n * Wraps a geometry object in a GeoJSON Feature.\n * @param geometry - The geometry to wrap\n * @returns A GeoJSON Feature containing the geometry\n */\n static geometryFeature(geometry: Geometry): Feature {\n return {\n geometry,\n properties: {},\n type: 'Feature',\n }\n }\n\n /** Computes and caches the center point of the quadkey's bounding box. */\n center(): MercatorLngLat {\n if (!this._lngLat) {\n const tile = tileFromQuadkey(this.quadkey)\n const bb = tileToBoundingBox(tile)\n const point = boundingBoxToCenter(bb)\n this._lngLat = new MercatorLngLat(point[0], point[1])\n }\n return this._lngLat\n }\n\n /** Returns a GeoJSON Point geometry at the center of the quadkey's bounding box. */\n point(): Point {\n this._point ??= {\n coordinates: this.center().toArray(),\n type: 'Point',\n }\n return this._point\n }\n\n /** Returns a GeoJSON Feature containing the center point geometry. */\n pointFeature(): Feature {\n return GeoJson.geometryFeature(this.point())\n }\n\n /** Returns a GeoJSON FeatureCollection containing the center point feature. */\n pointFeatureCollection(): FeatureCollection {\n return GeoJson.featureCollection([this.pointFeature()])\n }\n\n /** Returns a GeoJSON source specification for the center point. */\n pointSource(): GeoJsonSourceSpecification {\n return {\n data: this.pointFeatureCollection(),\n type: 'geojson',\n }\n }\n\n /** Returns a GeoJSON Polygon geometry representing the quadkey's bounding box. */\n polygon(): Polygon {\n this._polygon ??= boundingBoxToPolygon(tileToBoundingBox(tileFromQuadkey(this.quadkey)))\n return this._polygon\n }\n\n /** Returns a GeoJSON Feature containing the polygon geometry. */\n polygonFeature(): Feature {\n return GeoJson.geometryFeature(this.polygon())\n }\n\n /** Returns a GeoJSON FeatureCollection containing the polygon feature. */\n polygonFeatureCollection(): FeatureCollection {\n return GeoJson.featureCollection([this.polygonFeature()])\n }\n\n /** Returns a GeoJSON source specification for the polygon. */\n polygonSource(): GeoJsonSourceSpecification {\n return GeoJson.featuresSource(this.polygonFeatureCollection())\n }\n\n /** Returns the zoom level derived from the quadkey length. */\n zoom(): number {\n this._zoom = this._zoom ?? tileFromQuadkey(this.quadkey)[2]\n return this._zoom\n }\n}\n\nexport { GeoJson }\n", "interface MapLayer {\n id: string\n source?: string | Record<string, unknown>\n type?: string\n}\n\ninterface LayerMap<TLayer extends MapLayer = MapLayer> {\n addLayer(layer: TLayer): void\n getLayer(id: string): TLayer | undefined\n removeLayer(id: string): void\n}\n\n/** Abstract base class for managing map layers with add/remove lifecycle. */\nexport abstract class LayerBase<T extends MapLayer> {\n id: string\n source: string\n\n constructor(id: string, source: string) {\n this.id = id\n this.source = source\n }\n\n /**\n * Removes and re-adds the layer on the map, optionally hiding it.\n * @param map - The map instance\n * @param show - Whether to show the layer after updating (default true)\n */\n update(map: LayerMap<T>, show = true): void {\n if (map.getLayer(this.id)) {\n map.removeLayer(this.id)\n }\n if (show) {\n map.addLayer(this.buildLayer())\n }\n }\n\n /** Builds the layer configuration object. */\n abstract buildLayer(): T\n}\n\nexport type { LayerMap, MapLayer }\n"],
|
|
5
|
+
"mappings": ";AAOO,IAAM,wBAAwB,CAAC,QAA+C;AACnF,SAAO,CAAC,IAAI,aAAa,GAAG,IAAI,aAAa,GAAG,IAAI,aAAa,GAAG,IAAI,aAAa,GAAG,IAAI,aAAa,CAAC;AAC5G;;;ACDO,IAAM,sBAAsB,CAAC,aAAkC,UAAU,MAAM;AACpF,QAAM,OAAO,YAAY,QAAQ;AACjC,QAAM,QAAQ,YAAY,SAAS;AACnC,QAAM,OAAO,YAAY,QAAQ;AACjC,QAAM,QAAQ,YAAY,SAAS;AACnC,MAAI,OAAO,OAAO,QAAQ,IAAI;AAC9B,MAAI,OAAO,QAAQ,SAAS,IAAI;AAChC,MAAI,YAAY,UAAa,YAAY,MAAM;AAC7C,UAAM,OAAO,IAAI,QAAQ,OAAO,CAAC;AACjC,UAAM,OAAO,IAAI,QAAQ,OAAO,CAAC;AAAA,EACnC;AACA,SAAO,CAAC,KAAK,GAAG;AAClB;;;ACXO,IAAM,uBAAuB,CAAC,QAAsC;AACzE,QAAM,UAAU,sBAAsB,GAAG;AACzC,SAAO;AAAA,IACL,aAAa,CAAC,QAAQ,IAAI,CAAC,WAA2B,O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AC1D,WAAO,KAAK;AAAA,EACd;AACF;;;AC5GO,IAAe,YAAf,MAA6C;AAAA,EAClD;AAAA,EACA;AAAA,EAEA,YAAY,IAAY,QAAgB;AACtC,SAAK,KAAK;AACV,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,KAAkB,OAAO,MAAY;AAC1C,QAAI,IAAI,SAAS,KAAK,EAAE,GAAG;AACzB,UAAI,YAAY,KAAK,EAAE;AAAA,IACzB;AACA,QAAI,MAAM;AACR,UAAI,SAAS,KAAK,WAAW,CAAC;AAAA,IAChC;AAAA,EACF;AAIF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundingbox.d.ts","sourceRoot":"","sources":["../../../../../src/mercator/tile/to/boundingbox.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"boundingbox.d.ts","sourceRoot":"","sources":["../../../../../src/mercator/tile/to/boundingbox.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAkB,MAAM,gBAAgB,CAAA;AAWpE;;;;GAIG;AACH,QAAA,MAAM,iBAAiB,GAAI,MAAM,YAAY,KAAG,mBAM/C,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
import MapBox from 'mapbox-gl';
|
|
2
1
|
/** A Mercator tile represented as [x, y, zoom]. */
|
|
3
2
|
type MercatorTile = readonly [x: number, y: number, zoom: number];
|
|
4
3
|
/** An ordered array of MercatorLngLat points forming a boundary. */
|
|
5
4
|
type MercatorBoundary = MercatorLngLat[];
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type MercatorLngLatLike = MercatorLngLat | readonly [lng: number, lat: number] | {
|
|
6
|
+
lat: number;
|
|
7
|
+
lng: number;
|
|
8
|
+
};
|
|
9
|
+
/** A Mercator coordinate. */
|
|
10
|
+
declare class MercatorLngLat {
|
|
11
|
+
lat: number;
|
|
12
|
+
lng: number;
|
|
13
|
+
constructor(lng: number, lat: number);
|
|
14
|
+
toArray(): [lng: number, lat: number];
|
|
8
15
|
}
|
|
9
|
-
/** A Mercator
|
|
10
|
-
declare class
|
|
16
|
+
/** A Mercator bounding box. */
|
|
17
|
+
declare class MercatorBoundingBox {
|
|
18
|
+
private readonly ne;
|
|
19
|
+
private readonly sw;
|
|
20
|
+
constructor(sw?: MercatorLngLatLike, ne?: MercatorLngLatLike);
|
|
21
|
+
getCenter(): MercatorLngLat;
|
|
22
|
+
getEast(): number;
|
|
23
|
+
getNorth(): number;
|
|
24
|
+
getNorthEast(): MercatorLngLat;
|
|
25
|
+
getNorthWest(): MercatorLngLat;
|
|
26
|
+
getSouth(): number;
|
|
27
|
+
getSouthEast(): MercatorLngLat;
|
|
28
|
+
getSouthWest(): MercatorLngLat;
|
|
29
|
+
getWest(): number;
|
|
11
30
|
}
|
|
12
31
|
export { MercatorBoundingBox, MercatorLngLat };
|
|
13
|
-
export type { MercatorBoundary, MercatorTile };
|
|
32
|
+
export type { MercatorBoundary, MercatorLngLatLike, MercatorTile, };
|
|
14
33
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/mercator/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/mercator/types.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,KAAK,YAAY,GAAG,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;AACjE,oEAAoE;AACpE,KAAK,gBAAgB,GAAG,cAAc,EAAE,CAAA;AAExC,KAAK,kBAAkB,GAAG,cAAc,GAAG,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAS7G,6BAA6B;AAC7B,cAAM,cAAc;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;gBAEC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAKpC,OAAO,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC;CAGtC;AAED,+BAA+B;AAC/B,cAAM,mBAAmB;IACvB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAgB;IACnC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAgB;gBAEvB,EAAE,CAAC,EAAE,kBAAkB,EAAE,EAAE,CAAC,EAAE,kBAAkB;IAK5D,SAAS,IAAI,cAAc;IAO3B,OAAO,IAAI,MAAM;IAIjB,QAAQ,IAAI,MAAM;IAIlB,YAAY,IAAI,cAAc;IAI9B,YAAY,IAAI,cAAc;IAI9B,QAAQ,IAAI,MAAM;IAIlB,YAAY,IAAI,cAAc;IAI9B,YAAY,IAAI,cAAc;IAI9B,OAAO,IAAI,MAAM;CAGlB;AAED,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAA;AAC9C,YAAY,EACV,gBAAgB,EAAE,kBAAkB,EAAE,YAAY,GACnD,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/geo",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.5",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xylabs",
|
|
@@ -40,16 +40,12 @@
|
|
|
40
40
|
"README.md"
|
|
41
41
|
],
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@xylabs/toolchain": "^8.1.
|
|
44
|
-
"@xylabs/tsconfig": "^8.1.
|
|
45
|
-
"eslint": "^10.4.
|
|
46
|
-
"mapbox-gl": "^3.24.0",
|
|
43
|
+
"@xylabs/toolchain": "^8.1.8",
|
|
44
|
+
"@xylabs/tsconfig": "^8.1.8",
|
|
45
|
+
"eslint": "^10.4.1",
|
|
47
46
|
"typescript": "^6.0.3",
|
|
48
|
-
"vite": "^8.0.
|
|
49
|
-
"vitest": "^4.1.
|
|
50
|
-
},
|
|
51
|
-
"peerDependencies": {
|
|
52
|
-
"mapbox-gl": "^3.23"
|
|
47
|
+
"vite": "^8.0.16",
|
|
48
|
+
"vitest": "^4.1.8"
|
|
53
49
|
},
|
|
54
50
|
"engines": {
|
|
55
51
|
"node": ">=18"
|