@deck.gl/carto 9.0.34 → 9.1.0-beta.1
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/api/basemap.d.ts +2 -1
- package/dist/api/basemap.d.ts.map +1 -1
- package/dist/api/basemap.js +3 -0
- package/dist/api/fetch-map.d.ts.map +1 -1
- package/dist/api/fetch-map.js +9 -11
- package/dist/api/index.d.ts +1 -4
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +3 -2
- package/dist/api/layer-map.d.ts.map +1 -1
- package/dist/api/layer-map.js +5 -2
- package/dist/api/parse-map.d.ts.map +1 -1
- package/dist/api/parse-map.js +3 -0
- package/dist/api/types.d.ts +0 -56
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js +4 -20
- package/dist/basemap.d.ts +2 -1
- package/dist/basemap.d.ts.map +1 -1
- package/dist/basemap.js +4 -1
- package/dist/cartoRasterTile-worker.js +25 -2
- package/dist/cartoSpatialTile-worker.js +28 -3
- package/dist/cartoVectorTile-worker.js +29 -3
- package/dist/constants.d.ts +0 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -3
- package/dist/dist.dev.js +4512 -3855
- package/dist/index.cjs +328 -630
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +29 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/layers/cluster-tile-layer.d.ts +1 -1
- package/dist/layers/cluster-tile-layer.d.ts.map +1 -1
- package/dist/layers/cluster-tile-layer.js +4 -0
- package/dist/layers/cluster-utils.d.ts.map +1 -1
- package/dist/layers/cluster-utils.js +3 -0
- package/dist/layers/h3-tile-layer.d.ts +4 -4
- package/dist/layers/h3-tile-layer.d.ts.map +1 -1
- package/dist/layers/h3-tile-layer.js +15 -14
- package/dist/layers/h3-tileset-2d.d.ts.map +1 -1
- package/dist/layers/h3-tileset-2d.js +3 -0
- package/dist/layers/heatmap-tile-layer.d.ts +12 -2
- package/dist/layers/heatmap-tile-layer.d.ts.map +1 -1
- package/dist/layers/heatmap-tile-layer.js +85 -9
- package/dist/layers/heatmap.d.ts +69 -22
- package/dist/layers/heatmap.d.ts.map +1 -1
- package/dist/layers/heatmap.js +86 -102
- package/dist/layers/point-label-layer.d.ts.map +1 -1
- package/dist/layers/point-label-layer.js +5 -2
- package/dist/layers/post-process-utils.d.ts.map +1 -1
- package/dist/layers/post-process-utils.js +9 -5
- package/dist/layers/quadbin-layer.d.ts.map +1 -1
- package/dist/layers/quadbin-layer.js +3 -0
- package/dist/layers/quadbin-tile-layer.d.ts +4 -4
- package/dist/layers/quadbin-tile-layer.d.ts.map +1 -1
- package/dist/layers/quadbin-tile-layer.js +13 -12
- package/dist/layers/quadbin-tileset-2d.d.ts.map +1 -1
- package/dist/layers/quadbin-tileset-2d.js +3 -0
- package/dist/layers/quadbin-utils.d.ts.map +1 -1
- package/dist/layers/quadbin-utils.js +3 -0
- package/dist/layers/raster-layer-vertex.glsl.d.ts +1 -1
- package/dist/layers/raster-layer-vertex.glsl.d.ts.map +1 -1
- package/dist/layers/raster-layer-vertex.glsl.js +20 -25
- package/dist/layers/raster-layer.d.ts +6 -6
- package/dist/layers/raster-layer.d.ts.map +1 -1
- package/dist/layers/raster-layer.js +6 -1
- package/dist/layers/raster-tile-layer.d.ts +1 -1
- package/dist/layers/raster-tile-layer.d.ts.map +1 -1
- package/dist/layers/raster-tile-layer.js +14 -13
- package/dist/layers/schema/carto-properties-tile-loader.d.ts.map +1 -1
- package/dist/layers/schema/carto-properties-tile-loader.js +3 -0
- package/dist/layers/schema/carto-properties-tile.d.ts.map +1 -1
- package/dist/layers/schema/carto-properties-tile.js +3 -0
- package/dist/layers/schema/carto-raster-tile-loader.d.ts.map +1 -1
- package/dist/layers/schema/carto-raster-tile-loader.js +4 -1
- package/dist/layers/schema/carto-raster-tile.d.ts.map +1 -1
- package/dist/layers/schema/carto-raster-tile.js +3 -0
- package/dist/layers/schema/carto-spatial-tile-loader.d.ts.map +1 -1
- package/dist/layers/schema/carto-spatial-tile-loader.js +4 -1
- package/dist/layers/schema/carto-spatial-tile.d.ts.map +1 -1
- package/dist/layers/schema/carto-spatial-tile.js +3 -0
- package/dist/layers/schema/carto-tile.d.ts.map +1 -1
- package/dist/layers/schema/carto-tile.js +3 -0
- package/dist/layers/schema/carto-vector-tile-loader.d.ts.map +1 -1
- package/dist/layers/schema/carto-vector-tile-loader.js +4 -1
- package/dist/layers/schema/fast-pbf.d.ts.map +1 -1
- package/dist/layers/schema/fast-pbf.js +3 -0
- package/dist/layers/schema/spatialjson-utils.d.ts.map +1 -1
- package/dist/layers/schema/spatialjson-utils.js +3 -0
- package/dist/layers/schema/tile-loader-utils.d.ts.map +1 -1
- package/dist/layers/schema/tile-loader-utils.js +3 -0
- package/dist/layers/spatial-index-tile-layer.d.ts.map +1 -1
- package/dist/layers/spatial-index-tile-layer.js +3 -0
- package/dist/layers/utils.d.ts +2 -2
- package/dist/layers/utils.d.ts.map +1 -1
- package/dist/layers/utils.js +3 -0
- package/dist/layers/vector-tile-layer.d.ts +1 -1
- package/dist/layers/vector-tile-layer.d.ts.map +1 -1
- package/dist/layers/vector-tile-layer.js +3 -0
- package/dist/style/color-bins-style.d.ts.map +1 -1
- package/dist/style/color-bins-style.js +3 -0
- package/dist/style/color-categories-style.d.ts.map +1 -1
- package/dist/style/color-categories-style.js +3 -0
- package/dist/style/color-continuous-style.d.ts.map +1 -1
- package/dist/style/color-continuous-style.js +3 -0
- package/dist/style/palette.d.ts.map +1 -1
- package/dist/style/palette.js +3 -0
- package/dist/style/utils.d.ts.map +1 -1
- package/dist/style/utils.js +3 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +3 -0
- package/dist/workers/cartoRasterTile.js +3 -0
- package/dist/workers/cartoSpatialTile.js +3 -0
- package/dist/workers/cartoVectorTile.js +3 -0
- package/dist.min.js +115 -101
- package/package.json +13 -11
- package/src/api/basemap.ts +6 -1
- package/src/api/fetch-map.ts +23 -15
- package/src/api/index.ts +5 -13
- package/src/api/layer-map.ts +6 -2
- package/src/api/parse-map.ts +4 -0
- package/src/api/types.ts +4 -75
- package/src/basemap.ts +6 -2
- package/src/constants.ts +4 -4
- package/src/index.ts +28 -9
- package/src/layers/cluster-tile-layer.ts +6 -1
- package/src/layers/cluster-utils.ts +4 -0
- package/src/layers/h3-tile-layer.ts +18 -16
- package/src/layers/h3-tileset-2d.ts +4 -0
- package/src/layers/heatmap-tile-layer.ts +115 -11
- package/src/layers/heatmap.ts +41 -99
- package/src/layers/point-label-layer.ts +6 -2
- package/src/layers/post-process-utils.ts +10 -5
- package/src/layers/quadbin-layer.ts +4 -0
- package/src/layers/quadbin-tile-layer.ts +16 -14
- package/src/layers/quadbin-tileset-2d.ts +4 -0
- package/src/layers/quadbin-utils.ts +4 -0
- package/src/layers/raster-layer-vertex.glsl.ts +21 -27
- package/src/layers/raster-layer.ts +7 -1
- package/src/layers/raster-tile-layer.ts +16 -14
- package/src/layers/schema/carto-properties-tile-loader.ts +4 -0
- package/src/layers/schema/carto-properties-tile.ts +4 -0
- package/src/layers/schema/carto-raster-tile-loader.ts +4 -0
- package/src/layers/schema/carto-raster-tile.ts +4 -0
- package/src/layers/schema/carto-spatial-tile-loader.ts +4 -0
- package/src/layers/schema/carto-spatial-tile.ts +4 -0
- package/src/layers/schema/carto-tile.ts +4 -0
- package/src/layers/schema/carto-vector-tile-loader.ts +4 -0
- package/src/layers/schema/fast-pbf.ts +4 -0
- package/src/layers/schema/spatialjson-utils.ts +4 -0
- package/src/layers/schema/tile-loader-utils.ts +4 -0
- package/src/layers/spatial-index-tile-layer.ts +4 -0
- package/src/layers/utils.ts +5 -1
- package/src/layers/vector-tile-layer.ts +5 -1
- package/src/style/color-bins-style.ts +4 -0
- package/src/style/color-categories-style.ts +4 -0
- package/src/style/color-continuous-style.ts +4 -0
- package/src/style/palette.ts +4 -0
- package/src/style/utils.ts +4 -0
- package/src/utils.ts +4 -0
- package/src/workers/cartoRasterTile.ts +4 -0
- package/src/workers/cartoSpatialTile.ts +4 -0
- package/src/workers/cartoVectorTile.ts +4 -0
- package/dist/api/carto-api-error.d.ts +0 -19
- package/dist/api/carto-api-error.d.ts.map +0 -1
- package/dist/api/carto-api-error.js +0 -48
- package/dist/api/common.d.ts +0 -5
- package/dist/api/common.d.ts.map +0 -1
- package/dist/api/common.js +0 -5
- package/dist/api/endpoints.d.ts +0 -23
- package/dist/api/endpoints.d.ts.map +0 -1
- package/dist/api/endpoints.js +0 -22
- package/dist/api/query.d.ts +0 -4
- package/dist/api/query.d.ts.map +0 -1
- package/dist/api/query.js +0 -26
- package/dist/api/request-with-parameters.d.ts +0 -9
- package/dist/api/request-with-parameters.d.ts.map +0 -1
- package/dist/api/request-with-parameters.js +0 -86
- package/dist/sources/base-source.d.ts +0 -5
- package/dist/sources/base-source.d.ts.map +0 -1
- package/dist/sources/base-source.js +0 -60
- package/dist/sources/boundary-query-source.d.ts +0 -10
- package/dist/sources/boundary-query-source.d.ts.map +0 -1
- package/dist/sources/boundary-query-source.js +0 -18
- package/dist/sources/boundary-table-source.d.ts +0 -8
- package/dist/sources/boundary-table-source.d.ts.map +0 -1
- package/dist/sources/boundary-table-source.js +0 -15
- package/dist/sources/h3-query-source.d.ts +0 -4
- package/dist/sources/h3-query-source.d.ts.map +0 -1
- package/dist/sources/h3-query-source.js +0 -22
- package/dist/sources/h3-table-source.d.ts +0 -4
- package/dist/sources/h3-table-source.d.ts.map +0 -1
- package/dist/sources/h3-table-source.js +0 -19
- package/dist/sources/h3-tileset-source.d.ts +0 -4
- package/dist/sources/h3-tileset-source.d.ts.map +0 -1
- package/dist/sources/h3-tileset-source.js +0 -6
- package/dist/sources/index.d.ts +0 -28
- package/dist/sources/index.d.ts.map +0 -1
- package/dist/sources/index.js +0 -13
- package/dist/sources/quadbin-query-source.d.ts +0 -4
- package/dist/sources/quadbin-query-source.d.ts.map +0 -1
- package/dist/sources/quadbin-query-source.js +0 -22
- package/dist/sources/quadbin-table-source.d.ts +0 -4
- package/dist/sources/quadbin-table-source.d.ts.map +0 -1
- package/dist/sources/quadbin-table-source.js +0 -19
- package/dist/sources/quadbin-tileset-source.d.ts +0 -4
- package/dist/sources/quadbin-tileset-source.d.ts.map +0 -1
- package/dist/sources/quadbin-tileset-source.js +0 -6
- package/dist/sources/raster-source.d.ts +0 -4
- package/dist/sources/raster-source.d.ts.map +0 -1
- package/dist/sources/raster-source.js +0 -9
- package/dist/sources/types.d.ts +0 -219
- package/dist/sources/types.d.ts.map +0 -1
- package/dist/sources/types.js +0 -1
- package/dist/sources/vector-query-source.d.ts +0 -4
- package/dist/sources/vector-query-source.d.ts.map +0 -1
- package/dist/sources/vector-query-source.js +0 -22
- package/dist/sources/vector-table-source.d.ts +0 -4
- package/dist/sources/vector-table-source.d.ts.map +0 -1
- package/dist/sources/vector-table-source.js +0 -19
- package/dist/sources/vector-tileset-source.d.ts +0 -4
- package/dist/sources/vector-tileset-source.d.ts.map +0 -1
- package/dist/sources/vector-tileset-source.js +0 -6
- package/src/api/carto-api-error.ts +0 -68
- package/src/api/common.ts +0 -6
- package/src/api/endpoints.ts +0 -69
- package/src/api/query.ts +0 -42
- package/src/api/request-with-parameters.ts +0 -117
- package/src/sources/base-source.ts +0 -79
- package/src/sources/boundary-query-source.ts +0 -39
- package/src/sources/boundary-table-source.ts +0 -33
- package/src/sources/h3-query-source.ts +0 -55
- package/src/sources/h3-table-source.ts +0 -51
- package/src/sources/h3-tileset-source.ts +0 -14
- package/src/sources/index.ts +0 -45
- package/src/sources/quadbin-query-source.ts +0 -56
- package/src/sources/quadbin-table-source.ts +0 -52
- package/src/sources/quadbin-tileset-source.ts +0 -14
- package/src/sources/raster-source.ts +0 -17
- package/src/sources/types.ts +0 -231
- package/src/sources/vector-query-source.ts +0 -57
- package/src/sources/vector-table-source.ts +0 -51
- package/src/sources/vector-tileset-source.ts +0 -14
package/dist/index.cjs
CHANGED
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -29,38 +33,39 @@ __export(dist_exports, {
|
|
|
29
33
|
BASEMAP: () => basemap_default,
|
|
30
34
|
CARTO_LAYERS: () => CARTO_LAYERS,
|
|
31
35
|
CARTO_SOURCES: () => CARTO_SOURCES,
|
|
32
|
-
CartoAPIError: () => CartoAPIError,
|
|
33
36
|
ClusterTileLayer: () => cluster_tile_layer_default,
|
|
34
37
|
H3TileLayer: () => h3_tile_layer_default,
|
|
35
38
|
HeatmapTileLayer: () => heatmap_tile_layer_default,
|
|
36
39
|
QuadbinTileLayer: () => quadbin_tile_layer_default,
|
|
37
40
|
RasterTileLayer: () => raster_tile_layer_default,
|
|
38
|
-
SOURCE_DEFAULTS: () => SOURCE_DEFAULTS,
|
|
41
|
+
SOURCE_DEFAULTS: () => import_api_client3.SOURCE_DEFAULTS,
|
|
39
42
|
VectorTileLayer: () => vector_tile_layer_default,
|
|
40
43
|
_GOOGLE_BASEMAPS: () => GOOGLE_BASEMAPS,
|
|
41
44
|
_PointLabelLayer: () => point_label_layer_default,
|
|
45
|
+
_QuadbinLayer: () => quadbin_layer_default,
|
|
46
|
+
_RasterLayer: () => raster_layer_default,
|
|
42
47
|
_STYLE_LAYER_GROUPS: () => STYLE_LAYER_GROUPS,
|
|
48
|
+
_SpatialIndexTileLayer: () => spatial_index_tile_layer_default,
|
|
43
49
|
_applyLayerGroupFilters: () => applyLayerGroupFilters,
|
|
44
50
|
_fetchStyle: () => fetchStyle,
|
|
45
51
|
_getStyleUrl: () => getStyleUrl,
|
|
46
|
-
boundaryQuerySource: () => boundaryQuerySource,
|
|
47
|
-
boundaryTableSource: () => boundaryTableSource,
|
|
52
|
+
boundaryQuerySource: () => import_api_client3.boundaryQuerySource,
|
|
53
|
+
boundaryTableSource: () => import_api_client3.boundaryTableSource,
|
|
48
54
|
colorBins: () => colorBins,
|
|
49
55
|
colorCategories: () => colorCategories,
|
|
50
56
|
colorContinuous: () => colorContinuous,
|
|
51
57
|
fetchBasemapProps: () => fetchBasemapProps,
|
|
52
58
|
fetchMap: () => fetchMap,
|
|
53
|
-
h3QuerySource: () => h3QuerySource,
|
|
54
|
-
h3TableSource: () => h3TableSource,
|
|
55
|
-
h3TilesetSource: () => h3TilesetSource,
|
|
56
|
-
quadbinQuerySource: () => quadbinQuerySource,
|
|
57
|
-
quadbinTableSource: () => quadbinTableSource,
|
|
58
|
-
quadbinTilesetSource: () => quadbinTilesetSource,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
vectorTilesetSource: () => vectorTilesetSource
|
|
59
|
+
h3QuerySource: () => import_api_client3.h3QuerySource,
|
|
60
|
+
h3TableSource: () => import_api_client3.h3TableSource,
|
|
61
|
+
h3TilesetSource: () => import_api_client3.h3TilesetSource,
|
|
62
|
+
quadbinQuerySource: () => import_api_client3.quadbinQuerySource,
|
|
63
|
+
quadbinTableSource: () => import_api_client3.quadbinTableSource,
|
|
64
|
+
quadbinTilesetSource: () => import_api_client3.quadbinTilesetSource,
|
|
65
|
+
rasterSource: () => import_api_client3.rasterSource,
|
|
66
|
+
vectorQuerySource: () => import_api_client3.vectorQuerySource,
|
|
67
|
+
vectorTableSource: () => import_api_client3.vectorTableSource,
|
|
68
|
+
vectorTilesetSource: () => import_api_client3.vectorTilesetSource
|
|
64
69
|
});
|
|
65
70
|
module.exports = __toCommonJS(dist_exports);
|
|
66
71
|
|
|
@@ -195,26 +200,28 @@ function clustersToBinary(data) {
|
|
|
195
200
|
|
|
196
201
|
// dist/constants.js
|
|
197
202
|
var DEFAULT_TILE_SIZE = 512;
|
|
198
|
-
var DEFAULT_TILE_RESOLUTION = 0.5;
|
|
199
|
-
var DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
|
|
200
|
-
var DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
|
|
201
203
|
|
|
202
204
|
// dist/layers/quadbin-tileset-2d.js
|
|
203
205
|
var import_geo_layers = require("@deck.gl/geo-layers");
|
|
204
206
|
var import_quadbin2 = require("quadbin");
|
|
205
207
|
var QuadbinTileset2D = class extends import_geo_layers._Tileset2D {
|
|
208
|
+
// @ts-expect-error for spatial indices, TileSet2d should be parametrized by TileIndexT
|
|
206
209
|
getTileIndices(opts) {
|
|
207
210
|
return super.getTileIndices(opts).map(import_quadbin2.tileToCell).map((q) => ({ q, i: (0, import_quadbin2.bigIntToHex)(q) }));
|
|
208
211
|
}
|
|
212
|
+
// @ts-expect-error TileIndex must be generic
|
|
209
213
|
getTileId({ q, i }) {
|
|
210
214
|
return i || (0, import_quadbin2.bigIntToHex)(q);
|
|
211
215
|
}
|
|
216
|
+
// @ts-expect-error TileIndex must be generic
|
|
212
217
|
getTileMetadata({ q }) {
|
|
213
218
|
return super.getTileMetadata((0, import_quadbin2.cellToTile)(q));
|
|
214
219
|
}
|
|
220
|
+
// @ts-expect-error TileIndex must be generic
|
|
215
221
|
getTileZoom({ q }) {
|
|
216
222
|
return Number((0, import_quadbin2.getResolution)(q));
|
|
217
223
|
}
|
|
224
|
+
// @ts-expect-error TileIndex must be generic
|
|
218
225
|
getParentIndex({ q }) {
|
|
219
226
|
return { q: (0, import_quadbin2.cellToParent)(q) };
|
|
220
227
|
}
|
|
@@ -527,8 +534,6 @@ function scaleIdentity() {
|
|
|
527
534
|
};
|
|
528
535
|
return scale;
|
|
529
536
|
}
|
|
530
|
-
var isObject = (x) => x !== null && typeof x === "object";
|
|
531
|
-
var isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
|
|
532
537
|
|
|
533
538
|
// dist/layers/schema/spatialjson-utils.js
|
|
534
539
|
var import_quadbin4 = require("quadbin");
|
|
@@ -548,7 +553,7 @@ function binaryToSpatialjson(binary) {
|
|
|
548
553
|
}
|
|
549
554
|
|
|
550
555
|
// dist/layers/schema/carto-spatial-tile-loader.js
|
|
551
|
-
var VERSION = true ? "9.0.
|
|
556
|
+
var VERSION = true ? "9.1.0-beta.1" : "latest";
|
|
552
557
|
var id = "cartoSpatialTile";
|
|
553
558
|
var DEFAULT_OPTIONS = {
|
|
554
559
|
cartoSpatialTile: {
|
|
@@ -665,6 +670,7 @@ var ClusterGeoJsonLayer = class extends import_geo_layers2.TileLayer {
|
|
|
665
670
|
super.initializeState();
|
|
666
671
|
this.state.aggregationCache = /* @__PURE__ */ new WeakMap();
|
|
667
672
|
}
|
|
673
|
+
// eslint-disable-next-line max-statements
|
|
668
674
|
renderLayers() {
|
|
669
675
|
var _a;
|
|
670
676
|
const visibleTiles = (_a = this.state.tileset) == null ? void 0 : _a.tiles.filter((tile) => {
|
|
@@ -750,9 +756,11 @@ var ClusterTileLayer = class extends import_core6.CompositeLayer {
|
|
|
750
756
|
return null;
|
|
751
757
|
const { tiles: data, maxresolution: maxZoom } = tileJSON;
|
|
752
758
|
return [
|
|
759
|
+
// @ts-ignore
|
|
753
760
|
new ClusterGeoJsonLayer(this.props, {
|
|
754
761
|
id: `cluster-geojson-layer-${this.props.id}`,
|
|
755
762
|
data,
|
|
763
|
+
// TODO: Tileset2D should be generic over TileIndex type
|
|
756
764
|
TilesetClass: QuadbinTileset2D,
|
|
757
765
|
maxZoom,
|
|
758
766
|
loadOptions: this.getLoadOptions()
|
|
@@ -829,6 +837,12 @@ function getHexagonResolution(viewport, tileSize) {
|
|
|
829
837
|
return Math.max(0, Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS));
|
|
830
838
|
}
|
|
831
839
|
var H3Tileset2D = class extends import_geo_layers3._Tileset2D {
|
|
840
|
+
/**
|
|
841
|
+
* Returns all tile indices in the current viewport. If the current zoom level is smaller
|
|
842
|
+
* than minZoom, return an empty array. If the current zoom level is greater than maxZoom,
|
|
843
|
+
* return tiles that are on maxZoom.
|
|
844
|
+
*/
|
|
845
|
+
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
832
846
|
getTileIndices({ viewport, minZoom, maxZoom }) {
|
|
833
847
|
if (viewport.latitude === void 0)
|
|
834
848
|
return [];
|
|
@@ -849,15 +863,19 @@ var H3Tileset2D = class extends import_geo_layers3._Tileset2D {
|
|
|
849
863
|
}
|
|
850
864
|
return indices.map((i) => ({ i }));
|
|
851
865
|
}
|
|
866
|
+
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
852
867
|
getTileId({ i }) {
|
|
853
868
|
return i;
|
|
854
869
|
}
|
|
870
|
+
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
855
871
|
getTileMetadata({ i }) {
|
|
856
872
|
return { bbox: tileToBoundingBox(i) };
|
|
857
873
|
}
|
|
874
|
+
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
858
875
|
getTileZoom({ i }) {
|
|
859
876
|
return (0, import_h3_js.getResolution)(i);
|
|
860
877
|
}
|
|
878
|
+
// @ts-expect-error Tileset2D should be generic over TileIndex
|
|
861
879
|
getParentIndex(index) {
|
|
862
880
|
const resolution = (0, import_h3_js.getResolution)(index.i);
|
|
863
881
|
const i = (0, import_h3_js.cellToParent)(index.i, resolution - 1);
|
|
@@ -913,7 +931,7 @@ var TileReader3 = class {
|
|
|
913
931
|
};
|
|
914
932
|
|
|
915
933
|
// dist/layers/schema/carto-raster-tile-loader.js
|
|
916
|
-
var VERSION2 = true ? "9.0.
|
|
934
|
+
var VERSION2 = true ? "9.1.0-beta.1" : "latest";
|
|
917
935
|
var id2 = "cartoRasterTile";
|
|
918
936
|
var DEFAULT_OPTIONS2 = {
|
|
919
937
|
cartoRasterTile: {
|
|
@@ -984,7 +1002,8 @@ var SpatialIndexTileLayer = class extends import_geo_layers4.TileLayer {
|
|
|
984
1002
|
const { hoveredFeatureId } = this.state;
|
|
985
1003
|
const data = tile.content;
|
|
986
1004
|
const isFeatureIdPresent = isFeatureIdDefined(hoveredFeatureId);
|
|
987
|
-
if (!isFeatureIdPresent || !Array.isArray(data) ||
|
|
1005
|
+
if (!isFeatureIdPresent || !Array.isArray(data) || // Quick check for whether id is within tile. data.findIndex is expensive
|
|
1006
|
+
!this._featureInTile(tile, hoveredFeatureId)) {
|
|
988
1007
|
return -1;
|
|
989
1008
|
}
|
|
990
1009
|
return data.findIndex((feature) => feature.id === hoveredFeatureId);
|
|
@@ -1045,17 +1064,18 @@ var H3TileLayer = class extends import_core8.CompositeLayer {
|
|
|
1045
1064
|
if (this.props.maxZoom) {
|
|
1046
1065
|
maxresolution = Math.min(maxresolution, getHexagonResolution({ zoom: this.props.maxZoom, latitude: 0 }, this.props.tileSize));
|
|
1047
1066
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1067
|
+
const SubLayerClass = this.getSubLayerClass("spatial-index-tile", spatial_index_tile_layer_default);
|
|
1068
|
+
return new SubLayerClass(this.props, {
|
|
1069
|
+
id: `h3-tile-layer-${this.props.id}`,
|
|
1070
|
+
data,
|
|
1071
|
+
// TODO: Tileset2D should be generic over TileIndex type
|
|
1072
|
+
TilesetClass: H3Tileset2D,
|
|
1073
|
+
renderSubLayers,
|
|
1074
|
+
// minZoom and maxZoom are H3 resolutions, however we must use this naming as that is what the Tileset2D class expects
|
|
1075
|
+
minZoom: minresolution,
|
|
1076
|
+
maxZoom: maxresolution,
|
|
1077
|
+
loadOptions: this.getLoadOptions()
|
|
1078
|
+
});
|
|
1059
1079
|
}
|
|
1060
1080
|
};
|
|
1061
1081
|
H3TileLayer.layerName = "H3TileLayer";
|
|
@@ -1068,137 +1088,121 @@ var import_core11 = require("@deck.gl/core");
|
|
|
1068
1088
|
var import_layers2 = require("@deck.gl/layers");
|
|
1069
1089
|
|
|
1070
1090
|
// dist/layers/heatmap.js
|
|
1071
|
-
var fs =
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
vec2 colorDomain;
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
vec3 color5;
|
|
1080
|
-
vec3 color6;
|
|
1081
|
-
float intensity;
|
|
1082
|
-
float opacity;
|
|
1091
|
+
var fs = (
|
|
1092
|
+
/* glsl */
|
|
1093
|
+
`uniform heatmapUniforms {
|
|
1094
|
+
vec2 colorDomain;
|
|
1095
|
+
vec2 delta;
|
|
1096
|
+
float intensity;
|
|
1097
|
+
float opacity;
|
|
1098
|
+
float radiusPixels;
|
|
1083
1099
|
} heatmap;
|
|
1084
|
-
|
|
1100
|
+
|
|
1101
|
+
uniform sampler2D colorTexture;
|
|
1102
|
+
|
|
1085
1103
|
vec3 colorGradient(float value) {
|
|
1086
|
-
|
|
1087
|
-
vec3 c2;
|
|
1088
|
-
vec2 range;
|
|
1089
|
-
if (value < STOPS.x) {
|
|
1090
|
-
range = vec2(0.0, STOPS.x);
|
|
1091
|
-
c1 = heatmap.color1; c2 = heatmap.color2;
|
|
1092
|
-
} else if (value < STOPS.y) {
|
|
1093
|
-
range = STOPS.xy;
|
|
1094
|
-
c1 = heatmap.color2; c2 = heatmap.color3;
|
|
1095
|
-
} else if (value < STOPS.z) {
|
|
1096
|
-
range = STOPS.yz;
|
|
1097
|
-
c1 = heatmap.color3; c2 = heatmap.color4;
|
|
1098
|
-
} else if (value < STOPS.w) {
|
|
1099
|
-
range = STOPS.zw;
|
|
1100
|
-
c1 = heatmap.color4; c2 = heatmap.color5;
|
|
1101
|
-
} else {
|
|
1102
|
-
range = vec2(STOPS.w, 1.0);
|
|
1103
|
-
c1 = heatmap.color5; c2 = heatmap.color6;
|
|
1104
|
-
}
|
|
1105
|
-
float f = (clamp(value, 0.0, 1.0) - range.x) / (range.y - range.x);
|
|
1106
|
-
return mix(c1, c2, f) / 255.0;
|
|
1104
|
+
return texture(colorTexture, vec2(value, 0.5)).rgb;
|
|
1107
1105
|
}
|
|
1106
|
+
|
|
1108
1107
|
const vec3 SHIFT = vec3(1.0, 256.0, 256.0 * 256.0);
|
|
1109
1108
|
const float MAX_VAL = SHIFT.z * 255.0;
|
|
1110
1109
|
const float SCALE = MAX_VAL / 8.0;
|
|
1111
1110
|
vec4 pack(float value) {
|
|
1112
|
-
return vec4(mod(vec3(value, floor(value / SHIFT.yz)), 256.0), 255.0) / 255.0;
|
|
1111
|
+
return vec4(mod(vec3(value, floor(value / SHIFT.yz)), 256.0), 255.0) / 255.0;
|
|
1113
1112
|
}
|
|
1114
1113
|
float unpack(vec3 color) {
|
|
1115
|
-
return 255.0 * dot(color, SHIFT);
|
|
1114
|
+
return 255.0 * dot(color, SHIFT);
|
|
1116
1115
|
}
|
|
1116
|
+
|
|
1117
1117
|
vec4 heatmap_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
1118
|
-
bool firstPass = (heatmap.delta.y < 0.5);
|
|
1119
|
-
float accumulator = 0.0;
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
float
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
float
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
float
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
return
|
|
1118
|
+
bool firstPass = (heatmap.delta.y < 0.5);
|
|
1119
|
+
float accumulator = 0.0;
|
|
1120
|
+
|
|
1121
|
+
// Controls quality of heatmap, larger values increase quality at expense of performance
|
|
1122
|
+
float SUPPORT = clamp(heatmap.radiusPixels / 2.0, 8.0, 32.0);
|
|
1123
|
+
|
|
1124
|
+
// Gaussian normalization parameters
|
|
1125
|
+
float sigma = SUPPORT / 3.0;
|
|
1126
|
+
float a = -0.5 / (sigma * sigma);
|
|
1127
|
+
float w0 = 0.3989422804014327 / sigma; // 1D normalization
|
|
1128
|
+
for (float t = -SUPPORT; t <= SUPPORT; t++) {
|
|
1129
|
+
vec2 percent = (t * heatmap.delta - 0.5) / SUPPORT;
|
|
1130
|
+
vec2 delta = percent * heatmap.radiusPixels / texSize;
|
|
1131
|
+
vec4 offsetColor = texture(source, texCoord + delta);
|
|
1132
|
+
|
|
1133
|
+
// Unpack float
|
|
1134
|
+
float value = unpack(offsetColor.rgb);
|
|
1135
|
+
|
|
1136
|
+
// Gaussian
|
|
1137
|
+
float weight = w0 * exp(a * t * t);
|
|
1138
|
+
|
|
1139
|
+
accumulator += value * weight;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
if (firstPass) {
|
|
1143
|
+
return pack(accumulator);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
// Undo scaling to obtain normalized density
|
|
1147
|
+
float density = 10.0 * heatmap.intensity * accumulator / SCALE;
|
|
1148
|
+
|
|
1149
|
+
// Domain also in normalized density units
|
|
1150
|
+
vec2 domain = heatmap.colorDomain;
|
|
1151
|
+
|
|
1152
|
+
// Apply domain
|
|
1153
|
+
float f = (density - domain[0]) / (domain[1] - domain[0]);
|
|
1154
|
+
|
|
1155
|
+
// sqrt/log scaling??
|
|
1156
|
+
// float f = (log(density) - log(domain[0] + 1.0)) / (log(domain[1] + 1.0) - log(domain[0] + 1.0));
|
|
1157
|
+
// f = sqrt(f);
|
|
1158
|
+
|
|
1159
|
+
// Color map
|
|
1160
|
+
vec4 color = vec4(0.0);
|
|
1161
|
+
color.rgb = colorGradient(f);
|
|
1162
|
+
|
|
1163
|
+
color.a = smoothstep(0.0, 0.1, f);
|
|
1164
|
+
color.a = pow(color.a, 1.0 / 2.2);
|
|
1165
|
+
color.a *= heatmap.opacity;
|
|
1166
|
+
|
|
1167
|
+
return color;
|
|
1144
1168
|
}
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
[255, 255, 178],
|
|
1148
|
-
[254, 217, 118],
|
|
1149
|
-
[254, 178, 76],
|
|
1150
|
-
[253, 141, 60],
|
|
1151
|
-
[240, 59, 32],
|
|
1152
|
-
[189, 0, 38]
|
|
1153
|
-
];
|
|
1169
|
+
`
|
|
1170
|
+
);
|
|
1154
1171
|
var heatmap = {
|
|
1155
1172
|
name: "heatmap",
|
|
1156
1173
|
uniformPropTypes: {
|
|
1157
|
-
delta: { value: [0, 1] },
|
|
1158
|
-
radiusPixels: { value: 20, min: 0, softMax: 100 },
|
|
1159
1174
|
colorDomain: { value: [0, 1] },
|
|
1160
|
-
|
|
1161
|
-
color2: { value: [0, 0, 0] },
|
|
1162
|
-
color3: { value: [0, 0, 0] },
|
|
1163
|
-
color4: { value: [0, 0, 0] },
|
|
1164
|
-
color5: { value: [0, 0, 0] },
|
|
1165
|
-
color6: { value: [0, 0, 0] },
|
|
1175
|
+
delta: { value: [0, 1] },
|
|
1166
1176
|
intensity: { value: 1, min: 0.1, max: 10 },
|
|
1167
|
-
opacity: { value: 1, min: 0, max: 1 }
|
|
1177
|
+
opacity: { value: 1, min: 0, max: 1 },
|
|
1178
|
+
radiusPixels: { value: 20, min: 0, softMax: 100 }
|
|
1168
1179
|
},
|
|
1169
1180
|
uniformTypes: {
|
|
1170
|
-
delta: "vec2<f32>",
|
|
1171
|
-
radiusPixels: "f32",
|
|
1172
1181
|
colorDomain: "vec2<f32>",
|
|
1173
|
-
|
|
1174
|
-
color2: "vec3<f32>",
|
|
1175
|
-
color3: "vec3<f32>",
|
|
1176
|
-
color4: "vec3<f32>",
|
|
1177
|
-
color5: "vec3<f32>",
|
|
1178
|
-
color6: "vec3<f32>",
|
|
1182
|
+
delta: "vec2<f32>",
|
|
1179
1183
|
intensity: "f32",
|
|
1180
|
-
opacity: "f32"
|
|
1184
|
+
opacity: "f32",
|
|
1185
|
+
radiusPixels: "f32"
|
|
1181
1186
|
},
|
|
1187
|
+
// @ts-ignore TODO v9.1
|
|
1182
1188
|
getUniforms: (opts) => {
|
|
1183
|
-
|
|
1184
|
-
|
|
1189
|
+
if (!opts)
|
|
1190
|
+
return {};
|
|
1191
|
+
const { colorDomain = [0, 1], colorTexture, delta = [1, 0], intensity = 1, opacity = 1, radiusPixels = 20 } = opts;
|
|
1185
1192
|
return {
|
|
1186
|
-
delta,
|
|
1187
|
-
color1,
|
|
1188
|
-
color2,
|
|
1189
|
-
color3,
|
|
1190
|
-
color4,
|
|
1191
|
-
color5,
|
|
1192
|
-
color6,
|
|
1193
|
-
radiusPixels,
|
|
1194
1193
|
colorDomain,
|
|
1194
|
+
colorTexture,
|
|
1195
|
+
delta,
|
|
1195
1196
|
intensity,
|
|
1196
|
-
opacity
|
|
1197
|
+
opacity,
|
|
1198
|
+
radiusPixels
|
|
1197
1199
|
};
|
|
1198
1200
|
},
|
|
1199
1201
|
fs,
|
|
1200
1202
|
passes: [
|
|
1203
|
+
// @ts-expect-error Seems typing in luma.gl should be Partial<>
|
|
1201
1204
|
{ sampler: true, uniforms: { delta: [1, 0] } },
|
|
1205
|
+
// @ts-expect-error Seems typing in luma.gl should be Partial<>
|
|
1202
1206
|
{ sampler: true, uniforms: { delta: [0, 1] } }
|
|
1203
1207
|
]
|
|
1204
1208
|
};
|
|
@@ -1234,8 +1238,8 @@ function RTTModifier(BaseLayer) {
|
|
|
1234
1238
|
var _a;
|
|
1235
1239
|
return _a = class RTTLayer extends BaseLayer {
|
|
1236
1240
|
draw(opts) {
|
|
1237
|
-
const {
|
|
1238
|
-
const { picking } =
|
|
1241
|
+
const { shaderModuleProps } = opts;
|
|
1242
|
+
const { picking } = shaderModuleProps;
|
|
1239
1243
|
const postProcessLayer = getPostProcessLayer(this);
|
|
1240
1244
|
if (!picking.isActive) {
|
|
1241
1245
|
postProcessLayer.enableRTT(opts);
|
|
@@ -1279,10 +1283,11 @@ function PostProcessModifier(BaseLayer, effect) {
|
|
|
1279
1283
|
});
|
|
1280
1284
|
}
|
|
1281
1285
|
_resizeBuffers(opts) {
|
|
1282
|
-
const {
|
|
1286
|
+
const { shaderModuleProps } = opts;
|
|
1283
1287
|
const { viewport } = this.context;
|
|
1284
|
-
const
|
|
1285
|
-
const
|
|
1288
|
+
const { devicePixelRatio } = shaderModuleProps.project;
|
|
1289
|
+
const width = devicePixelRatio * viewport.width;
|
|
1290
|
+
const height = devicePixelRatio * viewport.height;
|
|
1286
1291
|
this.internalState.renderBuffers.forEach((fbo) => fbo.resize({ width, height }));
|
|
1287
1292
|
}
|
|
1288
1293
|
enableRTT(opts) {
|
|
@@ -1292,6 +1297,7 @@ function PostProcessModifier(BaseLayer, effect) {
|
|
|
1292
1297
|
this.internalState.internalRenderPass = this.context.device.beginRenderPass({
|
|
1293
1298
|
framebuffer,
|
|
1294
1299
|
parameters: { viewport: [0, 0, framebuffer.width, framebuffer.height] },
|
|
1300
|
+
// Only clear on first render
|
|
1295
1301
|
clearColor: this.internalState.renderInProgress ? false : [0, 0, 0, 0]
|
|
1296
1302
|
});
|
|
1297
1303
|
this.internalState.renderInProgress = true;
|
|
@@ -1370,16 +1376,16 @@ var QuadbinTileLayer = class extends import_core10.CompositeLayer {
|
|
|
1370
1376
|
if (!tileJSON)
|
|
1371
1377
|
return null;
|
|
1372
1378
|
const { tiles: data, maxresolution: maxZoom } = tileJSON;
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1379
|
+
const SubLayerClass = this.getSubLayerClass("spatial-index-tile", spatial_index_tile_layer_default);
|
|
1380
|
+
return new SubLayerClass(this.props, {
|
|
1381
|
+
id: `quadbin-tile-layer-${this.props.id}`,
|
|
1382
|
+
data,
|
|
1383
|
+
// TODO: Tileset2D should be generic over TileIndex type
|
|
1384
|
+
TilesetClass: QuadbinTileset2D,
|
|
1385
|
+
renderSubLayers: renderSubLayers2,
|
|
1386
|
+
maxZoom,
|
|
1387
|
+
loadOptions: this.getLoadOptions()
|
|
1388
|
+
});
|
|
1383
1389
|
}
|
|
1384
1390
|
};
|
|
1385
1391
|
QuadbinTileLayer.layerName = "QuadbinTileLayer";
|
|
@@ -1387,24 +1393,62 @@ QuadbinTileLayer.defaultProps = defaultProps5;
|
|
|
1387
1393
|
var quadbin_tile_layer_default = QuadbinTileLayer;
|
|
1388
1394
|
|
|
1389
1395
|
// dist/layers/heatmap-tile-layer.js
|
|
1396
|
+
var defaultColorRange = [
|
|
1397
|
+
[255, 255, 178],
|
|
1398
|
+
[254, 217, 118],
|
|
1399
|
+
[254, 178, 76],
|
|
1400
|
+
[253, 141, 60],
|
|
1401
|
+
[240, 59, 32],
|
|
1402
|
+
[189, 0, 38]
|
|
1403
|
+
];
|
|
1404
|
+
var TEXTURE_PROPS2 = {
|
|
1405
|
+
format: "rgba8unorm",
|
|
1406
|
+
mipmaps: false,
|
|
1407
|
+
sampler: {
|
|
1408
|
+
minFilter: "linear",
|
|
1409
|
+
magFilter: "linear",
|
|
1410
|
+
addressModeU: "clamp-to-edge",
|
|
1411
|
+
addressModeV: "clamp-to-edge"
|
|
1412
|
+
}
|
|
1413
|
+
};
|
|
1390
1414
|
function unitDensityForCell(cell) {
|
|
1391
1415
|
const cellResolution = Number((0, import_quadbin6.getResolution)(cell));
|
|
1392
1416
|
return Math.pow(4, cellResolution);
|
|
1393
1417
|
}
|
|
1418
|
+
function colorRangeToFlatArray(colorRange) {
|
|
1419
|
+
const flatArray = new Uint8Array(colorRange.length * 4);
|
|
1420
|
+
let index = 0;
|
|
1421
|
+
for (let i = 0; i < colorRange.length; i++) {
|
|
1422
|
+
const color = colorRange[i];
|
|
1423
|
+
flatArray[index++] = color[0];
|
|
1424
|
+
flatArray[index++] = color[1];
|
|
1425
|
+
flatArray[index++] = color[2];
|
|
1426
|
+
flatArray[index++] = Number.isFinite(color[3]) ? color[3] : 255;
|
|
1427
|
+
}
|
|
1428
|
+
return flatArray;
|
|
1429
|
+
}
|
|
1430
|
+
var uniformBlock = `uniform densityUniforms {
|
|
1431
|
+
float factor;
|
|
1432
|
+
} density;
|
|
1433
|
+
`;
|
|
1434
|
+
var densityUniforms = {
|
|
1435
|
+
name: "density",
|
|
1436
|
+
vs: uniformBlock,
|
|
1437
|
+
uniformTypes: {
|
|
1438
|
+
factor: "f32"
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1394
1441
|
var RTTSolidPolygonLayer = class extends RTTModifier(import_layers2.SolidPolygonLayer) {
|
|
1395
1442
|
getShaders(type) {
|
|
1396
1443
|
const shaders = super.getShaders(type);
|
|
1397
1444
|
shaders.inject = {
|
|
1398
|
-
"vs:#decl": `
|
|
1399
|
-
uniform float densityFactor;
|
|
1400
|
-
`,
|
|
1401
1445
|
"vs:#main-end": `
|
|
1402
1446
|
// Value from getWeight accessor
|
|
1403
1447
|
float weight = elevations;
|
|
1404
1448
|
|
|
1405
1449
|
// Keep "power" delivered to screen constant when tiles update
|
|
1406
|
-
// by outputting normalized density
|
|
1407
|
-
weight *=
|
|
1450
|
+
// by outputting normalized density
|
|
1451
|
+
weight *= density.factor;
|
|
1408
1452
|
|
|
1409
1453
|
// Pack float into 3 channels to pass to heatmap shader
|
|
1410
1454
|
// SCALE value important, as we don't want to saturate
|
|
@@ -1417,14 +1461,17 @@ uniform float densityFactor;
|
|
|
1417
1461
|
vColor = vec4(mod(vec3(weight, floor(weight / SHIFT.yz)), 256.0), 255.0) / 255.0;
|
|
1418
1462
|
`
|
|
1419
1463
|
};
|
|
1464
|
+
shaders.modules = [...shaders.modules, densityUniforms];
|
|
1420
1465
|
return shaders;
|
|
1421
1466
|
}
|
|
1422
1467
|
draw(opts) {
|
|
1423
1468
|
const cell = this.props.data[0];
|
|
1424
1469
|
const maxDensity = this.props.elevationScale;
|
|
1425
|
-
const
|
|
1470
|
+
const densityProps = {
|
|
1471
|
+
factor: unitDensityForCell(cell.id) / maxDensity
|
|
1472
|
+
};
|
|
1426
1473
|
for (const model of this.state.models) {
|
|
1427
|
-
model.
|
|
1474
|
+
model.shaderInputs.setProps({ density: densityProps });
|
|
1428
1475
|
}
|
|
1429
1476
|
super.draw(opts);
|
|
1430
1477
|
}
|
|
@@ -1436,6 +1483,7 @@ var defaultProps6 = {
|
|
|
1436
1483
|
getWeight: { type: "accessor", value: 1 },
|
|
1437
1484
|
onMaxDensityChange: { type: "function", optional: true, value: null },
|
|
1438
1485
|
colorDomain: { type: "array", value: [0, 1] },
|
|
1486
|
+
colorRange: defaultColorRange,
|
|
1439
1487
|
intensity: { type: "number", value: 1 },
|
|
1440
1488
|
radiusPixels: { type: "number", min: 0, max: 100, value: 20 }
|
|
1441
1489
|
};
|
|
@@ -1452,9 +1500,16 @@ var HeatmapTileLayer = class extends import_core11.CompositeLayer {
|
|
|
1452
1500
|
this.setState({ viewportChanged });
|
|
1453
1501
|
return changeFlags.somethingChanged;
|
|
1454
1502
|
}
|
|
1503
|
+
updateState(opts) {
|
|
1504
|
+
const { props, oldProps } = opts;
|
|
1505
|
+
super.updateState(opts);
|
|
1506
|
+
if (props.colorRange !== oldProps.colorRange) {
|
|
1507
|
+
this._updateColorTexture(opts);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1455
1510
|
renderLayers() {
|
|
1456
1511
|
var _a, _b, _c;
|
|
1457
|
-
const { data, getWeight, colorDomain,
|
|
1512
|
+
const { data, getWeight, colorDomain, intensity, radiusPixels, _subLayerProps, updateTriggers, onMaxDensityChange, onViewportLoad, onTileLoad, onTileUnload, ...tileLayerProps } = this.props;
|
|
1458
1513
|
const subLayerProps = {
|
|
1459
1514
|
..._subLayerProps,
|
|
1460
1515
|
cell: {
|
|
@@ -1486,20 +1541,24 @@ var HeatmapTileLayer = class extends import_core11.CompositeLayer {
|
|
|
1486
1541
|
return new PostProcessQuadbinTileLayer(tileLayerProps, this.getSubLayerProps({
|
|
1487
1542
|
id: "heatmap",
|
|
1488
1543
|
data,
|
|
1544
|
+
// Re-use existing props to pass down values to sublayer
|
|
1545
|
+
// TODO replace with custom layer
|
|
1489
1546
|
getFillColor: 0,
|
|
1490
1547
|
getElevation: getWeight,
|
|
1491
1548
|
elevationScale: maxDensity,
|
|
1492
1549
|
colorDomain,
|
|
1493
|
-
colorRange,
|
|
1494
1550
|
radiusPixels,
|
|
1495
1551
|
intensity,
|
|
1496
1552
|
_subLayerProps: subLayerProps,
|
|
1497
1553
|
refinementStrategy: "no-overlap",
|
|
1554
|
+
colorTexture: this.state.colorTexture,
|
|
1555
|
+
// Disable line rendering
|
|
1498
1556
|
extruded: false,
|
|
1499
1557
|
stroked: false,
|
|
1500
1558
|
updateTriggers: {
|
|
1501
1559
|
getElevation: updateTriggers.getWeight
|
|
1502
1560
|
},
|
|
1561
|
+
// Tile stats
|
|
1503
1562
|
onViewportLoad: (tiles2) => {
|
|
1504
1563
|
this.setState({ isLoaded: true });
|
|
1505
1564
|
if (typeof onViewportLoad === "function") {
|
|
@@ -1530,6 +1589,23 @@ var HeatmapTileLayer = class extends import_core11.CompositeLayer {
|
|
|
1530
1589
|
transitions: { elevationScale: { type: "spring", stiffness: 0.3, damping: 0.5 } }
|
|
1531
1590
|
}));
|
|
1532
1591
|
}
|
|
1592
|
+
_updateColorTexture(opts) {
|
|
1593
|
+
const { colorRange } = opts.props;
|
|
1594
|
+
let { colorTexture } = this.state;
|
|
1595
|
+
const colors = colorRangeToFlatArray(colorRange);
|
|
1596
|
+
if (colorTexture && (colorTexture == null ? void 0 : colorTexture.width) === colorRange.length) {
|
|
1597
|
+
colorTexture.setSubImageData({ data: colors });
|
|
1598
|
+
} else {
|
|
1599
|
+
colorTexture == null ? void 0 : colorTexture.destroy();
|
|
1600
|
+
colorTexture = this.context.device.createTexture({
|
|
1601
|
+
...TEXTURE_PROPS2,
|
|
1602
|
+
data: colors,
|
|
1603
|
+
width: colorRange.length,
|
|
1604
|
+
height: 1
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
this.setState({ colorTexture });
|
|
1608
|
+
}
|
|
1533
1609
|
};
|
|
1534
1610
|
HeatmapTileLayer.layerName = "HeatmapTileLayer";
|
|
1535
1611
|
HeatmapTileLayer.defaultProps = defaultProps6;
|
|
@@ -1543,8 +1619,8 @@ var EnhancedTextBackgroundLayer = class extends import_layers3._TextBackgroundLa
|
|
|
1543
1619
|
getShaders() {
|
|
1544
1620
|
const shaders = super.getShaders();
|
|
1545
1621
|
let vs = shaders.vs;
|
|
1546
|
-
vs = vs.replaceAll("padding.", "_padding.");
|
|
1547
|
-
vs = vs.replace("void main(void) {", "void main(void) {\n vec4 _padding = padding + instancePixelOffsets.xyxy * vec4(1.0, 1.0, -1.0, -1.0);");
|
|
1622
|
+
vs = vs.replaceAll("textBackground.padding.", "_padding.");
|
|
1623
|
+
vs = vs.replace("void main(void) {", "void main(void) {\n vec4 _padding = textBackground.padding + instancePixelOffsets.xyxy * vec4(1.0, 1.0, -1.0, -1.0);");
|
|
1548
1624
|
return { ...shaders, vs };
|
|
1549
1625
|
}
|
|
1550
1626
|
};
|
|
@@ -1647,16 +1723,20 @@ var PointLabelLayer = class extends import_core12.CompositeLayer {
|
|
|
1647
1723
|
const getPixelOffset = this.calculatePixelOffset(false);
|
|
1648
1724
|
const backgroundPadding = this.calculateBackgroundPadding();
|
|
1649
1725
|
const out = [
|
|
1726
|
+
// Text doesn't update via updateTrigger for some reason
|
|
1650
1727
|
this.renderTextLayer(`${updateTriggers.getText}-primary`, {
|
|
1651
1728
|
backgroundPadding,
|
|
1652
1729
|
getText,
|
|
1653
1730
|
getPixelOffset,
|
|
1654
1731
|
background: true
|
|
1732
|
+
// Only use background for primary label for faster collisions
|
|
1655
1733
|
}),
|
|
1656
1734
|
Boolean(getSecondaryText) && this.renderTextLayer(`${updateTriggers.getSecondaryText}-secondary`, {
|
|
1657
1735
|
getText: getSecondaryText,
|
|
1658
1736
|
getPixelOffset: this.calculatePixelOffset(true),
|
|
1659
1737
|
getAlignmentBaseline: "top",
|
|
1738
|
+
// updateTriggers: {getText: updateTriggers.getSecondaryText},
|
|
1739
|
+
// Optional overrides
|
|
1660
1740
|
...getSecondaryColor && { getColor: getSecondaryColor },
|
|
1661
1741
|
...secondarySizeScale && { sizeScale: secondarySizeScale },
|
|
1662
1742
|
...secondaryOutlineColor && { outlineColor: secondaryOutlineColor }
|
|
@@ -1685,38 +1765,30 @@ in float instanceElevations;
|
|
|
1685
1765
|
in vec4 instanceFillColors;
|
|
1686
1766
|
in vec4 instanceLineColors;
|
|
1687
1767
|
in vec3 instancePickingColors;
|
|
1688
|
-
uniform float opacity;
|
|
1689
|
-
uniform bool extruded;
|
|
1690
|
-
uniform bool stroked;
|
|
1691
|
-
uniform bool isStroke;
|
|
1692
|
-
uniform float coverage;
|
|
1693
|
-
uniform float elevationScale;
|
|
1694
|
-
uniform float widthScale;
|
|
1695
|
-
uniform vec3 offset;
|
|
1696
1768
|
out vec4 vColor;
|
|
1697
1769
|
#ifdef FLAT_SHADING
|
|
1698
1770
|
out vec4 position_commonspace;
|
|
1699
1771
|
#endif
|
|
1700
1772
|
void main(void) {
|
|
1701
|
-
vec2 common_position = offset.xy;
|
|
1702
|
-
float scale =
|
|
1773
|
+
vec2 common_position = column.offset.xy;
|
|
1774
|
+
float scale = column.widthScale;
|
|
1703
1775
|
int yIndex = - (gl_InstanceID / BLOCK_WIDTH);
|
|
1704
1776
|
int xIndex = gl_InstanceID + (yIndex * BLOCK_WIDTH);
|
|
1705
|
-
common_position += scale * vec2(float(xIndex), float(yIndex));
|
|
1706
|
-
vec4 color = isStroke ? instanceLineColors : instanceFillColors;
|
|
1777
|
+
common_position += scale * vec2(float(xIndex), float(yIndex - 1));
|
|
1778
|
+
vec4 color = column.isStroke ? instanceLineColors : instanceFillColors;
|
|
1707
1779
|
float shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0);
|
|
1708
|
-
float cellWidth = coverage * scale;
|
|
1780
|
+
float cellWidth = column.coverage * scale;
|
|
1709
1781
|
geometry.position = vec4(common_position, 0.0, 1.0);
|
|
1710
|
-
if (
|
|
1711
|
-
geometry.position.xyz -=
|
|
1782
|
+
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
|
|
1783
|
+
geometry.position.xyz -= project.commonOrigin;
|
|
1712
1784
|
}
|
|
1713
1785
|
float elevation = 0.0;
|
|
1714
1786
|
float strokeOffsetRatio = 1.0;
|
|
1715
|
-
if (extruded) {
|
|
1716
|
-
elevation = instanceElevations * (positions.z + 1.0) / 2.0 * elevationScale;
|
|
1717
|
-
} else if (stroked) {
|
|
1718
|
-
float halfOffset = project_pixel_size(widthScale) / cellWidth;
|
|
1719
|
-
if (isStroke) {
|
|
1787
|
+
if (column.extruded) {
|
|
1788
|
+
elevation = instanceElevations * (positions.z + 1.0) / 2.0 * column.elevationScale;
|
|
1789
|
+
} else if (column.stroked) {
|
|
1790
|
+
float halfOffset = project_pixel_size(column.widthScale) / cellWidth;
|
|
1791
|
+
if (column.isStroke) {
|
|
1720
1792
|
strokeOffsetRatio -= sign(positions.z) * halfOffset;
|
|
1721
1793
|
} else {
|
|
1722
1794
|
strokeOffsetRatio -= halfOffset;
|
|
@@ -1730,16 +1802,16 @@ geometry.position.xyz += pos;
|
|
|
1730
1802
|
gl_Position = project_common_position_to_clipspace(geometry.position);
|
|
1731
1803
|
geometry.normal = project_normal(normals);
|
|
1732
1804
|
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
|
1733
|
-
if (extruded && !isStroke) {
|
|
1805
|
+
if (column.extruded && !column.isStroke) {
|
|
1734
1806
|
#ifdef FLAT_SHADING
|
|
1735
1807
|
position_commonspace = geometry.position;
|
|
1736
|
-
vColor = vec4(color.rgb, color.a * opacity);
|
|
1808
|
+
vColor = vec4(color.rgb, color.a * layer.opacity);
|
|
1737
1809
|
#else
|
|
1738
|
-
vec3 lightColor = lighting_getLightColor(color.rgb,
|
|
1739
|
-
vColor = vec4(lightColor, color.a * opacity);
|
|
1810
|
+
vec3 lightColor = lighting_getLightColor(color.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
|
|
1811
|
+
vColor = vec4(lightColor, color.a * layer.opacity);
|
|
1740
1812
|
#endif
|
|
1741
1813
|
} else {
|
|
1742
|
-
vColor = vec4(color.rgb, color.a * opacity);
|
|
1814
|
+
vColor = vec4(color.rgb, color.a * layer.opacity);
|
|
1743
1815
|
}
|
|
1744
1816
|
DECKGL_FILTER_COLOR(vColor, geometry);
|
|
1745
1817
|
}
|
|
@@ -1800,7 +1872,8 @@ var RasterLayer = class extends import_core13.CompositeLayer {
|
|
|
1800
1872
|
return null;
|
|
1801
1873
|
const blockSize = data.blockSize ?? 0;
|
|
1802
1874
|
const [xOffset, yOffset, scale] = quadbinToOffset(tileIndex);
|
|
1803
|
-
const offset = [xOffset, yOffset
|
|
1875
|
+
const offset = [xOffset, yOffset];
|
|
1876
|
+
const lineWidthScale = scale / blockSize;
|
|
1804
1877
|
const CellLayer = this.getSubLayerClass("column", RasterColumnLayer);
|
|
1805
1878
|
const { highlightedObjectIndex, highlightColor } = this.state;
|
|
1806
1879
|
return new CellLayer(this.props, this.getSubLayerProps({
|
|
@@ -1813,10 +1886,13 @@ var RasterLayer = class extends import_core13.CompositeLayer {
|
|
|
1813
1886
|
}), {
|
|
1814
1887
|
data: {
|
|
1815
1888
|
data,
|
|
1889
|
+
// Pass through data for getSubLayerAccessor()
|
|
1816
1890
|
length: blockSize * blockSize
|
|
1817
1891
|
},
|
|
1818
1892
|
dataComparator: wrappedDataComparator,
|
|
1819
1893
|
offset,
|
|
1894
|
+
lineWidthScale,
|
|
1895
|
+
// Re-use widthScale prop to pass cell scale,
|
|
1820
1896
|
highlightedObjectIndex,
|
|
1821
1897
|
highlightColor
|
|
1822
1898
|
});
|
|
@@ -1889,17 +1965,17 @@ var RasterTileLayer = class extends import_core14.CompositeLayer {
|
|
|
1889
1965
|
if (!tileJSON)
|
|
1890
1966
|
return null;
|
|
1891
1967
|
const { tiles: data, minzoom: minZoom, maxzoom: maxZoom } = tileJSON;
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1968
|
+
const SubLayerClass = this.getSubLayerClass("tile", import_geo_layers7.TileLayer);
|
|
1969
|
+
return new SubLayerClass(this.props, {
|
|
1970
|
+
id: `raster-tile-layer-${this.props.id}`,
|
|
1971
|
+
data,
|
|
1972
|
+
// TODO: Tileset2D should be generic over TileIndex type
|
|
1973
|
+
TilesetClass: QuadbinTileset2D,
|
|
1974
|
+
renderSubLayers: renderSubLayers3,
|
|
1975
|
+
minZoom,
|
|
1976
|
+
maxZoom,
|
|
1977
|
+
loadOptions: this.getLoadOptions()
|
|
1978
|
+
});
|
|
1903
1979
|
}
|
|
1904
1980
|
};
|
|
1905
1981
|
RasterTileLayer.layerName = "RasterTileLayer";
|
|
@@ -1947,7 +2023,7 @@ var carto_properties_tile_loader_default = CartoPropertiesTileLoader;
|
|
|
1947
2023
|
|
|
1948
2024
|
// dist/layers/schema/carto-vector-tile-loader.js
|
|
1949
2025
|
var import_earcut = __toESM(require("earcut"), 1);
|
|
1950
|
-
var VERSION3 = true ? "9.0.
|
|
2026
|
+
var VERSION3 = true ? "9.1.0-beta.1" : "latest";
|
|
1951
2027
|
var id3 = "cartoVectorTile";
|
|
1952
2028
|
var DEFAULT_OPTIONS3 = {
|
|
1953
2029
|
cartoVectorTile: {
|
|
@@ -2038,6 +2114,7 @@ var VectorTileLayer = class extends import_geo_layers8.MVTLayer {
|
|
|
2038
2114
|
loadOptions.gis = { format: "binary" };
|
|
2039
2115
|
return loadOptions;
|
|
2040
2116
|
}
|
|
2117
|
+
/* eslint-disable camelcase */
|
|
2041
2118
|
async getTileData(tile) {
|
|
2042
2119
|
const tileJSON = this.props.data;
|
|
2043
2120
|
const { tiles, properties_tiles } = tileJSON;
|
|
@@ -2067,6 +2144,7 @@ var VectorTileLayer = class extends import_geo_layers8.MVTLayer {
|
|
|
2067
2144
|
return null;
|
|
2068
2145
|
return attributes ? mergeBoundaryData(geometry, attributes) : geometry;
|
|
2069
2146
|
}
|
|
2147
|
+
/* eslint-enable camelcase */
|
|
2070
2148
|
renderSubLayers(props) {
|
|
2071
2149
|
if (props.data === null) {
|
|
2072
2150
|
return null;
|
|
@@ -2093,6 +2171,7 @@ var VectorTileLayer = class extends import_geo_layers8.MVTLayer {
|
|
|
2093
2171
|
const subLayerProps = {
|
|
2094
2172
|
...props,
|
|
2095
2173
|
autoHighlight: false,
|
|
2174
|
+
// Do not perform clipping on points (#9059)
|
|
2096
2175
|
_subLayerProps: {
|
|
2097
2176
|
...props._subLayerProps,
|
|
2098
2177
|
...applyClipExtensionToSublayerProps("polygons-fill"),
|
|
@@ -2113,47 +2192,8 @@ VectorTileLayer.layerName = "VectorTileLayer";
|
|
|
2113
2192
|
VectorTileLayer.defaultProps = defaultProps10;
|
|
2114
2193
|
var vector_tile_layer_default = VectorTileLayer;
|
|
2115
2194
|
|
|
2116
|
-
// dist/api/carto-api-error.js
|
|
2117
|
-
var CartoAPIError = class extends Error {
|
|
2118
|
-
constructor(error, errorContext, response, responseJson) {
|
|
2119
|
-
let responseString = "Failed to connect";
|
|
2120
|
-
if (response) {
|
|
2121
|
-
responseString = "Server returned: ";
|
|
2122
|
-
if (response.status === 400) {
|
|
2123
|
-
responseString += "Bad request";
|
|
2124
|
-
} else if (response.status === 401 || response.status === 403) {
|
|
2125
|
-
responseString += "Unauthorized access";
|
|
2126
|
-
} else if (response.status === 404) {
|
|
2127
|
-
responseString += "Not found";
|
|
2128
|
-
} else {
|
|
2129
|
-
responseString += "Error";
|
|
2130
|
-
}
|
|
2131
|
-
responseString += ` (${response.status}):`;
|
|
2132
|
-
}
|
|
2133
|
-
responseString += ` ${error.message || error}`;
|
|
2134
|
-
let message = `${errorContext.requestType} API request failed`;
|
|
2135
|
-
message += `
|
|
2136
|
-
${responseString}`;
|
|
2137
|
-
for (const key of Object.keys(errorContext)) {
|
|
2138
|
-
if (key === "requestType")
|
|
2139
|
-
continue;
|
|
2140
|
-
message += `
|
|
2141
|
-
${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
2142
|
-
}
|
|
2143
|
-
message += "\n";
|
|
2144
|
-
super(message);
|
|
2145
|
-
this.name = "CartoAPIError";
|
|
2146
|
-
this.response = response;
|
|
2147
|
-
this.responseJson = responseJson;
|
|
2148
|
-
this.error = error;
|
|
2149
|
-
this.errorContext = errorContext;
|
|
2150
|
-
}
|
|
2151
|
-
};
|
|
2152
|
-
function formatErrorKey(key) {
|
|
2153
|
-
return key.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase());
|
|
2154
|
-
}
|
|
2155
|
-
|
|
2156
2195
|
// dist/basemap.js
|
|
2196
|
+
var import_api_client = require("@carto/api-client");
|
|
2157
2197
|
var cartoStyleUrlTemplate = "https://basemaps.cartocdn.com/gl/{basemap}-gl-style/style.json";
|
|
2158
2198
|
var CARTO_MAP_STYLES = ["positron", "dark-matter", "voyager"];
|
|
2159
2199
|
var GOOGLE_BASEMAPS = {
|
|
@@ -2238,7 +2278,7 @@ async function fetchStyle({ styleUrl, errorContext }) {
|
|
|
2238
2278
|
response = res;
|
|
2239
2279
|
return res.json();
|
|
2240
2280
|
}).catch((error) => {
|
|
2241
|
-
throw new CartoAPIError(error, { ...errorContext, requestType: "Basemap style" }, response);
|
|
2281
|
+
throw new import_api_client.CartoAPIError(error, { ...errorContext, requestType: "Basemap style" }, response);
|
|
2242
2282
|
});
|
|
2243
2283
|
}
|
|
2244
2284
|
var basemap_default = {
|
|
@@ -2358,343 +2398,11 @@ function colorContinuous({ attr, domain, colors = DEFAULT_PALETTE, nullColor = N
|
|
|
2358
2398
|
};
|
|
2359
2399
|
}
|
|
2360
2400
|
|
|
2361
|
-
// dist/api/
|
|
2362
|
-
var
|
|
2363
|
-
var DEFAULT_CLIENT = "deck-gl-carto";
|
|
2364
|
-
var V3_MINOR_VERSION = "3.4";
|
|
2365
|
-
var DEFAULT_MAX_LENGTH_URL = 7e3;
|
|
2366
|
-
|
|
2367
|
-
// dist/api/endpoints.js
|
|
2368
|
-
function joinPath(...args) {
|
|
2369
|
-
return args.map((part) => part.endsWith("/") ? part.slice(0, -1) : part).join("/");
|
|
2370
|
-
}
|
|
2371
|
-
function buildV3Path(apiBaseUrl, version, endpoint, ...rest) {
|
|
2372
|
-
return joinPath(apiBaseUrl, version, endpoint, ...rest);
|
|
2373
|
-
}
|
|
2374
|
-
function buildPublicMapUrl({ apiBaseUrl, cartoMapId }) {
|
|
2375
|
-
return buildV3Path(apiBaseUrl, "v3", "maps", "public", cartoMapId);
|
|
2376
|
-
}
|
|
2377
|
-
function buildStatsUrl({ attribute, apiBaseUrl, connectionName, source, type }) {
|
|
2378
|
-
if (type === "query") {
|
|
2379
|
-
return buildV3Path(apiBaseUrl, "v3", "stats", connectionName, attribute);
|
|
2380
|
-
}
|
|
2381
|
-
return buildV3Path(apiBaseUrl, "v3", "stats", connectionName, source, attribute);
|
|
2382
|
-
}
|
|
2383
|
-
function buildSourceUrl({ apiBaseUrl, connectionName, endpoint }) {
|
|
2384
|
-
return buildV3Path(apiBaseUrl, "v3", "maps", connectionName, endpoint);
|
|
2385
|
-
}
|
|
2386
|
-
function buildQueryUrl({ apiBaseUrl, connectionName }) {
|
|
2387
|
-
return buildV3Path(apiBaseUrl, "v3", "sql", connectionName, "query");
|
|
2388
|
-
}
|
|
2389
|
-
|
|
2390
|
-
// dist/api/request-with-parameters.js
|
|
2391
|
-
var import_core16 = require("@deck.gl/core");
|
|
2392
|
-
var DEFAULT_PARAMETERS = {
|
|
2393
|
-
v: V3_MINOR_VERSION,
|
|
2394
|
-
deckglVersion: import_core16.VERSION
|
|
2395
|
-
};
|
|
2396
|
-
var DEFAULT_HEADERS = {
|
|
2397
|
-
Accept: "application/json",
|
|
2398
|
-
"Content-Type": "application/json"
|
|
2399
|
-
};
|
|
2400
|
-
var REQUEST_CACHE = /* @__PURE__ */ new Map();
|
|
2401
|
-
async function requestWithParameters({ baseUrl, parameters = {}, headers: customHeaders = {}, errorContext, maxLengthURL = DEFAULT_MAX_LENGTH_URL }) {
|
|
2402
|
-
parameters = { ...DEFAULT_PARAMETERS, ...parameters };
|
|
2403
|
-
baseUrl = excludeURLParameters(baseUrl, Object.keys(parameters));
|
|
2404
|
-
const key = createCacheKey(baseUrl, parameters, customHeaders);
|
|
2405
|
-
if (REQUEST_CACHE.has(key)) {
|
|
2406
|
-
return REQUEST_CACHE.get(key);
|
|
2407
|
-
}
|
|
2408
|
-
const url = createURLWithParameters(baseUrl, parameters);
|
|
2409
|
-
const headers = { ...DEFAULT_HEADERS, ...customHeaders };
|
|
2410
|
-
const fetchPromise = url.length > maxLengthURL ? fetch(baseUrl, { method: "POST", body: JSON.stringify(parameters), headers }) : fetch(url, { headers });
|
|
2411
|
-
let response;
|
|
2412
|
-
let responseJson;
|
|
2413
|
-
const jsonPromise = fetchPromise.then((_response) => {
|
|
2414
|
-
response = _response;
|
|
2415
|
-
return response.json();
|
|
2416
|
-
}).then((json) => {
|
|
2417
|
-
responseJson = json;
|
|
2418
|
-
if (!response || !response.ok) {
|
|
2419
|
-
throw new Error(json.error);
|
|
2420
|
-
}
|
|
2421
|
-
return json;
|
|
2422
|
-
}).catch((error) => {
|
|
2423
|
-
REQUEST_CACHE.delete(key);
|
|
2424
|
-
throw new CartoAPIError(error, errorContext, response, responseJson);
|
|
2425
|
-
});
|
|
2426
|
-
REQUEST_CACHE.set(key, jsonPromise);
|
|
2427
|
-
return jsonPromise;
|
|
2428
|
-
}
|
|
2429
|
-
function createCacheKey(baseUrl, parameters, headers) {
|
|
2430
|
-
const parameterEntries = Object.entries(parameters).sort(([a], [b]) => a > b ? 1 : -1);
|
|
2431
|
-
const headerEntries = Object.entries(headers).sort(([a], [b]) => a > b ? 1 : -1);
|
|
2432
|
-
return JSON.stringify({ baseUrl, parameters: parameterEntries, headers: headerEntries });
|
|
2433
|
-
}
|
|
2434
|
-
function createURLWithParameters(baseUrlString, parameters) {
|
|
2435
|
-
const baseUrl = new URL(baseUrlString);
|
|
2436
|
-
for (const [key, value] of Object.entries(parameters)) {
|
|
2437
|
-
if (isPureObject(value) || Array.isArray(value)) {
|
|
2438
|
-
baseUrl.searchParams.set(key, JSON.stringify(value));
|
|
2439
|
-
} else {
|
|
2440
|
-
baseUrl.searchParams.set(key, value.toString());
|
|
2441
|
-
}
|
|
2442
|
-
}
|
|
2443
|
-
return baseUrl.toString();
|
|
2444
|
-
}
|
|
2445
|
-
function excludeURLParameters(baseUrlString, parameters) {
|
|
2446
|
-
const baseUrl = new URL(baseUrlString);
|
|
2447
|
-
for (const param of parameters) {
|
|
2448
|
-
if (baseUrl.searchParams.has(param)) {
|
|
2449
|
-
baseUrl.searchParams.delete(param);
|
|
2450
|
-
}
|
|
2451
|
-
}
|
|
2452
|
-
return baseUrl.toString();
|
|
2453
|
-
}
|
|
2454
|
-
|
|
2455
|
-
// dist/sources/base-source.js
|
|
2456
|
-
var SOURCE_DEFAULTS = {
|
|
2457
|
-
apiBaseUrl: DEFAULT_API_BASE_URL,
|
|
2458
|
-
clientId: DEFAULT_CLIENT,
|
|
2459
|
-
format: "tilejson",
|
|
2460
|
-
headers: {},
|
|
2461
|
-
maxLengthURL: DEFAULT_MAX_LENGTH_URL
|
|
2462
|
-
};
|
|
2463
|
-
async function baseSource(endpoint, options, urlParameters) {
|
|
2464
|
-
const { accessToken, connectionName, cache, ...optionalOptions } = options;
|
|
2465
|
-
const mergedOptions = { ...SOURCE_DEFAULTS, accessToken, connectionName, endpoint };
|
|
2466
|
-
for (const key in optionalOptions) {
|
|
2467
|
-
if (optionalOptions[key]) {
|
|
2468
|
-
mergedOptions[key] = optionalOptions[key];
|
|
2469
|
-
}
|
|
2470
|
-
}
|
|
2471
|
-
const baseUrl = buildSourceUrl(mergedOptions);
|
|
2472
|
-
const { clientId, maxLengthURL, format } = mergedOptions;
|
|
2473
|
-
const headers = { Authorization: `Bearer ${options.accessToken}`, ...options.headers };
|
|
2474
|
-
const parameters = { client: clientId, ...urlParameters };
|
|
2475
|
-
const errorContext = {
|
|
2476
|
-
requestType: "Map instantiation",
|
|
2477
|
-
connection: options.connectionName,
|
|
2478
|
-
type: endpoint,
|
|
2479
|
-
source: JSON.stringify(parameters, void 0, 2)
|
|
2480
|
-
};
|
|
2481
|
-
const mapInstantiation = await requestWithParameters({
|
|
2482
|
-
baseUrl,
|
|
2483
|
-
parameters,
|
|
2484
|
-
headers,
|
|
2485
|
-
errorContext,
|
|
2486
|
-
maxLengthURL
|
|
2487
|
-
});
|
|
2488
|
-
const dataUrl = mapInstantiation[format].url[0];
|
|
2489
|
-
if (cache) {
|
|
2490
|
-
cache.value = parseInt(new URL(dataUrl).searchParams.get("cache") || "", 10);
|
|
2491
|
-
}
|
|
2492
|
-
errorContext.requestType = "Map data";
|
|
2493
|
-
if (format === "tilejson") {
|
|
2494
|
-
const json = await requestWithParameters({
|
|
2495
|
-
baseUrl: dataUrl,
|
|
2496
|
-
headers,
|
|
2497
|
-
errorContext,
|
|
2498
|
-
maxLengthURL
|
|
2499
|
-
});
|
|
2500
|
-
if (accessToken) {
|
|
2501
|
-
json.accessToken = accessToken;
|
|
2502
|
-
}
|
|
2503
|
-
return json;
|
|
2504
|
-
}
|
|
2505
|
-
return await requestWithParameters({
|
|
2506
|
-
baseUrl: dataUrl,
|
|
2507
|
-
headers,
|
|
2508
|
-
errorContext,
|
|
2509
|
-
maxLengthURL
|
|
2510
|
-
});
|
|
2511
|
-
}
|
|
2512
|
-
|
|
2513
|
-
// dist/sources/boundary-query-source.js
|
|
2514
|
-
var boundaryQuerySource = async function(options) {
|
|
2515
|
-
const { columns, filters, tilesetTableName, propertiesSqlQuery, queryParameters } = options;
|
|
2516
|
-
const urlParameters = {
|
|
2517
|
-
tilesetTableName,
|
|
2518
|
-
propertiesSqlQuery
|
|
2519
|
-
};
|
|
2520
|
-
if (columns) {
|
|
2521
|
-
urlParameters.columns = columns.join(",");
|
|
2522
|
-
}
|
|
2523
|
-
if (filters) {
|
|
2524
|
-
urlParameters.filters = filters;
|
|
2525
|
-
}
|
|
2526
|
-
if (queryParameters) {
|
|
2527
|
-
urlParameters.queryParameters = queryParameters;
|
|
2528
|
-
}
|
|
2529
|
-
return baseSource("boundary", options, urlParameters);
|
|
2530
|
-
};
|
|
2531
|
-
|
|
2532
|
-
// dist/sources/boundary-table-source.js
|
|
2533
|
-
var boundaryTableSource = async function(options) {
|
|
2534
|
-
const { filters, tilesetTableName, columns, propertiesTableName } = options;
|
|
2535
|
-
const urlParameters = {
|
|
2536
|
-
tilesetTableName,
|
|
2537
|
-
propertiesTableName
|
|
2538
|
-
};
|
|
2539
|
-
if (columns) {
|
|
2540
|
-
urlParameters.columns = columns.join(",");
|
|
2541
|
-
}
|
|
2542
|
-
if (filters) {
|
|
2543
|
-
urlParameters.filters = filters;
|
|
2544
|
-
}
|
|
2545
|
-
return baseSource("boundary", options, urlParameters);
|
|
2546
|
-
};
|
|
2547
|
-
|
|
2548
|
-
// dist/sources/h3-query-source.js
|
|
2549
|
-
var h3QuerySource = async function(options) {
|
|
2550
|
-
const { aggregationExp, aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3, sqlQuery, spatialDataColumn = "h3", queryParameters, filters } = options;
|
|
2551
|
-
const urlParameters = {
|
|
2552
|
-
aggregationExp,
|
|
2553
|
-
spatialDataColumn,
|
|
2554
|
-
spatialDataType: "h3",
|
|
2555
|
-
q: sqlQuery
|
|
2556
|
-
};
|
|
2557
|
-
if (aggregationResLevel) {
|
|
2558
|
-
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
2559
|
-
}
|
|
2560
|
-
if (queryParameters) {
|
|
2561
|
-
urlParameters.queryParameters = queryParameters;
|
|
2562
|
-
}
|
|
2563
|
-
if (filters) {
|
|
2564
|
-
urlParameters.filters = filters;
|
|
2565
|
-
}
|
|
2566
|
-
return baseSource("query", options, urlParameters);
|
|
2567
|
-
};
|
|
2568
|
-
|
|
2569
|
-
// dist/sources/h3-table-source.js
|
|
2570
|
-
var h3TableSource = async function(options) {
|
|
2571
|
-
const { aggregationExp, aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3, spatialDataColumn = "h3", tableName, filters } = options;
|
|
2572
|
-
const urlParameters = {
|
|
2573
|
-
aggregationExp,
|
|
2574
|
-
name: tableName,
|
|
2575
|
-
spatialDataColumn,
|
|
2576
|
-
spatialDataType: "h3"
|
|
2577
|
-
};
|
|
2578
|
-
if (aggregationResLevel) {
|
|
2579
|
-
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
2580
|
-
}
|
|
2581
|
-
if (filters) {
|
|
2582
|
-
urlParameters.filters = filters;
|
|
2583
|
-
}
|
|
2584
|
-
return baseSource("table", options, urlParameters);
|
|
2585
|
-
};
|
|
2586
|
-
|
|
2587
|
-
// dist/sources/h3-tileset-source.js
|
|
2588
|
-
var h3TilesetSource = async function(options) {
|
|
2589
|
-
const { tableName } = options;
|
|
2590
|
-
const urlParameters = { name: tableName };
|
|
2591
|
-
return baseSource("tileset", options, urlParameters);
|
|
2592
|
-
};
|
|
2593
|
-
|
|
2594
|
-
// dist/sources/raster-source.js
|
|
2595
|
-
var rasterSource = async function(options) {
|
|
2596
|
-
const { tableName, filters } = options;
|
|
2597
|
-
const urlParameters = { name: tableName };
|
|
2598
|
-
if (filters) {
|
|
2599
|
-
urlParameters.filters = filters;
|
|
2600
|
-
}
|
|
2601
|
-
return baseSource("raster", options, urlParameters);
|
|
2602
|
-
};
|
|
2603
|
-
|
|
2604
|
-
// dist/sources/quadbin-query-source.js
|
|
2605
|
-
var quadbinQuerySource = async function(options) {
|
|
2606
|
-
const { aggregationExp, aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN, sqlQuery, spatialDataColumn = "quadbin", queryParameters, filters } = options;
|
|
2607
|
-
const urlParameters = {
|
|
2608
|
-
aggregationExp,
|
|
2609
|
-
q: sqlQuery,
|
|
2610
|
-
spatialDataColumn,
|
|
2611
|
-
spatialDataType: "quadbin"
|
|
2612
|
-
};
|
|
2613
|
-
if (aggregationResLevel) {
|
|
2614
|
-
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
2615
|
-
}
|
|
2616
|
-
if (queryParameters) {
|
|
2617
|
-
urlParameters.queryParameters = queryParameters;
|
|
2618
|
-
}
|
|
2619
|
-
if (filters) {
|
|
2620
|
-
urlParameters.filters = filters;
|
|
2621
|
-
}
|
|
2622
|
-
return baseSource("query", options, urlParameters);
|
|
2623
|
-
};
|
|
2624
|
-
|
|
2625
|
-
// dist/sources/quadbin-table-source.js
|
|
2626
|
-
var quadbinTableSource = async function(options) {
|
|
2627
|
-
const { aggregationExp, aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN, spatialDataColumn = "quadbin", tableName, filters } = options;
|
|
2628
|
-
const urlParameters = {
|
|
2629
|
-
aggregationExp,
|
|
2630
|
-
name: tableName,
|
|
2631
|
-
spatialDataColumn,
|
|
2632
|
-
spatialDataType: "quadbin"
|
|
2633
|
-
};
|
|
2634
|
-
if (aggregationResLevel) {
|
|
2635
|
-
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
2636
|
-
}
|
|
2637
|
-
if (filters) {
|
|
2638
|
-
urlParameters.filters = filters;
|
|
2639
|
-
}
|
|
2640
|
-
return baseSource("table", options, urlParameters);
|
|
2641
|
-
};
|
|
2642
|
-
|
|
2643
|
-
// dist/sources/quadbin-tileset-source.js
|
|
2644
|
-
var quadbinTilesetSource = async function(options) {
|
|
2645
|
-
const { tableName } = options;
|
|
2646
|
-
const urlParameters = { name: tableName };
|
|
2647
|
-
return baseSource("tileset", options, urlParameters);
|
|
2648
|
-
};
|
|
2649
|
-
|
|
2650
|
-
// dist/sources/vector-query-source.js
|
|
2651
|
-
var vectorQuerySource = async function(options) {
|
|
2652
|
-
const { columns, filters, spatialDataColumn = "geom", sqlQuery, tileResolution = DEFAULT_TILE_RESOLUTION, queryParameters } = options;
|
|
2653
|
-
const urlParameters = {
|
|
2654
|
-
spatialDataColumn,
|
|
2655
|
-
spatialDataType: "geo",
|
|
2656
|
-
tileResolution: tileResolution.toString(),
|
|
2657
|
-
q: sqlQuery
|
|
2658
|
-
};
|
|
2659
|
-
if (columns) {
|
|
2660
|
-
urlParameters.columns = columns.join(",");
|
|
2661
|
-
}
|
|
2662
|
-
if (filters) {
|
|
2663
|
-
urlParameters.filters = filters;
|
|
2664
|
-
}
|
|
2665
|
-
if (queryParameters) {
|
|
2666
|
-
urlParameters.queryParameters = queryParameters;
|
|
2667
|
-
}
|
|
2668
|
-
return baseSource("query", options, urlParameters);
|
|
2669
|
-
};
|
|
2670
|
-
|
|
2671
|
-
// dist/sources/vector-table-source.js
|
|
2672
|
-
var vectorTableSource = async function(options) {
|
|
2673
|
-
const { columns, filters, spatialDataColumn = "geom", tableName, tileResolution = DEFAULT_TILE_RESOLUTION } = options;
|
|
2674
|
-
const urlParameters = {
|
|
2675
|
-
name: tableName,
|
|
2676
|
-
spatialDataColumn,
|
|
2677
|
-
spatialDataType: "geo",
|
|
2678
|
-
tileResolution: tileResolution.toString()
|
|
2679
|
-
};
|
|
2680
|
-
if (columns) {
|
|
2681
|
-
urlParameters.columns = columns.join(",");
|
|
2682
|
-
}
|
|
2683
|
-
if (filters) {
|
|
2684
|
-
urlParameters.filters = filters;
|
|
2685
|
-
}
|
|
2686
|
-
return baseSource("table", options, urlParameters);
|
|
2687
|
-
};
|
|
2688
|
-
|
|
2689
|
-
// dist/sources/vector-tileset-source.js
|
|
2690
|
-
var vectorTilesetSource = async function(options) {
|
|
2691
|
-
const { tableName } = options;
|
|
2692
|
-
const urlParameters = { name: tableName };
|
|
2693
|
-
return baseSource("tileset", options, urlParameters);
|
|
2694
|
-
};
|
|
2401
|
+
// dist/api/fetch-map.js
|
|
2402
|
+
var import_api_client2 = require("@carto/api-client");
|
|
2695
2403
|
|
|
2696
2404
|
// dist/api/parse-map.js
|
|
2697
|
-
var
|
|
2405
|
+
var import_core16 = require("@deck.gl/core");
|
|
2698
2406
|
|
|
2699
2407
|
// dist/api/layer-map.js
|
|
2700
2408
|
var import_d3_array = require("d3-array");
|
|
@@ -2734,6 +2442,7 @@ var OPACITY_MAP = {
|
|
|
2734
2442
|
var AGGREGATION_FUNC = {
|
|
2735
2443
|
"count unique": (values, accessor) => (0, import_d3_array.groupSort)(values, (v) => v.length, accessor).length,
|
|
2736
2444
|
median: import_d3_array.median,
|
|
2445
|
+
// Unfortunately mode() is only available in d3-array@3+ which is ESM only
|
|
2737
2446
|
mode: (values, accessor) => (0, import_d3_array.groupSort)(values, (v) => v.length, accessor).pop(),
|
|
2738
2447
|
stddev: import_d3_array.deviation,
|
|
2739
2448
|
variance: import_d3_array.variance
|
|
@@ -2752,12 +2461,14 @@ var hexToRGBA = (c) => {
|
|
|
2752
2461
|
return [r, g, b, 255 * opacity];
|
|
2753
2462
|
};
|
|
2754
2463
|
var sharedPropMap = {
|
|
2464
|
+
// Apply the value of Kepler `color` prop to the deck `getFillColor` prop
|
|
2755
2465
|
color: "getFillColor",
|
|
2756
2466
|
isVisible: "visible",
|
|
2757
2467
|
label: "cartoLabel",
|
|
2758
2468
|
textLabel: {
|
|
2759
2469
|
alignment: "getTextAlignmentBaseline",
|
|
2760
2470
|
anchor: "getTextAnchor",
|
|
2471
|
+
// Apply the value of Kepler `textLabel.color` prop to the deck `getTextColor` prop
|
|
2761
2472
|
color: "getTextColor",
|
|
2762
2473
|
size: "getTextSize"
|
|
2763
2474
|
},
|
|
@@ -2830,7 +2541,7 @@ function getLayer(type, config, dataset) {
|
|
|
2830
2541
|
Layer: import_layers6.GeoJsonLayer
|
|
2831
2542
|
},
|
|
2832
2543
|
grid: {
|
|
2833
|
-
Layer: import_aggregation_layers.
|
|
2544
|
+
Layer: import_aggregation_layers.GridLayer,
|
|
2834
2545
|
propMap: { visConfig: { ...aggregationVisConfig, worldUnitSize: (x) => ({ cellSize: 1e3 * x }) } },
|
|
2835
2546
|
defaultProps: { getPosition }
|
|
2836
2547
|
},
|
|
@@ -3069,6 +2780,7 @@ function parseMap(json) {
|
|
|
3069
2780
|
createdAt: json.createdAt,
|
|
3070
2781
|
updatedAt: json.updatedAt,
|
|
3071
2782
|
initialViewState: mapState,
|
|
2783
|
+
/** @deprecated Use `basemap`. */
|
|
3072
2784
|
mapStyle,
|
|
3073
2785
|
token,
|
|
3074
2786
|
layers: layers.reverse().map(({ id: id4, type, config, visualChannels }) => {
|
|
@@ -3087,11 +2799,13 @@ function parseMap(json) {
|
|
|
3087
2799
|
...createInteractionProps(interactionConfig),
|
|
3088
2800
|
...styleProps,
|
|
3089
2801
|
...createChannelProps(id4, type, config, visualChannels, data),
|
|
2802
|
+
// Must come after style
|
|
3090
2803
|
...createParametersProp(layerBlending, styleProps.parameters || {}),
|
|
2804
|
+
// Must come after style
|
|
3091
2805
|
...createLoadOptions(token)
|
|
3092
2806
|
});
|
|
3093
2807
|
} catch (e) {
|
|
3094
|
-
|
|
2808
|
+
import_core16.log.error(e.message)();
|
|
3095
2809
|
return void 0;
|
|
3096
2810
|
}
|
|
3097
2811
|
})
|
|
@@ -3178,6 +2892,7 @@ function createChannelProps(id4, type, config, visualChannels, data) {
|
|
|
3178
2892
|
const { colorAggregation: aggregation, colorRange: range } = visConfig;
|
|
3179
2893
|
result.getFillColor = getColorAccessor(
|
|
3180
2894
|
colorField,
|
|
2895
|
+
// @ts-ignore
|
|
3181
2896
|
colorScale,
|
|
3182
2897
|
{ aggregation, range },
|
|
3183
2898
|
visConfig.opacity,
|
|
@@ -3200,7 +2915,9 @@ function createChannelProps(id4, type, config, visualChannels, data) {
|
|
|
3200
2915
|
}
|
|
3201
2916
|
if (radiusField || sizeField) {
|
|
3202
2917
|
result.getPointRadius = getSizeAccessor(
|
|
2918
|
+
// @ts-ignore
|
|
3203
2919
|
radiusField || sizeField,
|
|
2920
|
+
// @ts-ignore
|
|
3204
2921
|
radiusScale || sizeScale,
|
|
3205
2922
|
visConfig.sizeAggregation,
|
|
3206
2923
|
visConfig.radiusRange || visConfig.sizeRange,
|
|
@@ -3213,7 +2930,9 @@ function createChannelProps(id4, type, config, visualChannels, data) {
|
|
|
3213
2930
|
const { strokeColorAggregation: aggregation, strokeColorRange: range } = visConfig;
|
|
3214
2931
|
result.getLineColor = getColorAccessor(
|
|
3215
2932
|
strokeColorField,
|
|
2933
|
+
// @ts-ignore
|
|
3216
2934
|
strokeColorScale,
|
|
2935
|
+
// @ts-ignore
|
|
3217
2936
|
{ aggregation, range },
|
|
3218
2937
|
opacity,
|
|
3219
2938
|
data
|
|
@@ -3222,6 +2941,7 @@ function createChannelProps(id4, type, config, visualChannels, data) {
|
|
|
3222
2941
|
if (heightField && visConfig.enable3d) {
|
|
3223
2942
|
result.getElevation = getSizeAccessor(
|
|
3224
2943
|
heightField,
|
|
2944
|
+
// @ts-ignore
|
|
3225
2945
|
heightScale,
|
|
3226
2946
|
visConfig.heightAggregation,
|
|
3227
2947
|
visConfig.heightRange || visConfig.sizeRange,
|
|
@@ -3289,6 +3009,7 @@ function createChannelProps(id4, type, config, visualChannels, data) {
|
|
|
3289
3009
|
extensions: [collisionFilterExtension],
|
|
3290
3010
|
collisionEnabled: true,
|
|
3291
3011
|
collisionGroup,
|
|
3012
|
+
// getPointRadius already has radiusScale baked in, so only pass one or the other
|
|
3292
3013
|
...result.getPointRadius ? { getRadius: result.getPointRadius } : { radiusScale: visConfig.radius },
|
|
3293
3014
|
...secondaryField && {
|
|
3294
3015
|
getSecondaryText,
|
|
@@ -3377,7 +3098,7 @@ async function fetchBasemapProps({ config, errorContext, applyLayerFilters = tru
|
|
|
3377
3098
|
}
|
|
3378
3099
|
|
|
3379
3100
|
// dist/api/fetch-map.js
|
|
3380
|
-
async function _fetchMapDataset(dataset, accessToken, apiBaseUrl, clientId, headers, maxLengthURL =
|
|
3101
|
+
async function _fetchMapDataset(dataset, accessToken, apiBaseUrl, clientId, headers, maxLengthURL = import_api_client2.SOURCE_DEFAULTS.maxLengthURL) {
|
|
3381
3102
|
const { aggregationExp, aggregationResLevel, connectionName, columns, format, geoColumn, source, type, queryParameters } = dataset;
|
|
3382
3103
|
const cache = {};
|
|
3383
3104
|
const globalOptions = {
|
|
@@ -3391,15 +3112,15 @@ async function _fetchMapDataset(dataset, accessToken, apiBaseUrl, clientId, head
|
|
|
3391
3112
|
maxLengthURL
|
|
3392
3113
|
};
|
|
3393
3114
|
if (type === "tileset") {
|
|
3394
|
-
dataset.data = await vectorTilesetSource({ ...globalOptions, tableName: source });
|
|
3115
|
+
dataset.data = await (0, import_api_client2.vectorTilesetSource)({ ...globalOptions, tableName: source });
|
|
3395
3116
|
} else {
|
|
3396
3117
|
const [spatialDataType, spatialDataColumn] = geoColumn ? geoColumn.split(":") : ["geom"];
|
|
3397
3118
|
if (spatialDataType === "geom") {
|
|
3398
3119
|
const options = { ...globalOptions, spatialDataColumn };
|
|
3399
3120
|
if (type === "table") {
|
|
3400
|
-
dataset.data = await vectorTableSource({ ...options, columns, tableName: source });
|
|
3121
|
+
dataset.data = await (0, import_api_client2.vectorTableSource)({ ...options, columns, tableName: source });
|
|
3401
3122
|
} else if (type === "query") {
|
|
3402
|
-
dataset.data = await vectorQuerySource({
|
|
3123
|
+
dataset.data = await (0, import_api_client2.vectorQuerySource)({
|
|
3403
3124
|
...options,
|
|
3404
3125
|
columns,
|
|
3405
3126
|
sqlQuery: source,
|
|
@@ -3409,16 +3130,16 @@ async function _fetchMapDataset(dataset, accessToken, apiBaseUrl, clientId, head
|
|
|
3409
3130
|
} else if (spatialDataType === "h3") {
|
|
3410
3131
|
const options = { ...globalOptions, aggregationExp, aggregationResLevel, spatialDataColumn };
|
|
3411
3132
|
if (type === "table") {
|
|
3412
|
-
dataset.data = await h3TableSource({ ...options, tableName: source });
|
|
3133
|
+
dataset.data = await (0, import_api_client2.h3TableSource)({ ...options, tableName: source });
|
|
3413
3134
|
} else if (type === "query") {
|
|
3414
|
-
dataset.data = await h3QuerySource({ ...options, sqlQuery: source, queryParameters });
|
|
3135
|
+
dataset.data = await (0, import_api_client2.h3QuerySource)({ ...options, sqlQuery: source, queryParameters });
|
|
3415
3136
|
}
|
|
3416
3137
|
} else if (spatialDataType === "quadbin") {
|
|
3417
3138
|
const options = { ...globalOptions, aggregationExp, aggregationResLevel, spatialDataColumn };
|
|
3418
3139
|
if (type === "table") {
|
|
3419
|
-
dataset.data = await quadbinTableSource({ ...options, tableName: source });
|
|
3140
|
+
dataset.data = await (0, import_api_client2.quadbinTableSource)({ ...options, tableName: source });
|
|
3420
3141
|
} else if (type === "query") {
|
|
3421
|
-
dataset.data = await quadbinQuerySource({ ...options, sqlQuery: source, queryParameters });
|
|
3142
|
+
dataset.data = await (0, import_api_client2.quadbinQuerySource)({ ...options, sqlQuery: source, queryParameters });
|
|
3422
3143
|
}
|
|
3423
3144
|
}
|
|
3424
3145
|
}
|
|
@@ -3429,7 +3150,7 @@ async function _fetchMapDataset(dataset, accessToken, apiBaseUrl, clientId, head
|
|
|
3429
3150
|
}
|
|
3430
3151
|
return cacheChanged;
|
|
3431
3152
|
}
|
|
3432
|
-
async function _fetchTilestats(attribute, dataset, accessToken, apiBaseUrl, maxLengthURL =
|
|
3153
|
+
async function _fetchTilestats(attribute, dataset, accessToken, apiBaseUrl, maxLengthURL = import_api_client2.SOURCE_DEFAULTS.maxLengthURL) {
|
|
3433
3154
|
const { connectionName, data, id: id4, source, type, queryParameters } = dataset;
|
|
3434
3155
|
const errorContext = {
|
|
3435
3156
|
requestType: "Tile stats",
|
|
@@ -3438,9 +3159,9 @@ async function _fetchTilestats(attribute, dataset, accessToken, apiBaseUrl, maxL
|
|
|
3438
3159
|
source
|
|
3439
3160
|
};
|
|
3440
3161
|
if (!("tilestats" in data)) {
|
|
3441
|
-
throw new CartoAPIError(new Error(`Invalid dataset for tilestats: ${id4}`), errorContext);
|
|
3162
|
+
throw new import_api_client2.CartoAPIError(new Error(`Invalid dataset for tilestats: ${id4}`), errorContext);
|
|
3442
3163
|
}
|
|
3443
|
-
const baseUrl = buildStatsUrl({ attribute, apiBaseUrl, ...dataset });
|
|
3164
|
+
const baseUrl = (0, import_api_client2.buildStatsUrl)({ attribute, apiBaseUrl, ...dataset });
|
|
3444
3165
|
const client = new URLSearchParams(data.tiles[0]).get("client");
|
|
3445
3166
|
const headers = { Authorization: `Bearer ${accessToken}` };
|
|
3446
3167
|
const parameters = {};
|
|
@@ -3453,7 +3174,7 @@ async function _fetchTilestats(attribute, dataset, accessToken, apiBaseUrl, maxL
|
|
|
3453
3174
|
parameters.queryParameters = JSON.stringify(queryParameters);
|
|
3454
3175
|
}
|
|
3455
3176
|
}
|
|
3456
|
-
const stats = await requestWithParameters({
|
|
3177
|
+
const stats = await (0, import_api_client2.requestWithParameters)({
|
|
3457
3178
|
baseUrl,
|
|
3458
3179
|
headers,
|
|
3459
3180
|
parameters,
|
|
@@ -3465,11 +3186,11 @@ async function _fetchTilestats(attribute, dataset, accessToken, apiBaseUrl, maxL
|
|
|
3465
3186
|
attributes[index] = stats;
|
|
3466
3187
|
return true;
|
|
3467
3188
|
}
|
|
3468
|
-
async function fillInMapDatasets({ datasets, token }, clientId, apiBaseUrl, headers, maxLengthURL =
|
|
3189
|
+
async function fillInMapDatasets({ datasets, token }, clientId, apiBaseUrl, headers, maxLengthURL = import_api_client2.SOURCE_DEFAULTS.maxLengthURL) {
|
|
3469
3190
|
const promises = datasets.map((dataset) => _fetchMapDataset(dataset, token, apiBaseUrl, clientId, headers, maxLengthURL));
|
|
3470
3191
|
return await Promise.all(promises);
|
|
3471
3192
|
}
|
|
3472
|
-
async function fillInTileStats({ datasets, keplerMapConfig, token }, apiBaseUrl, maxLengthURL =
|
|
3193
|
+
async function fillInTileStats({ datasets, keplerMapConfig, token }, apiBaseUrl, maxLengthURL = import_api_client2.SOURCE_DEFAULTS.maxLengthURL) {
|
|
3473
3194
|
var _a;
|
|
3474
3195
|
const attributes = [];
|
|
3475
3196
|
const { layers } = keplerMapConfig.config.visState;
|
|
@@ -3493,7 +3214,7 @@ async function fillInTileStats({ datasets, keplerMapConfig, token }, apiBaseUrl,
|
|
|
3493
3214
|
const promises = filteredAttributes.map(({ attribute, dataset }) => _fetchTilestats(attribute, dataset, token, apiBaseUrl, maxLengthURL));
|
|
3494
3215
|
return await Promise.all(promises);
|
|
3495
3216
|
}
|
|
3496
|
-
async function fetchMap({ accessToken, apiBaseUrl =
|
|
3217
|
+
async function fetchMap({ accessToken, apiBaseUrl = import_api_client2.SOURCE_DEFAULTS.apiBaseUrl, cartoMapId, clientId = import_api_client2.SOURCE_DEFAULTS.clientId, headers = {}, autoRefresh, onNewData, maxLengthURL = import_api_client2.SOURCE_DEFAULTS.maxLengthURL }) {
|
|
3497
3218
|
assert(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})');
|
|
3498
3219
|
assert(apiBaseUrl, "Must define apiBaseUrl");
|
|
3499
3220
|
if (accessToken) {
|
|
@@ -3504,9 +3225,9 @@ async function fetchMap({ accessToken, apiBaseUrl = DEFAULT_API_BASE_URL, cartoM
|
|
|
3504
3225
|
assert(typeof onNewData === "function", "`onNewData` must be a function");
|
|
3505
3226
|
assert(typeof autoRefresh === "number" && autoRefresh > 0, "`autoRefresh` must be a positive number");
|
|
3506
3227
|
}
|
|
3507
|
-
const baseUrl = buildPublicMapUrl({ apiBaseUrl, cartoMapId });
|
|
3228
|
+
const baseUrl = (0, import_api_client2.buildPublicMapUrl)({ apiBaseUrl, cartoMapId });
|
|
3508
3229
|
const errorContext = { requestType: "Public map", mapId: cartoMapId };
|
|
3509
|
-
const map = await requestWithParameters({ baseUrl, headers, errorContext, maxLengthURL });
|
|
3230
|
+
const map = await (0, import_api_client2.requestWithParameters)({ baseUrl, headers, errorContext, maxLengthURL });
|
|
3510
3231
|
let stopAutoRefresh;
|
|
3511
3232
|
if (autoRefresh) {
|
|
3512
3233
|
const intervalId = setInterval(async () => {
|
|
@@ -3535,6 +3256,7 @@ async function fetchMap({ accessToken, apiBaseUrl = DEFAULT_API_BASE_URL, cartoM
|
|
|
3535
3256
|
});
|
|
3536
3257
|
const [basemap] = await Promise.all([
|
|
3537
3258
|
fetchBasemapProps({ config: map.keplerMapConfig.config, errorContext }),
|
|
3259
|
+
// Mutates map.datasets so that dataset.data contains data
|
|
3538
3260
|
fillInMapDatasets(map, clientId, apiBaseUrl, headers, maxLengthURL)
|
|
3539
3261
|
]);
|
|
3540
3262
|
await fillInTileStats(map, apiBaseUrl, maxLengthURL);
|
|
@@ -3550,32 +3272,8 @@ async function fetchMap({ accessToken, apiBaseUrl = DEFAULT_API_BASE_URL, cartoM
|
|
|
3550
3272
|
return out;
|
|
3551
3273
|
}
|
|
3552
3274
|
|
|
3553
|
-
// dist/api/query.js
|
|
3554
|
-
var query = async function(options) {
|
|
3555
|
-
const { apiBaseUrl = SOURCE_DEFAULTS.apiBaseUrl, clientId = SOURCE_DEFAULTS.clientId, maxLengthURL = SOURCE_DEFAULTS.maxLengthURL, connectionName, sqlQuery, queryParameters } = options;
|
|
3556
|
-
const urlParameters = { q: sqlQuery };
|
|
3557
|
-
if (queryParameters) {
|
|
3558
|
-
urlParameters.queryParameters = JSON.stringify(queryParameters);
|
|
3559
|
-
}
|
|
3560
|
-
const baseUrl = buildQueryUrl({ apiBaseUrl, connectionName });
|
|
3561
|
-
const headers = { Authorization: `Bearer ${options.accessToken}`, ...options.headers };
|
|
3562
|
-
const parameters = { client: clientId, ...urlParameters };
|
|
3563
|
-
const errorContext = {
|
|
3564
|
-
requestType: "SQL",
|
|
3565
|
-
connection: options.connectionName,
|
|
3566
|
-
type: "query",
|
|
3567
|
-
source: JSON.stringify(parameters, void 0, 2)
|
|
3568
|
-
};
|
|
3569
|
-
return await requestWithParameters({
|
|
3570
|
-
baseUrl,
|
|
3571
|
-
parameters,
|
|
3572
|
-
headers,
|
|
3573
|
-
errorContext,
|
|
3574
|
-
maxLengthURL
|
|
3575
|
-
});
|
|
3576
|
-
};
|
|
3577
|
-
|
|
3578
3275
|
// dist/index.js
|
|
3276
|
+
var import_api_client3 = require("@carto/api-client");
|
|
3579
3277
|
var CARTO_LAYERS = {
|
|
3580
3278
|
ClusterTileLayer: cluster_tile_layer_default,
|
|
3581
3279
|
H3TileLayer: h3_tile_layer_default,
|
|
@@ -3586,17 +3284,17 @@ var CARTO_LAYERS = {
|
|
|
3586
3284
|
VectorTileLayer: vector_tile_layer_default
|
|
3587
3285
|
};
|
|
3588
3286
|
var CARTO_SOURCES = {
|
|
3589
|
-
boundaryQuerySource,
|
|
3590
|
-
boundaryTableSource,
|
|
3591
|
-
h3QuerySource,
|
|
3592
|
-
h3TableSource,
|
|
3593
|
-
h3TilesetSource,
|
|
3594
|
-
rasterSource,
|
|
3595
|
-
quadbinQuerySource,
|
|
3596
|
-
quadbinTableSource,
|
|
3597
|
-
quadbinTilesetSource,
|
|
3598
|
-
vectorQuerySource,
|
|
3599
|
-
vectorTableSource,
|
|
3600
|
-
vectorTilesetSource
|
|
3287
|
+
boundaryQuerySource: import_api_client3.boundaryQuerySource,
|
|
3288
|
+
boundaryTableSource: import_api_client3.boundaryTableSource,
|
|
3289
|
+
h3QuerySource: import_api_client3.h3QuerySource,
|
|
3290
|
+
h3TableSource: import_api_client3.h3TableSource,
|
|
3291
|
+
h3TilesetSource: import_api_client3.h3TilesetSource,
|
|
3292
|
+
rasterSource: import_api_client3.rasterSource,
|
|
3293
|
+
quadbinQuerySource: import_api_client3.quadbinQuerySource,
|
|
3294
|
+
quadbinTableSource: import_api_client3.quadbinTableSource,
|
|
3295
|
+
quadbinTilesetSource: import_api_client3.quadbinTilesetSource,
|
|
3296
|
+
vectorQuerySource: import_api_client3.vectorQuerySource,
|
|
3297
|
+
vectorTableSource: import_api_client3.vectorTableSource,
|
|
3298
|
+
vectorTilesetSource: import_api_client3.vectorTilesetSource
|
|
3601
3299
|
};
|
|
3602
3300
|
//# sourceMappingURL=index.cjs.map
|