@xylabs/geo 4.13.20 → 4.13.22
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 +791 -3
- package/dist/neutral/index.mjs +6 -6
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/mercator/tile/from/quadkey.d.ts +2 -1
- package/dist/neutral/mercator/tile/from/quadkey.d.ts.map +1 -1
- package/dist/neutral/mercator/tile/to/children.d.ts +1 -1
- package/dist/neutral/mercator/tile/to/children.d.ts.map +1 -1
- package/dist/neutral/mercator/tile/to/quadkey.d.ts +1 -1
- package/dist/neutral/mercator/tile/to/quadkey.d.ts.map +1 -1
- package/dist/neutral/mercator/tiles/equal.d.ts +1 -1
- package/dist/neutral/mercator/tiles/equal.d.ts.map +1 -1
- package/dist/neutral/mercator/types.d.ts +1 -1
- package/dist/neutral/mercator/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/mercator/tile/from/quadkey.ts +3 -1
- package/src/mercator/tile/to/children.ts +1 -1
- package/src/mercator/tile/to/quadkey.ts +4 -4
- package/src/mercator/tiles/equal.ts +2 -2
- package/src/mercator/types.ts +1 -1
package/README.md
CHANGED
|
@@ -12,13 +12,801 @@
|
|
|
12
12
|
[![snyk-badge][]][snyk-link]
|
|
13
13
|
[![socket-badge][]][socket-link]
|
|
14
14
|
|
|
15
|
-
Version: 4.13.19
|
|
16
15
|
|
|
17
16
|
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
18
17
|
|
|
19
|
-
##
|
|
18
|
+
## Reference
|
|
19
|
+
|
|
20
|
+
**@xylabs/geo**
|
|
21
|
+
|
|
22
|
+
***
|
|
23
|
+
|
|
24
|
+
## Classes
|
|
25
|
+
|
|
26
|
+
- [GeoJson](#classes/GeoJson)
|
|
27
|
+
- [LayerBase](#classes/LayerBase)
|
|
28
|
+
- [MercatorBoundingBox](#classes/MercatorBoundingBox)
|
|
29
|
+
- [MercatorLngLat](#classes/MercatorLngLat)
|
|
30
|
+
|
|
31
|
+
## Type Aliases
|
|
32
|
+
|
|
33
|
+
- [MercatorTile](#type-aliases/MercatorTile)
|
|
34
|
+
- [MercatorBoundary](#type-aliases/MercatorBoundary)
|
|
35
|
+
|
|
36
|
+
## Variables
|
|
37
|
+
|
|
38
|
+
- [d2r](#variables/d2r)
|
|
39
|
+
- [r2d](#variables/r2d)
|
|
40
|
+
|
|
41
|
+
## Functions
|
|
42
|
+
|
|
43
|
+
- [boundingBoxToBoundary](#functions/boundingBoxToBoundary)
|
|
44
|
+
- [boundingBoxToCenter](#functions/boundingBoxToCenter)
|
|
45
|
+
- [boundingBoxToPolygon](#functions/boundingBoxToPolygon)
|
|
46
|
+
- [tileFromPoint](#functions/tileFromPoint)
|
|
47
|
+
- [tileFromQuadkey](#functions/tileFromQuadkey)
|
|
48
|
+
- [tileToBoundingBox](#functions/tileToBoundingBox)
|
|
49
|
+
- [tileToChildren](#functions/tileToChildren)
|
|
50
|
+
- [tileToGeoJson](#functions/tileToGeoJson)
|
|
51
|
+
- [tileToParent](#functions/tileToParent)
|
|
52
|
+
- [tileToPoint](#functions/tileToPoint)
|
|
53
|
+
- [tileToQuadkey](#functions/tileToQuadkey)
|
|
54
|
+
- [tileToSiblings](#functions/tileToSiblings)
|
|
55
|
+
- [tilesEqual](#functions/tilesEqual)
|
|
56
|
+
- [tilesFromBoundingBox](#functions/tilesFromBoundingBox)
|
|
57
|
+
- [hasSiblings](#functions/hasSiblings)
|
|
58
|
+
- [tilesHasTile](#functions/tilesHasTile)
|
|
59
|
+
|
|
60
|
+
### classes
|
|
61
|
+
|
|
62
|
+
### <a id="GeoJson"></a>GeoJson
|
|
63
|
+
|
|
64
|
+
[**@xylabs/geo**](#../README)
|
|
65
|
+
|
|
66
|
+
***
|
|
67
|
+
|
|
68
|
+
## Constructors
|
|
69
|
+
|
|
70
|
+
### Constructor
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
new GeoJson(quadkey): GeoJson;
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Parameters
|
|
77
|
+
|
|
78
|
+
#### quadkey
|
|
79
|
+
|
|
80
|
+
`string`
|
|
81
|
+
|
|
82
|
+
### Returns
|
|
83
|
+
|
|
84
|
+
`GeoJson`
|
|
85
|
+
|
|
86
|
+
## Methods
|
|
87
|
+
|
|
88
|
+
### featureCollection()
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
static featureCollection(features): FeatureCollection;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Parameters
|
|
95
|
+
|
|
96
|
+
#### features
|
|
97
|
+
|
|
98
|
+
`Feature`\<`Geometry`, `GeoJsonProperties`\>[]
|
|
99
|
+
|
|
100
|
+
### Returns
|
|
101
|
+
|
|
102
|
+
`FeatureCollection`
|
|
103
|
+
|
|
104
|
+
***
|
|
105
|
+
|
|
106
|
+
### featuresSource()
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
static featuresSource(data): GeoJSONSourceSpecification;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Parameters
|
|
113
|
+
|
|
114
|
+
#### data
|
|
115
|
+
|
|
116
|
+
`FeatureCollection`
|
|
117
|
+
|
|
118
|
+
### Returns
|
|
119
|
+
|
|
120
|
+
`GeoJSONSourceSpecification`
|
|
121
|
+
|
|
122
|
+
***
|
|
123
|
+
|
|
124
|
+
### geometryFeature()
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
static geometryFeature(geometry): Feature;
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Parameters
|
|
131
|
+
|
|
132
|
+
#### geometry
|
|
133
|
+
|
|
134
|
+
`Geometry`
|
|
135
|
+
|
|
136
|
+
### Returns
|
|
137
|
+
|
|
138
|
+
`Feature`
|
|
139
|
+
|
|
140
|
+
***
|
|
141
|
+
|
|
142
|
+
### center()
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
center(): LngLat;
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Returns
|
|
149
|
+
|
|
150
|
+
`LngLat`
|
|
151
|
+
|
|
152
|
+
***
|
|
153
|
+
|
|
154
|
+
### point()
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
point(): Point;
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Returns
|
|
161
|
+
|
|
162
|
+
`Point`
|
|
163
|
+
|
|
164
|
+
***
|
|
165
|
+
|
|
166
|
+
### pointFeature()
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
pointFeature(): Feature;
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Returns
|
|
173
|
+
|
|
174
|
+
`Feature`
|
|
175
|
+
|
|
176
|
+
***
|
|
177
|
+
|
|
178
|
+
### pointFeatureCollection()
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
pointFeatureCollection(): FeatureCollection;
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Returns
|
|
185
|
+
|
|
186
|
+
`FeatureCollection`
|
|
187
|
+
|
|
188
|
+
***
|
|
189
|
+
|
|
190
|
+
### pointSource()
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
pointSource(): GeoJSONSourceSpecification;
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Returns
|
|
197
|
+
|
|
198
|
+
`GeoJSONSourceSpecification`
|
|
199
|
+
|
|
200
|
+
***
|
|
201
|
+
|
|
202
|
+
### polygon()
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
polygon(): Polygon;
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Returns
|
|
209
|
+
|
|
210
|
+
`Polygon`
|
|
211
|
+
|
|
212
|
+
***
|
|
213
|
+
|
|
214
|
+
### polygonFeature()
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
polygonFeature(): Feature;
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Returns
|
|
221
|
+
|
|
222
|
+
`Feature`
|
|
223
|
+
|
|
224
|
+
***
|
|
225
|
+
|
|
226
|
+
### polygonFeatureCollection()
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
polygonFeatureCollection(): FeatureCollection;
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Returns
|
|
233
|
+
|
|
234
|
+
`FeatureCollection`
|
|
235
|
+
|
|
236
|
+
***
|
|
237
|
+
|
|
238
|
+
### polygonSource()
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
polygonSource(): GeoJSONSourceSpecification;
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Returns
|
|
245
|
+
|
|
246
|
+
`GeoJSONSourceSpecification`
|
|
247
|
+
|
|
248
|
+
***
|
|
249
|
+
|
|
250
|
+
### zoom()
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
zoom(): number;
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Returns
|
|
257
|
+
|
|
258
|
+
`number`
|
|
259
|
+
|
|
260
|
+
### <a id="LayerBase"></a>LayerBase
|
|
261
|
+
|
|
262
|
+
[**@xylabs/geo**](#../README)
|
|
263
|
+
|
|
264
|
+
***
|
|
265
|
+
|
|
266
|
+
## Type Parameters
|
|
267
|
+
|
|
268
|
+
### T
|
|
269
|
+
|
|
270
|
+
`T` *extends* `MapBox.Layer`
|
|
271
|
+
|
|
272
|
+
## Constructors
|
|
273
|
+
|
|
274
|
+
### Constructor
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
new LayerBase<T>(id, source): LayerBase<T>;
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Parameters
|
|
281
|
+
|
|
282
|
+
#### id
|
|
283
|
+
|
|
284
|
+
`string`
|
|
285
|
+
|
|
286
|
+
#### source
|
|
287
|
+
|
|
288
|
+
`string`
|
|
289
|
+
|
|
290
|
+
### Returns
|
|
291
|
+
|
|
292
|
+
`LayerBase`\<`T`\>
|
|
293
|
+
|
|
294
|
+
## Properties
|
|
295
|
+
|
|
296
|
+
### id
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
id: string;
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
***
|
|
303
|
+
|
|
304
|
+
### source
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
source: string;
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Methods
|
|
311
|
+
|
|
312
|
+
### update()
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
update(map, show): void;
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Parameters
|
|
319
|
+
|
|
320
|
+
#### map
|
|
321
|
+
|
|
322
|
+
`Map$1`
|
|
323
|
+
|
|
324
|
+
#### show
|
|
325
|
+
|
|
326
|
+
`boolean` = `true`
|
|
327
|
+
|
|
328
|
+
### Returns
|
|
329
|
+
|
|
330
|
+
`void`
|
|
331
|
+
|
|
332
|
+
***
|
|
333
|
+
|
|
334
|
+
### buildLayer()
|
|
335
|
+
|
|
336
|
+
```ts
|
|
337
|
+
abstract buildLayer(): T;
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Returns
|
|
341
|
+
|
|
342
|
+
`T`
|
|
343
|
+
|
|
344
|
+
### <a id="MercatorBoundingBox"></a>MercatorBoundingBox
|
|
345
|
+
|
|
346
|
+
[**@xylabs/geo**](#../README)
|
|
347
|
+
|
|
348
|
+
***
|
|
349
|
+
|
|
350
|
+
## Extends
|
|
351
|
+
|
|
352
|
+
- `LngLatBounds`
|
|
353
|
+
|
|
354
|
+
## Constructors
|
|
355
|
+
|
|
356
|
+
### Constructor
|
|
357
|
+
|
|
358
|
+
```ts
|
|
359
|
+
new MercatorBoundingBox(sw?, ne?): MercatorBoundingBox;
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Parameters
|
|
363
|
+
|
|
364
|
+
#### sw?
|
|
365
|
+
|
|
366
|
+
\[`number`, `number`, `number`, `number`\] | `LngLatLike` | \[`LngLatLike`, `LngLatLike`\]
|
|
367
|
+
|
|
368
|
+
#### ne?
|
|
369
|
+
|
|
370
|
+
`LngLatLike`
|
|
371
|
+
|
|
372
|
+
### Returns
|
|
373
|
+
|
|
374
|
+
`MercatorBoundingBox`
|
|
375
|
+
|
|
376
|
+
### Inherited from
|
|
377
|
+
|
|
378
|
+
```ts
|
|
379
|
+
MapBox.LngLatBounds.constructor
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### <a id="MercatorLngLat"></a>MercatorLngLat
|
|
383
|
+
|
|
384
|
+
[**@xylabs/geo**](#../README)
|
|
385
|
+
|
|
386
|
+
***
|
|
387
|
+
|
|
388
|
+
## Extends
|
|
389
|
+
|
|
390
|
+
- `LngLat`
|
|
391
|
+
|
|
392
|
+
## Constructors
|
|
393
|
+
|
|
394
|
+
### Constructor
|
|
395
|
+
|
|
396
|
+
```ts
|
|
397
|
+
new MercatorLngLat(lng, lat): MercatorLngLat;
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### Parameters
|
|
401
|
+
|
|
402
|
+
#### lng
|
|
403
|
+
|
|
404
|
+
`number`
|
|
405
|
+
|
|
406
|
+
#### lat
|
|
407
|
+
|
|
408
|
+
`number`
|
|
409
|
+
|
|
410
|
+
### Returns
|
|
411
|
+
|
|
412
|
+
`MercatorLngLat`
|
|
413
|
+
|
|
414
|
+
### Inherited from
|
|
415
|
+
|
|
416
|
+
```ts
|
|
417
|
+
MapBox.LngLat.constructor
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### functions
|
|
421
|
+
|
|
422
|
+
### <a id="boundingBoxToBoundary"></a>boundingBoxToBoundary
|
|
423
|
+
|
|
424
|
+
[**@xylabs/geo**](#../README)
|
|
425
|
+
|
|
426
|
+
***
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
function boundingBoxToBoundary(box): MercatorBoundary;
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
## Parameters
|
|
433
|
+
|
|
434
|
+
### box
|
|
435
|
+
|
|
436
|
+
[`MercatorBoundingBox`](#../classes/MercatorBoundingBox)
|
|
437
|
+
|
|
438
|
+
## Returns
|
|
439
|
+
|
|
440
|
+
[`MercatorBoundary`](#../type-aliases/MercatorBoundary)
|
|
441
|
+
|
|
442
|
+
### <a id="boundingBoxToCenter"></a>boundingBoxToCenter
|
|
443
|
+
|
|
444
|
+
[**@xylabs/geo**](#../README)
|
|
445
|
+
|
|
446
|
+
***
|
|
447
|
+
|
|
448
|
+
```ts
|
|
449
|
+
function boundingBoxToCenter(boundingBox, decimal): number[];
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
## Parameters
|
|
453
|
+
|
|
454
|
+
### boundingBox
|
|
455
|
+
|
|
456
|
+
[`MercatorBoundingBox`](#../classes/MercatorBoundingBox)
|
|
457
|
+
|
|
458
|
+
### decimal
|
|
459
|
+
|
|
460
|
+
`number` = `6`
|
|
461
|
+
|
|
462
|
+
## Returns
|
|
463
|
+
|
|
464
|
+
`number`[]
|
|
465
|
+
|
|
466
|
+
### <a id="boundingBoxToPolygon"></a>boundingBoxToPolygon
|
|
467
|
+
|
|
468
|
+
[**@xylabs/geo**](#../README)
|
|
469
|
+
|
|
470
|
+
***
|
|
471
|
+
|
|
472
|
+
```ts
|
|
473
|
+
function boundingBoxToPolygon(box): Polygon;
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
## Parameters
|
|
477
|
+
|
|
478
|
+
### box
|
|
479
|
+
|
|
480
|
+
[`MercatorBoundingBox`](#../classes/MercatorBoundingBox)
|
|
481
|
+
|
|
482
|
+
## Returns
|
|
483
|
+
|
|
484
|
+
`Polygon`
|
|
485
|
+
|
|
486
|
+
### <a id="hasSiblings"></a>hasSiblings
|
|
487
|
+
|
|
488
|
+
[**@xylabs/geo**](#../README)
|
|
489
|
+
|
|
490
|
+
***
|
|
491
|
+
|
|
492
|
+
```ts
|
|
493
|
+
function hasSiblings(tiles, tile): boolean;
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
## Parameters
|
|
497
|
+
|
|
498
|
+
### tiles
|
|
499
|
+
|
|
500
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)[]
|
|
501
|
+
|
|
502
|
+
### tile
|
|
503
|
+
|
|
504
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
505
|
+
|
|
506
|
+
## Returns
|
|
507
|
+
|
|
508
|
+
`boolean`
|
|
509
|
+
|
|
510
|
+
### <a id="tileFromPoint"></a>tileFromPoint
|
|
511
|
+
|
|
512
|
+
[**@xylabs/geo**](#../README)
|
|
513
|
+
|
|
514
|
+
***
|
|
515
|
+
|
|
516
|
+
```ts
|
|
517
|
+
function tileFromPoint(point, z): number[];
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
## Parameters
|
|
521
|
+
|
|
522
|
+
### point
|
|
523
|
+
|
|
524
|
+
[`MercatorLngLat`](#../classes/MercatorLngLat)
|
|
525
|
+
|
|
526
|
+
### z
|
|
527
|
+
|
|
528
|
+
`number`
|
|
529
|
+
|
|
530
|
+
## Returns
|
|
531
|
+
|
|
532
|
+
`number`[]
|
|
533
|
+
|
|
534
|
+
### <a id="tileFromQuadkey"></a>tileFromQuadkey
|
|
535
|
+
|
|
536
|
+
[**@xylabs/geo**](#../README)
|
|
537
|
+
|
|
538
|
+
***
|
|
539
|
+
|
|
540
|
+
```ts
|
|
541
|
+
function tileFromQuadkey(quadkey): number[];
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
## Parameters
|
|
545
|
+
|
|
546
|
+
### quadkey
|
|
547
|
+
|
|
548
|
+
`string`
|
|
549
|
+
|
|
550
|
+
## Returns
|
|
551
|
+
|
|
552
|
+
`number`[]
|
|
553
|
+
|
|
554
|
+
### <a id="tileToBoundingBox"></a>tileToBoundingBox
|
|
555
|
+
|
|
556
|
+
[**@xylabs/geo**](#../README)
|
|
557
|
+
|
|
558
|
+
***
|
|
559
|
+
|
|
560
|
+
```ts
|
|
561
|
+
function tileToBoundingBox(tile): MercatorBoundingBox;
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
## Parameters
|
|
565
|
+
|
|
566
|
+
### tile
|
|
567
|
+
|
|
568
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
569
|
+
|
|
570
|
+
## Returns
|
|
571
|
+
|
|
572
|
+
[`MercatorBoundingBox`](#../classes/MercatorBoundingBox)
|
|
573
|
+
|
|
574
|
+
### <a id="tileToChildren"></a>tileToChildren
|
|
575
|
+
|
|
576
|
+
[**@xylabs/geo**](#../README)
|
|
577
|
+
|
|
578
|
+
***
|
|
579
|
+
|
|
580
|
+
```ts
|
|
581
|
+
function tileToChildren(tile): number[][];
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
## Parameters
|
|
585
|
+
|
|
586
|
+
### tile
|
|
587
|
+
|
|
588
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
589
|
+
|
|
590
|
+
## Returns
|
|
591
|
+
|
|
592
|
+
`number`[][]
|
|
593
|
+
|
|
594
|
+
### <a id="tileToGeoJson"></a>tileToGeoJson
|
|
595
|
+
|
|
596
|
+
[**@xylabs/geo**](#../README)
|
|
597
|
+
|
|
598
|
+
***
|
|
599
|
+
|
|
600
|
+
```ts
|
|
601
|
+
function tileToGeoJson(tile): Polygon;
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
## Parameters
|
|
605
|
+
|
|
606
|
+
### tile
|
|
607
|
+
|
|
608
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
609
|
+
|
|
610
|
+
## Returns
|
|
611
|
+
|
|
612
|
+
`Polygon`
|
|
613
|
+
|
|
614
|
+
### <a id="tileToParent"></a>tileToParent
|
|
615
|
+
|
|
616
|
+
[**@xylabs/geo**](#../README)
|
|
617
|
+
|
|
618
|
+
***
|
|
619
|
+
|
|
620
|
+
```ts
|
|
621
|
+
function tileToParent(tile): MercatorTile;
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
## Parameters
|
|
625
|
+
|
|
626
|
+
### tile
|
|
627
|
+
|
|
628
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
629
|
+
|
|
630
|
+
## Returns
|
|
631
|
+
|
|
632
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
633
|
+
|
|
634
|
+
### <a id="tileToPoint"></a>tileToPoint
|
|
635
|
+
|
|
636
|
+
[**@xylabs/geo**](#../README)
|
|
637
|
+
|
|
638
|
+
***
|
|
639
|
+
|
|
640
|
+
```ts
|
|
641
|
+
function tileToPoint(tile): MercatorLngLat;
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
## Parameters
|
|
645
|
+
|
|
646
|
+
### tile
|
|
647
|
+
|
|
648
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
649
|
+
|
|
650
|
+
## Returns
|
|
651
|
+
|
|
652
|
+
[`MercatorLngLat`](#../classes/MercatorLngLat)
|
|
653
|
+
|
|
654
|
+
### <a id="tileToQuadkey"></a>tileToQuadkey
|
|
655
|
+
|
|
656
|
+
[**@xylabs/geo**](#../README)
|
|
657
|
+
|
|
658
|
+
***
|
|
659
|
+
|
|
660
|
+
```ts
|
|
661
|
+
function tileToQuadkey(tile): string;
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
## Parameters
|
|
665
|
+
|
|
666
|
+
### tile
|
|
667
|
+
|
|
668
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
669
|
+
|
|
670
|
+
## Returns
|
|
671
|
+
|
|
672
|
+
`string`
|
|
673
|
+
|
|
674
|
+
### <a id="tileToSiblings"></a>tileToSiblings
|
|
675
|
+
|
|
676
|
+
[**@xylabs/geo**](#../README)
|
|
677
|
+
|
|
678
|
+
***
|
|
679
|
+
|
|
680
|
+
```ts
|
|
681
|
+
function tileToSiblings(tile): MercatorTile[];
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
## Parameters
|
|
685
|
+
|
|
686
|
+
### tile
|
|
687
|
+
|
|
688
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
689
|
+
|
|
690
|
+
## Returns
|
|
691
|
+
|
|
692
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)[]
|
|
693
|
+
|
|
694
|
+
### <a id="tilesEqual"></a>tilesEqual
|
|
695
|
+
|
|
696
|
+
[**@xylabs/geo**](#../README)
|
|
697
|
+
|
|
698
|
+
***
|
|
699
|
+
|
|
700
|
+
```ts
|
|
701
|
+
function tilesEqual(tile1, tile2): boolean;
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
## Parameters
|
|
705
|
+
|
|
706
|
+
### tile1
|
|
707
|
+
|
|
708
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
709
|
+
|
|
710
|
+
### tile2
|
|
711
|
+
|
|
712
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
713
|
+
|
|
714
|
+
## Returns
|
|
715
|
+
|
|
716
|
+
`boolean`
|
|
717
|
+
|
|
718
|
+
### <a id="tilesFromBoundingBox"></a>tilesFromBoundingBox
|
|
719
|
+
|
|
720
|
+
[**@xylabs/geo**](#../README)
|
|
721
|
+
|
|
722
|
+
***
|
|
723
|
+
|
|
724
|
+
```ts
|
|
725
|
+
function tilesFromBoundingBox(box, zoom): MercatorTile[];
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
## Parameters
|
|
729
|
+
|
|
730
|
+
### box
|
|
731
|
+
|
|
732
|
+
[`MercatorBoundingBox`](#../classes/MercatorBoundingBox)
|
|
733
|
+
|
|
734
|
+
### zoom
|
|
735
|
+
|
|
736
|
+
`number`
|
|
737
|
+
|
|
738
|
+
## Returns
|
|
739
|
+
|
|
740
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)[]
|
|
741
|
+
|
|
742
|
+
### <a id="tilesHasTile"></a>tilesHasTile
|
|
743
|
+
|
|
744
|
+
[**@xylabs/geo**](#../README)
|
|
745
|
+
|
|
746
|
+
***
|
|
747
|
+
|
|
748
|
+
```ts
|
|
749
|
+
function tilesHasTile(tiles, tile): boolean;
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
## Parameters
|
|
753
|
+
|
|
754
|
+
### tiles
|
|
755
|
+
|
|
756
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)[]
|
|
757
|
+
|
|
758
|
+
### tile
|
|
759
|
+
|
|
760
|
+
[`MercatorTile`](#../type-aliases/MercatorTile)
|
|
761
|
+
|
|
762
|
+
## Returns
|
|
763
|
+
|
|
764
|
+
`boolean`
|
|
765
|
+
|
|
766
|
+
### type-aliases
|
|
767
|
+
|
|
768
|
+
### <a id="MercatorBoundary"></a>MercatorBoundary
|
|
769
|
+
|
|
770
|
+
[**@xylabs/geo**](#../README)
|
|
771
|
+
|
|
772
|
+
***
|
|
773
|
+
|
|
774
|
+
```ts
|
|
775
|
+
type MercatorBoundary = MercatorLngLat[];
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
### <a id="MercatorTile"></a>MercatorTile
|
|
779
|
+
|
|
780
|
+
[**@xylabs/geo**](#../README)
|
|
781
|
+
|
|
782
|
+
***
|
|
783
|
+
|
|
784
|
+
```ts
|
|
785
|
+
type MercatorTile = number[];
|
|
786
|
+
```
|
|
787
|
+
|
|
788
|
+
### variables
|
|
789
|
+
|
|
790
|
+
### <a id="d2r"></a>d2r
|
|
791
|
+
|
|
792
|
+
[**@xylabs/geo**](#../README)
|
|
793
|
+
|
|
794
|
+
***
|
|
795
|
+
|
|
796
|
+
```ts
|
|
797
|
+
const d2r: number;
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
### <a id="r2d"></a>r2d
|
|
801
|
+
|
|
802
|
+
[**@xylabs/geo**](#../README)
|
|
803
|
+
|
|
804
|
+
***
|
|
805
|
+
|
|
806
|
+
```ts
|
|
807
|
+
const r2d: number;
|
|
808
|
+
```
|
|
20
809
|
|
|
21
|
-
Coming Soon!
|
|
22
810
|
|
|
23
811
|
Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
|
|
24
812
|
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -142,13 +142,13 @@ var tileToPoint = (tile) => {
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
// src/mercator/tile/to/quadkey.ts
|
|
145
|
-
var tileToQuadkey = (
|
|
145
|
+
var tileToQuadkey = ([tileX, tileY, tileZoom]) => {
|
|
146
146
|
let index = "";
|
|
147
|
-
for (let z =
|
|
147
|
+
for (let z = tileZoom; z > 0; z--) {
|
|
148
148
|
let b = 0;
|
|
149
149
|
const mask = 1 << z - 1;
|
|
150
|
-
if ((
|
|
151
|
-
if ((
|
|
150
|
+
if ((tileX & mask) !== 0) b++;
|
|
151
|
+
if ((tileY & mask) !== 0) b += 2;
|
|
152
152
|
index += b.toString();
|
|
153
153
|
}
|
|
154
154
|
return index;
|
|
@@ -160,8 +160,8 @@ var tileToSiblings = (tile) => {
|
|
|
160
160
|
};
|
|
161
161
|
|
|
162
162
|
// src/mercator/tiles/equal.ts
|
|
163
|
-
var tilesEqual = (
|
|
164
|
-
return
|
|
163
|
+
var tilesEqual = ([x1, y1, zoom1], [x2, y2, zoom2]) => {
|
|
164
|
+
return x1 === x2 && y1 === y2 && zoom1 === zoom2;
|
|
165
165
|
};
|
|
166
166
|
|
|
167
167
|
// src/mercator/tiles/from/boundingbox.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/GeoJson.ts","../../src/mercator/boundingbox/to/boundary.ts","../../src/mercator/boundingbox/to/center.ts","../../src/mercator/boundingbox/to/polygon.ts","../../src/mercator/constants.ts","../../src/mercator/tile/from/point.ts","../../src/mercator/tile/from/quadkey.ts","../../src/mercator/tile/to/boundingbox.ts","../../src/mercator/types.ts","../../src/mercator/tile/to/children.ts","../../src/mercator/tile/to/geoJson.ts","../../src/mercator/tile/to/parent.ts","../../src/mercator/tile/to/point.ts","../../src/mercator/tile/to/quadkey.ts","../../src/mercator/tile/to/siblings.ts","../../src/mercator/tiles/equal.ts","../../src/mercator/tiles/from/boundingbox.ts","../../src/mercator/tiles/hasTile.ts","../../src/mercator/tiles/hasSiblings.ts","../../src/LayerBase.ts"],"sourcesContent":["import type {\n Feature, FeatureCollection, Geometry, Point, Polygon,\n} from 'geojson'\nimport MapBox from 'mapbox-gl'\n\nimport {\n boundingBoxToCenter, boundingBoxToPolygon, tileFromQuadkey, tileToBoundingBox,\n} from './mercator/index.ts'\n\nclass GeoJson {\n private _lngLat?: MapBox.LngLat\n private _point?: Point\n private _polygon?: Polygon\n private _zoom?: number\n\n private quadkey: string\n\n constructor(quadkey: string) {\n this.quadkey = quadkey\n }\n\n static featureCollection(features: Feature[]): FeatureCollection {\n return {\n features,\n type: 'FeatureCollection',\n }\n }\n\n static featuresSource(data: FeatureCollection): MapBox.GeoJSONSourceSpecification {\n return {\n data,\n type: 'geojson',\n }\n }\n\n static geometryFeature(geometry: Geometry): Feature {\n return {\n geometry,\n properties: {},\n type: 'Feature',\n }\n }\n\n center(): MapBox.LngLat {\n if (!this._lngLat) {\n const tile = tileFromQuadkey(this.quadkey)\n const bb = tileToBoundingBox(tile)\n const point = boundingBoxToCenter(bb)\n this._lngLat = new MapBox.LngLat(point[0], point[1])\n }\n return this._lngLat\n }\n\n point(): Point {\n if (!this._point) {\n this._point = {\n coordinates: this.center().toArray(),\n type: 'Point',\n }\n }\n return this._point\n }\n\n pointFeature(): Feature {\n return GeoJson.geometryFeature(this.point())\n }\n\n pointFeatureCollection(): FeatureCollection {\n return GeoJson.featureCollection([this.pointFeature()])\n }\n\n pointSource(): MapBox.GeoJSONSourceSpecification {\n return {\n data: this.pointFeatureCollection(),\n type: 'geojson',\n }\n }\n\n polygon(): Polygon {\n if (!this._polygon) {\n this._polygon = boundingBoxToPolygon(tileToBoundingBox(tileFromQuadkey(this.quadkey))) as Polygon\n }\n return this._polygon\n }\n\n polygonFeature(): Feature {\n return GeoJson.geometryFeature(this.polygon())\n }\n\n polygonFeatureCollection(): FeatureCollection {\n return GeoJson.featureCollection([this.polygonFeature()])\n }\n\n polygonSource(): MapBox.GeoJSONSourceSpecification {\n return GeoJson.featuresSource(this.polygonFeatureCollection())\n }\n\n zoom(): number {\n this._zoom = this._zoom ?? tileFromQuadkey(this.quadkey)[2]\n return this._zoom\n }\n}\n\nexport { GeoJson }\n","import type { MercatorBoundary, MercatorBoundingBox } from '../../types.ts'\n\nexport const boundingBoxToBoundary = (box: MercatorBoundingBox): MercatorBoundary => {\n return [box.getNorthWest(), box.getNorthEast(), box.getSouthEast(), box.getSouthWest(), box.getNorthWest()]\n}\n","import type { MercatorBoundingBox } from '../../types.ts'\n\nexport const boundingBoxToCenter = (boundingBox: MercatorBoundingBox, decimal = 6) => {\n const west = boundingBox.getWest()\n const south = boundingBox.getSouth()\n const east = boundingBox.getEast()\n const north = boundingBox.getNorth()\n let lng = (west - east) / 2 + east\n let lat = (south - north) / 2 + north\n if (decimal !== undefined && decimal !== null) {\n lng = Number(lng.toFixed(decimal))\n lat = Number(lat.toFixed(decimal))\n }\n return [lng, lat]\n}\n","import type { Polygon } from 'geojson'\n\nimport type { MercatorBoundingBox, MercatorLngLat } from '../../types.ts'\nimport { boundingBoxToBoundary } from './boundary.ts'\n\nexport const boundingBoxToPolygon = (box: MercatorBoundingBox): Polygon => {\n const boundry = boundingBoxToBoundary(box)\n return {\n coordinates: [boundry.map((lnglng: MercatorLngLat) => lnglng.toArray())],\n type: 'Polygon',\n }\n}\n","const d2r = Math.PI / 180\nconst r2d = 180 / Math.PI\n\nexport { d2r, r2d }\n","import { d2r } from '../../constants.ts'\nimport type { MercatorLngLat } from '../../types.ts'\n\nconst pointToTileFraction = (point: MercatorLngLat, z: number) => {\n const sin = Math.sin(point.lat * d2r)\n const z2 = Math.pow(2, z)\n let x = z2 * (point.lng / 360 + 0.5)\n const y = z2 * (0.5 - (0.25 * Math.log((1 + sin) / (1 - sin))) / Math.PI)\n\n // Wrap Tile X\n x = x % z2\n if (x < 0) x = x + z2\n return [x, y, z]\n}\n\nconst tileFromPoint = (point: MercatorLngLat, z: number) => {\n const tile = pointToTileFraction(point, z)\n tile[0] = Math.floor(tile[0])\n tile[1] = Math.floor(tile[1])\n if (tile[0] < 0) {\n tile[0] = 0\n }\n if (tile[1] < 0) {\n tile[1] = 0\n }\n return tile\n}\n\nexport { tileFromPoint }\n","const tileFromQuadkey = (quadkey: string) => {\n let x = 0\n let y = 0\n const z = quadkey.length\n\n for (let i = z; i > 0; i--) {\n const mask = 1 << (i - 1)\n const q = +quadkey[z - i]\n if (q === 1) x |= mask\n if (q === 2) y |= mask\n if (q === 3) {\n x |= mask\n y |= mask\n }\n }\n return [x, y, z]\n}\n\nexport { tileFromQuadkey }\n","import MapBox from 'mapbox-gl'\n\nimport { r2d } from '../../constants.ts'\nimport type { MercatorTile } from '../../types.ts'\nimport { MercatorBoundingBox } from '../../types.ts'\n\nconst toLongitude = (x: number, z: number): number => {\n return (x / Math.pow(2, z)) * 360 - 180\n}\n\nconst toLatitude = (y: number, z: number): number => {\n const n = Math.PI - (2 * Math.PI * y) / Math.pow(2, z)\n return r2d * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)))\n}\n\nconst tileToBoundingBox = (tile: MercatorTile): MercatorBoundingBox => {\n const e = toLongitude(tile[0] + 1, tile[2])\n const w = toLongitude(tile[0], tile[2])\n const s = toLatitude(tile[1] + 1, tile[2])\n const n = toLatitude(tile[1], tile[2])\n return new MercatorBoundingBox(new MapBox.LngLat(w, s), new MapBox.LngLat(e, n))\n}\n\nexport { tileToBoundingBox }\n","import MapBox from 'mapbox-gl'\n\ntype MercatorTile = number[]\ntype MercatorBoundary = MercatorLngLat[]\nclass MercatorBoundingBox extends MapBox.LngLatBounds {}\nclass MercatorLngLat extends MapBox.LngLat {}\n\nexport { MercatorBoundingBox, MercatorLngLat }\nexport type { MercatorBoundary, MercatorTile }\n","import type { MercatorTile } from '../../types.ts'\n\nconst tileToChildren = (tile: MercatorTile) => {\n return [\n [tile[0] * 2, tile[1] * 2, tile[2] + 1],\n [tile[0] * 2 + 1, tile[1] * 2, tile[2] + 1],\n [tile[0] * 2 + 1, tile[1] * 2 + 1, tile[2] + 1],\n [tile[0] * 2, tile[1] * 2 + 1, tile[2] + 1],\n ]\n}\n\nexport { tileToChildren }\n","import type { Polygon, Position } from 'geojson'\n\nimport type { MercatorTile } from '../../types.ts'\nimport { tileToBoundingBox } from './boundingbox.ts'\n\nconst tileToGeoJson = (tile: MercatorTile): Polygon => {\n const box = tileToBoundingBox(tile)\n const poly: Polygon = {\n coordinates: [\n [\n box.getNorthWest().toArray() as Position,\n box.getNorthEast().toArray() as Position,\n box.getSouthEast().toArray() as Position,\n box.getSouthWest().toArray() as Position,\n box.getNorthWest().toArray() as Position,\n ],\n ],\n type: 'Polygon',\n }\n return poly\n}\n\nexport { tileToGeoJson }\n","import type { MercatorTile } from '../../types.ts'\n\nconst tileToParent = (tile: MercatorTile): MercatorTile => {\n return [tile[0] >> 1, tile[1] >> 1, tile[2] - 1]\n}\n\nexport { tileToParent }\n","import type { MercatorLngLat, MercatorTile } from '../../types.ts'\nimport { tileToBoundingBox } from './boundingbox.ts'\n\nconst tileToPoint = (tile: MercatorTile): MercatorLngLat => {\n const boundingBox = tileToBoundingBox(tile)\n boundingBox.getCenter()\n return boundingBox.getCenter()\n}\n\nexport { tileToPoint }\n","import type { MercatorTile } from '../../types.ts'\n\nconst tileToQuadkey = (tile: MercatorTile): string => {\n let index = ''\n for (let z = tile[2]; z > 0; z--) {\n let b = 0\n const mask = 1 << (z - 1)\n if ((tile[0] & mask) !== 0) b++\n if ((tile[1] & mask) !== 0) b += 2\n index += b.toString()\n }\n return index\n}\n\nexport { tileToQuadkey }\n","import type { MercatorTile } from '../../types.ts'\nimport { tileToChildren } from './children.ts'\nimport { tileToParent } from './parent.ts'\n\nconst tileToSiblings = (tile: MercatorTile): MercatorTile[] => {\n return tileToChildren(tileToParent(tile))\n}\n\nexport { tileToSiblings }\n","import type { MercatorTile } from '../types.ts'\n\nexport const tilesEqual = (tile1: MercatorTile, tile2: MercatorTile) => {\n return tile1[0] === tile2[0] && tile1[1] === tile2[1] && tile1[2] === tile2[2]\n}\n","import { tileFromPoint } from '../../tile/index.ts'\nimport type { MercatorBoundingBox, MercatorTile } from '../../types.ts'\n\nconst tilesFromBoundingBox = (box: MercatorBoundingBox, zoom: number): MercatorTile[] => {\n const nw = tileFromPoint(box.getNorthWest(), zoom)\n const se = tileFromPoint(box.getSouthEast(), zoom)\n const size = Math.pow(2, zoom)\n\n let minX = nw[0]\n let maxX = se[0]\n let minY = nw[1]\n let maxY = se[1]\n\n // in case of horizontal wrapping\n if (minX >= maxX) {\n maxX = maxX + size\n }\n\n if (zoom < 4) {\n minX = 0\n maxX = size - 1\n minY = 0\n maxY = size - 1\n }\n\n const result: MercatorTile[] = []\n\n for (let x = minX; x <= maxX; x++) {\n for (let y = minY; y <= maxY; y++) {\n result.push([x % size, y, zoom])\n }\n }\n\n return result\n}\n\nexport { tilesFromBoundingBox }\n","import type { MercatorTile } from '../types.ts'\nimport { tilesEqual } from './equal.ts'\n\nexport const tilesHasTile = (tiles: MercatorTile[], tile: MercatorTile) => {\n for (const tileToCheck of tiles) {\n if (tilesEqual(tileToCheck, tile)) return true\n }\n return false\n}\n","import { tileToSiblings } from '../tile/index.ts'\nimport type { MercatorTile } from '../types.ts'\nimport { tilesHasTile } from './hasTile.ts'\n\nexport const hasSiblings = (tiles: MercatorTile[], tile: MercatorTile) => {\n const siblings = tileToSiblings(tile)\n for (const sibling of siblings) {\n if (!tilesHasTile(tiles, sibling)) return false\n }\n return true\n}\n","import type MapBox from 'mapbox-gl'\n\nexport abstract class LayerBase<T extends MapBox.Layer> {\n id: string\n source: string\n\n constructor(id: string, source: string) {\n this.id = id\n this.source = source\n }\n\n update(map: MapBox.Map, show = true) {\n if (map.getLayer(this.id)) {\n map.removeLayer(this.id)\n }\n if (show) {\n map.addLayer(this.buildLayer())\n }\n }\n\n abstract buildLayer(): T\n}\n"],"mappings":";AAGA,OAAOA,aAAY;;;ACDZ,IAAM,wBAAwB,CAAC,QAA+C;AAC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son.ts","../../src/mercator/boundingbox/to/boundary.ts","../../src/mercator/boundingbox/to/center.ts","../../src/mercator/boundingbox/to/polygon.ts","../../src/mercator/constants.ts","../../src/mercator/tile/from/point.ts","../../src/mercator/tile/from/quadkey.ts","../../src/mercator/tile/to/boundingbox.ts","../../src/mercator/types.ts","../../src/mercator/tile/to/children.ts","../../src/mercator/tile/to/geoJson.ts","../../src/mercator/tile/to/parent.ts","../../src/mercator/tile/to/point.ts","../../src/mercator/tile/to/quadkey.ts","../../src/mercator/tile/to/siblings.ts","../../src/mercator/tiles/equal.ts","../../src/mercator/tiles/from/boundingbox.ts","../../src/mercator/tiles/hasTile.ts","../../src/mercator/tiles/hasSiblings.ts","../../src/LayerBase.ts"],"sourcesContent":["import type {\n Feature, FeatureCollection, Geometry, Point, Polygon,\n} from 'geojson'\nimport MapBox from 'mapbox-gl'\n\nimport {\n boundingBoxToCenter, boundingBoxToPolygon, tileFromQuadkey, tileToBoundingBox,\n} from './mercator/index.ts'\n\nclass GeoJson {\n private _lngLat?: MapBox.LngLat\n private _point?: Point\n private _polygon?: Polygon\n private _zoom?: number\n\n private quadkey: string\n\n constructor(quadkey: string) {\n this.quadkey = quadkey\n }\n\n static featureCollection(features: Feature[]): FeatureCollection {\n return {\n features,\n type: 'FeatureCollection',\n }\n }\n\n static featuresSource(data: FeatureCollection): MapBox.GeoJSONSourceSpecification {\n return {\n data,\n type: 'geojson',\n }\n }\n\n static geometryFeature(geometry: Geometry): Feature {\n return {\n geometry,\n properties: {},\n type: 'Feature',\n }\n }\n\n center(): MapBox.LngLat {\n if (!this._lngLat) {\n const tile = tileFromQuadkey(this.quadkey)\n const bb = tileToBoundingBox(tile)\n const point = boundingBoxToCenter(bb)\n this._lngLat = new MapBox.LngLat(point[0], point[1])\n }\n return this._lngLat\n }\n\n point(): Point {\n if (!this._point) {\n this._point = {\n coordinates: this.center().toArray(),\n type: 'Point',\n }\n }\n return this._point\n }\n\n pointFeature(): Feature {\n return GeoJson.geometryFeature(this.point())\n }\n\n pointFeatureCollection(): FeatureCollection {\n return GeoJson.featureCollection([this.pointFeature()])\n }\n\n pointSource(): MapBox.GeoJSONSourceSpecification {\n return {\n data: this.pointFeatureCollection(),\n type: 'geojson',\n }\n }\n\n polygon(): Polygon {\n if (!this._polygon) {\n this._polygon = boundingBoxToPolygon(tileToBoundingBox(tileFromQuadkey(this.quadkey))) as Polygon\n }\n return this._polygon\n }\n\n polygonFeature(): Feature {\n return GeoJson.geometryFeature(this.polygon())\n }\n\n polygonFeatureCollection(): FeatureCollection {\n return GeoJson.featureCollection([this.polygonFeature()])\n }\n\n polygonSource(): MapBox.GeoJSONSourceSpecification {\n return GeoJson.featuresSource(this.polygonFeatureCollection())\n }\n\n zoom(): number {\n this._zoom = this._zoom ?? tileFromQuadkey(this.quadkey)[2]\n return this._zoom\n }\n}\n\nexport { GeoJson }\n","import type { MercatorBoundary, MercatorBoundingBox } from '../../types.ts'\n\nexport const boundingBoxToBoundary = (box: MercatorBoundingBox): MercatorBoundary => {\n return [box.getNorthWest(), box.getNorthEast(), box.getSouthEast(), box.getSouthWest(), box.getNorthWest()]\n}\n","import type { MercatorBoundingBox } from '../../types.ts'\n\nexport const boundingBoxToCenter = (boundingBox: MercatorBoundingBox, decimal = 6) => {\n const west = boundingBox.getWest()\n const south = boundingBox.getSouth()\n const east = boundingBox.getEast()\n const north = boundingBox.getNorth()\n let lng = (west - east) / 2 + east\n let lat = (south - north) / 2 + north\n if (decimal !== undefined && decimal !== null) {\n lng = Number(lng.toFixed(decimal))\n lat = Number(lat.toFixed(decimal))\n }\n return [lng, lat]\n}\n","import type { Polygon } from 'geojson'\n\nimport type { MercatorBoundingBox, MercatorLngLat } from '../../types.ts'\nimport { boundingBoxToBoundary } from './boundary.ts'\n\nexport const boundingBoxToPolygon = (box: MercatorBoundingBox): Polygon => {\n const boundry = boundingBoxToBoundary(box)\n return {\n coordinates: [boundry.map((lnglng: MercatorLngLat) => lnglng.toArray())],\n type: 'Polygon',\n }\n}\n","const d2r = Math.PI / 180\nconst r2d = 180 / Math.PI\n\nexport { d2r, r2d }\n","import { d2r } from '../../constants.ts'\nimport type { MercatorLngLat } from '../../types.ts'\n\nconst pointToTileFraction = (point: MercatorLngLat, z: number) => {\n const sin = Math.sin(point.lat * d2r)\n const z2 = Math.pow(2, z)\n let x = z2 * (point.lng / 360 + 0.5)\n const y = z2 * (0.5 - (0.25 * Math.log((1 + sin) / (1 - sin))) / Math.PI)\n\n // Wrap Tile X\n x = x % z2\n if (x < 0) x = x + z2\n return [x, y, z]\n}\n\nconst tileFromPoint = (point: MercatorLngLat, z: number) => {\n const tile = pointToTileFraction(point, z)\n tile[0] = Math.floor(tile[0])\n tile[1] = Math.floor(tile[1])\n if (tile[0] < 0) {\n tile[0] = 0\n }\n if (tile[1] < 0) {\n tile[1] = 0\n }\n return tile\n}\n\nexport { tileFromPoint }\n","import type { MercatorTile } from '../../types.ts'\n\nconst tileFromQuadkey = (quadkey: string): MercatorTile => {\n let x = 0\n let y = 0\n const z = quadkey.length\n\n for (let i = z; i > 0; i--) {\n const mask = 1 << (i - 1)\n const q = +quadkey[z - i]\n if (q === 1) x |= mask\n if (q === 2) y |= mask\n if (q === 3) {\n x |= mask\n y |= mask\n }\n }\n return [x, y, z]\n}\n\nexport { tileFromQuadkey }\n","import MapBox from 'mapbox-gl'\n\nimport { r2d } from '../../constants.ts'\nimport type { MercatorTile } from '../../types.ts'\nimport { MercatorBoundingBox } from '../../types.ts'\n\nconst toLongitude = (x: number, z: number): number => {\n return (x / Math.pow(2, z)) * 360 - 180\n}\n\nconst toLatitude = (y: number, z: number): number => {\n const n = Math.PI - (2 * Math.PI * y) / Math.pow(2, z)\n return r2d * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)))\n}\n\nconst tileToBoundingBox = (tile: MercatorTile): MercatorBoundingBox => {\n const e = toLongitude(tile[0] + 1, tile[2])\n const w = toLongitude(tile[0], tile[2])\n const s = toLatitude(tile[1] + 1, tile[2])\n const n = toLatitude(tile[1], tile[2])\n return new MercatorBoundingBox(new MapBox.LngLat(w, s), new MapBox.LngLat(e, n))\n}\n\nexport { tileToBoundingBox }\n","import MapBox from 'mapbox-gl'\n\ntype MercatorTile = readonly [x: number, y: number, zoom: number]\ntype MercatorBoundary = MercatorLngLat[]\nclass MercatorBoundingBox extends MapBox.LngLatBounds {}\nclass MercatorLngLat extends MapBox.LngLat {}\n\nexport { MercatorBoundingBox, MercatorLngLat }\nexport type { MercatorBoundary, MercatorTile }\n","import type { MercatorTile } from '../../types.ts'\n\nconst tileToChildren = (tile: MercatorTile): MercatorTile[] => {\n return [\n [tile[0] * 2, tile[1] * 2, tile[2] + 1],\n [tile[0] * 2 + 1, tile[1] * 2, tile[2] + 1],\n [tile[0] * 2 + 1, tile[1] * 2 + 1, tile[2] + 1],\n [tile[0] * 2, tile[1] * 2 + 1, tile[2] + 1],\n ]\n}\n\nexport { tileToChildren }\n","import type { Polygon, Position } from 'geojson'\n\nimport type { MercatorTile } from '../../types.ts'\nimport { tileToBoundingBox } from './boundingbox.ts'\n\nconst tileToGeoJson = (tile: MercatorTile): Polygon => {\n const box = tileToBoundingBox(tile)\n const poly: Polygon = {\n coordinates: [\n [\n box.getNorthWest().toArray() as Position,\n box.getNorthEast().toArray() as Position,\n box.getSouthEast().toArray() as Position,\n box.getSouthWest().toArray() as Position,\n box.getNorthWest().toArray() as Position,\n ],\n ],\n type: 'Polygon',\n }\n return poly\n}\n\nexport { tileToGeoJson }\n","import type { MercatorTile } from '../../types.ts'\n\nconst tileToParent = (tile: MercatorTile): MercatorTile => {\n return [tile[0] >> 1, tile[1] >> 1, tile[2] - 1]\n}\n\nexport { tileToParent }\n","import type { MercatorLngLat, MercatorTile } from '../../types.ts'\nimport { tileToBoundingBox } from './boundingbox.ts'\n\nconst tileToPoint = (tile: MercatorTile): MercatorLngLat => {\n const boundingBox = tileToBoundingBox(tile)\n boundingBox.getCenter()\n return boundingBox.getCenter()\n}\n\nexport { tileToPoint }\n","import type { MercatorTile } from '../../types.ts'\n\nconst tileToQuadkey = ([tileX, tileY, tileZoom]: MercatorTile): string => {\n let index = ''\n for (let z = tileZoom; z > 0; z--) {\n let b = 0\n const mask = 1 << (z - 1)\n if ((tileX & mask) !== 0) b++\n if ((tileY & mask) !== 0) b += 2\n index += b.toString()\n }\n return index\n}\n\nexport { tileToQuadkey }\n","import type { MercatorTile } from '../../types.ts'\nimport { tileToChildren } from './children.ts'\nimport { tileToParent } from './parent.ts'\n\nconst tileToSiblings = (tile: MercatorTile): MercatorTile[] => {\n return tileToChildren(tileToParent(tile))\n}\n\nexport { tileToSiblings }\n","import type { MercatorTile } from '../types.ts'\n\nexport const tilesEqual = /* @__PURE__ */ ([x1, y1, zoom1]: MercatorTile, [x2, y2, zoom2]: MercatorTile): boolean => {\n return x1 === x2 && y1 === y2 && zoom1 === zoom2\n}\n","import { tileFromPoint } from '../../tile/index.ts'\nimport type { MercatorBoundingBox, MercatorTile } from '../../types.ts'\n\nconst tilesFromBoundingBox = (box: MercatorBoundingBox, zoom: number): MercatorTile[] => {\n const nw = tileFromPoint(box.getNorthWest(), zoom)\n const se = tileFromPoint(box.getSouthEast(), zoom)\n const size = Math.pow(2, zoom)\n\n let minX = nw[0]\n let maxX = se[0]\n let minY = nw[1]\n let maxY = se[1]\n\n // in case of horizontal wrapping\n if (minX >= maxX) {\n maxX = maxX + size\n }\n\n if (zoom < 4) {\n minX = 0\n maxX = size - 1\n minY = 0\n maxY = size - 1\n }\n\n const result: MercatorTile[] = []\n\n for (let x = minX; x <= maxX; x++) {\n for (let y = minY; y <= maxY; y++) {\n result.push([x % size, y, zoom])\n }\n }\n\n return result\n}\n\nexport { tilesFromBoundingBox }\n","import type { MercatorTile } from '../types.ts'\nimport { tilesEqual } from './equal.ts'\n\nexport const tilesHasTile = (tiles: MercatorTile[], tile: MercatorTile) => {\n for (const tileToCheck of tiles) {\n if (tilesEqual(tileToCheck, tile)) return true\n }\n return false\n}\n","import { tileToSiblings } from '../tile/index.ts'\nimport type { MercatorTile } from '../types.ts'\nimport { tilesHasTile } from './hasTile.ts'\n\nexport const hasSiblings = (tiles: MercatorTile[], tile: MercatorTile) => {\n const siblings = tileToSiblings(tile)\n for (const sibling of siblings) {\n if (!tilesHasTile(tiles, sibling)) return false\n }\n return true\n}\n","import type MapBox from 'mapbox-gl'\n\nexport abstract class LayerBase<T extends MapBox.Layer> {\n id: string\n source: string\n\n constructor(id: string, source: string) {\n this.id = id\n this.source = source\n }\n\n update(map: MapBox.Map, show = true) {\n if (map.getLayer(this.id)) {\n map.removeLayer(this.id)\n }\n if (show) {\n map.addLayer(this.buildLayer())\n }\n }\n\n abstract buildLayer(): T\n}\n"],"mappings":";AAGA,OAAOA,aAAY;;;ACDZ,IAAM,wBAAwB,CAAC,QAA+C;AACnF,SAAO,CAAC,IAAI,aAAa,GAAG,IAAI,aAAa,GAAG,IAAI,aAAa,GAAG,IAAI,aAAa,GAAG,IAAI,aAAa,CAAC;AAC5G;;;ACFO,IAAM,sBAAsB,CAAC,aAAkC,UAAU,MAAM;AACpF,QAAM,OAAO,YAAY,QAAQ;AACjC,QAAM,QAAQ,YAAY,SAAS;AACnC,QAAM,OAAO,YAAY,QAAQ;AACjC,QAAM,QAAQ,YAAY,SAAS;AACnC,MAAI,OAAO,OAAO,QAAQ,IAAI;AAC9B,MAAI,OAAO,QAAQ,SAAS,IAAI;AAChC,MAAI,YAAY,UAAa,YAAY,MAAM;AAC7C,UAAM,OAAO,IAAI,QAAQ,OAAO,CAAC;AACjC,UAAM,OAAO,IAAI,QAAQ,OAAO,CAAC;AAAA,EACnC;AACA,SAAO,CAAC,KAAK,GAAG;AAClB;;;ACTO,IAAM,uBAAuB,CAAC,QAAsC;AACzE,QAAM,UAAU,sBAAsB,GAAG;AACzC,SAAO;AAAA,IACL,aAAa,CAAC,QAAQ,IAAI,CAAC,WAA2B,OAAO,QAAQ,CAAC,CAAC;AAAA,IACvE,MAAM;AAAA,EACR;AACF;;;ACXA,IAAM,MAAM,KAAK,K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AO,EAAE,CAAC;AAC1D,WAAO,KAAK;AAAA,EACd;AACF;;;AmBnGO,IAAe,YAAf,MAAiD;AAAA,EACtD;AAAA,EACA;AAAA,EAEA,YAAY,IAAY,QAAgB;AACtC,SAAK,KAAK;AACV,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,OAAO,KAAiB,OAAO,MAAM;AACnC,QAAI,IAAI,SAAS,KAAK,EAAE,GAAG;AACzB,UAAI,YAAY,KAAK,EAAE;AAAA,IACzB;AACA,QAAI,MAAM;AACR,UAAI,SAAS,KAAK,WAAW,CAAC;AAAA,IAChC;AAAA,EACF;AAGF;","names":["MapBox","MapBox","MapBox","MapBox"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quadkey.d.ts","sourceRoot":"","sources":["../../../../../src/mercator/tile/from/quadkey.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,eAAe,GAAI,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"quadkey.d.ts","sourceRoot":"","sources":["../../../../../src/mercator/tile/from/quadkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,QAAA,MAAM,eAAe,GAAI,SAAS,MAAM,KAAG,YAgB1C,CAAA;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"children.d.ts","sourceRoot":"","sources":["../../../../../src/mercator/tile/to/children.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,QAAA,MAAM,cAAc,GAAI,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"children.d.ts","sourceRoot":"","sources":["../../../../../src/mercator/tile/to/children.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,QAAA,MAAM,cAAc,GAAI,MAAM,YAAY,KAAG,YAAY,EAOxD,CAAA;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quadkey.d.ts","sourceRoot":"","sources":["../../../../../src/mercator/tile/to/quadkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,QAAA,MAAM,aAAa,GAAI,
|
|
1
|
+
{"version":3,"file":"quadkey.d.ts","sourceRoot":"","sources":["../../../../../src/mercator/tile/to/quadkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,QAAA,MAAM,aAAa,GAAI,0BAA0B,YAAY,KAAG,MAU/D,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { MercatorTile } from '../types.ts';
|
|
2
|
-
export declare const tilesEqual: (
|
|
2
|
+
export declare const tilesEqual: ([x1, y1, zoom1]: MercatorTile, [x2, y2, zoom2]: MercatorTile) => boolean;
|
|
3
3
|
//# sourceMappingURL=equal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../src/mercator/tiles/equal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../src/mercator/tiles/equal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,eAAO,MAAM,UAAU,GAAoB,iBAAiB,YAAY,EAAE,iBAAiB,YAAY,KAAG,OAEzG,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/mercator/types.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,KAAK,YAAY,GAAG,MAAM,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/mercator/types.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,KAAK,YAAY,GAAG,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;AACjE,KAAK,gBAAgB,GAAG,cAAc,EAAE,CAAA;AACxC,cAAM,mBAAoB,SAAQ,MAAM,CAAC,YAAY;CAAG;AACxD,cAAM,cAAe,SAAQ,MAAM,CAAC,MAAM;CAAG;AAE7C,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAA;AAC9C,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MercatorTile } from '../../types.ts'
|
|
2
2
|
|
|
3
|
-
const tileToChildren = (tile: MercatorTile) => {
|
|
3
|
+
const tileToChildren = (tile: MercatorTile): MercatorTile[] => {
|
|
4
4
|
return [
|
|
5
5
|
[tile[0] * 2, tile[1] * 2, tile[2] + 1],
|
|
6
6
|
[tile[0] * 2 + 1, tile[1] * 2, tile[2] + 1],
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { MercatorTile } from '../../types.ts'
|
|
2
2
|
|
|
3
|
-
const tileToQuadkey = (
|
|
3
|
+
const tileToQuadkey = ([tileX, tileY, tileZoom]: MercatorTile): string => {
|
|
4
4
|
let index = ''
|
|
5
|
-
for (let z =
|
|
5
|
+
for (let z = tileZoom; z > 0; z--) {
|
|
6
6
|
let b = 0
|
|
7
7
|
const mask = 1 << (z - 1)
|
|
8
|
-
if ((
|
|
9
|
-
if ((
|
|
8
|
+
if ((tileX & mask) !== 0) b++
|
|
9
|
+
if ((tileY & mask) !== 0) b += 2
|
|
10
10
|
index += b.toString()
|
|
11
11
|
}
|
|
12
12
|
return index
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MercatorTile } from '../types.ts'
|
|
2
2
|
|
|
3
|
-
export const tilesEqual = (
|
|
4
|
-
return
|
|
3
|
+
export const tilesEqual = /* @__PURE__ */ ([x1, y1, zoom1]: MercatorTile, [x2, y2, zoom2]: MercatorTile): boolean => {
|
|
4
|
+
return x1 === x2 && y1 === y2 && zoom1 === zoom2
|
|
5
5
|
}
|
package/src/mercator/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import MapBox from 'mapbox-gl'
|
|
2
2
|
|
|
3
|
-
type MercatorTile = number
|
|
3
|
+
type MercatorTile = readonly [x: number, y: number, zoom: number]
|
|
4
4
|
type MercatorBoundary = MercatorLngLat[]
|
|
5
5
|
class MercatorBoundingBox extends MapBox.LngLatBounds {}
|
|
6
6
|
class MercatorLngLat extends MapBox.LngLat {}
|