@deck.gl-community/geo-layers 9.2.0-beta.3

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.
Files changed (90) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +5 -0
  3. package/dist/global-grid-layer/global-grid-cluster-layer.d.ts +36 -0
  4. package/dist/global-grid-layer/global-grid-cluster-layer.d.ts.map +1 -0
  5. package/dist/global-grid-layer/global-grid-cluster-layer.js +55 -0
  6. package/dist/global-grid-layer/global-grid-cluster-layer.js.map +1 -0
  7. package/dist/global-grid-layer/global-grid-layer.d.ts +21 -0
  8. package/dist/global-grid-layer/global-grid-layer.d.ts.map +1 -0
  9. package/dist/global-grid-layer/global-grid-layer.js +33 -0
  10. package/dist/global-grid-layer/global-grid-layer.js.map +1 -0
  11. package/dist/global-grid-systems/grids/a5-grid.d.ts +18 -0
  12. package/dist/global-grid-systems/grids/a5-grid.d.ts.map +1 -0
  13. package/dist/global-grid-systems/grids/a5-grid.js +23 -0
  14. package/dist/global-grid-systems/grids/a5-grid.js.map +1 -0
  15. package/dist/global-grid-systems/grids/geohash-grid.d.ts +15 -0
  16. package/dist/global-grid-systems/grids/geohash-grid.d.ts.map +1 -0
  17. package/dist/global-grid-systems/grids/geohash-grid.js +92 -0
  18. package/dist/global-grid-systems/grids/geohash-grid.js.map +1 -0
  19. package/dist/global-grid-systems/grids/global-grid.d.ts +31 -0
  20. package/dist/global-grid-systems/grids/global-grid.d.ts.map +1 -0
  21. package/dist/global-grid-systems/grids/global-grid.js +5 -0
  22. package/dist/global-grid-systems/grids/global-grid.js.map +1 -0
  23. package/dist/global-grid-systems/grids/h3-grid.d.ts +16 -0
  24. package/dist/global-grid-systems/grids/h3-grid.d.ts.map +1 -0
  25. package/dist/global-grid-systems/grids/h3-grid.js +29 -0
  26. package/dist/global-grid-systems/grids/h3-grid.js.map +1 -0
  27. package/dist/global-grid-systems/grids/quadkey-grid.d.ts +41 -0
  28. package/dist/global-grid-systems/grids/quadkey-grid.d.ts.map +1 -0
  29. package/dist/global-grid-systems/grids/quadkey-grid.js +166 -0
  30. package/dist/global-grid-systems/grids/quadkey-grid.js.map +1 -0
  31. package/dist/global-grid-systems/grids/s2-grid.d.ts +16 -0
  32. package/dist/global-grid-systems/grids/s2-grid.d.ts.map +1 -0
  33. package/dist/global-grid-systems/grids/s2-grid.js +74 -0
  34. package/dist/global-grid-systems/grids/s2-grid.js.map +1 -0
  35. package/dist/global-grid-systems/h3-js-bigint/h3-js-bigint.d.ts +9 -0
  36. package/dist/global-grid-systems/h3-js-bigint/h3-js-bigint.d.ts.map +1 -0
  37. package/dist/global-grid-systems/h3-js-bigint/h3-js-bigint.js +62 -0
  38. package/dist/global-grid-systems/h3-js-bigint/h3-js-bigint.js.map +1 -0
  39. package/dist/global-grid-systems/s2-geometry/s2-geometry.d.ts +13 -0
  40. package/dist/global-grid-systems/s2-geometry/s2-geometry.d.ts.map +1 -0
  41. package/dist/global-grid-systems/s2-geometry/s2-geometry.js +139 -0
  42. package/dist/global-grid-systems/s2-geometry/s2-geometry.js.map +1 -0
  43. package/dist/global-grid-systems/s2-geometry/s2-to-boundary.d.ts +14 -0
  44. package/dist/global-grid-systems/s2-geometry/s2-to-boundary.d.ts.map +1 -0
  45. package/dist/global-grid-systems/s2-geometry/s2-to-boundary.js +60 -0
  46. package/dist/global-grid-systems/s2-geometry/s2-to-boundary.js.map +1 -0
  47. package/dist/global-grid-systems/s2-geometry/s2-token.d.ts +13 -0
  48. package/dist/global-grid-systems/s2-geometry/s2-token.d.ts.map +1 -0
  49. package/dist/global-grid-systems/s2-geometry/s2-token.js +61 -0
  50. package/dist/global-grid-systems/s2-geometry/s2-token.js.map +1 -0
  51. package/dist/global-grid-systems/utils/geometry-utils.d.ts +4 -0
  52. package/dist/global-grid-systems/utils/geometry-utils.d.ts.map +1 -0
  53. package/dist/global-grid-systems/utils/geometry-utils.js +26 -0
  54. package/dist/global-grid-systems/utils/geometry-utils.js.map +1 -0
  55. package/dist/global-grid-systems/utils/h3-utils.d.ts +5 -0
  56. package/dist/global-grid-systems/utils/h3-utils.d.ts.map +1 -0
  57. package/dist/global-grid-systems/utils/h3-utils.js +41 -0
  58. package/dist/global-grid-systems/utils/h3-utils.js.map +1 -0
  59. package/dist/global-grid-systems/utils/hex-utils.d.ts +8 -0
  60. package/dist/global-grid-systems/utils/hex-utils.d.ts.map +1 -0
  61. package/dist/global-grid-systems/utils/hex-utils.js +34 -0
  62. package/dist/global-grid-systems/utils/hex-utils.js.map +1 -0
  63. package/dist/index.cjs +640 -0
  64. package/dist/index.cjs.map +7 -0
  65. package/dist/index.d.ts +10 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +11 -0
  68. package/dist/index.js.map +1 -0
  69. package/dist/tile-source-layer/tile-source-layer.d.ts +45 -0
  70. package/dist/tile-source-layer/tile-source-layer.d.ts.map +1 -0
  71. package/dist/tile-source-layer/tile-source-layer.js +110 -0
  72. package/dist/tile-source-layer/tile-source-layer.js.map +1 -0
  73. package/package.json +53 -0
  74. package/src/global-grid-layer/global-grid-cluster-layer.ts +93 -0
  75. package/src/global-grid-layer/global-grid-layer.ts +54 -0
  76. package/src/global-grid-systems/grids/a5-grid.ts +38 -0
  77. package/src/global-grid-systems/grids/geohash-grid.ts +105 -0
  78. package/src/global-grid-systems/grids/global-grid.ts +40 -0
  79. package/src/global-grid-systems/grids/h3-grid.ts +45 -0
  80. package/src/global-grid-systems/grids/quadkey-grid.ts +190 -0
  81. package/src/global-grid-systems/grids/s2-grid.ts +86 -0
  82. package/src/global-grid-systems/h3-js-bigint/h3-js-bigint.ts +85 -0
  83. package/src/global-grid-systems/s2-geometry/s2-geometry.ts +180 -0
  84. package/src/global-grid-systems/s2-geometry/s2-to-boundary.ts +76 -0
  85. package/src/global-grid-systems/s2-geometry/s2-token.ts +70 -0
  86. package/src/global-grid-systems/utils/geometry-utils.ts +28 -0
  87. package/src/global-grid-systems/utils/h3-utils.ts +52 -0
  88. package/src/global-grid-systems/utils/hex-utils.ts +37 -0
  89. package/src/index.ts +15 -0
  90. package/src/tile-source-layer/tile-source-layer.ts +156 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/tile-source-layer/tile-source-layer.ts", "../src/global-grid-layer/global-grid-layer.ts", "../src/global-grid-systems/utils/geometry-utils.ts", "../src/global-grid-systems/grids/a5-grid.ts", "../src/global-grid-systems/utils/hex-utils.ts", "../src/global-grid-systems/h3-js-bigint/h3-js-bigint.ts", "../src/global-grid-systems/grids/h3-grid.ts", "../src/global-grid-systems/s2-geometry/s2-token.ts", "../src/global-grid-systems/s2-geometry/s2-geometry.ts", "../src/global-grid-systems/s2-geometry/s2-to-boundary.ts", "../src/global-grid-systems/grids/s2-grid.ts", "../src/global-grid-systems/grids/geohash-grid.ts", "../src/global-grid-systems/grids/quadkey-grid.ts"],
