@deck.gl/carto 9.0.0-beta.1 → 9.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/carto-api-error.js +47 -0
- package/dist/{esm/api → api}/common.js +4 -5
- package/dist/api/endpoints.js +22 -0
- package/dist/api/fetch-map.js +187 -0
- package/dist/api/index.js +3 -0
- package/dist/api/layer-map.js +373 -0
- package/dist/api/parse-map.js +250 -0
- package/dist/api/query.js +24 -0
- package/dist/api/request-with-parameters.js +53 -0
- package/dist/api/types.js +12 -0
- package/dist/basemap.js +9 -0
- package/dist/cartoRasterTile-worker.js +2 -2
- package/dist/cartoSpatialTile-worker.js +3 -3
- package/dist/cartoVectorTile-worker.js +3 -3
- package/dist/dist.dev.js +1222 -1073
- package/dist/index.cjs +2685 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +37 -0
- package/{typed → dist}/index.d.ts.map +1 -1
- package/dist/index.js +34 -0
- package/dist/layers/h3-tile-layer.js +64 -0
- package/dist/layers/h3-tileset-2d.js +99 -0
- package/dist/layers/point-label-layer.js +150 -0
- package/dist/layers/quadbin-layer.js +21 -0
- package/dist/layers/quadbin-tile-layer.js +47 -0
- package/dist/layers/quadbin-tileset-2d.js +27 -0
- package/dist/layers/quadbin-utils.js +21 -0
- package/dist/{esm/layers → layers}/raster-layer-vertex.glsl.js +0 -1
- package/dist/layers/raster-layer.js +97 -0
- package/dist/layers/raster-tile-layer.js +43 -0
- package/dist/layers/schema/carto-properties-tile-loader.js +21 -0
- package/dist/layers/schema/carto-properties-tile.js +14 -0
- package/dist/layers/schema/carto-raster-tile-loader.js +36 -0
- package/dist/layers/schema/carto-raster-tile.js +46 -0
- package/dist/layers/schema/carto-spatial-tile-loader.js +35 -0
- package/dist/layers/schema/carto-spatial-tile.js +38 -0
- package/dist/layers/schema/carto-tile.js +187 -0
- package/dist/layers/schema/carto-vector-tile-loader.js +65 -0
- package/dist/layers/schema/fast-pbf.js +7 -0
- package/dist/layers/schema/spatialjson-utils.js +15 -0
- package/dist/layers/schema/tile-loader-utils.js +6 -0
- package/{typed → dist}/layers/spatial-index-tile-layer.d.ts +1 -1
- package/{typed → dist}/layers/spatial-index-tile-layer.d.ts.map +1 -1
- package/dist/layers/spatial-index-tile-layer.js +64 -0
- package/dist/layers/utils.js +74 -0
- package/dist/layers/vector-tile-layer.js +98 -0
- package/dist/sources/base-source.js +52 -0
- package/{typed → dist}/sources/boundary-query-source.d.ts +1 -1
- package/{typed → dist}/sources/boundary-query-source.d.ts.map +1 -1
- package/dist/sources/boundary-query-source.js +13 -0
- package/dist/sources/boundary-table-source.js +13 -0
- package/dist/sources/h3-query-source.js +18 -0
- package/dist/sources/h3-table-source.js +18 -0
- package/dist/sources/h3-tileset-source.js +6 -0
- package/dist/sources/index.js +13 -0
- package/dist/sources/quadbin-query-source.js +18 -0
- package/dist/sources/quadbin-table-source.js +18 -0
- package/dist/sources/quadbin-tileset-source.js +6 -0
- package/dist/sources/raster-source.js +6 -0
- package/dist/sources/types.js +1 -0
- package/dist/sources/vector-query-source.js +10 -0
- package/dist/sources/vector-table-source.js +10 -0
- package/dist/sources/vector-tileset-source.js +6 -0
- package/dist/style/color-bins-style.js +21 -0
- package/dist/style/color-categories-style.js +25 -0
- package/dist/style/color-continuous-style.js +21 -0
- package/dist/style/palette.js +62 -0
- package/dist/style/utils.js +11 -0
- package/dist/utils.js +41 -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 +28 -42
- package/package.json +22 -15
- package/src/api/fetch-map.ts +1 -1
- package/src/api/query.ts +1 -1
- package/src/index.ts +4 -4
- package/src/layers/spatial-index-tile-layer.ts +3 -2
- package/src/sources/boundary-query-source.ts +1 -1
- package/dist/es5/api/carto-api-error.js +0 -83
- package/dist/es5/api/carto-api-error.js.map +0 -1
- package/dist/es5/api/common.js +0 -25
- package/dist/es5/api/common.js.map +0 -1
- package/dist/es5/api/endpoints.js +0 -61
- package/dist/es5/api/endpoints.js.map +0 -1
- package/dist/es5/api/fetch-map.js +0 -566
- package/dist/es5/api/fetch-map.js.map +0 -1
- package/dist/es5/api/index.js +0 -30
- package/dist/es5/api/index.js.map +0 -1
- package/dist/es5/api/layer-map.js +0 -634
- package/dist/es5/api/layer-map.js.map +0 -1
- package/dist/es5/api/parse-map.js +0 -347
- package/dist/es5/api/parse-map.js.map +0 -1
- package/dist/es5/api/query.js +0 -81
- package/dist/es5/api/query.js.map +0 -1
- package/dist/es5/api/request-with-parameters.js +0 -150
- package/dist/es5/api/request-with-parameters.js.map +0 -1
- package/dist/es5/api/types.js +0 -21
- package/dist/es5/api/types.js.map +0 -1
- package/dist/es5/basemap.js +0 -17
- package/dist/es5/basemap.js.map +0 -1
- package/dist/es5/index.js +0 -205
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/layers/h3-tile-layer.js +0 -128
- package/dist/es5/layers/h3-tile-layer.js.map +0 -1
- package/dist/es5/layers/h3-tileset-2d.js +0 -172
- package/dist/es5/layers/h3-tileset-2d.js.map +0 -1
- package/dist/es5/layers/point-label-layer.js +0 -263
- package/dist/es5/layers/point-label-layer.js.map +0 -1
- package/dist/es5/layers/quadbin-layer.js +0 -72
- package/dist/es5/layers/quadbin-layer.js.map +0 -1
- package/dist/es5/layers/quadbin-tile-layer.js +0 -103
- package/dist/es5/layers/quadbin-tile-layer.js.map +0 -1
- package/dist/es5/layers/quadbin-tileset-2d.js +0 -76
- package/dist/es5/layers/quadbin-tileset-2d.js.map +0 -1
- package/dist/es5/layers/quadbin-utils.js +0 -60
- package/dist/es5/layers/quadbin-utils.js.map +0 -1
- package/dist/es5/layers/raster-layer-vertex.glsl.js +0 -9
- package/dist/es5/layers/raster-layer-vertex.glsl.js.map +0 -1
- package/dist/es5/layers/raster-layer.js +0 -174
- package/dist/es5/layers/raster-layer.js.map +0 -1
- package/dist/es5/layers/raster-tile-layer.js +0 -91
- package/dist/es5/layers/raster-tile-layer.js.map +0 -1
- package/dist/es5/layers/schema/carto-properties-tile-loader.js +0 -60
- package/dist/es5/layers/schema/carto-properties-tile-loader.js.map +0 -1
- package/dist/es5/layers/schema/carto-properties-tile.js +0 -38
- package/dist/es5/layers/schema/carto-properties-tile.js.map +0 -1
- package/dist/es5/layers/schema/carto-raster-tile-loader.js +0 -89
- package/dist/es5/layers/schema/carto-raster-tile-loader.js.map +0 -1
- package/dist/es5/layers/schema/carto-raster-tile.js +0 -79
- package/dist/es5/layers/schema/carto-raster-tile.js.map +0 -1
- package/dist/es5/layers/schema/carto-spatial-tile-loader.js +0 -81
- package/dist/es5/layers/schema/carto-spatial-tile-loader.js.map +0 -1
- package/dist/es5/layers/schema/carto-spatial-tile.js +0 -80
- package/dist/es5/layers/schema/carto-spatial-tile.js.map +0 -1
- package/dist/es5/layers/schema/carto-tile.js +0 -269
- package/dist/es5/layers/schema/carto-tile.js.map +0 -1
- package/dist/es5/layers/schema/carto-vector-tile-loader.js +0 -120
- package/dist/es5/layers/schema/carto-vector-tile-loader.js.map +0 -1
- package/dist/es5/layers/schema/fast-pbf.js +0 -14
- package/dist/es5/layers/schema/fast-pbf.js.map +0 -1
- package/dist/es5/layers/schema/spatialjson-utils.js +0 -42
- package/dist/es5/layers/schema/spatialjson-utils.js.map +0 -1
- package/dist/es5/layers/schema/tile-loader-utils.js +0 -17
- package/dist/es5/layers/schema/tile-loader-utils.js.map +0 -1
- package/dist/es5/layers/spatial-index-tile-layer.js +0 -126
- package/dist/es5/layers/spatial-index-tile-layer.js.map +0 -1
- package/dist/es5/layers/utils.js +0 -131
- package/dist/es5/layers/utils.js.map +0 -1
- package/dist/es5/layers/vector-tile-layer.js +0 -248
- package/dist/es5/layers/vector-tile-layer.js.map +0 -1
- package/dist/es5/sources/base-source.js +0 -128
- package/dist/es5/sources/base-source.js.map +0 -1
- package/dist/es5/sources/boundary-query-source.js +0 -51
- package/dist/es5/sources/boundary-query-source.js.map +0 -1
- package/dist/es5/sources/boundary-table-source.js +0 -51
- package/dist/es5/sources/boundary-table-source.js.map +0 -1
- package/dist/es5/sources/h3-query-source.js +0 -56
- package/dist/es5/sources/h3-query-source.js.map +0 -1
- package/dist/es5/sources/h3-table-source.js +0 -56
- package/dist/es5/sources/h3-table-source.js.map +0 -1
- package/dist/es5/sources/h3-tileset-source.js +0 -43
- package/dist/es5/sources/h3-tileset-source.js.map +0 -1
- package/dist/es5/sources/index.js +0 -110
- package/dist/es5/sources/index.js.map +0 -1
- package/dist/es5/sources/quadbin-query-source.js +0 -56
- package/dist/es5/sources/quadbin-query-source.js.map +0 -1
- package/dist/es5/sources/quadbin-table-source.js +0 -56
- package/dist/es5/sources/quadbin-table-source.js.map +0 -1
- package/dist/es5/sources/quadbin-tileset-source.js +0 -43
- package/dist/es5/sources/quadbin-tileset-source.js.map +0 -1
- package/dist/es5/sources/raster-source.js +0 -43
- package/dist/es5/sources/raster-source.js.map +0 -1
- package/dist/es5/sources/types.js +0 -2
- package/dist/es5/sources/types.js.map +0 -1
- package/dist/es5/sources/vector-query-source.js +0 -51
- package/dist/es5/sources/vector-query-source.js.map +0 -1
- package/dist/es5/sources/vector-table-source.js +0 -51
- package/dist/es5/sources/vector-table-source.js.map +0 -1
- package/dist/es5/sources/vector-tileset-source.js +0 -43
- package/dist/es5/sources/vector-tileset-source.js.map +0 -1
- package/dist/es5/style/color-bins-style.js +0 -37
- package/dist/es5/style/color-bins-style.js.map +0 -1
- package/dist/es5/style/color-categories-style.js +0 -65
- package/dist/es5/style/color-categories-style.js.map +0 -1
- package/dist/es5/style/color-continuous-style.js +0 -37
- package/dist/es5/style/color-continuous-style.js.map +0 -1
- package/dist/es5/style/palette.js +0 -81
- package/dist/es5/style/palette.js.map +0 -1
- package/dist/es5/style/utils.js +0 -28
- package/dist/es5/style/utils.js.map +0 -1
- package/dist/es5/utils.js +0 -65
- package/dist/es5/utils.js.map +0 -1
- package/dist/es5/workers/cartoRasterTile.js +0 -10
- package/dist/es5/workers/cartoRasterTile.js.map +0 -1
- package/dist/es5/workers/cartoSpatialTile.js +0 -10
- package/dist/es5/workers/cartoSpatialTile.js.map +0 -1
- package/dist/es5/workers/cartoVectorTile.js +0 -10
- package/dist/es5/workers/cartoVectorTile.js.map +0 -1
- package/dist/esm/api/carto-api-error.js +0 -46
- package/dist/esm/api/carto-api-error.js.map +0 -1
- package/dist/esm/api/common.js.map +0 -1
- package/dist/esm/api/endpoints.js +0 -41
- package/dist/esm/api/endpoints.js.map +0 -1
- package/dist/esm/api/fetch-map.js +0 -298
- package/dist/esm/api/fetch-map.js.map +0 -1
- package/dist/esm/api/index.js +0 -4
- package/dist/esm/api/index.js.map +0 -1
- package/dist/esm/api/layer-map.js +0 -520
- package/dist/esm/api/layer-map.js.map +0 -1
- package/dist/esm/api/parse-map.js +0 -343
- package/dist/esm/api/parse-map.js.map +0 -1
- package/dist/esm/api/query.js +0 -40
- package/dist/esm/api/query.js.map +0 -1
- package/dist/esm/api/request-with-parameters.js +0 -82
- package/dist/esm/api/request-with-parameters.js.map +0 -1
- package/dist/esm/api/types.js +0 -14
- package/dist/esm/api/types.js.map +0 -1
- package/dist/esm/basemap.js +0 -10
- package/dist/esm/basemap.js.map +0 -1
- package/dist/esm/index.js +0 -35
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/layers/h3-tile-layer.js +0 -77
- package/dist/esm/layers/h3-tile-layer.js.map +0 -1
- package/dist/esm/layers/h3-tileset-2d.js +0 -119
- package/dist/esm/layers/h3-tileset-2d.js.map +0 -1
- package/dist/esm/layers/point-label-layer.js +0 -194
- package/dist/esm/layers/point-label-layer.js.map +0 -1
- package/dist/esm/layers/quadbin-layer.js +0 -31
- package/dist/esm/layers/quadbin-layer.js.map +0 -1
- package/dist/esm/layers/quadbin-tile-layer.js +0 -51
- package/dist/esm/layers/quadbin-tile-layer.js.map +0 -1
- package/dist/esm/layers/quadbin-tileset-2d.js +0 -39
- package/dist/esm/layers/quadbin-tileset-2d.js.map +0 -1
- package/dist/esm/layers/quadbin-utils.js +0 -23
- package/dist/esm/layers/quadbin-utils.js.map +0 -1
- package/dist/esm/layers/raster-layer-vertex.glsl.js.map +0 -1
- package/dist/esm/layers/raster-layer.js +0 -108
- package/dist/esm/layers/raster-layer.js.map +0 -1
- package/dist/esm/layers/raster-tile-layer.js +0 -48
- package/dist/esm/layers/raster-tile-layer.js.map +0 -1
- package/dist/esm/layers/schema/carto-properties-tile-loader.js +0 -23
- package/dist/esm/layers/schema/carto-properties-tile-loader.js.map +0 -1
- package/dist/esm/layers/schema/carto-properties-tile.js +0 -18
- package/dist/esm/layers/schema/carto-properties-tile.js.map +0 -1
- package/dist/esm/layers/schema/carto-raster-tile-loader.js +0 -54
- package/dist/esm/layers/schema/carto-raster-tile-loader.js.map +0 -1
- package/dist/esm/layers/schema/carto-raster-tile.js +0 -51
- package/dist/esm/layers/schema/carto-raster-tile.js.map +0 -1
- package/dist/esm/layers/schema/carto-spatial-tile-loader.js +0 -44
- package/dist/esm/layers/schema/carto-spatial-tile-loader.js.map +0 -1
- package/dist/esm/layers/schema/carto-spatial-tile.js +0 -47
- package/dist/esm/layers/schema/carto-spatial-tile.js.map +0 -1
- package/dist/esm/layers/schema/carto-tile.js +0 -197
- package/dist/esm/layers/schema/carto-tile.js.map +0 -1
- package/dist/esm/layers/schema/carto-vector-tile-loader.js +0 -82
- package/dist/esm/layers/schema/carto-vector-tile-loader.js.map +0 -1
- package/dist/esm/layers/schema/fast-pbf.js +0 -7
- package/dist/esm/layers/schema/fast-pbf.js.map +0 -1
- package/dist/esm/layers/schema/spatialjson-utils.js +0 -27
- package/dist/esm/layers/schema/spatialjson-utils.js.map +0 -1
- package/dist/esm/layers/schema/tile-loader-utils.js +0 -7
- package/dist/esm/layers/schema/tile-loader-utils.js.map +0 -1
- package/dist/esm/layers/spatial-index-tile-layer.js +0 -86
- package/dist/esm/layers/spatial-index-tile-layer.js.map +0 -1
- package/dist/esm/layers/utils.js +0 -85
- package/dist/esm/layers/utils.js.map +0 -1
- package/dist/esm/layers/vector-tile-layer.js +0 -143
- package/dist/esm/layers/vector-tile-layer.js.map +0 -1
- package/dist/esm/sources/base-source.js +0 -72
- package/dist/esm/sources/base-source.js.map +0 -1
- package/dist/esm/sources/boundary-query-source.js +0 -21
- package/dist/esm/sources/boundary-query-source.js.map +0 -1
- package/dist/esm/sources/boundary-table-source.js +0 -21
- package/dist/esm/sources/boundary-table-source.js.map +0 -1
- package/dist/esm/sources/h3-query-source.js +0 -27
- package/dist/esm/sources/h3-query-source.js.map +0 -1
- package/dist/esm/sources/h3-table-source.js +0 -27
- package/dist/esm/sources/h3-table-source.js.map +0 -1
- package/dist/esm/sources/h3-tileset-source.js +0 -11
- package/dist/esm/sources/h3-tileset-source.js.map +0 -1
- package/dist/esm/sources/index.js +0 -14
- package/dist/esm/sources/index.js.map +0 -1
- package/dist/esm/sources/quadbin-query-source.js +0 -27
- package/dist/esm/sources/quadbin-query-source.js.map +0 -1
- package/dist/esm/sources/quadbin-table-source.js +0 -27
- package/dist/esm/sources/quadbin-table-source.js.map +0 -1
- package/dist/esm/sources/quadbin-tileset-source.js +0 -11
- package/dist/esm/sources/quadbin-tileset-source.js.map +0 -1
- package/dist/esm/sources/raster-source.js +0 -11
- package/dist/esm/sources/raster-source.js.map +0 -1
- package/dist/esm/sources/types.js +0 -2
- package/dist/esm/sources/types.js.map +0 -1
- package/dist/esm/sources/vector-query-source.js +0 -20
- package/dist/esm/sources/vector-query-source.js.map +0 -1
- package/dist/esm/sources/vector-table-source.js +0 -20
- package/dist/esm/sources/vector-table-source.js.map +0 -1
- package/dist/esm/sources/vector-tileset-source.js +0 -11
- package/dist/esm/sources/vector-tileset-source.js.map +0 -1
- package/dist/esm/style/color-bins-style.js +0 -19
- package/dist/esm/style/color-bins-style.js.map +0 -1
- package/dist/esm/style/color-categories-style.js +0 -24
- package/dist/esm/style/color-categories-style.js.map +0 -1
- package/dist/esm/style/color-continuous-style.js +0 -19
- package/dist/esm/style/color-continuous-style.js.map +0 -1
- package/dist/esm/style/palette.js +0 -51
- package/dist/esm/style/palette.js.map +0 -1
- package/dist/esm/style/utils.js +0 -15
- package/dist/esm/style/utils.js.map +0 -1
- package/dist/esm/utils.js +0 -51
- package/dist/esm/utils.js.map +0 -1
- package/dist/esm/workers/cartoRasterTile.js +0 -4
- package/dist/esm/workers/cartoRasterTile.js.map +0 -1
- package/dist/esm/workers/cartoSpatialTile.js +0 -4
- package/dist/esm/workers/cartoSpatialTile.js.map +0 -1
- package/dist/esm/workers/cartoVectorTile.js +0 -4
- package/dist/esm/workers/cartoVectorTile.js.map +0 -1
- package/typed/index.d.ts +0 -37
- /package/{typed → dist}/api/carto-api-error.d.ts +0 -0
- /package/{typed → dist}/api/carto-api-error.d.ts.map +0 -0
- /package/{typed → dist}/api/common.d.ts +0 -0
- /package/{typed → dist}/api/common.d.ts.map +0 -0
- /package/{typed → dist}/api/endpoints.d.ts +0 -0
- /package/{typed → dist}/api/endpoints.d.ts.map +0 -0
- /package/{typed → dist}/api/fetch-map.d.ts +0 -0
- /package/{typed → dist}/api/fetch-map.d.ts.map +0 -0
- /package/{typed → dist}/api/index.d.ts +0 -0
- /package/{typed → dist}/api/index.d.ts.map +0 -0
- /package/{typed → dist}/api/layer-map.d.ts +0 -0
- /package/{typed → dist}/api/layer-map.d.ts.map +0 -0
- /package/{typed → dist}/api/parse-map.d.ts +0 -0
- /package/{typed → dist}/api/parse-map.d.ts.map +0 -0
- /package/{typed → dist}/api/query.d.ts +0 -0
- /package/{typed → dist}/api/query.d.ts.map +0 -0
- /package/{typed → dist}/api/request-with-parameters.d.ts +0 -0
- /package/{typed → dist}/api/request-with-parameters.d.ts.map +0 -0
- /package/{typed → dist}/api/types.d.ts +0 -0
- /package/{typed → dist}/api/types.d.ts.map +0 -0
- /package/{typed → dist}/basemap.d.ts +0 -0
- /package/{typed → dist}/basemap.d.ts.map +0 -0
- /package/{typed → dist}/layers/h3-tile-layer.d.ts +0 -0
- /package/{typed → dist}/layers/h3-tile-layer.d.ts.map +0 -0
- /package/{typed → dist}/layers/h3-tileset-2d.d.ts +0 -0
- /package/{typed → dist}/layers/h3-tileset-2d.d.ts.map +0 -0
- /package/{typed → dist}/layers/point-label-layer.d.ts +0 -0
- /package/{typed → dist}/layers/point-label-layer.d.ts.map +0 -0
- /package/{typed → dist}/layers/quadbin-layer.d.ts +0 -0
- /package/{typed → dist}/layers/quadbin-layer.d.ts.map +0 -0
- /package/{typed → dist}/layers/quadbin-tile-layer.d.ts +0 -0
- /package/{typed → dist}/layers/quadbin-tile-layer.d.ts.map +0 -0
- /package/{typed → dist}/layers/quadbin-tileset-2d.d.ts +0 -0
- /package/{typed → dist}/layers/quadbin-tileset-2d.d.ts.map +0 -0
- /package/{typed → dist}/layers/quadbin-utils.d.ts +0 -0
- /package/{typed → dist}/layers/quadbin-utils.d.ts.map +0 -0
- /package/{typed → dist}/layers/raster-layer-vertex.glsl.d.ts +0 -0
- /package/{typed → dist}/layers/raster-layer-vertex.glsl.d.ts.map +0 -0
- /package/{typed → dist}/layers/raster-layer.d.ts +0 -0
- /package/{typed → dist}/layers/raster-layer.d.ts.map +0 -0
- /package/{typed → dist}/layers/raster-tile-layer.d.ts +0 -0
- /package/{typed → dist}/layers/raster-tile-layer.d.ts.map +0 -0
- /package/{typed → dist}/layers/schema/carto-properties-tile-loader.d.ts +0 -0
- /package/{typed → dist}/layers/schema/carto-properties-tile-loader.d.ts.map +0 -0
- /package/{typed → dist}/layers/schema/carto-properties-tile.d.ts +0 -0
- /package/{typed → dist}/layers/schema/carto-properties-tile.d.ts.map +0 -0
- /package/{typed → dist}/layers/schema/carto-raster-tile-loader.d.ts +0 -0
- /package/{typed → dist}/layers/schema/carto-raster-tile-loader.d.ts.map +0 -0
- /package/{typed → dist}/layers/schema/carto-raster-tile.d.ts +0 -0
- /package/{typed → dist}/layers/schema/carto-raster-tile.d.ts.map +0 -0
- /package/{typed → dist}/layers/schema/carto-spatial-tile-loader.d.ts +0 -0
- /package/{typed → dist}/layers/schema/carto-spatial-tile-loader.d.ts.map +0 -0
- /package/{typed → dist}/layers/schema/carto-spatial-tile.d.ts +0 -0
- /package/{typed → dist}/layers/schema/carto-spatial-tile.d.ts.map +0 -0
- /package/{typed → dist}/layers/schema/carto-tile.d.ts +0 -0
- /package/{typed → dist}/layers/schema/carto-tile.d.ts.map +0 -0
- /package/{typed → dist}/layers/schema/carto-vector-tile-loader.d.ts +0 -0
- /package/{typed → dist}/layers/schema/carto-vector-tile-loader.d.ts.map +0 -0
- /package/{typed → dist}/layers/schema/fast-pbf.d.ts +0 -0
- /package/{typed → dist}/layers/schema/fast-pbf.d.ts.map +0 -0
- /package/{typed → dist}/layers/schema/spatialjson-utils.d.ts +0 -0
- /package/{typed → dist}/layers/schema/spatialjson-utils.d.ts.map +0 -0
- /package/{typed → dist}/layers/schema/tile-loader-utils.d.ts +0 -0
- /package/{typed → dist}/layers/schema/tile-loader-utils.d.ts.map +0 -0
- /package/{typed → dist}/layers/utils.d.ts +0 -0
- /package/{typed → dist}/layers/utils.d.ts.map +0 -0
- /package/{typed → dist}/layers/vector-tile-layer.d.ts +0 -0
- /package/{typed → dist}/layers/vector-tile-layer.d.ts.map +0 -0
- /package/{typed → dist}/sources/base-source.d.ts +0 -0
- /package/{typed → dist}/sources/base-source.d.ts.map +0 -0
- /package/{typed → dist}/sources/boundary-table-source.d.ts +0 -0
- /package/{typed → dist}/sources/boundary-table-source.d.ts.map +0 -0
- /package/{typed → dist}/sources/h3-query-source.d.ts +0 -0
- /package/{typed → dist}/sources/h3-query-source.d.ts.map +0 -0
- /package/{typed → dist}/sources/h3-table-source.d.ts +0 -0
- /package/{typed → dist}/sources/h3-table-source.d.ts.map +0 -0
- /package/{typed → dist}/sources/h3-tileset-source.d.ts +0 -0
- /package/{typed → dist}/sources/h3-tileset-source.d.ts.map +0 -0
- /package/{typed → dist}/sources/index.d.ts +0 -0
- /package/{typed → dist}/sources/index.d.ts.map +0 -0
- /package/{typed → dist}/sources/quadbin-query-source.d.ts +0 -0
- /package/{typed → dist}/sources/quadbin-query-source.d.ts.map +0 -0
- /package/{typed → dist}/sources/quadbin-table-source.d.ts +0 -0
- /package/{typed → dist}/sources/quadbin-table-source.d.ts.map +0 -0
- /package/{typed → dist}/sources/quadbin-tileset-source.d.ts +0 -0
- /package/{typed → dist}/sources/quadbin-tileset-source.d.ts.map +0 -0
- /package/{typed → dist}/sources/raster-source.d.ts +0 -0
- /package/{typed → dist}/sources/raster-source.d.ts.map +0 -0
- /package/{typed → dist}/sources/types.d.ts +0 -0
- /package/{typed → dist}/sources/types.d.ts.map +0 -0
- /package/{typed → dist}/sources/vector-query-source.d.ts +0 -0
- /package/{typed → dist}/sources/vector-query-source.d.ts.map +0 -0
- /package/{typed → dist}/sources/vector-table-source.d.ts +0 -0
- /package/{typed → dist}/sources/vector-table-source.d.ts.map +0 -0
- /package/{typed → dist}/sources/vector-tileset-source.d.ts +0 -0
- /package/{typed → dist}/sources/vector-tileset-source.d.ts.map +0 -0
- /package/{typed → dist}/style/color-bins-style.d.ts +0 -0
- /package/{typed → dist}/style/color-bins-style.d.ts.map +0 -0
- /package/{typed → dist}/style/color-categories-style.d.ts +0 -0
- /package/{typed → dist}/style/color-categories-style.d.ts.map +0 -0
- /package/{typed → dist}/style/color-continuous-style.d.ts +0 -0
- /package/{typed → dist}/style/color-continuous-style.d.ts.map +0 -0
- /package/{typed → dist}/style/palette.d.ts +0 -0
- /package/{typed → dist}/style/palette.d.ts.map +0 -0
- /package/{typed → dist}/style/utils.d.ts +0 -0
- /package/{typed → dist}/style/utils.d.ts.map +0 -0
- /package/{typed → dist}/utils.d.ts +0 -0
- /package/{typed → dist}/utils.d.ts.map +0 -0
- /package/{typed → dist}/workers/cartoRasterTile.d.ts +0 -0
- /package/{typed → dist}/workers/cartoRasterTile.d.ts.map +0 -0
- /package/{typed → dist}/workers/cartoSpatialTile.d.ts +0 -0
- /package/{typed → dist}/workers/cartoSpatialTile.d.ts.map +0 -0
- /package/{typed → dist}/workers/cartoVectorTile.d.ts +0 -0
- /package/{typed → dist}/workers/cartoVectorTile.d.ts.map +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Custom error for reported errors in CARTO Maps API.
|
|
4
|
+
* Provides useful debugging information in console and context for applications.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export class CartoAPIError extends Error {
|
|
8
|
+
constructor(error, errorContext, response) {
|
|
9
|
+
let responseString = 'Failed to connect';
|
|
10
|
+
if (response) {
|
|
11
|
+
responseString = 'Server returned: ';
|
|
12
|
+
if (response.status === 400) {
|
|
13
|
+
responseString += 'Bad request';
|
|
14
|
+
}
|
|
15
|
+
else if (response.status === 401 || response.status === 403) {
|
|
16
|
+
responseString += 'Unauthorized access';
|
|
17
|
+
}
|
|
18
|
+
else if (response.status === 404) {
|
|
19
|
+
responseString += 'Not found';
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
responseString += 'Error';
|
|
23
|
+
}
|
|
24
|
+
responseString += ` (${response.status}):`;
|
|
25
|
+
}
|
|
26
|
+
responseString += ` ${error.message || error}`;
|
|
27
|
+
let message = `${errorContext.requestType} API request failed`;
|
|
28
|
+
message += `\n${responseString}`;
|
|
29
|
+
for (const key of Object.keys(errorContext)) {
|
|
30
|
+
if (key === 'requestType')
|
|
31
|
+
continue; // eslint-disable-line no-continue
|
|
32
|
+
message += `\n${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
33
|
+
}
|
|
34
|
+
message += '\n';
|
|
35
|
+
super(message);
|
|
36
|
+
this.name = 'CartoAPIError';
|
|
37
|
+
this.response = response;
|
|
38
|
+
this.error = error;
|
|
39
|
+
this.errorContext = errorContext;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Converts camelCase to Camel Case
|
|
44
|
+
*/
|
|
45
|
+
function formatErrorKey(key) {
|
|
46
|
+
return key.replace(/([A-Z])/g, ' $1').replace(/^./, s => s.toUpperCase());
|
|
47
|
+
}
|
|
@@ -3,11 +3,10 @@ export const DEFAULT_CLIENT = 'deck-gl-carto';
|
|
|
3
3
|
export const V3_MINOR_VERSION = '3.3';
|
|
4
4
|
export const MAX_GET_LENGTH = 8192;
|
|
5
5
|
export const DEFAULT_PARAMETERS = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
client: DEFAULT_CLIENT,
|
|
7
|
+
v: V3_MINOR_VERSION
|
|
8
8
|
};
|
|
9
9
|
export const DEFAULT_HEADERS = {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
Accept: 'application/json',
|
|
11
|
+
'Content-Type': 'application/json'
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function joinPath(...args) {
|
|
2
|
+
return args.map(part => (part.endsWith('/') ? part.slice(0, -1) : part)).join('/');
|
|
3
|
+
}
|
|
4
|
+
function buildV3Path(apiBaseUrl, version, endpoint, ...rest) {
|
|
5
|
+
return joinPath(apiBaseUrl, version, endpoint, ...rest);
|
|
6
|
+
}
|
|
7
|
+
export function buildPublicMapUrl({ apiBaseUrl, cartoMapId }) {
|
|
8
|
+
return buildV3Path(apiBaseUrl, 'v3', 'maps', 'public', cartoMapId);
|
|
9
|
+
}
|
|
10
|
+
export function buildStatsUrl({ attribute, apiBaseUrl, connectionName, source, type }) {
|
|
11
|
+
if (type === 'query') {
|
|
12
|
+
return buildV3Path(apiBaseUrl, 'v3', 'stats', connectionName, attribute);
|
|
13
|
+
}
|
|
14
|
+
// type === 'table'
|
|
15
|
+
return buildV3Path(apiBaseUrl, 'v3', 'stats', connectionName, source, attribute);
|
|
16
|
+
}
|
|
17
|
+
export function buildSourceUrl({ apiBaseUrl, connectionName, endpoint }) {
|
|
18
|
+
return buildV3Path(apiBaseUrl, 'v3', 'maps', connectionName, endpoint);
|
|
19
|
+
}
|
|
20
|
+
export function buildQueryUrl({ apiBaseUrl, connectionName }) {
|
|
21
|
+
return buildV3Path(apiBaseUrl, 'v3', 'sql', connectionName, 'query');
|
|
22
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
/**
|
|
3
|
+
* Maps API Client for Carto 3
|
|
4
|
+
*/
|
|
5
|
+
import { CartoAPIError } from "./carto-api-error.js";
|
|
6
|
+
import { DEFAULT_API_BASE_URL, DEFAULT_CLIENT } from "./common.js";
|
|
7
|
+
import { buildPublicMapUrl, buildStatsUrl } from "./endpoints.js";
|
|
8
|
+
import { h3QuerySource, h3TableSource, quadbinQuerySource, quadbinTableSource, vectorQuerySource, vectorTableSource, vectorTilesetSource } from "../sources/index.js";
|
|
9
|
+
import { parseMap } from "./parse-map.js";
|
|
10
|
+
import { requestWithParameters } from "./request-with-parameters.js";
|
|
11
|
+
import { assert } from "../utils.js";
|
|
12
|
+
/* global clearInterval, setInterval, URL */
|
|
13
|
+
/* eslint-disable complexity, max-statements */
|
|
14
|
+
async function _fetchMapDataset(dataset, accessToken, apiBaseUrl, clientId, headers) {
|
|
15
|
+
const { aggregationExp, aggregationResLevel, connectionName, columns, format, geoColumn, source, type, queryParameters } = dataset;
|
|
16
|
+
const cache = {};
|
|
17
|
+
const globalOptions = {
|
|
18
|
+
accessToken,
|
|
19
|
+
apiBaseUrl,
|
|
20
|
+
cache,
|
|
21
|
+
clientId,
|
|
22
|
+
connectionName,
|
|
23
|
+
format,
|
|
24
|
+
headers
|
|
25
|
+
};
|
|
26
|
+
if (type === 'tileset') {
|
|
27
|
+
// TODO do we want a generic tilesetSource?
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
dataset.data = await vectorTilesetSource({ ...globalOptions, tableName: source });
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const [spatialDataType, spatialDataColumn] = geoColumn ? geoColumn.split(':') : ['geom'];
|
|
33
|
+
if (spatialDataType === 'geom') {
|
|
34
|
+
const options = { ...globalOptions, spatialDataColumn };
|
|
35
|
+
if (type === 'table') {
|
|
36
|
+
dataset.data = await vectorTableSource({ ...options, columns, tableName: source });
|
|
37
|
+
}
|
|
38
|
+
else if (type === 'query') {
|
|
39
|
+
dataset.data = await vectorQuerySource({ ...options, sqlQuery: source, queryParameters });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (spatialDataType === 'h3') {
|
|
43
|
+
const options = { ...globalOptions, aggregationExp, aggregationResLevel, spatialDataColumn };
|
|
44
|
+
if (type === 'table') {
|
|
45
|
+
dataset.data = await h3TableSource({ ...options, columns, tableName: source });
|
|
46
|
+
}
|
|
47
|
+
else if (type === 'query') {
|
|
48
|
+
dataset.data = await h3QuerySource({ ...options, sqlQuery: source, queryParameters });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if (spatialDataType === 'quadbin') {
|
|
52
|
+
const options = { ...globalOptions, aggregationExp, aggregationResLevel, spatialDataColumn };
|
|
53
|
+
if (type === 'table') {
|
|
54
|
+
dataset.data = await quadbinTableSource({ ...options, columns, tableName: source });
|
|
55
|
+
}
|
|
56
|
+
else if (type === 'query') {
|
|
57
|
+
dataset.data = await quadbinQuerySource({ ...options, sqlQuery: source, queryParameters });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
let cacheChanged = true;
|
|
62
|
+
if (cache.value) {
|
|
63
|
+
cacheChanged = dataset.cache !== cache.value;
|
|
64
|
+
dataset.cache = cache.value;
|
|
65
|
+
}
|
|
66
|
+
return cacheChanged;
|
|
67
|
+
}
|
|
68
|
+
async function _fetchTilestats(attribute, dataset, accessToken, apiBaseUrl) {
|
|
69
|
+
const { connectionName, data, id, source, type, queryParameters } = dataset;
|
|
70
|
+
const errorContext = {
|
|
71
|
+
requestType: 'Tile stats',
|
|
72
|
+
connection: connectionName,
|
|
73
|
+
type,
|
|
74
|
+
source
|
|
75
|
+
};
|
|
76
|
+
if (!('tilestats' in data)) {
|
|
77
|
+
throw new CartoAPIError(new Error(`Invalid dataset for tilestats: ${id}`), errorContext);
|
|
78
|
+
}
|
|
79
|
+
const baseUrl = buildStatsUrl({ attribute, apiBaseUrl, ...dataset });
|
|
80
|
+
const headers = { Authorization: `Bearer ${accessToken}` };
|
|
81
|
+
const parameters = {};
|
|
82
|
+
if (type === 'query') {
|
|
83
|
+
parameters.q = source;
|
|
84
|
+
if (queryParameters) {
|
|
85
|
+
parameters.queryParameters = JSON.stringify(queryParameters);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const stats = await requestWithParameters({
|
|
89
|
+
baseUrl,
|
|
90
|
+
headers,
|
|
91
|
+
parameters,
|
|
92
|
+
errorContext
|
|
93
|
+
});
|
|
94
|
+
// Replace tilestats for attribute with value from API
|
|
95
|
+
const { attributes } = data.tilestats.layers[0];
|
|
96
|
+
const index = attributes.findIndex(d => d.attribute === attribute);
|
|
97
|
+
attributes[index] = stats;
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
async function fillInMapDatasets({ datasets, token }, clientId, apiBaseUrl, headers) {
|
|
101
|
+
const promises = datasets.map(dataset => _fetchMapDataset(dataset, token, apiBaseUrl, clientId, headers));
|
|
102
|
+
return await Promise.all(promises);
|
|
103
|
+
}
|
|
104
|
+
async function fillInTileStats({ datasets, keplerMapConfig, token }, apiBaseUrl) {
|
|
105
|
+
const attributes = [];
|
|
106
|
+
const { layers } = keplerMapConfig.config.visState;
|
|
107
|
+
for (const layer of layers) {
|
|
108
|
+
for (const channel of Object.keys(layer.visualChannels)) {
|
|
109
|
+
const attribute = layer.visualChannels[channel]?.name;
|
|
110
|
+
if (attribute) {
|
|
111
|
+
const dataset = datasets.find(d => d.id === layer.config.dataId);
|
|
112
|
+
if (dataset && dataset.type !== 'tileset' && dataset.data.tilestats) {
|
|
113
|
+
// Only fetch stats for QUERY & TABLE map types
|
|
114
|
+
attributes.push({ attribute, dataset });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Remove duplicates to avoid repeated requests
|
|
120
|
+
const filteredAttributes = [];
|
|
121
|
+
for (const a of attributes) {
|
|
122
|
+
if (!filteredAttributes.find(({ attribute, dataset }) => attribute === a.attribute && dataset === a.dataset)) {
|
|
123
|
+
filteredAttributes.push(a);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const promises = filteredAttributes.map(({ attribute, dataset }) => _fetchTilestats(attribute, dataset, token, apiBaseUrl));
|
|
127
|
+
return await Promise.all(promises);
|
|
128
|
+
}
|
|
129
|
+
/* eslint-disable max-statements */
|
|
130
|
+
export async function fetchMap({ apiBaseUrl = DEFAULT_API_BASE_URL, cartoMapId, clientId = DEFAULT_CLIENT, headers = {}, autoRefresh, onNewData }) {
|
|
131
|
+
assert(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})');
|
|
132
|
+
assert(apiBaseUrl, 'Must define apiBaseUrl');
|
|
133
|
+
if (autoRefresh || onNewData) {
|
|
134
|
+
assert(onNewData, 'Must define `onNewData` when using autoRefresh');
|
|
135
|
+
assert(typeof onNewData === 'function', '`onNewData` must be a function');
|
|
136
|
+
assert(typeof autoRefresh === 'number' && autoRefresh > 0, '`autoRefresh` must be a positive number');
|
|
137
|
+
}
|
|
138
|
+
const baseUrl = buildPublicMapUrl({ apiBaseUrl, cartoMapId });
|
|
139
|
+
const errorContext = { requestType: 'Public map', mapId: cartoMapId };
|
|
140
|
+
const map = await requestWithParameters({ baseUrl, headers, errorContext });
|
|
141
|
+
// Periodically check if the data has changed. Note that this
|
|
142
|
+
// will not update when a map is published.
|
|
143
|
+
let stopAutoRefresh;
|
|
144
|
+
if (autoRefresh) {
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
146
|
+
const intervalId = setInterval(async () => {
|
|
147
|
+
const changed = await fillInMapDatasets(map, clientId, apiBaseUrl, {
|
|
148
|
+
...headers,
|
|
149
|
+
'If-Modified-Since': new Date().toUTCString()
|
|
150
|
+
});
|
|
151
|
+
if (onNewData && changed.some(v => v === true)) {
|
|
152
|
+
onNewData(parseMap(map));
|
|
153
|
+
}
|
|
154
|
+
}, autoRefresh * 1000);
|
|
155
|
+
stopAutoRefresh = () => {
|
|
156
|
+
clearInterval(intervalId);
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const geojsonLayers = map.keplerMapConfig.config.visState.layers.filter(({ type }) => type === 'geojson' || type === 'point');
|
|
160
|
+
const geojsonDatasetIds = geojsonLayers.map(({ config }) => config.dataId);
|
|
161
|
+
map.datasets.forEach(dataset => {
|
|
162
|
+
if (geojsonDatasetIds.includes(dataset.id)) {
|
|
163
|
+
const { config } = geojsonLayers.find(({ config }) => config.dataId === dataset.id);
|
|
164
|
+
dataset.format = 'geojson';
|
|
165
|
+
// Support for very old maps. geoColumn was not stored in the past
|
|
166
|
+
if (!dataset.geoColumn && config.columns.geojson) {
|
|
167
|
+
dataset.geoColumn = config.columns.geojson;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
// Mutates map.datasets so that dataset.data contains data
|
|
172
|
+
await fillInMapDatasets(map, clientId, apiBaseUrl, headers);
|
|
173
|
+
// Mutates attributes in visualChannels to contain tile stats
|
|
174
|
+
await fillInTileStats(map, apiBaseUrl);
|
|
175
|
+
const out = { ...parseMap(map), ...{ stopAutoRefresh } };
|
|
176
|
+
const textLayers = out.layers.filter(layer => {
|
|
177
|
+
const pointType = layer.props.pointType || '';
|
|
178
|
+
return pointType.includes('text');
|
|
179
|
+
});
|
|
180
|
+
/* global FontFace, window, document */
|
|
181
|
+
if (textLayers.length && window.FontFace && !document.fonts.check('12px Inter')) {
|
|
182
|
+
// Fetch font needed for labels
|
|
183
|
+
const font = new FontFace('Inter', 'url(https://fonts.gstatic.com/s/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7W0Q5nw.woff2)');
|
|
184
|
+
await font.load().then(f => document.fonts.add(f));
|
|
185
|
+
}
|
|
186
|
+
return out;
|
|
187
|
+
}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { deviation, extent, groupSort, median, variance } from 'd3-array';
|
|
2
|
+
import { rgb } from 'd3-color';
|
|
3
|
+
import { scaleLinear, scaleOrdinal, scaleLog, scalePoint, scaleQuantile, scaleQuantize, scaleSqrt, scaleThreshold } from 'd3-scale';
|
|
4
|
+
import { format as d3Format } from 'd3-format';
|
|
5
|
+
import moment from 'moment-timezone';
|
|
6
|
+
import { CPUGridLayer, HeatmapLayer, HexagonLayer } from '@deck.gl/aggregation-layers';
|
|
7
|
+
import { GeoJsonLayer } from '@deck.gl/layers';
|
|
8
|
+
import { H3HexagonLayer } from '@deck.gl/geo-layers';
|
|
9
|
+
import H3TileLayer from "../layers/h3-tile-layer.js";
|
|
10
|
+
import QuadbinTileLayer from "../layers/quadbin-tile-layer.js";
|
|
11
|
+
import RasterTileLayer from "../layers/raster-tile-layer.js";
|
|
12
|
+
import VectorTileLayer from "../layers/vector-tile-layer.js";
|
|
13
|
+
import { assert, createBinaryProxy, scaleIdentity } from "../utils.js";
|
|
14
|
+
const SCALE_FUNCS = {
|
|
15
|
+
linear: scaleLinear,
|
|
16
|
+
ordinal: scaleOrdinal,
|
|
17
|
+
log: scaleLog,
|
|
18
|
+
point: scalePoint,
|
|
19
|
+
quantile: scaleQuantile,
|
|
20
|
+
quantize: scaleQuantize,
|
|
21
|
+
sqrt: scaleSqrt,
|
|
22
|
+
custom: scaleThreshold,
|
|
23
|
+
identity: scaleIdentity
|
|
24
|
+
};
|
|
25
|
+
function identity(v) {
|
|
26
|
+
return v;
|
|
27
|
+
}
|
|
28
|
+
const UNKNOWN_COLOR = '#868d91';
|
|
29
|
+
export const AGGREGATION = {
|
|
30
|
+
average: 'MEAN',
|
|
31
|
+
maximum: 'MAX',
|
|
32
|
+
minimum: 'MIN',
|
|
33
|
+
sum: 'SUM'
|
|
34
|
+
};
|
|
35
|
+
export const OPACITY_MAP = {
|
|
36
|
+
getFillColor: 'opacity',
|
|
37
|
+
getLineColor: 'strokeOpacity',
|
|
38
|
+
getTextColor: 'opacity'
|
|
39
|
+
};
|
|
40
|
+
const AGGREGATION_FUNC = {
|
|
41
|
+
'count unique': (values, accessor) => groupSort(values, v => v.length, accessor).length,
|
|
42
|
+
median,
|
|
43
|
+
// Unfortunately mode() is only available in d3-array@3+ which is ESM only
|
|
44
|
+
mode: (values, accessor) => groupSort(values, v => v.length, accessor).pop(),
|
|
45
|
+
stddev: deviation,
|
|
46
|
+
variance
|
|
47
|
+
};
|
|
48
|
+
const hexToRGBA = c => {
|
|
49
|
+
const { r, g, b, opacity } = rgb(c);
|
|
50
|
+
return [r, g, b, 255 * opacity];
|
|
51
|
+
};
|
|
52
|
+
// Kepler prop value -> Deck.gl prop value
|
|
53
|
+
// Supports nested definitions, and function transforms:
|
|
54
|
+
// {keplerProp: 'deckProp'} is equivalent to:
|
|
55
|
+
// {keplerProp: x => ({deckProp: x})}
|
|
56
|
+
const sharedPropMap = {
|
|
57
|
+
// Apply the value of Kepler `color` prop to the deck `getFillColor` prop
|
|
58
|
+
color: 'getFillColor',
|
|
59
|
+
isVisible: 'visible',
|
|
60
|
+
label: 'cartoLabel',
|
|
61
|
+
textLabel: {
|
|
62
|
+
alignment: 'getTextAlignmentBaseline',
|
|
63
|
+
anchor: 'getTextAnchor',
|
|
64
|
+
// Apply the value of Kepler `textLabel.color` prop to the deck `getTextColor` prop
|
|
65
|
+
color: 'getTextColor',
|
|
66
|
+
size: 'getTextSize'
|
|
67
|
+
},
|
|
68
|
+
visConfig: {
|
|
69
|
+
enable3d: 'extruded',
|
|
70
|
+
elevationScale: 'elevationScale',
|
|
71
|
+
filled: 'filled',
|
|
72
|
+
strokeColor: 'getLineColor',
|
|
73
|
+
stroked: 'stroked',
|
|
74
|
+
thickness: 'getLineWidth',
|
|
75
|
+
radius: 'getPointRadius',
|
|
76
|
+
wireframe: 'wireframe'
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const customMarkersPropsMap = {
|
|
80
|
+
color: 'getIconColor',
|
|
81
|
+
visConfig: {
|
|
82
|
+
radius: 'getIconSize'
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const aggregationVisConfig = {
|
|
86
|
+
colorAggregation: x => ({ colorAggregation: AGGREGATION[x] || AGGREGATION.sum }),
|
|
87
|
+
colorRange: x => ({ colorRange: x.colors.map(hexToRGBA) }),
|
|
88
|
+
coverage: 'coverage',
|
|
89
|
+
elevationPercentile: ['elevationLowerPercentile', 'elevationUpperPercentile'],
|
|
90
|
+
percentile: ['lowerPercentile', 'upperPercentile']
|
|
91
|
+
};
|
|
92
|
+
const defaultProps = {
|
|
93
|
+
lineMiterLimit: 2,
|
|
94
|
+
lineWidthUnits: 'pixels',
|
|
95
|
+
pointRadiusUnits: 'pixels',
|
|
96
|
+
rounded: true,
|
|
97
|
+
wrapLongitude: false
|
|
98
|
+
};
|
|
99
|
+
function mergePropMaps(a = {}, b = {}) {
|
|
100
|
+
return { ...a, ...b, visConfig: { ...a.visConfig, ...b.visConfig } };
|
|
101
|
+
}
|
|
102
|
+
export function getLayer(type, config, dataset) {
|
|
103
|
+
let basePropMap = sharedPropMap;
|
|
104
|
+
if (config.visConfig?.customMarkers) {
|
|
105
|
+
basePropMap = mergePropMaps(sharedPropMap, customMarkersPropsMap);
|
|
106
|
+
}
|
|
107
|
+
if (type === 'mvt' || type === 'tileset' || type === 'h3' || type === 'quadbin') {
|
|
108
|
+
return getTileLayer(dataset, basePropMap);
|
|
109
|
+
}
|
|
110
|
+
const geoColumn = dataset?.geoColumn;
|
|
111
|
+
const getPosition = d => d[geoColumn].coordinates;
|
|
112
|
+
const hexagonId = config.columns?.hex_id;
|
|
113
|
+
const layerTypeDefs = {
|
|
114
|
+
point: {
|
|
115
|
+
Layer: GeoJsonLayer,
|
|
116
|
+
propMap: {
|
|
117
|
+
columns: {
|
|
118
|
+
altitude: x => ({ parameters: { depthTest: Boolean(x) } })
|
|
119
|
+
},
|
|
120
|
+
visConfig: { outline: 'stroked' }
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
geojson: {
|
|
124
|
+
Layer: GeoJsonLayer
|
|
125
|
+
},
|
|
126
|
+
grid: {
|
|
127
|
+
Layer: CPUGridLayer,
|
|
128
|
+
propMap: { visConfig: { ...aggregationVisConfig, worldUnitSize: x => ({ cellSize: 1000 * x }) } },
|
|
129
|
+
defaultProps: { getPosition }
|
|
130
|
+
},
|
|
131
|
+
heatmap: {
|
|
132
|
+
Layer: HeatmapLayer,
|
|
133
|
+
propMap: { visConfig: { ...aggregationVisConfig, radius: 'radiusPixels' } },
|
|
134
|
+
defaultProps: { getPosition }
|
|
135
|
+
},
|
|
136
|
+
hexagon: {
|
|
137
|
+
Layer: HexagonLayer,
|
|
138
|
+
propMap: { visConfig: { ...aggregationVisConfig, worldUnitSize: x => ({ radius: 1000 * x }) } },
|
|
139
|
+
defaultProps: { getPosition }
|
|
140
|
+
},
|
|
141
|
+
hexagonId: {
|
|
142
|
+
Layer: H3HexagonLayer,
|
|
143
|
+
propMap: { visConfig: { coverage: 'coverage' } },
|
|
144
|
+
defaultProps: { getHexagon: d => d[hexagonId], stroked: false }
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const layer = layerTypeDefs[type];
|
|
148
|
+
assert(layer, `Unsupported layer type: ${type}`);
|
|
149
|
+
return {
|
|
150
|
+
...layer,
|
|
151
|
+
propMap: mergePropMaps(basePropMap, layer.propMap),
|
|
152
|
+
defaultProps: { ...defaultProps, ...layer.defaultProps }
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
export function layerFromTileDataset(scheme, type) {
|
|
156
|
+
if (type === 'raster') {
|
|
157
|
+
return RasterTileLayer;
|
|
158
|
+
}
|
|
159
|
+
if (scheme === 'h3') {
|
|
160
|
+
return H3TileLayer;
|
|
161
|
+
}
|
|
162
|
+
if (scheme === 'quadbin') {
|
|
163
|
+
return QuadbinTileLayer;
|
|
164
|
+
}
|
|
165
|
+
return VectorTileLayer;
|
|
166
|
+
}
|
|
167
|
+
function getTileLayer(dataset, basePropMap) {
|
|
168
|
+
const { aggregationExp, aggregationResLevel, data: { scheme } } = dataset;
|
|
169
|
+
return {
|
|
170
|
+
Layer: layerFromTileDataset(scheme),
|
|
171
|
+
propMap: basePropMap,
|
|
172
|
+
defaultProps: {
|
|
173
|
+
...defaultProps,
|
|
174
|
+
...(aggregationExp && { aggregationExp }),
|
|
175
|
+
...(aggregationResLevel && { aggregationResLevel }),
|
|
176
|
+
uniqueIdProperty: 'geoid'
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function domainFromAttribute(attribute, scaleType, scaleLength) {
|
|
181
|
+
if (scaleType === 'ordinal' || scaleType === 'point') {
|
|
182
|
+
return attribute.categories.map(c => c.category).filter(c => c !== undefined && c !== null);
|
|
183
|
+
}
|
|
184
|
+
if (scaleType === 'quantile' && attribute.quantiles) {
|
|
185
|
+
return attribute.quantiles.global
|
|
186
|
+
? attribute.quantiles.global[scaleLength]
|
|
187
|
+
: attribute.quantiles[scaleLength];
|
|
188
|
+
}
|
|
189
|
+
let { min } = attribute;
|
|
190
|
+
if (scaleType === 'log' && min === 0) {
|
|
191
|
+
min = 1e-5;
|
|
192
|
+
}
|
|
193
|
+
return [min, attribute.max];
|
|
194
|
+
}
|
|
195
|
+
function domainFromValues(values, scaleType) {
|
|
196
|
+
if (scaleType === 'ordinal' || scaleType === 'point') {
|
|
197
|
+
return groupSort(values, g => -g.length, d => d);
|
|
198
|
+
}
|
|
199
|
+
else if (scaleType === 'quantile') {
|
|
200
|
+
return values.sort((a, b) => a - b);
|
|
201
|
+
}
|
|
202
|
+
else if (scaleType === 'log') {
|
|
203
|
+
const [d0, d1] = extent(values);
|
|
204
|
+
return [d0 === 0 ? 1e-5 : d0, d1];
|
|
205
|
+
}
|
|
206
|
+
return extent(values);
|
|
207
|
+
}
|
|
208
|
+
function calculateDomain(data, name, scaleType, scaleLength) {
|
|
209
|
+
if (data.tilestats) {
|
|
210
|
+
// Tileset data type
|
|
211
|
+
const { attributes } = data.tilestats.layers[0];
|
|
212
|
+
const attribute = attributes.find(a => a.attribute === name);
|
|
213
|
+
return domainFromAttribute(attribute, scaleType, scaleLength);
|
|
214
|
+
}
|
|
215
|
+
else if (data.features) {
|
|
216
|
+
// GeoJSON data type
|
|
217
|
+
const values = data.features.map(({ properties }) => properties[name]);
|
|
218
|
+
return domainFromValues(values, scaleType);
|
|
219
|
+
}
|
|
220
|
+
else if (Array.isArray(data) && data[0][name] !== undefined) {
|
|
221
|
+
// JSON data type
|
|
222
|
+
const values = data.map(properties => properties[name]);
|
|
223
|
+
return domainFromValues(values, scaleType);
|
|
224
|
+
}
|
|
225
|
+
return [0, 1];
|
|
226
|
+
}
|
|
227
|
+
function normalizeAccessor(accessor, data) {
|
|
228
|
+
if (data.features || data.tilestats) {
|
|
229
|
+
return (object, info) => {
|
|
230
|
+
if (object) {
|
|
231
|
+
return accessor(object.properties || object.__source.object.properties);
|
|
232
|
+
}
|
|
233
|
+
const { data, index } = info;
|
|
234
|
+
const proxy = createBinaryProxy(data, index);
|
|
235
|
+
return accessor(proxy);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
return accessor;
|
|
239
|
+
}
|
|
240
|
+
export function opacityToAlpha(opacity) {
|
|
241
|
+
return opacity !== undefined ? Math.round(255 * Math.pow(opacity, 1 / 2.2)) : 255;
|
|
242
|
+
}
|
|
243
|
+
function getAccessorKeys(name, aggregation) {
|
|
244
|
+
let keys = [name];
|
|
245
|
+
if (aggregation) {
|
|
246
|
+
// Snowflake will capitalized the keys, need to check lower and upper case version
|
|
247
|
+
keys = keys.concat([aggregation, aggregation.toUpperCase()].map(a => `${name}_${a}`));
|
|
248
|
+
}
|
|
249
|
+
return keys;
|
|
250
|
+
}
|
|
251
|
+
function findAccessorKey(keys, properties) {
|
|
252
|
+
for (const key of keys) {
|
|
253
|
+
if (key in properties) {
|
|
254
|
+
return [key];
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
throw new Error(`Could not find property for any accessor key: ${keys}`);
|
|
258
|
+
}
|
|
259
|
+
export function getColorValueAccessor({ name }, colorAggregation, data) {
|
|
260
|
+
const aggregator = AGGREGATION_FUNC[colorAggregation];
|
|
261
|
+
const accessor = values => aggregator(values, p => p[name]);
|
|
262
|
+
return normalizeAccessor(accessor, data);
|
|
263
|
+
}
|
|
264
|
+
export function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range }, opacity, data) {
|
|
265
|
+
const scale = calculateLayerScale(colorColumn || name, scaleType, range, data);
|
|
266
|
+
const alpha = opacityToAlpha(opacity);
|
|
267
|
+
let accessorKeys = getAccessorKeys(name, aggregation);
|
|
268
|
+
const accessor = properties => {
|
|
269
|
+
if (!(accessorKeys[0] in properties)) {
|
|
270
|
+
accessorKeys = findAccessorKey(accessorKeys, properties);
|
|
271
|
+
}
|
|
272
|
+
const propertyValue = properties[accessorKeys[0]];
|
|
273
|
+
const { r, g, b } = rgb(scale(propertyValue));
|
|
274
|
+
return [r, g, b, propertyValue === null ? 0 : alpha];
|
|
275
|
+
};
|
|
276
|
+
return normalizeAccessor(accessor, data);
|
|
277
|
+
}
|
|
278
|
+
function calculateLayerScale(name, scaleType, range, data) {
|
|
279
|
+
const scale = SCALE_FUNCS[scaleType]();
|
|
280
|
+
let domain = [];
|
|
281
|
+
let scaleColor = [];
|
|
282
|
+
if (scaleType !== 'identity') {
|
|
283
|
+
const { colorMap, colors } = range;
|
|
284
|
+
if (Array.isArray(colorMap)) {
|
|
285
|
+
colorMap.forEach(([value, color]) => {
|
|
286
|
+
domain.push(value);
|
|
287
|
+
scaleColor.push(color);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
domain = calculateDomain(data, name, scaleType, colors.length);
|
|
292
|
+
scaleColor = colors;
|
|
293
|
+
}
|
|
294
|
+
if (scaleType === 'ordinal') {
|
|
295
|
+
domain = domain.slice(0, scaleColor.length);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
scale.domain(domain);
|
|
299
|
+
scale.range(scaleColor);
|
|
300
|
+
scale.unknown(UNKNOWN_COLOR);
|
|
301
|
+
return scale;
|
|
302
|
+
}
|
|
303
|
+
const FALLBACK_ICON = 'data:image/svg+xml;charset=utf-8;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNTAiLz4NCjwvc3ZnPg==';
|
|
304
|
+
export function getIconUrlAccessor(field, range, { fallbackUrl, maxIconSize, useMaskedIcons }, data) {
|
|
305
|
+
const urlToUnpackedIcon = (url) => ({
|
|
306
|
+
id: `${url}@@${maxIconSize}`,
|
|
307
|
+
url,
|
|
308
|
+
width: maxIconSize,
|
|
309
|
+
height: maxIconSize,
|
|
310
|
+
mask: useMaskedIcons
|
|
311
|
+
});
|
|
312
|
+
let unknownValue = fallbackUrl || FALLBACK_ICON;
|
|
313
|
+
if (range?.othersMarker) {
|
|
314
|
+
unknownValue = range.othersMarker;
|
|
315
|
+
}
|
|
316
|
+
const unknownIcon = urlToUnpackedIcon(unknownValue);
|
|
317
|
+
if (!range || !field) {
|
|
318
|
+
return () => unknownIcon;
|
|
319
|
+
}
|
|
320
|
+
const mapping = {};
|
|
321
|
+
for (const { value, markerUrl } of range.markerMap) {
|
|
322
|
+
if (markerUrl) {
|
|
323
|
+
mapping[value] = urlToUnpackedIcon(markerUrl);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const accessor = properties => {
|
|
327
|
+
const propertyValue = properties[field.name];
|
|
328
|
+
return mapping[propertyValue] || unknownIcon;
|
|
329
|
+
};
|
|
330
|
+
return normalizeAccessor(accessor, data);
|
|
331
|
+
}
|
|
332
|
+
export function getMaxMarkerSize(visConfig, visualChannels) {
|
|
333
|
+
const { radiusRange, radius } = visConfig;
|
|
334
|
+
const { radiusField, sizeField } = visualChannels;
|
|
335
|
+
const field = radiusField || sizeField;
|
|
336
|
+
return Math.ceil(radiusRange && field ? radiusRange[1] : radius);
|
|
337
|
+
}
|
|
338
|
+
export function negateAccessor(accessor) {
|
|
339
|
+
return typeof accessor === 'function' ? (d, i) => -accessor(d, i) : -accessor;
|
|
340
|
+
}
|
|
341
|
+
export function getSizeAccessor({ name }, scaleType, aggregation, range, data) {
|
|
342
|
+
const scale = scaleType ? SCALE_FUNCS[scaleType]() : identity;
|
|
343
|
+
if (scaleType) {
|
|
344
|
+
if (aggregation !== 'count') {
|
|
345
|
+
scale.domain(calculateDomain(data, name, scaleType));
|
|
346
|
+
}
|
|
347
|
+
scale.range(range);
|
|
348
|
+
}
|
|
349
|
+
let accessorKeys = getAccessorKeys(name, aggregation);
|
|
350
|
+
const accessor = properties => {
|
|
351
|
+
if (!(accessorKeys[0] in properties)) {
|
|
352
|
+
accessorKeys = findAccessorKey(accessorKeys, properties);
|
|
353
|
+
}
|
|
354
|
+
const propertyValue = properties[accessorKeys[0]];
|
|
355
|
+
return scale(propertyValue);
|
|
356
|
+
};
|
|
357
|
+
return normalizeAccessor(accessor, data);
|
|
358
|
+
}
|
|
359
|
+
const FORMATS = {
|
|
360
|
+
date: s => moment.utc(s).format('MM/DD/YY HH:mm:ssa'),
|
|
361
|
+
integer: d3Format('i'),
|
|
362
|
+
float: d3Format('.5f'),
|
|
363
|
+
timestamp: s => moment.utc(s).format('X'),
|
|
364
|
+
default: String
|
|
365
|
+
};
|
|
366
|
+
export function getTextAccessor({ name, type }, data) {
|
|
367
|
+
const format = FORMATS[type] || FORMATS.default;
|
|
368
|
+
const accessor = properties => {
|
|
369
|
+
return format(properties[name]);
|
|
370
|
+
};
|
|
371
|
+
return normalizeAccessor(accessor, data);
|
|
372
|
+
}
|
|
373
|
+
export { domainFromValues as _domainFromValues };
|