@gisatcz/deckgl-geolib 2.6.0-dev.1 → 2.6.0-dev.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.
@@ -0,0 +1,37 @@
1
+ import { useState } from 'react';
2
+
3
+ /**
4
+ * React hook for syncing terrain elevation bounds to overlay TileLayer for 3D frustum culling.
5
+ *
6
+ * Manages the zRange state needed to prevent foreground tile clipping when viewport is tilted in 3D.
7
+ *
8
+ * @returns Object with zRange state and onZRangeUpdate callback
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const { zRange, onZRangeUpdate } = useTerrainZRange();
13
+ *
14
+ * const layers = useMemo(() => [
15
+ * new TileLayer({
16
+ * id: 'osm',
17
+ * zRange: zRange, // Pass elevation bounds to overlay
18
+ * // ... other props
19
+ * }),
20
+ * new CogTerrainLayer({
21
+ * id: 'terrain',
22
+ * onZRangeUpdate: onZRangeUpdate, // Sync elevation bounds from terrain
23
+ * // ... other props
24
+ * }),
25
+ * ], [zRange]);
26
+ * ```
27
+ */
28
+ function useTerrainZRange() {
29
+ const [zRange, setZRange] = useState(null);
30
+ return {
31
+ zRange,
32
+ onZRangeUpdate: setZRange,
33
+ };
34
+ }
35
+
36
+ export { useTerrainZRange };
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/hooks/useTerrainZRange.ts"],"sourcesContent":["import { useState } from 'react';\nimport type { ZRange } from '../layers/CogTerrainLayer';\n\n/**\n * React hook for syncing terrain elevation bounds to overlay TileLayer for 3D frustum culling.\n *\n * Manages the zRange state needed to prevent foreground tile clipping when viewport is tilted in 3D.\n *\n * @returns Object with zRange state and onZRangeUpdate callback\n *\n * @example\n * ```typescript\n * const { zRange, onZRangeUpdate } = useTerrainZRange();\n *\n * const layers = useMemo(() => [\n * new TileLayer({\n * id: 'osm',\n * zRange: zRange, // Pass elevation bounds to overlay\n * // ... other props\n * }),\n * new CogTerrainLayer({\n * id: 'terrain',\n * onZRangeUpdate: onZRangeUpdate, // Sync elevation bounds from terrain\n * // ... other props\n * }),\n * ], [zRange]);\n * ```\n */\nexport function useTerrainZRange() {\n const [zRange, setZRange] = useState<ZRange | null>(null);\n\n return {\n zRange,\n onZRangeUpdate: setZRange,\n };\n}\n"],"names":[],"mappings":";;AAGA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;SACa,gBAAgB,GAAA;IAC9B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC;IAEzD,OAAO;QACL,MAAM;AACN,QAAA,cAAc,EAAE,SAAS;KAC1B;AACH;;;;"}
@@ -0,0 +1,2 @@
1
+ import{useState as n}from"react";function t(){const[t,e]=n(null);return{zRange:t,onZRangeUpdate:e}}export{t as useTerrainZRange};
2
+ //# sourceMappingURL=index.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.min.js","sources":["../../../src/hooks/useTerrainZRange.ts"],"sourcesContent":["import { useState } from 'react';\nimport type { ZRange } from '../layers/CogTerrainLayer';\n\n/**\n * React hook for syncing terrain elevation bounds to overlay TileLayer for 3D frustum culling.\n *\n * Manages the zRange state needed to prevent foreground tile clipping when viewport is tilted in 3D.\n *\n * @returns Object with zRange state and onZRangeUpdate callback\n *\n * @example\n * ```typescript\n * const { zRange, onZRangeUpdate } = useTerrainZRange();\n *\n * const layers = useMemo(() => [\n * new TileLayer({\n * id: 'osm',\n * zRange: zRange, // Pass elevation bounds to overlay\n * // ... other props\n * }),\n * new CogTerrainLayer({\n * id: 'terrain',\n * onZRangeUpdate: onZRangeUpdate, // Sync elevation bounds from terrain\n * // ... other props\n * }),\n * ], [zRange]);\n * ```\n */\nexport function useTerrainZRange() {\n const [zRange, setZRange] = useState<ZRange | null>(null);\n\n return {\n zRange,\n onZRangeUpdate: setZRange,\n };\n}\n"],"names":["useTerrainZRange","zRange","setZRange","useState","onZRangeUpdate"],"mappings":"0CA4BgBA,IACd,MAAOC,EAAQC,GAAaC,EAAwB,MAEpD,MAAO,CACLF,SACAG,eAAgBF,EAEpB"}
@@ -0,0 +1 @@
1
+ export { useTerrainZRange } from './useTerrainZRange';
@@ -0,0 +1,30 @@
1
+ import type { ZRange } from '../layers/CogTerrainLayer';
2
+ /**
3
+ * React hook for syncing terrain elevation bounds to overlay TileLayer for 3D frustum culling.
4
+ *
5
+ * Manages the zRange state needed to prevent foreground tile clipping when viewport is tilted in 3D.
6
+ *
7
+ * @returns Object with zRange state and onZRangeUpdate callback
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const { zRange, onZRangeUpdate } = useTerrainZRange();
12
+ *
13
+ * const layers = useMemo(() => [
14
+ * new TileLayer({
15
+ * id: 'osm',
16
+ * zRange: zRange, // Pass elevation bounds to overlay
17
+ * // ... other props
18
+ * }),
19
+ * new CogTerrainLayer({
20
+ * id: 'terrain',
21
+ * onZRangeUpdate: onZRangeUpdate, // Sync elevation bounds from terrain
22
+ * // ... other props
23
+ * }),
24
+ * ], [zRange]);
25
+ * ```
26
+ */
27
+ export declare function useTerrainZRange(): {
28
+ zRange: ZRange | null;
29
+ onZRangeUpdate: import("react").Dispatch<import("react").SetStateAction<ZRange | null>>;
30
+ };
@@ -1,4 +1,6 @@
1
1
  export { CogBitmapLayer, CogTerrainLayer } from './layers/index';
