@xylabs/geo 5.0.94 → 5.0.96
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
CHANGED
|
@@ -1,75 +1,52 @@
|
|
|
1
1
|
# @xylabs/geo
|
|
2
2
|
|
|
3
|
-
[![
|
|
3
|
+
[![npm][npm-badge]][npm-link]
|
|
4
|
+
[![license][license-badge]][license-link]
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
[![npm-badge][]][npm-link]
|
|
7
|
-
[![npm-downloads-badge][]][npm-link]
|
|
8
|
-
[![jsdelivr-badge][]][jsdelivr-link]
|
|
9
|
-
[![npm-license-badge][]](LICENSE)
|
|
10
|
-
[![codacy-badge][]][codacy-link]
|
|
11
|
-
[![codeclimate-badge][]][codeclimate-link]
|
|
12
|
-
[![snyk-badge][]][snyk-link]
|
|
13
|
-
[![socket-badge][]][socket-link]
|
|
6
|
+
> Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
14
7
|
|
|
8
|
+
## Install
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
Using npm:
|
|
17
11
|
|
|
12
|
+
```sh
|
|
13
|
+
npm install {{name}}
|
|
14
|
+
```
|
|
18
15
|
|
|
16
|
+
Using yarn:
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
```sh
|
|
19
|
+
yarn add {{name}}
|
|
20
|
+
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Using pnpm:
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
```sh
|
|
25
|
+
pnpm add {{name}}
|
|
26
|
+
```
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
Using bun:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
bun add {{name}}
|
|
32
|
+
```
|
|
27
33
|
|
|
28
|
-
| Class | Description |
|
|
29
|
-
| ------ | ------ |
|
|
30
|
-
| [GeoJson](#classes/GeoJson) | Provides GeoJSON geometry and MapBox source generation from a quadkey. |
|
|
31
|
-
| [LayerBase](#classes/LayerBase) | Abstract base class for managing MapBox map layers with add/remove lifecycle. |
|
|
32
|
-
| [MercatorBoundingBox](#classes/MercatorBoundingBox) | A Mercator bounding box extending MapBox LngLatBounds. |
|
|
33
|
-
| [MercatorLngLat](#classes/MercatorLngLat) | A Mercator coordinate extending MapBox LngLat. |
|
|
34
34
|
|
|
35
|
-
##
|
|
35
|
+
## License
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
| ------ | ------ |
|
|
39
|
-
| [MercatorTile](#type-aliases/MercatorTile) | A Mercator tile represented as [x, y, zoom]. |
|
|
40
|
-
| [MercatorBoundary](#type-aliases/MercatorBoundary) | An ordered array of MercatorLngLat points forming a boundary. |
|
|
37
|
+
See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
|
|
41
38
|
|
|
42
|
-
##
|
|
39
|
+
## Reference
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
| ------ | ------ |
|
|
46
|
-
| [d2r](#variables/d2r) | Conversion factor from degrees to radians. |
|
|
47
|
-
| [r2d](#variables/r2d) | Conversion factor from radians to degrees. |
|
|
41
|
+
### packages
|
|
48
42
|
|
|
49
|
-
|
|
43
|
+
### geo
|
|
50
44
|
|
|
51
|
-
|
|
52
|
-
| ------ | ------ |
|
|
53
|
-
| [boundingBoxToBoundary](#functions/boundingBoxToBoundary) | Converts a bounding box to an ordered boundary polygon (closed ring of corner points). |
|
|
54
|
-
| [boundingBoxToCenter](#functions/boundingBoxToCenter) | Computes the center point of a bounding box as [lng, lat], rounded to the specified decimal places. |
|
|
55
|
-
| [boundingBoxToPolygon](#functions/boundingBoxToPolygon) | Converts a bounding box to a GeoJSON Polygon geometry. |
|
|
56
|
-
| [tileFromPoint](#functions/tileFromPoint) | Converts a geographic point to the integer Mercator tile containing it at the given zoom level. |
|
|
57
|
-
| [tileFromQuadkey](#functions/tileFromQuadkey) | Converts a quadkey string to a Mercator tile [x, y, zoom]. |
|
|
58
|
-
| [tileToBoundingBox](#functions/tileToBoundingBox) | Converts a Mercator tile to its geographic bounding box. |
|
|
59
|
-
| [tileToChildren](#functions/tileToChildren) | Returns the four child tiles at one zoom level higher. |
|
|
60
|
-
| [tileToGeoJson](#functions/tileToGeoJson) | Converts a Mercator tile to a GeoJSON Polygon geometry. |
|
|
61
|
-
| [tileToParent](#functions/tileToParent) | Returns the parent tile at one zoom level lower. |
|
|
62
|
-
| [tileToPoint](#functions/tileToPoint) | Returns the center point of a Mercator tile. |
|
|
63
|
-
| [tileToQuadkey](#functions/tileToQuadkey) | Converts a Mercator tile to its quadkey string representation. |
|
|
64
|
-
| [tileToSiblings](#functions/tileToSiblings) | Returns the four sibling tiles (children of the parent tile) for the given tile. |
|
|
65
|
-
| [tilesEqual](#functions/tilesEqual) | Checks whether two Mercator tiles are equal by comparing their x, y, and zoom values. |
|
|
66
|
-
| [tilesFromBoundingBox](#functions/tilesFromBoundingBox) | Returns all Mercator tiles that intersect the given bounding box at the specified zoom level. |
|
|
67
|
-
| [hasSiblings](#functions/hasSiblings) | Checks whether all four siblings of the given tile exist in the tile array. |
|
|
68
|
-
| [tilesHasTile](#functions/tilesHasTile) | Checks whether a specific tile exists in the given tile array. |
|
|
45
|
+
### .temp-typedoc
|
|
69
46
|
|
|
70
|
-
### classes
|
|
47
|
+
### classes
|
|
71
48
|
|
|
72
|
-
|
|
49
|
+
### <a id="GeoJson"></a>GeoJson
|
|
73
50
|
|
|
74
51
|
[**@xylabs/geo**](#../README)
|
|
75
52
|
|
|
@@ -82,14 +59,14 @@ Provides GeoJSON geometry and MapBox source generation from a quadkey.
|
|
|
82
59
|
### Constructor
|
|
83
60
|
|
|
84
61
|
```ts
|
|
85
|
-
new GeoJson(quadkey
|
|
62
|
+
new GeoJson(quadkey): GeoJson;
|
|
86
63
|
```
|
|
87
64
|
|
|
88
65
|
### Parameters
|
|
89
66
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
67
|
+
#### quadkey
|
|
68
|
+
|
|
69
|
+
`string`
|
|
93
70
|
|
|
94
71
|
### Returns
|
|
95
72
|
|
|
@@ -100,16 +77,18 @@ new GeoJson(quadkey: string): GeoJson;
|
|
|
100
77
|
### featureCollection()
|
|
101
78
|
|
|
102
79
|
```ts
|
|
103
|
-
static featureCollection(features
|
|
80
|
+
static featureCollection(features): FeatureCollection;
|
|
104
81
|
```
|
|
105
82
|
|
|
106
83
|
Creates a GeoJSON FeatureCollection from an array of features.
|
|
107
84
|
|
|
108
85
|
### Parameters
|
|
109
86
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
87
|
+
#### features
|
|
88
|
+
|
|
89
|
+
`Feature`\<`Geometry`, `GeoJsonProperties`\>[]
|
|
90
|
+
|
|
91
|
+
The features to include
|
|
113
92
|
|
|
114
93
|
### Returns
|
|
115
94
|
|
|
@@ -122,16 +101,18 @@ A GeoJSON FeatureCollection
|
|
|
122
101
|
### featuresSource()
|
|
123
102
|
|
|
124
103
|
```ts
|
|
125
|
-
static featuresSource(data
|
|
104
|
+
static featuresSource(data): GeoJSONSourceSpecification;
|
|
126
105
|
```
|
|
127
106
|
|
|
128
107
|
Creates a MapBox GeoJSON source specification from a FeatureCollection.
|
|
129
108
|
|
|
130
109
|
### Parameters
|
|
131
110
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
111
|
+
#### data
|
|
112
|
+
|
|
113
|
+
`FeatureCollection`
|
|
114
|
+
|
|
115
|
+
The FeatureCollection to use as the source data
|
|
135
116
|
|
|
136
117
|
### Returns
|
|
137
118
|
|
|
@@ -144,16 +125,18 @@ A MapBox GeoJSON source specification
|
|
|
144
125
|
### geometryFeature()
|
|
145
126
|
|
|
146
127
|
```ts
|
|
147
|
-
static geometryFeature(geometry
|
|
128
|
+
static geometryFeature(geometry): Feature;
|
|
148
129
|
```
|
|
149
130
|
|
|
150
131
|
Wraps a geometry object in a GeoJSON Feature.
|
|
151
132
|
|
|
152
133
|
### Parameters
|
|
153
134
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
135
|
+
#### geometry
|
|
136
|
+
|
|
137
|
+
`Geometry`
|
|
138
|
+
|
|
139
|
+
The geometry to wrap
|
|
157
140
|
|
|
158
141
|
### Returns
|
|
159
142
|
|
|
@@ -301,7 +284,7 @@ Returns the zoom level derived from the quadkey length.
|
|
|
301
284
|
|
|
302
285
|
`number`
|
|
303
286
|
|
|
304
|
-
|
|
287
|
+
### <a id="LayerBase"></a>LayerBase
|
|
305
288
|
|
|
306
289
|
[**@xylabs/geo**](#../README)
|
|
307
290
|
|
|
@@ -311,24 +294,27 @@ Abstract base class for managing MapBox map layers with add/remove lifecycle.
|
|
|
311
294
|
|
|
312
295
|
## Type Parameters
|
|
313
296
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
297
|
+
### T
|
|
298
|
+
|
|
299
|
+
`T` *extends* `MapBox.Layer`
|
|
317
300
|
|
|
318
301
|
## Constructors
|
|
319
302
|
|
|
320
303
|
### Constructor
|
|
321
304
|
|
|
322
305
|
```ts
|
|
323
|
-
new LayerBase<T>(id
|
|
306
|
+
new LayerBase<T>(id, source): LayerBase<T>;
|
|
324
307
|
```
|
|
325
308
|
|
|
326
309
|
### Parameters
|
|
327
310
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
311
|
+
#### id
|
|
312
|
+
|
|
313
|
+
`string`
|
|
314
|
+
|
|
315
|
+
#### source
|
|
316
|
+
|
|
317
|
+
`string`
|
|
332
318
|
|
|
333
319
|
### Returns
|
|
334
320
|
|
|
@@ -336,27 +322,43 @@ new LayerBase<T>(id: string, source: string): LayerBase<T>;
|
|
|
336
322
|
|
|
337
323
|
## Properties
|
|
338
324
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
325
|
+
### id
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
id: string;
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
***
|
|
332
|
+
|
|
333
|
+
### source
|
|
334
|
+
|
|
335
|
+
```ts
|
|
336
|
+
source: string;
|
|
337
|
+
```
|
|
343
338
|
|
|
344
339
|
## Methods
|
|
345
340
|
|
|
346
341
|
### update()
|
|
347
342
|
|
|
348
343
|
```ts
|
|
349
|
-
update(map
|
|
344
|
+
update(map, show?): void;
|
|
350
345
|
```
|
|
351
346
|
|
|
352
347
|
Removes and re-adds the layer on the map, optionally hiding it.
|
|
353
348
|
|
|
354
349
|
### Parameters
|
|
355
350
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
351
|
+
#### map
|
|
352
|
+
|
|
353
|
+
`Map$1`
|
|
354
|
+
|
|
355
|
+
The MapBox map instance
|
|
356
|
+
|
|
357
|
+
#### show?
|
|
358
|
+
|
|
359
|
+
`boolean` = `true`
|
|
360
|
+
|
|
361
|
+
Whether to show the layer after updating (default true)
|
|
360
362
|
|
|
361
363
|
### Returns
|
|
362
364
|
|
|
@@ -376,7 +378,7 @@ Builds the MapBox layer configuration object.
|
|
|
376
378
|
|
|
377
379
|
`T`
|
|
378
380
|
|
|
379
|
-
|
|
381
|
+
### <a id="MercatorBoundingBox"></a>MercatorBoundingBox
|
|
380
382
|
|
|
381
383
|
[**@xylabs/geo**](#../README)
|
|
382
384
|
|
|
@@ -393,18 +395,20 @@ A Mercator bounding box extending MapBox LngLatBounds.
|
|
|
393
395
|
### Constructor
|
|
394
396
|
|
|
395
397
|
```ts
|
|
396
|
-
new MercatorBoundingBox(sw
|
|
397
|
-
| [number, number, number, number]
|
|
398
|
-
| LngLatLike
|
|
399
|
-
| [LngLatLike, LngLatLike], ne?: LngLatLike): MercatorBoundingBox;
|
|
398
|
+
new MercatorBoundingBox(sw?, ne?): MercatorBoundingBox;
|
|
400
399
|
```
|
|
401
400
|
|
|
402
401
|
### Parameters
|
|
403
402
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
403
|
+
#### sw?
|
|
404
|
+
|
|
405
|
+
\| \[`number`, `number`, `number`, `number`\]
|
|
406
|
+
\| `LngLatLike`
|
|
407
|
+
\| \[`LngLatLike`, `LngLatLike`\]
|
|
408
|
+
|
|
409
|
+
#### ne?
|
|
410
|
+
|
|
411
|
+
`LngLatLike`
|
|
408
412
|
|
|
409
413
|
### Returns
|
|
410
414
|
|
|
@@ -416,7 +420,7 @@ new MercatorBoundingBox(sw?:
|
|
|
416
420
|
MapBox.LngLatBounds.constructor
|
|
417
421
|
```
|
|
418
422
|
|
|
419
|
-
|
|
423
|
+
### <a id="MercatorLngLat"></a>MercatorLngLat
|
|
420
424
|
|
|
421
425
|
[**@xylabs/geo**](#../README)
|
|
422
426
|
|
|
@@ -433,15 +437,18 @@ A Mercator coordinate extending MapBox LngLat.
|
|
|
433
437
|
### Constructor
|
|
434
438
|
|
|
435
439
|
```ts
|
|
436
|
-
new MercatorLngLat(lng
|
|
440
|
+
new MercatorLngLat(lng, lat): MercatorLngLat;
|
|
437
441
|
```
|
|
438
442
|
|
|
439
443
|
### Parameters
|
|
440
444
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
+
#### lng
|
|
446
|
+
|
|
447
|
+
`number`
|
|
448
|
+
|
|
449
|
+
#### lat
|
|
450
|
+
|
|
451
|
+
`number`
|
|
445
452
|
|
|
446
453
|
### Returns
|
|
447
454
|
|
|
@@ -453,25 +460,27 @@ new MercatorLngLat(lng: number, lat: number): MercatorLngLat;
|
|
|
453
460
|
MapBox.LngLat.constructor
|
|
454
461
|
```
|
|
455
462
|
|
|
456
|
-
### functions
|
|
463
|
+
### functions
|
|
457
464
|
|
|
458
|
-
|
|
465
|
+
### <a id="boundingBoxToBoundary"></a>boundingBoxToBoundary
|
|
459
466
|
|
|
460
467
|
[**@xylabs/geo**](#../README)
|
|
461
468
|
|
|
462
469
|
***
|
|
463
470
|
|
|
464
471
|
```ts
|
|
465
|
-
function boundingBoxToBoundary(box
|
|
472
|
+
function boundingBoxToBoundary(box): MercatorBoundary;
|
|
466
473
|
```
|
|
467
474
|
|
|
468
475
|
Converts a bounding box to an ordered boundary polygon (closed ring of corner points).
|
|
469
476
|
|
|
470
477
|
## Parameters
|
|
471
478
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
479
|
+
### box
|
|
480
|
+
|
|
481
|
+
[`MercatorBoundingBox`](#../classes/MercatorBoundingBox)
|
|
482
|
+
|
|
483
|
+
The bounding box to convert
|
|
475
484
|
|
|
476
485
|
## Returns
|
|
477
486
|
|
|
@@ -479,24 +488,31 @@ Converts a bounding box to an ordered boundary polygon (closed ring of corner po
|
|
|
479
488
|
|
|
480
489
|
An array of corner points forming a closed boundary
|
|
481
490
|
|
|
482
|
-
|
|
491
|
+
### <a id="boundingBoxToCenter"></a>boundingBoxToCenter
|
|
483
492
|
|
|
484
493
|
[**@xylabs/geo**](#../README)
|
|
485
494
|
|
|
486
495
|
***
|
|
487
496
|
|
|
488
497
|
```ts
|
|
489
|
-
function boundingBoxToCenter(boundingBox
|
|
498
|
+
function boundingBoxToCenter(boundingBox, decimal?): number[];
|
|
490
499
|
```
|
|
491
500
|
|
|
492
501
|
Computes the center point of a bounding box as [lng, lat], rounded to the specified decimal places.
|
|
493
502
|
|
|
494
503
|
## Parameters
|
|
495
504
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
505
|
+
### boundingBox
|
|
506
|
+
|
|
507
|
+
[`MercatorBoundingBox`](#../classes/MercatorBoundingBox)
|
|
508
|
+
|
|
509
|
+
The bounding box to find the center of
|
|
510
|
+
|
|
511
|
+
### decimal?
|
|
512
|
+
|
|
513
|
+
`number` = `6`
|
|
514
|
+
|
|
515
|
+
Number of decimal places for rounding (default 6)
|
|
500
516
|
|
|
501
517
|
## Returns
|
|
502
518
|
|
|
@@ -504,23 +520,25 @@ Computes the center point of a bounding box as [lng, lat], rounded to the specif
|
|
|
504
520
|
|
|
505
521
|
A [longitude, latitude] tuple representing the center
|
|
506
522
|
|
|
507
|
-
|
|
523
|
+
### <a id="boundingBoxToPolygon"></a>boundingBoxToPolygon
|
|
508
524
|
|
|
509
525
|
[**@xylabs/geo**](#../README)
|
|
510
526
|
|
|
511
527
|
***
|
|
512
528
|
|
|
513
529
|
```ts
|
|
514
|
-
function boundingBoxToPolygon(box
|
|
530
|
+
function boundingBoxToPolygon(box): Polygon;
|
|
515
531
|
```
|
|
516
532
|
|
|
517
533
|
Converts a bounding box to a GeoJSON Polygon geometry.
|
|
518
534
|
|
|
519
535
|
## Parameters
|
|
520
536
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
537
|
+
### box
|
|
538
|
+
|
|
539
|
+
[`MercatorBoundingBox`](#../classes/MercatorBoundingBox)
|
|
540
|
+
|
|
541
|
+
The bounding box to convert
|
|
524
542
|
|
|
525
543
|
## Returns
|
|
526
544
|
|
|
@@ -528,24 +546,31 @@ Converts a bounding box to a GeoJSON Polygon geometry.
|
|
|
528
546
|
|
|
529
547
|
A GeoJSON Polygon representing the bounding box
|
|
530
548
|
|
|
531
|
-
|
|
549
|
+
### <a id="hasSiblings"></a>hasSiblings
|
|
532
550
|
|
|
533
551
|
[**@xylabs/geo**](#../README)
|
|
534
552
|
|
|
535
553
|
***
|
|
536
554
|
|
|
537
555
|
```ts
|
|
538
|
-
function hasSiblings(tiles
|
|
556
|
+
function hasSiblings(tiles, tile): boolean;
|
|
539
557
|
```
|
|
540
558
|
|
|
541
559
|
Checks whether all four siblings of the given tile exist in the tile array.
|
|
542
560
|
|
|
543
561
|
## Parameters
|
|
544
562
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
563
|
+
### tiles
|
|
564
|
+
|
|
565
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)[]
|
|
566
|
+
|
|
567
|
+
The array of tiles to search
|
|
568
|
+
|
|
569
|
+
### tile
|
|
570
|
+
|
|
571
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
572
|
+
|
|
573
|
+
The tile whose siblings to check for
|
|
549
574
|
|
|
550
575
|
## Returns
|
|
551
576
|
|
|
@@ -553,24 +578,31 @@ Checks whether all four siblings of the given tile exist in the tile array.
|
|
|
553
578
|
|
|
554
579
|
True if all siblings are present in the array
|
|
555
580
|
|
|
556
|
-
|
|
581
|
+
### <a id="tileFromPoint"></a>tileFromPoint
|
|
557
582
|
|
|
558
583
|
[**@xylabs/geo**](#../README)
|
|
559
584
|
|
|
560
585
|
***
|
|
561
586
|
|
|
562
587
|
```ts
|
|
563
|
-
function tileFromPoint(point
|
|
588
|
+
function tileFromPoint(point, z): MercatorTile;
|
|
564
589
|
```
|
|
565
590
|
|
|
566
591
|
Converts a geographic point to the integer Mercator tile containing it at the given zoom level.
|
|
567
592
|
|
|
568
593
|
## Parameters
|
|
569
594
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
595
|
+
### point
|
|
596
|
+
|
|
597
|
+
[`MercatorLngLat`](#../classes/MercatorLngLat)
|
|
598
|
+
|
|
599
|
+
The geographic coordinate
|
|
600
|
+
|
|
601
|
+
### z
|
|
602
|
+
|
|
603
|
+
`number`
|
|
604
|
+
|
|
605
|
+
The zoom level
|
|
574
606
|
|
|
575
607
|
## Returns
|
|
576
608
|
|
|
@@ -578,23 +610,25 @@ Converts a geographic point to the integer Mercator tile containing it at the gi
|
|
|
578
610
|
|
|
579
611
|
The tile as [x, y, zoom]
|
|
580
612
|
|
|
581
|
-
|
|
613
|
+
### <a id="tileFromQuadkey"></a>tileFromQuadkey
|
|
582
614
|
|
|
583
615
|
[**@xylabs/geo**](#../README)
|
|
584
616
|
|
|
585
617
|
***
|
|
586
618
|
|
|
587
619
|
```ts
|
|
588
|
-
function tileFromQuadkey(quadkey
|
|
620
|
+
function tileFromQuadkey(quadkey): MercatorTile;
|
|
589
621
|
```
|
|
590
622
|
|
|
591
623
|
Converts a quadkey string to a Mercator tile [x, y, zoom].
|
|
592
624
|
|
|
593
625
|
## Parameters
|
|
594
626
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
627
|
+
### quadkey
|
|
628
|
+
|
|
629
|
+
`string`
|
|
630
|
+
|
|
631
|
+
The quadkey string to decode
|
|
598
632
|
|
|
599
633
|
## Returns
|
|
600
634
|
|
|
@@ -602,23 +636,25 @@ Converts a quadkey string to a Mercator tile [x, y, zoom].
|
|
|
602
636
|
|
|
603
637
|
The tile as [x, y, zoom]
|
|
604
638
|
|
|
605
|
-
|
|
639
|
+
### <a id="tileToBoundingBox"></a>tileToBoundingBox
|
|
606
640
|
|
|
607
641
|
[**@xylabs/geo**](#../README)
|
|
608
642
|
|
|
609
643
|
***
|
|
610
644
|
|
|
611
645
|
```ts
|
|
612
|
-
function tileToBoundingBox(tile
|
|
646
|
+
function tileToBoundingBox(tile): MercatorBoundingBox;
|
|
613
647
|
```
|
|
614
648
|
|
|
615
649
|
Converts a Mercator tile to its geographic bounding box.
|
|
616
650
|
|
|
617
651
|
## Parameters
|
|
618
652
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
653
|
+
### tile
|
|
654
|
+
|
|
655
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
656
|
+
|
|
657
|
+
The tile as [x, y, zoom]
|
|
622
658
|
|
|
623
659
|
## Returns
|
|
624
660
|
|
|
@@ -626,23 +662,25 @@ Converts a Mercator tile to its geographic bounding box.
|
|
|
626
662
|
|
|
627
663
|
The bounding box covering the tile's geographic extent
|
|
628
664
|
|
|
629
|
-
|
|
665
|
+
### <a id="tileToChildren"></a>tileToChildren
|
|
630
666
|
|
|
631
667
|
[**@xylabs/geo**](#../README)
|
|
632
668
|
|
|
633
669
|
***
|
|
634
670
|
|
|
635
671
|
```ts
|
|
636
|
-
function tileToChildren(tile
|
|
672
|
+
function tileToChildren(tile): MercatorTile[];
|
|
637
673
|
```
|
|
638
674
|
|
|
639
675
|
Returns the four child tiles at one zoom level higher.
|
|
640
676
|
|
|
641
677
|
## Parameters
|
|
642
678
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
679
|
+
### tile
|
|
680
|
+
|
|
681
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
682
|
+
|
|
683
|
+
The parent tile as [x, y, zoom]
|
|
646
684
|
|
|
647
685
|
## Returns
|
|
648
686
|
|
|
@@ -650,23 +688,25 @@ Returns the four child tiles at one zoom level higher.
|
|
|
650
688
|
|
|
651
689
|
An array of four child tiles at zoom + 1
|
|
652
690
|
|
|
653
|
-
|
|
691
|
+
### <a id="tileToGeoJson"></a>tileToGeoJson
|
|
654
692
|
|
|
655
693
|
[**@xylabs/geo**](#../README)
|
|
656
694
|
|
|
657
695
|
***
|
|
658
696
|
|
|
659
697
|
```ts
|
|
660
|
-
function tileToGeoJson(tile
|
|
698
|
+
function tileToGeoJson(tile): Polygon;
|
|
661
699
|
```
|
|
662
700
|
|
|
663
701
|
Converts a Mercator tile to a GeoJSON Polygon geometry.
|
|
664
702
|
|
|
665
703
|
## Parameters
|
|
666
704
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
705
|
+
### tile
|
|
706
|
+
|
|
707
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
708
|
+
|
|
709
|
+
The tile as [x, y, zoom]
|
|
670
710
|
|
|
671
711
|
## Returns
|
|
672
712
|
|
|
@@ -674,23 +714,25 @@ Converts a Mercator tile to a GeoJSON Polygon geometry.
|
|
|
674
714
|
|
|
675
715
|
A GeoJSON Polygon representing the tile's geographic extent
|
|
676
716
|
|
|
677
|
-
|
|
717
|
+
### <a id="tileToParent"></a>tileToParent
|
|
678
718
|
|
|
679
719
|
[**@xylabs/geo**](#../README)
|
|
680
720
|
|
|
681
721
|
***
|
|
682
722
|
|
|
683
723
|
```ts
|
|
684
|
-
function tileToParent(tile
|
|
724
|
+
function tileToParent(tile): MercatorTile;
|
|
685
725
|
```
|
|
686
726
|
|
|
687
727
|
Returns the parent tile at one zoom level lower.
|
|
688
728
|
|
|
689
729
|
## Parameters
|
|
690
730
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
731
|
+
### tile
|
|
732
|
+
|
|
733
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
734
|
+
|
|
735
|
+
The tile as [x, y, zoom]
|
|
694
736
|
|
|
695
737
|
## Returns
|
|
696
738
|
|
|
@@ -698,23 +740,25 @@ Returns the parent tile at one zoom level lower.
|
|
|
698
740
|
|
|
699
741
|
The parent tile at zoom - 1
|
|
700
742
|
|
|
701
|
-
|
|
743
|
+
### <a id="tileToPoint"></a>tileToPoint
|
|
702
744
|
|
|
703
745
|
[**@xylabs/geo**](#../README)
|
|
704
746
|
|
|
705
747
|
***
|
|
706
748
|
|
|
707
749
|
```ts
|
|
708
|
-
function tileToPoint(tile
|
|
750
|
+
function tileToPoint(tile): MercatorLngLat;
|
|
709
751
|
```
|
|
710
752
|
|
|
711
753
|
Returns the center point of a Mercator tile.
|
|
712
754
|
|
|
713
755
|
## Parameters
|
|
714
756
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
757
|
+
### tile
|
|
758
|
+
|
|
759
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
760
|
+
|
|
761
|
+
The tile as [x, y, zoom]
|
|
718
762
|
|
|
719
763
|
## Returns
|
|
720
764
|
|
|
@@ -722,23 +766,25 @@ Returns the center point of a Mercator tile.
|
|
|
722
766
|
|
|
723
767
|
The center coordinate as a MercatorLngLat
|
|
724
768
|
|
|
725
|
-
|
|
769
|
+
### <a id="tileToQuadkey"></a>tileToQuadkey
|
|
726
770
|
|
|
727
771
|
[**@xylabs/geo**](#../README)
|
|
728
772
|
|
|
729
773
|
***
|
|
730
774
|
|
|
731
775
|
```ts
|
|
732
|
-
function tileToQuadkey(param0
|
|
776
|
+
function tileToQuadkey(param0): string;
|
|
733
777
|
```
|
|
734
778
|
|
|
735
779
|
Converts a Mercator tile to its quadkey string representation.
|
|
736
780
|
|
|
737
781
|
## Parameters
|
|
738
782
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
783
|
+
### param0
|
|
784
|
+
|
|
785
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
786
|
+
|
|
787
|
+
The tile as [tileX, tileY, tileZoom]
|
|
742
788
|
|
|
743
789
|
## Returns
|
|
744
790
|
|
|
@@ -746,23 +792,25 @@ Converts a Mercator tile to its quadkey string representation.
|
|
|
746
792
|
|
|
747
793
|
The quadkey string encoding the tile's position and zoom
|
|
748
794
|
|
|
749
|
-
|
|
795
|
+
### <a id="tileToSiblings"></a>tileToSiblings
|
|
750
796
|
|
|
751
797
|
[**@xylabs/geo**](#../README)
|
|
752
798
|
|
|
753
799
|
***
|
|
754
800
|
|
|
755
801
|
```ts
|
|
756
|
-
function tileToSiblings(tile
|
|
802
|
+
function tileToSiblings(tile): MercatorTile[];
|
|
757
803
|
```
|
|
758
804
|
|
|
759
805
|
Returns the four sibling tiles (children of the parent tile) for the given tile.
|
|
760
806
|
|
|
761
807
|
## Parameters
|
|
762
808
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
809
|
+
### tile
|
|
810
|
+
|
|
811
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
812
|
+
|
|
813
|
+
The tile as [x, y, zoom]
|
|
766
814
|
|
|
767
815
|
## Returns
|
|
768
816
|
|
|
@@ -770,24 +818,31 @@ Returns the four sibling tiles (children of the parent tile) for the given tile.
|
|
|
770
818
|
|
|
771
819
|
An array of four sibling tiles at the same zoom level
|
|
772
820
|
|
|
773
|
-
|
|
821
|
+
### <a id="tilesEqual"></a>tilesEqual
|
|
774
822
|
|
|
775
823
|
[**@xylabs/geo**](#../README)
|
|
776
824
|
|
|
777
825
|
***
|
|
778
826
|
|
|
779
827
|
```ts
|
|
780
|
-
function tilesEqual(param0
|
|
828
|
+
function tilesEqual(param0, param1): boolean;
|
|
781
829
|
```
|
|
782
830
|
|
|
783
831
|
Checks whether two Mercator tiles are equal by comparing their x, y, and zoom values.
|
|
784
832
|
|
|
785
833
|
## Parameters
|
|
786
834
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
835
|
+
### param0
|
|
836
|
+
|
|
837
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
838
|
+
|
|
839
|
+
The first tile as [x, y, zoom]
|
|
840
|
+
|
|
841
|
+
### param1
|
|
842
|
+
|
|
843
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
844
|
+
|
|
845
|
+
The second tile as [x, y, zoom]
|
|
791
846
|
|
|
792
847
|
## Returns
|
|
793
848
|
|
|
@@ -795,24 +850,31 @@ Checks whether two Mercator tiles are equal by comparing their x, y, and zoom va
|
|
|
795
850
|
|
|
796
851
|
True if both tiles have identical coordinates and zoom
|
|
797
852
|
|
|
798
|
-
|
|
853
|
+
### <a id="tilesFromBoundingBox"></a>tilesFromBoundingBox
|
|
799
854
|
|
|
800
855
|
[**@xylabs/geo**](#../README)
|
|
801
856
|
|
|
802
857
|
***
|
|
803
858
|
|
|
804
859
|
```ts
|
|
805
|
-
function tilesFromBoundingBox(box
|
|
860
|
+
function tilesFromBoundingBox(box, zoom): MercatorTile[];
|
|
806
861
|
```
|
|
807
862
|
|
|
808
863
|
Returns all Mercator tiles that intersect the given bounding box at the specified zoom level.
|
|
809
864
|
|
|
810
865
|
## Parameters
|
|
811
866
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
867
|
+
### box
|
|
868
|
+
|
|
869
|
+
[`MercatorBoundingBox`](#../classes/MercatorBoundingBox)
|
|
870
|
+
|
|
871
|
+
The geographic bounding box
|
|
872
|
+
|
|
873
|
+
### zoom
|
|
874
|
+
|
|
875
|
+
`number`
|
|
876
|
+
|
|
877
|
+
The zoom level
|
|
816
878
|
|
|
817
879
|
## Returns
|
|
818
880
|
|
|
@@ -820,24 +882,31 @@ Returns all Mercator tiles that intersect the given bounding box at the specifie
|
|
|
820
882
|
|
|
821
883
|
An array of tiles covering the bounding box
|
|
822
884
|
|
|
823
|
-
|
|
885
|
+
### <a id="tilesHasTile"></a>tilesHasTile
|
|
824
886
|
|
|
825
887
|
[**@xylabs/geo**](#../README)
|
|
826
888
|
|
|
827
889
|
***
|
|
828
890
|
|
|
829
891
|
```ts
|
|
830
|
-
function tilesHasTile(tiles
|
|
892
|
+
function tilesHasTile(tiles, tile): boolean;
|
|
831
893
|
```
|
|
832
894
|
|
|
833
895
|
Checks whether a specific tile exists in the given tile array.
|
|
834
896
|
|
|
835
897
|
## Parameters
|
|
836
898
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
899
|
+
### tiles
|
|
900
|
+
|
|
901
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)[]
|
|
902
|
+
|
|
903
|
+
The array of tiles to search
|
|
904
|
+
|
|
905
|
+
### tile
|
|
906
|
+
|
|
907
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
908
|
+
|
|
909
|
+
The tile to look for
|
|
841
910
|
|
|
842
911
|
## Returns
|
|
843
912
|
|
|
@@ -845,9 +914,9 @@ Checks whether a specific tile exists in the given tile array.
|
|
|
845
914
|
|
|
846
915
|
True if the tile is found in the array
|
|
847
916
|
|
|
848
|
-
### type-aliases
|
|
917
|
+
### type-aliases
|
|
849
918
|
|
|
850
|
-
|
|
919
|
+
### <a id="MercatorBoundary"></a>MercatorBoundary
|
|
851
920
|
|
|
852
921
|
[**@xylabs/geo**](#../README)
|
|
853
922
|
|
|
@@ -859,7 +928,7 @@ type MercatorBoundary = MercatorLngLat[];
|
|
|
859
928
|
|
|
860
929
|
An ordered array of MercatorLngLat points forming a boundary.
|
|
861
930
|
|
|
862
|
-
|
|
931
|
+
### <a id="MercatorTile"></a>MercatorTile
|
|
863
932
|
|
|
864
933
|
[**@xylabs/geo**](#../README)
|
|
865
934
|
|
|
@@ -871,9 +940,9 @@ type MercatorTile = readonly [number, number, number];
|
|
|
871
940
|
|
|
872
941
|
A Mercator tile represented as [x, y, zoom].
|
|
873
942
|
|
|
874
|
-
### variables
|
|
943
|
+
### variables
|
|
875
944
|
|
|
876
|
-
|
|
945
|
+
### <a id="d2r"></a>d2r
|
|
877
946
|
|
|
878
947
|
[**@xylabs/geo**](#../README)
|
|
879
948
|
|
|
@@ -885,7 +954,7 @@ const d2r: number;
|
|
|
885
954
|
|
|
886
955
|
Conversion factor from degrees to radians.
|
|
887
956
|
|
|
888
|
-
|
|
957
|
+
### <a id="r2d"></a>r2d
|
|
889
958
|
|
|
890
959
|
[**@xylabs/geo**](#../README)
|
|
891
960
|
|
|
@@ -898,41 +967,7 @@ const r2d: number;
|
|
|
898
967
|
Conversion factor from radians to degrees.
|
|
899
968
|
|
|
900
969
|
|
|
901
|
-
Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
|
|
902
|
-
|
|
903
|
-
## Maintainers
|
|
904
|
-
|
|
905
|
-
- [Arie Trouw](https://github.com/arietrouw) ([arietrouw.com](https://arietrouw.com))
|
|
906
|
-
- [Matt Jones](https://github.com/jonesmac)
|
|
907
|
-
- [Joel Carter](https://github.com/JoelBCarter)
|
|
908
|
-
- [Jordan Trouw](https://github.com/jordantrouw)
|
|
909
|
-
|
|
910
|
-
## License
|
|
911
|
-
|
|
912
|
-
> See the [LICENSE](LICENSE) file for license details
|
|
913
|
-
|
|
914
|
-
## Credits
|
|
915
|
-
|
|
916
|
-
[Made with 🔥 and ❄️ by XYLabs](https://xylabs.com)
|
|
917
|
-
|
|
918
|
-
[logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg
|
|
919
|
-
|
|
920
|
-
[main-build]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml/badge.svg
|
|
921
|
-
[main-build-link]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml
|
|
922
970
|
[npm-badge]: https://img.shields.io/npm/v/@xylabs/geo.svg
|
|
923
971
|
[npm-link]: https://www.npmjs.com/package/@xylabs/geo
|
|
924
|
-
[
|
|
925
|
-
[
|
|
926
|
-
[codeclimate-badge]: https://api.codeclimate.com/v1/badges/c5eb068f806f0b047ea7/maintainability
|
|
927
|
-
[codeclimate-link]: https://codeclimate.com/github/xylabs/sdk-js/maintainability
|
|
928
|
-
[snyk-badge]: https://snyk.io/test/github/xylabs/sdk-js/badge.svg?targetFile=package.json
|
|
929
|
-
[snyk-link]: https://snyk.io/test/github/xylabs/sdk-js?targetFile=package.json
|
|
930
|
-
|
|
931
|
-
[npm-downloads-badge]: https://img.shields.io/npm/dw/@xylabs/geo
|
|
932
|
-
[npm-license-badge]: https://img.shields.io/npm/l/@xylabs/geo
|
|
933
|
-
|
|
934
|
-
[jsdelivr-badge]: https://data.jsdelivr.com/v1/package/npm/@xylabs/geo/badge
|
|
935
|
-
[jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xylabs/geo
|
|
936
|
-
|
|
937
|
-
[socket-badge]: https://socket.dev/api/badge/npm/package/@xylabs/geo
|
|
938
|
-
[socket-link]: https://socket.dev/npm/package/@xylabs/geo
|
|
972
|
+
[license-badge]: https://img.shields.io/npm/l/@xylabs/geo.svg
|
|
973
|
+
[license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mercator/tiles/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mercator/tiles/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/geo",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.96",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xylabs",
|
|
@@ -28,12 +28,10 @@
|
|
|
28
28
|
"exports": {
|
|
29
29
|
".": {
|
|
30
30
|
"types": "./dist/neutral/index.d.ts",
|
|
31
|
-
"import": "./dist/neutral/index.mjs",
|
|
32
31
|
"default": "./dist/neutral/index.mjs"
|
|
33
32
|
},
|
|
34
33
|
"./package.json": "./package.json"
|
|
35
34
|
},
|
|
36
|
-
"types": "./dist/neutral/index.d.ts",
|
|
37
35
|
"files": [
|
|
38
36
|
"dist",
|
|
39
37
|
"!**/*.bench.*",
|
|
@@ -46,15 +44,16 @@
|
|
|
46
44
|
"mapbox-gl": "~3.21.0"
|
|
47
45
|
},
|
|
48
46
|
"devDependencies": {
|
|
49
|
-
"@types/node": "^25.
|
|
50
|
-
"@xylabs/
|
|
51
|
-
"@xylabs/
|
|
52
|
-
"@xylabs/tsconfig": "~7.7.3",
|
|
53
|
-
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
47
|
+
"@types/node": "^25.6.0",
|
|
48
|
+
"@xylabs/toolchain": "~7.10.4",
|
|
49
|
+
"@xylabs/tsconfig": "~7.10.4",
|
|
54
50
|
"esbuild": "^0.28.0",
|
|
55
51
|
"typescript": "^5",
|
|
56
|
-
"vite": "^
|
|
57
|
-
"vitest": "^4.1.
|
|
52
|
+
"vite": "^8.0.8",
|
|
53
|
+
"vitest": "^4.1.4"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=18"
|
|
58
57
|
},
|
|
59
58
|
"publishConfig": {
|
|
60
59
|
"access": "public"
|