@deck.gl/carto 8.8.3 → 8.8.6
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/dist/dist.dev.js +1382 -1153
- package/dist/es5/api/index.js.map +1 -1
- package/dist/es5/api/layer-map.js +104 -17
- package/dist/es5/api/layer-map.js.map +1 -1
- package/dist/es5/api/maps-api-common.js.map +1 -1
- package/dist/es5/api/maps-v3-client.js +213 -47
- package/dist/es5/api/maps-v3-client.js.map +1 -1
- package/dist/es5/api/parseMap.js +14 -4
- package/dist/es5/api/parseMap.js.map +1 -1
- package/dist/es5/config.js +11 -2
- package/dist/es5/config.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/layers/carto-layer.js +10 -23
- package/dist/es5/layers/carto-layer.js.map +1 -1
- package/dist/es5/style/color-bins-style.js.map +1 -1
- package/dist/es5/style/color-categories-style.js.map +1 -1
- package/dist/es5/style/color-continuous-style.js.map +1 -1
- package/dist/es5/style/utils.js +3 -1
- package/dist/es5/style/utils.js.map +1 -1
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/layer-map.js +79 -14
- package/dist/esm/api/layer-map.js.map +1 -1
- package/dist/esm/api/maps-api-common.js.map +1 -1
- package/dist/esm/api/maps-v3-client.js +111 -11
- package/dist/esm/api/maps-v3-client.js.map +1 -1
- package/dist/esm/api/parseMap.js +18 -4
- package/dist/esm/api/parseMap.js.map +1 -1
- package/dist/esm/config.js +10 -2
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/layers/carto-layer.js +7 -19
- package/dist/esm/layers/carto-layer.js.map +1 -1
- package/dist/esm/style/color-bins-style.js.map +1 -1
- package/dist/esm/style/color-categories-style.js.map +1 -1
- package/dist/esm/style/color-continuous-style.js.map +1 -1
- package/dist/esm/style/utils.js +3 -1
- package/dist/esm/style/utils.js.map +1 -1
- package/dist.min.js +138 -138
- package/package.json +9 -9
- package/src/api/index.ts +1 -0
- package/src/api/layer-map.ts +76 -13
- package/src/api/maps-api-common.ts +8 -0
- package/src/api/maps-v3-client.ts +116 -12
- package/src/api/parseMap.ts +6 -2
- package/src/config.ts +12 -2
- package/src/index.ts +1 -1
- package/src/layers/carto-layer.ts +19 -32
- package/src/style/color-bins-style.ts +25 -3
- package/src/style/color-categories-style.ts +28 -4
- package/src/style/color-continuous-style.ts +25 -3
- package/src/style/utils.ts +8 -4
- package/typed/api/index.d.ts +1 -0
- package/typed/api/index.d.ts.map +1 -1
- package/typed/api/layer-map.d.ts +12 -4
- package/typed/api/layer-map.d.ts.map +1 -1
- package/typed/api/maps-api-common.d.ts +4 -0
- package/typed/api/maps-api-common.d.ts.map +1 -1
- package/typed/api/maps-v3-client.d.ts +4 -3
- package/typed/api/maps-v3-client.d.ts.map +1 -1
- package/typed/config.d.ts +2 -0
- package/typed/config.d.ts.map +1 -1
- package/typed/index.d.ts +1 -0
- package/typed/index.d.ts.map +1 -1
- package/typed/layers/carto-layer.d.ts +5 -8
- package/typed/layers/carto-layer.d.ts.map +1 -1
- package/typed/style/color-bins-style.d.ts +22 -3
- package/typed/style/color-bins-style.d.ts.map +1 -1
- package/typed/style/color-categories-style.d.ts +24 -4
- package/typed/style/color-categories-style.d.ts.map +1 -1
- package/typed/style/color-continuous-style.d.ts +22 -3
- package/typed/style/color-continuous-style.d.ts.map +1 -1
- package/typed/style/utils.d.ts +3 -6
- package/typed/style/utils.d.ts.map +1 -1
- package/typed/api/index.js +0 -3
- package/typed/api/layer-map.js +0 -264
- package/typed/api/maps-api-common.js +0 -50
- package/typed/api/maps-client.js +0 -125
- package/typed/api/maps-v3-client.js +0 -304
- package/typed/api/parseMap.js +0 -178
- package/typed/basemap.js +0 -9
- package/typed/config.js +0 -35
- package/typed/index.js +0 -10
- package/typed/layers/carto-layer.js +0 -173
- package/typed/layers/carto-tile-layer.js +0 -105
- package/typed/layers/h3-tile-layer.js +0 -47
- package/typed/layers/h3-tileset-2d.js +0 -85
- package/typed/layers/quadkey-tile-layer.js +0 -42
- package/typed/layers/quadkey-tileset-2d.js +0 -36
- package/typed/layers/schema/carto-tile.js +0 -161
- package/typed/layers/spatial-index-tile-layer.js +0 -40
- package/typed/style/color-bins-style.js +0 -12
- package/typed/style/color-categories-style.js +0 -16
- package/typed/style/color-continuous-style.js +0 -12
- package/typed/style/palette.js +0 -62
- package/typed/style/utils.js +0 -15
- package/typed/utils.js +0 -4
package/dist/es5/api/parseMap.js
CHANGED
|
@@ -218,21 +218,31 @@ function createChannelProps(visualChannels, type, config, data) {
|
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
} else if (colorField) {
|
|
221
|
-
|
|
221
|
+
var aggregation = visConfig.colorAggregation,
|
|
222
|
+
range = visConfig.colorRange;
|
|
223
|
+
result.getFillColor = (0, _layerMap.getColorAccessor)(colorField, colorScale, {
|
|
224
|
+
aggregation: aggregation,
|
|
225
|
+
range: range
|
|
226
|
+
}, visConfig.opacity, data);
|
|
222
227
|
}
|
|
223
228
|
|
|
224
229
|
if (strokeColorField) {
|
|
225
230
|
var fallbackOpacity = type === 'point' ? visConfig.opacity : 1;
|
|
226
231
|
var opacity = visConfig.strokeOpacity !== undefined ? visConfig.strokeOpacity : fallbackOpacity;
|
|
227
|
-
|
|
232
|
+
var _aggregation = visConfig.strokeColorAggregation,
|
|
233
|
+
_range = visConfig.strokeColorRange;
|
|
234
|
+
result.getLineColor = (0, _layerMap.getColorAccessor)(strokeColorField, strokeColorScale, {
|
|
235
|
+
aggregation: _aggregation,
|
|
236
|
+
range: _range
|
|
237
|
+
}, opacity, data);
|
|
228
238
|
}
|
|
229
239
|
|
|
230
240
|
if (heightField) {
|
|
231
|
-
result.getElevation = (0, _layerMap.getSizeAccessor)(heightField, heightScale, visConfig.heightRange || visConfig.sizeRange, data);
|
|
241
|
+
result.getElevation = (0, _layerMap.getSizeAccessor)(heightField, heightScale, visConfig.heightAggregation, visConfig.heightRange || visConfig.sizeRange, data);
|
|
232
242
|
}
|
|
233
243
|
|
|
234
244
|
if (sizeField) {
|
|
235
|
-
result.getPointRadius = (0, _layerMap.getSizeAccessor)(sizeField, sizeScale, visConfig.radiusRange || visConfig.sizeRange, data);
|
|
245
|
+
result.getPointRadius = (0, _layerMap.getSizeAccessor)(sizeField, sizeScale, visConfig.sizeAggregation, visConfig.radiusRange || visConfig.sizeRange, data);
|
|
236
246
|
}
|
|
237
247
|
|
|
238
248
|
if (textLabelField) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/api/parseMap.ts"],"names":["parseMap","json","keplerMapConfig","datasets","version","config","mapState","mapStyle","visState","layers","layerBlending","interactionConfig","id","title","description","createdAt","updatedAt","initialViewState","extractTextLayers","reverse","map","type","visualChannels","dataId","dataset","find","d","data","Layer","propMap","defaultProps","createBlendingProps","textLabel","createInteractionProps","createStyleProps","createChannelProps","e","log","error","message","undefined","rest","configRest","filter","t","field","name","label","visConfig","opacity","parameters","blendFunc","blendEquation","pickable","tooltip","enabled","autoHighlight","mapProps","source","target","mapping","sourceKey","sourceValue","targetKey","Object","entries","key","value","result","stroked","getLineColor","getFillColor","colorAccessor","OPACITY_MAP","Array","isArray","color","opacityKey","highlightColor","enable3d","colorField","colorScale","sizeField","sizeScale","strokeColorField","strokeColorScale","heightField","heightScale","textLabelField","colorScaleType","colorAggregation","AGGREGATION","getColorValue","getColorWeight","colorRange","fallbackOpacity","strokeOpacity","strokeColorRange","getElevation","heightRange","sizeRange","getPointRadius","radiusRange","getText","pointType","radius","getTextPixelOffset"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AAWA;;AACA;;;;;;;;;AAEO,SAASA,QAAT,CAAkBC,IAAlB,EAAwB;AAC7B,MAAOC,eAAP,GAAoCD,IAApC,CAAOC,eAAP;AAAA,MAAwBC,QAAxB,GAAoCF,IAApC,CAAwBE,QAAxB;AACA,qBAAOD,eAAe,CAACE,OAAhB,KAA4B,IAAnC,EAAyC,wBAAzC;AACA,8BAA6BF,eAAe,C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AAAA,MAAM,CAACoC,SAAP,GAAmB,MAAnB;AACA,QAAMC,MAAM,GAAGrC,MAAM,CAACiC,cAAP,IAAyBrD,SAAS,CAACyD,MAAlD;AACArC,IAAAA,MAAM,CAACsC,kBAAP,GAA4B,0CAA2B1E,SAA3B,EAAsCyE,MAAtC,CAA5B;AACD;;AAED,SAAOrC,MAAP;AACD","sourcesContent":["import GL from '@luma.gl/constants';\nimport {\n AGGREGATION,\n getLayer,\n getColorAccessor,\n getColorValueAccessor,\n getSizeAccessor,\n getTextAccessor,\n getTextPixelOffsetAccessor,\n OPACITY_MAP,\n opacityToAlpha\n} from './layer-map';\nimport {_flatten as flatten, log} from '@deck.gl/core';\nimport {assert} from '../utils';\n\nexport function parseMap(json) {\n const {keplerMapConfig, datasets} = json;\n assert(keplerMapConfig.version === 'v1', 'Only support Kepler v1');\n const {mapState, mapStyle} = keplerMapConfig.config;\n const {layers, layerBlending, interactionConfig} = keplerMapConfig.config.visState;\n\n return {\n id: json.id,\n title: json.title,\n description: json.description,\n createdAt: json.createdAt,\n updatedAt: json.updatedAt,\n initialViewState: mapState,\n mapStyle,\n layers: extractTextLayers(layers.reverse()).map(({id, type, config, visualChannels}) => {\n try {\n const {dataId} = config;\n const dataset = datasets.find(d => d.id === dataId);\n assert(dataset, `No dataset matching dataId: ${dataId}`);\n const {data} = dataset;\n assert(data, `No data loaded for dataId: ${dataId}`);\n const {Layer, propMap, defaultProps} = getLayer(type, config, dataset);\n return new Layer({\n id,\n data,\n ...defaultProps,\n ...createBlendingProps(layerBlending),\n ...(!config.textLabel && createInteractionProps(interactionConfig)),\n ...createStyleProps(config, propMap),\n ...createChannelProps(visualChannels, type, config, data) // Must come after style\n });\n } catch (e: any) {\n log.error(e.message)();\n return undefined;\n }\n })\n };\n}\n\nfunction extractTextLayers(layers) {\n return flatten(\n layers.map(({id, config, ...rest}) => {\n const {textLabel, ...configRest} = config;\n return [\n // Original layer without textLabel\n {id, config: configRest, ...rest},\n\n // One layer per valid text label, with full opacity\n ...textLabel\n .filter(t => t.field)\n .map(t => {\n return {\n id: `${id}-label-${t.field.name}`,\n config: {\n textLabel: t,\n ...configRest,\n label: `${config.label}-label-${t.field.name}`,\n visConfig: {...configRest.visConfig, opacity: 1}\n },\n ...rest\n };\n })\n ];\n })\n );\n}\n\nfunction createBlendingProps(layerBlending) {\n if (layerBlending === 'additive') {\n return {\n parameters: {\n blendFunc: [GL.SRC_ALPHA, GL.DST_ALPHA],\n blendEquation: GL.FUNC_ADD\n }\n };\n } else if (layerBlending === 'subtractive') {\n return {\n parameters: {\n blendFunc: [GL.ONE, GL.ONE_MINUS_DST_COLOR, GL.SRC_ALPHA, GL.DST_ALPHA],\n blendEquation: [GL.FUNC_SUBTRACT, GL.FUNC_ADD]\n }\n };\n }\n\n return {};\n}\n\nfunction createInteractionProps(interactionConfig) {\n const pickable = interactionConfig && interactionConfig.tooltip.enabled;\n return {\n autoHighlight: pickable,\n pickable\n };\n}\n\nfunction mapProps(source, target, mapping) {\n for (const sourceKey in mapping) {\n const sourceValue = source[sourceKey];\n const targetKey = mapping[sourceKey];\n if (sourceValue === undefined) {\n // eslint-disable-next-line no-continue\n continue;\n }\n if (typeof targetKey === 'string') {\n target[targetKey] = sourceValue;\n } else if (typeof targetKey === 'function') {\n const [key, value] = Object.entries(targetKey(sourceValue))[0];\n target[key] = value;\n } else if (typeof targetKey === 'object') {\n // Nested definition, recurse down one level (also handles arrays)\n mapProps(sourceValue, target, targetKey);\n }\n }\n}\n\nfunction createStyleProps(config, mapping) {\n const result: Record<string, any> = {};\n mapProps(config, result, mapping);\n\n // Kepler format sometimes omits strokeColor. TODO: remove once we can rely on\n // `strokeColor` always being set when `stroke: true`.\n if (result.stroked && !result.getLineColor) {\n result.getLineColor = result.getFillColor;\n }\n\n for (const colorAccessor in OPACITY_MAP) {\n if (Array.isArray(result[colorAccessor])) {\n const color = [...result[colorAccessor]];\n const opacityKey = OPACITY_MAP[colorAccessor];\n const opacity = config.visConfig[opacityKey];\n color[3] = opacityToAlpha(opacity);\n result[colorAccessor] = color;\n }\n }\n\n result.highlightColor = config.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];\n return result;\n}\n\n/* eslint-disable complexity, max-statements */\nfunction createChannelProps(visualChannels, type, config, data) {\n const {colorField, colorScale, sizeField, sizeScale, strokeColorField, strokeColorScale} =\n visualChannels;\n let {heightField, heightScale} = visualChannels;\n if (type === 'hexagonId') {\n heightField = sizeField;\n heightScale = sizeScale;\n }\n const {textLabel, visConfig} = config;\n const result: Record<string, any> = {};\n const textLabelField = textLabel && textLabel.field;\n\n if (type === 'grid' || type === 'hexagon') {\n result.colorScaleType = colorScale;\n if (colorField) {\n const {colorAggregation} = config.visConfig;\n if (!AGGREGATION[colorAggregation]) {\n result.getColorValue = getColorValueAccessor(colorField, colorAggregation, data);\n } else {\n result.getColorWeight = d => d[colorField.name];\n }\n }\n } else if (colorField) {\n result.getFillColor = getColorAccessor(\n colorField,\n colorScale,\n visConfig.colorRange,\n visConfig.opacity,\n data\n );\n }\n\n if (strokeColorField) {\n const fallbackOpacity = type === 'point' ? visConfig.opacity : 1;\n const opacity =\n visConfig.strokeOpacity !== undefined ? visConfig.strokeOpacity : fallbackOpacity;\n result.getLineColor = getColorAccessor(\n strokeColorField,\n strokeColorScale,\n visConfig.strokeColorRange,\n opacity,\n data\n );\n }\n if (heightField) {\n result.getElevation = getSizeAccessor(\n heightField,\n heightScale,\n visConfig.heightRange || visConfig.sizeRange,\n data\n );\n }\n if (sizeField) {\n result.getPointRadius = getSizeAccessor(\n sizeField,\n sizeScale,\n visConfig.radiusRange || visConfig.sizeRange,\n data\n );\n }\n if (textLabelField) {\n result.getText = getTextAccessor(textLabelField, data);\n result.pointType = 'text';\n const radius = result.getPointRadius || visConfig.radius;\n result.getTextPixelOffset = getTextPixelOffsetAccessor(textLabel, radius);\n }\n\n return result;\n}\n"],"file":"parseMap.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/api/parseMap.ts"],"names":["parseMap","json","keplerMapConfig","datasets","version","config","mapState","mapStyle","visState","layers","layerBlending","interactionConfig","id","title","description","createdAt","updatedAt","initialViewState","extractTextLayers","reverse","map","type","visualChannels","dataId","dataset","find","d","data","Layer","propMap","defaultProps","createBlendingProps","textLabel","createInteractionProps","createStyleProps","createChannelProps","e","log","error","message","undefined","rest","configRest","filter","t","field","name","label","visConfig","opacity","parameters","blendFunc","blendEquation","pickable","tooltip","enabled","autoHighlight","mapProps","source","target","mapping","sourceKey","sourceValue","targetKey","Object","entries","key","value","result","stroked","getLineColor","getFillColor","colorAccessor","OPACITY_MAP","Array","isArray","color","opacityKey","highlightColor","enable3d","colorField","colorScale","sizeField","sizeScale","strokeColorField","strokeColorScale","heightField","heightScale","textLabelField","colorScaleType","colorAggregation","AGGREGATION","getColorValue","getColorWeight","aggregation","range","colorRange","fallbackOpacity","strokeOpacity","strokeColorAggregation","strokeColorRange","getElevation","heightAggregation","heightRange","sizeRange","getPointRadius","sizeAggregation","radiusRange","getText","pointType","radius","getTextPixelOffset"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AAWA;;AACA;;;;;;;;;AAEO,SAASA,QAAT,CAAkBC,IAAlB,EAAwB;AAC7B,MAAOC,eAAP,GAAoCD,IAApC,CAAOC,eAAP;AAAA,MAAwBC,QAAxB,GAAoCF,IAApC,CAAwBE,QAAxB;AACA,qBAAOD,eAAe,CAACE,OAAhB,KAA4B,IAAnC,EAAyC,wBAAzC;AACA,8BAA6BF,eAAe,CAACG,MAA7C;AAAA,MAAOC,QAAP,yBAAOA,QAAP;AAAA,MAAiBC,QAAjB,yBAAiBA,QAAjB;AACA,+BAAmDL,eAAe,CAACG,MAAhB,CAAuBG,QAA1E;AAAA,MAAOC,MAAP,0BAAOA,MAAP;AAAA,MAAeC,aAAf,0BAAeA,aAAf;AAAA,MAA8BC,iBAA9B,0BAA8BA,iBAA9B;AAEA,SAAO;AACLC,IAAAA,EAAE,EAAEX,IAAI,CAACW,EADJ;AAELC,IAA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wC,OAAP,GAAiB,+BAAgBpB,cAAhB,EAAgC7D,IAAhC,CAAjB;AACAyC,IAAAA,MAAM,CAACyC,SAAP,GAAmB,MAAnB;AACA,QAAMC,MAAM,GAAG1C,MAAM,CAACqC,cAAP,IAAyBzD,SAAS,CAAC8D,MAAlD;AACA1C,IAAAA,MAAM,CAAC2C,kBAAP,GAA4B,0CAA2B/E,SAA3B,EAAsC8E,MAAtC,CAA5B;AACD;;AAED,SAAO1C,MAAP;AACD","sourcesContent":["import GL from '@luma.gl/constants';\nimport {\n AGGREGATION,\n getLayer,\n getColorAccessor,\n getColorValueAccessor,\n getSizeAccessor,\n getTextAccessor,\n getTextPixelOffsetAccessor,\n OPACITY_MAP,\n opacityToAlpha\n} from './layer-map';\nimport {_flatten as flatten, log} from '@deck.gl/core';\nimport {assert} from '../utils';\n\nexport function parseMap(json) {\n const {keplerMapConfig, datasets} = json;\n assert(keplerMapConfig.version === 'v1', 'Only support Kepler v1');\n const {mapState, mapStyle} = keplerMapConfig.config;\n const {layers, layerBlending, interactionConfig} = keplerMapConfig.config.visState;\n\n return {\n id: json.id,\n title: json.title,\n description: json.description,\n createdAt: json.createdAt,\n updatedAt: json.updatedAt,\n initialViewState: mapState,\n mapStyle,\n layers: extractTextLayers(layers.reverse()).map(({id, type, config, visualChannels}) => {\n try {\n const {dataId} = config;\n const dataset = datasets.find(d => d.id === dataId);\n assert(dataset, `No dataset matching dataId: ${dataId}`);\n const {data} = dataset;\n assert(data, `No data loaded for dataId: ${dataId}`);\n const {Layer, propMap, defaultProps} = getLayer(type, config, dataset);\n return new Layer({\n id,\n data,\n ...defaultProps,\n ...createBlendingProps(layerBlending),\n ...(!config.textLabel && createInteractionProps(interactionConfig)),\n ...createStyleProps(config, propMap),\n ...createChannelProps(visualChannels, type, config, data) // Must come after style\n });\n } catch (e: any) {\n log.error(e.message)();\n return undefined;\n }\n })\n };\n}\n\nfunction extractTextLayers(layers) {\n return flatten(\n layers.map(({id, config, ...rest}) => {\n const {textLabel, ...configRest} = config;\n return [\n // Original layer without textLabel\n {id, config: configRest, ...rest},\n\n // One layer per valid text label, with full opacity\n ...textLabel\n .filter(t => t.field)\n .map(t => {\n return {\n id: `${id}-label-${t.field.name}`,\n config: {\n textLabel: t,\n ...configRest,\n label: `${config.label}-label-${t.field.name}`,\n visConfig: {...configRest.visConfig, opacity: 1}\n },\n ...rest\n };\n })\n ];\n })\n );\n}\n\nfunction createBlendingProps(layerBlending) {\n if (layerBlending === 'additive') {\n return {\n parameters: {\n blendFunc: [GL.SRC_ALPHA, GL.DST_ALPHA],\n blendEquation: GL.FUNC_ADD\n }\n };\n } else if (layerBlending === 'subtractive') {\n return {\n parameters: {\n blendFunc: [GL.ONE, GL.ONE_MINUS_DST_COLOR, GL.SRC_ALPHA, GL.DST_ALPHA],\n blendEquation: [GL.FUNC_SUBTRACT, GL.FUNC_ADD]\n }\n };\n }\n\n return {};\n}\n\nfunction createInteractionProps(interactionConfig) {\n const pickable = interactionConfig && interactionConfig.tooltip.enabled;\n return {\n autoHighlight: pickable,\n pickable\n };\n}\n\nfunction mapProps(source, target, mapping) {\n for (const sourceKey in mapping) {\n const sourceValue = source[sourceKey];\n const targetKey = mapping[sourceKey];\n if (sourceValue === undefined) {\n // eslint-disable-next-line no-continue\n continue;\n }\n if (typeof targetKey === 'string') {\n target[targetKey] = sourceValue;\n } else if (typeof targetKey === 'function') {\n const [key, value] = Object.entries(targetKey(sourceValue))[0];\n target[key] = value;\n } else if (typeof targetKey === 'object') {\n // Nested definition, recurse down one level (also handles arrays)\n mapProps(sourceValue, target, targetKey);\n }\n }\n}\n\nfunction createStyleProps(config, mapping) {\n const result: Record<string, any> = {};\n mapProps(config, result, mapping);\n\n // Kepler format sometimes omits strokeColor. TODO: remove once we can rely on\n // `strokeColor` always being set when `stroke: true`.\n if (result.stroked && !result.getLineColor) {\n result.getLineColor = result.getFillColor;\n }\n\n for (const colorAccessor in OPACITY_MAP) {\n if (Array.isArray(result[colorAccessor])) {\n const color = [...result[colorAccessor]];\n const opacityKey = OPACITY_MAP[colorAccessor];\n const opacity = config.visConfig[opacityKey];\n color[3] = opacityToAlpha(opacity);\n result[colorAccessor] = color;\n }\n }\n\n result.highlightColor = config.visConfig.enable3d ? [255, 255, 255, 60] : [252, 242, 26, 255];\n return result;\n}\n\n/* eslint-disable complexity, max-statements */\nfunction createChannelProps(visualChannels, type, config, data) {\n const {colorField, colorScale, sizeField, sizeScale, strokeColorField, strokeColorScale} =\n visualChannels;\n let {heightField, heightScale} = visualChannels;\n if (type === 'hexagonId') {\n heightField = sizeField;\n heightScale = sizeScale;\n }\n const {textLabel, visConfig} = config;\n const result: Record<string, any> = {};\n const textLabelField = textLabel && textLabel.field;\n\n if (type === 'grid' || type === 'hexagon') {\n result.colorScaleType = colorScale;\n if (colorField) {\n const {colorAggregation} = config.visConfig;\n if (!AGGREGATION[colorAggregation]) {\n result.getColorValue = getColorValueAccessor(colorField, colorAggregation, data);\n } else {\n result.getColorWeight = d => d[colorField.name];\n }\n }\n } else if (colorField) {\n const {colorAggregation: aggregation, colorRange: range} = visConfig;\n result.getFillColor = getColorAccessor(\n colorField,\n colorScale,\n {aggregation, range},\n visConfig.opacity,\n data\n );\n }\n\n if (strokeColorField) {\n const fallbackOpacity = type === 'point' ? visConfig.opacity : 1;\n const opacity =\n visConfig.strokeOpacity !== undefined ? visConfig.strokeOpacity : fallbackOpacity;\n const {strokeColorAggregation: aggregation, strokeColorRange: range} = visConfig;\n result.getLineColor = getColorAccessor(\n strokeColorField,\n strokeColorScale,\n {aggregation, range},\n opacity,\n data\n );\n }\n if (heightField) {\n result.getElevation = getSizeAccessor(\n heightField,\n heightScale,\n visConfig.heightAggregation,\n visConfig.heightRange || visConfig.sizeRange,\n data\n );\n }\n if (sizeField) {\n result.getPointRadius = getSizeAccessor(\n sizeField,\n sizeScale,\n visConfig.sizeAggregation,\n visConfig.radiusRange || visConfig.sizeRange,\n data\n );\n }\n if (textLabelField) {\n result.getText = getTextAccessor(textLabelField, data);\n result.pointType = 'text';\n const radius = result.getPointRadius || visConfig.radius;\n result.getTextPixelOffset = getTextPixelOffsetAccessor(textLabel, radius);\n }\n\n return result;\n}\n"],"file":"parseMap.js"}
|
package/dist/es5/config.js
CHANGED
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.setDefaultCredentials = setDefaultCredentials;
|
|
9
9
|
exports.getDefaultCredentials = getDefaultCredentials;
|
|
10
10
|
exports.buildMapsUrlFromBase = buildMapsUrlFromBase;
|
|
11
|
+
exports.buildStatsUrlFromBase = buildStatsUrlFromBase;
|
|
11
12
|
exports.defaultCloudNativeCredentials = exports.defaultClassicCredentials = void 0;
|
|
12
13
|
|
|
13
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -63,8 +64,8 @@ function getDefaultCredentials() {
|
|
|
63
64
|
return credentials;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
function
|
|
67
|
-
var suffix =
|
|
67
|
+
function buildUrlFromBase(apiBaseUrl, endpoint) {
|
|
68
|
+
var suffix = "/v3/".concat(endpoint);
|
|
68
69
|
|
|
69
70
|
if (apiBaseUrl.endsWith('/')) {
|
|
70
71
|
suffix = suffix.substring(1);
|
|
@@ -72,4 +73,12 @@ function buildMapsUrlFromBase(apiBaseUrl) {
|
|
|
72
73
|
|
|
73
74
|
return "".concat(apiBaseUrl).concat(suffix);
|
|
74
75
|
}
|
|
76
|
+
|
|
77
|
+
function buildMapsUrlFromBase(apiBaseUrl) {
|
|
78
|
+
return buildUrlFromBase(apiBaseUrl, 'maps');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function buildStatsUrlFromBase(apiBaseUrl) {
|
|
82
|
+
return buildUrlFromBase(apiBaseUrl, 'stats');
|
|
83
|
+
}
|
|
75
84
|
//# sourceMappingURL=config.js.map
|
package/dist/es5/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config.ts"],"names":["defaultClassicCredentials","apiKey","region","username","defaultCloudNativeCredentials","apiBaseUrl","credentials","setDefaultCredentials","apiVersion","rest","API_VERSIONS","V3","V1","V2","Error","getDefaultCredentials","
|
|
1
|
+
{"version":3,"sources":["../../src/config.ts"],"names":["defaultClassicCredentials","apiKey","region","username","defaultCloudNativeCredentials","apiBaseUrl","credentials","setDefaultCredentials","apiVersion","rest","API_VERSIONS","V3","V1","V2","Error","getDefaultCredentials","buildUrlFromBase","endpoint","suffix","endsWith","substring","buildMapsUrlFromBase","buildStatsUrlFromBase"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;AAEO,IAAMA,yBAAyB,GAAG;AACvCC,EAAAA,MAAM,EAAE,gBAD+B;AAEvCC,EAAAA,MAAM,EAAE,IAF+B;AAGvCC,EAAAA,QAAQ,EAAE;AAH6B,CAAlC;;AAMA,IAAMC,6BAA6B,GAAG;AAC3CC,EAAAA,UAAU,EAAE;AAD+B,CAAtC;;AAoBP,IAAIC,WAAwB,GAAG,EAA/B;AAEAC,qBAAqB,CAAC,EAAD,CAArB;;AAEO,SAASA,qBAAT,OAA4E;AAAA,MAA5CC,UAA4C,QAA5CA,UAA4C;AAAA,MAA7BC,IAA6B;AACjFD,EAAAA,UAAU,GAAGA,UAAU,IAAIE,4BAAaC,EAAxC;;AAEA,UAAQH,UAAR;AACE,SAAKE,4BAAaE,EAAlB;AACA,SAAKF,4BAAaG,EAAlB;AACEP,MAAAA,WAAW;AAAIE,QAAAA,UAAU,EAAVA;AAAJ,SAAmBR,yBAAnB,GAAiDS,IAAjD,CAAX;AACA;;AACF,SAAKC,4BAAaC,EAAlB;AACEL,MAAAA,WAAW;AAAIE,QAAAA,UAAU,EAAVA;AAAJ,SAAmBJ,6BAAnB,GAAqDK,IAArD,CAAX;AACA;;AACF;AACE,YAAM,IAAIK,KAAJ,+BAAiCN,UAAjC,8BAAN;AATJ;AAWD;;AAEM,SAASO,qBAAT,GAA8C;AACnD,SAAOT,WAAP;AACD;;AAID,SAASU,gBAAT,CAA0BX,UAA1B,EAA8CY,QAA9C,EAAoE;AAClE,MAAIC,MAAM,iBAAUD,QAAV,CAAV;;AACA,MAAIZ,UAAU,CAACc,QAAX,CAAoB,GAApB,CAAJ,EAA8B;AAC5BD,IAAAA,MAAM,GAAGA,MAAM,CAACE,SAAP,CAAiB,CAAjB,CAAT;AACD;;AAED,mBAAUf,UAAV,SAAuBa,MAAvB;AACD;;AAEM,SAASG,oBAAT,CAA8BhB,UAA9B,EAA0D;AAC/D,SAAOW,gBAAgB,CAACX,UAAD,EAAa,MAAb,CAAvB;AACD;;AAEM,SAASiB,qBAAT,CAA+BjB,UAA/B,EAA2D;AAChE,SAAOW,gBAAgB,CAACX,UAAD,EAAa,OAAb,CAAvB;AACD","sourcesContent":["import {API_VERSIONS} from './api/maps-api-common';\n\nexport const defaultClassicCredentials = {\n apiKey: 'default_public',\n region: 'us',\n username: 'public'\n} as const;\n\nexport const defaultCloudNativeCredentials = {\n apiBaseUrl: 'https://gcp-us-east1.api.carto.com'\n} as const;\n\nexport interface ClassicCredentials {\n apiVersion: 'v1' | 'v2';\n apiKey: string;\n region: string;\n username: string;\n mapsUrl?: string;\n}\n\nexport interface CloudNativeCredentials {\n apiVersion: 'v3';\n apiBaseUrl: string;\n accessToken?: string;\n mapsUrl?: string;\n}\n\nexport type Credentials = ClassicCredentials | CloudNativeCredentials;\nlet credentials: Credentials = {} as Credentials;\n\nsetDefaultCredentials({});\n\nexport function setDefaultCredentials({apiVersion, ...rest}: Partial<Credentials>) {\n apiVersion = apiVersion || API_VERSIONS.V3;\n\n switch (apiVersion) {\n case API_VERSIONS.V1:\n case API_VERSIONS.V2:\n credentials = {apiVersion, ...defaultClassicCredentials, ...rest};\n break;\n case API_VERSIONS.V3:\n credentials = {apiVersion, ...defaultCloudNativeCredentials, ...rest};\n break;\n default:\n throw new Error(`Invalid API version ${apiVersion}. Use API_VERSIONS enum.`);\n }\n}\n\nexport function getDefaultCredentials(): Credentials {\n return credentials;\n}\n\nexport type V3Endpoint = 'maps' | 'stats';\n\nfunction buildUrlFromBase(apiBaseUrl: string, endpoint: V3Endpoint) {\n let suffix = `/v3/${endpoint}`;\n if (apiBaseUrl.endsWith('/')) {\n suffix = suffix.substring(1);\n }\n\n return `${apiBaseUrl}${suffix}`;\n}\n\nexport function buildMapsUrlFromBase(apiBaseUrl: string): string {\n return buildUrlFromBase(apiBaseUrl, 'maps');\n}\n\nexport function buildStatsUrlFromBase(apiBaseUrl: string): string {\n return buildUrlFromBase(apiBaseUrl, 'stats');\n}\n"],"file":"config.js"}
|
package/dist/es5/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["export {getDefaultCredentials, setDefaultCredentials} from './config';\nexport {default as CartoLayer} from './layers/carto-layer';\nexport {default as _CartoTileLayer} from './layers/carto-tile-layer';\nexport {default as _H3TileLayer} from './layers/h3-tile-layer';\nexport {default as _QuadbinTileLayer} from './layers/quadbin-tile-layer';\nexport {\n tileToQuadbin as _tileToQuadbin,\n quadbinToTile as _quadbinToTile,\n quadbinZoom as _quadbinZoom\n} from './layers/quadbin-utils';\nexport {default as BASEMAP} from './basemap';\nexport {default as colorBins} from './style/color-bins-style';\nexport {default as colorCategories} from './style/color-categories-style';\nexport {default as colorContinuous} from './style/color-continuous-style';\nexport {\n FORMATS,\n TILE_FORMATS,\n MAP_TYPES,\n API_VERSIONS,\n fetchLayerData,\n fetchMap,\n getDataV2 as _getDataV2,\n mapInstantiation as _mapInstantiation\n} from './api';\
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["export {getDefaultCredentials, setDefaultCredentials} from './config';\nexport {default as CartoLayer} from './layers/carto-layer';\nexport {default as _CartoTileLayer} from './layers/carto-tile-layer';\nexport {default as _H3TileLayer} from './layers/h3-tile-layer';\nexport {default as _QuadbinTileLayer} from './layers/quadbin-tile-layer';\nexport {\n tileToQuadbin as _tileToQuadbin,\n quadbinToTile as _quadbinToTile,\n quadbinZoom as _quadbinZoom\n} from './layers/quadbin-utils';\nexport {default as BASEMAP} from './basemap';\nexport {default as colorBins} from './style/color-bins-style';\nexport {default as colorCategories} from './style/color-categories-style';\nexport {default as colorContinuous} from './style/color-continuous-style';\nexport {\n FORMATS,\n TILE_FORMATS,\n MAP_TYPES,\n API_VERSIONS,\n fetchLayerData,\n fetchMap,\n getDataV2 as _getDataV2,\n mapInstantiation as _mapInstantiation\n} from './api';\nexport type {QueryParameters} from './api';\nexport type {CartoLayerProps} from './layers/carto-layer';\n"],"file":"index.js"}
|
|
@@ -31,23 +31,19 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
31
31
|
|
|
32
32
|
var _core = require("@deck.gl/core");
|
|
33
33
|
|
|
34
|
-
var _cartoTileLayer = _interopRequireDefault(require("./carto-tile-layer"));
|
|
35
|
-
|
|
36
|
-
var _h3TileLayer = _interopRequireDefault(require("./h3-tile-layer"));
|
|
37
|
-
|
|
38
|
-
var _quadbinTileLayer = _interopRequireDefault(require("./quadbin-tile-layer"));
|
|
39
|
-
|
|
40
34
|
var _geoLayers = require("@deck.gl/geo-layers");
|
|
41
35
|
|
|
42
36
|
var _api = require("../api");
|
|
43
37
|
|
|
38
|
+
var _layerMap = require("../api/layer-map");
|
|
39
|
+
|
|
44
40
|
var _mapsApiCommon = require("../api/maps-api-common");
|
|
45
41
|
|
|
46
42
|
var _config = require("../config");
|
|
47
43
|
|
|
48
44
|
var _utils = require("../utils");
|
|
49
45
|
|
|
50
|
-
var _excluded = ["type", "data", "
|
|
46
|
+
var _excluded = ["type", "data", "credentials", "connection"],
|
|
51
47
|
_excluded2 = ["data"];
|
|
52
48
|
|
|
53
49
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -84,7 +80,8 @@ var defaultProps = {
|
|
|
84
80
|
value: null
|
|
85
81
|
},
|
|
86
82
|
aggregationExp: null,
|
|
87
|
-
aggregationResLevel: null
|
|
83
|
+
aggregationResLevel: null,
|
|
84
|
+
queryParameters: null
|
|
88
85
|
};
|
|
89
86
|
|
|
90
87
|
var CartoLayer = function (_CompositeLayer) {
|
|
@@ -160,7 +157,7 @@ var CartoLayer = function (_CompositeLayer) {
|
|
|
160
157
|
|
|
161
158
|
this._checkProps(props);
|
|
162
159
|
|
|
163
|
-
var shouldUpdateData = changeFlags.dataChanged || props.aggregationExp !== oldProps.aggregationExp || props.aggregationResLevel !== oldProps.aggregationResLevel || props.connection !== oldProps.connection || props.geoColumn !== oldProps.geoColumn || props.formatTiles !== oldProps.formatTiles || props.type !== oldProps.type || JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) || JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials);
|
|
160
|
+
var shouldUpdateData = changeFlags.dataChanged || props.aggregationExp !== oldProps.aggregationExp || props.aggregationResLevel !== oldProps.aggregationResLevel || props.connection !== oldProps.connection || props.geoColumn !== oldProps.geoColumn || props.formatTiles !== oldProps.formatTiles || props.type !== oldProps.type || JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) || JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials) || JSON.stringify(props.queryParameters) !== JSON.stringify(oldProps.queryParameters);
|
|
164
161
|
|
|
165
162
|
if (shouldUpdateData) {
|
|
166
163
|
this.setState({
|
|
@@ -175,14 +172,14 @@ var CartoLayer = function (_CompositeLayer) {
|
|
|
175
172
|
key: "_updateData",
|
|
176
173
|
value: function () {
|
|
177
174
|
var _updateData2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
|
|
178
|
-
var _this$props$onDataLoa, _this$props2, _this$props, type, source,
|
|
175
|
+
var _this$props$onDataLoa, _this$props2, _this$props, type, source, credentials, connection, rest, localConfig, apiVersion, result;
|
|
179
176
|
|
|
180
177
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
181
178
|
while (1) {
|
|
182
179
|
switch (_context.prev = _context.next) {
|
|
183
180
|
case 0:
|
|
184
181
|
_context.prev = 0;
|
|
185
|
-
_this$props = this.props, type = _this$props.type, source = _this$props.data,
|
|
182
|
+
_this$props = this.props, type = _this$props.type, source = _this$props.data, credentials = _this$props.credentials, connection = _this$props.connection, rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
|
|
186
183
|
localConfig = _objectSpread(_objectSpread({}, (0, _config.getDefaultCredentials)()), credentials);
|
|
187
184
|
apiVersion = localConfig.apiVersion;
|
|
188
185
|
|
|
@@ -211,7 +208,6 @@ var CartoLayer = function (_CompositeLayer) {
|
|
|
211
208
|
return (0, _api.fetchLayerData)(_objectSpread(_objectSpread({
|
|
212
209
|
type: type,
|
|
213
210
|
source: source,
|
|
214
|
-
clientId: clientId,
|
|
215
211
|
credentials: credentials,
|
|
216
212
|
connection: connection
|
|
217
213
|
}, rest), {}, {
|
|
@@ -283,17 +279,8 @@ var CartoLayer = function (_CompositeLayer) {
|
|
|
283
279
|
}
|
|
284
280
|
|
|
285
281
|
var tileUrl = new URL(data.tiles[0]);
|
|
286
|
-
props.formatTiles = props.formatTiles || tileUrl.searchParams.get('formatTiles')
|
|
287
|
-
|
|
288
|
-
if (data.scheme === 'h3') {
|
|
289
|
-
return [_h3TileLayer.default, props];
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
if (data.scheme === 'quadbin') {
|
|
293
|
-
return [_quadbinTileLayer.default, props];
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
return props.formatTiles === _mapsApiCommon.TILE_FORMATS.MVT ? [_geoLayers.MVTLayer, props] : [_cartoTileLayer.default, props];
|
|
282
|
+
props.formatTiles = props.formatTiles || tileUrl.searchParams.get('formatTiles');
|
|
283
|
+
return [(0, _layerMap.layerFromTileDataset)(props.formatTiles, data.scheme), props];
|
|
297
284
|
}
|
|
298
285
|
}, {
|
|
299
286
|
key: "renderLayers",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layers/carto-layer.ts"],"names":["defaultProps","data","type","onDataLoad","value","compare","onDataError","optional","uniqueIdProperty","credentials","connection","format","formatTiles","clientId","geoColumn","columns","aggregationExp","aggregationResLevel","CartoLayer","state","apiVersion","getSubLayers","length","props","localCreds","log","assert","Object","values","API_VERSIONS","includes","V1","V2","MAP_TYPES","QUERY","TILESET","V3","COLUMNS_SUPPORT","join","GEO_COLUMN_SUPPORT","Array","isArray","oldProps","changeFlags","_checkProps","shouldUpdateData","dataChanged","JSON","stringify","setState","_updateData","source","rest","localConfig","result","FORMATS","TILEJSON","propName","layer","_notUsed","propsNoData","MVTLayer","tileUrl","URL","tiles","searchParams","get","TILE_FORMATS","MVT","scheme","H3TileLayer","QuadbinTileLayer","CartoTileLayer","updateTriggers","_getSubLayerAndProps","getSubLayerProps","id","layerName","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AASA;;AAOA;;;;;;;;;;;;;AA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AAP,GAAe,KAAKkB,KAApB,CAAOlB,IAAP;AAEA,UAAI,CAACA,IAAL,EAAW,OAAO,IAAP;AAEX,UAAOwE,cAAP,GAAyB,KAAKlD,KAA9B,CAAOkD,cAAP;;AAEA,kCAAuB,KAAKC,oBAAL,EAAvB;AAAA;AAAA,UAAOhB,KAAP;AAAA,UAAcnC,KAAd;;AAGA,aAAO,IAAImC,KAAJ,CACLnC,KADK,EAEL,KAAKoD,gBAAL,CAAsB;AACpBC,QAAAA,EAAE,kBAAWlB,KAAK,CAACmB,SAAjB,CADkB;AAEpB5E,QAAAA,IAAI,EAAJA,IAFoB;AAGpBwE,QAAAA,cAAc,EAAdA;AAHoB,OAAtB,CAFK,CAAP;AAQD;;;EAhLsDK,oB;;;8BAApC5D,U,eAGA,Y;8BAHAA,U,kBAIGlB,Y","sourcesContent":["import {\n CompositeLayer,\n Layer,\n log,\n CompositeLayerProps,\n LayerProps,\n ChangeFlags\n} from '@deck.gl/core';\nimport CartoTileLayer from './carto-tile-layer';\nimport H3TileLayer from './h3-tile-layer';\nimport QuadbinTileLayer from './quadbin-tile-layer';\nimport {MVTLayer} from '@deck.gl/geo-layers';\nimport {fetchLayerData, getDataV2, API_VERSIONS} from '../api';\nimport {\n COLUMNS_SUPPORT,\n FORMATS,\n GEO_COLUMN_SUPPORT,\n MapType,\n MAP_TYPES,\n TileFormat,\n TILE_FORMATS\n} from '../api/maps-api-common';\nimport {\n ClassicCredentials,\n CloudNativeCredentials,\n Credentials,\n getDefaultCredentials\n} from '../config';\nimport {FetchLayerDataResult} from '../api/maps-v3-client';\nimport {assert} from '../utils';\n\nconst defaultProps = {\n // (String, required): data resource to load. table name, sql query or tileset name.\n data: null,\n // (Enum (MAP_TYPES), required)\n type: null,\n onDataLoad: {type: 'function', value: data => {}, compare: false},\n onDataError: {type: 'function', value: null, compare: false, optional: true},\n uniqueIdProperty: 'cartodb_id',\n\n // override carto credentials for the layer, set to null to read from default\n credentials: null,\n\n /*********************/\n /* API v3 PARAMETERS */\n /**********************/\n // (String, required): connection name at CARTO platform\n connection: null,\n\n // (String, optional): format of data\n format: null,\n\n // (String, optional): force format of data for tiles\n formatTiles: null,\n\n // (String, optional): clientId identifier used for internal tracing, place here a string to identify the client who is doing the request.\n clientId: null,\n\n // (String, optional): name of the `geo_column` in the CARTO platform. Use this override the default column ('geom'), from which the geometry information should be fetched.\n geoColumn: null,\n\n // (Array<String>, optional): names of columns to fetch. By default, all columns are fetched.\n columns: {type: 'array', value: null},\n\n // (String, optional): aggregation SQL expression. Only used for spatial index datasets\n aggregationExp: null,\n\n // (Number, optional): aggregation resolution level. Only used for spatial index datasets, defaults to 6 for quadbins, 4 for h3\n aggregationResLevel: null\n};\n\n/** All properties supported by CartoLayer. */\nexport type CartoLayerProps<DataT = any> = _CartoLayerProps & CompositeLayerProps<DataT>;\n\n/** Properties added by CartoLayer. */\ntype _CartoLayerProps = {\n /**\n * Either a SQL query or a name of dataset/tileset.\n */\n data: string;\n\n /**\n * Data type.\n *\n * Possible values are:\n * * `MAP_TYPES.QUERY`, if data is a SQL query.\n * * `MAP_TYPES.TILESET`, if data is a tileset name.\n * * `MAP_TYPES.TABLE`, if data is a dataset name. Only supported with API v3.\n */\n type: MapType;\n\n /**\n * Name of the connection registered in the CARTO workspace.\n *\n * Required when apiVersion is `API_VERSIONS.V3`.\n */\n connection?: string;\n\n /**\n * Use to override the default tile data format.\n *\n * Only supported when apiVersion is `API_VERSIONS.V3`.\n *\n * Possible values are: `TILE_FORMATS.BINARY`, `TILE_FORMATS.GEOJSON` and `TILE_FORMATS.MVT`.\n */\n formatTiles?: TileFormat;\n\n /**\n * Name of the geo_column in the CARTO platform.\n *\n * Use this override the default column (`'geom'`), from which the geometry information should be fetched.\n *\n * Only supported when apiVersion is `API_VERSIONS.V3` and type is `MAP_TYPES.TABLE`.\n */\n geoColumn?: string;\n\n /**\n * Names of columns to fetch.\n *\n * By default, all columns are fetched\n *\n * Only supported when apiVersion is `API_VERSIONS.V3` and type is `MAP_TYPES.TABLE`.\n */\n columns?: string[];\n\n /**\n * A string pointing to a unique attribute at the result of the query.\n *\n * A unique attribute is needed for highlighting with vector tiles when a feature is split across two or more tiles.\n */\n uniqueIdProperty?: string;\n\n /**\n * Optional. Overrides the configuration to connect with CARTO.\n *\n * @see Credentials\n */\n credentials?: Credentials;\n\n /**\n * Called when the request to the CARTO Maps API failed.\n *\n * By default the Error is thrown.\n */\n onDataError?: (err: unknown) => void;\n\n clientId?: string;\n\n /** Aggregation SQL expression. Only used for spatial index datasets **/\n aggregationExp?: string;\n\n /** Aggregation resolution level. Only used for spatial index datasets, defaults to 6 for quadbins, 4 for h3. **/\n aggregationResLevel?: number;\n};\n\nexport default class CartoLayer<ExtraProps = {}> extends CompositeLayer<\n Required<_CartoLayerProps> & ExtraProps\n> {\n static layerName = 'CartoLayer';\n static defaultProps = defaultProps as any;\n\n initializeState(): void {\n this.state = {\n data: null,\n apiVersion: null\n };\n }\n\n get isLoaded(): boolean {\n return this.getSubLayers().length > 0 && super.isLoaded;\n }\n\n _checkProps(props: CartoLayerProps): void {\n const {type, credentials, connection, geoColumn, columns} = props;\n const localCreds = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localCreds;\n\n log.assert(\n Object.values(API_VERSIONS).includes(apiVersion),\n `Invalid apiVersion ${apiVersion}. Use API_VERSIONS enum.`\n );\n\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n log.assert(\n type === MAP_TYPES.QUERY || type === MAP_TYPES.TILESET,\n `Invalid type ${type}. Use type MAP_TYPES.QUERY or MAP_TYPES.TILESET for apiVersion ${apiVersion}`\n );\n log.assert(!connection, `Connection prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!geoColumn, `geoColumn prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!columns, `columns prop is not supported for apiVersion ${apiVersion}`);\n } else if (apiVersion === API_VERSIONS.V3) {\n log.assert(connection, 'Missing mandatory connection parameter');\n log.assert(\n Object.values(MAP_TYPES).includes(type),\n `Invalid type ${type}. Use MAP_TYPES enum.`\n );\n if (!COLUMNS_SUPPORT.includes(type)) {\n log.assert(!columns, `columns prop is only supported for types: ${COLUMNS_SUPPORT.join()}`);\n }\n if (!GEO_COLUMN_SUPPORT.includes(type)) {\n log.assert(\n !geoColumn,\n `geoColumn prop is only supported for types: ${GEO_COLUMN_SUPPORT.join()}`\n );\n }\n if (columns) {\n log.assert(Array.isArray(columns), 'columns prop must be an Array');\n }\n }\n }\n\n updateState({\n props,\n oldProps,\n changeFlags\n }: {\n props: CartoLayerProps;\n oldProps: CartoLayerProps;\n context: any;\n changeFlags: ChangeFlags;\n }): void {\n this._checkProps(props);\n const shouldUpdateData =\n changeFlags.dataChanged ||\n props.aggregationExp !== oldProps.aggregationExp ||\n props.aggregationResLevel !== oldProps.aggregationResLevel ||\n props.connection !== oldProps.connection ||\n props.geoColumn !== oldProps.geoColumn ||\n props.formatTiles !== oldProps.formatTiles ||\n props.type !== oldProps.type ||\n JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) ||\n JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials);\n\n if (shouldUpdateData) {\n this.setState({data: null, apiVersion: null});\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._updateData();\n }\n }\n\n async _updateData(): Promise<void> {\n try {\n const {type, data: source, clientId, credentials, connection, ...rest} = this.props;\n const localConfig = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localConfig;\n\n let result: Partial<FetchLayerDataResult>;\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n result = {\n data: await getDataV2({type, source, credentials: credentials as ClassicCredentials})\n };\n } else {\n result = await fetchLayerData({\n type,\n source,\n clientId,\n credentials: credentials as CloudNativeCredentials,\n connection,\n ...rest,\n // CartoLayer only supports tiled output from v8.8, force data format\n format: FORMATS.TILEJSON\n });\n }\n\n this.setState({...result, apiVersion});\n\n this.props.onDataLoad?.(result.data, {\n propName: 'data',\n layer: this\n });\n } catch (err) {\n if (this.props.onDataError) {\n this.props.onDataError(err as Error);\n } else {\n throw err;\n }\n }\n }\n\n _getSubLayerAndProps(): [any, LayerProps] {\n assert(this.state);\n\n const {data, apiVersion} = this.state;\n\n const {uniqueIdProperty} = defaultProps;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {data: _notUsed, ...propsNoData} = this.props;\n // @ts-expect-error 'uniqueIdProperty' is specified more than once, so this usage will be overwritten.\n const props = {uniqueIdProperty, ...propsNoData};\n\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n return [MVTLayer, props];\n }\n\n /* global URL */\n const tileUrl = new URL(data.tiles[0]);\n\n props.formatTiles =\n props.formatTiles ||\n (tileUrl.searchParams.get('formatTiles') as TileFormat) ||\n TILE_FORMATS.MVT;\n\n if (data.scheme === 'h3') {\n return [H3TileLayer, props];\n }\n if (data.scheme === 'quadbin') {\n return [QuadbinTileLayer, props];\n }\n return props.formatTiles === TILE_FORMATS.MVT ? [MVTLayer, props] : [CartoTileLayer, props];\n }\n\n renderLayers(): Layer | null {\n assert(this.state);\n\n const {data} = this.state;\n\n if (!data) return null;\n\n const {updateTriggers} = this.props;\n\n const [layer, props] = this._getSubLayerAndProps();\n\n // eslint-disable-next-line new-cap\n return new layer(\n props,\n this.getSubLayerProps({\n id: `carto-${layer.layerName}`,\n data,\n updateTriggers\n })\n );\n }\n}\n"],"file":"carto-layer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/layers/carto-layer.ts"],"names":["defaultProps","data","type","onDataLoad","value","compare","onDataError","optional","uniqueIdProperty","credentials","connection","format","formatTiles","clientId","geoColumn","columns","aggregationExp","aggregationResLevel","queryParameters","CartoLayer","state","apiVersion","getSubLayers","length","props","localCreds","log","assert","Object","values","API_VERSIONS","includes","V1","V2","MAP_TYPES","QUERY","TILESET","V3","COLUMNS_SUPPORT","join","GEO_COLUMN_SUPPORT","Array","isArray","oldProps","changeFlags","_checkProps","shouldUpdateData","dataChanged","JSON","stringify","setState","_updateData","source","rest","localConfig","result","FORMATS","TILEJSON","propName","layer","_notUsed","propsNoData","MVTLayer","tileUrl","URL","tiles","searchParams","get","scheme","updateTriggers","_getSubLayerAndProps","getSubLayerProps","id","layerName","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AASA;;AACA;;AACA;;AACA;;AASA;;AAOA;;;;;;;;;;;;;AAEA,IAAMA,YAAY,GAAG;AAEnBC,EAAAA,IAAI,EAAE,IAFa;AAInBC,EAAAA,IAAI,EAAE,IAJa;AAKnBC,EAAAA,UAAU,EAAE;AAACD,IAAAA,IAAI,EAAE,UAAP;AAAmBE,IAAAA,KAAK,EAAE,eAAAH,IAAI,EAAI,CAAE,CAApC;AAAsCI,IAAAA,OAAO,EAAE;AAA/C,GALO;AAMnBC,EAAAA,WAAW,EAAE;AAACJ,IAAAA,IAAI,EAAE,UAAP;AAAmBE,IAAAA,KAAK,EAAE,IAA1B;AAAgCC,IAAAA,OAAO,EAAE,KAAzC;AAAgDE,IAAAA,QAAQ,EAAE;AAA1D,GANM;AAOnBC,EAAAA,gBAAgB,EAAE,YAPC;AAUnBC,EAAAA,WAAW,EAAE,IAVM;AAgBnBC,EAAAA,UAAU,EAAE,IAhBO;AAmBnBC,EAAAA,MAAM,EAAE,IAnBW;AAsBnBC,EAAAA,WAAW,EAAE,IAtBM;AAyBnBC,EAAAA,QAAQ,EAAE,IAzBS;AA4BnBC,EAAAA,SAAS,EAAE,IA5BQ;AA+BnBC,EAAAA,OAAO,EAAE;AAACb,IAAAA,IAAI,EAAE,OAAP;AAAgBE,IAAAA,KAAK,EAAE;AAAvB,GA/BU;AAkCnBY,EAAAA,cAAc,EAAE,IAlCG;AAqCnBC,EAAAA,mBAAmB,EAAE,IArCF;AAwCnBC,EAAAA,eAAe,EAAE;AAxCE,CAArB;;IAkIqBC,U;;;;;;;;;;;;WAMnB,2BAAwB;AACtB,WAAKC,KAAL,GAAa;AACXnB,Q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CX,IAAI,CAACmE,MAA7C,CAAD,EAAuD5C,KAAvD,CAAP;AACD;;;WAED,wBAA6B;AAC3B,yBAAO,KAAKJ,KAAZ;AAEA,UAAOnB,IAAP,GAAe,KAAKmB,KAApB,CAAOnB,IAAP;AAEA,UAAI,CAACA,IAAL,EAAW,OAAO,IAAP;AAEX,UAAOoE,cAAP,GAAyB,KAAK7C,KAA9B,CAAO6C,cAAP;;AAEA,kCAAuB,KAAKC,oBAAL,EAAvB;AAAA;AAAA,UAAOX,KAAP;AAAA,UAAcnC,KAAd;;AAGA,aAAO,IAAImC,KAAJ,CACLnC,KADK,EAEL,KAAK+C,gBAAL,CAAsB;AACpBC,QAAAA,EAAE,kBAAWb,KAAK,CAACc,SAAjB,CADkB;AAEpBxE,QAAAA,IAAI,EAAJA,IAFoB;AAGpBoE,QAAAA,cAAc,EAAdA;AAHoB,OAAtB,CAFK,CAAP;AAQD;;;EA9JsDK,oB;;;8BAApCvD,U,eAGA,Y;8BAHAA,U,kBAIGnB,Y","sourcesContent":["import {\n CompositeLayer,\n CompositeLayerProps,\n Layer,\n LayerProps,\n log,\n UpdateParameters\n} from '@deck.gl/core';\n\nimport {MVTLayer} from '@deck.gl/geo-layers';\nimport {fetchLayerData, getDataV2, API_VERSIONS} from '../api';\nimport {layerFromTileDataset} from '../api/layer-map';\nimport {\n COLUMNS_SUPPORT,\n FORMATS,\n GEO_COLUMN_SUPPORT,\n MapType,\n MAP_TYPES,\n TileFormat,\n QueryParameters\n} from '../api/maps-api-common';\nimport {\n ClassicCredentials,\n CloudNativeCredentials,\n Credentials,\n getDefaultCredentials\n} from '../config';\nimport {FetchLayerDataResult} from '../api/maps-v3-client';\nimport {assert} from '../utils';\n\nconst defaultProps = {\n // (String, required): data resource to load. table name, sql query or tileset name.\n data: null,\n // (Enum (MAP_TYPES), required)\n type: null,\n onDataLoad: {type: 'function', value: data => {}, compare: false},\n onDataError: {type: 'function', value: null, compare: false, optional: true},\n uniqueIdProperty: 'cartodb_id',\n\n // override carto credentials for the layer, set to null to read from default\n credentials: null,\n\n /*********************/\n /* API v3 PARAMETERS */\n /**********************/\n // (String, required): connection name at CARTO platform\n connection: null,\n\n // (String, optional): format of data\n format: null,\n\n // (String, optional): force format of data for tiles\n formatTiles: null,\n\n // (String, optional): clientId identifier used for internal tracing, place here a string to identify the client who is doing the request.\n clientId: null,\n\n // (String, optional): name of the `geo_column` in the CARTO platform. Use this override the default column ('geom'), from which the geometry information should be fetched.\n geoColumn: null,\n\n // (Array<String>, optional): names of columns to fetch. By default, all columns are fetched.\n columns: {type: 'array', value: null},\n\n // (String, optional): aggregation SQL expression. Only used for spatial index datasets\n aggregationExp: null,\n\n // (Number, optional): aggregation resolution level. Only used for spatial index datasets, defaults to 6 for quadbins, 4 for h3\n aggregationResLevel: null,\n\n // (QueryParameters, optional): query parameters to be sent to the server.\n queryParameters: null\n};\n\n/** All properties supported by CartoLayer. */\nexport type CartoLayerProps<DataT = any> = _CartoLayerProps & CompositeLayerProps<DataT>;\n\n/** Properties added by CartoLayer. */\ntype _CartoLayerProps = {\n /**\n * Either a SQL query or a name of dataset/tileset.\n */\n data: string;\n\n /**\n * Data type.\n *\n * Possible values are:\n * * `MAP_TYPES.QUERY`, if data is a SQL query.\n * * `MAP_TYPES.TILESET`, if data is a tileset name.\n * * `MAP_TYPES.TABLE`, if data is a dataset name. Only supported with API v3.\n */\n type: MapType;\n\n /**\n * Name of the connection registered in the CARTO workspace.\n *\n * Required when apiVersion is `API_VERSIONS.V3`.\n */\n connection?: string;\n\n /**\n * Use to override the default tile data format.\n *\n * Only supported when apiVersion is `API_VERSIONS.V3`.\n *\n * Possible values are: `TILE_FORMATS.BINARY`, `TILE_FORMATS.GEOJSON` and `TILE_FORMATS.MVT`.\n */\n formatTiles?: TileFormat;\n\n /**\n * Name of the geo_column in the CARTO platform.\n *\n * Use this override the default column (`'geom'`), from which the geometry information should be fetched.\n *\n * Only supported when apiVersion is `API_VERSIONS.V3` and type is `MAP_TYPES.TABLE`.\n */\n geoColumn?: string;\n\n /**\n * Names of columns to fetch.\n *\n * By default, all columns are fetched\n *\n * Only supported when apiVersion is `API_VERSIONS.V3` and type is `MAP_TYPES.TABLE`.\n */\n columns?: string[];\n\n /**\n * A string pointing to a unique attribute at the result of the query.\n *\n * A unique attribute is needed for highlighting with vector tiles when a feature is split across two or more tiles.\n */\n uniqueIdProperty?: string;\n\n /**\n * Optional. Overrides the configuration to connect with CARTO.\n *\n * @see Credentials\n */\n credentials?: Credentials;\n\n /**\n * Called when the request to the CARTO Maps API failed.\n *\n * By default the Error is thrown.\n */\n onDataError?: (err: unknown) => void;\n\n clientId?: string;\n\n /** Aggregation SQL expression. Only used for spatial index datasets **/\n aggregationExp?: string;\n\n /** Aggregation resolution level. Only used for spatial index datasets, defaults to 6 for quadbins, 4 for h3. **/\n aggregationResLevel?: number;\n\n /** Query parameters to be sent to the server. **/\n queryParameters?: QueryParameters;\n};\n\nexport default class CartoLayer<ExtraProps = {}> extends CompositeLayer<\n Required<_CartoLayerProps> & ExtraProps\n> {\n static layerName = 'CartoLayer';\n static defaultProps = defaultProps as any;\n\n initializeState(): void {\n this.state = {\n data: null,\n apiVersion: null\n };\n }\n\n get isLoaded(): boolean {\n return this.getSubLayers().length > 0 && super.isLoaded;\n }\n\n _checkProps(props: CartoLayerProps): void {\n const {type, credentials, connection, geoColumn, columns} = props;\n const localCreds = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localCreds;\n\n log.assert(\n Object.values(API_VERSIONS).includes(apiVersion),\n `Invalid apiVersion ${apiVersion}. Use API_VERSIONS enum.`\n );\n\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n log.assert(\n type === MAP_TYPES.QUERY || type === MAP_TYPES.TILESET,\n `Invalid type ${type}. Use type MAP_TYPES.QUERY or MAP_TYPES.TILESET for apiVersion ${apiVersion}`\n );\n log.assert(!connection, `Connection prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!geoColumn, `geoColumn prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!columns, `columns prop is not supported for apiVersion ${apiVersion}`);\n } else if (apiVersion === API_VERSIONS.V3) {\n log.assert(connection, 'Missing mandatory connection parameter');\n log.assert(\n Object.values(MAP_TYPES).includes(type),\n `Invalid type ${type}. Use MAP_TYPES enum.`\n );\n if (!COLUMNS_SUPPORT.includes(type)) {\n log.assert(!columns, `columns prop is only supported for types: ${COLUMNS_SUPPORT.join()}`);\n }\n if (!GEO_COLUMN_SUPPORT.includes(type)) {\n log.assert(\n !geoColumn,\n `geoColumn prop is only supported for types: ${GEO_COLUMN_SUPPORT.join()}`\n );\n }\n if (columns) {\n log.assert(Array.isArray(columns), 'columns prop must be an Array');\n }\n }\n }\n\n updateState({props, oldProps, changeFlags}: UpdateParameters<this>) {\n this._checkProps(props);\n const shouldUpdateData =\n changeFlags.dataChanged ||\n props.aggregationExp !== oldProps.aggregationExp ||\n props.aggregationResLevel !== oldProps.aggregationResLevel ||\n props.connection !== oldProps.connection ||\n props.geoColumn !== oldProps.geoColumn ||\n props.formatTiles !== oldProps.formatTiles ||\n props.type !== oldProps.type ||\n JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) ||\n JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials) ||\n JSON.stringify(props.queryParameters) !== JSON.stringify(oldProps.queryParameters);\n\n if (shouldUpdateData) {\n this.setState({data: null, apiVersion: null});\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._updateData();\n }\n }\n\n async _updateData(): Promise<void> {\n try {\n const {type, data: source, credentials, connection, ...rest} = this.props;\n const localConfig = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localConfig;\n\n let result: Partial<FetchLayerDataResult>;\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n result = {\n data: await getDataV2({type, source, credentials: credentials as ClassicCredentials})\n };\n } else {\n result = await fetchLayerData({\n type,\n source,\n credentials: credentials as CloudNativeCredentials,\n connection,\n ...rest,\n // CartoLayer only supports tiled output from v8.8, force data format\n format: FORMATS.TILEJSON\n });\n }\n\n this.setState({...result, apiVersion});\n\n this.props.onDataLoad?.(result.data, {\n propName: 'data',\n layer: this\n });\n } catch (err) {\n if (this.props.onDataError) {\n this.props.onDataError(err as Error);\n } else {\n throw err;\n }\n }\n }\n\n _getSubLayerAndProps(): [any, LayerProps] {\n assert(this.state);\n\n const {data, apiVersion} = this.state;\n\n const {uniqueIdProperty} = defaultProps;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {data: _notUsed, ...propsNoData} = this.props;\n // @ts-expect-error 'uniqueIdProperty' is specified more than once, so this usage will be overwritten.\n const props = {uniqueIdProperty, ...propsNoData};\n\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n return [MVTLayer, props];\n }\n\n /* global URL */\n const tileUrl = new URL(data.tiles[0]);\n props.formatTiles =\n props.formatTiles || (tileUrl.searchParams.get('formatTiles') as TileFormat);\n\n return [layerFromTileDataset(props.formatTiles, data.scheme), props];\n }\n\n renderLayers(): Layer | null {\n assert(this.state);\n\n const {data} = this.state;\n\n if (!data) return null;\n\n const {updateTriggers} = this.props;\n\n const [layer, props] = this._getSubLayerAndProps();\n\n // eslint-disable-next-line new-cap\n return new layer(\n props,\n this.getSubLayerProps({\n id: `carto-${layer.layerName}`,\n data,\n updateTriggers\n })\n );\n }\n}\n"],"file":"carto-layer.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/style/color-bins-style.ts"],"names":["colorBins","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;;;AAAA;;
|
|
1
|
+
{"version":3,"sources":["../../../src/style/color-bins-style.ts"],"names":["colorBins","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;;;AAAA;;AAGA;;AACA;;;;;;AAUe,SAASA,SAAT,OAsBoB;AAAA,MArBjCC,IAqBiC,QArBjCA,IAqBiC;AAAA,MApBjCC,MAoBiC,QApBjCA,MAoBiC;AAAA,yBAnBjCC,MAmBiC;AAAA,MAnBjCA,MAmBiC,4BAnBxBC,wBAmBwB;AAAA,4BAlBjCC,SAkBiC;AAAA,MAlBjCA,SAkBiC,+BAlBrBC,mBAkBqB;AACjC,qBAAOC,KAAK,CAACC,OAAN,CAAcN,MAAd,CAAP,EAA8B,6CAA9B;AAEA,MAAMO,OAAO,GAAG,OAAON,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACQ,MAAP,GAAgB,CAAnC,CAA7B,GAAqEP,MAArF;AAEA,MAAMQ,KAAK,GAAG,+BAAgCT,MAAhC,CAAuCA,MAAvC,EAA+CU,KAA/C,CAAqDH,OAArD,CAAd;AAEA,SAAO,UAAAI,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAab,IAAb,EAAmBY,CAAnB,CAAd;AACA,WAAO,OAAOC,KAAP,KAAiB,QAAjB,IAA6BC,MAAM,CAACC,QAAP,CAAgBF,KAAhB,CAA7B,GAAsDH,KAAK,CAACG,KAAD,CAA3D,GAAqET,SAA5E;AACD,GAHD;AAID","sourcesContent":["import {scaleThreshold} from 'd3-scale';\nimport {AccessorFunction} from '@deck.gl/core';\nimport {Feature} from 'geojson';\nimport getPalette, {Color, DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, AttributeSelector, getAttrValue} from './utils';\n\n/**\n * Helper function for quickly creating a color bins style based on `d3` `scaleThreshold`.\n *\n * Data values of each attribute are rounded down to the nearest value in the domain and are then\n * styled with the corresponding color.\n *\n * @return accessor that maps objects to `Color` values\n */\nexport default function colorBins<DataT = Feature>({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}: {\n /** Attribute or column to symbolize by. */\n attr: AttributeSelector<DataT, number>;\n\n /** Category list. Must be a valid list of categories. */\n domain: number[];\n\n /**\n * Color assigned to each domain value.\n *\n * Either Array of colors in RGBA or valid named CARTOColors palette.\n * @default `PurpOr`\n */\n colors?: string | Color[];\n\n /** Color for null values. @default: [204, 204, 204] */\n nullColor?: Color;\n}): AccessorFunction<DataT, Color> {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length + 1) : colors;\n\n const color = scaleThreshold<number, Color>().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return typeof value === 'number' && Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-bins-style.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/style/color-categories-style.ts"],"names":["colorCategories","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","othersColor","OTHERS_COLOR","Array","isArray","colorsByCategory","palette","length","entries","i","c","d","value","Number","isFinite"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/style/color-categories-style.ts"],"names":["colorCategories","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","othersColor","OTHERS_COLOR","Array","isArray","colorsByCategory","palette","length","entries","i","c","d","value","Number","isFinite"],"mappings":";;;;;;;;;;;;;AAEA;;AACA;;;;;;;;;;;;AAUe,SAASA,eAAT,OA0BoB;AAAA,MAzBjCC,IAyBiC,QAzBjCA,IAyBiC;AAAA,MAxBjCC,MAwBiC,QAxBjCA,MAwBiC;AAAA,yBAvBjCC,MAuBiC;AAAA,MAvBjCA,MAuBiC,4BAvBxBC,wBAuBwB;AAAA,4BAtBjCC,SAsBiC;AAAA,MAtBjCA,SAsBiC,+BAtBrBC,mBAsBqB;AAAA,8BArBjCC,WAqBiC;AAAA,MArBjCA,WAqBiC,iCArBnBC,qBAqBmB;AACjC,qBAAOC,KAAK,CAACC,OAAN,CAAcR,MAAd,CAAP,EAA8B,wDAA9B;AAEA,MAAMS,gBAAgB,GAAG,EAAzB;AACA,MAAMC,OAAO,GAAG,OAAOT,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACW,MAA1B,CAA7B,GAAiEV,MAAjF;;AAJiC,6CAMZD,MAAM,CAACY,OAAP,EANY;AAAA;;AAAA;AAMjC,wDAAuC;AAAA;AAAA,UAA3BC,CAA2B;AAAA,UAAxBC,CAAwB;;AACrCL,MAAAA,gBAAgB,CAACK,CAAD,CAAhB,GAAsBJ,OAAO,CAACG,CAAD,CAA7B;AACD;AARgC;AAAA;AAAA;AAAA;AAAA;;AAUjC,SAAO,UAAAE,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAajB,IAAb,EAAmBgB,CAAnB,CAAd;AACA,WAAQ,OAAOC,KAAP,KAAiB,QAAjB,IAA6BC,MAAM,CAACC,QAAP,CAAgBF,KAAhB,CAA9B,IAAyD,OAAOA,KAAP,KAAiB,QAA1E,GACHP,gBAAgB,CAACO,KAAD,CAAhB,IAA2BX,WADxB,GAEHF,SAFJ;AAGD,GALD;AAMD","sourcesContent":["import {AccessorFunction} from '@deck.gl/core';\nimport {Feature} from 'geojson';\nimport getPalette, {Color, DEFAULT_PALETTE, NULL_COLOR, OTHERS_COLOR} from './palette';\nimport {assert, AttributeSelector, getAttrValue} from './utils';\n\n/**\n * Helper function for quickly creating a color category style.\n *\n * Data values of each attribute listed in the domain are mapped one to one\n * with corresponding colors in the range.\n *\n * @return accessor that maps objects to `Color` values\n */\nexport default function colorCategories<DataT = Feature>({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR,\n othersColor = OTHERS_COLOR\n}: {\n /** Attribute or column to symbolize by */\n attr: string | AttributeSelector<DataT, number | string>;\n\n /** Category list. Must be a valid list of categories. */\n domain: number[] | string[];\n\n /**\n * Color assigned to each domain value.\n *\n * Either Array of colors in RGBA or valid named CARTOColors palette.\n * @default `PurpOr`\n */\n colors: string | Color[];\n\n /** Color for null values. @default: [204, 204, 204] */\n nullColor?: Color;\n\n /** Fallback color for a category not correctly assigned. @default: [119, 119, 119] */\n othersColor?: Color;\n}): AccessorFunction<DataT, Color> {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers or strings');\n\n const colorsByCategory = {};\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n\n for (const [i, c] of domain.entries()) {\n colorsByCategory[c] = palette[i];\n }\n\n return d => {\n const value = getAttrValue(attr, d);\n return (typeof value === 'number' && Number.isFinite(value)) || typeof value === 'string'\n ? colorsByCategory[value] || othersColor\n : nullColor;\n };\n}\n"],"file":"color-categories-style.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/style/color-continuous-style.ts"],"names":["colorContinuous","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/style/color-continuous-style.ts"],"names":["colorContinuous","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;;;AACA;;AAEA;;AACA;;;;;;AAUe,SAASA,eAAT,OAsBoB;AAAA,MArBjCC,IAqBiC,QArBjCA,IAqBiC;AAAA,MApBjCC,MAoBiC,QApBjCA,MAoBiC;AAAA,yBAnBjCC,MAmBiC;AAAA,MAnBjCA,MAmBiC,4BAnBxBC,wBAmBwB;AAAA,4BAlBjCC,SAkBiC;AAAA,MAlBjCA,SAkBiC,+BAlBrBC,mBAkBqB;AACjC,qBAAOC,KAAK,CAACC,OAAN,CAAcN,MAAd,CAAP,EAA8B,6CAA9B;AAEA,MAAMO,OAAO,GAAG,OAAON,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACQ,MAA1B,CAA7B,GAAiEP,MAAjF;AACA,MAAMQ,KAAK,GAAG,4BAAqBT,MAArB,CAA4BA,MAA5B,EAAoCU,KAApC,CAA0CH,OAA1C,CAAd;AAEA,SAAO,UAAAI,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAab,IAAb,EAAmBY,CAAnB,CAAd;AACA,WAAO,OAAOC,KAAP,KAAiB,QAAjB,IAA6BC,MAAM,CAACC,QAAP,CAAgBF,KAAhB,CAA7B,GAAsDH,KAAK,CAACG,KAAD,CAA3D,GAAqET,SAA5E;AACD,GAHD;AAID","sourcesContent":["import {AccessorFunction} from '@deck.gl/core';\nimport {scaleLinear} from 'd3-scale';\nimport {Feature} from 'geojson';\nimport getPalette, {Color, DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, AttributeSelector, getAttrValue} from './utils';\n\n/**\n * Helper function for quickly creating a color continuous style.\n *\n * Data values of each field are interpolated linearly across values in the domain and\n * are then styled with a blend of the corresponding color in the range.\n *\n * @return accessor that maps objects to `Color` values\n */\nexport default function colorContinuous<DataT = Feature>({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}: {\n /** Attribute or column to symbolize by. */\n attr: AttributeSelector<DataT, number>;\n\n /** Attribute domain to define the data range. */\n domain: number[];\n\n /**\n * Color assigned to each domain value.\n *\n * Either Array of colors in RGBA or valid named CARTOColors palette.\n * @default `PurpOr`\n */\n colors?: string | Color[];\n\n /** Color for null values. @default: [204, 204, 204]*/\n nullColor?: Color;\n}): AccessorFunction<DataT, Color> {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n const color = scaleLinear<Color>().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return typeof value === 'number' && Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-continuous-style.js"}
|
package/dist/es5/style/utils.js
CHANGED
|
@@ -13,6 +13,8 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
|
13
13
|
var ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);
|
|
14
14
|
|
|
15
15
|
function getAttrValue(attr, d) {
|
|
16
|
+
var _properties;
|
|
17
|
+
|
|
16
18
|
assert((0, _typeof2.default)(d) === 'object', 'Expected "data" to be an object');
|
|
17
19
|
assert(ALLOWED_ATTR_TYPES.includes((0, _typeof2.default)(attr)), 'Expected "attr" to be a function or string');
|
|
18
20
|
|
|
@@ -20,7 +22,7 @@ function getAttrValue(attr, d) {
|
|
|
20
22
|
return attr(d);
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
return d.properties[attr];
|
|
25
|
+
return d === null || d === void 0 ? void 0 : (_properties = d.properties) === null || _properties === void 0 ? void 0 : _properties[attr];
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
function assert(condition) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/style/utils.ts"],"names":["ALLOWED_ATTR_TYPES","Object","freeze","getAttrValue","attr","d","assert","includes","properties","condition","message","Error"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/style/utils.ts"],"names":["ALLOWED_ATTR_TYPES","Object","freeze","getAttrValue","attr","d","assert","includes","properties","condition","message","Error"],"mappings":";;;;;;;;;;;;AAEA,IAAMA,kBAAkB,GAAGC,MAAM,CAACC,MAAP,CAAc,CAAC,UAAD,EAAa,QAAb,CAAd,CAA3B;;AAIO,SAASC,YAAT,CACLC,IADK,EAELC,CAFK,EAGC;AAAA;;AACNC,EAAAA,MAAM,CAAC,sBAAOD,CAAP,MAAa,QAAd,EAAwB,iCAAxB,CAAN;AACAC,EAAAA,MAAM,CAACN,kBAAkB,CAACO,QAAnB,uBAAmCH,IAAnC,EAAD,EAA2C,4CAA3C,CAAN;;AAGA,MAAI,OAAOA,IAAP,KAAgB,UAApB,EAAgC;AAC9B,WAAOA,IAAI,CAACC,CAAD,CAAX;AACD;;AACD,SAAQA,CAAR,aAAQA,CAAR,sCAAQA,CAAD,CAA2BG,UAAlC,gDAAO,YAAwCJ,IAAxC,CAAP;AACD;;AAEM,SAASE,MAAT,CAAgBG,SAAhB,EAA4D;AAAA,MAAjCC,OAAiC,uEAAvB,EAAuB;;AACjE,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,8BAAgCD,OAAhC,EAAN;AACD;AACF","sourcesContent":["import {Feature} from 'geojson';\n\nconst ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);\n\nexport type AttributeSelector<DataT = Feature, OutT = any> = string | ((d: DataT) => OutT);\n\nexport function getAttrValue<DataT = Feature, OutT = any>(\n attr: string | AttributeSelector<DataT, OutT>,\n d: DataT\n): OutT {\n assert(typeof d === 'object', 'Expected \"data\" to be an object');\n assert(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected \"attr\" to be a function or string');\n\n // Is function\n if (typeof attr === 'function') {\n return attr(d);\n }\n return (d as unknown as Feature)?.properties?.[attr] as OutT;\n}\n\nexport function assert(condition, message = ''): asserts condition {\n if (!condition) {\n throw new Error(`CARTO style error: ${message}`);\n }\n}\n"],"file":"utils.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/api/index.ts"],"names":["FORMATS","TILE_FORMATS","MAP_TYPES","API_VERSIONS","getDataV2","CONNECTIONS","fetchLayerData","fetchMap","mapInstantiation"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,YAAjB,EAA+BC,SAA/B,EAA0CC,YAA1C,QAA6D,mBAA7D;
|
|
1
|
+
{"version":3,"sources":["../../../src/api/index.ts"],"names":["FORMATS","TILE_FORMATS","MAP_TYPES","API_VERSIONS","getDataV2","CONNECTIONS","fetchLayerData","fetchMap","mapInstantiation"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,YAAjB,EAA+BC,SAA/B,EAA0CC,YAA1C,QAA6D,mBAA7D;AAEA,SAAQC,SAAR,EAAmBC,WAAnB,QAAqC,eAArC;AACA,SAAQC,cAAR,EAAwBC,QAAxB,EAAkCC,gBAAlC,QAAyD,kBAAzD","sourcesContent":["export {FORMATS, TILE_FORMATS, MAP_TYPES, API_VERSIONS} from './maps-api-common';\nexport type {QueryParameters} from './maps-api-common';\nexport {getDataV2, CONNECTIONS} from './maps-client';\nexport {fetchLayerData, fetchMap, mapInstantiation} from './maps-v3-client';\n"],"file":"index.js"}
|