@xylabs/geo 4.4.35
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/LICENSE +165 -0
- package/README.md +69 -0
- package/dist/neutral/GeoJson.d.ts +25 -0
- package/dist/neutral/GeoJson.d.ts.map +1 -0
- package/dist/neutral/LayerBase.d.ts +9 -0
- package/dist/neutral/LayerBase.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +4 -0
- package/dist/neutral/index.d.ts.map +1 -0
- package/dist/neutral/index.mjs +322 -0
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/neutral/mercator/boundingbox/index.d.ts +2 -0
- package/dist/neutral/mercator/boundingbox/index.d.ts.map +1 -0
- package/dist/neutral/mercator/boundingbox/to/boundary.d.ts +3 -0
- package/dist/neutral/mercator/boundingbox/to/boundary.d.ts.map +1 -0
- package/dist/neutral/mercator/boundingbox/to/center.d.ts +3 -0
- package/dist/neutral/mercator/boundingbox/to/center.d.ts.map +1 -0
- package/dist/neutral/mercator/boundingbox/to/index.d.ts +4 -0
- package/dist/neutral/mercator/boundingbox/to/index.d.ts.map +1 -0
- package/dist/neutral/mercator/boundingbox/to/polygon.d.ts +4 -0
- package/dist/neutral/mercator/boundingbox/to/polygon.d.ts.map +1 -0
- package/dist/neutral/mercator/constants.d.ts +4 -0
- package/dist/neutral/mercator/constants.d.ts.map +1 -0
- package/dist/neutral/mercator/index.d.ts +6 -0
- package/dist/neutral/mercator/index.d.ts.map +1 -0
- package/dist/neutral/mercator/tile/from/index.d.ts +3 -0
- package/dist/neutral/mercator/tile/from/index.d.ts.map +1 -0
- package/dist/neutral/mercator/tile/from/point.d.ts +4 -0
- package/dist/neutral/mercator/tile/from/point.d.ts.map +1 -0
- package/dist/neutral/mercator/tile/from/quadkey.d.ts +3 -0
- package/dist/neutral/mercator/tile/from/quadkey.d.ts.map +1 -0
- package/dist/neutral/mercator/tile/index.d.ts +3 -0
- package/dist/neutral/mercator/tile/index.d.ts.map +1 -0
- package/dist/neutral/mercator/tile/to/boundingbox.d.ts +5 -0
- package/dist/neutral/mercator/tile/to/boundingbox.d.ts.map +1 -0
- package/dist/neutral/mercator/tile/to/children.d.ts +4 -0
- package/dist/neutral/mercator/tile/to/children.d.ts.map +1 -0
- package/dist/neutral/mercator/tile/to/geoJson.d.ts +5 -0
- package/dist/neutral/mercator/tile/to/geoJson.d.ts.map +1 -0
- package/dist/neutral/mercator/tile/to/index.d.ts +8 -0
- package/dist/neutral/mercator/tile/to/index.d.ts.map +1 -0
- package/dist/neutral/mercator/tile/to/parent.d.ts +4 -0
- package/dist/neutral/mercator/tile/to/parent.d.ts.map +1 -0
- package/dist/neutral/mercator/tile/to/point.d.ts +4 -0
- package/dist/neutral/mercator/tile/to/point.d.ts.map +1 -0
- package/dist/neutral/mercator/tile/to/quadkey.d.ts +4 -0
- package/dist/neutral/mercator/tile/to/quadkey.d.ts.map +1 -0
- package/dist/neutral/mercator/tile/to/siblings.d.ts +4 -0
- package/dist/neutral/mercator/tile/to/siblings.d.ts.map +1 -0
- package/dist/neutral/mercator/tiles/equal.d.ts +4 -0
- package/dist/neutral/mercator/tiles/equal.d.ts.map +1 -0
- package/dist/neutral/mercator/tiles/from/boundingbox.d.ts +4 -0
- package/dist/neutral/mercator/tiles/from/boundingbox.d.ts.map +1 -0
- package/dist/neutral/mercator/tiles/from/index.d.ts +2 -0
- package/dist/neutral/mercator/tiles/from/index.d.ts.map +1 -0
- package/dist/neutral/mercator/tiles/hasSiblings.d.ts +4 -0
- package/dist/neutral/mercator/tiles/hasSiblings.d.ts.map +1 -0
- package/dist/neutral/mercator/tiles/hasTile.d.ts +4 -0
- package/dist/neutral/mercator/tiles/hasTile.d.ts.map +1 -0
- package/dist/neutral/mercator/tiles/index.d.ts +4 -0
- package/dist/neutral/mercator/tiles/index.d.ts.map +1 -0
- package/dist/neutral/mercator/types.d.ts +10 -0
- package/dist/neutral/mercator/types.d.ts.map +1 -0
- package/package.json +53 -0
- package/src/GeoJson.spec.ts +12 -0
- package/src/GeoJson.ts +104 -0
- package/src/LayerBase.ts +22 -0
- package/src/index.ts +3 -0
- package/src/mercator/boundingbox/index.ts +1 -0
- package/src/mercator/boundingbox/to/boundary.ts +5 -0
- package/src/mercator/boundingbox/to/center.ts +15 -0
- package/src/mercator/boundingbox/to/index.ts +3 -0
- package/src/mercator/boundingbox/to/polygon.ts +12 -0
- package/src/mercator/constants.ts +4 -0
- package/src/mercator/index.ts +5 -0
- package/src/mercator/tile/from/index.ts +2 -0
- package/src/mercator/tile/from/point.ts +29 -0
- package/src/mercator/tile/from/quadkey.ts +19 -0
- package/src/mercator/tile/index.ts +2 -0
- package/src/mercator/tile/to/boundingbox.ts +24 -0
- package/src/mercator/tile/to/children.ts +12 -0
- package/src/mercator/tile/to/geoJson.ts +23 -0
- package/src/mercator/tile/to/index.ts +7 -0
- package/src/mercator/tile/to/parent.ts +7 -0
- package/src/mercator/tile/to/point.ts +10 -0
- package/src/mercator/tile/to/quadkey.ts +15 -0
- package/src/mercator/tile/to/siblings.ts +9 -0
- package/src/mercator/tiles/equal.ts +7 -0
- package/src/mercator/tiles/from/boundingbox.ts +37 -0
- package/src/mercator/tiles/from/index.ts +1 -0
- package/src/mercator/tiles/hasSiblings.ts +13 -0
- package/src/mercator/tiles/hasTile.ts +11 -0
- package/src/mercator/tiles/index.ts +3 -0
- package/src/mercator/types.ts +9 -0
- package/typedoc.json +5 -0
- package/xy.config.ts +10 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MercatorLngLat, MercatorTile } from '../../types.ts'
|
|
2
|
+
import { tileToBoundingBox } from './boundingbox.ts'
|
|
3
|
+
|
|
4
|
+
const tileToPoint = (tile: MercatorTile): MercatorLngLat => {
|
|
5
|
+
const boundingBox = tileToBoundingBox(tile)
|
|
6
|
+
boundingBox.getCenter()
|
|
7
|
+
return boundingBox.getCenter()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { tileToPoint }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MercatorTile } from '../../types.ts'
|
|
2
|
+
|
|
3
|
+
const tileToQuadkey = (tile: MercatorTile): string => {
|
|
4
|
+
let index = ''
|
|
5
|
+
for (let z = tile[2]; z > 0; z--) {
|
|
6
|
+
let b = 0
|
|
7
|
+
const mask = 1 << (z - 1)
|
|
8
|
+
if ((tile[0] & mask) !== 0) b++
|
|
9
|
+
if ((tile[1] & mask) !== 0) b += 2
|
|
10
|
+
index += b.toString()
|
|
11
|
+
}
|
|
12
|
+
return index
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { tileToQuadkey }
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MercatorTile } from '../../types.ts'
|
|
2
|
+
import { tileToChildren } from './children.ts'
|
|
3
|
+
import { tileToParent } from './parent.ts'
|
|
4
|
+
|
|
5
|
+
const tileToSiblings = (tile: MercatorTile): MercatorTile[] => {
|
|
6
|
+
return tileToChildren(tileToParent(tile))
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { tileToSiblings }
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { tileFromPoint } from '../../tile/index.ts'
|
|
2
|
+
import type { MercatorBoundingBox, MercatorTile } from '../../types.ts'
|
|
3
|
+
|
|
4
|
+
const tilesFromBoundingBox = (box: MercatorBoundingBox, zoom: number): MercatorTile[] => {
|
|
5
|
+
const nw = tileFromPoint(box.getNorthWest(), zoom)
|
|
6
|
+
const se = tileFromPoint(box.getSouthEast(), zoom)
|
|
7
|
+
const size = Math.pow(2, zoom)
|
|
8
|
+
|
|
9
|
+
let minX = nw[0]
|
|
10
|
+
let maxX = se[0]
|
|
11
|
+
let minY = nw[1]
|
|
12
|
+
let maxY = se[1]
|
|
13
|
+
|
|
14
|
+
// in case of horizontal wrapping
|
|
15
|
+
if (minX >= maxX) {
|
|
16
|
+
maxX = maxX + size
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (zoom < 4) {
|
|
20
|
+
minX = 0
|
|
21
|
+
maxX = size - 1
|
|
22
|
+
minY = 0
|
|
23
|
+
maxY = size - 1
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const result: MercatorTile[] = []
|
|
27
|
+
|
|
28
|
+
for (let x = minX; x <= maxX; x++) {
|
|
29
|
+
for (let y = minY; y <= maxY; y++) {
|
|
30
|
+
result.push([x % size, y, zoom])
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return result
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { tilesFromBoundingBox }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { tilesFromBoundingBox } from './boundingbox.ts'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { tileToSiblings } from '../tile/index.ts'
|
|
2
|
+
import type { MercatorTile } from '../types.ts'
|
|
3
|
+
import { tilesHasTile } from './hasTile.ts'
|
|
4
|
+
|
|
5
|
+
const hasSiblings = (tiles: MercatorTile[], tile: MercatorTile) => {
|
|
6
|
+
const siblings = tileToSiblings(tile)
|
|
7
|
+
for (const sibling of siblings) {
|
|
8
|
+
if (!tilesHasTile(tiles, sibling)) return false
|
|
9
|
+
}
|
|
10
|
+
return true
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { hasSiblings }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MercatorTile } from '../types.ts'
|
|
2
|
+
import { tilesEqual } from './equal.ts'
|
|
3
|
+
|
|
4
|
+
const tilesHasTile = (tiles: MercatorTile[], tile: MercatorTile) => {
|
|
5
|
+
for (const tileToCheck of tiles) {
|
|
6
|
+
if (tilesEqual(tileToCheck, tile)) return true
|
|
7
|
+
}
|
|
8
|
+
return false
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { tilesHasTile }
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import MapBox from 'mapbox-gl'
|
|
2
|
+
|
|
3
|
+
type MercatorTile = number[]
|
|
4
|
+
type MercatorBoundary = MercatorLngLat[]
|
|
5
|
+
class MercatorBoundingBox extends MapBox.LngLatBounds {}
|
|
6
|
+
class MercatorLngLat extends MapBox.LngLat {}
|
|
7
|
+
|
|
8
|
+
export { MercatorBoundingBox, MercatorLngLat }
|
|
9
|
+
export type { MercatorBoundary, MercatorTile }
|
package/typedoc.json
ADDED