@xylabs/geo 5.0.83 → 5.0.86
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 +266 -176
- package/dist/neutral/GeoJson.d.ts +26 -0
- package/dist/neutral/GeoJson.d.ts.map +1 -1
- package/dist/neutral/LayerBase.d.ts +7 -0
- package/dist/neutral/LayerBase.d.ts.map +1 -1
- package/dist/neutral/index.mjs +30 -0
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/mercator/boundingbox/to/boundary.d.ts +5 -0
- package/dist/neutral/mercator/boundingbox/to/boundary.d.ts.map +1 -1
- package/dist/neutral/mercator/boundingbox/to/center.d.ts +6 -0
- package/dist/neutral/mercator/boundingbox/to/center.d.ts.map +1 -1
- package/dist/neutral/mercator/boundingbox/to/polygon.d.ts +5 -0
- package/dist/neutral/mercator/boundingbox/to/polygon.d.ts.map +1 -1
- package/dist/neutral/mercator/constants.d.ts +2 -0
- package/dist/neutral/mercator/constants.d.ts.map +1 -1
- package/dist/neutral/mercator/tile/from/point.d.ts +6 -0
- package/dist/neutral/mercator/tile/from/point.d.ts.map +1 -1
- package/dist/neutral/mercator/tile/from/quadkey.d.ts +5 -0
- package/dist/neutral/mercator/tile/from/quadkey.d.ts.map +1 -1
- package/dist/neutral/mercator/tile/to/boundingbox.d.ts +5 -0
- package/dist/neutral/mercator/tile/to/boundingbox.d.ts.map +1 -1
- package/dist/neutral/mercator/tile/to/children.d.ts +5 -0
- package/dist/neutral/mercator/tile/to/children.d.ts.map +1 -1
- package/dist/neutral/mercator/tile/to/geoJson.d.ts +5 -0
- package/dist/neutral/mercator/tile/to/geoJson.d.ts.map +1 -1
- package/dist/neutral/mercator/tile/to/parent.d.ts +5 -0
- package/dist/neutral/mercator/tile/to/parent.d.ts.map +1 -1
- package/dist/neutral/mercator/tile/to/point.d.ts +5 -0
- package/dist/neutral/mercator/tile/to/point.d.ts.map +1 -1
- package/dist/neutral/mercator/tile/to/quadkey.d.ts +5 -0
- package/dist/neutral/mercator/tile/to/quadkey.d.ts.map +1 -1
- package/dist/neutral/mercator/tile/to/siblings.d.ts +5 -0
- package/dist/neutral/mercator/tile/to/siblings.d.ts.map +1 -1
- package/dist/neutral/mercator/tiles/equal.d.ts +6 -0
- package/dist/neutral/mercator/tiles/equal.d.ts.map +1 -1
- package/dist/neutral/mercator/tiles/from/boundingbox.d.ts +6 -0
- package/dist/neutral/mercator/tiles/from/boundingbox.d.ts.map +1 -1
- package/dist/neutral/mercator/tiles/hasSiblings.d.ts +6 -0
- package/dist/neutral/mercator/tiles/hasSiblings.d.ts.map +1 -1
- package/dist/neutral/mercator/tiles/hasTile.d.ts +6 -0
- package/dist/neutral/mercator/tiles/hasTile.d.ts.map +1 -1
- package/dist/neutral/mercator/types.d.ts +4 -0
- package/dist/neutral/mercator/types.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
|
|
18
20
|
## Reference
|
|
19
21
|
|
|
20
22
|
**@xylabs/geo**
|
|
@@ -23,39 +25,47 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
|
23
25
|
|
|
24
26
|
## Classes
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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. |
|
|
30
34
|
|
|
31
35
|
## Type Aliases
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
| Type Alias | Description |
|
|
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. |
|
|
35
41
|
|
|
36
42
|
## Variables
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
| Variable | Description |
|
|
45
|
+
| ------ | ------ |
|
|
46
|
+
| [d2r](#variables/d2r) | Conversion factor from degrees to radians. |
|
|
47
|
+
| [r2d](#variables/r2d) | Conversion factor from radians to degrees. |
|
|
40
48
|
|
|
41
49
|
## Functions
|
|
42
50
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
| Function | Description |
|
|
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. |
|
|
59
69
|
|
|
60
70
|
### classes
|
|
61
71
|
|
|
@@ -65,19 +75,21 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
|
65
75
|
|
|
66
76
|
***
|
|
67
77
|
|
|
78
|
+
Provides GeoJSON geometry and MapBox source generation from a quadkey.
|
|
79
|
+
|
|
68
80
|
## Constructors
|
|
69
81
|
|
|
70
82
|
### Constructor
|
|
71
83
|
|
|
72
84
|
```ts
|
|
73
|
-
new GeoJson(quadkey): GeoJson;
|
|
85
|
+
new GeoJson(quadkey: string): GeoJson;
|
|
74
86
|
```
|
|
75
87
|
|
|
76
88
|
### Parameters
|
|
77
89
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
`string`
|
|
90
|
+
| Parameter | Type |
|
|
91
|
+
| ------ | ------ |
|
|
92
|
+
| `quadkey` | `string` |
|
|
81
93
|
|
|
82
94
|
### Returns
|
|
83
95
|
|
|
@@ -88,55 +100,67 @@ new GeoJson(quadkey): GeoJson;
|
|
|
88
100
|
### featureCollection()
|
|
89
101
|
|
|
90
102
|
```ts
|
|
91
|
-
static featureCollection(features): FeatureCollection;
|
|
103
|
+
static featureCollection(features: Feature<Geometry, GeoJsonProperties>[]): FeatureCollection;
|
|
92
104
|
```
|
|
93
105
|
|
|
94
|
-
|
|
106
|
+
Creates a GeoJSON FeatureCollection from an array of features.
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
### Parameters
|
|
97
109
|
|
|
98
|
-
|
|
110
|
+
| Parameter | Type | Description |
|
|
111
|
+
| ------ | ------ | ------ |
|
|
112
|
+
| `features` | `Feature`\<`Geometry`, `GeoJsonProperties`\>[] | The features to include |
|
|
99
113
|
|
|
100
114
|
### Returns
|
|
101
115
|
|
|
102
116
|
`FeatureCollection`
|
|
103
117
|
|
|
118
|
+
A GeoJSON FeatureCollection
|
|
119
|
+
|
|
104
120
|
***
|
|
105
121
|
|
|
106
122
|
### featuresSource()
|
|
107
123
|
|
|
108
124
|
```ts
|
|
109
|
-
static featuresSource(data): GeoJSONSourceSpecification;
|
|
125
|
+
static featuresSource(data: FeatureCollection): GeoJSONSourceSpecification;
|
|
110
126
|
```
|
|
111
127
|
|
|
112
|
-
|
|
128
|
+
Creates a MapBox GeoJSON source specification from a FeatureCollection.
|
|
113
129
|
|
|
114
|
-
|
|
130
|
+
### Parameters
|
|
115
131
|
|
|
116
|
-
|
|
132
|
+
| Parameter | Type | Description |
|
|
133
|
+
| ------ | ------ | ------ |
|
|
134
|
+
| `data` | `FeatureCollection` | The FeatureCollection to use as the source data |
|
|
117
135
|
|
|
118
136
|
### Returns
|
|
119
137
|
|
|
120
138
|
`GeoJSONSourceSpecification`
|
|
121
139
|
|
|
140
|
+
A MapBox GeoJSON source specification
|
|
141
|
+
|
|
122
142
|
***
|
|
123
143
|
|
|
124
144
|
### geometryFeature()
|
|
125
145
|
|
|
126
146
|
```ts
|
|
127
|
-
static geometryFeature(geometry): Feature;
|
|
147
|
+
static geometryFeature(geometry: Geometry): Feature;
|
|
128
148
|
```
|
|
129
149
|
|
|
130
|
-
|
|
150
|
+
Wraps a geometry object in a GeoJSON Feature.
|
|
131
151
|
|
|
132
|
-
|
|
152
|
+
### Parameters
|
|
133
153
|
|
|
134
|
-
|
|
154
|
+
| Parameter | Type | Description |
|
|
155
|
+
| ------ | ------ | ------ |
|
|
156
|
+
| `geometry` | `Geometry` | The geometry to wrap |
|
|
135
157
|
|
|
136
158
|
### Returns
|
|
137
159
|
|
|
138
160
|
`Feature`
|
|
139
161
|
|
|
162
|
+
A GeoJSON Feature containing the geometry
|
|
163
|
+
|
|
140
164
|
***
|
|
141
165
|
|
|
142
166
|
### center()
|
|
@@ -145,6 +169,8 @@ static geometryFeature(geometry): Feature;
|
|
|
145
169
|
center(): LngLat;
|
|
146
170
|
```
|
|
147
171
|
|
|
172
|
+
Computes and caches the center point of the quadkey's bounding box as a MapBox LngLat.
|
|
173
|
+
|
|
148
174
|
### Returns
|
|
149
175
|
|
|
150
176
|
`LngLat`
|
|
@@ -157,6 +183,8 @@ center(): LngLat;
|
|
|
157
183
|
point(): Point;
|
|
158
184
|
```
|
|
159
185
|
|
|
186
|
+
Returns a GeoJSON Point geometry at the center of the quadkey's bounding box.
|
|
187
|
+
|
|
160
188
|
### Returns
|
|
161
189
|
|
|
162
190
|
`Point`
|
|
@@ -169,6 +197,8 @@ point(): Point;
|
|
|
169
197
|
pointFeature(): Feature;
|
|
170
198
|
```
|
|
171
199
|
|
|
200
|
+
Returns a GeoJSON Feature containing the center point geometry.
|
|
201
|
+
|
|
172
202
|
### Returns
|
|
173
203
|
|
|
174
204
|
`Feature`
|
|
@@ -181,6 +211,8 @@ pointFeature(): Feature;
|
|
|
181
211
|
pointFeatureCollection(): FeatureCollection;
|
|
182
212
|
```
|
|
183
213
|
|
|
214
|
+
Returns a GeoJSON FeatureCollection containing the center point feature.
|
|
215
|
+
|
|
184
216
|
### Returns
|
|
185
217
|
|
|
186
218
|
`FeatureCollection`
|
|
@@ -193,6 +225,8 @@ pointFeatureCollection(): FeatureCollection;
|
|
|
193
225
|
pointSource(): GeoJSONSourceSpecification;
|
|
194
226
|
```
|
|
195
227
|
|
|
228
|
+
Returns a MapBox GeoJSON source specification for the center point.
|
|
229
|
+
|
|
196
230
|
### Returns
|
|
197
231
|
|
|
198
232
|
`GeoJSONSourceSpecification`
|
|
@@ -205,6 +239,8 @@ pointSource(): GeoJSONSourceSpecification;
|
|
|
205
239
|
polygon(): Polygon;
|
|
206
240
|
```
|
|
207
241
|
|
|
242
|
+
Returns a GeoJSON Polygon geometry representing the quadkey's bounding box.
|
|
243
|
+
|
|
208
244
|
### Returns
|
|
209
245
|
|
|
210
246
|
`Polygon`
|
|
@@ -217,6 +253,8 @@ polygon(): Polygon;
|
|
|
217
253
|
polygonFeature(): Feature;
|
|
218
254
|
```
|
|
219
255
|
|
|
256
|
+
Returns a GeoJSON Feature containing the polygon geometry.
|
|
257
|
+
|
|
220
258
|
### Returns
|
|
221
259
|
|
|
222
260
|
`Feature`
|
|
@@ -229,6 +267,8 @@ polygonFeature(): Feature;
|
|
|
229
267
|
polygonFeatureCollection(): FeatureCollection;
|
|
230
268
|
```
|
|
231
269
|
|
|
270
|
+
Returns a GeoJSON FeatureCollection containing the polygon feature.
|
|
271
|
+
|
|
232
272
|
### Returns
|
|
233
273
|
|
|
234
274
|
`FeatureCollection`
|
|
@@ -241,6 +281,8 @@ polygonFeatureCollection(): FeatureCollection;
|
|
|
241
281
|
polygonSource(): GeoJSONSourceSpecification;
|
|
242
282
|
```
|
|
243
283
|
|
|
284
|
+
Returns a MapBox GeoJSON source specification for the polygon.
|
|
285
|
+
|
|
244
286
|
### Returns
|
|
245
287
|
|
|
246
288
|
`GeoJSONSourceSpecification`
|
|
@@ -253,6 +295,8 @@ polygonSource(): GeoJSONSourceSpecification;
|
|
|
253
295
|
zoom(): number;
|
|
254
296
|
```
|
|
255
297
|
|
|
298
|
+
Returns the zoom level derived from the quadkey length.
|
|
299
|
+
|
|
256
300
|
### Returns
|
|
257
301
|
|
|
258
302
|
`number`
|
|
@@ -263,29 +307,28 @@ zoom(): number;
|
|
|
263
307
|
|
|
264
308
|
***
|
|
265
309
|
|
|
266
|
-
|
|
310
|
+
Abstract base class for managing MapBox map layers with add/remove lifecycle.
|
|
267
311
|
|
|
268
|
-
|
|
312
|
+
## Type Parameters
|
|
269
313
|
|
|
270
|
-
|
|
314
|
+
| Type Parameter |
|
|
315
|
+
| ------ |
|
|
316
|
+
| `T` *extends* `MapBox.Layer` |
|
|
271
317
|
|
|
272
318
|
## Constructors
|
|
273
319
|
|
|
274
320
|
### Constructor
|
|
275
321
|
|
|
276
322
|
```ts
|
|
277
|
-
new LayerBase<T>(id, source): LayerBase<T>;
|
|
323
|
+
new LayerBase<T>(id: string, source: string): LayerBase<T>;
|
|
278
324
|
```
|
|
279
325
|
|
|
280
326
|
### Parameters
|
|
281
327
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
`string`
|
|
285
|
-
|
|
286
|
-
#### source
|
|
287
|
-
|
|
288
|
-
`string`
|
|
328
|
+
| Parameter | Type |
|
|
329
|
+
| ------ | ------ |
|
|
330
|
+
| `id` | `string` |
|
|
331
|
+
| `source` | `string` |
|
|
289
332
|
|
|
290
333
|
### Returns
|
|
291
334
|
|
|
@@ -293,37 +336,27 @@ new LayerBase<T>(id, source): LayerBase<T>;
|
|
|
293
336
|
|
|
294
337
|
## Properties
|
|
295
338
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
id
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
***
|
|
303
|
-
|
|
304
|
-
### source
|
|
305
|
-
|
|
306
|
-
```ts
|
|
307
|
-
source: string;
|
|
308
|
-
```
|
|
339
|
+
| Property | Type |
|
|
340
|
+
| ------ | ------ |
|
|
341
|
+
| <a id="id"></a> `id` | `string` |
|
|
342
|
+
| <a id="source"></a> `source` | `string` |
|
|
309
343
|
|
|
310
344
|
## Methods
|
|
311
345
|
|
|
312
346
|
### update()
|
|
313
347
|
|
|
314
348
|
```ts
|
|
315
|
-
update(map, show
|
|
349
|
+
update(map: Map$1, show?: boolean): void;
|
|
316
350
|
```
|
|
317
351
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
#### map
|
|
352
|
+
Removes and re-adds the layer on the map, optionally hiding it.
|
|
321
353
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
#### show?
|
|
354
|
+
### Parameters
|
|
325
355
|
|
|
326
|
-
|
|
356
|
+
| Parameter | Type | Default value | Description |
|
|
357
|
+
| ------ | ------ | ------ | ------ |
|
|
358
|
+
| `map` | `Map$1` | `undefined` | The MapBox map instance |
|
|
359
|
+
| `show` | `boolean` | `true` | Whether to show the layer after updating (default true) |
|
|
327
360
|
|
|
328
361
|
### Returns
|
|
329
362
|
|
|
@@ -337,6 +370,8 @@ update(map, show?): void;
|
|
|
337
370
|
abstract buildLayer(): T;
|
|
338
371
|
```
|
|
339
372
|
|
|
373
|
+
Builds the MapBox layer configuration object.
|
|
374
|
+
|
|
340
375
|
### Returns
|
|
341
376
|
|
|
342
377
|
`T`
|
|
@@ -347,6 +382,8 @@ abstract buildLayer(): T;
|
|
|
347
382
|
|
|
348
383
|
***
|
|
349
384
|
|
|
385
|
+
A Mercator bounding box extending MapBox LngLatBounds.
|
|
386
|
+
|
|
350
387
|
## Extends
|
|
351
388
|
|
|
352
389
|
- `LngLatBounds`
|
|
@@ -356,18 +393,18 @@ abstract buildLayer(): T;
|
|
|
356
393
|
### Constructor
|
|
357
394
|
|
|
358
395
|
```ts
|
|
359
|
-
new MercatorBoundingBox(sw
|
|
396
|
+
new MercatorBoundingBox(sw?:
|
|
397
|
+
| [number, number, number, number]
|
|
398
|
+
| LngLatLike
|
|
399
|
+
| [LngLatLike, LngLatLike], ne?: LngLatLike): MercatorBoundingBox;
|
|
360
400
|
```
|
|
361
401
|
|
|
362
402
|
### Parameters
|
|
363
403
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
\[`number`, `number`, `number`, `number`\]
|
|
367
|
-
|
|
368
|
-
#### ne?
|
|
369
|
-
|
|
370
|
-
`LngLatLike`
|
|
404
|
+
| Parameter | Type |
|
|
405
|
+
| ------ | ------ |
|
|
406
|
+
| `sw?` | \| \[`number`, `number`, `number`, `number`\] \| `LngLatLike` \| \[`LngLatLike`, `LngLatLike`\] |
|
|
407
|
+
| `ne?` | `LngLatLike` |
|
|
371
408
|
|
|
372
409
|
### Returns
|
|
373
410
|
|
|
@@ -385,6 +422,8 @@ MapBox.LngLatBounds.constructor
|
|
|
385
422
|
|
|
386
423
|
***
|
|
387
424
|
|
|
425
|
+
A Mercator coordinate extending MapBox LngLat.
|
|
426
|
+
|
|
388
427
|
## Extends
|
|
389
428
|
|
|
390
429
|
- `LngLat`
|
|
@@ -394,18 +433,15 @@ MapBox.LngLatBounds.constructor
|
|
|
394
433
|
### Constructor
|
|
395
434
|
|
|
396
435
|
```ts
|
|
397
|
-
new MercatorLngLat(lng, lat): MercatorLngLat;
|
|
436
|
+
new MercatorLngLat(lng: number, lat: number): MercatorLngLat;
|
|
398
437
|
```
|
|
399
438
|
|
|
400
439
|
### Parameters
|
|
401
440
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
`number`
|
|
405
|
-
|
|
406
|
-
#### lat
|
|
407
|
-
|
|
408
|
-
`number`
|
|
441
|
+
| Parameter | Type |
|
|
442
|
+
| ------ | ------ |
|
|
443
|
+
| `lng` | `number` |
|
|
444
|
+
| `lat` | `number` |
|
|
409
445
|
|
|
410
446
|
### Returns
|
|
411
447
|
|
|
@@ -426,19 +462,23 @@ MapBox.LngLat.constructor
|
|
|
426
462
|
***
|
|
427
463
|
|
|
428
464
|
```ts
|
|
429
|
-
function boundingBoxToBoundary(box): MercatorBoundary;
|
|
465
|
+
function boundingBoxToBoundary(box: MercatorBoundingBox): MercatorBoundary;
|
|
430
466
|
```
|
|
431
467
|
|
|
432
|
-
|
|
468
|
+
Converts a bounding box to an ordered boundary polygon (closed ring of corner points).
|
|
433
469
|
|
|
434
|
-
|
|
470
|
+
## Parameters
|
|
435
471
|
|
|
436
|
-
|
|
472
|
+
| Parameter | Type | Description |
|
|
473
|
+
| ------ | ------ | ------ |
|
|
474
|
+
| `box` | [`MercatorBoundingBox`](#../classes/MercatorBoundingBox) | The bounding box to convert |
|
|
437
475
|
|
|
438
476
|
## Returns
|
|
439
477
|
|
|
440
478
|
[`MercatorBoundary`](#../type-aliases/MercatorBoundary)
|
|
441
479
|
|
|
480
|
+
An array of corner points forming a closed boundary
|
|
481
|
+
|
|
442
482
|
### <a id="boundingBoxToCenter"></a>boundingBoxToCenter
|
|
443
483
|
|
|
444
484
|
[**@xylabs/geo**](#../README)
|
|
@@ -446,23 +486,24 @@ function boundingBoxToBoundary(box): MercatorBoundary;
|
|
|
446
486
|
***
|
|
447
487
|
|
|
448
488
|
```ts
|
|
449
|
-
function boundingBoxToCenter(boundingBox, decimal
|
|
489
|
+
function boundingBoxToCenter(boundingBox: MercatorBoundingBox, decimal?: number): number[];
|
|
450
490
|
```
|
|
451
491
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
### boundingBox
|
|
492
|
+
Computes the center point of a bounding box as [lng, lat], rounded to the specified decimal places.
|
|
455
493
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
### decimal?
|
|
494
|
+
## Parameters
|
|
459
495
|
|
|
460
|
-
|
|
496
|
+
| Parameter | Type | Default value | Description |
|
|
497
|
+
| ------ | ------ | ------ | ------ |
|
|
498
|
+
| `boundingBox` | [`MercatorBoundingBox`](#../classes/MercatorBoundingBox) | `undefined` | The bounding box to find the center of |
|
|
499
|
+
| `decimal` | `number` | `6` | Number of decimal places for rounding (default 6) |
|
|
461
500
|
|
|
462
501
|
## Returns
|
|
463
502
|
|
|
464
503
|
`number`[]
|
|
465
504
|
|
|
505
|
+
A [longitude, latitude] tuple representing the center
|
|
506
|
+
|
|
466
507
|
### <a id="boundingBoxToPolygon"></a>boundingBoxToPolygon
|
|
467
508
|
|
|
468
509
|
[**@xylabs/geo**](#../README)
|
|
@@ -470,19 +511,23 @@ function boundingBoxToCenter(boundingBox, decimal?): number[];
|
|
|
470
511
|
***
|
|
471
512
|
|
|
472
513
|
```ts
|
|
473
|
-
function boundingBoxToPolygon(box): Polygon;
|
|
514
|
+
function boundingBoxToPolygon(box: MercatorBoundingBox): Polygon;
|
|
474
515
|
```
|
|
475
516
|
|
|
476
|
-
|
|
517
|
+
Converts a bounding box to a GeoJSON Polygon geometry.
|
|
477
518
|
|
|
478
|
-
|
|
519
|
+
## Parameters
|
|
479
520
|
|
|
480
|
-
|
|
521
|
+
| Parameter | Type | Description |
|
|
522
|
+
| ------ | ------ | ------ |
|
|
523
|
+
| `box` | [`MercatorBoundingBox`](#../classes/MercatorBoundingBox) | The bounding box to convert |
|
|
481
524
|
|
|
482
525
|
## Returns
|
|
483
526
|
|
|
484
527
|
`Polygon`
|
|
485
528
|
|
|
529
|
+
A GeoJSON Polygon representing the bounding box
|
|
530
|
+
|
|
486
531
|
### <a id="hasSiblings"></a>hasSiblings
|
|
487
532
|
|
|
488
533
|
[**@xylabs/geo**](#../README)
|
|
@@ -490,23 +535,24 @@ function boundingBoxToPolygon(box): Polygon;
|
|
|
490
535
|
***
|
|
491
536
|
|
|
492
537
|
```ts
|
|
493
|
-
function hasSiblings(tiles, tile): boolean;
|
|
538
|
+
function hasSiblings(tiles: MercatorTile[], tile: MercatorTile): boolean;
|
|
494
539
|
```
|
|
495
540
|
|
|
496
|
-
|
|
541
|
+
Checks whether all four siblings of the given tile exist in the tile array.
|
|
497
542
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
[`MercatorTile`](#../type-aliases/MercatorTile)[]
|
|
501
|
-
|
|
502
|
-
### tile
|
|
543
|
+
## Parameters
|
|
503
544
|
|
|
504
|
-
|
|
545
|
+
| Parameter | Type | Description |
|
|
546
|
+
| ------ | ------ | ------ |
|
|
547
|
+
| `tiles` | [`MercatorTile`](#../type-aliases/MercatorTile)[] | The array of tiles to search |
|
|
548
|
+
| `tile` | [`MercatorTile`](#../type-aliases/MercatorTile) | The tile whose siblings to check for |
|
|
505
549
|
|
|
506
550
|
## Returns
|
|
507
551
|
|
|
508
552
|
`boolean`
|
|
509
553
|
|
|
554
|
+
True if all siblings are present in the array
|
|
555
|
+
|
|
510
556
|
### <a id="tileFromPoint"></a>tileFromPoint
|
|
511
557
|
|
|
512
558
|
[**@xylabs/geo**](#../README)
|
|
@@ -514,23 +560,24 @@ function hasSiblings(tiles, tile): boolean;
|
|
|
514
560
|
***
|
|
515
561
|
|
|
516
562
|
```ts
|
|
517
|
-
function tileFromPoint(point, z): MercatorTile;
|
|
563
|
+
function tileFromPoint(point: MercatorLngLat, z: number): MercatorTile;
|
|
518
564
|
```
|
|
519
565
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
### point
|
|
523
|
-
|
|
524
|
-
[`MercatorLngLat`](#../classes/MercatorLngLat)
|
|
566
|
+
Converts a geographic point to the integer Mercator tile containing it at the given zoom level.
|
|
525
567
|
|
|
526
|
-
|
|
568
|
+
## Parameters
|
|
527
569
|
|
|
528
|
-
|
|
570
|
+
| Parameter | Type | Description |
|
|
571
|
+
| ------ | ------ | ------ |
|
|
572
|
+
| `point` | [`MercatorLngLat`](#../classes/MercatorLngLat) | The geographic coordinate |
|
|
573
|
+
| `z` | `number` | The zoom level |
|
|
529
574
|
|
|
530
575
|
## Returns
|
|
531
576
|
|
|
532
577
|
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
533
578
|
|
|
579
|
+
The tile as [x, y, zoom]
|
|
580
|
+
|
|
534
581
|
### <a id="tileFromQuadkey"></a>tileFromQuadkey
|
|
535
582
|
|
|
536
583
|
[**@xylabs/geo**](#../README)
|
|
@@ -538,19 +585,23 @@ function tileFromPoint(point, z): MercatorTile;
|
|
|
538
585
|
***
|
|
539
586
|
|
|
540
587
|
```ts
|
|
541
|
-
function tileFromQuadkey(quadkey): MercatorTile;
|
|
588
|
+
function tileFromQuadkey(quadkey: string): MercatorTile;
|
|
542
589
|
```
|
|
543
590
|
|
|
544
|
-
|
|
591
|
+
Converts a quadkey string to a Mercator tile [x, y, zoom].
|
|
545
592
|
|
|
546
|
-
|
|
593
|
+
## Parameters
|
|
547
594
|
|
|
548
|
-
|
|
595
|
+
| Parameter | Type | Description |
|
|
596
|
+
| ------ | ------ | ------ |
|
|
597
|
+
| `quadkey` | `string` | The quadkey string to decode |
|
|
549
598
|
|
|
550
599
|
## Returns
|
|
551
600
|
|
|
552
601
|
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
553
602
|
|
|
603
|
+
The tile as [x, y, zoom]
|
|
604
|
+
|
|
554
605
|
### <a id="tileToBoundingBox"></a>tileToBoundingBox
|
|
555
606
|
|
|
556
607
|
[**@xylabs/geo**](#../README)
|
|
@@ -558,19 +609,23 @@ function tileFromQuadkey(quadkey): MercatorTile;
|
|
|
558
609
|
***
|
|
559
610
|
|
|
560
611
|
```ts
|
|
561
|
-
function tileToBoundingBox(tile): MercatorBoundingBox;
|
|
612
|
+
function tileToBoundingBox(tile: MercatorTile): MercatorBoundingBox;
|
|
562
613
|
```
|
|
563
614
|
|
|
564
|
-
|
|
615
|
+
Converts a Mercator tile to its geographic bounding box.
|
|
565
616
|
|
|
566
|
-
|
|
617
|
+
## Parameters
|
|
567
618
|
|
|
568
|
-
|
|
619
|
+
| Parameter | Type | Description |
|
|
620
|
+
| ------ | ------ | ------ |
|
|
621
|
+
| `tile` | [`MercatorTile`](#../type-aliases/MercatorTile) | The tile as [x, y, zoom] |
|
|
569
622
|
|
|
570
623
|
## Returns
|
|
571
624
|
|
|
572
625
|
[`MercatorBoundingBox`](#../classes/MercatorBoundingBox)
|
|
573
626
|
|
|
627
|
+
The bounding box covering the tile's geographic extent
|
|
628
|
+
|
|
574
629
|
### <a id="tileToChildren"></a>tileToChildren
|
|
575
630
|
|
|
576
631
|
[**@xylabs/geo**](#../README)
|
|
@@ -578,19 +633,23 @@ function tileToBoundingBox(tile): MercatorBoundingBox;
|
|
|
578
633
|
***
|
|
579
634
|
|
|
580
635
|
```ts
|
|
581
|
-
function tileToChildren(tile): MercatorTile[];
|
|
636
|
+
function tileToChildren(tile: MercatorTile): MercatorTile[];
|
|
582
637
|
```
|
|
583
638
|
|
|
639
|
+
Returns the four child tiles at one zoom level higher.
|
|
640
|
+
|
|
584
641
|
## Parameters
|
|
585
642
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
643
|
+
| Parameter | Type | Description |
|
|
644
|
+
| ------ | ------ | ------ |
|
|
645
|
+
| `tile` | [`MercatorTile`](#../type-aliases/MercatorTile) | The parent tile as [x, y, zoom] |
|
|
589
646
|
|
|
590
647
|
## Returns
|
|
591
648
|
|
|
592
649
|
[`MercatorTile`](#../type-aliases/MercatorTile)[]
|
|
593
650
|
|
|
651
|
+
An array of four child tiles at zoom + 1
|
|
652
|
+
|
|
594
653
|
### <a id="tileToGeoJson"></a>tileToGeoJson
|
|
595
654
|
|
|
596
655
|
[**@xylabs/geo**](#../README)
|
|
@@ -598,19 +657,23 @@ function tileToChildren(tile): MercatorTile[];
|
|
|
598
657
|
***
|
|
599
658
|
|
|
600
659
|
```ts
|
|
601
|
-
function tileToGeoJson(tile): Polygon;
|
|
660
|
+
function tileToGeoJson(tile: MercatorTile): Polygon;
|
|
602
661
|
```
|
|
603
662
|
|
|
663
|
+
Converts a Mercator tile to a GeoJSON Polygon geometry.
|
|
664
|
+
|
|
604
665
|
## Parameters
|
|
605
666
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
667
|
+
| Parameter | Type | Description |
|
|
668
|
+
| ------ | ------ | ------ |
|
|
669
|
+
| `tile` | [`MercatorTile`](#../type-aliases/MercatorTile) | The tile as [x, y, zoom] |
|
|
609
670
|
|
|
610
671
|
## Returns
|
|
611
672
|
|
|
612
673
|
`Polygon`
|
|
613
674
|
|
|
675
|
+
A GeoJSON Polygon representing the tile's geographic extent
|
|
676
|
+
|
|
614
677
|
### <a id="tileToParent"></a>tileToParent
|
|
615
678
|
|
|
616
679
|
[**@xylabs/geo**](#../README)
|
|
@@ -618,19 +681,23 @@ function tileToGeoJson(tile): Polygon;
|
|
|
618
681
|
***
|
|
619
682
|
|
|
620
683
|
```ts
|
|
621
|
-
function tileToParent(tile): MercatorTile;
|
|
684
|
+
function tileToParent(tile: MercatorTile): MercatorTile;
|
|
622
685
|
```
|
|
623
686
|
|
|
624
|
-
|
|
687
|
+
Returns the parent tile at one zoom level lower.
|
|
625
688
|
|
|
626
|
-
|
|
689
|
+
## Parameters
|
|
627
690
|
|
|
628
|
-
|
|
691
|
+
| Parameter | Type | Description |
|
|
692
|
+
| ------ | ------ | ------ |
|
|
693
|
+
| `tile` | [`MercatorTile`](#../type-aliases/MercatorTile) | The tile as [x, y, zoom] |
|
|
629
694
|
|
|
630
695
|
## Returns
|
|
631
696
|
|
|
632
697
|
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
633
698
|
|
|
699
|
+
The parent tile at zoom - 1
|
|
700
|
+
|
|
634
701
|
### <a id="tileToPoint"></a>tileToPoint
|
|
635
702
|
|
|
636
703
|
[**@xylabs/geo**](#../README)
|
|
@@ -638,19 +705,23 @@ function tileToParent(tile): MercatorTile;
|
|
|
638
705
|
***
|
|
639
706
|
|
|
640
707
|
```ts
|
|
641
|
-
function tileToPoint(tile): MercatorLngLat;
|
|
708
|
+
function tileToPoint(tile: MercatorTile): MercatorLngLat;
|
|
642
709
|
```
|
|
643
710
|
|
|
644
|
-
|
|
711
|
+
Returns the center point of a Mercator tile.
|
|
645
712
|
|
|
646
|
-
|
|
713
|
+
## Parameters
|
|
647
714
|
|
|
648
|
-
|
|
715
|
+
| Parameter | Type | Description |
|
|
716
|
+
| ------ | ------ | ------ |
|
|
717
|
+
| `tile` | [`MercatorTile`](#../type-aliases/MercatorTile) | The tile as [x, y, zoom] |
|
|
649
718
|
|
|
650
719
|
## Returns
|
|
651
720
|
|
|
652
721
|
[`MercatorLngLat`](#../classes/MercatorLngLat)
|
|
653
722
|
|
|
723
|
+
The center coordinate as a MercatorLngLat
|
|
724
|
+
|
|
654
725
|
### <a id="tileToQuadkey"></a>tileToQuadkey
|
|
655
726
|
|
|
656
727
|
[**@xylabs/geo**](#../README)
|
|
@@ -658,19 +729,23 @@ function tileToPoint(tile): MercatorLngLat;
|
|
|
658
729
|
***
|
|
659
730
|
|
|
660
731
|
```ts
|
|
661
|
-
function tileToQuadkey(
|
|
732
|
+
function tileToQuadkey(param0: MercatorTile): string;
|
|
662
733
|
```
|
|
663
734
|
|
|
664
|
-
|
|
735
|
+
Converts a Mercator tile to its quadkey string representation.
|
|
665
736
|
|
|
666
|
-
|
|
737
|
+
## Parameters
|
|
667
738
|
|
|
668
|
-
|
|
739
|
+
| Parameter | Type | Description |
|
|
740
|
+
| ------ | ------ | ------ |
|
|
741
|
+
| `param0` | [`MercatorTile`](#../type-aliases/MercatorTile) | The tile as [tileX, tileY, tileZoom] |
|
|
669
742
|
|
|
670
743
|
## Returns
|
|
671
744
|
|
|
672
745
|
`string`
|
|
673
746
|
|
|
747
|
+
The quadkey string encoding the tile's position and zoom
|
|
748
|
+
|
|
674
749
|
### <a id="tileToSiblings"></a>tileToSiblings
|
|
675
750
|
|
|
676
751
|
[**@xylabs/geo**](#../README)
|
|
@@ -678,19 +753,23 @@ function tileToQuadkey(__namedParameters): string;
|
|
|
678
753
|
***
|
|
679
754
|
|
|
680
755
|
```ts
|
|
681
|
-
function tileToSiblings(tile): MercatorTile[];
|
|
756
|
+
function tileToSiblings(tile: MercatorTile): MercatorTile[];
|
|
682
757
|
```
|
|
683
758
|
|
|
684
|
-
|
|
759
|
+
Returns the four sibling tiles (children of the parent tile) for the given tile.
|
|
685
760
|
|
|
686
|
-
|
|
761
|
+
## Parameters
|
|
687
762
|
|
|
688
|
-
|
|
763
|
+
| Parameter | Type | Description |
|
|
764
|
+
| ------ | ------ | ------ |
|
|
765
|
+
| `tile` | [`MercatorTile`](#../type-aliases/MercatorTile) | The tile as [x, y, zoom] |
|
|
689
766
|
|
|
690
767
|
## Returns
|
|
691
768
|
|
|
692
769
|
[`MercatorTile`](#../type-aliases/MercatorTile)[]
|
|
693
770
|
|
|
771
|
+
An array of four sibling tiles at the same zoom level
|
|
772
|
+
|
|
694
773
|
### <a id="tilesEqual"></a>tilesEqual
|
|
695
774
|
|
|
696
775
|
[**@xylabs/geo**](#../README)
|
|
@@ -698,23 +777,24 @@ function tileToSiblings(tile): MercatorTile[];
|
|
|
698
777
|
***
|
|
699
778
|
|
|
700
779
|
```ts
|
|
701
|
-
function tilesEqual(
|
|
780
|
+
function tilesEqual(param0: MercatorTile, param1: MercatorTile): boolean;
|
|
702
781
|
```
|
|
703
782
|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
### \_\_namedParameters
|
|
707
|
-
|
|
708
|
-
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
783
|
+
Checks whether two Mercator tiles are equal by comparing their x, y, and zoom values.
|
|
709
784
|
|
|
710
|
-
|
|
785
|
+
## Parameters
|
|
711
786
|
|
|
712
|
-
|
|
787
|
+
| Parameter | Type | Description |
|
|
788
|
+
| ------ | ------ | ------ |
|
|
789
|
+
| `param0` | [`MercatorTile`](#../type-aliases/MercatorTile) | The first tile as [x, y, zoom] |
|
|
790
|
+
| `param1` | [`MercatorTile`](#../type-aliases/MercatorTile) | The second tile as [x, y, zoom] |
|
|
713
791
|
|
|
714
792
|
## Returns
|
|
715
793
|
|
|
716
794
|
`boolean`
|
|
717
795
|
|
|
796
|
+
True if both tiles have identical coordinates and zoom
|
|
797
|
+
|
|
718
798
|
### <a id="tilesFromBoundingBox"></a>tilesFromBoundingBox
|
|
719
799
|
|
|
720
800
|
[**@xylabs/geo**](#../README)
|
|
@@ -722,23 +802,24 @@ function tilesEqual(__namedParameters, __namedParameters): boolean;
|
|
|
722
802
|
***
|
|
723
803
|
|
|
724
804
|
```ts
|
|
725
|
-
function tilesFromBoundingBox(box, zoom): MercatorTile[];
|
|
805
|
+
function tilesFromBoundingBox(box: MercatorBoundingBox, zoom: number): MercatorTile[];
|
|
726
806
|
```
|
|
727
807
|
|
|
728
|
-
|
|
808
|
+
Returns all Mercator tiles that intersect the given bounding box at the specified zoom level.
|
|
729
809
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
[`MercatorBoundingBox`](#../classes/MercatorBoundingBox)
|
|
733
|
-
|
|
734
|
-
### zoom
|
|
810
|
+
## Parameters
|
|
735
811
|
|
|
736
|
-
|
|
812
|
+
| Parameter | Type | Description |
|
|
813
|
+
| ------ | ------ | ------ |
|
|
814
|
+
| `box` | [`MercatorBoundingBox`](#../classes/MercatorBoundingBox) | The geographic bounding box |
|
|
815
|
+
| `zoom` | `number` | The zoom level |
|
|
737
816
|
|
|
738
817
|
## Returns
|
|
739
818
|
|
|
740
819
|
[`MercatorTile`](#../type-aliases/MercatorTile)[]
|
|
741
820
|
|
|
821
|
+
An array of tiles covering the bounding box
|
|
822
|
+
|
|
742
823
|
### <a id="tilesHasTile"></a>tilesHasTile
|
|
743
824
|
|
|
744
825
|
[**@xylabs/geo**](#../README)
|
|
@@ -746,23 +827,24 @@ function tilesFromBoundingBox(box, zoom): MercatorTile[];
|
|
|
746
827
|
***
|
|
747
828
|
|
|
748
829
|
```ts
|
|
749
|
-
function tilesHasTile(tiles, tile): boolean;
|
|
830
|
+
function tilesHasTile(tiles: MercatorTile[], tile: MercatorTile): boolean;
|
|
750
831
|
```
|
|
751
832
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
### tiles
|
|
833
|
+
Checks whether a specific tile exists in the given tile array.
|
|
755
834
|
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
### tile
|
|
835
|
+
## Parameters
|
|
759
836
|
|
|
760
|
-
|
|
837
|
+
| Parameter | Type | Description |
|
|
838
|
+
| ------ | ------ | ------ |
|
|
839
|
+
| `tiles` | [`MercatorTile`](#../type-aliases/MercatorTile)[] | The array of tiles to search |
|
|
840
|
+
| `tile` | [`MercatorTile`](#../type-aliases/MercatorTile) | The tile to look for |
|
|
761
841
|
|
|
762
842
|
## Returns
|
|
763
843
|
|
|
764
844
|
`boolean`
|
|
765
845
|
|
|
846
|
+
True if the tile is found in the array
|
|
847
|
+
|
|
766
848
|
### type-aliases
|
|
767
849
|
|
|
768
850
|
### <a id="MercatorBoundary"></a>MercatorBoundary
|
|
@@ -775,6 +857,8 @@ function tilesHasTile(tiles, tile): boolean;
|
|
|
775
857
|
type MercatorBoundary = MercatorLngLat[];
|
|
776
858
|
```
|
|
777
859
|
|
|
860
|
+
An ordered array of MercatorLngLat points forming a boundary.
|
|
861
|
+
|
|
778
862
|
### <a id="MercatorTile"></a>MercatorTile
|
|
779
863
|
|
|
780
864
|
[**@xylabs/geo**](#../README)
|
|
@@ -785,6 +869,8 @@ type MercatorBoundary = MercatorLngLat[];
|
|
|
785
869
|
type MercatorTile = readonly [number, number, number];
|
|
786
870
|
```
|
|
787
871
|
|
|
872
|
+
A Mercator tile represented as [x, y, zoom].
|
|
873
|
+
|
|
788
874
|
### variables
|
|
789
875
|
|
|
790
876
|
### <a id="d2r"></a>d2r
|
|
@@ -797,6 +883,8 @@ type MercatorTile = readonly [number, number, number];
|
|
|
797
883
|
const d2r: number;
|
|
798
884
|
```
|
|
799
885
|
|
|
886
|
+
Conversion factor from degrees to radians.
|
|
887
|
+
|
|
800
888
|
### <a id="r2d"></a>r2d
|
|
801
889
|
|
|
802
890
|
[**@xylabs/geo**](#../README)
|
|
@@ -807,6 +895,8 @@ const d2r: number;
|
|
|
807
895
|
const r2d: number;
|
|
808
896
|
```
|
|
809
897
|
|
|
898
|
+
Conversion factor from radians to degrees.
|
|
899
|
+
|
|
810
900
|
|
|
811
901
|
Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
|
|
812
902
|
|