@deck.gl/carto 8.10.0-alpha.7 → 9.0.0-alpha.4
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/cartoRasterTile-worker.js +32 -24
- package/dist/cartoSpatialTile-worker.js +32 -24
- package/dist/cartoVectorTile-worker.js +69 -63
- package/dist/dist.dev.js +12061 -12560
- package/dist/es5/api/carto-api-error.js.map +1 -1
- package/dist/es5/api/common.js +25 -0
- package/dist/es5/api/common.js.map +1 -0
- package/dist/es5/api/endpoints.js +40 -0
- package/dist/es5/api/endpoints.js.map +1 -0
- package/dist/es5/api/fetch-map.js +568 -0
- package/dist/es5/api/fetch-map.js.map +1 -0
- package/dist/es5/api/index.js +5 -49
- package/dist/es5/api/index.js.map +1 -1
- package/dist/es5/api/layer-map.js +43 -45
- package/dist/es5/api/layer-map.js.map +1 -1
- package/dist/es5/api/{parseMap.js → parse-map.js} +5 -3
- package/dist/es5/api/parse-map.js.map +1 -0
- package/dist/es5/api/query.js +78 -0
- package/dist/es5/api/query.js.map +1 -0
- package/dist/es5/{sources/utils.js → api/request-with-parameters.js} +60 -46
- package/dist/es5/api/request-with-parameters.js.map +1 -0
- package/dist/es5/api/types.js +19 -0
- package/dist/es5/api/types.js.map +1 -1
- package/dist/es5/index.js +66 -80
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/layers/h3-tile-layer.js +3 -5
- package/dist/es5/layers/h3-tile-layer.js.map +1 -1
- package/dist/es5/layers/point-label-layer.js.map +1 -1
- package/dist/es5/layers/quadbin-layer.js.map +1 -1
- package/dist/es5/layers/quadbin-tile-layer.js +1 -4
- package/dist/es5/layers/quadbin-tile-layer.js.map +1 -1
- package/dist/es5/layers/raster-layer.js +2 -0
- package/dist/es5/layers/raster-layer.js.map +1 -1
- package/dist/es5/layers/raster-tile-layer.js +1 -3
- package/dist/es5/layers/raster-tile-layer.js.map +1 -1
- package/dist/es5/layers/schema/carto-properties-tile-loader.js +60 -0
- package/dist/es5/layers/schema/carto-properties-tile-loader.js.map +1 -0
- package/dist/es5/layers/schema/carto-properties-tile.js +38 -0
- package/dist/es5/layers/schema/carto-properties-tile.js.map +1 -0
- package/dist/es5/layers/schema/carto-raster-tile-loader.js +1 -1
- package/dist/es5/layers/schema/carto-raster-tile-loader.js.map +1 -1
- package/dist/es5/layers/schema/carto-spatial-tile-loader.js +1 -1
- package/dist/es5/layers/schema/carto-spatial-tile-loader.js.map +1 -1
- package/dist/es5/layers/schema/carto-vector-tile-loader.js +1 -2
- package/dist/es5/layers/schema/carto-vector-tile-loader.js.map +1 -1
- package/dist/es5/layers/spatial-index-tile-layer.js +16 -26
- package/dist/es5/layers/spatial-index-tile-layer.js.map +1 -1
- package/dist/es5/layers/utils.js +102 -0
- package/dist/es5/layers/utils.js.map +1 -1
- package/dist/es5/layers/vector-tile-layer.js +112 -27
- package/dist/es5/layers/vector-tile-layer.js.map +1 -1
- package/dist/es5/sources/base-source.js +56 -28
- package/dist/es5/sources/base-source.js.map +1 -1
- package/dist/es5/sources/boundary-query-source.js +51 -0
- package/dist/es5/sources/boundary-query-source.js.map +1 -0
- package/dist/es5/sources/boundary-table-source.js +51 -0
- package/dist/es5/sources/boundary-table-source.js.map +1 -0
- package/dist/es5/sources/boundary-tileset-source.js +43 -0
- package/dist/es5/sources/boundary-tileset-source.js.map +1 -0
- package/dist/es5/sources/h3-query-source.js +9 -11
- package/dist/es5/sources/h3-query-source.js.map +1 -1
- package/dist/es5/sources/h3-table-source.js +10 -12
- package/dist/es5/sources/h3-table-source.js.map +1 -1
- package/dist/es5/sources/h3-tileset-source.js +5 -5
- package/dist/es5/sources/h3-tileset-source.js.map +1 -1
- package/dist/es5/sources/index.js +46 -22
- package/dist/es5/sources/index.js.map +1 -1
- package/dist/es5/sources/quadbin-query-source.js +10 -12
- package/dist/es5/sources/quadbin-query-source.js.map +1 -1
- package/dist/es5/sources/quadbin-table-source.js +10 -12
- package/dist/es5/sources/quadbin-table-source.js.map +1 -1
- package/dist/es5/sources/quadbin-tileset-source.js +5 -5
- package/dist/es5/sources/quadbin-tileset-source.js.map +1 -1
- package/dist/es5/sources/raster-source.js +5 -5
- package/dist/es5/sources/raster-source.js.map +1 -1
- package/dist/es5/sources/types.js +2 -0
- package/dist/es5/sources/types.js.map +1 -0
- package/dist/es5/sources/vector-query-source.js +11 -12
- package/dist/es5/sources/vector-query-source.js.map +1 -1
- package/dist/es5/sources/vector-table-source.js +12 -13
- package/dist/es5/sources/vector-table-source.js.map +1 -1
- package/dist/es5/sources/vector-tileset-source.js +5 -5
- package/dist/es5/sources/vector-tileset-source.js.map +1 -1
- package/dist/es5/style/color-bins-style.js +4 -2
- package/dist/es5/style/color-bins-style.js.map +1 -1
- package/dist/es5/style/color-categories-style.js +4 -2
- package/dist/es5/style/color-categories-style.js.map +1 -1
- package/dist/es5/style/color-continuous-style.js +4 -2
- package/dist/es5/style/color-continuous-style.js.map +1 -1
- package/dist/es5/style/palette.js +1 -1
- package/dist/es5/style/palette.js.map +1 -1
- package/dist/es5/style/utils.js +4 -11
- package/dist/es5/style/utils.js.map +1 -1
- package/dist/es5/utils.js +30 -1
- package/dist/es5/utils.js.map +1 -1
- package/dist/esm/api/carto-api-error.js.map +1 -1
- package/dist/esm/api/common.js +13 -0
- package/dist/esm/api/common.js.map +1 -0
- package/dist/esm/api/endpoints.js +28 -0
- package/dist/esm/api/endpoints.js.map +1 -0
- package/dist/esm/api/fetch-map.js +300 -0
- package/dist/esm/api/fetch-map.js.map +1 -0
- package/dist/esm/api/index.js +2 -3
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/layer-map.js +43 -35
- package/dist/esm/api/layer-map.js.map +1 -1
- package/dist/esm/api/{parseMap.js → parse-map.js} +3 -2
- package/dist/esm/api/parse-map.js.map +1 -0
- package/dist/esm/api/query.js +38 -0
- package/dist/esm/api/query.js.map +1 -0
- package/dist/esm/{sources/utils.js → api/request-with-parameters.js} +25 -12
- package/dist/esm/api/request-with-parameters.js.map +1 -0
- package/dist/esm/api/types.js +13 -1
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/index.js +31 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/layers/h3-tile-layer.js +2 -6
- package/dist/esm/layers/h3-tile-layer.js.map +1 -1
- package/dist/esm/layers/point-label-layer.js.map +1 -1
- package/dist/esm/layers/quadbin-layer.js.map +1 -1
- package/dist/esm/layers/quadbin-tile-layer.js +1 -3
- package/dist/esm/layers/quadbin-tile-layer.js.map +1 -1
- package/dist/esm/layers/raster-layer.js +1 -0
- package/dist/esm/layers/raster-layer.js.map +1 -1
- package/dist/esm/layers/raster-tile-layer.js +1 -2
- package/dist/esm/layers/raster-tile-layer.js.map +1 -1
- package/dist/esm/layers/schema/carto-properties-tile-loader.js +23 -0
- package/dist/esm/layers/schema/carto-properties-tile-loader.js.map +1 -0
- package/dist/esm/layers/schema/carto-properties-tile.js +18 -0
- package/dist/esm/layers/schema/carto-properties-tile.js.map +1 -0
- package/dist/esm/layers/schema/carto-raster-tile-loader.js +1 -1
- package/dist/esm/layers/schema/carto-raster-tile-loader.js.map +1 -1
- package/dist/esm/layers/schema/carto-spatial-tile-loader.js +1 -1
- package/dist/esm/layers/schema/carto-spatial-tile-loader.js.map +1 -1
- package/dist/esm/layers/schema/carto-vector-tile-loader.js +1 -2
- package/dist/esm/layers/schema/carto-vector-tile-loader.js.map +1 -1
- package/dist/esm/layers/spatial-index-tile-layer.js +9 -24
- package/dist/esm/layers/spatial-index-tile-layer.js.map +1 -1
- package/dist/esm/layers/utils.js +71 -0
- package/dist/esm/layers/utils.js.map +1 -1
- package/dist/esm/layers/vector-tile-layer.js +40 -12
- package/dist/esm/layers/vector-tile-layer.js.map +1 -1
- package/dist/esm/sources/base-source.js +33 -10
- package/dist/esm/sources/base-source.js.map +1 -1
- package/dist/esm/sources/boundary-query-source.js +21 -0
- package/dist/esm/sources/boundary-query-source.js.map +1 -0
- package/dist/esm/sources/boundary-table-source.js +21 -0
- package/dist/esm/sources/boundary-table-source.js.map +1 -0
- package/dist/esm/sources/boundary-tileset-source.js +11 -0
- package/dist/esm/sources/boundary-tileset-source.js.map +1 -0
- package/dist/esm/sources/h3-query-source.js +6 -11
- package/dist/esm/sources/h3-query-source.js.map +1 -1
- package/dist/esm/sources/h3-table-source.js +7 -12
- package/dist/esm/sources/h3-table-source.js.map +1 -1
- package/dist/esm/sources/h3-tileset-source.js +3 -6
- package/dist/esm/sources/h3-tileset-source.js.map +1 -1
- package/dist/esm/sources/index.js +14 -11
- package/dist/esm/sources/index.js.map +1 -1
- package/dist/esm/sources/quadbin-query-source.js +7 -12
- package/dist/esm/sources/quadbin-query-source.js.map +1 -1
- package/dist/esm/sources/quadbin-table-source.js +7 -12
- package/dist/esm/sources/quadbin-table-source.js.map +1 -1
- package/dist/esm/sources/quadbin-tileset-source.js +3 -6
- package/dist/esm/sources/quadbin-tileset-source.js.map +1 -1
- package/dist/esm/sources/raster-source.js +3 -6
- package/dist/esm/sources/raster-source.js.map +1 -1
- package/dist/esm/sources/types.js +2 -0
- package/dist/esm/sources/types.js.map +1 -0
- package/dist/esm/sources/vector-query-source.js +6 -11
- package/dist/esm/sources/vector-query-source.js.map +1 -1
- package/dist/esm/sources/vector-table-source.js +7 -12
- package/dist/esm/sources/vector-table-source.js.map +1 -1
- package/dist/esm/sources/vector-tileset-source.js +3 -6
- package/dist/esm/sources/vector-tileset-source.js.map +1 -1
- package/dist/esm/style/color-bins-style.js +2 -1
- package/dist/esm/style/color-bins-style.js.map +1 -1
- package/dist/esm/style/color-categories-style.js +2 -1
- package/dist/esm/style/color-categories-style.js.map +1 -1
- package/dist/esm/style/color-continuous-style.js +2 -1
- package/dist/esm/style/color-continuous-style.js.map +1 -1
- package/dist/esm/style/palette.js +1 -1
- package/dist/esm/style/palette.js.map +1 -1
- package/dist/esm/style/utils.js +1 -5
- package/dist/esm/style/utils.js.map +1 -1
- package/dist/esm/utils.js +24 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist.min.js +42 -41
- package/package.json +10 -9
- package/src/api/carto-api-error.ts +1 -9
- package/src/api/common.ts +14 -0
- package/src/api/endpoints.ts +38 -0
- package/src/api/fetch-map.ts +294 -0
- package/src/api/index.ts +5 -5
- package/src/api/layer-map.ts +40 -36
- package/src/api/{parseMap.ts → parse-map.ts} +2 -2
- package/src/api/query.ts +34 -0
- package/src/{sources/utils.ts → api/request-with-parameters.ts} +22 -17
- package/src/api/types.ts +49 -0
- package/src/index.ts +93 -41
- package/src/layers/h3-tile-layer.ts +13 -18
- package/src/layers/point-label-layer.ts +1 -1
- package/src/layers/quadbin-layer.ts +3 -2
- package/src/layers/quadbin-tile-layer.ts +10 -11
- package/src/layers/raster-layer.ts +2 -2
- package/src/layers/raster-tile-layer.ts +11 -9
- package/src/layers/schema/carto-properties-tile-loader.ts +25 -0
- package/src/layers/schema/carto-properties-tile.ts +21 -0
- package/src/layers/schema/carto-vector-tile-loader.ts +1 -1
- package/src/layers/spatial-index-tile-layer.ts +18 -26
- package/src/layers/utils.ts +73 -0
- package/src/layers/vector-tile-layer.ts +40 -21
- package/src/sources/base-source.ts +35 -18
- package/src/sources/boundary-query-source.ts +31 -0
- package/src/sources/boundary-table-source.ts +31 -0
- package/src/sources/boundary-tileset-source.ts +14 -0
- package/src/sources/h3-query-source.ts +22 -22
- package/src/sources/h3-table-source.ts +22 -22
- package/src/sources/h3-tileset-source.ts +7 -9
- package/src/sources/index.ts +31 -22
- package/src/sources/quadbin-query-source.ts +22 -22
- package/src/sources/quadbin-table-source.ts +23 -22
- package/src/sources/quadbin-tileset-source.ts +7 -9
- package/src/sources/raster-source.ts +5 -9
- package/src/sources/types.ts +98 -0
- package/src/sources/vector-query-source.ts +15 -15
- package/src/sources/vector-table-source.ts +15 -15
- package/src/sources/vector-tileset-source.ts +7 -9
- package/src/style/color-bins-style.ts +2 -1
- package/src/style/color-categories-style.ts +2 -1
- package/src/style/color-continuous-style.ts +2 -1
- package/src/style/palette.ts +1 -1
- package/src/style/utils.ts +1 -6
- package/src/utils.ts +25 -1
- package/typed/api/carto-api-error.d.ts +1 -8
- package/typed/api/carto-api-error.d.ts.map +1 -1
- package/typed/api/common.d.ts +13 -0
- package/typed/api/common.d.ts.map +1 -0
- package/typed/api/endpoints.d.ts +12 -0
- package/typed/api/endpoints.d.ts.map +1 -0
- package/typed/api/fetch-map.d.ts +22 -0
- package/typed/api/fetch-map.d.ts.map +1 -0
- package/typed/api/index.d.ts +5 -5
- package/typed/api/index.d.ts.map +1 -1
- package/typed/api/layer-map.d.ts +6 -9
- package/typed/api/layer-map.d.ts.map +1 -1
- package/typed/api/{parseMap.d.ts → parse-map.d.ts} +1 -1
- package/typed/api/parse-map.d.ts.map +1 -0
- package/typed/api/query.d.ts +4 -0
- package/typed/api/query.d.ts.map +1 -0
- package/typed/api/request-with-parameters.d.ts +9 -0
- package/typed/api/request-with-parameters.d.ts.map +1 -0
- package/typed/api/types.d.ts +40 -0
- package/typed/api/types.d.ts.map +1 -1
- package/typed/index.d.ts +33 -12
- package/typed/index.d.ts.map +1 -1
- package/typed/layers/h3-tile-layer.d.ts +12 -7
- package/typed/layers/h3-tile-layer.d.ts.map +1 -1
- package/typed/layers/point-label-layer.d.ts +2 -2
- package/typed/layers/point-label-layer.d.ts.map +1 -1
- package/typed/layers/quadbin-layer.d.ts +2 -2
- package/typed/layers/quadbin-layer.d.ts.map +1 -1
- package/typed/layers/quadbin-tile-layer.d.ts +6 -6
- package/typed/layers/quadbin-tile-layer.d.ts.map +1 -1
- package/typed/layers/raster-layer.d.ts +2 -2
- package/typed/layers/raster-layer.d.ts.map +1 -1
- package/typed/layers/raster-tile-layer.d.ts +6 -5
- package/typed/layers/raster-tile-layer.d.ts.map +1 -1
- package/typed/layers/schema/carto-properties-tile-loader.d.ts +4 -0
- package/typed/layers/schema/carto-properties-tile-loader.d.ts.map +1 -0
- package/typed/layers/schema/carto-properties-tile.d.ts +10 -0
- package/typed/layers/schema/carto-properties-tile.d.ts.map +1 -0
- package/typed/layers/spatial-index-tile-layer.d.ts +10 -9
- package/typed/layers/spatial-index-tile-layer.d.ts.map +1 -1
- package/typed/layers/utils.d.ts +11 -0
- package/typed/layers/utils.d.ts.map +1 -1
- package/typed/layers/vector-tile-layer.d.ts +6 -11
- package/typed/layers/vector-tile-layer.d.ts.map +1 -1
- package/typed/sources/base-source.d.ts +4 -3
- package/typed/sources/base-source.d.ts.map +1 -1
- package/typed/sources/boundary-query-source.d.ts +10 -0
- package/typed/sources/boundary-query-source.d.ts.map +1 -0
- package/typed/sources/boundary-table-source.d.ts +9 -0
- package/typed/sources/boundary-table-source.d.ts.map +1 -0
- package/typed/sources/boundary-tileset-source.d.ts +6 -0
- package/typed/sources/boundary-tileset-source.d.ts.map +1 -0
- package/typed/sources/h3-query-source.d.ts +3 -4
- package/typed/sources/h3-query-source.d.ts.map +1 -1
- package/typed/sources/h3-table-source.d.ts +3 -4
- package/typed/sources/h3-table-source.d.ts.map +1 -1
- package/typed/sources/h3-tileset-source.d.ts +3 -4
- package/typed/sources/h3-tileset-source.d.ts.map +1 -1
- package/typed/sources/index.d.ts +28 -22
- package/typed/sources/index.d.ts.map +1 -1
- package/typed/sources/quadbin-query-source.d.ts +3 -4
- package/typed/sources/quadbin-query-source.d.ts.map +1 -1
- package/typed/sources/quadbin-table-source.d.ts +3 -4
- package/typed/sources/quadbin-table-source.d.ts.map +1 -1
- package/typed/sources/quadbin-tileset-source.d.ts +3 -4
- package/typed/sources/quadbin-tileset-source.d.ts.map +1 -1
- package/typed/sources/raster-source.d.ts +3 -4
- package/typed/sources/raster-source.d.ts.map +1 -1
- package/typed/sources/{common.d.ts → types.d.ts} +26 -42
- package/typed/sources/types.d.ts.map +1 -0
- package/typed/sources/vector-query-source.d.ts +3 -4
- package/typed/sources/vector-query-source.d.ts.map +1 -1
- package/typed/sources/vector-table-source.d.ts +3 -4
- package/typed/sources/vector-table-source.d.ts.map +1 -1
- package/typed/sources/vector-tileset-source.d.ts +3 -4
- package/typed/sources/vector-tileset-source.d.ts.map +1 -1
- package/typed/style/color-bins-style.d.ts.map +1 -1
- package/typed/style/color-categories-style.d.ts.map +1 -1
- package/typed/style/color-continuous-style.d.ts.map +1 -1
- package/typed/style/utils.d.ts +0 -1
- package/typed/style/utils.d.ts.map +1 -1
- package/typed/utils.d.ts +8 -0
- package/typed/utils.d.ts.map +1 -1
- package/LICENSE +0 -19
- package/dist/es5/api/maps-api-common.js +0 -77
- package/dist/es5/api/maps-api-common.js.map +0 -1
- package/dist/es5/api/maps-client.js +0 -220
- package/dist/es5/api/maps-client.js.map +0 -1
- package/dist/es5/api/maps-v3-client.js +0 -959
- package/dist/es5/api/maps-v3-client.js.map +0 -1
- package/dist/es5/api/parseMap.js.map +0 -1
- package/dist/es5/config.js +0 -84
- package/dist/es5/config.js.map +0 -1
- package/dist/es5/layers/carto-layer.js +0 -329
- package/dist/es5/layers/carto-layer.js.map +0 -1
- package/dist/es5/sources/common.js +0 -48
- package/dist/es5/sources/common.js.map +0 -1
- package/dist/es5/sources/utils.js.map +0 -1
- package/dist/esm/api/maps-api-common.js +0 -54
- package/dist/esm/api/maps-api-common.js.map +0 -1
- package/dist/esm/api/maps-client.js +0 -148
- package/dist/esm/api/maps-client.js.map +0 -1
- package/dist/esm/api/maps-v3-client.js +0 -638
- package/dist/esm/api/maps-v3-client.js.map +0 -1
- package/dist/esm/api/parseMap.js.map +0 -1
- package/dist/esm/config.js +0 -60
- package/dist/esm/config.js.map +0 -1
- package/dist/esm/layers/carto-layer.js +0 -233
- package/dist/esm/layers/carto-layer.js.map +0 -1
- package/dist/esm/sources/common.js +0 -26
- package/dist/esm/sources/common.js.map +0 -1
- package/dist/esm/sources/utils.js.map +0 -1
- package/src/api/maps-api-common.ts +0 -95
- package/src/api/maps-client.ts +0 -196
- package/src/api/maps-v3-client.ts +0 -659
- package/src/config.ts +0 -70
- package/src/layers/carto-layer.ts +0 -340
- package/src/sources/common.ts +0 -132
- package/typed/api/maps-api-common.d.ts +0 -76
- package/typed/api/maps-api-common.d.ts.map +0 -1
- package/typed/api/maps-client.d.ts +0 -18
- package/typed/api/maps-client.d.ts.map +0 -1
- package/typed/api/maps-v3-client.d.ts +0 -49
- package/typed/api/maps-v3-client.d.ts.map +0 -1
- package/typed/api/parseMap.d.ts.map +0 -1
- package/typed/config.d.ts +0 -28
- package/typed/config.d.ts.map +0 -1
- package/typed/layers/carto-layer.d.ts +0 -126
- package/typed/layers/carto-layer.d.ts.map +0 -1
- package/typed/sources/common.d.ts.map +0 -1
- package/typed/sources/utils.d.ts +0 -15
- package/typed/sources/utils.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/api/common.ts"],"names":["DEFAULT_API_BASE_URL","DEFAULT_CLIENT","V3_MINOR_VERSION","MAX_GET_LENGTH","DEFAULT_PARAMETERS","client","v","DEFAULT_HEADERS","Accept"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG,oCAA7B;AACP,OAAO,MAAMC,cAAc,GAAG,eAAvB;AACP,OAAO,MAAMC,gBAAgB,GAAG,KAAzB;AACP,OAAO,MAAMC,cAAc,GAAG,IAAvB;AAEP,OAAO,MAAMC,kBAAkB,GAAG;AAChCC,EAAAA,MAAM,EAAEJ,cADwB;AAEhCK,EAAAA,CAAC,EAAEJ;AAF6B,CAA3B;AAKP,OAAO,MAAMK,eAAe,GAAG;AAC7BC,EAAAA,MAAM,EAAE,kBADqB;AAE7B,kBAAgB;AAFa,CAAxB","sourcesContent":["export const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';\nexport const DEFAULT_CLIENT = 'deck-gl-carto';\nexport const V3_MINOR_VERSION = '3.3';\nexport const MAX_GET_LENGTH = 8192;\n\nexport const DEFAULT_PARAMETERS = {\n client: DEFAULT_CLIENT,\n v: V3_MINOR_VERSION\n};\n\nexport const DEFAULT_HEADERS = {\n Accept: 'application/json',\n 'Content-Type': 'application/json'\n};\n"],"file":"common.js"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function buildUrlFromBase(apiBaseUrl, endpoint) {
|
|
2
|
+
let suffix = `/v3/${endpoint}`;
|
|
3
|
+
|
|
4
|
+
if (apiBaseUrl.endsWith('/')) {
|
|
5
|
+
suffix = suffix.substring(1);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return `${apiBaseUrl}${suffix}`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function buildMapsUrlFromBase(apiBaseUrl) {
|
|
12
|
+
return buildUrlFromBase(apiBaseUrl, 'maps');
|
|
13
|
+
}
|
|
14
|
+
export function buildStatsUrlFromBase(apiBaseUrl) {
|
|
15
|
+
return buildUrlFromBase(apiBaseUrl, 'stats');
|
|
16
|
+
}
|
|
17
|
+
export function buildQueryUrlFromBase(apiBaseUrl) {
|
|
18
|
+
return buildUrlFromBase(apiBaseUrl, 'sql');
|
|
19
|
+
}
|
|
20
|
+
export function buildSourceUrl({
|
|
21
|
+
apiBaseUrl,
|
|
22
|
+
connectionName,
|
|
23
|
+
endpoint,
|
|
24
|
+
mapsUrl
|
|
25
|
+
}) {
|
|
26
|
+
return `${mapsUrl || buildMapsUrlFromBase(apiBaseUrl)}/${connectionName}/${endpoint}`;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=endpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/api/endpoints.ts"],"names":["buildUrlFromBase","apiBaseUrl","endpoint","suffix","endsWith","substring","buildMapsUrlFromBase","buildStatsUrlFromBase","buildQueryUrlFromBase","buildSourceUrl","connectionName","mapsUrl"],"mappings":"AAIA,SAASA,gBAAT,CAA0BC,UAA1B,EAA8CC,QAA9C,EAAoE;AAClE,MAAIC,MAAM,GAAI,OAAMD,QAAS,EAA7B;;AACA,MAAID,UAAU,CAACG,QAAX,CAAoB,GAApB,CAAJ,EAA8B;AAC5BD,IAAAA,MAAM,GAAGA,MAAM,CAACE,SAAP,CAAiB,CAAjB,CAAT;AACD;;AAED,SAAQ,GAAEJ,UAAW,GAAEE,MAAO,EAA9B;AACD;;AAED,OAAO,SAASG,oBAAT,CAA8BL,UAA9B,EAA0D;AAC/D,SAAOD,gBAAgB,CAACC,UAAD,EAAa,MAAb,CAAvB;AACD;AAED,OAAO,SAASM,qBAAT,CAA+BN,UAA/B,EAA2D;AAChE,SAAOD,gBAAgB,CAACC,UAAD,EAAa,OAAb,CAAvB;AACD;AAED,OAAO,SAASO,qBAAT,CAA+BP,UAA/B,EAA2D;AAChE,SAAOD,gBAAgB,CAACC,UAAD,EAAa,KAAb,CAAvB;AACD;AAED,OAAO,SAASQ,cAAT,CAAwB;AAC7BR,EAAAA,UAD6B;AAE7BS,EAAAA,cAF6B;AAG7BR,EAAAA,QAH6B;AAI7BS,EAAAA;AAJ6B,CAAxB,EAUI;AACT,SAAQ,GAAEA,OAAO,IAAIL,oBAAoB,CAACL,UAAD,CAAa,IAAGS,cAAe,IAAGR,QAAS,EAApF;AACD","sourcesContent":["import {MapType} from './types';\n\nexport type V3Endpoint = 'maps' | 'stats' | 'sql';\n\nfunction buildUrlFromBase(apiBaseUrl: string, endpoint: V3Endpoint) {\n let suffix = `/v3/${endpoint}`;\n if (apiBaseUrl.endsWith('/')) {\n suffix = suffix.substring(1);\n }\n\n return `${apiBaseUrl}${suffix}`;\n}\n\nexport function buildMapsUrlFromBase(apiBaseUrl: string): string {\n return buildUrlFromBase(apiBaseUrl, 'maps');\n}\n\nexport function buildStatsUrlFromBase(apiBaseUrl: string): string {\n return buildUrlFromBase(apiBaseUrl, 'stats');\n}\n\nexport function buildQueryUrlFromBase(apiBaseUrl: string): string {\n return buildUrlFromBase(apiBaseUrl, 'sql');\n}\n\nexport function buildSourceUrl({\n apiBaseUrl,\n connectionName,\n endpoint,\n mapsUrl\n}: {\n apiBaseUrl: string;\n connectionName: string;\n endpoint: MapType;\n mapsUrl?: string;\n}): string {\n return `${mapsUrl || buildMapsUrlFromBase(apiBaseUrl)}/${connectionName}/${endpoint}`;\n}\n"],"file":"endpoints.js"}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { CartoAPIError } from './carto-api-error';
|
|
2
|
+
import { DEFAULT_API_BASE_URL, DEFAULT_CLIENT } from './common';
|
|
3
|
+
import { buildMapsUrlFromBase, buildStatsUrlFromBase } from './endpoints';
|
|
4
|
+
import { h3QuerySource, h3TableSource, quadbinQuerySource, quadbinTableSource, vectorQuerySource, vectorTableSource, vectorTilesetSource } from '../sources';
|
|
5
|
+
import { parseMap } from './parse-map';
|
|
6
|
+
import { requestWithParameters } from './request-with-parameters';
|
|
7
|
+
import { assert } from '../utils';
|
|
8
|
+
|
|
9
|
+
async function _fetchMapDataset(dataset, accessToken, apiBaseUrl, clientId, headers) {
|
|
10
|
+
const {
|
|
11
|
+
aggregationExp,
|
|
12
|
+
aggregationResLevel,
|
|
13
|
+
connectionName,
|
|
14
|
+
columns,
|
|
15
|
+
format,
|
|
16
|
+
geoColumn,
|
|
17
|
+
source,
|
|
18
|
+
type,
|
|
19
|
+
queryParameters
|
|
20
|
+
} = dataset;
|
|
21
|
+
const cache = {};
|
|
22
|
+
const globalOptions = {
|
|
23
|
+
accessToken,
|
|
24
|
+
apiBaseUrl,
|
|
25
|
+
cache,
|
|
26
|
+
clientId,
|
|
27
|
+
connectionName,
|
|
28
|
+
format,
|
|
29
|
+
headers
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (type === 'tileset') {
|
|
33
|
+
dataset.data = await vectorTilesetSource({ ...globalOptions,
|
|
34
|
+
tableName: source
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
const [spatialDataType, spatialDataColumn] = geoColumn ? geoColumn.split(':') : ['geom'];
|
|
38
|
+
|
|
39
|
+
if (spatialDataType === 'geom') {
|
|
40
|
+
const options = { ...globalOptions,
|
|
41
|
+
spatialDataColumn
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (type === 'table') {
|
|
45
|
+
dataset.data = await vectorTableSource({ ...options,
|
|
46
|
+
columns,
|
|
47
|
+
tableName: source
|
|
48
|
+
});
|
|
49
|
+
} else if (type === 'query') {
|
|
50
|
+
dataset.data = await vectorQuerySource({ ...options,
|
|
51
|
+
sqlQuery: source,
|
|
52
|
+
queryParameters
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
} else if (spatialDataType === 'h3') {
|
|
56
|
+
const options = { ...globalOptions,
|
|
57
|
+
aggregationExp,
|
|
58
|
+
aggregationResLevel,
|
|
59
|
+
spatialDataColumn
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (type === 'table') {
|
|
63
|
+
dataset.data = await h3TableSource({ ...options,
|
|
64
|
+
columns,
|
|
65
|
+
tableName: source
|
|
66
|
+
});
|
|
67
|
+
} else if (type === 'query') {
|
|
68
|
+
dataset.data = await h3QuerySource({ ...options,
|
|
69
|
+
sqlQuery: source,
|
|
70
|
+
queryParameters
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
} else if (spatialDataType === 'quadbin') {
|
|
74
|
+
const options = { ...globalOptions,
|
|
75
|
+
aggregationExp,
|
|
76
|
+
aggregationResLevel,
|
|
77
|
+
spatialDataColumn
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
if (type === 'table') {
|
|
81
|
+
dataset.data = await quadbinTableSource({ ...options,
|
|
82
|
+
columns,
|
|
83
|
+
tableName: source
|
|
84
|
+
});
|
|
85
|
+
} else if (type === 'query') {
|
|
86
|
+
dataset.data = await quadbinQuerySource({ ...options,
|
|
87
|
+
sqlQuery: source,
|
|
88
|
+
queryParameters
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let cacheChanged = true;
|
|
95
|
+
|
|
96
|
+
if (cache.value) {
|
|
97
|
+
cacheChanged = dataset.cache !== cache.value;
|
|
98
|
+
dataset.cache = cache.value;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return cacheChanged;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function _fetchTilestats(attribute, dataset, accessToken, apiBaseUrl) {
|
|
105
|
+
const {
|
|
106
|
+
connectionName: connection,
|
|
107
|
+
data,
|
|
108
|
+
id,
|
|
109
|
+
source,
|
|
110
|
+
type,
|
|
111
|
+
queryParameters
|
|
112
|
+
} = dataset;
|
|
113
|
+
const errorContext = {
|
|
114
|
+
requestType: 'Tile stats',
|
|
115
|
+
connection,
|
|
116
|
+
type,
|
|
117
|
+
source
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
if (!('tilestats' in data)) {
|
|
121
|
+
throw new CartoAPIError(new Error(`Invalid dataset for tilestats: ${id}`), errorContext);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const statsUrl = buildStatsUrlFromBase(apiBaseUrl);
|
|
125
|
+
let baseUrl = `${statsUrl}/${connection}/`;
|
|
126
|
+
|
|
127
|
+
if (type === 'query') {
|
|
128
|
+
baseUrl += attribute;
|
|
129
|
+
} else {
|
|
130
|
+
baseUrl += `${source}/${attribute}`;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const headers = {
|
|
134
|
+
Authorization: `Bearer ${accessToken}`
|
|
135
|
+
};
|
|
136
|
+
const parameters = {};
|
|
137
|
+
|
|
138
|
+
if (type === 'query') {
|
|
139
|
+
parameters.q = source;
|
|
140
|
+
|
|
141
|
+
if (queryParameters) {
|
|
142
|
+
parameters.queryParameters = JSON.stringify(queryParameters);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const stats = await requestWithParameters({
|
|
147
|
+
baseUrl,
|
|
148
|
+
headers,
|
|
149
|
+
parameters,
|
|
150
|
+
errorContext
|
|
151
|
+
});
|
|
152
|
+
const {
|
|
153
|
+
attributes
|
|
154
|
+
} = data.tilestats.layers[0];
|
|
155
|
+
const index = attributes.findIndex(d => d.attribute === attribute);
|
|
156
|
+
attributes[index] = stats;
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function fillInMapDatasets({
|
|
161
|
+
datasets,
|
|
162
|
+
token
|
|
163
|
+
}, clientId, apiBaseUrl, headers) {
|
|
164
|
+
const promises = datasets.map(dataset => _fetchMapDataset(dataset, token, apiBaseUrl, clientId, headers));
|
|
165
|
+
return await Promise.all(promises);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function fillInTileStats({
|
|
169
|
+
datasets,
|
|
170
|
+
keplerMapConfig,
|
|
171
|
+
token
|
|
172
|
+
}, apiBaseUrl) {
|
|
173
|
+
const attributes = [];
|
|
174
|
+
const {
|
|
175
|
+
layers
|
|
176
|
+
} = keplerMapConfig.config.visState;
|
|
177
|
+
|
|
178
|
+
for (const layer of layers) {
|
|
179
|
+
for (const channel of Object.keys(layer.visualChannels)) {
|
|
180
|
+
var _layer$visualChannels;
|
|
181
|
+
|
|
182
|
+
const attribute = (_layer$visualChannels = layer.visualChannels[channel]) === null || _layer$visualChannels === void 0 ? void 0 : _layer$visualChannels.name;
|
|
183
|
+
|
|
184
|
+
if (attribute) {
|
|
185
|
+
const dataset = datasets.find(d => d.id === layer.config.dataId);
|
|
186
|
+
|
|
187
|
+
if (dataset && dataset.type !== 'tileset' && dataset.data.tilestats) {
|
|
188
|
+
attributes.push({
|
|
189
|
+
attribute,
|
|
190
|
+
dataset
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const filteredAttributes = [];
|
|
198
|
+
|
|
199
|
+
for (const a of attributes) {
|
|
200
|
+
if (!filteredAttributes.find(({
|
|
201
|
+
attribute,
|
|
202
|
+
dataset
|
|
203
|
+
}) => attribute === a.attribute && dataset === a.dataset)) {
|
|
204
|
+
filteredAttributes.push(a);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const promises = filteredAttributes.map(({
|
|
209
|
+
attribute,
|
|
210
|
+
dataset
|
|
211
|
+
}) => _fetchTilestats(attribute, dataset, token, apiBaseUrl));
|
|
212
|
+
return await Promise.all(promises);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export async function fetchMap({
|
|
216
|
+
apiBaseUrl = DEFAULT_API_BASE_URL,
|
|
217
|
+
cartoMapId,
|
|
218
|
+
clientId = DEFAULT_CLIENT,
|
|
219
|
+
headers = {},
|
|
220
|
+
mapsUrl,
|
|
221
|
+
autoRefresh,
|
|
222
|
+
onNewData
|
|
223
|
+
}) {
|
|
224
|
+
assert(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})');
|
|
225
|
+
assert(apiBaseUrl, 'Must define apiBaseUrl');
|
|
226
|
+
|
|
227
|
+
if (autoRefresh || onNewData) {
|
|
228
|
+
assert(onNewData, 'Must define `onNewData` when using autoRefresh');
|
|
229
|
+
assert(typeof onNewData === 'function', '`onNewData` must be a function');
|
|
230
|
+
assert(typeof autoRefresh === 'number' && autoRefresh > 0, '`autoRefresh` must be a positive number');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const baseUrl = `${mapsUrl || buildMapsUrlFromBase(apiBaseUrl)}/public/${cartoMapId}`;
|
|
234
|
+
const errorContext = {
|
|
235
|
+
requestType: 'Public map',
|
|
236
|
+
mapId: cartoMapId
|
|
237
|
+
};
|
|
238
|
+
const map = await requestWithParameters({
|
|
239
|
+
baseUrl,
|
|
240
|
+
headers,
|
|
241
|
+
errorContext
|
|
242
|
+
});
|
|
243
|
+
let stopAutoRefresh;
|
|
244
|
+
|
|
245
|
+
if (autoRefresh) {
|
|
246
|
+
const intervalId = setInterval(async () => {
|
|
247
|
+
const changed = await fillInMapDatasets(map, clientId, apiBaseUrl, { ...headers,
|
|
248
|
+
'If-Modified-Since': new Date().toUTCString()
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
if (onNewData && changed.some(v => v === true)) {
|
|
252
|
+
onNewData(parseMap(map));
|
|
253
|
+
}
|
|
254
|
+
}, autoRefresh * 1000);
|
|
255
|
+
|
|
256
|
+
stopAutoRefresh = () => {
|
|
257
|
+
clearInterval(intervalId);
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const geojsonLayers = map.keplerMapConfig.config.visState.layers.filter(({
|
|
262
|
+
type
|
|
263
|
+
}) => type === 'geojson' || type === 'point');
|
|
264
|
+
const geojsonDatasetIds = geojsonLayers.map(({
|
|
265
|
+
config
|
|
266
|
+
}) => config.dataId);
|
|
267
|
+
map.datasets.forEach(dataset => {
|
|
268
|
+
if (geojsonDatasetIds.includes(dataset.id)) {
|
|
269
|
+
const {
|
|
270
|
+
config
|
|
271
|
+
} = geojsonLayers.find(({
|
|
272
|
+
config
|
|
273
|
+
}) => config.dataId === dataset.id);
|
|
274
|
+
dataset.format = 'geojson';
|
|
275
|
+
|
|
276
|
+
if (!dataset.geoColumn && config.columns.geojson) {
|
|
277
|
+
dataset.geoColumn = config.columns.geojson;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
await fillInMapDatasets(map, clientId, apiBaseUrl, headers);
|
|
282
|
+
await fillInTileStats(map, apiBaseUrl);
|
|
283
|
+
const out = { ...parseMap(map),
|
|
284
|
+
...{
|
|
285
|
+
stopAutoRefresh
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
const textLayers = out.layers.filter(layer => {
|
|
289
|
+
const pointType = layer.props.pointType || '';
|
|
290
|
+
return pointType.includes('text');
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
if (textLayers.length && window.FontFace && !document.fonts.check('12px Inter')) {
|
|
294
|
+
const font = new FontFace('Inter', 'url(https://fonts.gstatic.com/s/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7W0Q5nw.woff2)');
|
|
295
|
+
await font.load().then(f => document.fonts.add(f));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return out;
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=fetch-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/api/fetch-map.ts"],"names":["CartoAPIError","DEFAULT_API_BASE_URL","DEFAULT_CLIENT","buildMapsUrlFromBase","buildStatsUrlFromBase","h3QuerySource","h3TableSource","quadbinQuerySource","quadbinTableSource","vectorQuerySource","vectorTableSource","vectorTilesetSource","parseMap","requestWithParameters","assert","_fetchMapDataset","dataset","accessToken","apiBaseUrl","clientId","headers","aggregationExp","aggregationResLevel","connectionName","columns","format","geoColumn","source","type","queryParameters","cache","globalOptions","data","tableName","spatialDataType","spatialDataColumn","split","options","sqlQuery","cacheChanged","value","_fetchTilestats","attribute","connection","id","errorContext","requestType","Error","statsUrl","baseUrl","Authorization","parameters","q","JSON","stringify","stats","attributes","tilestats","layers","index","findIndex","d","fillInMapDatasets","datasets","token","promises","map","Promise","all","fillInTileStats","keplerMapConfig","config","visState","layer","channel","Object","keys","visualChannels","name","find","dataId","push","filteredAttributes","a","fetchMap","cartoMapId","mapsUrl","autoRefresh","onNewData","mapId","stopAutoRefresh","intervalId","setInterval","changed","Date","toUTCString","some","v","clearInterval","geojsonLayers","filter","geojsonDatasetIds","forEach","includes","geojson","out","textLayers","pointType","props","length","window","FontFace","document","fonts","check","font","load","then","f","add"],"mappings":"AAIA,SAAQA,aAAR,QAA4B,mBAA5B;AACA,SAAQC,oBAAR,EAA8BC,cAA9B,QAAmD,UAAnD;AACA,SAAQC,oBAAR,EAA8BC,qBAA9B,QAA0D,aAA1D;AACA,SAIEC,aAJF,EAKEC,aALF,EAMEC,kBANF,EAOEC,kBAPF,EAQEC,iBARF,EASEC,iBATF,EAUEC,mBAVF,QAWO,YAXP;AAYA,SAAQC,QAAR,QAAuB,aAAvB;AACA,SAAQC,qBAAR,QAAoC,2BAApC;AACA,SAAQC,MAAR,QAAqB,UAArB;;AAoBA,eAAeC,gBAAf,CACEC,OADF,EAEEC,WAFF,EAGEC,UAHF,EAIEC,QAJF,EAKEC,OALF,EAME;AACA,QAAM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QAAQ,CAACsD,GAAD,CAAZ;AAAmB,OAAG;AAACwB,MAAAA;AAAD;AAAtB,GAAZ;AAEA,QAAMgB,UAAU,GAAGD,GAAG,CAAC/C,MAAJ,CAAW0C,MAAX,CAAkB3B,KAAK,IAAI;AAC5C,UAAMkC,SAAS,GAAGlC,KAAK,CAACmC,KAAN,CAAYD,SAAZ,IAAyB,EAA3C;AACA,WAAOA,SAAS,CAACJ,QAAV,CAAmB,MAAnB,CAAP;AACD,GAHkB,CAAnB;;AAMA,MAAIG,UAAU,CAACG,MAAX,IAAqBC,MAAM,CAACC,QAA5B,IAAwC,CAACC,QAAQ,CAACC,KAAT,CAAeC,KAAf,CAAqB,YAArB,CAA7C,EAAiF;AAE/E,UAAMC,IAAI,GAAG,IAAIJ,QAAJ,CACX,OADW,EAEX,6FAFW,CAAb;AAIA,UAAMI,IAAI,CAACC,IAAL,GAAYC,IAAZ,CAAiBC,CAAC,IAAIN,QAAQ,CAACC,KAAT,CAAeM,GAAf,CAAmBD,CAAnB,CAAtB,CAAN;AACD;;AAED,SAAOb,GAAP;AACD","sourcesContent":["/* eslint-disable camelcase */\n/**\n * Maps API Client for Carto 3\n */\nimport {CartoAPIError} from './carto-api-error';\nimport {DEFAULT_API_BASE_URL, DEFAULT_CLIENT} from './common';\nimport {buildMapsUrlFromBase, buildStatsUrlFromBase} from './endpoints';\nimport {\n GeojsonResult,\n JsonResult,\n TilejsonResult,\n h3QuerySource,\n h3TableSource,\n quadbinQuerySource,\n quadbinTableSource,\n vectorQuerySource,\n vectorTableSource,\n vectorTilesetSource\n} from '../sources';\nimport {parseMap} from './parse-map';\nimport {requestWithParameters} from './request-with-parameters';\nimport {assert} from '../utils';\nimport type {APIErrorContext, Format, MapType, QueryParameters} from './types';\n\ntype Dataset = {\n id: string;\n type: MapType;\n source: string;\n cache?: number;\n connectionName: string;\n geoColumn: string;\n data: TilejsonResult | GeojsonResult | JsonResult;\n columns: string[];\n format: Format;\n aggregationExp: string;\n aggregationResLevel: number;\n queryParameters: QueryParameters;\n};\n\n/* global clearInterval, setInterval, URL */\n/* eslint-disable complexity, max-statements */\nasync function _fetchMapDataset(\n dataset: Dataset,\n accessToken: string,\n apiBaseUrl: string,\n clientId?: string,\n headers?: Record<string, string>\n) {\n const {\n aggregationExp,\n aggregationResLevel,\n connectionName,\n columns,\n format,\n geoColumn,\n source,\n type,\n queryParameters\n } = dataset;\n\n const cache: {value?: number} = {};\n const globalOptions: any = {\n accessToken,\n apiBaseUrl,\n cache,\n clientId,\n connectionName,\n format,\n headers\n };\n\n if (type === 'tileset') {\n // TODO do we want a generic tilesetSource?\n // @ts-ignore\n dataset.data = await vectorTilesetSource({...globalOptions, tableName: source});\n } else {\n const [spatialDataType, spatialDataColumn] = geoColumn ? geoColumn.split(':') : ['geom'];\n if (spatialDataType === 'geom') {\n const options = {...globalOptions, spatialDataColumn};\n if (type === 'table') {\n dataset.data = await vectorTableSource({...options, columns, tableName: source});\n } else if (type === 'query') {\n dataset.data = await vectorQuerySource({...options, sqlQuery: source, queryParameters});\n }\n } else if (spatialDataType === 'h3') {\n const options = {...globalOptions, aggregationExp, aggregationResLevel, spatialDataColumn};\n if (type === 'table') {\n dataset.data = await h3TableSource({...options, columns, tableName: source});\n } else if (type === 'query') {\n dataset.data = await h3QuerySource({...options, sqlQuery: source, queryParameters});\n }\n } else if (spatialDataType === 'quadbin') {\n const options = {...globalOptions, aggregationExp, aggregationResLevel, spatialDataColumn};\n if (type === 'table') {\n dataset.data = await quadbinTableSource({...options, columns, tableName: source});\n } else if (type === 'query') {\n dataset.data = await quadbinQuerySource({...options, sqlQuery: source, queryParameters});\n }\n }\n }\n let cacheChanged = true;\n if (cache.value) {\n cacheChanged = dataset.cache !== cache.value;\n dataset.cache = cache.value;\n }\n\n return cacheChanged;\n}\n\nasync function _fetchTilestats(\n attribute,\n dataset: Dataset,\n accessToken: string,\n apiBaseUrl: string\n) {\n const {connectionName: connection, data, id, source, type, queryParameters} = dataset;\n const errorContext: APIErrorContext = {requestType: 'Tile stats', connection, type, source};\n if (!('tilestats' in data)) {\n throw new CartoAPIError(new Error(`Invalid dataset for tilestats: ${id}`), errorContext);\n }\n\n const statsUrl = buildStatsUrlFromBase(apiBaseUrl);\n let baseUrl = `${statsUrl}/${connection}/`;\n if (type === 'query') {\n baseUrl += attribute;\n } else {\n // MAP_TYPE.TABLE\n baseUrl += `${source}/${attribute}`;\n }\n\n const headers = {Authorization: `Bearer ${accessToken}`};\n const parameters: Record<string, string> = {};\n if (type === 'query') {\n parameters.q = source;\n if (queryParameters) {\n parameters.queryParameters = JSON.stringify(queryParameters);\n }\n }\n const stats = await requestWithParameters({\n baseUrl,\n headers,\n parameters,\n errorContext\n });\n\n // Replace tilestats for attribute with value from API\n const {attributes} = data.tilestats.layers[0];\n const index = attributes.findIndex(d => d.attribute === attribute);\n attributes[index] = stats;\n return true;\n}\n\nasync function fillInMapDatasets(\n {datasets, token}: {datasets: Dataset[]; token: string},\n clientId: string,\n apiBaseUrl: string,\n headers?: Record<string, string>\n) {\n const promises = datasets.map(dataset =>\n _fetchMapDataset(dataset, token, apiBaseUrl, clientId, headers)\n );\n return await Promise.all(promises);\n}\n\nasync function fillInTileStats(\n {datasets, keplerMapConfig, token}: {datasets: Dataset[]; keplerMapConfig: any; token: string},\n apiBaseUrl: string\n) {\n const attributes: {attribute?: string; dataset?: any}[] = [];\n const {layers} = keplerMapConfig.config.visState;\n for (const layer of layers) {\n for (const channel of Object.keys(layer.visualChannels)) {\n const attribute = layer.visualChannels[channel]?.name;\n if (attribute) {\n const dataset = datasets.find(d => d.id === layer.config.dataId);\n if (dataset && dataset.type !== 'tileset' && (dataset.data as TilejsonResult).tilestats) {\n // Only fetch stats for QUERY & TABLE map types\n attributes.push({attribute, dataset});\n }\n }\n }\n }\n // Remove duplicates to avoid repeated requests\n const filteredAttributes: {attribute?: string; dataset?: any}[] = [];\n for (const a of attributes) {\n if (\n !filteredAttributes.find(\n ({attribute, dataset}) => attribute === a.attribute && dataset === a.dataset\n )\n ) {\n filteredAttributes.push(a);\n }\n }\n\n const promises = filteredAttributes.map(({attribute, dataset}) =>\n _fetchTilestats(attribute, dataset, token, apiBaseUrl)\n );\n return await Promise.all(promises);\n}\n\nexport type FetchMapOptions = {\n apiBaseUrl?: string;\n cartoMapId: string;\n clientId?: string;\n headers?: Record<string, string>;\n mapsUrl?: string;\n autoRefresh?: number;\n onNewData?: (map: any) => void;\n};\n\n/* eslint-disable max-statements */\nexport async function fetchMap({\n apiBaseUrl = DEFAULT_API_BASE_URL,\n cartoMapId,\n clientId = DEFAULT_CLIENT,\n headers = {},\n mapsUrl,\n autoRefresh,\n onNewData\n}: FetchMapOptions) {\n assert(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: \"XXXX-XXXX-XXXX\"})');\n assert(apiBaseUrl, 'Must define apiBaseUrl');\n\n if (autoRefresh || onNewData) {\n assert(onNewData, 'Must define `onNewData` when using autoRefresh');\n assert(typeof onNewData === 'function', '`onNewData` must be a function');\n assert(\n typeof autoRefresh === 'number' && autoRefresh > 0,\n '`autoRefresh` must be a positive number'\n );\n }\n\n const baseUrl = `${mapsUrl || buildMapsUrlFromBase(apiBaseUrl)}/public/${cartoMapId}`;\n const errorContext: APIErrorContext = {requestType: 'Public map', mapId: cartoMapId};\n const map = await requestWithParameters({baseUrl, headers, errorContext});\n\n // Periodically check if the data has changed. Note that this\n // will not update when a map is published.\n let stopAutoRefresh: (() => void) | undefined;\n if (autoRefresh) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n const intervalId = setInterval(async () => {\n const changed = await fillInMapDatasets(map, clientId, apiBaseUrl, {\n ...headers,\n 'If-Modified-Since': new Date().toUTCString()\n });\n if (onNewData && changed.some(v => v === true)) {\n onNewData(parseMap(map));\n }\n }, autoRefresh * 1000);\n stopAutoRefresh = () => {\n clearInterval(intervalId);\n };\n }\n\n const geojsonLayers = map.keplerMapConfig.config.visState.layers.filter(\n ({type}) => type === 'geojson' || type === 'point'\n );\n const geojsonDatasetIds = geojsonLayers.map(({config}) => config.dataId);\n map.datasets.forEach(dataset => {\n if (geojsonDatasetIds.includes(dataset.id)) {\n const {config} = geojsonLayers.find(({config}) => config.dataId === dataset.id);\n dataset.format = 'geojson';\n // Support for very old maps. geoColumn was not stored in the past\n if (!dataset.geoColumn && config.columns.geojson) {\n dataset.geoColumn = config.columns.geojson;\n }\n }\n });\n\n // Mutates map.datasets so that dataset.data contains data\n await fillInMapDatasets(map, clientId, apiBaseUrl, headers);\n\n // Mutates attributes in visualChannels to contain tile stats\n await fillInTileStats(map, apiBaseUrl);\n const out = {...parseMap(map), ...{stopAutoRefresh}};\n\n const textLayers = out.layers.filter(layer => {\n const pointType = layer.props.pointType || '';\n return pointType.includes('text');\n });\n\n /* global FontFace, window, document */\n if (textLayers.length && window.FontFace && !document.fonts.check('12px Inter')) {\n // Fetch font needed for labels\n const font = new FontFace(\n 'Inter',\n 'url(https://fonts.gstatic.com/s/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7W0Q5nw.woff2)'\n );\n await font.load().then(f => document.fonts.add(f));\n }\n\n return out;\n}\n"],"file":"fetch-map.js"}
|
package/dist/esm/api/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { CartoAPIError } from './carto-api-error';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { fetchLayerData, fetchMap, mapInstantiation } from './maps-v3-client';
|
|
2
|
+
export { fetchMap } from './fetch-map';
|
|
3
|
+
export { query } from './query';
|
|
5
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/api/index.ts"],"names":["CartoAPIError","
|
|
1
|
+
{"version":3,"sources":["../../../src/api/index.ts"],"names":["CartoAPIError","fetchMap","query"],"mappings":"AAAA,SAAQA,aAAR,QAA4B,mBAA5B;AACA,SAAQC,QAAR,QAAuB,aAAvB;AAGA,SAAQC,KAAR,QAAoB,SAApB","sourcesContent":["export {CartoAPIError} from './carto-api-error';\nexport {fetchMap} from './fetch-map';\nexport type {FetchMapOptions} from './fetch-map';\nexport type {APIErrorContext, Format, MapType, RequestType, QueryParameters} from './types';\nexport {query} from './query';\nexport type {QueryOptions} from './query';\n"],"file":"index.js"}
|
|
@@ -10,8 +10,7 @@ import H3TileLayer from '../layers/h3-tile-layer';
|
|
|
10
10
|
import QuadbinTileLayer from '../layers/quadbin-tile-layer';
|
|
11
11
|
import RasterTileLayer from '../layers/raster-tile-layer';
|
|
12
12
|
import VectorTileLayer from '../layers/vector-tile-layer';
|
|
13
|
-
import {
|
|
14
|
-
import { assert, createBinaryProxy } from '../utils';
|
|
13
|
+
import { assert, createBinaryProxy, scaleIdentity } from '../utils';
|
|
15
14
|
const SCALE_FUNCS = {
|
|
16
15
|
linear: scaleLinear,
|
|
17
16
|
ordinal: scaleOrdinal,
|
|
@@ -20,7 +19,8 @@ const SCALE_FUNCS = {
|
|
|
20
19
|
quantile: scaleQuantile,
|
|
21
20
|
quantize: scaleQuantize,
|
|
22
21
|
sqrt: scaleSqrt,
|
|
23
|
-
custom: scaleThreshold
|
|
22
|
+
custom: scaleThreshold,
|
|
23
|
+
identity: scaleIdentity
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
function identity(v) {
|
|
@@ -208,7 +208,7 @@ export function getLayer(type, config, dataset) {
|
|
|
208
208
|
}
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
-
export function layerFromTileDataset(
|
|
211
|
+
export function layerFromTileDataset(scheme, type) {
|
|
212
212
|
if (type === 'raster') {
|
|
213
213
|
return RasterTileLayer;
|
|
214
214
|
}
|
|
@@ -229,13 +229,11 @@ function getTileLayer(dataset, basePropMap) {
|
|
|
229
229
|
aggregationExp,
|
|
230
230
|
aggregationResLevel,
|
|
231
231
|
data: {
|
|
232
|
-
scheme
|
|
233
|
-
tiles: [tileUrl]
|
|
232
|
+
scheme
|
|
234
233
|
}
|
|
235
234
|
} = dataset;
|
|
236
|
-
const formatTiles = new URL(tileUrl).searchParams.get('formatTiles');
|
|
237
235
|
return {
|
|
238
|
-
Layer: layerFromTileDataset(
|
|
236
|
+
Layer: layerFromTileDataset(scheme),
|
|
239
237
|
propMap: basePropMap,
|
|
240
238
|
defaultProps: { ...defaultProps,
|
|
241
239
|
...(aggregationExp && {
|
|
@@ -244,7 +242,6 @@ function getTileLayer(dataset, basePropMap) {
|
|
|
244
242
|
...(aggregationResLevel && {
|
|
245
243
|
aggregationResLevel
|
|
246
244
|
}),
|
|
247
|
-
formatTiles,
|
|
248
245
|
uniqueIdProperty: 'geoid'
|
|
249
246
|
}
|
|
250
247
|
};
|
|
@@ -356,35 +353,13 @@ export function getColorValueAccessor({
|
|
|
356
353
|
return normalizeAccessor(accessor, data);
|
|
357
354
|
}
|
|
358
355
|
export function getColorAccessor({
|
|
359
|
-
name
|
|
356
|
+
name,
|
|
357
|
+
colorColumn
|
|
360
358
|
}, scaleType, {
|
|
361
359
|
aggregation,
|
|
362
|
-
range
|
|
363
|
-
colors,
|
|
364
|
-
colorMap
|
|
365
|
-
}
|
|
360
|
+
range
|
|
366
361
|
}, opacity, data) {
|
|
367
|
-
const scale =
|
|
368
|
-
let domain = [];
|
|
369
|
-
let scaleColor = [];
|
|
370
|
-
|
|
371
|
-
if (Array.isArray(colorMap)) {
|
|
372
|
-
colorMap.forEach(([value, color]) => {
|
|
373
|
-
domain.push(value);
|
|
374
|
-
scaleColor.push(color);
|
|
375
|
-
});
|
|
376
|
-
} else {
|
|
377
|
-
domain = calculateDomain(data, name, scaleType, colors.length);
|
|
378
|
-
scaleColor = colors;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
if (scaleType === 'ordinal') {
|
|
382
|
-
domain = domain.slice(0, scaleColor.length);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
scale.domain(domain);
|
|
386
|
-
scale.range(scaleColor);
|
|
387
|
-
scale.unknown(UNKNOWN_COLOR);
|
|
362
|
+
const scale = calculateLayerScale(colorColumn || name, scaleType, range, data);
|
|
388
363
|
const alpha = opacityToAlpha(opacity);
|
|
389
364
|
let accessorKeys = getAccessorKeys(name, aggregation);
|
|
390
365
|
|
|
@@ -404,6 +379,39 @@ export function getColorAccessor({
|
|
|
404
379
|
|
|
405
380
|
return normalizeAccessor(accessor, data);
|
|
406
381
|
}
|
|
382
|
+
|
|
383
|
+
function calculateLayerScale(name, scaleType, range, data) {
|
|
384
|
+
const scale = SCALE_FUNCS[scaleType]();
|
|
385
|
+
let domain = [];
|
|
386
|
+
let scaleColor = [];
|
|
387
|
+
|
|
388
|
+
if (scaleType !== 'identity') {
|
|
389
|
+
const {
|
|
390
|
+
colorMap,
|
|
391
|
+
colors
|
|
392
|
+
} = range;
|
|
393
|
+
|
|
394
|
+
if (Array.isArray(colorMap)) {
|
|
395
|
+
colorMap.forEach(([value, color]) => {
|
|
396
|
+
domain.push(value);
|
|
397
|
+
scaleColor.push(color);
|
|
398
|
+
});
|
|
399
|
+
} else {
|
|
400
|
+
domain = calculateDomain(data, name, scaleType, colors.length);
|
|
401
|
+
scaleColor = colors;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (scaleType === 'ordinal') {
|
|
405
|
+
domain = domain.slice(0, scaleColor.length);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
scale.domain(domain);
|
|
410
|
+
scale.range(scaleColor);
|
|
411
|
+
scale.unknown(UNKNOWN_COLOR);
|
|
412
|
+
return scale;
|
|
413
|
+
}
|
|
414
|
+
|
|
407
415
|
const FALLBACK_ICON = 'data:image/svg+xml;charset=utf-8;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNTAiLz4NCjwvc3ZnPg==';
|
|
408
416
|
export function getIconUrlAccessor(field, range, {
|
|
409
417
|
fallbackUrl,
|