2
2
  export { CogTiles, GeoImage } from './core/index';
3
3
  export { suppressGlobalAbortErrors } from './utils/suppressAbortErrors';
4
+ export { extractTerrainCoordinate, sampleTerrainTileCoordinates } from './utils/terrainPickingUtils';
4
5
  export type { GeoImageOptions } from './core/index';
6
+ export type { TerrainCoordinate } from './utils/terrainPickingUtils';
@@ -61,6 +61,11 @@ type _CogTerrainLayerProps = {
61
61
  * Useful for showing a neutral grey terrain during mode transitions.
62
62
  */
63
63
  disableTexture?: boolean;
64
+ /**
65
+ * Callback fired when the terrain zRange is updated.
66
+ * Used to sync overlay TileLayer zRange for proper 3D frustum culling.
67
+ */
68
+ onZRangeUpdate?: (zRange: ZRange | null) => void;
64
69
  /**
65
70
  * @deprecated Use `loadOptions.terrain.workerUrl` instead
66
71
  */
@@ -0,0 +1 @@
1
+ export { useTerrainZRange } from '../hooks/index';
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Terrain coordinate extraction utility for CogTerrainLayer
3
+ * Enables precise lat/lon/elevation extraction from 3D terrain picks
4
+ */
5
+ /**
6
+ * Represents a geographic coordinate with elevation from terrain picking
7
+ */
8
+ export interface TerrainCoordinate {
9
+ /** Longitude in degrees */
10
+ longitude: number;
11
+ /** Latitude in degrees */
12
+ latitude: number;
13
+ /** Elevation in meters */
14
+ elevation: number;
15
+ }
16
+ /**
17
+ * Extracts precise geographic coordinates and elevation from a CogTerrainLayer pick result
18
+ *
19
+ * @param pickResult - DeckGL pickObject result from terrain-layer pick
20
+ * @returns TerrainCoordinate with lon/lat/elevation, or null if extraction fails
21
+ *
22
+ * @requires deck.gl >=9.3.0 (for `pickable: '3d'` support)
23
+ * @note Requires `pickable: '3d'` on CogTerrainLayer. With 3D picking enabled,
24
+ * deck.gl's terrain layer provides info.coordinate as a 3-element array [lon, lat, elevation]
25
+ * where elevation is read directly from the terrain mesh at the picked point.
26
+ * This gives accurate 3D coordinates regardless of camera pitch or bearing.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const cogLayer = new CogTerrainLayer({
31
+ * // ...
32
+ * pickable: '3d', // Requires deck.gl >=9.3.0
33
+ * onClick: (info) => {
34
+ * const coord = extractTerrainCoordinate(info);
35
+ * if (coord) {
36
+ * console.log(`Clicked at ${coord.latitude}, ${coord.longitude}, elevation: ${coord.elevation}m`);
37
+ * }
38
+ * }
39
+ * });
40
+ * ```
41
+ */
42
+ export declare function extractTerrainCoordinate(pickResult: any): TerrainCoordinate | null;
43
+ /**
44
+ * Samples terrain coordinates in a grid around a pick point for debugging
45
+ * Useful for understanding terrain data layout and accuracy
46
+ *
47
+ * @param pickResult - DeckGL pickObject result from terrain-layer pick
48
+ * @param gridSize - Odd number for grid dimensions (default: 3 for 3x3 grid).
49
+ * gridSize=3 → 3×3 grid (offset±1), gridSize=5 → 5×5 grid (offset±2).
50
+ * Uses WebMercator projection for accurate latitude mapping.
51
+ * @returns Array of TerrainCoordinate samples, or empty array if extraction fails
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const samples = sampleTerrainTileCoordinates(info, 5); // 5x5 grid around click
56
+ * samples.forEach(coord => {
57
+ * console.log(`Sample: ${coord.latitude}, ${coord.longitude}, elev: ${coord.elevation}m`);
58
+ * });
59
+ * ```
60
+ */
61
+ export declare function sampleTerrainTileCoordinates(pickResult: any, gridSize?: number): TerrainCoordinate[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisatcz/deckgl-geolib",
3
- "version": "2.6.0-dev.1",
3
+ "version": "2.6.0-dev.3",
4
4
  "description": "Deck.gl extension for rendering Cloud-Optimized GeoTIFF (COG) data",
5
5
  "keywords": [
6
6
  "deck.gl",
@@ -30,6 +30,11 @@
30
30
  "types": "./dist/esm/types/index.d.ts",
31
31
  "import": "./dist/esm/index.js",
32
32
  "require": "./dist/cjs/index.js"
33
+ },
34
+ "./react": {
35
+ "types": "./dist/esm/types/react/index.d.ts",
36
+ "import": "./dist/esm/react/index.js",
37
+ "require": "./dist/cjs/react/index.js"
33
38
  }
34
39
  },
35
40
  "sideEffects": false,
@@ -64,20 +69,26 @@
64
69
  "@loaders.gl/schema": ">=4.0.0",
65
70
  "@luma.gl/core": ">=9.0.0",
66
71
  "@luma.gl/engine": ">=9.0.0",
67
- "@luma.gl/shadertools": ">=9.0.0"
72
+ "@luma.gl/shadertools": ">=9.0.0",
73
+ "react": ">=16.8.0"
74
+ },
75
+ "peerDependenciesMeta": {
76
+ "react": {
77
+ "optional": true
78
+ }
68
79
  },
