@sqlrooms/deck 0.29.0-rc.10
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.md +10 -0
- package/README.md +654 -0
- package/dist/BlockMapSettings.d.ts +3 -0
- package/dist/BlockMapSettings.d.ts.map +1 -0
- package/dist/BlockMapSettings.js +57 -0
- package/dist/BlockMapSettings.js.map +1 -0
- package/dist/DashboardMapSettings.d.ts +7 -0
- package/dist/DashboardMapSettings.d.ts.map +1 -0
- package/dist/DashboardMapSettings.js +52 -0
- package/dist/DashboardMapSettings.js.map +1 -0
- package/dist/DeckJsonMap.d.ts +4 -0
- package/dist/DeckJsonMap.d.ts.map +1 -0
- package/dist/DeckJsonMap.js +370 -0
- package/dist/DeckJsonMap.js.map +1 -0
- package/dist/DeckJsonMapSpec.d.ts +7617 -0
- package/dist/DeckJsonMapSpec.d.ts.map +1 -0
- package/dist/DeckJsonMapSpec.js +82 -0
- package/dist/DeckJsonMapSpec.js.map +1 -0
- package/dist/DeckMapDefaultStylesProvider.d.ts +28 -0
- package/dist/DeckMapDefaultStylesProvider.d.ts.map +1 -0
- package/dist/DeckMapDefaultStylesProvider.js +23 -0
- package/dist/DeckMapDefaultStylesProvider.js.map +1 -0
- package/dist/DeckMapSurface.d.ts +39 -0
- package/dist/DeckMapSurface.d.ts.map +1 -0
- package/dist/DeckMapSurface.js +137 -0
- package/dist/DeckMapSurface.js.map +1 -0
- package/dist/DeckMapsSlice.d.ts +99 -0
- package/dist/DeckMapsSlice.d.ts.map +1 -0
- package/dist/DeckMapsSlice.js +89 -0
- package/dist/DeckMapsSlice.js.map +1 -0
- package/dist/MapSettings.d.ts +16 -0
- package/dist/MapSettings.d.ts.map +1 -0
- package/dist/MapSettings.js +292 -0
- package/dist/MapSettings.js.map +1 -0
- package/dist/MapSettingsControls.d.ts +40 -0
- package/dist/MapSettingsControls.d.ts.map +1 -0
- package/dist/MapSettingsControls.js +54 -0
- package/dist/MapSettingsControls.js.map +1 -0
- package/dist/ai.d.ts +261 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +392 -0
- package/dist/ai.js.map +1 -0
- package/dist/block.d.ts +21 -0
- package/dist/block.d.ts.map +1 -0
- package/dist/block.js +105 -0
- package/dist/block.js.map +1 -0
- package/dist/blockDocumentRegistration.d.ts +45 -0
- package/dist/blockDocumentRegistration.d.ts.map +1 -0
- package/dist/blockDocumentRegistration.js +68 -0
- package/dist/blockDocumentRegistration.js.map +1 -0
- package/dist/createDeckJsonSpecFromDatasets.d.ts +11 -0
- package/dist/createDeckJsonSpecFromDatasets.d.ts.map +1 -0
- package/dist/createDeckJsonSpecFromDatasets.js +85 -0
- package/dist/createDeckJsonSpecFromDatasets.js.map +1 -0
- package/dist/createOrUpdateDeckMapResource.d.ts +81 -0
- package/dist/createOrUpdateDeckMapResource.d.ts.map +1 -0
- package/dist/createOrUpdateDeckMapResource.js +82 -0
- package/dist/createOrUpdateDeckMapResource.js.map +1 -0
- package/dist/dashboard.d.ts +6 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/dashboard.js +337 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/dashboardConfig.d.ts +25 -0
- package/dist/dashboardConfig.d.ts.map +1 -0
- package/dist/dashboardConfig.js +82 -0
- package/dist/dashboardConfig.js.map +1 -0
- package/dist/dashboardIntegration.d.ts +3 -0
- package/dist/dashboardIntegration.d.ts.map +1 -0
- package/dist/dashboardIntegration.js +16 -0
- package/dist/dashboardIntegration.js.map +1 -0
- package/dist/datasetSourceUtils.d.ts +16 -0
- package/dist/datasetSourceUtils.d.ts.map +1 -0
- package/dist/datasetSourceUtils.js +25 -0
- package/dist/datasetSourceUtils.js.map +1 -0
- package/dist/datasets/PreparedDatasetStore.d.ts +120 -0
- package/dist/datasets/PreparedDatasetStore.d.ts.map +1 -0
- package/dist/datasets/PreparedDatasetStore.js +268 -0
- package/dist/datasets/PreparedDatasetStore.js.map +1 -0
- package/dist/datasets/helpers.d.ts +57 -0
- package/dist/datasets/helpers.d.ts.map +1 -0
- package/dist/datasets/helpers.js +155 -0
- package/dist/datasets/helpers.js.map +1 -0
- package/dist/datasets/normalizeDatasets.d.ts +11 -0
- package/dist/datasets/normalizeDatasets.d.ts.map +1 -0
- package/dist/datasets/normalizeDatasets.js +50 -0
- package/dist/datasets/normalizeDatasets.js.map +1 -0
- package/dist/datasets/tableAdapter.d.ts +11 -0
- package/dist/datasets/tableAdapter.d.ts.map +1 -0
- package/dist/datasets/tableAdapter.js +11 -0
- package/dist/datasets/tableAdapter.js.map +1 -0
- package/dist/datasets/tableDatasetSql.d.ts +16 -0
- package/dist/datasets/tableDatasetSql.d.ts.map +1 -0
- package/dist/datasets/tableDatasetSql.js +49 -0
- package/dist/datasets/tableDatasetSql.js.map +1 -0
- package/dist/datasets/types.d.ts +40 -0
- package/dist/datasets/types.d.ts.map +1 -0
- package/dist/datasets/types.js +2 -0
- package/dist/datasets/types.js.map +1 -0
- package/dist/datasets/usePreparedDatasetStates.d.ts +16 -0
- package/dist/datasets/usePreparedDatasetStates.d.ts.map +1 -0
- package/dist/datasets/usePreparedDatasetStates.js +59 -0
- package/dist/datasets/usePreparedDatasetStates.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/json/aggregateWaypoints.d.ts +14 -0
- package/dist/json/aggregateWaypoints.d.ts.map +1 -0
- package/dist/json/aggregateWaypoints.js +190 -0
- package/dist/json/aggregateWaypoints.js.map +1 -0
- package/dist/json/colorScaleFunction.d.ts +27 -0
- package/dist/json/colorScaleFunction.d.ts.map +1 -0
- package/dist/json/colorScaleFunction.js +46 -0
- package/dist/json/colorScaleFunction.js.map +1 -0
- package/dist/json/compileColorScale.d.ts +12 -0
- package/dist/json/compileColorScale.d.ts.map +1 -0
- package/dist/json/compileColorScale.js +125 -0
- package/dist/json/compileColorScale.js.map +1 -0
- package/dist/json/compileGeoArrowAccessor.d.ts +18 -0
- package/dist/json/compileGeoArrowAccessor.d.ts.map +1 -0
- package/dist/json/compileGeoArrowAccessor.js +129 -0
- package/dist/json/compileGeoArrowAccessor.js.map +1 -0
- package/dist/json/createDeckJsonConfiguration.d.ts +9 -0
- package/dist/json/createDeckJsonConfiguration.d.ts.map +1 -0
- package/dist/json/createDeckJsonConfiguration.js +315 -0
- package/dist/json/createDeckJsonConfiguration.js.map +1 -0
- package/dist/json/defaultClasses.d.ts +12 -0
- package/dist/json/defaultClasses.d.ts.map +1 -0
- package/dist/json/defaultClasses.js +35 -0
- package/dist/json/defaultClasses.js.map +1 -0
- package/dist/json/extractColorScaleLegends.d.ts +8 -0
- package/dist/json/extractColorScaleLegends.d.ts.map +1 -0
- package/dist/json/extractColorScaleLegends.js +86 -0
- package/dist/json/extractColorScaleLegends.js.map +1 -0
- package/dist/json/heatmapDefaults.d.ts +8 -0
- package/dist/json/heatmapDefaults.d.ts.map +1 -0
- package/dist/json/heatmapDefaults.js +14 -0
- package/dist/json/heatmapDefaults.js.map +1 -0
- package/dist/json/layerCompatibility.d.ts +21 -0
- package/dist/json/layerCompatibility.d.ts.map +1 -0
- package/dist/json/layerCompatibility.js +168 -0
- package/dist/json/layerCompatibility.js.map +1 -0
- package/dist/json/layerConfig.d.ts +14 -0
- package/dist/json/layerConfig.d.ts.map +1 -0
- package/dist/json/layerConfig.js +54 -0
- package/dist/json/layerConfig.js.map +1 -0
- package/dist/json/layers/DeckColumnLayer.d.ts +10 -0
- package/dist/json/layers/DeckColumnLayer.d.ts.map +1 -0
- package/dist/json/layers/DeckColumnLayer.js +26 -0
- package/dist/json/layers/DeckColumnLayer.js.map +1 -0
- package/dist/json/layers/DeckH3HexagonLayer.d.ts +37 -0
- package/dist/json/layers/DeckH3HexagonLayer.d.ts.map +1 -0
- package/dist/json/layers/DeckH3HexagonLayer.js +118 -0
- package/dist/json/layers/DeckH3HexagonLayer.js.map +1 -0
- package/dist/json/layers/DeckTripsLayer.d.ts +46 -0
- package/dist/json/layers/DeckTripsLayer.d.ts.map +1 -0
- package/dist/json/layers/DeckTripsLayer.js +170 -0
- package/dist/json/layers/DeckTripsLayer.js.map +1 -0
- package/dist/json/layers/createTableToRecordBatchAdapter.d.ts +20 -0
- package/dist/json/layers/createTableToRecordBatchAdapter.d.ts.map +1 -0
- package/dist/json/layers/createTableToRecordBatchAdapter.js +81 -0
- package/dist/json/layers/createTableToRecordBatchAdapter.js.map +1 -0
- package/dist/json/layers/index.d.ts +5 -0
- package/dist/json/layers/index.d.ts.map +1 -0
- package/dist/json/layers/index.js +5 -0
- package/dist/json/layers/index.js.map +1 -0
- package/dist/json/rewriteGeoArrowAccessors.d.ts +7 -0
- package/dist/json/rewriteGeoArrowAccessors.d.ts.map +1 -0
- package/dist/json/rewriteGeoArrowAccessors.js +55 -0
- package/dist/json/rewriteGeoArrowAccessors.js.map +1 -0
- package/dist/mapAiConfig.d.ts +111 -0
- package/dist/mapAiConfig.d.ts.map +1 -0
- package/dist/mapAiConfig.js +69 -0
- package/dist/mapAiConfig.js.map +1 -0
- package/dist/mapConfig.d.ts +73 -0
- package/dist/mapConfig.d.ts.map +1 -0
- package/dist/mapConfig.js +47 -0
- package/dist/mapConfig.js.map +1 -0
- package/dist/mapConfigUtils.d.ts +111 -0
- package/dist/mapConfigUtils.d.ts.map +1 -0
- package/dist/mapConfigUtils.js +502 -0
- package/dist/mapConfigUtils.js.map +1 -0
- package/dist/mapDataPolicy.d.ts +9 -0
- package/dist/mapDataPolicy.d.ts.map +1 -0
- package/dist/mapDataPolicy.js +25 -0
- package/dist/mapDataPolicy.js.map +1 -0
- package/dist/mapFit.d.ts +62 -0
- package/dist/mapFit.d.ts.map +1 -0
- package/dist/mapFit.js +325 -0
- package/dist/mapFit.js.map +1 -0
- package/dist/mapLayerConfigUtils.d.ts +54 -0
- package/dist/mapLayerConfigUtils.d.ts.map +1 -0
- package/dist/mapLayerConfigUtils.js +296 -0
- package/dist/mapLayerConfigUtils.js.map +1 -0
- package/dist/mapResourceAuthoring.d.ts +40 -0
- package/dist/mapResourceAuthoring.d.ts.map +1 -0
- package/dist/mapResourceAuthoring.js +266 -0
- package/dist/mapResourceAuthoring.js.map +1 -0
- package/dist/mosaic.d.ts +9 -0
- package/dist/mosaic.d.ts.map +1 -0
- package/dist/mosaic.js +8 -0
- package/dist/mosaic.js.map +1 -0
- package/dist/prepare/detectGeometryColumn.d.ts +19 -0
- package/dist/prepare/detectGeometryColumn.d.ts.map +1 -0
- package/dist/prepare/detectGeometryColumn.js +126 -0
- package/dist/prepare/detectGeometryColumn.js.map +1 -0
- package/dist/prepare/geoarrow.d.ts +18 -0
- package/dist/prepare/geoarrow.d.ts.map +1 -0
- package/dist/prepare/geoarrow.js +114 -0
- package/dist/prepare/geoarrow.js.map +1 -0
- package/dist/prepare/geometryDecoder.d.ts +8 -0
- package/dist/prepare/geometryDecoder.d.ts.map +1 -0
- package/dist/prepare/geometryDecoder.js +2 -0
- package/dist/prepare/geometryDecoder.js.map +1 -0
- package/dist/prepare/prepareDeckDataset.d.ts +57 -0
- package/dist/prepare/prepareDeckDataset.d.ts.map +1 -0
- package/dist/prepare/prepareDeckDataset.js +112 -0
- package/dist/prepare/prepareDeckDataset.js.map +1 -0
- package/dist/prepare/toGeoJsonBinary.d.ts +9 -0
- package/dist/prepare/toGeoJsonBinary.d.ts.map +1 -0
- package/dist/prepare/toGeoJsonBinary.js +26 -0
- package/dist/prepare/toGeoJsonBinary.js.map +1 -0
- package/dist/prepare/types.d.ts +25 -0
- package/dist/prepare/types.d.ts.map +1 -0
- package/dist/prepare/types.js +2 -0
- package/dist/prepare/types.js.map +1 -0
- package/dist/prepare/wkbDecoder.d.ts +3 -0
- package/dist/prepare/wkbDecoder.d.ts.map +1 -0
- package/dist/prepare/wkbDecoder.js +419 -0
- package/dist/prepare/wkbDecoder.js.map +1 -0
- package/dist/prepare/wkbParser.d.ts +24 -0
- package/dist/prepare/wkbParser.d.ts.map +1 -0
- package/dist/prepare/wkbParser.js +139 -0
- package/dist/prepare/wkbParser.js.map +1 -0
- package/dist/types.d.ts +92 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/dist/useDeckMapDatasetSchema.d.ts +33 -0
- package/dist/useDeckMapDatasetSchema.d.ts.map +1 -0
- package/dist/useDeckMapDatasetSchema.js +138 -0
- package/dist/useDeckMapDatasetSchema.js.map +1 -0
- package/dist/useDeckMapDatasets.d.ts +17 -0
- package/dist/useDeckMapDatasets.d.ts.map +1 -0
- package/dist/useDeckMapDatasets.js +69 -0
- package/dist/useDeckMapDatasets.js.map +1 -0
- package/dist/useDeckMapFitToBounds.d.ts +31 -0
- package/dist/useDeckMapFitToBounds.d.ts.map +1 -0
- package/dist/useDeckMapFitToBounds.js +58 -0
- package/dist/useDeckMapFitToBounds.js.map +1 -0
- package/package.json +98 -0
package/dist/mapFit.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import { type DeckMapConfig, type DeckMapDatasetSource, type DeckMapFitToDataConfig } from './mapConfig';
|
|
3
|
+
import { type DeckDatasetInput, type DeckJsonMapHandle } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the effective fit-to-data configuration for a Deck map.
|
|
6
|
+
*
|
|
7
|
+
* Explicit coordinate or geometry fields take precedence. Missing geometry and
|
|
8
|
+
* H3 fields are inferred from dataset metadata, interaction configuration, and
|
|
9
|
+
* layer bindings without consulting host-specific state.
|
|
10
|
+
*
|
|
11
|
+
* @param config - Durable Deck map configuration to inspect.
|
|
12
|
+
* @returns A normalized fit configuration, or `null` when fitting is disabled.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveDeckMapFitToData(config: DeckMapConfig | null | undefined): DeckMapFitToDataConfig | null;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a host-resolved Deck dataset input into a queryable map source.
|
|
17
|
+
*
|
|
18
|
+
* Prepared Arrow datasets intentionally return `null` because fitting them
|
|
19
|
+
* requires host-provided bounds rather than a DuckDB source query.
|
|
20
|
+
*
|
|
21
|
+
* @param dataset - Dataset after the host data adapter has resolved its source.
|
|
22
|
+
* @returns A SQL or table source suitable for bounds queries, or `null`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getDeckMapDatasetSource(dataset: DeckDatasetInput | undefined): DeckMapDatasetSource | null;
|
|
25
|
+
/**
|
|
26
|
+
* Builds the DuckDB query used to calculate a map dataset's geographic extent.
|
|
27
|
+
*
|
|
28
|
+
* The query strategy follows the normalized fit configuration: H3 cells,
|
|
29
|
+
* geometry values, explicit longitude/latitude columns, or conventional
|
|
30
|
+
* `Longitude`/`Latitude` column names as a final fallback.
|
|
31
|
+
*
|
|
32
|
+
* @param options - Resolved dataset source and normalized fit configuration.
|
|
33
|
+
* @returns SQL that yields min/max longitude and latitude, or `null` when the
|
|
34
|
+
* configuration cannot identify a target dataset.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createDeckMapBoundsQuery(options: {
|
|
37
|
+
source: DeckMapDatasetSource;
|
|
38
|
+
fitToData: DeckMapFitToDataConfig;
|
|
39
|
+
}): string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Executes host-neutral fit-to-data requests for a Deck map surface.
|
|
42
|
+
*
|
|
43
|
+
* The controller observes the map container, de-duplicates manual requests,
|
|
44
|
+
* optionally auto-fits when the source changes, loads H3 support when needed,
|
|
45
|
+
* queries dataset bounds, and updates the imperative Deck map view. Hosts are
|
|
46
|
+
* responsible only for resolving their dataset source and request version.
|
|
47
|
+
*
|
|
48
|
+
* @param options - Map identity, resolved fit inputs, view refs, request state,
|
|
49
|
+
* and optional success and error callbacks.
|
|
50
|
+
*/
|
|
51
|
+
export declare function useDeckMapFitController(options: {
|
|
52
|
+
scopeId: string;
|
|
53
|
+
fitToData: DeckMapFitToDataConfig | null;
|
|
54
|
+
source: DeckMapDatasetSource | null;
|
|
55
|
+
container: HTMLElement | null;
|
|
56
|
+
deckMapRef: RefObject<DeckJsonMapHandle | null>;
|
|
57
|
+
requestVersion: number;
|
|
58
|
+
autoFit?: boolean;
|
|
59
|
+
onSuccess?: () => void;
|
|
60
|
+
onError?: (error: Error) => void;
|
|
61
|
+
}): void;
|
|
62
|
+
//# sourceMappingURL=mapFit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapFit.d.ts","sourceRoot":"","sources":["../src/mapFit.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAKnE,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,GACvC,sBAAsB,GAAG,IAAI,CAqC/B;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,gBAAgB,GAAG,SAAS,GACpC,oBAAoB,GAAG,IAAI,CAU7B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,MAAM,EAAE,oBAAoB,CAAC;IAC7B,SAAS,EAAE,sBAAsB,CAAC;CACnC,iBA0EA;AAmFD;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACzC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACpC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAChD,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC,QA6HA"}
|
package/dist/mapFit.js
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { WebMercatorViewport } from '@deck.gl/core';
|
|
2
|
+
import { escapeId, getColValAsNumber, useStoreWithDuckDb, } from '@sqlrooms/duckdb';
|
|
3
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
4
|
+
import { DeckTableDatasetInvalidTableNameError, createDeckTableDatasetSql, } from './datasets/tableDatasetSql';
|
|
5
|
+
import { isDeckMapSqlDatasetSource, } from './mapConfig';
|
|
6
|
+
import { isSqlDatasetInput, isTableDatasetInput, } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the effective fit-to-data configuration for a Deck map.
|
|
9
|
+
*
|
|
10
|
+
* Explicit coordinate or geometry fields take precedence. Missing geometry and
|
|
11
|
+
* H3 fields are inferred from dataset metadata, interaction configuration, and
|
|
12
|
+
* layer bindings without consulting host-specific state.
|
|
13
|
+
*
|
|
14
|
+
* @param config - Durable Deck map configuration to inspect.
|
|
15
|
+
* @returns A normalized fit configuration, or `null` when fitting is disabled.
|
|
16
|
+
*/
|
|
17
|
+
export function resolveDeckMapFitToData(config) {
|
|
18
|
+
if (!config)
|
|
19
|
+
return null;
|
|
20
|
+
const fitToData = config.fitToData;
|
|
21
|
+
if (!fitToData?.dataset)
|
|
22
|
+
return null;
|
|
23
|
+
if (fitToData.longitudeColumn && fitToData.latitudeColumn)
|
|
24
|
+
return fitToData;
|
|
25
|
+
const dataset = config.datasets[fitToData.dataset];
|
|
26
|
+
const geometryColumn = fitToData.geometryColumn ?? dataset?.geometryColumn;
|
|
27
|
+
if (geometryColumn)
|
|
28
|
+
return { ...fitToData, geometryColumn };
|
|
29
|
+
if (config.interaction?.longitudeColumn &&
|
|
30
|
+
config.interaction.latitudeColumn) {
|
|
31
|
+
return {
|
|
32
|
+
...fitToData,
|
|
33
|
+
longitudeColumn: config.interaction.longitudeColumn,
|
|
34
|
+
latitudeColumn: config.interaction.latitudeColumn,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const spec = typeof config.spec === 'string'
|
|
38
|
+
? undefined
|
|
39
|
+
: config.spec;
|
|
40
|
+
const layers = Array.isArray(spec?.layers) ? spec.layers : [];
|
|
41
|
+
for (const layer of layers) {
|
|
42
|
+
if (!layer || typeof layer !== 'object')
|
|
43
|
+
continue;
|
|
44
|
+
const binding = layer._sqlroomsBinding;
|
|
45
|
+
if (binding?.dataset === fitToData.dataset && binding.hexagonColumn) {
|
|
46
|
+
return { ...fitToData, h3Column: String(binding.hexagonColumn) };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return fitToData;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Converts a host-resolved Deck dataset input into a queryable map source.
|
|
53
|
+
*
|
|
54
|
+
* Prepared Arrow datasets intentionally return `null` because fitting them
|
|
55
|
+
* requires host-provided bounds rather than a DuckDB source query.
|
|
56
|
+
*
|
|
57
|
+
* @param dataset - Dataset after the host data adapter has resolved its source.
|
|
58
|
+
* @returns A SQL or table source suitable for bounds queries, or `null`.
|
|
59
|
+
*/
|
|
60
|
+
export function getDeckMapDatasetSource(dataset) {
|
|
61
|
+
if (!dataset)
|
|
62
|
+
return null;
|
|
63
|
+
if (isSqlDatasetInput(dataset))
|
|
64
|
+
return { sqlQuery: dataset.sqlQuery };
|
|
65
|
+
if (isTableDatasetInput(dataset)) {
|
|
66
|
+
return {
|
|
67
|
+
tableName: dataset.tableName,
|
|
68
|
+
transformSql: dataset.transformSql,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Builds the DuckDB query used to calculate a map dataset's geographic extent.
|
|
75
|
+
*
|
|
76
|
+
* The query strategy follows the normalized fit configuration: H3 cells,
|
|
77
|
+
* geometry values, explicit longitude/latitude columns, or conventional
|
|
78
|
+
* `Longitude`/`Latitude` column names as a final fallback.
|
|
79
|
+
*
|
|
80
|
+
* @param options - Resolved dataset source and normalized fit configuration.
|
|
81
|
+
* @returns SQL that yields min/max longitude and latitude, or `null` when the
|
|
82
|
+
* configuration cannot identify a target dataset.
|
|
83
|
+
*/
|
|
84
|
+
export function createDeckMapBoundsQuery(options) {
|
|
85
|
+
const { source, fitToData } = options;
|
|
86
|
+
if (!fitToData.dataset)
|
|
87
|
+
return null;
|
|
88
|
+
const baseSourceSql = isDeckMapSqlDatasetSource(source)
|
|
89
|
+
? `SELECT * FROM (${source.sqlQuery.trim().replace(/(?:\s*;+\s*)+$/, '')}) AS "__sqlrooms_dashboard_map_source"`
|
|
90
|
+
: createDeckMapBoundsTableSourceSql(source);
|
|
91
|
+
if (fitToData.h3Column) {
|
|
92
|
+
const column = escapeId(fitToData.h3Column);
|
|
93
|
+
return `
|
|
94
|
+
SELECT
|
|
95
|
+
MIN(h3_cell_to_lng(${column})) AS min_longitude,
|
|
96
|
+
MIN(h3_cell_to_lat(${column})) AS min_latitude,
|
|
97
|
+
MAX(h3_cell_to_lng(${column})) AS max_longitude,
|
|
98
|
+
MAX(h3_cell_to_lat(${column})) AS max_latitude
|
|
99
|
+
FROM (${baseSourceSql}) AS "__sqlrooms_dashboard_map_h3"
|
|
100
|
+
WHERE ${column} IS NOT NULL
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
if (fitToData.geometryColumn) {
|
|
104
|
+
const column = escapeId(fitToData.geometryColumn);
|
|
105
|
+
const sourceSql = isDeckMapSqlDatasetSource(source)
|
|
106
|
+
? source.sqlQuery
|
|
107
|
+
: (source.transformSql ?? '');
|
|
108
|
+
const geometry = sourceSql.toLowerCase().includes('st_aswkb')
|
|
109
|
+
? `ST_GeomFromWKB(${column})`
|
|
110
|
+
: `${column}::GEOMETRY`;
|
|
111
|
+
return `
|
|
112
|
+
SELECT
|
|
113
|
+
ST_XMin(extent) AS min_longitude,
|
|
114
|
+
ST_YMin(extent) AS min_latitude,
|
|
115
|
+
ST_XMax(extent) AS max_longitude,
|
|
116
|
+
ST_YMax(extent) AS max_latitude
|
|
117
|
+
FROM (
|
|
118
|
+
SELECT ST_Extent_Agg(${geometry}) AS extent
|
|
119
|
+
FROM (${baseSourceSql}) AS "__sqlrooms_dashboard_map_geom"
|
|
120
|
+
WHERE ${column} IS NOT NULL
|
|
121
|
+
) AS "__sqlrooms_dashboard_map_extent"
|
|
122
|
+
WHERE extent IS NOT NULL
|
|
123
|
+
`;
|
|
124
|
+
}
|
|
125
|
+
if (fitToData.longitudeColumn && fitToData.latitudeColumn) {
|
|
126
|
+
const longitude = escapeId(fitToData.longitudeColumn);
|
|
127
|
+
const latitude = escapeId(fitToData.latitudeColumn);
|
|
128
|
+
return `
|
|
129
|
+
SELECT
|
|
130
|
+
ST_XMin(extent) AS min_longitude,
|
|
131
|
+
ST_YMin(extent) AS min_latitude,
|
|
132
|
+
ST_XMax(extent) AS max_longitude,
|
|
133
|
+
ST_YMax(extent) AS max_latitude
|
|
134
|
+
FROM (
|
|
135
|
+
SELECT ST_Extent_Agg(ST_Point(${longitude}, ${latitude})) AS extent
|
|
136
|
+
FROM (${baseSourceSql}) AS "__sqlrooms_dashboard_map_points"
|
|
137
|
+
WHERE ${longitude} IS NOT NULL AND ${latitude} IS NOT NULL
|
|
138
|
+
) AS "__sqlrooms_dashboard_map_extent"
|
|
139
|
+
WHERE extent IS NOT NULL
|
|
140
|
+
`;
|
|
141
|
+
}
|
|
142
|
+
return `
|
|
143
|
+
SELECT
|
|
144
|
+
ST_XMin(extent) AS min_longitude,
|
|
145
|
+
ST_YMin(extent) AS min_latitude,
|
|
146
|
+
ST_XMax(extent) AS max_longitude,
|
|
147
|
+
ST_YMax(extent) AS max_latitude
|
|
148
|
+
FROM (
|
|
149
|
+
SELECT ST_Extent_Agg(ST_Point(Longitude, Latitude)) AS extent
|
|
150
|
+
FROM (${baseSourceSql}) AS "__sqlrooms_dashboard_map_points"
|
|
151
|
+
WHERE Longitude IS NOT NULL AND Latitude IS NOT NULL
|
|
152
|
+
) AS "__sqlrooms_dashboard_map_extent"
|
|
153
|
+
WHERE extent IS NOT NULL
|
|
154
|
+
`;
|
|
155
|
+
}
|
|
156
|
+
function createDeckMapBoundsTableSourceSql(source) {
|
|
157
|
+
try {
|
|
158
|
+
return createDeckTableDatasetSql(source);
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
if (error instanceof DeckTableDatasetInvalidTableNameError) {
|
|
162
|
+
throw new Error('Deck map fit-to-data requires a valid table source.');
|
|
163
|
+
}
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function readDeckMapBounds(result) {
|
|
168
|
+
const minLongitude = getColValAsNumber(result, 'min_longitude');
|
|
169
|
+
const minLatitude = getColValAsNumber(result, 'min_latitude');
|
|
170
|
+
const maxLongitude = getColValAsNumber(result, 'max_longitude');
|
|
171
|
+
const maxLatitude = getColValAsNumber(result, 'max_latitude');
|
|
172
|
+
if (!Number.isFinite(minLongitude) ||
|
|
173
|
+
!Number.isFinite(minLatitude) ||
|
|
174
|
+
!Number.isFinite(maxLongitude) ||
|
|
175
|
+
!Number.isFinite(maxLatitude)) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
return [
|
|
179
|
+
[
|
|
180
|
+
minLongitude === maxLongitude ? minLongitude - 0.01 : minLongitude,
|
|
181
|
+
minLatitude === maxLatitude ? minLatitude - 0.01 : minLatitude,
|
|
182
|
+
],
|
|
183
|
+
[
|
|
184
|
+
minLongitude === maxLongitude ? maxLongitude + 0.01 : maxLongitude,
|
|
185
|
+
minLatitude === maxLatitude ? maxLatitude + 0.01 : maxLatitude,
|
|
186
|
+
],
|
|
187
|
+
];
|
|
188
|
+
}
|
|
189
|
+
function fitDeckMapView(options) {
|
|
190
|
+
const { bounds, width, height, padding = 40, maxZoom = 18 } = options;
|
|
191
|
+
const fitted = new WebMercatorViewport({
|
|
192
|
+
width: Math.max(width, 1),
|
|
193
|
+
height: Math.max(height, 1),
|
|
194
|
+
}).fitBounds([
|
|
195
|
+
[bounds[0][0], bounds[0][1]],
|
|
196
|
+
[bounds[1][0], bounds[1][1]],
|
|
197
|
+
], { padding });
|
|
198
|
+
return {
|
|
199
|
+
longitude: fitted.longitude,
|
|
200
|
+
latitude: fitted.latitude,
|
|
201
|
+
zoom: Math.min(fitted.zoom, maxZoom),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function createInitialFitState(key, requestVersion) {
|
|
205
|
+
return {
|
|
206
|
+
key,
|
|
207
|
+
didAutoFit: false,
|
|
208
|
+
handledRequestVersion: requestVersion,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Executes host-neutral fit-to-data requests for a Deck map surface.
|
|
213
|
+
*
|
|
214
|
+
* The controller observes the map container, de-duplicates manual requests,
|
|
215
|
+
* optionally auto-fits when the source changes, loads H3 support when needed,
|
|
216
|
+
* queries dataset bounds, and updates the imperative Deck map view. Hosts are
|
|
217
|
+
* responsible only for resolving their dataset source and request version.
|
|
218
|
+
*
|
|
219
|
+
* @param options - Map identity, resolved fit inputs, view refs, request state,
|
|
220
|
+
* and optional success and error callbacks.
|
|
221
|
+
*/
|
|
222
|
+
export function useDeckMapFitController(options) {
|
|
223
|
+
const { scopeId, fitToData, source, container, deckMapRef, requestVersion, autoFit = false, onSuccess, onError, } = options;
|
|
224
|
+
const executeSql = useStoreWithDuckDb((state) => state.db.executeSql);
|
|
225
|
+
const [containerSize, setContainerSize] = useState({ width: 0, height: 0 });
|
|
226
|
+
const fitKey = useMemo(() => JSON.stringify({ scopeId, fitToData, source }), [fitToData, scopeId, source]);
|
|
227
|
+
const [fitState, setFitState] = useState(() => createInitialFitState(fitKey, requestVersion));
|
|
228
|
+
// A source change resets auto-fit state, but must not mark a newer manual
|
|
229
|
+
// request as handled before the effect observes it.
|
|
230
|
+
const activeFitState = fitState.key === fitKey
|
|
231
|
+
? fitState
|
|
232
|
+
: createInitialFitState(fitKey, fitState.handledRequestVersion);
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
if (!container)
|
|
235
|
+
return;
|
|
236
|
+
const updateSize = () => setContainerSize({
|
|
237
|
+
width: container.clientWidth,
|
|
238
|
+
height: container.clientHeight,
|
|
239
|
+
});
|
|
240
|
+
updateSize();
|
|
241
|
+
if (typeof ResizeObserver === 'undefined')
|
|
242
|
+
return;
|
|
243
|
+
const observer = new ResizeObserver(updateSize);
|
|
244
|
+
observer.observe(container);
|
|
245
|
+
return () => observer.disconnect();
|
|
246
|
+
}, [container]);
|
|
247
|
+
useEffect(() => {
|
|
248
|
+
const hasManualRequest = requestVersion > activeFitState.handledRequestVersion;
|
|
249
|
+
if (!fitToData ||
|
|
250
|
+
!source ||
|
|
251
|
+
containerSize.width <= 0 ||
|
|
252
|
+
containerSize.height <= 0 ||
|
|
253
|
+
(!hasManualRequest && (!autoFit || activeFitState.didAutoFit))) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
let cancelled = false;
|
|
257
|
+
const markHandled = () => setFitState({
|
|
258
|
+
key: fitKey,
|
|
259
|
+
didAutoFit: true,
|
|
260
|
+
handledRequestVersion: requestVersion,
|
|
261
|
+
});
|
|
262
|
+
void (async () => {
|
|
263
|
+
try {
|
|
264
|
+
if (fitToData.h3Column) {
|
|
265
|
+
try {
|
|
266
|
+
await executeSql('INSTALL h3 FROM community');
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
// The extension may already be installed.
|
|
270
|
+
}
|
|
271
|
+
await executeSql('LOAD h3');
|
|
272
|
+
}
|
|
273
|
+
const query = createDeckMapBoundsQuery({ source, fitToData });
|
|
274
|
+
if (!query) {
|
|
275
|
+
markHandled();
|
|
276
|
+
onSuccess?.();
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const handle = await executeSql(query);
|
|
280
|
+
const result = handle ? await handle : null;
|
|
281
|
+
if (cancelled || !result)
|
|
282
|
+
return;
|
|
283
|
+
const bounds = readDeckMapBounds(result);
|
|
284
|
+
if (bounds) {
|
|
285
|
+
deckMapRef.current?.jumpTo(fitDeckMapView({
|
|
286
|
+
bounds,
|
|
287
|
+
width: containerSize.width,
|
|
288
|
+
height: containerSize.height,
|
|
289
|
+
padding: fitToData.padding,
|
|
290
|
+
maxZoom: fitToData.maxZoom,
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
293
|
+
markHandled();
|
|
294
|
+
onSuccess?.();
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
if (cancelled)
|
|
298
|
+
return;
|
|
299
|
+
const fitError = error instanceof Error
|
|
300
|
+
? error
|
|
301
|
+
: new Error('Unable to fit map view to data.');
|
|
302
|
+
onError?.(fitError);
|
|
303
|
+
markHandled();
|
|
304
|
+
}
|
|
305
|
+
})();
|
|
306
|
+
return () => {
|
|
307
|
+
cancelled = true;
|
|
308
|
+
};
|
|
309
|
+
}, [
|
|
310
|
+
activeFitState.didAutoFit,
|
|
311
|
+
activeFitState.handledRequestVersion,
|
|
312
|
+
autoFit,
|
|
313
|
+
containerSize.height,
|
|
314
|
+
containerSize.width,
|
|
315
|
+
deckMapRef,
|
|
316
|
+
executeSql,
|
|
317
|
+
fitKey,
|
|
318
|
+
fitToData,
|
|
319
|
+
onError,
|
|
320
|
+
onSuccess,
|
|
321
|
+
requestVersion,
|
|
322
|
+
source,
|
|
323
|
+
]);
|
|
324
|
+
}
|
|
325
|
+
//# sourceMappingURL=mapFit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapFit.js","sourceRoot":"","sources":["../src/mapFit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,kBAAk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AAE,aAAa,CAAC,KAAK;wBAC1B,MAAM,EAAE,aAAa,CAAC,MAAM;wBAC5B,OAAO,EAAE,SAAS,CAAC,OAAO;wBAC1B,OAAO,EAAE,SAAS,CAAC,OAAO;qBAC3B,CAAC,CACH,CAAC;gBACJ,CAAC;gBACD,WAAW,EAAE,CAAC;gBACd,SAAS,EAAE,EAAE,CAAC;YAChB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,SAAS;oBAAE,OAAO;gBACtB,MAAM,QAAQ,GACZ,KAAK,YAAY,KAAK;oBACpB,CAAC,CAAC,KAAK;oBACP,CAAC,CAAC,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;gBACnD,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;gBACpB,WAAW,EAAE,CAAC;YAChB,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;QAEL,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,cAAc,CAAC,UAAU;QACzB,cAAc,CAAC,qBAAqB;QACpC,OAAO;QACP,aAAa,CAAC,MAAM;QACpB,aAAa,CAAC,KAAK;QACnB,UAAU;QACV,UAAU;QACV,MAAM;QACN,SAAS;QACT,OAAO;QACP,SAAS;QACT,cAAc;QACd,MAAM;KACP,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {WebMercatorViewport} from '@deck.gl/core';\nimport {\n escapeId,\n getColValAsNumber,\n useStoreWithDuckDb,\n} from '@sqlrooms/duckdb';\nimport type {Table as ArrowTable} from 'apache-arrow';\nimport {useEffect, useMemo, useState, type RefObject} from 'react';\nimport {\n DeckTableDatasetInvalidTableNameError,\n createDeckTableDatasetSql,\n} from './datasets/tableDatasetSql';\nimport {\n isDeckMapSqlDatasetSource,\n type DeckMapConfig,\n type DeckMapDatasetSource,\n type DeckMapFitToDataConfig,\n} from './mapConfig';\nimport {\n isSqlDatasetInput,\n isTableDatasetInput,\n type DeckDatasetInput,\n type DeckJsonMapHandle,\n} from './types';\n\n/**\n * Resolves the effective fit-to-data configuration for a Deck map.\n *\n * Explicit coordinate or geometry fields take precedence. Missing geometry and\n * H3 fields are inferred from dataset metadata, interaction configuration, and\n * layer bindings without consulting host-specific state.\n *\n * @param config - Durable Deck map configuration to inspect.\n * @returns A normalized fit configuration, or `null` when fitting is disabled.\n */\nexport function resolveDeckMapFitToData(\n config: DeckMapConfig | null | undefined,\n): DeckMapFitToDataConfig | null {\n if (!config) return null;\n const fitToData = config.fitToData;\n if (!fitToData?.dataset) return null;\n if (fitToData.longitudeColumn && fitToData.latitudeColumn) return fitToData;\n\n const dataset = config.datasets[fitToData.dataset];\n const geometryColumn = fitToData.geometryColumn ?? dataset?.geometryColumn;\n if (geometryColumn) return {...fitToData, geometryColumn};\n\n if (\n config.interaction?.longitudeColumn &&\n config.interaction.latitudeColumn\n ) {\n return {\n ...fitToData,\n longitudeColumn: config.interaction.longitudeColumn,\n latitudeColumn: config.interaction.latitudeColumn,\n };\n }\n\n const spec =\n typeof config.spec === 'string'\n ? undefined\n : (config.spec as Record<string, unknown>);\n const layers = Array.isArray(spec?.layers) ? spec.layers : [];\n for (const layer of layers) {\n if (!layer || typeof layer !== 'object') continue;\n const binding = (layer as Record<string, unknown>)._sqlroomsBinding as\n | Record<string, unknown>\n | undefined;\n if (binding?.dataset === fitToData.dataset && binding.hexagonColumn) {\n return {...fitToData, h3Column: String(binding.hexagonColumn)};\n }\n }\n\n return fitToData;\n}\n\n/**\n * Converts a host-resolved Deck dataset input into a queryable map source.\n *\n * Prepared Arrow datasets intentionally return `null` because fitting them\n * requires host-provided bounds rather than a DuckDB source query.\n *\n * @param dataset - Dataset after the host data adapter has resolved its source.\n * @returns A SQL or table source suitable for bounds queries, or `null`.\n */\nexport function getDeckMapDatasetSource(\n dataset: DeckDatasetInput | undefined,\n): DeckMapDatasetSource | null {\n if (!dataset) return null;\n if (isSqlDatasetInput(dataset)) return {sqlQuery: dataset.sqlQuery};\n if (isTableDatasetInput(dataset)) {\n return {\n tableName: dataset.tableName,\n transformSql: dataset.transformSql,\n };\n }\n return null;\n}\n\n/**\n * Builds the DuckDB query used to calculate a map dataset's geographic extent.\n *\n * The query strategy follows the normalized fit configuration: H3 cells,\n * geometry values, explicit longitude/latitude columns, or conventional\n * `Longitude`/`Latitude` column names as a final fallback.\n *\n * @param options - Resolved dataset source and normalized fit configuration.\n * @returns SQL that yields min/max longitude and latitude, or `null` when the\n * configuration cannot identify a target dataset.\n */\nexport function createDeckMapBoundsQuery(options: {\n source: DeckMapDatasetSource;\n fitToData: DeckMapFitToDataConfig;\n}) {\n const {source, fitToData} = options;\n if (!fitToData.dataset) return null;\n const baseSourceSql = isDeckMapSqlDatasetSource(source)\n ? `SELECT * FROM (${source.sqlQuery.trim().replace(/(?:\\s*;+\\s*)+$/, '')}) AS \"__sqlrooms_dashboard_map_source\"`\n : createDeckMapBoundsTableSourceSql(source);\n\n if (fitToData.h3Column) {\n const column = escapeId(fitToData.h3Column);\n return `\n SELECT\n MIN(h3_cell_to_lng(${column})) AS min_longitude,\n MIN(h3_cell_to_lat(${column})) AS min_latitude,\n MAX(h3_cell_to_lng(${column})) AS max_longitude,\n MAX(h3_cell_to_lat(${column})) AS max_latitude\n FROM (${baseSourceSql}) AS \"__sqlrooms_dashboard_map_h3\"\n WHERE ${column} IS NOT NULL\n `;\n }\n\n if (fitToData.geometryColumn) {\n const column = escapeId(fitToData.geometryColumn);\n const sourceSql = isDeckMapSqlDatasetSource(source)\n ? source.sqlQuery\n : (source.transformSql ?? '');\n const geometry = sourceSql.toLowerCase().includes('st_aswkb')\n ? `ST_GeomFromWKB(${column})`\n : `${column}::GEOMETRY`;\n return `\n SELECT\n ST_XMin(extent) AS min_longitude,\n ST_YMin(extent) AS min_latitude,\n ST_XMax(extent) AS max_longitude,\n ST_YMax(extent) AS max_latitude\n FROM (\n SELECT ST_Extent_Agg(${geometry}) AS extent\n FROM (${baseSourceSql}) AS \"__sqlrooms_dashboard_map_geom\"\n WHERE ${column} IS NOT NULL\n ) AS \"__sqlrooms_dashboard_map_extent\"\n WHERE extent IS NOT NULL\n `;\n }\n\n if (fitToData.longitudeColumn && fitToData.latitudeColumn) {\n const longitude = escapeId(fitToData.longitudeColumn);\n const latitude = escapeId(fitToData.latitudeColumn);\n return `\n SELECT\n ST_XMin(extent) AS min_longitude,\n ST_YMin(extent) AS min_latitude,\n ST_XMax(extent) AS max_longitude,\n ST_YMax(extent) AS max_latitude\n FROM (\n SELECT ST_Extent_Agg(ST_Point(${longitude}, ${latitude})) AS extent\n FROM (${baseSourceSql}) AS \"__sqlrooms_dashboard_map_points\"\n WHERE ${longitude} IS NOT NULL AND ${latitude} IS NOT NULL\n ) AS \"__sqlrooms_dashboard_map_extent\"\n WHERE extent IS NOT NULL\n `;\n }\n\n return `\n SELECT\n ST_XMin(extent) AS min_longitude,\n ST_YMin(extent) AS min_latitude,\n ST_XMax(extent) AS max_longitude,\n ST_YMax(extent) AS max_latitude\n FROM (\n SELECT ST_Extent_Agg(ST_Point(Longitude, Latitude)) AS extent\n FROM (${baseSourceSql}) AS \"__sqlrooms_dashboard_map_points\"\n WHERE Longitude IS NOT NULL AND Latitude IS NOT NULL\n ) AS \"__sqlrooms_dashboard_map_extent\"\n WHERE extent IS NOT NULL\n `;\n}\n\nfunction createDeckMapBoundsTableSourceSql(\n source: Exclude<DeckMapDatasetSource, {sqlQuery: string}>,\n) {\n try {\n return createDeckTableDatasetSql(source);\n } catch (error) {\n if (error instanceof DeckTableDatasetInvalidTableNameError) {\n throw new Error('Deck map fit-to-data requires a valid table source.');\n }\n throw error;\n }\n}\n\nfunction readDeckMapBounds(result: ArrowTable) {\n const minLongitude = getColValAsNumber(result, 'min_longitude');\n const minLatitude = getColValAsNumber(result, 'min_latitude');\n const maxLongitude = getColValAsNumber(result, 'max_longitude');\n const maxLatitude = getColValAsNumber(result, 'max_latitude');\n if (\n !Number.isFinite(minLongitude) ||\n !Number.isFinite(minLatitude) ||\n !Number.isFinite(maxLongitude) ||\n !Number.isFinite(maxLatitude)\n ) {\n return null;\n }\n return [\n [\n minLongitude === maxLongitude ? minLongitude - 0.01 : minLongitude,\n minLatitude === maxLatitude ? minLatitude - 0.01 : minLatitude,\n ],\n [\n minLongitude === maxLongitude ? maxLongitude + 0.01 : maxLongitude,\n minLatitude === maxLatitude ? maxLatitude + 0.01 : maxLatitude,\n ],\n ] as const;\n}\n\nfunction fitDeckMapView(options: {\n bounds: readonly [readonly [number, number], readonly [number, number]];\n width: number;\n height: number;\n padding?: number;\n maxZoom?: number;\n}) {\n const {bounds, width, height, padding = 40, maxZoom = 18} = options;\n const fitted = new WebMercatorViewport({\n width: Math.max(width, 1),\n height: Math.max(height, 1),\n }).fitBounds(\n [\n [bounds[0][0], bounds[0][1]],\n [bounds[1][0], bounds[1][1]],\n ],\n {padding},\n ) as WebMercatorViewport & {\n longitude: number;\n latitude: number;\n zoom: number;\n };\n return {\n longitude: fitted.longitude,\n latitude: fitted.latitude,\n zoom: Math.min(fitted.zoom, maxZoom),\n };\n}\n\ntype DeckMapFitState = {\n key: string;\n didAutoFit: boolean;\n handledRequestVersion: number;\n};\n\nfunction createInitialFitState(key: string, requestVersion: number) {\n return {\n key,\n didAutoFit: false,\n handledRequestVersion: requestVersion,\n };\n}\n\n/**\n * Executes host-neutral fit-to-data requests for a Deck map surface.\n *\n * The controller observes the map container, de-duplicates manual requests,\n * optionally auto-fits when the source changes, loads H3 support when needed,\n * queries dataset bounds, and updates the imperative Deck map view. Hosts are\n * responsible only for resolving their dataset source and request version.\n *\n * @param options - Map identity, resolved fit inputs, view refs, request state,\n * and optional success and error callbacks.\n */\nexport function useDeckMapFitController(options: {\n scopeId: string;\n fitToData: DeckMapFitToDataConfig | null;\n source: DeckMapDatasetSource | null;\n container: HTMLElement | null;\n deckMapRef: RefObject<DeckJsonMapHandle | null>;\n requestVersion: number;\n autoFit?: boolean;\n onSuccess?: () => void;\n onError?: (error: Error) => void;\n}) {\n const {\n scopeId,\n fitToData,\n source,\n container,\n deckMapRef,\n requestVersion,\n autoFit = false,\n onSuccess,\n onError,\n } = options;\n const executeSql = useStoreWithDuckDb((state) => state.db.executeSql);\n const [containerSize, setContainerSize] = useState({width: 0, height: 0});\n const fitKey = useMemo(\n () => JSON.stringify({scopeId, fitToData, source}),\n [fitToData, scopeId, source],\n );\n const [fitState, setFitState] = useState<DeckMapFitState>(() =>\n createInitialFitState(fitKey, requestVersion),\n );\n // A source change resets auto-fit state, but must not mark a newer manual\n // request as handled before the effect observes it.\n const activeFitState =\n fitState.key === fitKey\n ? fitState\n : createInitialFitState(fitKey, fitState.handledRequestVersion);\n\n useEffect(() => {\n if (!container) return;\n const updateSize = () =>\n setContainerSize({\n width: container.clientWidth,\n height: container.clientHeight,\n });\n updateSize();\n if (typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(updateSize);\n observer.observe(container);\n return () => observer.disconnect();\n }, [container]);\n\n useEffect(() => {\n const hasManualRequest =\n requestVersion > activeFitState.handledRequestVersion;\n if (\n !fitToData ||\n !source ||\n containerSize.width <= 0 ||\n containerSize.height <= 0 ||\n (!hasManualRequest && (!autoFit || activeFitState.didAutoFit))\n ) {\n return;\n }\n\n let cancelled = false;\n const markHandled = () =>\n setFitState({\n key: fitKey,\n didAutoFit: true,\n handledRequestVersion: requestVersion,\n });\n\n void (async () => {\n try {\n if (fitToData.h3Column) {\n try {\n await executeSql('INSTALL h3 FROM community');\n } catch {\n // The extension may already be installed.\n }\n await executeSql('LOAD h3');\n }\n const query = createDeckMapBoundsQuery({source, fitToData});\n if (!query) {\n markHandled();\n onSuccess?.();\n return;\n }\n const handle = await executeSql(query);\n const result = handle ? await handle : null;\n if (cancelled || !result) return;\n const bounds = readDeckMapBounds(result);\n if (bounds) {\n deckMapRef.current?.jumpTo(\n fitDeckMapView({\n bounds,\n width: containerSize.width,\n height: containerSize.height,\n padding: fitToData.padding,\n maxZoom: fitToData.maxZoom,\n }),\n );\n }\n markHandled();\n onSuccess?.();\n } catch (error) {\n if (cancelled) return;\n const fitError =\n error instanceof Error\n ? error\n : new Error('Unable to fit map view to data.');\n onError?.(fitError);\n markHandled();\n }\n })();\n\n return () => {\n cancelled = true;\n };\n }, [\n activeFitState.didAutoFit,\n activeFitState.handledRequestVersion,\n autoFit,\n containerSize.height,\n containerSize.width,\n deckMapRef,\n executeSql,\n fitKey,\n fitToData,\n onError,\n onSuccess,\n requestVersion,\n source,\n ]);\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ColorScaleConfig, ColorScaleScheme } from '@sqlrooms/color-scales';
|
|
2
|
+
import type { DeckMapConfig } from './mapConfig';
|
|
3
|
+
import type { DeckAutoLayerType } from './types';
|
|
4
|
+
export type DeckMapLayerRecord = Record<string, unknown>;
|
|
5
|
+
export type DeckMapLayerColorScaleFunction = ColorScaleConfig & {
|
|
6
|
+
'@@function': 'colorScale';
|
|
7
|
+
};
|
|
8
|
+
export type DeckMapLayerColorAccessor = 'getFillColor' | 'getLineColor' | 'getColor' | 'getSourceColor' | 'getTargetColor';
|
|
9
|
+
export declare const DECK_MAP_LAYER_TYPE_OPTIONS: ReadonlyArray<{
|
|
10
|
+
value: DeckAutoLayerType | 'GeoArrowSolidPolygonLayer';
|
|
11
|
+
label: string;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const DECK_MAP_COLOR_ACCESSOR_OPTIONS: ReadonlyArray<{
|
|
14
|
+
value: DeckMapLayerColorAccessor;
|
|
15
|
+
label: string;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const DECK_MAP_COLOR_SCALE_TYPE_OPTIONS: ReadonlyArray<{
|
|
18
|
+
value: ColorScaleConfig['type'];
|
|
19
|
+
label: string;
|
|
20
|
+
defaultScheme: ColorScaleScheme;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function getDeckMapLayerRecords(config: DeckMapConfig): DeckMapLayerRecord[];
|
|
23
|
+
export declare function getDeckMapLayerDatasetId(layer: DeckMapLayerRecord | undefined): string | undefined;
|
|
24
|
+
export declare function usesGeometryColumnSetting(layerType: unknown): boolean;
|
|
25
|
+
export declare function usesH3ColumnSetting(layerType: unknown): boolean;
|
|
26
|
+
export declare function usesArcColumnSetting(layerType: unknown): boolean;
|
|
27
|
+
export declare function usesRadiusSetting(layerType: unknown): boolean;
|
|
28
|
+
export declare function usesColumnRadiusSetting(layerType: unknown): boolean;
|
|
29
|
+
export declare function usesTripsSettings(layerType: unknown): boolean;
|
|
30
|
+
export declare function usesExtrusionSettings(layerType: unknown): boolean;
|
|
31
|
+
export declare function getDeckMapColorAccessorOptions(layerType: unknown): typeof DECK_MAP_COLOR_ACCESSOR_OPTIONS;
|
|
32
|
+
export declare function updateDeckMapLayer(config: DeckMapConfig, layerIndex: number, updater: (layer: DeckMapLayerRecord) => DeckMapLayerRecord): DeckMapConfig;
|
|
33
|
+
export declare function setDeckMapLayerType(config: DeckMapConfig, layerIndex: number, layerType: string): DeckMapConfig;
|
|
34
|
+
export declare function setDeckMapLayerGeometryColumn(config: DeckMapConfig, layerIndex: number, geometryColumn: string): DeckMapConfig;
|
|
35
|
+
export declare function setDeckMapLayerHexagonColumn(config: DeckMapConfig, layerIndex: number, hexagonColumn: string): DeckMapConfig;
|
|
36
|
+
export declare function setDeckMapLayerArcColumns(config: DeckMapConfig, layerIndex: number, columns: {
|
|
37
|
+
sourceGeometryColumn?: string;
|
|
38
|
+
targetGeometryColumn?: string;
|
|
39
|
+
sourceLatitudeColumn?: string;
|
|
40
|
+
sourceLongitudeColumn?: string;
|
|
41
|
+
targetLatitudeColumn?: string;
|
|
42
|
+
targetLongitudeColumn?: string;
|
|
43
|
+
}): DeckMapConfig;
|
|
44
|
+
export declare function setDeckMapLayerTimestampColumn(config: DeckMapConfig, layerIndex: number, timestampColumn: string): DeckMapConfig;
|
|
45
|
+
export declare function getDeckMapLayerColorScale(layer: DeckMapLayerRecord | undefined, accessor: DeckMapLayerColorAccessor): DeckMapLayerColorScaleFunction | undefined;
|
|
46
|
+
export declare function setDeckMapLayerColorScale(config: DeckMapConfig, layerIndex: number, accessor: DeckMapLayerColorAccessor, colorScale: DeckMapLayerColorScaleFunction): DeckMapConfig;
|
|
47
|
+
export declare function clearDeckMapLayerColorScale(config: DeckMapConfig, layerIndex: number, accessor: DeckMapLayerColorAccessor): DeckMapConfig;
|
|
48
|
+
export declare function createDeckMapLayerColorScale(options: {
|
|
49
|
+
field: string;
|
|
50
|
+
type?: ColorScaleConfig['type'];
|
|
51
|
+
scheme?: ColorScaleScheme;
|
|
52
|
+
title?: string;
|
|
53
|
+
}): DeckMapLayerColorScaleFunction;
|
|
54
|
+
//# sourceMappingURL=mapLayerConfigUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapLayerConfigUtils.d.ts","sourceRoot":"","sources":["../src/mapLayerConfigUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAC/E,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAG/C,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEzD,MAAM,MAAM,8BAA8B,GAAG,gBAAgB,GAAG;IAC9D,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,yBAAyB,GACjC,cAAc,GACd,cAAc,GACd,UAAU,GACV,gBAAgB,GAChB,gBAAgB,CAAC;AAErB,eAAO,MAAM,2BAA2B,EAAE,aAAa,CAAC;IACtD,KAAK,EAAE,iBAAiB,GAAG,2BAA2B,CAAC;IACvD,KAAK,EAAE,MAAM,CAAC;CACf,CAWA,CAAC;AAEF,eAAO,MAAM,+BAA+B,EAAE,aAAa,CAAC;IAC1D,KAAK,EAAE,yBAAyB,CAAC;IACjC,KAAK,EAAE,MAAM,C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