@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
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { JSONConfiguration } from '@deck.gl/json';
|
|
2
|
+
import type { PreparedDeckDatasetState } from '../types';
|
|
3
|
+
type CreateDeckJsonConfigurationOptions = {
|
|
4
|
+
datasetStates: Record<string, PreparedDeckDatasetState>;
|
|
5
|
+
datasetIds: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare function createDeckJsonConfiguration(options: CreateDeckJsonConfigurationOptions): JSONConfiguration;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=createDeckJsonConfiguration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDeckJsonConfiguration.d.ts","sourceRoot":"","sources":["../../src/json/createDeckJsonConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAKhD,OAAO,KAAK,EAAoB,wBAAwB,EAAC,MAAM,UAAU,CAAC;AAuB1E,KAAK,kCAAkC,GAAG;IACxC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IACxD,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAgLF,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,kCAAkC,qBA+N5C"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { JSONConfiguration } from '@deck.gl/json';
|
|
2
|
+
import { wkbGeometryDecoder } from '../prepare/wkbDecoder';
|
|
3
|
+
import { tryAggregateWaypointsToLineStrings } from './aggregateWaypoints';
|
|
4
|
+
import { createColorScaleMarker, getAllColorScales, COLOR_SCALE_PROP_NAMES, } from './colorScaleFunction';
|
|
5
|
+
import { compileColorScale } from './compileColorScale';
|
|
6
|
+
import { DEFAULT_DECK_JSON_CLASSES, DEFAULT_DECK_JSON_CONSTANTS, DEFAULT_DECK_JSON_ENUMERATIONS, } from './defaultClasses';
|
|
7
|
+
import { DEFAULT_HEATMAP_COLOR_RANGE } from './heatmapDefaults';
|
|
8
|
+
import { getLayerCompatibility } from './layerCompatibility';
|
|
9
|
+
import { isManagedLayer, resolveConfiguredColumn, resolveDatasetId, resolveGeometryColumn, stripLayerExtensionProps, } from './layerConfig';
|
|
10
|
+
import { rewriteGeoArrowAccessors } from './rewriteGeoArrowAccessors';
|
|
11
|
+
function getLayerName(Class) {
|
|
12
|
+
const maybeClass = Class;
|
|
13
|
+
return maybeClass.layerName ?? maybeClass.name ?? 'UnknownLayer';
|
|
14
|
+
}
|
|
15
|
+
function applyColorScale(options) {
|
|
16
|
+
const { props, table } = options;
|
|
17
|
+
const allScales = getAllColorScales(props);
|
|
18
|
+
let result = props;
|
|
19
|
+
const triggers = result.updateTriggers &&
|
|
20
|
+
typeof result.updateTriggers === 'object' &&
|
|
21
|
+
!Array.isArray(result.updateTriggers)
|
|
22
|
+
? { ...result.updateTriggers }
|
|
23
|
+
: {};
|
|
24
|
+
for (const { propName, colorScale } of allScales) {
|
|
25
|
+
result = {
|
|
26
|
+
...result,
|
|
27
|
+
[propName]: compileColorScale({
|
|
28
|
+
table,
|
|
29
|
+
colorScale,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
triggers[propName] = JSON.stringify(colorScale);
|
|
33
|
+
}
|
|
34
|
+
// Set updateTriggers for color props that are static or absent (not a scale)
|
|
35
|
+
// so deck.gl detects changes when a scale is cleared or a constant value changes.
|
|
36
|
+
for (const propName of COLOR_SCALE_PROP_NAMES) {
|
|
37
|
+
if (!(propName in triggers)) {
|
|
38
|
+
const value = result[propName];
|
|
39
|
+
triggers[propName] = value !== undefined ? JSON.stringify(value) : 'none';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (Object.keys(triggers).length > 0) {
|
|
43
|
+
result = { ...result, updateTriggers: triggers };
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
function resolveGeoArrowBindings(options) {
|
|
48
|
+
const { layerName, compatibility, layerProps, prepared, props } = options;
|
|
49
|
+
let table = prepared.table;
|
|
50
|
+
const boundProps = {};
|
|
51
|
+
for (const binding of compatibility.bindings) {
|
|
52
|
+
if (props[binding.prop] !== undefined) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (binding.kind === 'geometry') {
|
|
56
|
+
const columnName = resolveConfiguredColumn(layerProps, binding.configKey);
|
|
57
|
+
if (binding.required && !columnName) {
|
|
58
|
+
throw new Error(`Layer "${layerName}" requires _sqlroomsBinding.${binding.configKey}.`);
|
|
59
|
+
}
|
|
60
|
+
let resolvedGeometry;
|
|
61
|
+
try {
|
|
62
|
+
resolvedGeometry = prepared.resolveGeometry(columnName);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
throw new Error(`Geometry column "${columnName}" was not found in dataset "${prepared.datasetId}".`);
|
|
66
|
+
}
|
|
67
|
+
// Detect mismatch: synthesized points can't satisfy a LineString binding.
|
|
68
|
+
// For PathLayer, try auto-aggregating waypoint rows into linestrings.
|
|
69
|
+
if (resolvedGeometry.encoding === 'geoarrow.point' &&
|
|
70
|
+
binding.prop === 'getPath') {
|
|
71
|
+
const aggregated = tryAggregateWaypointsToLineStrings(prepared.table);
|
|
72
|
+
if (aggregated) {
|
|
73
|
+
table = aggregated.table;
|
|
74
|
+
boundProps[binding.prop] = aggregated.geometryVector;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const available = prepared.table.schema.fields
|
|
78
|
+
.map((f) => f.name)
|
|
79
|
+
.join(', ');
|
|
80
|
+
throw new Error(`Layer "${layerName}" requires LineString geometry for getPath, ` +
|
|
81
|
+
`but only point coordinates were found and auto-aggregation failed. ` +
|
|
82
|
+
`The dataset sqlQuery must aggregate rows into linestrings using ST_MakeLine. ` +
|
|
83
|
+
`Available columns: ${available}.`);
|
|
84
|
+
}
|
|
85
|
+
if (resolvedGeometry.encoding === 'geoarrow.point' &&
|
|
86
|
+
binding.prop === 'getPolygon') {
|
|
87
|
+
const available = prepared.table.schema.fields
|
|
88
|
+
.map((f) => f.name)
|
|
89
|
+
.join(', ');
|
|
90
|
+
throw new Error(`Layer "${layerName}" requires Polygon geometry for ${binding.prop}, ` +
|
|
91
|
+
`but only point coordinates were found. Available columns: ${available}.`);
|
|
92
|
+
}
|
|
93
|
+
if (!resolvedGeometry.nativeGeoArrow) {
|
|
94
|
+
if (!compatibility.allowGeoArrowPromotion ||
|
|
95
|
+
!wkbGeometryDecoder.supportsGeoArrowPromotion(layerName, resolvedGeometry.encoding, prepared.table, resolvedGeometry.columnName)) {
|
|
96
|
+
throw new Error(`Layer "${layerName}" cannot render geometry encoding "${resolvedGeometry.encoding}" for dataset "${prepared.datasetId}".`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const layerData = prepared.getGeoArrowLayerData(columnName);
|
|
100
|
+
if (layerData.source === 'promoted') {
|
|
101
|
+
boundProps[binding.prop] = layerData.geometryColumn;
|
|
102
|
+
if (table === prepared.table) {
|
|
103
|
+
table = layerData.table;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
if (table !== prepared.table && table !== layerData.table) {
|
|
108
|
+
throw new Error(`Layer "${layerName}" cannot combine promoted geometry columns from different prepared tables.`);
|
|
109
|
+
}
|
|
110
|
+
table = layerData.table;
|
|
111
|
+
boundProps[binding.prop] = layerData.geometryColumn;
|
|
112
|
+
}
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const columnName = resolveConfiguredColumn(layerProps, binding.configKey);
|
|
116
|
+
if (!columnName) {
|
|
117
|
+
if (binding.required) {
|
|
118
|
+
throw new Error(`Layer "${layerName}" requires _sqlroomsBinding.${binding.configKey}.`);
|
|
119
|
+
}
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const vector = table.getChild(columnName) ?? prepared.table.getChild(columnName);
|
|
123
|
+
if (!vector) {
|
|
124
|
+
throw new Error(`Layer "${layerName}" references unknown column "${columnName}" for ${binding.prop}.`);
|
|
125
|
+
}
|
|
126
|
+
boundProps[binding.prop] = vector;
|
|
127
|
+
}
|
|
128
|
+
return { table, boundProps };
|
|
129
|
+
}
|
|
130
|
+
export function createDeckJsonConfiguration(options) {
|
|
131
|
+
const { datasetStates, datasetIds } = options;
|
|
132
|
+
return new JSONConfiguration({
|
|
133
|
+
classes: DEFAULT_DECK_JSON_CLASSES,
|
|
134
|
+
enumerations: DEFAULT_DECK_JSON_ENUMERATIONS,
|
|
135
|
+
constants: DEFAULT_DECK_JSON_CONSTANTS,
|
|
136
|
+
functions: {
|
|
137
|
+
colorScale: (props) => createColorScaleMarker(props),
|
|
138
|
+
scale: (props) => {
|
|
139
|
+
const field = typeof props.field === 'string' ? props.field : undefined;
|
|
140
|
+
if (!field)
|
|
141
|
+
return undefined;
|
|
142
|
+
return `@@=${field}`;
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
// We preserve raw `@@=` strings here because `@deck.gl/json` would otherwise
|
|
146
|
+
// eagerly compile them into row-based accessors before `preProcessClassProps`
|
|
147
|
+
// can rewrite them for GeoArrow's batch-oriented callback contract.
|
|
148
|
+
convertFunction: ((expression) => `@@=${expression}`),
|
|
149
|
+
preProcessClassProps: (Class, props) => {
|
|
150
|
+
const layerName = getLayerName(Class);
|
|
151
|
+
const compatibility = getLayerCompatibility(layerName);
|
|
152
|
+
if (!compatibility) {
|
|
153
|
+
return props;
|
|
154
|
+
}
|
|
155
|
+
const layerProps = props;
|
|
156
|
+
const extensionProps = layerProps;
|
|
157
|
+
const datasetId = resolveDatasetId(extensionProps, datasetIds);
|
|
158
|
+
const managed = isManagedLayer(extensionProps, datasetIds) ||
|
|
159
|
+
(datasetIds.length > 1 && layerProps.data === undefined);
|
|
160
|
+
if (!managed) {
|
|
161
|
+
return props;
|
|
162
|
+
}
|
|
163
|
+
if (!datasetId) {
|
|
164
|
+
throw new Error(`Layer "${layerName}" must declare _sqlroomsBinding.dataset when multiple datasets are available.`);
|
|
165
|
+
}
|
|
166
|
+
const datasetState = datasetStates[datasetId];
|
|
167
|
+
if (!datasetState) {
|
|
168
|
+
throw new Error(`Layer "${layerName}" references unknown dataset "${datasetId}".`);
|
|
169
|
+
}
|
|
170
|
+
if (datasetState.status !== 'ready') {
|
|
171
|
+
return { ...stripLayerExtensionProps(layerProps), data: [] };
|
|
172
|
+
}
|
|
173
|
+
const prepared = datasetState.prepared;
|
|
174
|
+
const geometryColumn = resolveGeometryColumn(extensionProps);
|
|
175
|
+
const strippedProps = stripLayerExtensionProps(layerProps);
|
|
176
|
+
if (compatibility.representation === 'geojson') {
|
|
177
|
+
const baseProps = applyColorScale({
|
|
178
|
+
props: strippedProps,
|
|
179
|
+
table: prepared.table,
|
|
180
|
+
});
|
|
181
|
+
return {
|
|
182
|
+
...baseProps,
|
|
183
|
+
data: prepared.getGeoJsonBinaryData(geometryColumn),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const { table, boundProps } = resolveGeoArrowBindings({
|
|
187
|
+
layerName,
|
|
188
|
+
compatibility: compatibility,
|
|
189
|
+
layerProps: extensionProps,
|
|
190
|
+
prepared,
|
|
191
|
+
props: strippedProps,
|
|
192
|
+
});
|
|
193
|
+
const baseProps = applyColorScale({
|
|
194
|
+
props: strippedProps,
|
|
195
|
+
table,
|
|
196
|
+
});
|
|
197
|
+
const nextProps = {
|
|
198
|
+
...baseProps,
|
|
199
|
+
data: table,
|
|
200
|
+
...boundProps,
|
|
201
|
+
};
|
|
202
|
+
// Normalize getElevation: subtract column minimum so the lowest
|
|
203
|
+
// feature sits at ground level and differences are clearly visible.
|
|
204
|
+
const rawElev = nextProps.getElevation;
|
|
205
|
+
if (typeof rawElev === 'string' && rawElev.startsWith('@@=')) {
|
|
206
|
+
const elevField = rawElev.slice(3).trim();
|
|
207
|
+
const elevVector = table.getChild(elevField);
|
|
208
|
+
if (elevVector) {
|
|
209
|
+
let min = Infinity;
|
|
210
|
+
for (let i = 0; i < elevVector.length; i++) {
|
|
211
|
+
const v = Number(elevVector.get(i));
|
|
212
|
+
if (Number.isFinite(v) && v < min)
|
|
213
|
+
min = v;
|
|
214
|
+
}
|
|
215
|
+
if (Number.isFinite(min) && min !== 0) {
|
|
216
|
+
nextProps.getElevation = `@@=Math.max(0, ${elevField} - ${min})`;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const rewritten = rewriteGeoArrowAccessors({
|
|
221
|
+
props: nextProps,
|
|
222
|
+
table,
|
|
223
|
+
layerName,
|
|
224
|
+
});
|
|
225
|
+
// Set updateTriggers for @@= accessor props and getElevation
|
|
226
|
+
// so deck.gl re-evaluates them when references change or are cleared.
|
|
227
|
+
{
|
|
228
|
+
const accessorTriggers = {};
|
|
229
|
+
for (const [propName, propValue] of Object.entries(nextProps)) {
|
|
230
|
+
if (typeof propValue === 'string' &&
|
|
231
|
+
propValue.startsWith('@@=') &&
|
|
232
|
+
propName.startsWith('get')) {
|
|
233
|
+
accessorTriggers[propName] = propValue;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// Always emit getElevation trigger so clearing the column invalidates
|
|
237
|
+
// stale heights from a previous column-based accessor.
|
|
238
|
+
if (!('getElevation' in accessorTriggers)) {
|
|
239
|
+
const elev = nextProps.getElevation;
|
|
240
|
+
accessorTriggers.getElevation =
|
|
241
|
+
elev !== undefined ? String(elev) : 'none';
|
|
242
|
+
}
|
|
243
|
+
const existingTriggers = rewritten.updateTriggers &&
|
|
244
|
+
typeof rewritten.updateTriggers === 'object' &&
|
|
245
|
+
!Array.isArray(rewritten.updateTriggers)
|
|
246
|
+
? rewritten.updateTriggers
|
|
247
|
+
: {};
|
|
248
|
+
rewritten.updateTriggers = {
|
|
249
|
+
...existingTriggers,
|
|
250
|
+
...accessorTriggers,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
// For TripsLayer: compute max timestamp for animation and set defaults
|
|
254
|
+
if (layerName === 'GeoArrowTripsLayer' || layerName === 'TripsLayer') {
|
|
255
|
+
const tsVector = boundProps.getTimestamps;
|
|
256
|
+
if (tsVector) {
|
|
257
|
+
let maxTs = 0;
|
|
258
|
+
for (let i = 0; i < tsVector.length; i++) {
|
|
259
|
+
const listItem = tsVector.get(i);
|
|
260
|
+
if (listItem &&
|
|
261
|
+
typeof listItem === 'object' &&
|
|
262
|
+
'length' in listItem) {
|
|
263
|
+
const list = listItem;
|
|
264
|
+
for (let j = 0; j < list.length; j++) {
|
|
265
|
+
const v = Number(list.get(j)) || 0;
|
|
266
|
+
if (v > maxTs)
|
|
267
|
+
maxTs = v;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (maxTs > 0) {
|
|
272
|
+
rewritten._tripsMaxTimestamp = maxTs;
|
|
273
|
+
if (!rewritten.trailLength) {
|
|
274
|
+
rewritten.trailLength = maxTs;
|
|
275
|
+
}
|
|
276
|
+
if (rewritten.currentTime === undefined ||
|
|
277
|
+
rewritten.currentTime === 0) {
|
|
278
|
+
rewritten.currentTime = maxTs;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
// For HeatmapLayer: apply default colorRange (YlOrRd) when not explicitly set.
|
|
284
|
+
// Also set updateTriggers to force re-aggregation when colorRange changes.
|
|
285
|
+
if (layerName === 'GeoArrowHeatmapLayer') {
|
|
286
|
+
if (!rewritten.colorRange) {
|
|
287
|
+
rewritten.colorRange = DEFAULT_HEATMAP_COLOR_RANGE;
|
|
288
|
+
}
|
|
289
|
+
const existingTriggers = rewritten.updateTriggers &&
|
|
290
|
+
typeof rewritten.updateTriggers === 'object' &&
|
|
291
|
+
!Array.isArray(rewritten.updateTriggers)
|
|
292
|
+
? rewritten.updateTriggers
|
|
293
|
+
: {};
|
|
294
|
+
const previousGetWeight = existingTriggers.getWeight;
|
|
295
|
+
rewritten.updateTriggers = {
|
|
296
|
+
...existingTriggers,
|
|
297
|
+
getWeight: previousGetWeight === undefined
|
|
298
|
+
? JSON.stringify(rewritten.colorRange)
|
|
299
|
+
: [previousGetWeight, JSON.stringify(rewritten.colorRange)],
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
return rewritten;
|
|
303
|
+
},
|
|
304
|
+
postProcessConvertedJson: (json) => {
|
|
305
|
+
if (json &&
|
|
306
|
+
typeof json === 'object' &&
|
|
307
|
+
'layers' in json &&
|
|
308
|
+
Array.isArray(json.layers)) {
|
|
309
|
+
json.layers = json.layers.filter(Boolean);
|
|
310
|
+
}
|
|
311
|
+
return json;
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=createDeckJsonConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDeckJsonConfiguration.js","sourceRoot":"","sources":["../../src/json/createDeckJsonConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAGhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAC,kCAAkC,EAAC,MAAM,sBAAsB,CAAC;AAExE,OAAO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,MAAM,CAAC,EACpD,CAAC;gBACA,IAA4B,CAAC,MAAM,GAClC,IACD,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {JSONConfiguration} from '@deck.gl/json';\nimport * as arrow from 'apache-arrow';\nimport type {ColorScaleConfig} from '@sqlrooms/color-scales';\nimport {wkbGeometryDecoder} from '../prepare/wkbDecoder';\nimport {tryAggregateWaypointsToLineStrings} from './aggregateWaypoints';\nimport type {LayerBindingProps, PreparedDeckDatasetState} from '../types';\nimport {\n createColorScaleMarker,\n getAllColorScales,\n COLOR_SCALE_PROP_NAMES,\n} from './colorScaleFunction';\nimport {compileColorScale} from './compileColorScale';\nimport {\n DEFAULT_DECK_JSON_CLASSES,\n DEFAULT_DECK_JSON_CONSTANTS,\n DEFAULT_DECK_JSON_ENUMERATIONS,\n} from './defaultClasses';\nimport {DEFAULT_HEATMAP_COLOR_RANGE} from './heatmapDefaults';\nimport {getLayerCompatibility} from './layerCompatibility';\nimport {\n isManagedLayer,\n resolveConfiguredColumn,\n resolveDatasetId,\n resolveGeometryColumn,\n stripLayerExtensionProps,\n} from './layerConfig';\nimport {rewriteGeoArrowAccessors} from './rewriteGeoArrowAccessors';\n\ntype CreateDeckJsonConfigurationOptions = {\n datasetStates: Record<string, PreparedDeckDatasetState>;\n datasetIds: string[];\n};\n\nfunction getLayerName(Class: unknown) {\n const maybeClass = Class as {layerName?: string; name?: string};\n return maybeClass.layerName ?? maybeClass.name ?? 'UnknownLayer';\n}\n\nfunction applyColorScale(options: {\n props: Record<string, unknown>;\n table: import('apache-arrow').Table;\n}) {\n const {props, table} = options;\n const allScales = getAllColorScales(props);\n\n let result = props;\n const triggers: Record<string, unknown> =\n result.updateTriggers &&\n typeof result.updateTriggers === 'object' &&\n !Array.isArray(result.updateTriggers)\n ? {...(result.updateTriggers as Record<string, unknown>)}\n : {};\n\n for (const {propName, colorScale} of allScales) {\n result = {\n ...result,\n [propName]: compileColorScale({\n table,\n colorScale,\n }),\n };\n triggers[propName] = JSON.stringify(colorScale);\n }\n\n // Set updateTriggers for color props that are static or absent (not a scale)\n // so deck.gl detects changes when a scale is cleared or a constant value changes.\n for (const propName of COLOR_SCALE_PROP_NAMES) {\n if (!(propName in triggers)) {\n const value = result[propName];\n triggers[propName] = value !== undefined ? JSON.stringify(value) : 'none';\n }\n }\n\n if (Object.keys(triggers).length > 0) {\n result = {...result, updateTriggers: triggers};\n }\n\n return result;\n}\n\nfunction resolveGeoArrowBindings(options: {\n layerName: string;\n compatibility: NonNullable<ReturnType<typeof getLayerCompatibility>> & {\n representation: 'geoarrow';\n };\n layerProps: LayerBindingProps & Record<string, unknown>;\n prepared: Extract<PreparedDeckDatasetState, {status: 'ready'}>['prepared'];\n props: Record<string, unknown>;\n}) {\n const {layerName, compatibility, layerProps, prepared, props} = options;\n let table = prepared.table;\n const boundProps: Record<string, unknown> = {};\n\n for (const binding of compatibility.bindings) {\n if (props[binding.prop] !== undefined) {\n continue;\n }\n\n if (binding.kind === 'geometry') {\n const columnName = resolveConfiguredColumn(layerProps, binding.configKey);\n if (binding.required && !columnName) {\n throw new Error(\n `Layer \"${layerName}\" requires _sqlroomsBinding.${binding.configKey}.`,\n );\n }\n\n let resolvedGeometry;\n try {\n resolvedGeometry = prepared.resolveGeometry(columnName);\n } catch {\n throw new Error(\n `Geometry column \"${columnName}\" was not found in dataset \"${prepared.datasetId}\".`,\n );\n }\n\n // Detect mismatch: synthesized points can't satisfy a LineString binding.\n // For PathLayer, try auto-aggregating waypoint rows into linestrings.\n if (\n resolvedGeometry.encoding === 'geoarrow.point' &&\n binding.prop === 'getPath'\n ) {\n const aggregated = tryAggregateWaypointsToLineStrings(prepared.table);\n if (aggregated) {\n table = aggregated.table;\n boundProps[binding.prop] = aggregated.geometryVector;\n continue;\n }\n const available = prepared.table.schema.fields\n .map((f) => f.name)\n .join(', ');\n throw new Error(\n `Layer \"${layerName}\" requires LineString geometry for getPath, ` +\n `but only point coordinates were found and auto-aggregation failed. ` +\n `The dataset sqlQuery must aggregate rows into linestrings using ST_MakeLine. ` +\n `Available columns: ${available}.`,\n );\n }\n if (\n resolvedGeometry.encoding === 'geoarrow.point' &&\n binding.prop === 'getPolygon'\n ) {\n const available = prepared.table.schema.fields\n .map((f) => f.name)\n .join(', ');\n throw new Error(\n `Layer \"${layerName}\" requires Polygon geometry for ${binding.prop}, ` +\n `but only point coordinates were found. Available columns: ${available}.`,\n );\n }\n if (!resolvedGeometry.nativeGeoArrow) {\n if (\n !compatibility.allowGeoArrowPromotion ||\n !wkbGeometryDecoder.supportsGeoArrowPromotion(\n layerName,\n resolvedGeometry.encoding,\n prepared.table,\n resolvedGeometry.columnName,\n )\n ) {\n throw new Error(\n `Layer \"${layerName}\" cannot render geometry encoding \"${resolvedGeometry.encoding}\" for dataset \"${prepared.datasetId}\".`,\n );\n }\n }\n\n const layerData = prepared.getGeoArrowLayerData(columnName);\n if (layerData.source === 'promoted') {\n boundProps[binding.prop] = layerData.geometryColumn;\n if (table === prepared.table) {\n table = layerData.table;\n }\n } else {\n if (table !== prepared.table && table !== layerData.table) {\n throw new Error(\n `Layer \"${layerName}\" cannot combine promoted geometry columns from different prepared tables.`,\n );\n }\n table = layerData.table;\n boundProps[binding.prop] = layerData.geometryColumn;\n }\n continue;\n }\n\n const columnName = resolveConfiguredColumn(layerProps, binding.configKey);\n if (!columnName) {\n if (binding.required) {\n throw new Error(\n `Layer \"${layerName}\" requires _sqlroomsBinding.${binding.configKey}.`,\n );\n }\n continue;\n }\n\n const vector =\n table.getChild(columnName) ?? prepared.table.getChild(columnName);\n if (!vector) {\n throw new Error(\n `Layer \"${layerName}\" references unknown column \"${columnName}\" for ${binding.prop}.`,\n );\n }\n\n boundProps[binding.prop] = vector;\n }\n\n return {table, boundProps};\n}\n\nexport function createDeckJsonConfiguration(\n options: CreateDeckJsonConfigurationOptions,\n) {\n const {datasetStates, datasetIds} = options;\n\n return new JSONConfiguration({\n classes: DEFAULT_DECK_JSON_CLASSES,\n enumerations: DEFAULT_DECK_JSON_ENUMERATIONS,\n constants: DEFAULT_DECK_JSON_CONSTANTS,\n functions: {\n colorScale: (props: ColorScaleConfig) => createColorScaleMarker(props),\n scale: (props: Record<string, unknown>) => {\n const field = typeof props.field === 'string' ? props.field : undefined;\n if (!field) return undefined;\n return `@@=${field}`;\n },\n },\n // We preserve raw `@@=` strings here because `@deck.gl/json` would otherwise\n // eagerly compile them into row-based accessors before `preProcessClassProps`\n // can rewrite them for GeoArrow's batch-oriented callback contract.\n convertFunction: ((expression: string) => `@@=${expression}`) as never,\n preProcessClassProps: (Class: unknown, props: Record<string, unknown>) => {\n const layerName = getLayerName(Class);\n const compatibility = getLayerCompatibility(layerName);\n\n if (!compatibility) {\n return props;\n }\n\n const layerProps = props as Record<string, unknown>;\n const extensionProps = layerProps as typeof layerProps &\n LayerBindingProps;\n const datasetId = resolveDatasetId(extensionProps, datasetIds);\n const managed =\n isManagedLayer(extensionProps, datasetIds) ||\n (datasetIds.length > 1 && layerProps.data === undefined);\n\n if (!managed) {\n return props;\n }\n\n if (!datasetId) {\n throw new Error(\n `Layer \"${layerName}\" must declare _sqlroomsBinding.dataset when multiple datasets are available.`,\n );\n }\n\n const datasetState = datasetStates[datasetId];\n if (!datasetState) {\n throw new Error(\n `Layer \"${layerName}\" references unknown dataset \"${datasetId}\".`,\n );\n }\n\n if (datasetState.status !== 'ready') {\n return {...stripLayerExtensionProps(layerProps), data: []};\n }\n\n const prepared = datasetState.prepared;\n const geometryColumn = resolveGeometryColumn(extensionProps);\n const strippedProps = stripLayerExtensionProps(layerProps);\n\n if (compatibility.representation === 'geojson') {\n const baseProps = applyColorScale({\n props: strippedProps,\n table: prepared.table,\n });\n return {\n ...baseProps,\n data: prepared.getGeoJsonBinaryData(geometryColumn),\n };\n }\n\n const {table, boundProps} = resolveGeoArrowBindings({\n layerName,\n compatibility: compatibility as NonNullable<\n ReturnType<typeof getLayerCompatibility>\n > & {representation: 'geoarrow'},\n layerProps: extensionProps,\n prepared,\n props: strippedProps,\n });\n const baseProps = applyColorScale({\n props: strippedProps,\n table,\n });\n const nextProps: Record<string, unknown> = {\n ...baseProps,\n data: table,\n ...boundProps,\n };\n\n // Normalize getElevation: subtract column minimum so the lowest\n // feature sits at ground level and differences are clearly visible.\n const rawElev = nextProps.getElevation;\n if (typeof rawElev === 'string' && rawElev.startsWith('@@=')) {\n const elevField = rawElev.slice(3).trim();\n const elevVector = table.getChild(elevField);\n if (elevVector) {\n let min = Infinity;\n for (let i = 0; i < elevVector.length; i++) {\n const v = Number(elevVector.get(i));\n if (Number.isFinite(v) && v < min) min = v;\n }\n if (Number.isFinite(min) && min !== 0) {\n nextProps.getElevation = `@@=Math.max(0, ${elevField} - ${min})`;\n }\n }\n }\n\n const rewritten = rewriteGeoArrowAccessors({\n props: nextProps,\n table,\n layerName,\n });\n\n // Set updateTriggers for @@= accessor props and getElevation\n // so deck.gl re-evaluates them when references change or are cleared.\n {\n const accessorTriggers: Record<string, unknown> = {};\n for (const [propName, propValue] of Object.entries(nextProps)) {\n if (\n typeof propValue === 'string' &&\n propValue.startsWith('@@=') &&\n propName.startsWith('get')\n ) {\n accessorTriggers[propName] = propValue;\n }\n }\n // Always emit getElevation trigger so clearing the column invalidates\n // stale heights from a previous column-based accessor.\n if (!('getElevation' in accessorTriggers)) {\n const elev = nextProps.getElevation;\n accessorTriggers.getElevation =\n elev !== undefined ? String(elev) : 'none';\n }\n const existingTriggers =\n rewritten.updateTriggers &&\n typeof rewritten.updateTriggers === 'object' &&\n !Array.isArray(rewritten.updateTriggers)\n ? (rewritten.updateTriggers as Record<string, unknown>)\n : {};\n rewritten.updateTriggers = {\n ...existingTriggers,\n ...accessorTriggers,\n };\n }\n\n // For TripsLayer: compute max timestamp for animation and set defaults\n if (layerName === 'GeoArrowTripsLayer' || layerName === 'TripsLayer') {\n const tsVector = boundProps.getTimestamps as arrow.Vector | undefined;\n if (tsVector) {\n let maxTs = 0;\n for (let i = 0; i < tsVector.length; i++) {\n const listItem = tsVector.get(i);\n if (\n listItem &&\n typeof listItem === 'object' &&\n 'length' in listItem\n ) {\n const list = listItem as {\n length: number;\n get: (i: number) => unknown;\n };\n for (let j = 0; j < list.length; j++) {\n const v = Number(list.get(j)) || 0;\n if (v > maxTs) maxTs = v;\n }\n }\n }\n if (maxTs > 0) {\n rewritten._tripsMaxTimestamp = maxTs;\n if (!rewritten.trailLength) {\n rewritten.trailLength = maxTs;\n }\n if (\n rewritten.currentTime === undefined ||\n rewritten.currentTime === 0\n ) {\n rewritten.currentTime = maxTs;\n }\n }\n }\n }\n\n // For HeatmapLayer: apply default colorRange (YlOrRd) when not explicitly set.\n // Also set updateTriggers to force re-aggregation when colorRange changes.\n if (layerName === 'GeoArrowHeatmapLayer') {\n if (!rewritten.colorRange) {\n rewritten.colorRange = DEFAULT_HEATMAP_COLOR_RANGE;\n }\n const existingTriggers =\n rewritten.updateTriggers &&\n typeof rewritten.updateTriggers === 'object' &&\n !Array.isArray(rewritten.updateTriggers)\n ? (rewritten.updateTriggers as Record<string, unknown>)\n : {};\n const previousGetWeight = existingTriggers.getWeight;\n rewritten.updateTriggers = {\n ...existingTriggers,\n getWeight:\n previousGetWeight === undefined\n ? JSON.stringify(rewritten.colorRange)\n : [previousGetWeight, JSON.stringify(rewritten.colorRange)],\n };\n }\n\n return rewritten;\n },\n postProcessConvertedJson: (json: unknown) => {\n if (\n json &&\n typeof json === 'object' &&\n 'layers' in json &&\n Array.isArray((json as {layers?: unknown[]}).layers)\n ) {\n (json as {layers: unknown[]}).layers = (\n json as {layers: unknown[]}\n ).layers.filter(Boolean);\n }\n\n return json;\n },\n });\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const DEFAULT_DECK_JSON_CLASSES: Record<string, new (props: Record<string, unknown>) => unknown>;
|
|
2
|
+
export declare const DEFAULT_DECK_JSON_ENUMERATIONS: {
|
|
3
|
+
COORDINATE_SYSTEM: {
|
|
4
|
+
readonly DEFAULT: "default";
|
|
5
|
+
readonly LNGLAT: "lnglat";
|
|
6
|
+
readonly METER_OFFSETS: "meter-offsets";
|
|
7
|
+
readonly LNGLAT_OFFSETS: "lnglat-offsets";
|
|
8
|
+
readonly CARTESIAN: "cartesian";
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare const DEFAULT_DECK_JSON_CONSTANTS: {};
|
|
12
|
+
//# sourceMappingURL=defaultClasses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultClasses.d.ts","sourceRoot":"","sources":["../../src/json/defaultClasses.ts"],"names":[],"mappings":"AA+CA,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAC5C,MAAM,EACN,KAAK,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAgBhD,CAAC;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;CAE1C,CAAC;AAEF,eAAO,MAAM,2BAA2B,IAAK,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { COORDINATE_SYSTEM, FirstPersonView, MapView, OrbitView, OrthographicView, } from '@deck.gl/core';
|
|
2
|
+
import { GeoJsonLayer } from '@deck.gl/layers';
|
|
3
|
+
import { GeoArrowArcLayer, GeoArrowHeatmapLayer, GeoArrowPathLayer, GeoArrowPolygonLayer, GeoArrowScatterplotLayer, GeoArrowSolidPolygonLayer, } from '@geoarrow/deck.gl-geoarrow';
|
|
4
|
+
import { createTableToRecordBatchAdapter } from './layers/createTableToRecordBatchAdapter';
|
|
5
|
+
import { DeckColumnLayer, DeckH3HexagonLayer, DeckTripsLayer } from './layers';
|
|
6
|
+
// The 0.4.x GeoArrow layers expect `data: RecordBatch` + geometry as `Data`,
|
|
7
|
+
// but our JSON pipeline passes `data: Table` + geometry as `Vector`.
|
|
8
|
+
// These adapters bridge the gap by splitting Table batches into sublayers.
|
|
9
|
+
const AdaptedScatterplotLayer = createTableToRecordBatchAdapter(GeoArrowScatterplotLayer, 'GeoArrowScatterplotLayer');
|
|
10
|
+
const AdaptedHeatmapLayer = createTableToRecordBatchAdapter(GeoArrowHeatmapLayer, 'GeoArrowHeatmapLayer');
|
|
11
|
+
const AdaptedPathLayer = createTableToRecordBatchAdapter(GeoArrowPathLayer, 'GeoArrowPathLayer');
|
|
12
|
+
const AdaptedPolygonLayer = createTableToRecordBatchAdapter(GeoArrowPolygonLayer, 'GeoArrowPolygonLayer');
|
|
13
|
+
const AdaptedSolidPolygonLayer = createTableToRecordBatchAdapter(GeoArrowSolidPolygonLayer, 'GeoArrowSolidPolygonLayer');
|
|
14
|
+
const AdaptedArcLayer = createTableToRecordBatchAdapter(GeoArrowArcLayer, 'GeoArrowArcLayer');
|
|
15
|
+
export const DEFAULT_DECK_JSON_CLASSES = {
|
|
16
|
+
MapView,
|
|
17
|
+
FirstPersonView,
|
|
18
|
+
OrbitView,
|
|
19
|
+
OrthographicView,
|
|
20
|
+
GeoJsonLayer,
|
|
21
|
+
GeoArrowScatterplotLayer: AdaptedScatterplotLayer,
|
|
22
|
+
GeoArrowHeatmapLayer: AdaptedHeatmapLayer,
|
|
23
|
+
GeoArrowColumnLayer: DeckColumnLayer,
|
|
24
|
+
GeoArrowPathLayer: AdaptedPathLayer,
|
|
25
|
+
GeoArrowPolygonLayer: AdaptedPolygonLayer,
|
|
26
|
+
GeoArrowSolidPolygonLayer: AdaptedSolidPolygonLayer,
|
|
27
|
+
GeoArrowArcLayer: AdaptedArcLayer,
|
|
28
|
+
GeoArrowTripsLayer: DeckTripsLayer,
|
|
29
|
+
GeoArrowH3HexagonLayer: DeckH3HexagonLayer,
|
|
30
|
+
};
|
|
31
|
+
export const DEFAULT_DECK_JSON_ENUMERATIONS = {
|
|
32
|
+
COORDINATE_SYSTEM,
|
|
33
|
+
};
|
|
34
|
+
export const DEFAULT_DECK_JSON_CONSTANTS = {};
|
|
35
|
+
//# sourceMappingURL=defaultClasses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultClasses.js","sourceRoot":"","sources":["../../src/json/defaultClasses.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,OAAO,EACP,SAAS,EACT,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAC,+BAA+B,EAAC,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC;AAE7E,6EAA6E;AAC7E,qEAAqE;AACrE,2EAA2E;AAC3E,MAAM,uBAAuB,GAAG,+BAA+B,CAC7D,wBAA+B,EAC/B,0BAA0B,CAC3B,CAAC;AACF,MAAM,mBAAmB,GAAG,+BAA+B,CACzD,oBAA2B,EAC3B,sBAAsB,CACvB,CAAC;AACF,MAAM,gBAAgB,GAAG,+BAA+B,CACtD,iBAAwB,EACxB,mBAAmB,CACpB,CAAC;AACF,MAAM,mBAAmB,GAAG,+BAA+B,CACzD,oBAA2B,EAC3B,sBAAsB,CACvB,CAAC;AACF,MAAM,wBAAwB,GAAG,+BAA+B,CAC9D,yBAAgC,EAChC,2BAA2B,CAC5B,CAAC;AACF,MAAM,eAAe,GAAG,+BAA+B,CACrD,gBAAuB,EACvB,kBAAkB,CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAGlC;IACF,OAAO;IACP,eAAe;IACf,SAAS;IACT,gBAAgB;IAChB,YAAY;IACZ,wBAAwB,EAAE,uBAAuB;IACjD,oBAAoB,EAAE,mBAAmB;IACzC,mBAAmB,EAAE,eAAe;IACpC,iBAAiB,EAAE,gBAAgB;IACnC,oBAAoB,EAAE,mBAAmB;IACzC,yBAAyB,EAAE,wBAAwB;IACnD,gBAAgB,EAAE,eAAe;IACjC,kBAAkB,EAAE,cAAc;IAClC,sBAAsB,EAAE,kBAAkB;CAC3C,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,iBAAiB;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC","sourcesContent":["import {\n COORDINATE_SYSTEM,\n FirstPersonView,\n MapView,\n OrbitView,\n OrthographicView,\n} from '@deck.gl/core';\nimport {GeoJsonLayer} from '@deck.gl/layers';\nimport {\n GeoArrowArcLayer,\n GeoArrowHeatmapLayer,\n GeoArrowPathLayer,\n GeoArrowPolygonLayer,\n GeoArrowScatterplotLayer,\n GeoArrowSolidPolygonLayer,\n} from '@geoarrow/deck.gl-geoarrow';\nimport {createTableToRecordBatchAdapter} from './layers/createTableToRecordBatchAdapter';\nimport {DeckColumnLayer, DeckH3HexagonLayer, DeckTripsLayer} from './layers';\n\n// The 0.4.x GeoArrow layers expect `data: RecordBatch` + geometry as `Data`,\n// but our JSON pipeline passes `data: Table` + geometry as `Vector`.\n// These adapters bridge the gap by splitting Table batches into sublayers.\nconst AdaptedScatterplotLayer = createTableToRecordBatchAdapter(\n GeoArrowScatterplotLayer as any,\n 'GeoArrowScatterplotLayer',\n);\nconst AdaptedHeatmapLayer = createTableToRecordBatchAdapter(\n GeoArrowHeatmapLayer as any,\n 'GeoArrowHeatmapLayer',\n);\nconst AdaptedPathLayer = createTableToRecordBatchAdapter(\n GeoArrowPathLayer as any,\n 'GeoArrowPathLayer',\n);\nconst AdaptedPolygonLayer = createTableToRecordBatchAdapter(\n GeoArrowPolygonLayer as any,\n 'GeoArrowPolygonLayer',\n);\nconst AdaptedSolidPolygonLayer = createTableToRecordBatchAdapter(\n GeoArrowSolidPolygonLayer as any,\n 'GeoArrowSolidPolygonLayer',\n);\nconst AdaptedArcLayer = createTableToRecordBatchAdapter(\n GeoArrowArcLayer as any,\n 'GeoArrowArcLayer',\n);\n\nexport const DEFAULT_DECK_JSON_CLASSES: Record<\n string,\n new (props: Record<string, unknown>) => unknown\n> = {\n MapView,\n FirstPersonView,\n OrbitView,\n OrthographicView,\n GeoJsonLayer,\n GeoArrowScatterplotLayer: AdaptedScatterplotLayer,\n GeoArrowHeatmapLayer: AdaptedHeatmapLayer,\n GeoArrowColumnLayer: DeckColumnLayer,\n GeoArrowPathLayer: AdaptedPathLayer,\n GeoArrowPolygonLayer: AdaptedPolygonLayer,\n GeoArrowSolidPolygonLayer: AdaptedSolidPolygonLayer,\n GeoArrowArcLayer: AdaptedArcLayer,\n GeoArrowTripsLayer: DeckTripsLayer,\n GeoArrowH3HexagonLayer: DeckH3HexagonLayer,\n};\n\nexport const DEFAULT_DECK_JSON_ENUMERATIONS = {\n COORDINATE_SYSTEM,\n};\n\nexport const DEFAULT_DECK_JSON_CONSTANTS = {};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResolvedColorLegend } from '@sqlrooms/color-scales';
|
|
2
|
+
import type { PreparedDeckDatasetState } from '../types';
|
|
3
|
+
export declare function extractColorScaleLegends(options: {
|
|
4
|
+
spec: Record<string, unknown> | null;
|
|
5
|
+
datasetIds: string[];
|
|
6
|
+
datasetStates: Record<string, PreparedDeckDatasetState>;
|
|
7
|
+
}): ResolvedColorLegend[];
|
|
8
|
+
//# sourceMappingURL=extractColorScaleLegends.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractColorScaleLegends.d.ts","sourceRoot":"","sources":["../../src/json/extractColorScaleLegends.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,UAAU,CAAC;AAoDvD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACrC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;CACzD,yBA8DA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { getAllColorScales } from './colorScaleFunction';
|
|
2
|
+
import { buildColorScaleLegend } from './compileColorScale';
|
|
3
|
+
import { DEFAULT_HEATMAP_COLOR_RANGE } from './heatmapDefaults';
|
|
4
|
+
import { resolveColorLegend, resolveDatasetId } from './layerConfig';
|
|
5
|
+
function resolveLegendTitle(layerProps, propName, fallbackField) {
|
|
6
|
+
const legend = resolveColorLegend(layerProps, propName);
|
|
7
|
+
if (legend &&
|
|
8
|
+
typeof legend === 'object' &&
|
|
9
|
+
typeof legend.title === 'string') {
|
|
10
|
+
return legend.title;
|
|
11
|
+
}
|
|
12
|
+
return fallbackField;
|
|
13
|
+
}
|
|
14
|
+
function buildHeatmapLegend(layerProps) {
|
|
15
|
+
const rawRange = layerProps.colorRange;
|
|
16
|
+
const colorRange = Array.isArray(rawRange) && rawRange.length >= 2
|
|
17
|
+
? rawRange
|
|
18
|
+
: DEFAULT_HEATMAP_COLOR_RANGE;
|
|
19
|
+
const stops = colorRange.map((c, i) => {
|
|
20
|
+
const pct = (i / (colorRange.length - 1)) * 100;
|
|
21
|
+
return `rgba(${c[0]},${c[1]},${c[2]},${(c[3] ?? 255) / 255}) ${pct.toFixed(1)}%`;
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
type: 'continuous',
|
|
25
|
+
title: 'Density',
|
|
26
|
+
gradient: `linear-gradient(to right, ${stops.join(', ')})`,
|
|
27
|
+
ticks: [
|
|
28
|
+
{ label: 'Low', offset: 0 },
|
|
29
|
+
{ label: 'High', offset: 100 },
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function extractColorScaleLegends(options) {
|
|
34
|
+
const { spec, datasetIds, datasetStates } = options;
|
|
35
|
+
if (!spec || !Array.isArray(spec.layers)) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const legends = [];
|
|
39
|
+
for (const layer of spec.layers) {
|
|
40
|
+
if (!layer || typeof layer !== 'object') {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const layerProps = layer;
|
|
44
|
+
if (layerProps.visible === false) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const layerType = layerProps['@@type'];
|
|
48
|
+
if (layerType === 'GeoArrowHeatmapLayer') {
|
|
49
|
+
const heatmapLegend = buildHeatmapLegend(layerProps);
|
|
50
|
+
if (heatmapLegend) {
|
|
51
|
+
legends.push(heatmapLegend);
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const resolvedColorScales = getAllColorScales(layerProps);
|
|
56
|
+
if (resolvedColorScales.length === 0) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const datasetId = resolveDatasetId(layerProps, datasetIds);
|
|
60
|
+
if (!datasetId) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const datasetState = datasetStates[datasetId];
|
|
64
|
+
if (!datasetState || datasetState.status !== 'ready') {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
for (const { propName, colorScale } of resolvedColorScales) {
|
|
68
|
+
let resolvedLegend = null;
|
|
69
|
+
try {
|
|
70
|
+
resolvedLegend = buildColorScaleLegend({
|
|
71
|
+
table: datasetState.prepared.table,
|
|
72
|
+
colorScale,
|
|
73
|
+
title: resolveLegendTitle(layerProps, propName, colorScale.field),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (resolvedLegend) {
|
|
80
|
+
legends.push(resolvedLegend);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return legends;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=extractColorScaleLegends.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractColorScaleLegends.js","sourceRoot":"","sources":["../../src/json/extractColorScaleLegends.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAC,qBAAqB,EAAC,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAC,2BAA2B,EAAC,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAC,kBAAkB,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAInE,SAAS,kBAAkB,CACzB,UAAmC,EACnC,QAA4B,EAC5B,aAAqB;IAErB,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACxD,IACE,MAAM;QACN,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,EAChC,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,kBAAkB,CACzB,UAAmC;IAEnC,MAAM,QAAQ,GAAG,UAAU,CAAC,UAEf,CAAC;IACd,MAAM,UAAU,GACd,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC;QAC7C,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,2BAA2B,CAAC;IAElC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACpC,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QAChD,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,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,CAAC;YAC9B,CAAC;YACD,SAAS;QACX,CAAC;QAED,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC1D,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrC,SAAS;QACX,CAAC;QAED,MAAM,SAAS,GAAG,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAC3D,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS;QACX,CAAC;QAED,MAAM,YAAY,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;YACrD,SAAS;QACX,CAAC;QAED,KAAK,MAAM,EAAC,QAAQ,EAAE,UAAU,EAAC,IAAI,mBAAmB,EAAE,CAAC;YACzD,IAAI,cAAc,GAA+B,IAAI,CAAC;YACtD,IAAI,CAAC;gBACH,cAAc,GAAG,qBAAqB,CAAC;oBACrC,KAAK,EAAE,YAAY,CAAC,QAAQ,CAAC,KAAK;oBAClC,UAAU;oBACV,KAAK,EAAE,kBAAkB,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC;iBAClE,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,SAAS;YACX,CAAC;YAED,IAAI,cAAc,EAAE,CAAC;gBACnB,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type {ResolvedColorLegend} from '@sqlrooms/color-scales';\nimport type {PreparedDeckDatasetState} from '../types';\nimport {getAllColorScales} from './colorScaleFunction';\nimport {buildColorScaleLegend} from './compileColorScale';\nimport {DEFAULT_HEATMAP_COLOR_RANGE} from './heatmapDefaults';\nimport {resolveColorLegend, resolveDatasetId} from './layerConfig';\n\nimport type {ColorScalePropName} from './colorScaleFunction';\n\nfunction resolveLegendTitle(\n layerProps: Record<string, unknown>,\n propName: ColorScalePropName,\n fallbackField: string,\n) {\n const legend = resolveColorLegend(layerProps, propName);\n if (\n legend &&\n typeof legend === 'object' &&\n typeof legend.title === 'string'\n ) {\n return legend.title;\n }\n\n return fallbackField;\n}\n\nfunction buildHeatmapLegend(\n layerProps: Record<string, unknown>,\n): ResolvedColorLegend | null {\n const rawRange = layerProps.colorRange as\n | Array<[number, number, number, number]>\n | undefined;\n const colorRange =\n Array.isArray(rawRange) && rawRange.length >= 2\n ? rawRange\n : DEFAULT_HEATMAP_COLOR_RANGE;\n\n const stops = colorRange.map((c, i) => {\n const pct = (i / (colorRange.length - 1)) * 100;\n return `rgba(${c[0]},${c[1]},${c[2]},${(c[3] ?? 255) / 255}) ${pct.toFixed(1)}%`;\n });\n\n return {\n type: 'continuous',\n title: 'Density',\n gradient: `linear-gradient(to right, ${stops.join(', ')})`,\n ticks: [\n {label: 'Low', offset: 0},\n {label: 'High', offset: 100},\n ],\n };\n}\n\nexport function extractColorScaleLegends(options: {\n spec: Record<string, unknown> | null;\n datasetIds: string[];\n datasetStates: Record<string, PreparedDeckDatasetState>;\n}) {\n const {spec, datasetIds, datasetStates} = options;\n if (!spec || !Array.isArray(spec.layers)) {\n return [] as ResolvedColorLegend[];\n }\n\n const legends: ResolvedColorLegend[] = [];\n\n for (const layer of spec.layers) {\n if (!layer || typeof layer !== 'object') {\n continue;\n }\n\n const layerProps = layer as Record<string, unknown>;\n\n if (layerProps.visible === false) {\n continue;\n }\n\n const layerType = layerProps['@@type'];\n if (layerType === 'GeoArrowHeatmapLayer') {\n const heatmapLegend = buildHeatmapLegend(layerProps);\n if (heatmapLegend) {\n legends.push(heatmapLegend);\n }\n continue;\n }\n\n const resolvedColorScales = getAllColorScales(layerProps);\n if (resolvedColorScales.length === 0) {\n continue;\n }\n\n const datasetId = resolveDatasetId(layerProps, datasetIds);\n if (!datasetId) {\n continue;\n }\n\n const datasetState = datasetStates[datasetId];\n if (!datasetState || datasetState.status !== 'ready') {\n continue;\n }\n\n for (const {propName, colorScale} of resolvedColorScales) {\n let resolvedLegend: ResolvedColorLegend | null = null;\n try {\n resolvedLegend = buildColorScaleLegend({\n table: datasetState.prepared.table,\n colorScale,\n title: resolveLegendTitle(layerProps, propName, colorScale.field),\n });\n } catch {\n continue;\n }\n\n if (resolvedLegend) {\n legends.push(resolvedLegend);\n }\n }\n }\n\n return legends;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heatmapDefaults.d.ts","sourceRoot":"","sources":["../../src/json/heatmapDefaults.ts"],"names":[],"mappings":"AAOA,4FAA4F;AAC5F,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAC7C;IAAC,MAAM;IAAE,MAAM;IAAE,MAAM;IAAE,MAAM;CAAC,CAc7B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { continuousSequentialInterpolators, parseColorString, } from '@sqlrooms/color-scales';
|
|
2
|
+
const HEATMAP_COLOR_STEPS = 6;
|
|
3
|
+
/** Default color range for heatmap layers (YlOrRd, matching deck.gl's built-in default). */
|
|
4
|
+
export const DEFAULT_HEATMAP_COLOR_RANGE = continuousSequentialInterpolators.YlOrRd
|
|
5
|
+
? Array.from({ length: HEATMAP_COLOR_STEPS }, (_, i) => parseColorString(continuousSequentialInterpolators.YlOrRd(i / (HEATMAP_COLOR_STEPS - 1))))
|
|
6
|
+
: [
|
|
7
|
+
[255, 255, 178, 255],
|
|
8
|
+
[254, 178, 76, 255],
|
|
9
|
+
[253, 141, 60, 255],
|
|
10
|
+
[240, 59, 32, 255],
|
|
11
|
+
[189, 0, 38, 255],
|
|
12
|
+
[128, 0, 38, 255],
|
|
13
|
+
];
|
|
14
|
+
//# sourceMappingURL=heatmapDefaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heatmapDefaults.js","sourceRoot":"","sources":["../../src/json/heatmapDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,4FAA4F;AAC5F,MAAM,CAAC,MAAM,2BAA2B,GAEpC,iCAAiC,CAAC,MAAM;IAC1C,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,mBAAmB,EAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACjD,gBAAgB,CACd,iCAAiC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC,CACxE,CACF;IACH,CAAC,CAAC;QACE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;QACpB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC;QACnB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC;QACnB,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;QAClB,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC;QACjB,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC;KAClB,CAAC","sourcesContent":["import {\n continuousSequentialInterpolators,\n parseColorString,\n} from '@sqlrooms/color-scales';\n\nconst HEATMAP_COLOR_STEPS = 6;\n\n/** Default color range for heatmap layers (YlOrRd, matching deck.gl's built-in default). */\nexport const DEFAULT_HEATMAP_COLOR_RANGE: Array<\n [number, number, number, number]\n> = continuousSequentialInterpolators.YlOrRd\n ? Array.from({length: HEATMAP_COLOR_STEPS}, (_, i) =>\n parseColorString(\n continuousSequentialInterpolators.YlOrRd(i / (HEATMAP_COLOR_STEPS - 1)),\n ),\n )\n : [\n [255, 255, 178, 255],\n [254, 178, 76, 255],\n [253, 141, 60, 255],\n [240, 59, 32, 255],\n [189, 0, 38, 255],\n [128, 0, 38, 255],\n ];\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LayerConfigColumnKey } from './layerConfig';
|
|
2
|
+
type GeoJsonCompatibility = {
|
|
3
|
+
representation: 'geojson';
|
|
4
|
+
vectorAccessorProps: string[];
|
|
5
|
+
};
|
|
6
|
+
type GeoArrowBinding = {
|
|
7
|
+
prop: string;
|
|
8
|
+
kind: 'geometry' | 'column';
|
|
9
|
+
configKey: LayerConfigColumnKey;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
};
|
|
12
|
+
type GeoArrowCompatibility = {
|
|
13
|
+
representation: 'geoarrow';
|
|
14
|
+
bindings: GeoArrowBinding[];
|
|
15
|
+
vectorAccessorProps: string[];
|
|
16
|
+
allowGeoArrowPromotion?: boolean;
|
|
17
|
+
};
|
|
18
|
+
type LayerCompatibility = GeoJsonCompatibility | GeoArrowCompatibility;
|
|
19
|
+
export declare function getLayerCompatibility(layerName: string): LayerCompatibility | undefined;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=layerCompatibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layerCompatibility.d.ts","sourceRoot":"","sources":["../../src/json/layerCompatibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAExD,KAAK,oBAAoB,GAAG;IAC1B,cAAc,EAAE,SAAS,CAAC;IAC1B,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC5B,SAAS,EAAE,oBAAoB,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,cAAc,EAAE,UAAU,CAAC;IAC3B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,KAAK,kBAAkB,GAAG,oBAAoB,GAAG,qBAAqB,CAAC;AAuKvE,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,kCAEtD"}
|