69
80
  "devDependencies": {
70
- "@deck.gl/core": "^9.2.11",
71
- "@deck.gl/extensions": "^9.2.11",
72
- "@deck.gl/geo-layers": "^9.2.11",
73
- "@deck.gl/layers": "^9.2.11",
74
- "@deck.gl/mesh-layers": "^9.2.11",
75
- "@loaders.gl/core": "^4.3.4",
76
- "@loaders.gl/loader-utils": "^4.3.4",
77
- "@loaders.gl/schema": "^4.3.4",
78
- "@luma.gl/core": "^9.2.6",
79
- "@luma.gl/engine": "^9.2.6",
80
- "@luma.gl/shadertools": "^9.2.6",
81
+ "@deck.gl/core": "^9.3.2",
82
+ "@deck.gl/extensions": "^9.3.2",
83
+ "@deck.gl/geo-layers": "^9.3.2",
84
+ "@deck.gl/layers": "^9.3.2",
85
+ "@deck.gl/mesh-layers": "^9.3.2",
86
+ "@loaders.gl/core": "^4.4.1",
87
+ "@loaders.gl/loader-utils": "^4.4.1",
88
+ "@loaders.gl/schema": "^4.4.1",
89
+ "@luma.gl/core": "^9.3.3",
90
+ "@luma.gl/engine": "^9.3.3",
91
+ "@luma.gl/shadertools": "^9.3.3",
81
92
  "@rollup/plugin-commonjs": "^29.0.2",
82
93
  "@rollup/plugin-json": "^6.1.0",
83
94
  "@rollup/plugin-node-resolve": "^16.0.3",