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