4
+ "sourcesContent": ["// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport type {TileSourceLayerProps} from './tile-source-layer/tile-source-layer';\nexport {TileSourceLayer} from './tile-source-layer/tile-source-layer';\n\nexport {GlobalGridLayer, type GlobalGridLayerProps} from './global-grid-layer/global-grid-layer';\n\nexport {type GlobalGrid} from './global-grid-systems/grids/global-grid';\nexport {A5Grid} from './global-grid-systems/grids/a5-grid';\nexport {H3Grid} from './global-grid-systems/grids/h3-grid';\nexport {S2Grid} from './global-grid-systems/grids/s2-grid';\nexport {GeohashGrid} from './global-grid-systems/grids/geohash-grid';\nexport {QuadkeyGrid} from './global-grid-systems/grids/quadkey-grid';\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {CompositeLayer, Layer} from '@deck.gl/core';\nimport type {TileLayerProps} from '@deck.gl/geo-layers';\nimport {TileLayer} from '@deck.gl/geo-layers';\nimport {BitmapLayer, GeoJsonLayer, PathLayer} from '@deck.gl/layers';\nimport type {TileSource} from '@loaders.gl/loader-utils';\n\n/* global window */\nconst devicePixelRatio = (typeof window !== 'undefined' && window.devicePixelRatio) || 1;\n\nexport type TileSourceLayerProps = TileLayerProps & {\n tileSource: TileSource<any>;\n showTileBorders?: boolean;\n};\n\n/**\n * A Deck.gl layer that renders a tile source\n * Autodiscovers type of content (vector tile, bitmap, ...)\n * Can render debug borders around tiles\n * TODO - Change debug border color based on zoom level\n */\nexport class TileSourceLayer extends CompositeLayer<TileSourceLayerProps> {\n static layerName = 'TileSourceLayer';\n static defaultProps = {\n ...TileLayer.defaultProps,\n showTileBorders: true\n };\n\n state: {\n tileSource: TileSource<any> | null;\n } = undefined!;\n\n initializeState() {\n this.setState({\n tileSource: null\n });\n }\n\n updateState({props, changeFlags}) {\n this.setState({\n tileSource: props.tileSource\n });\n }\n\n renderLayers() {\n const {tileSource, showTileBorders, metadata, onTilesLoad} = this.props as any;\n const minZoom = metadata?.minZoom || 0;\n const maxZoom = metadata?.maxZoom || 30;\n\n return [\n new TileLayer({\n // HACK: Trigger new layer via id prop to force clear tile cache\n id: String(tileSource.url),\n getTileData: tileSource.getTileData,\n // Assume the pmtiles file support HTTP/2, so we aren't limited by the browser to a certain number per domain.\n maxRequests: 20,\n\n pickable: true,\n onViewportLoad: onTilesLoad,\n autoHighlight: showTileBorders,\n highlightColor: [60, 60, 60, 40],\n minZoom,\n maxZoom,\n tileSize: 256,\n // TOOD - why is this needed?\n zoomOffset: devicePixelRatio === 1 ? -1 : 0,\n renderSubLayers: renderSubLayers as any,\n\n // Custom prop\n tileSource,\n showTileBorders\n })\n ];\n }\n}\n\nfunction renderSubLayers(\n props: TileSourceLayerProps & {tile: {index; bbox: {west; south; east; north}}}\n) {\n const {\n tileSource,\n showTileBorders,\n minZoom,\n maxZoom,\n tile: {\n index: {z: zoom},\n bbox: {west, south, east, north}\n }\n } = props as any;\n\n const layers: Layer[] = [];\n\n const borderColor = zoom <= minZoom || zoom >= maxZoom ? [255, 0, 0, 255] : [0, 0, 255, 255];\n\n switch (tileSource.mimeType) {\n case 'application/vnd.mapbox-vector-tile':\n layers.push(\n new GeoJsonLayer({\n id: `${props.id}-geojson`,\n data: props.data as any,\n pickable: true,\n getFillColor: [0, 190, 80, 255],\n lineWidthScale: 500,\n lineWidthMinPixels: 0.5\n })\n );\n break;\n\n case 'image/png':\n case 'image/jpeg':\n case 'image/webp':\n case 'image/avif':\n layers.push(\n new BitmapLayer(\n props as any,\n {\n data: null,\n image: props.data,\n bounds: [west, south, east, north],\n pickable: true\n } as any\n )\n );\n break;\n\n default:\n // eslint-disable-next-line no-console\n console.error('Unknown tile mimeType', tileSource?.mimeType);\n }\n\n // Debug tile borders\n if (showTileBorders) {\n layers.push(\n new PathLayer({\n id: `${props.id}-border`,\n data: [\n [\n [west, north],\n [west, south],\n [east, south],\n [east, north],\n [west, north]\n ]\n ],\n getPath: (d) => d,\n getColor: borderColor as any,\n widthMinPixels: 4\n })\n );\n }\n\n return layers;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {type AccessorFunction, type DefaultProps} from '@deck.gl/core';\nimport {_GeoCellLayer, type _GeoCellLayerProps} from '@deck.gl/geo-layers';\nimport {GlobalGrid} from '../global-grid-systems/grids/global-grid';\nimport {flattenPolygon} from '../global-grid-systems/utils/geometry-utils';\n\n/** All properties supported by GlobalGridLayer. */\nexport type GlobalGridLayerProps<DataT = unknown> = _GlobalGridLayerProps<DataT> &\n _GeoCellLayerProps<DataT>;\n\n/** Properties added by GlobalGridLayer. */\ntype _GlobalGridLayerProps<DataT> = {\n /** The DGGS decoder to use. */\n globalGrid: GlobalGrid;\n /** Called for each data object to retrieve the DGGS cell identifier. By default, it reads `cellId` property of data object. */\n getCellId?: AccessorFunction<DataT, string | bigint>;\n};\n\n/** Render filled and/or stroked polygons based on the specified DGGS geospatial indexing system. */\nexport class GlobalGridLayer<DataT = any, ExtraProps extends {} = {}> extends _GeoCellLayer<\n DataT,\n Required<_GlobalGridLayerProps<DataT>> & ExtraProps\n> {\n static layerName = 'GlobalGridLayer';\n static defaultProps: DefaultProps<GlobalGridLayerProps> = {\n getCellId: {type: 'accessor', value: (d: any) => d.cellId},\n globalGrid: {type: 'object', compare: true, value: undefined!}\n };\n\n initializeState(): void {\n this.props.globalGrid?.initialize?.();\n }\n\n indexToBounds(): Partial<_GeoCellLayer['props']> | null {\n const {data, getCellId} = this.props;\n\n return {\n data,\n _normalize: false,\n _windingOrder: 'CCW',\n positionFormat: 'XY',\n getPolygon: (x: DataT, objectInfo) => {\n const {globalGrid} = this.props;\n const cell = getCellId(x, objectInfo);\n const boundary = globalGrid.cellToBoundary(cell);\n boundary.push(boundary[0]);\n return flattenPolygon(boundary);\n }\n };\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {type CoordPair} from '../h3-js-bigint/h3-js-bigint';\n\n// normalize longitudes w.r.t center (refLng), when not provided first vertex\nexport function normalizeLongitudes(vertices: CoordPair[], refLng?: number): void {\n refLng = refLng === undefined ? vertices[0][0] : refLng;\n for (const pt of vertices) {\n const deltaLng = pt[0] - refLng;\n if (deltaLng > 180) {\n pt[0] -= 360;\n } else if (deltaLng < -180) {\n pt[0] += 360;\n }\n }\n}\n\nexport function flattenPolygon(vertices: number[][]): Float64Array {\n const positions = new Float64Array(vertices.length * 2);\n let i = 0;\n for (const pt of vertices) {\n positions[i++] = pt[0];\n positions[i++] = pt[1];\n }\n return positions;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// import {type Bounds2D} from '@math.gl/types';\nimport {type GlobalGrid} from './global-grid';\nimport {cellToBoundary, cellToLonLat, lonLatToCell} from 'a5-js';\nimport { hexToBigInt } from '../utils/hex-utils';\n\n// TODO - internal types in a5-js\ntype Degrees = number & {\n __brand: 'Degrees';\n};\ntype LonLat = [longitude: Degrees, latitude: Degrees] & {\n __brand: 'LonLat';\n};\n\n/**\n * \"Standardized\" API for working with A5 DGGS tokens.\n * @note Copy of same type in math.gl. They are structurally identical. Will be replaced by an import in the future.\n */\nexport const A5Grid = {\n name: 'A5',\n hasNumericRepresentation: true,\n\n tokenToCell: (token: string) => hexToBigInt(token),\n lngLatToCell: (lngLat: [number, number], resolution: number) =>\n lonLatToCell(lngLat as LonLat, resolution),\n\n cellToToken: (cell: string | bigint) => (typeof cell === 'string' ? cell : cell.toString(16)),\n cellToLngLat: (cell: string | bigint) => cellToLonLat(getBigInt(cell)),\n cellToBoundary: (cell: string | bigint) => cellToBoundary(getBigInt(cell))\n} as const satisfies GlobalGrid;\n\n/** Helper function to convert cells to bigints */\nconst getBigInt = (value: string | bigint): bigint => {\n return typeof value === 'string' ? hexToBigInt(value) : value;\n};\n", "/**\n * Converts a hexadecimal string (with or without \u201C0x\u201D prefix) to a bigint.\n * @param hex - The hex string representation (e.g., \"0x1a2b\", \"FF\", \"00ff\")\n * @returns The corresponding bigint value.\n * @throws {Error} If the input is not a valid hex string.\n */\nexport function hexToBigInt(hex: string): bigint {\n if (typeof hex !== 'string') {\n throw new Error(`hexToBigInt: expected string, got ${typeof hex}`);\n }\n\n let s = hex.trim();\n if (s.startsWith('0x') || s.startsWith('0X')) {\n s = s.slice(2);\n }\n\n if (s === '') {\n throw new Error(`hexToBigInt: empty hex string`);\n }\n\n // validate: only hex digits\n if (!/^[0-9A-Fa-f]+$/.test(s)) {\n throw new Error(`hexToBigInt: invalid hex string \u201C${hex}\u201D`);\n }\n\n // Optional: normalize even length by prepending a zero if odd\n if (s.length % 2 === 1) {\n s = `0${ s}`;\n }\n\n // Use BigInt conversion from string with 0x prefix\n try {\n return BigInt(`0x${ s}`);\n } catch (e) {\n throw new Error(`hexToBigInt: cannot convert hex string \u201C${hex}\u201D to bigint: ${(e as Error).message}`);\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// A thin wrapper around h3-js that support BigInts\n// Note: incurs some overhead as we need to convert between BigInt and SplitLong\n\nimport {\n type CoordPair,\n type SplitLong,\n latLngToCell,\n cellToBoundary as _cellToBoundary,\n cellToLatLng as _cellToLatLng,\n cellsToMultiPolygon as _cellsToMultiPolygon,\n h3IndexToSplitLong as _h3IndexToSplitLong\n // splitLongToH3Index as _splitLongToH3Index\n} from 'h3-js';\n\nexport {type CoordPair, type SplitLong, latLngToCell};\n\nexport type H3IndexInput = bigint | string | SplitLong;\n\nconst scratchSplitLong: SplitLong = [0, 0];\n\nexport function h3IndexToSplitLong(h3Index: H3IndexInput, target?: SplitLong): SplitLong {\n if (typeof h3Index === 'bigint') {\n return bigIntToSplitLong(h3Index, target ?? [0, 0]);\n }\n return _h3IndexToSplitLong(h3Index);\n}\n\nexport function h3IndexToBigInt(h3Index: H3IndexInput): bigint {\n if (typeof h3Index === 'bigint') {\n return h3Index;\n }\n const splitLong = h3IndexToSplitLong(h3Index, scratchSplitLong);\n return splitLongToBigInt(splitLong);\n}\n\nexport function cellToLatLng(h3Index: H3IndexInput): [number, number] {\n const splitLong = h3IndexToSplitLong(h3Index, scratchSplitLong);\n const latLng = _cellToLatLng(splitLong);\n return latLng;\n}\n\nexport function cellToBoundary(h3Index: H3IndexInput, formatAsGeoJson?: boolean): CoordPair[] {\n const splitLong = h3IndexToSplitLong(h3Index, scratchSplitLong);\n const vertices = _cellToBoundary(splitLong, formatAsGeoJson);\n return vertices;\n}\n\nexport function cellsToMultiPolygon(\n h3Indexes: H3IndexInput[],\n formatAsGeoJson?: boolean\n): CoordPair[][][] {\n const splitLongs = h3Indexes.map((h3Index) => h3IndexToSplitLong(h3Index));\n const polygons = _cellsToMultiPolygon(splitLongs, formatAsGeoJson);\n return polygons;\n}\n\n// HELPERS\n\n/**\n * Splits a bigint into a 2-element array of 32-bit numbers.\n * @param value - The bigint to split.\n * @returns A 2-element array containing the high and low 32-bit numbers.\n */\nfunction bigIntToSplitLong(value: bigint, target: SplitLong = [0, 0]): SplitLong {\n // Mask lower 32 bits\n target[0] = Number(value & 0xffffffffn); // BigInt & BigInt \u21D2 BigInt :contentReference[oaicite:2]{index=2}\n // Shift right to get upper 32 bits\n target[1] = Number((value >> 32n) & 0xffffffffn); // BigInt >> BigInt \u21D2 BigInt :contentReference[oaicite:3]{index=3}\n return target;\n}\n\n/**\n * Joins two 32-bit numbers into a bigint.\n * @param high - The high 32-bit number.\n * @param low - The low 32-bit number.\n * @returns The combined bigint.\n */\nfunction splitLongToBigInt([low, high]: SplitLong): bigint {\n // Shift high half back and OR with low half\n return (BigInt(high) << 32n) | BigInt(low); // BigInt << BigInt \u21D2 BigInt; BigInt | BigInt \u21D2 BigInt :contentReference[oaicite:4]{index=4}\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {type GlobalGrid} from './global-grid';\nimport {\n latLngToCell,\n cellToBoundary,\n cellToLatLng,\n cellsToMultiPolygon,\n h3IndexToBigInt\n} from '../h3-js-bigint/h3-js-bigint';\n\n/**\n * \"Standardized\" API for working with H3 DGGS tokens.\n * @note Inspired by similar work in math.gl. May replace by an import in the future.\n */\nexport const H3Grid = {\n name: 'H3',\n hasNumericRepresentation: true,\n\n // See `main/bundle.ts`, installs a check for the H3 library.\n initialize: () => {},\n\n tokenToCell: (token: string) => h3IndexToBigInt(token),\n\n lngLatToToken: (lngLat: [number, number], resolution: number) =>\n latLngToCell(lngLat[1], lngLat[0], resolution),\n lngLatToCell: (lngLat: [number, number], resolution: number) =>\n h3IndexToBigInt(latLngToCell(lngLat[1], lngLat[0], resolution)),\n\n cellToLngLat: (cell: string | bigint) => reverseLatLngInPlace(cellToLatLng(cell)),\n cellToBoundary: (cell: string | bigint) => cellToBoundary(cell),\n cellsToBoundaryMultiPolygon: (cells: string[] | bigint[]) => cellsToMultiPolygon(cells, true)\n} as const satisfies GlobalGrid;\n\n// HELPERS\n\n/** Reverse the latitude and longitude in place to avoid minting new arrays. */\nfunction reverseLatLngInPlace(latLng: [number, number]): [number, number] {\n const temp = latLng[0];\n latLng[0] = latLng[1];\n latLng[1] = temp;\n return latLng;\n}\n", "// math.gl\n// SPDX-License-Identifier: MIT and Apache-2.0\n// Copyright (c) vis.gl contributors\n\n// s2-geometry is a pure JavaScript port of Google/Niantic's S2 Geometry library\n// which is perfect since it works in the browser.\n\n// const MAXIMUM_TOKEN_LENGTH = 16;\n\n// INDEX CALCULATIONS\n\n/**\n * Given an S2 token (String) this function convert the token to 64 bit id (Index)\n * 'X' is the empty cell\n * https://github.com/google/s2-geometry-library-java/blob/c04b68bf3197a9c34082327eeb3aec7ab7c85da1/src/com/google/common/geometry/S2CellId.java#L439\n */\nexport function getS2IndexFromToken(token: string): bigint {\n if (token === 'X') {\n token = '';\n }\n // pad token with zeros to make the length 16\n const paddedToken = token.padEnd(16, '0');\n return BigInt(`0x${paddedToken}`);\n}\n\n/**\n * Convert a 64 bit number to a string token\n * 'X' is the empty cell\n */\nexport function getS2TokenFromIndex(cellId: bigint): string {\n if (cellId === 0n) {\n return 'X';\n }\n let numZeroDigits = countTrailingZeros(cellId);\n\n const remainder = numZeroDigits % 4;\n numZeroDigits = (numZeroDigits - remainder) / 4;\n const trailingZeroHexChars = numZeroDigits;\n numZeroDigits *= 4;\n\n const x = cellId >> BigInt(numZeroDigits);\n const hexString = x.toString(16).replace(/0+$/, '');\n const zeroString = Array(17 - trailingZeroHexChars - hexString.length).join('0');\n return zeroString + hexString;\n}\n\nexport function getS2ChildIndex(s2Index: bigint, index: number): bigint {\n // Shift sentinel bit 2 positions to the right.\n const newLsb = lsb(s2Index) >> 2n;\n // Insert child index before the sentinel bit.\n const childCellId: bigint = s2Index + BigInt(2 * index + 1 - 4) * newLsb;\n return childCellId;\n}\n\n/**\n * Return the lowest-numbered bit that is on for this cell id\n * @private\n */\nfunction lsb(cellId: bigint): bigint {\n return cellId & (cellId + 1n); // eslint-disable-line\n}\n\nfunction countTrailingZeros(n: bigint): number {\n let count = 0;\n while (n % 2n === 0n) {\n n /= 2n;\n count++;\n }\n return count;\n}\n", "// math.gl\n// SPDX-License-Identifier: MIT and ISC\n// Copyright (c) vis.gl contributors\n\n// math.gl, MIT license\n/*\nAdapted from s2-geometry under ISC License (ISC)\nCopyright (c) 2012-2016, Jon Atkins <github@jonatkins.com>\nCopyright (c) 2016, AJ ONeal <aj@daplie.com>\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\n\nexport type S2Cell = {\n face: number;\n ij: [number, number];\n level: number;\n};\n\nexport function getS2Cell(s2Index: bigint): S2Cell {\n const key = toHilbertQuadkey(s2Index);\n const s2cell = fromHilbertQuadKey(key);\n return s2cell;\n}\n\n//\n// Functional Style\n//\nconst FACE_BITS = 3;\nconst MAX_LEVEL = 30;\nconst POS_BITS = 2 * MAX_LEVEL + 1; // 61 (60 bits of data, 1 bit lsb marker)\nconst RADIAN_TO_DEGREE = 180 / Math.PI;\n\n/*\n Original function taken from deck.gl doesn't support the case of (face <= 5)\n It's fixed here.\n*/\nexport function fromHilbertQuadKey(hilbertQuadkey: string): S2Cell {\n const parts = hilbertQuadkey.split('/');\n const face = parseInt(parts[0], 10);\n const position = parts[1];\n /*\n Fix for the case of level==0 that corresponds to (face <= 5)\n const maxLevel = position.length;\n let level;\n */\n const maxLevel = face > 5 ? position.length : 0;\n let level = 0;\n\n const point = [0, 0] as [number, number];\n\n for (let i = maxLevel - 1; i >= 0; i--) {\n level = maxLevel - i;\n const bit = position[i];\n let rx = 0;\n let ry = 0;\n if (bit === '1') {\n ry = 1;\n } else if (bit === '2') {\n rx = 1;\n ry = 1;\n } else if (bit === '3') {\n rx = 1;\n }\n\n const val = Math.pow(2, level - 1);\n rotateAndFlipQuadrant(val, point, rx, ry);\n\n point[0] += val * rx;\n point[1] += val * ry;\n }\n\n if (face % 2 === 1) {\n const t = point[0];\n point[0] = point[1];\n point[1] = t;\n }\n\n return {face, ij: point, level};\n}\n\nexport function toHilbertQuadkey(id: bigint): string {\n let bin = id.toString(2);\n\n while (bin.length < FACE_BITS + POS_BITS) {\n // eslint-disable-next-line prefer-template\n bin = '0' + bin;\n }\n\n // MUST come AFTER binstr has been left-padded with '0's\n const lsbIndex = bin.lastIndexOf('1');\n // substr(start, len)\n // substring(start, end) // includes start, does not include end\n const faceB = bin.substring(0, 3);\n // posB will always be a multiple of 2 (or it's invalid)\n const posB = bin.substring(3, lsbIndex);\n const levelN = posB.length / 2;\n\n const faceS = BigInt(`0b${faceB}`).toString(10);\n\n /*\n Here is a fix for the case when posB is an empty string that causes an exception in Long.fromString\n\n let posS = Long.fromString(posB, true, 2).toString(4);\n */\n let posS = '0';\n if (levelN !== 0) {\n // posB is not an empty string< because levelN!==0\n posS = BigInt(`0b${posB}`).toString(4);\n\n while (posS.length < levelN) {\n // eslint-disable-next-line prefer-template\n posS = '0' + posS;\n }\n }\n // Note, posS will be \"0\" for the level==0\n // TODO: Is it ok?\n\n return `${faceS}/${posS}`;\n}\n\nexport function IJToST(\n ij: [number, number],\n order: number,\n offsets: [number, number]\n): [number, number] {\n const maxSize = 1 << order;\n\n return [(ij[0] + offsets[0]) / maxSize, (ij[1] + offsets[1]) / maxSize];\n}\n\nfunction singleSTtoUV(st: number): number {\n if (st >= 0.5) {\n return (1 / 3.0) * (4 * st * st - 1);\n }\n return (1 / 3.0) * (1 - 4 * (1 - st) * (1 - st));\n}\n\nexport function STToUV(st: [number, number]): [number, number] {\n return [singleSTtoUV(st[0]), singleSTtoUV(st[1])];\n}\n\nexport function FaceUVToXYZ(face: number, [u, v]: [number, number]): [number, number, number] {\n switch (face) {\n case 0:\n return [1, u, v];\n case 1:\n return [-u, 1, v];\n case 2:\n return [-u, -v, 1];\n case 3:\n return [-1, -v, -u];\n case 4:\n return [v, -1, -u];\n case 5:\n return [v, u, -1];\n default:\n throw new Error('Invalid face');\n }\n}\n\nexport function XYZToLngLat([x, y, z]: [number, number, number]): [number, number] {\n const lat = Math.atan2(z, Math.sqrt(x * x + y * y));\n const lng = Math.atan2(y, x);\n\n return [lng * RADIAN_TO_DEGREE, lat * RADIAN_TO_DEGREE];\n}\n\nfunction rotateAndFlipQuadrant(n: number, point: [number, number], rx: number, ry: number): void {\n if (ry === 0) {\n if (rx === 1) {\n point[0] = n - 1 - point[0];\n point[1] = n - 1 - point[1];\n }\n\n const x = point[0];\n point[0] = point[1];\n point[1] = x;\n }\n}\n", "// math.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {IJToST, STToUV, FaceUVToXYZ, XYZToLngLat, getS2Cell} from './s2-geometry';\n\nconst MAX_RESOLUTION = 100;\n\nexport function getS2GeoBounds(s2Index: bigint): Float64Array {\n const s2Cell = getS2Cell(s2Index);\n return getS2GeoBoundsFromCell(s2Cell);\n}\n\n/**\n * The S2 cell edge is curved: http://s2geometry.io/\n * This is more prominent at lower levels\n * resolution is the number of segments to generate per edge.\n * We exponentially reduce resolution as level increases so it doesn't affect perf\n * when there are a large number of cells\n */\n// eslint-disable-next-line max-statements\nexport function getS2GeoBoundsFromCell({\n face,\n ij,\n level\n}: {\n face: number;\n ij: [number, number];\n level: number;\n}): Float64Array {\n const offsets = [\n [0, 0],\n [0, 1],\n [1, 1],\n [1, 0],\n [0, 0]\n ];\n\n const resolution = Math.max(1, Math.ceil(MAX_RESOLUTION * Math.pow(2, -level)));\n const result = new Float64Array(4 * resolution * 2 + 2);\n let ptIndex = 0;\n let prevLng = 0;\n\n for (let i = 0; i < 4; i++) {\n const offset = offsets[i].slice(0) as [number, number];\n const nextOffset = offsets[i + 1];\n const stepI = (nextOffset[0] - offset[0]) / resolution;\n const stepJ = (nextOffset[1] - offset[1]) / resolution;\n\n for (let j = 0; j < resolution; j++) {\n offset[0] += stepI;\n offset[1] += stepJ;\n // Cell can be represented by coordinates IJ, ST, UV, XYZ\n // http://s2geometry.io/devguide/s2cell_hierarchy#coordinate-systems\n const st = IJToST(ij, level, offset);\n const uv = STToUV(st);\n const xyz = FaceUVToXYZ(face, uv);\n const lngLat = XYZToLngLat(xyz);\n\n // Adjust longitude for Web Mercator projection\n if (Math.abs(lngLat[1]) > 89.999) {\n lngLat[0] = prevLng;\n }\n const deltaLng = lngLat[0] - prevLng;\n lngLat[0] += deltaLng > 180 ? -360 : deltaLng < -180 ? 360 : 0;\n\n result[ptIndex++] = lngLat[0];\n result[ptIndex++] = lngLat[1];\n prevLng = lngLat[0];\n }\n }\n // close the loop\n result[ptIndex++] = result[0];\n result[ptIndex++] = result[1];\n return result;\n}\n", "// math.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {type Bounds2D} from '@math.gl/types';\nimport {type GlobalGrid} from './global-grid';\n\nimport {getS2IndexFromToken, getS2TokenFromIndex} from '../s2-geometry/s2-token';\nimport {getS2GeoBounds} from '../s2-geometry/s2-to-boundary';\nimport {getS2Cell, IJToST, STToUV, FaceUVToXYZ, XYZToLngLat} from '../s2-geometry/s2-geometry';\n\n/** Decoder for the S2 DGGS */\nexport const S2Grid = {\n name: 'S2',\n hasNumericRepresentation: true,\n\n tokenToCell: (cell: string): bigint => getS2IndexFromToken(cell),\n cellToToken: (cell: string | bigint): string => getS2TokenFromIndex(getBigInt(cell)),\n cellToLngLat: (cell: string | bigint): [number, number] => getS2LngLat(getBigInt(cell)),\n cellToBoundary: (cell: string | bigint): [number, number][] => getS2Boundary(getBigInt(cell))\n\n // cellToBoundaryPolygonFlat: (cell: bigint): number[] => getS2BoundaryFlat(cell),\n // cellToBounds: (cell: bigint): Bounds2D => getS2Bounds(cell)\n} as const satisfies GlobalGrid;\n\n/** S2 functions operate on bigints */\nconst getBigInt = (value: string | bigint): bigint => {\n return typeof value === 'string' ? getS2IndexFromToken(value) : value;\n};\n\n/**\n * Retrieve S2 geometry center\n */\nexport function getS2LngLat(cell: bigint): [number, number] {\n const s2Cell = getS2Cell(cell);\n\n const st = IJToST(s2Cell.ij, s2Cell.level, [0.5, 0.5]);\n const uv = STToUV(st);\n const xyz = FaceUVToXYZ(s2Cell.face, uv);\n const lngLat = XYZToLngLat(xyz);\n\n return lngLat;\n}\n\n/**\n * Get a polygon with corner coordinates for an s2 cell\n * @param - This can be an S2 key or token\n * @return {Float64Array} - a simple polygon in flat array format: [lng0, lat0, lng1, lat1, ...]\n * - the polygon is closed, i.e. last coordinate is a copy of the first coordinate\n */\nfunction getS2BoundaryFlat(cell: bigint): number[] {\n const float64Array = getS2GeoBounds(cell);\n // TODO - inefficient\n return Array.from(float64Array);\n}\n\nfunction getS2Boundary(cell: bigint): [number, number][] {\n const flatBoundary = getS2BoundaryFlat(cell);\n const boundary: [number, number][] = [];\n for (let i = 0; i < flatBoundary.length; i += 2) {\n boundary.push([flatBoundary[i], flatBoundary[i + 1]]);\n }\n return boundary;\n}\n\nexport function getS2Bounds(cell: bigint): Bounds2D {\n const flatBoundary = getS2Boundary(cell);\n\n // We know that we have at least one point, no Infinity will be returned.\n let xmin = Infinity;\n let ymin = Infinity;\n let xmax = -Infinity;\n let ymax = -Infinity;\n\n for (const [x, y] of flatBoundary) {\n if (x < xmin) xmin = x;\n if (x > xmax) xmax = x;\n if (y < ymin) ymin = y;\n if (y > ymax) ymax = y;\n }\n\n return [\n [xmin, ymin],\n [xmax, ymax]\n ];\n}\n", "// math.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {type Bounds2D} from '@math.gl/types';\nimport {type GlobalGrid} from './global-grid';\n\n/** Decoder for the geohash global grid system */\nexport const GeohashGrid = {\n name: 'geohash',\n hasNumericRepresentation: false,\n\n cellToLngLat: (geohash: string | bigint): [number, number] =>\n getGeohashLngLat(getString(geohash)),\n cellToBoundary: (geohash: string | bigint): [number, number][] =>\n getGeohashBoundary(getString(geohash))\n // cellToBoundaryPolygonFlat: (geohash: bigint): number[] => getGeohashBoundaryFlat(geohash),\n // cellToBounds: (geohash: bigint): Bounds2D => getGeohashBounds(geohash)\n} as const satisfies GlobalGrid;\n\nconst getString = (geohash: string | bigint): string => {\n if (typeof geohash !== 'string') {\n throw new Error('geohash must be a string');\n }\n return geohash;\n};\n\nconst BASE32_CODES = '0123456789bcdefghjkmnpqrstuvwxyz';\nconst BASE32_CODES_DICT: Record<string, number> = {};\nfor (let i = 0; i < BASE32_CODES.length; i++) {\n BASE32_CODES_DICT[BASE32_CODES.charAt(i)] = i;\n}\n\nconst MIN_LAT = -90;\nconst MAX_LAT = 90;\nconst MIN_LON = -180;\nconst MAX_LON = 180;\n\n/** Return center lng,lat of geohash cell */\nfunction getGeohashLngLat(geohash: string): [number, number] {\n const [[s, w], [n, e]] = getGeohashBounds(geohash);\n return [(e + w) / 2, (n + s) / 2];\n}\n\n/** Return boundary polygon of geohash cell as lng,lat array */\nfunction getGeohashBoundary(geohash: string): [number, number][] {\n const [[s, w], [n, e]] = getGeohashBounds(geohash);\n return [\n [e, n],\n [e, s],\n [w, s],\n [w, n],\n [e, n]\n ];\n}\n\n/** Return boundary polygon of geohash cell as flat array */\nexport function getGeohashBoundaryFlat(geohash: string): number[] {\n const [[s, w], [n, e]] = getGeohashBounds(geohash);\n return [e, n, e, s, w, s, w, n, e, n];\n}\n\n/**\n * @note Adapted from ngeohash decode_bbox\n */\n/* eslint-disable max-depth */\nexport function getGeohashBounds(geohash: string): Bounds2D {\n let isLon = true;\n let maxLat = MAX_LAT;\n let minLat = MIN_LAT;\n let maxLon = MAX_LON;\n let minLon = MIN_LON;\n let mid: number;\n\n let hashValue = 0;\n for (let i = 0, l = geohash.length; i < l; i++) {\n const code = geohash[i].toLowerCase();\n hashValue = BASE32_CODES_DICT[code];\n\n for (let bits = 4; bits >= 0; bits--) {\n const bit = (hashValue >> bits) & 1;\n if (isLon) {\n mid = (maxLon + minLon) / 2;\n if (bit === 1) {\n minLon = mid;\n } else {\n maxLon = mid;\n }\n } else {\n mid = (maxLat + minLat) / 2;\n if (bit === 1) {\n minLat = mid;\n } else {\n maxLat = mid;\n }\n }\n isLon = !isLon;\n }\n }\n\n return [\n [minLat, minLon],\n [maxLat, maxLon]\n ];\n}\n", "// math.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {type Bounds2D} from '@math.gl/types';\nimport {type GlobalGrid} from './global-grid';\n\nconst TILE_SIZE = 512;\n\n/** Decoder for the quadkey DGGS */\nexport const QuadkeyGrid = {\n name: 'quadkey',\n hasNumericRepresentation: true,\n\n // cellToToken: (cell: bigint): string => quadkeyCellToToken(cell),\n // tokenToCell: (cell: string): bigint => quadKeyToBigint(cell),\n\n cellToLngLat: (cell: string | bigint): [number, number] => quadkeyCellToLngLat(getString(cell)),\n cellToBoundary: (cell: string | bigint): [number, number][] =>\n quadkeyCellToBoundary(getString(cell))\n\n // cellToBoundaryPolygonFlat: (cell: string | bigint): number[] => getQuadkeyBoundaryFlat(cell),\n // cellToBounds: (cell: string | bigint): Bounds2D => getQuadkeyBounds(cell)\n} as const satisfies GlobalGrid;\n\n/** Quadkey only supports strings */\nconst getString = (cell: string | bigint): string => {\n if (typeof cell !== 'string') {\n throw new Error('geohash must be a string');\n }\n return cell;\n};\n\nfunction quadkeyCellToLngLat(quadkey: string): [number, number] {\n const [topLeft, bottomRight] = quadkeyToWorldBounds(quadkey);\n const [w, n] = worldToLngLat(topLeft);\n const [e, s] = worldToLngLat(bottomRight);\n return [(e + w) / 2, (s + n) / 2];\n}\n\nfunction quadkeyCellToBoundary(quadkey: string): [number, number][] {\n const [topLeft, bottomRight] = quadkeyToWorldBounds(quadkey);\n const [w, n] = worldToLngLat(topLeft);\n const [e, s] = worldToLngLat(bottomRight);\n return [\n [e, n],\n [e, s],\n [w, s],\n [w, n],\n [e, n]\n ];\n}\n\nexport function quadkeyCellToBoundaryFlat(quadkey: string): number[] {\n const [topLeft, bottomRight] = quadkeyToWorldBounds(quadkey);\n const [w, n] = worldToLngLat(topLeft);\n const [e, s] = worldToLngLat(bottomRight);\n return [e, n, e, s, w, s, w, n, e, n];\n}\n\nexport function quadkeyCellToBounds(quadkey: string): Bounds2D {\n const [topLeft, bottomRight] = quadkeyToWorldBounds(quadkey);\n const [w, n] = worldToLngLat(topLeft);\n const [e, s] = worldToLngLat(bottomRight);\n return [\n [w, s],\n [e, n]\n ];\n}\n\nexport function quadkeyToWorldBounds(quadkey: string): [[number, number], [number, number]] {\n let x = 0;\n let y = 0;\n let mask = 1 << quadkey.length;\n const scale = mask / TILE_SIZE;\n\n for (let i = 0; i < quadkey.length; i++) {\n mask >>= 1;\n const q = parseInt(quadkey[i], 10);\n if (q % 2) x |= mask;\n if (q > 1) y |= mask;\n }\n return [\n [x / scale, TILE_SIZE - y / scale],\n [(x + 0.99) / scale, TILE_SIZE - (y + 0.99) / scale]\n ];\n}\n\n// CONSTANTS\nconst PI = Math.PI;\nconst PI_4 = PI / 4;\nconst RADIANS_TO_DEGREES = 180 / PI;\n\n/**\n * Unproject world point [x,y] on map onto {lat, lon} on sphere\n *\n * @param xy - array with [x,y] members\n * representing point on projected map plane\n * @return - array with [x,y] of point on sphere.\n * Has toArray method if you need a GeoJSON Array.\n * Per cartographic tradition, lat and lon are specified as degrees.\n */\nfunction worldToLngLat(xy: number[]): [number, number] {\n const [x, y] = xy;\n const lambda2 = (x / TILE_SIZE) * (2 * PI) - PI;\n const phi2 = 2 * (Math.atan(Math.exp((y / TILE_SIZE) * (2 * PI) - PI)) - PI_4);\n return [lambda2 * RADIANS_TO_DEGREES, phi2 * RADIANS_TO_DEGREES];\n}\n\n// EXPERIMENTAL BIGINT ENCODING FOR QUADKEYS\n\n/**\n * Encodes a QuadKey string into a bigint.\n * @param quadkey - The QuadKey string.\n * @returns The bigint representation of the QuadKey.\n */\nexport function quadKeyToBigint(quadkey: string): bigint {\n let result = 0n;\n for (const digit of quadkey) {\n const value = BigInt(parseInt(digit, 4));\n result = (result << 2n) | value;\n }\n const zoom = quadkey.length;\n // Shift the result to align with the most significant bits\n const shift = 64 - 5 - zoom * 2; // Reserve 5 bits for zoom level\n result = result << BigInt(shift);\n // Append the zoom level in the least significant 5 bits\n return result | BigInt(zoom);\n}\n\n/**\n * Decodes a bigint-encoded QuadKey back into its string representation.\n * @param encoded - The bigint representation of the QuadKey with embedded zoom level.\n * @returns The decoded QuadKey string.\n */\nexport function bigintToQuadKey(encoded: bigint): string {\n const zoom = Number(encoded & 0b11111n); // Extract the last 5 bits for zoom level\n const shift = BigInt(64 - 5 - zoom * 2); // Calculate the shift to align the QuadKey bits\n const quadkeyBits = (encoded >> shift) & ((1n << BigInt(zoom * 2)) - 1n); // Extract QuadKey bits\n let quadkey = '';\n for (let i = zoom - 1; i >= 0; i--) {\n const digit = Number((quadkeyBits >> BigInt(i * 2)) & 0b11n);\n quadkey += digit.toString();\n }\n return quadkey;\n}\n\n/**\n * Checks if the child QuadKey is contained within the parent QuadKey.\n * @param parent - The bigint representation of the parent QuadKey.\n * @param child - The bigint representation of the child QuadKey.\n * @returns True if the child is contained within the parent; otherwise, false.\n */\nexport function isContained(parent: bigint, child: bigint): boolean {\n const parentZoom = Number(parent & 0b11111n); // Extract zoom level from parent\n const childZoom = Number(child & 0b11111n); // Extract zoom level from child\n\n if (parentZoom >= childZoom) return false;\n\n const parentShift = BigInt(64 - 5 - parentZoom * 2);\n const childShift = BigInt(64 - 5 - childZoom * 2);\n\n const parentPrefix = (parent >> parentShift) & ((1n << BigInt(parentZoom * 2)) - 1n);\n const childPrefix = (child >> childShift) & ((1n << BigInt(parentZoom * 2)) - 1n);\n\n return parentPrefix === childPrefix;\n}\n\n/**\n * Decodes a bigint-encoded QuadKey into tile X, tile Y, and zoom level.\n * @param encoded - The bigint representation of the QuadKey with embedded zoom level.\n * @returns An object containing tileX, tileY, and zoom.\n */\nexport function decodeBigintQuadKey(encoded: bigint): {tileX: number; tileY: number; zoom: number} {\n const zoom = Number(encoded & 0b11111n); // Extract the last 5 bits for zoom level\n const quadKeyBits = encoded >> 5n; // Remove the zoom level bits\n\n let tileX = 0;\n let tileY = 0;\n\n for (let i = 0; i < zoom; i++) {\n const shift = BigInt((zoom - i - 1) * 2);\n const digit = Number((quadKeyBits >> shift) & 0b11n);\n const mask = 1 << (zoom - i - 1);\n if (digit & 1) tileX |= mask;\n if (digit & 2) tileY |= mask;\n }\n\n return {tileX, tileY, zoom};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;ACIA,kBAAoC;AAEpC,wBAAwB;AACxB,oBAAmD;AAInD,IAAM,mBAAoB,OAAO,WAAW,eAAe,OAAO,oBAAqB;AAajF,IAAO,kBAAP,cAA+B,2BAAoC;EAOvE,QAEI;EAEJ,kBAAe;AACb,SAAK,SAAS;MACZ,YAAY;KACb;EACH;EAEA,YAAY,EAAC,OAAO,YAAW,GAAC;AAC9B,SAAK,SAAS;MACZ,YAAY,MAAM;KACnB;EACH;EAEA,eAAY;AACV,UAAM,EAAC,YAAY,iBAAiB,UAAU,YAAW,IAAI,KAAK;AAClE,UAAM,WAAU,qCAAU,YAAW;AACrC,UAAM,WAAU,qCAAU,YAAW;AAErC,WAAO;MACL,IAAI,4BAAU;;QAEZ,IAAI,OAAO,WAAW,GAAG;QACzB,aAAa,WAAW;;QAExB,aAAa;QAEb,UAAU;QACV,gBAAgB;QAChB,eAAe;QACf,gBAAgB,CAAC,IAAI,IAAI,IAAI,EAAE;QAC/B;QACA;QACA,UAAU;;QAEV,YAAY,qBAAqB,IAAI,KAAK;QAC1C;;QAGA;QACA;OACD;;EAEL;;AAnDA,cADW,iBACJ,aAAY;AACn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OAAO,kBAAkB;AACjE;",
6
+ "names": ["import_geo_layers", "_h3IndexToSplitLong", "_cellToLatLng", "cellToBoundary", "_cellToBoundary", "_cellsToMultiPolygon", "cellToBoundary", "getBigInt", "getString"]
7
+ }
@@ -0,0 +1,10 @@
1
+ export type { TileSourceLayerProps } from "./tile-source-layer/tile-source-layer.js";
2
+ export { TileSourceLayer } from "./tile-source-layer/tile-source-layer.js";
3
+ export { GlobalGridLayer, type GlobalGridLayerProps } from "./global-grid-layer/global-grid-layer.js";
4
+ export { type GlobalGrid } from "./global-grid-systems/grids/global-grid.js";
5
+ export { A5Grid } from "./global-grid-systems/grids/a5-grid.js";
6
+ export { H3Grid } from "./global-grid-systems/grids/h3-grid.js";
7
+ export { S2Grid } from "./global-grid-systems/grids/s2-grid.js";
8
+ export { GeohashGrid } from "./global-grid-systems/grids/geohash-grid.js";
9
+ export { QuadkeyGrid } from "./global-grid-systems/grids/quadkey-grid.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,YAAY,EAAC,oBAAoB,EAAC,iDAA8C;AAChF,OAAO,EAAC,eAAe,EAAC,iDAA8C;AAEtE,OAAO,EAAC,eAAe,EAAE,KAAK,oBAAoB,EAAC,iDAA8C;AAEjG,OAAO,EAAC,KAAK,UAAU,EAAC,mDAAgD;AACxE,OAAO,EAAC,MAAM,EAAC,+CAA4C;AAC3D,OAAO,EAAC,MAAM,EAAC,+CAA4C;AAC3D,OAAO,EAAC,MAAM,EAAC,+CAA4C;AAC3D,OAAO,EAAC,WAAW,EAAC,oDAAiD;AACrE,OAAO,EAAC,WAAW,EAAC,oDAAiD"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ export { TileSourceLayer } from "./tile-source-layer/tile-source-layer.js";
5
+ export { GlobalGridLayer } from "./global-grid-layer/global-grid-layer.js";
6
+ export { A5Grid } from "./global-grid-systems/grids/a5-grid.js";
7
+ export { H3Grid } from "./global-grid-systems/grids/h3-grid.js";
8
+ export { S2Grid } from "./global-grid-systems/grids/s2-grid.js";
9
+ export { GeohashGrid } from "./global-grid-systems/grids/geohash-grid.js";
10
+ export { QuadkeyGrid } from "./global-grid-systems/grids/quadkey-grid.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,eAAe,EAAC,iDAA8C;AAEtE,OAAO,EAAC,eAAe,EAA4B,iDAA8C;AAGjG,OAAO,EAAC,MAAM,EAAC,+CAA4C;AAC3D,OAAO,EAAC,MAAM,EAAC,+CAA4C;AAC3D,OAAO,EAAC,MAAM,EAAC,+CAA4C;AAC3D,OAAO,EAAC,WAAW,EAAC,oDAAiD;AACrE,OAAO,EAAC,WAAW,EAAC,oDAAiD"}
@@ -0,0 +1,45 @@
1
+ import { CompositeLayer } from '@deck.gl/core';
2
+ import type { TileLayerProps } from '@deck.gl/geo-layers';
3
+ import { TileLayer } from '@deck.gl/geo-layers';
4
+ import type { TileSource } from '@loaders.gl/loader-utils';
5
+ export type TileSourceLayerProps = TileLayerProps & {
6
+ tileSource: TileSource<any>;
7
+ showTileBorders?: boolean;
8
+ };
9
+ /**
10
+ * A Deck.gl layer that renders a tile source
11
+ * Autodiscovers type of content (vector tile, bitmap, ...)
12
+ * Can render debug borders around tiles
13
+ * TODO - Change debug border color based on zoom level
14
+ */
15
+ export declare class TileSourceLayer extends CompositeLayer<TileSourceLayerProps> {
16
+ static layerName: string;
17
+ static defaultProps: {
18
+ showTileBorders: boolean;
19
+ };
20
+ state: {
21
+ tileSource: TileSource<any> | null;
22
+ };
23
+ initializeState(): void;
24
+ updateState({ props, changeFlags }: {
25
+ props: any;
26
+ changeFlags: any;
27
+ }): void;
28
+ renderLayers(): TileLayer<any, {
29
+ id: string;
30
+ getTileData: any;
31
+ maxRequests: 20;
32
+ pickable: true;
33
+ onViewportLoad: any;
34
+ autoHighlight: any;
35
+ highlightColor: number[];
36
+ minZoom: any;
37
+ maxZoom: any;
38
+ tileSize: 256;
39
+ zoomOffset: 0 | -1;
40
+ renderSubLayers: any;
41
+ tileSource: any;
42
+ showTileBorders: any;
43
+ }>[];
44
+ }
45
+ //# sourceMappingURL=tile-source-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile-source-layer.d.ts","sourceRoot":"","sources":["../../src/tile-source-layer/tile-source-layer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,EAAQ,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAKzD,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG;IAClD,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,oBAAoB,CAAC;IACvE,MAAM,CAAC,SAAS,SAAqB;IACrC,MAAM,CAAC,YAAY;;MAGjB;IAEF,KAAK,EAAE;QACL,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;KACpC,CAAc;IAEf,eAAe;IAMf,WAAW,CAAC,EAAC,KAAK,EAAE,WAAW,EAAC;;;KAAA;IAMhC,YAAY;;;;;;;;;;;;yBAsB8B,GAAG;;;;CAQ9C"}
@@ -0,0 +1,110 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { CompositeLayer } from '@deck.gl/core';
5
+ import { TileLayer } from '@deck.gl/geo-layers';
6
+ import { BitmapLayer, GeoJsonLayer, PathLayer } from '@deck.gl/layers';
7
+ /* global window */
8
+ const devicePixelRatio = (typeof window !== 'undefined' && window.devicePixelRatio) || 1;
9
+ /**
10
+ * A Deck.gl layer that renders a tile source
11
+ * Autodiscovers type of content (vector tile, bitmap, ...)
12
+ * Can render debug borders around tiles
13
+ * TODO - Change debug border color based on zoom level
14
+ */
15
+ export class TileSourceLayer extends CompositeLayer {
16
+ static layerName = 'TileSourceLayer';
17
+ static defaultProps = {
18
+ ...TileLayer.defaultProps,
19
+ showTileBorders: true
20
+ };
21
+ state = undefined;
22
+ initializeState() {
23
+ this.setState({
24
+ tileSource: null
25
+ });
26
+ }
27
+ updateState({ props, changeFlags }) {
28
+ this.setState({
29
+ tileSource: props.tileSource
30
+ });
31
+ }
32
+ renderLayers() {
33
+ const { tileSource, showTileBorders, metadata, onTilesLoad } = this.props;
34
+ const minZoom = metadata?.minZoom || 0;
35
+ const maxZoom = metadata?.maxZoom || 30;
36
+ return [
37
+ new TileLayer({
38
+ // HACK: Trigger new layer via id prop to force clear tile cache
39
+ id: String(tileSource.url),
40
+ getTileData: tileSource.getTileData,
41
+ // Assume the pmtiles file support HTTP/2, so we aren't limited by the browser to a certain number per domain.
42
+ maxRequests: 20,
43
+ pickable: true,
44
+ onViewportLoad: onTilesLoad,
45
+ autoHighlight: showTileBorders,
46
+ highlightColor: [60, 60, 60, 40],
47
+ minZoom,
48
+ maxZoom,
49
+ tileSize: 256,
50
+ // TOOD - why is this needed?
51
+ zoomOffset: devicePixelRatio === 1 ? -1 : 0,
52
+ renderSubLayers: renderSubLayers,
53
+ // Custom prop
54
+ tileSource,
55
+ showTileBorders
56
+ })
57
+ ];
58
+ }
59
+ }
60
+ function renderSubLayers(props) {
61
+ const { tileSource, showTileBorders, minZoom, maxZoom, tile: { index: { z: zoom }, bbox: { west, south, east, north } } } = props;
62
+ const layers = [];
63
+ const borderColor = zoom <= minZoom || zoom >= maxZoom ? [255, 0, 0, 255] : [0, 0, 255, 255];
64
+ switch (tileSource.mimeType) {
65
+ case 'application/vnd.mapbox-vector-tile':
66
+ layers.push(new GeoJsonLayer({
67
+ id: `${props.id}-geojson`,
68
+ data: props.data,
69
+ pickable: true,
70
+ getFillColor: [0, 190, 80, 255],
71
+ lineWidthScale: 500,
72
+ lineWidthMinPixels: 0.5
73
+ }));
74
+ break;
75
+ case 'image/png':
76
+ case 'image/jpeg':
77
+ case 'image/webp':
78
+ case 'image/avif':
79
+ layers.push(new BitmapLayer(props, {
80
+ data: null,
81
+ image: props.data,
82
+ bounds: [west, south, east, north],
83
+ pickable: true
84
+ }));
85
+ break;
86
+ default:
87
+ // eslint-disable-next-line no-console
88
+ console.error('Unknown tile mimeType', tileSource?.mimeType);
89
+ }
90
+ // Debug tile borders
91
+ if (showTileBorders) {
92
+ layers.push(new PathLayer({
93
+ id: `${props.id}-border`,
94
+ data: [
95
+ [
96
+ [west, north],
97
+ [west, south],
98
+ [east, south],
99
+ [east, north],
100
+ [west, north]
101
+ ]
102
+ ],
103
+ getPath: (d) => d,
104
+ getColor: borderColor,
105
+ widthMinPixels: 4
106
+ }));
107
+ }
108
+ return layers;
109
+ }
110
+ //# sourceMappingURL=tile-source-layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile-source-layer.js","sourceRoot":"","sources":["../../src/tile-source-layer/tile-source-layer.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,cAAc,EAAQ,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,WAAW,EAAE,YAAY,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAGrE,mBAAmB;AACnB,MAAM,gBAAgB,GAAG,CAAC,OAAO,MAAM,KAAK,WAAW,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EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;gBAClC,QAAQ,EAAE,IAAI;aACR,CACT,CACF,CAAC;YACF,MAAM;QAER;YACE,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED,qBAAqB;IACrB,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CACT,IAAI,SAAS,CAAC;YACZ,EAAE,EAAE,GAAG,KAAK,CAAC,EAAE,SAAS;YACxB,IAAI,EAAE;gBACJ;oBACE,CAAC,IAAI,EAAE,KAAK,CAAC;oBACb,CAAC,IAAI,EAAE,KAAK,CAAC;oBACb,CAAC,IAAI,EAAE,KAAK,CAAC;oBACb,CAAC,IAAI,EAAE,KAAK,CAAC;oBACb,CAAC,IAAI,EAAE,KAAK,CAAC;iBACd;aACF;YACD,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACjB,QAAQ,EAAE,WAAkB;YAC5B,cAAc,EAAE,CAAC;SAClB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@deck.gl-community/geo-layers",
3
+ "version": "9.2.0-beta.3",
4
+ "description": "Add-0n geospatial layers for deck.gl",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "keywords": [
10
+ "layers",
11
+ "visualization",
12
+ "gpu",
13
+ "deck.gl"
14
+ ],
15
+ "type": "module",
16
+ "sideEffects": false,
17
+ "types": "./dist/index.d.ts",
18
+ "main": "./dist/index.cjs",
19
+ "module": "./dist/index.js",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "require": "./dist/index.cjs",
24
+ "import": "./dist/index.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "src"
30
+ ],
31
+ "scripts": {
32
+ "test": "vitest run",
33
+ "test-watch": "vitest"
34
+ },
35
+ "dependencies": {
36
+ "@deck.gl/core": "~9.2.1",
37
+ "@deck.gl/geo-layers": "~9.2.1",
38
+ "@deck.gl/layers": "~9.2.1",
39
+ "@loaders.gl/loader-utils": "^4.2.0",
40
+ "@luma.gl/core": "~9.2.0",
41
+ "@luma.gl/engine": "~9.2.0",
42
+ "@luma.gl/shadertools": "~9.2.0",
43
+ "@math.gl/core": "^4.0.0",
44
+ "a5-js": "^0.5.0",
45
+ "h3-js": "^4.2.1"
46
+ },
47
+ "devDependencies": {
48
+ "@deck.gl/test-utils": "~9.2.1",
49
+ "@luma.gl/webgpu": "~9.2.0",
50
+ "@probe.gl/test-utils": "^4.0.4"
51
+ },
52
+ "gitHead": "6110b774c8be16f199ecdf67723851a2e34901e5"
53
+ }
@@ -0,0 +1,93 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {
6
+ type AccessorFunction,
7
+ type UpdateParameters,
8
+ type DefaultProps,
9
+ createIterable
10
+ } from '@deck.gl/core';
11
+ import {_GeoCellLayer, type _GeoCellLayerProps} from '@deck.gl/geo-layers';
12
+ import {type GlobalGrid} from '../global-grid-systems/grids/global-grid';
13
+ import {normalizeLongitudes} from '../global-grid-systems/utils/geometry-utils';
14
+
15
+ /** All properties supported by GlobalGridClusterLayer. */
16
+ export type GlobalGridClusterLayerProps<DataT = unknown> = _GlobalGridClusterLayerProps<DataT> &
17
+ _GeoCellLayerProps<DataT>;
18
+
19
+ /** Properties added by GlobalGridClusterLayer. */
20
+ type _GlobalGridClusterLayerProps<DataT> = {
21
+ /** The DGGS decoder to use. */
22
+ globalGrid: GlobalGrid;
23
+ /** Called for each data object to retrieve the hexagon identifiers. By default, it reads `cellIds` property of data object. */
24
+ getCellIds?: AccessorFunction<DataT, string[] | bigint[]>;
25
+ };
26
+
27
+ export class GlobalGridClusterLayer<DataT = any, ExtraProps extends {} = {}> extends _GeoCellLayer<
28
+ DataT,
29
+ Required<_GlobalGridClusterLayerProps<DataT>> & ExtraProps
30
+ > {
31
+ static layerName = 'GlobalGridClusterLayer';
32
+ static defaultProps = {
33
+ getCellIds: {type: 'accessor', value: (d: any) => d.cellIds},
34
+ globalGrid: {type: 'object', compare: true, value: undefined!}
35
+ } as const satisfies DefaultProps<GlobalGridClusterLayerProps>;
36
+
37
+ declare state: {
38
+ polygons: {polygon: number[][][]}[];
39
+ };
40
+
41
+ initializeState(): void {
42
+ this.props.globalGrid.initialize?.();
43
+ }
44
+
45
+ updateState({props, changeFlags}: UpdateParameters<this>): void {
46
+ if (
47
+ changeFlags.dataChanged ||
48
+ (changeFlags.updateTriggersChanged && changeFlags.updateTriggersChanged.getCellIds)
49
+ ) {
50
+ const {data, getCellIds, globalGrid} = props;
51
+ const polygons: {polygon: number[][][]}[] = [];
52
+
53
+ const {iterable, objectInfo} = createIterable(data);
54
+ for (const object of iterable) {
55
+ objectInfo.index++;
56
+ const cellIds = getCellIds(object, objectInfo);
57
+ if (!globalGrid.cellsToBoundaryMultiPolygon) {
58
+ throw new Error(`${globalGrid.name} adapter: cellsToBoundaryMultiPolygon not supported`);
59
+ }
60
+ // TODO - should not need to map the tokens
61
+ const cellIndexes = cellIds.map((cellId) =>
62
+ typeof cellId === 'string' ? globalGrid.tokenToCell?.(cellId) : cellId
63
+ );
64
+ const multiPolygon = globalGrid.cellsToBoundaryMultiPolygon(cellIndexes);
65
+
66
+ for (const polygon of multiPolygon) {
67
+ // Normalize polygons to prevent wrapping over the anti-meridian
68
+ // eslint-disable-next-line max-depth
69
+ for (const ring of polygon) {
70
+ normalizeLongitudes(ring);
71
+ }
72
+ polygons.push(this.getSubLayerRow({polygon}, object, objectInfo.index));
73
+ }
74
+ }
75
+
76
+ this.setState({polygons});
77
+ }
78
+ }
79
+
80
+ indexToBounds(): Partial<_GeoCellLayer['props']> {
81
+ const {getElevation, getFillColor, getLineColor, getLineWidth} = this.props;
82
+
83
+ return {
84
+ data: this.state.polygons,
85
+ getPolygon: (d) => d.polygon,
86
+
87
+ getElevation: this.getSubLayerAccessor(getElevation),
88
+ getFillColor: this.getSubLayerAccessor(getFillColor),
89
+ getLineColor: this.getSubLayerAccessor(getLineColor),
90
+ getLineWidth: this.getSubLayerAccessor(getLineWidth)
91
+ };
92
+ }
93
+ }
@@ -0,0 +1,54 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {type AccessorFunction, type DefaultProps} from '@deck.gl/core';
6
+ import {_GeoCellLayer, type _GeoCellLayerProps} from '@deck.gl/geo-layers';
7
+ import {GlobalGrid} from '../global-grid-systems/grids/global-grid';
8
+ import {flattenPolygon} from '../global-grid-systems/utils/geometry-utils';
9
+
10
+ /** All properties supported by GlobalGridLayer. */
11
+ export type GlobalGridLayerProps<DataT = unknown> = _GlobalGridLayerProps<DataT> &
12
+ _GeoCellLayerProps<DataT>;
13
+
14
+ /** Properties added by GlobalGridLayer. */
15
+ type _GlobalGridLayerProps<DataT> = {
16
+ /** The DGGS decoder to use. */
17
+ globalGrid: GlobalGrid;
18
+ /** Called for each data object to retrieve the DGGS cell identifier. By default, it reads `cellId` property of data object. */
19
+ getCellId?: AccessorFunction<DataT, string | bigint>;
20
+ };
21
+
22
+ /** Render filled and/or stroked polygons based on the specified DGGS geospatial indexing system. */
23
+ export class GlobalGridLayer<DataT = any, ExtraProps extends {} = {}> extends _GeoCellLayer<
24
+ DataT,
25
+ Required<_GlobalGridLayerProps<DataT>> & ExtraProps
26
+ > {
27
+ static layerName = 'GlobalGridLayer';
28
+ static defaultProps: DefaultProps<GlobalGridLayerProps> = {
29
+ getCellId: {type: 'accessor', value: (d: any) => d.cellId},
30
+ globalGrid: {type: 'object', compare: true, value: undefined!}
31
+ };
32
+
33
+ initializeState(): void {
34
+ this.props.globalGrid?.initialize?.();
35
+ }
36
+
37
+ indexToBounds(): Partial<_GeoCellLayer['props']> | null {
38
+ const {data, getCellId} = this.props;
39
+
40
+ return {
41
+ data,
42
+ _normalize: false,
43
+ _windingOrder: 'CCW',
44
+ positionFormat: 'XY',
45
+ getPolygon: (x: DataT, objectInfo) => {
46
+ const {globalGrid} = this.props;
47
+ const cell = getCellId(x, objectInfo);
48
+ const boundary = globalGrid.cellToBoundary(cell);
49
+ boundary.push(boundary[0]);
50
+ return flattenPolygon(boundary);
51
+ }
52
+ };
53
+ }
54
+ }
@@ -0,0 +1,38 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ // import {type Bounds2D} from '@math.gl/types';
6
+ import {type GlobalGrid} from './global-grid';
7
+ import {cellToBoundary, cellToLonLat, lonLatToCell} from 'a5-js';
8
+ import { hexToBigInt } from '../utils/hex-utils';
9
+
10
+ // TODO - internal types in a5-js
11
+ type Degrees = number & {
12
+ __brand: 'Degrees';
13
+ };
14
+ type LonLat = [longitude: Degrees, latitude: Degrees] & {
15
+ __brand: 'LonLat';
16
+ };
17
+
18
+ /**
19
+ * "Standardized" API for working with A5 DGGS tokens.
20
+ * @note Copy of same type in math.gl. They are structurally identical. Will be replaced by an import in the future.
21
+ */
22
+ export const A5Grid = {
23
+ name: 'A5',
24
+ hasNumericRepresentation: true,
25
+
26
+ tokenToCell: (token: string) => hexToBigInt(token),
27
+ lngLatToCell: (lngLat: [number, number], resolution: number) =>
28
+ lonLatToCell(lngLat as LonLat, resolution),
29
+
30
+ cellToToken: (cell: string | bigint) => (typeof cell === 'string' ? cell : cell.toString(16)),
31
+ cellToLngLat: (cell: string | bigint) => cellToLonLat(getBigInt(cell)),
32
+ cellToBoundary: (cell: string | bigint) => cellToBoundary(getBigInt(cell))
33
+ } as const satisfies GlobalGrid;
34
+
35
+ /** Helper function to convert cells to bigints */
36
+ const getBigInt = (value: string | bigint): bigint => {
37
+ return typeof value === 'string' ? hexToBigInt(value) : value;
38
+ };