@deck.gl/carto 9.0.35 → 9.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/basemap.d.ts +2 -1
- package/dist/api/basemap.d.ts.map +1 -1
- package/dist/api/basemap.js +3 -0
- package/dist/api/fetch-map.d.ts.map +1 -1
- package/dist/api/fetch-map.js +9 -11
- package/dist/api/index.d.ts +1 -4
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +3 -2
- package/dist/api/layer-map.d.ts.map +1 -1
- package/dist/api/layer-map.js +5 -2
- package/dist/api/parse-map.d.ts.map +1 -1
- package/dist/api/parse-map.js +3 -0
- package/dist/api/types.d.ts +0 -56
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js +4 -20
- package/dist/basemap.d.ts +2 -1
- package/dist/basemap.d.ts.map +1 -1
- package/dist/basemap.js +4 -1
- package/dist/cartoRasterTile-worker.js +25 -2
- package/dist/cartoSpatialTile-worker.js +28 -3
- package/dist/cartoVectorTile-worker.js +29 -3
- package/dist/constants.d.ts +0 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -3
- package/dist/dist.dev.js +4391 -3737
- package/dist/index.cjs +224 -531
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +16 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/layers/cluster-tile-layer.d.ts +1 -1
- package/dist/layers/cluster-tile-layer.d.ts.map +1 -1
- package/dist/layers/cluster-tile-layer.js +4 -0
- package/dist/layers/cluster-utils.d.ts.map +1 -1
- package/dist/layers/cluster-utils.js +3 -0
- package/dist/layers/h3-tile-layer.d.ts +1 -1
- package/dist/layers/h3-tile-layer.d.ts.map +1 -1
- package/dist/layers/h3-tile-layer.js +3 -0
- package/dist/layers/h3-tileset-2d.d.ts.map +1 -1
- package/dist/layers/h3-tileset-2d.js +3 -0
- package/dist/layers/heatmap-tile-layer.d.ts +1 -1
- package/dist/layers/heatmap-tile-layer.d.ts.map +1 -1
- package/dist/layers/heatmap-tile-layer.js +23 -7
- package/dist/layers/heatmap.d.ts +3 -3
- package/dist/layers/heatmap.d.ts.map +1 -1
- package/dist/layers/heatmap.js +69 -36
- package/dist/layers/point-label-layer.d.ts.map +1 -1
- package/dist/layers/point-label-layer.js +5 -2
- package/dist/layers/post-process-utils.d.ts.map +1 -1
- package/dist/layers/post-process-utils.js +9 -5
- package/dist/layers/quadbin-layer.d.ts.map +1 -1
- package/dist/layers/quadbin-layer.js +3 -0
- package/dist/layers/quadbin-tile-layer.d.ts +1 -1
- package/dist/layers/quadbin-tile-layer.d.ts.map +1 -1
- package/dist/layers/quadbin-tile-layer.js +3 -0
- package/dist/layers/quadbin-tileset-2d.d.ts.map +1 -1
- package/dist/layers/quadbin-tileset-2d.js +3 -0
- package/dist/layers/quadbin-utils.d.ts.map +1 -1
- package/dist/layers/quadbin-utils.js +3 -0
- package/dist/layers/raster-layer-vertex.glsl.d.ts +1 -1
- package/dist/layers/raster-layer-vertex.glsl.d.ts.map +1 -1
- package/dist/layers/raster-layer-vertex.glsl.js +19 -24
- package/dist/layers/raster-layer.d.ts +6 -6
- package/dist/layers/raster-layer.d.ts.map +1 -1
- package/dist/layers/raster-layer.js +6 -1
- package/dist/layers/raster-tile-layer.d.ts +1 -1
- package/dist/layers/raster-tile-layer.d.ts.map +1 -1
- package/dist/layers/raster-tile-layer.js +3 -0
- package/dist/layers/schema/carto-properties-tile-loader.d.ts.map +1 -1
- package/dist/layers/schema/carto-properties-tile-loader.js +3 -0
- package/dist/layers/schema/carto-properties-tile.d.ts.map +1 -1
- package/dist/layers/schema/carto-properties-tile.js +3 -0
- package/dist/layers/schema/carto-raster-tile-loader.d.ts.map +1 -1
- package/dist/layers/schema/carto-raster-tile-loader.js +4 -1
- package/dist/layers/schema/carto-raster-tile.d.ts.map +1 -1
- package/dist/layers/schema/carto-raster-tile.js +3 -0
- package/dist/layers/schema/carto-spatial-tile-loader.d.ts.map +1 -1
- package/dist/layers/schema/carto-spatial-tile-loader.js +4 -1
- package/dist/layers/schema/carto-spatial-tile.d.ts.map +1 -1
- package/dist/layers/schema/carto-spatial-tile.js +3 -0
- package/dist/layers/schema/carto-tile.d.ts.map +1 -1
- package/dist/layers/schema/carto-tile.js +3 -0
- package/dist/layers/schema/carto-vector-tile-loader.d.ts.map +1 -1
- package/dist/layers/schema/carto-vector-tile-loader.js +4 -1
- package/dist/layers/schema/fast-pbf.d.ts.map +1 -1
- package/dist/layers/schema/fast-pbf.js +3 -0
- package/dist/layers/schema/spatialjson-utils.d.ts.map +1 -1
- package/dist/layers/schema/spatialjson-utils.js +3 -0
- package/dist/layers/schema/tile-loader-utils.d.ts.map +1 -1
- package/dist/layers/schema/tile-loader-utils.js +3 -0
- package/dist/layers/spatial-index-tile-layer.d.ts.map +1 -1
- package/dist/layers/spatial-index-tile-layer.js +3 -0
- package/dist/layers/utils.d.ts +2 -2
- package/dist/layers/utils.d.ts.map +1 -1
- package/dist/layers/utils.js +3 -0
- package/dist/layers/vector-tile-layer.d.ts +1 -1
- package/dist/layers/vector-tile-layer.d.ts.map +1 -1
- package/dist/layers/vector-tile-layer.js +3 -0
- package/dist/style/color-bins-style.d.ts.map +1 -1
- package/dist/style/color-bins-style.js +3 -0
- package/dist/style/color-categories-style.d.ts.map +1 -1
- package/dist/style/color-categories-style.js +3 -0
- package/dist/style/color-continuous-style.d.ts.map +1 -1
- package/dist/style/color-continuous-style.js +3 -0
- package/dist/style/palette.d.ts.map +1 -1
- package/dist/style/palette.js +3 -0
- package/dist/style/utils.d.ts.map +1 -1
- package/dist/style/utils.js +3 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +3 -0
- package/dist/workers/cartoRasterTile.js +3 -0
- package/dist/workers/cartoSpatialTile.js +3 -0
- package/dist/workers/cartoVectorTile.js +3 -0
- package/dist.min.js +113 -73
- package/package.json +13 -11
- package/src/api/basemap.ts +6 -1
- package/src/api/fetch-map.ts +23 -15
- package/src/api/index.ts +5 -13
- package/src/api/layer-map.ts +6 -2
- package/src/api/parse-map.ts +4 -0
- package/src/api/types.ts +4 -75
- package/src/basemap.ts +6 -2
- package/src/constants.ts +4 -4
- package/src/index.ts +7 -9
- package/src/layers/cluster-tile-layer.ts +6 -1
- package/src/layers/cluster-utils.ts +4 -0
- package/src/layers/h3-tile-layer.ts +5 -1
- package/src/layers/h3-tileset-2d.ts +4 -0
- package/src/layers/heatmap-tile-layer.ts +29 -8
- package/src/layers/heatmap.ts +8 -2
- package/src/layers/point-label-layer.ts +6 -2
- package/src/layers/post-process-utils.ts +10 -5
- package/src/layers/quadbin-layer.ts +4 -0
- package/src/layers/quadbin-tile-layer.ts +5 -1
- package/src/layers/quadbin-tileset-2d.ts +4 -0
- package/src/layers/quadbin-utils.ts +4 -0
- package/src/layers/raster-layer-vertex.glsl.ts +20 -26
- package/src/layers/raster-layer.ts +7 -1
- package/src/layers/raster-tile-layer.ts +5 -1
- package/src/layers/schema/carto-properties-tile-loader.ts +4 -0
- package/src/layers/schema/carto-properties-tile.ts +4 -0
- package/src/layers/schema/carto-raster-tile-loader.ts +4 -0
- package/src/layers/schema/carto-raster-tile.ts +4 -0
- package/src/layers/schema/carto-spatial-tile-loader.ts +4 -0
- package/src/layers/schema/carto-spatial-tile.ts +4 -0
- package/src/layers/schema/carto-tile.ts +4 -0
- package/src/layers/schema/carto-vector-tile-loader.ts +4 -0
- package/src/layers/schema/fast-pbf.ts +4 -0
- package/src/layers/schema/spatialjson-utils.ts +4 -0
- package/src/layers/schema/tile-loader-utils.ts +4 -0
- package/src/layers/spatial-index-tile-layer.ts +4 -0
- package/src/layers/utils.ts +5 -1
- package/src/layers/vector-tile-layer.ts +5 -1
- package/src/style/color-bins-style.ts +4 -0
- package/src/style/color-categories-style.ts +4 -0
- package/src/style/color-continuous-style.ts +4 -0
- package/src/style/palette.ts +4 -0
- package/src/style/utils.ts +4 -0
- package/src/utils.ts +4 -0
- package/src/workers/cartoRasterTile.ts +4 -0
- package/src/workers/cartoSpatialTile.ts +4 -0
- package/src/workers/cartoVectorTile.ts +4 -0
- package/dist/api/carto-api-error.d.ts +0 -19
- package/dist/api/carto-api-error.d.ts.map +0 -1
- package/dist/api/carto-api-error.js +0 -48
- package/dist/api/common.d.ts +0 -5
- package/dist/api/common.d.ts.map +0 -1
- package/dist/api/common.js +0 -5
- package/dist/api/endpoints.d.ts +0 -23
- package/dist/api/endpoints.d.ts.map +0 -1
- package/dist/api/endpoints.js +0 -22
- package/dist/api/query.d.ts +0 -4
- package/dist/api/query.d.ts.map +0 -1
- package/dist/api/query.js +0 -26
- package/dist/api/request-with-parameters.d.ts +0 -9
- package/dist/api/request-with-parameters.d.ts.map +0 -1
- package/dist/api/request-with-parameters.js +0 -86
- package/dist/sources/base-source.d.ts +0 -5
- package/dist/sources/base-source.d.ts.map +0 -1
- package/dist/sources/base-source.js +0 -60
- package/dist/sources/boundary-query-source.d.ts +0 -10
- package/dist/sources/boundary-query-source.d.ts.map +0 -1
- package/dist/sources/boundary-query-source.js +0 -18
- package/dist/sources/boundary-table-source.d.ts +0 -8
- package/dist/sources/boundary-table-source.d.ts.map +0 -1
- package/dist/sources/boundary-table-source.js +0 -15
- package/dist/sources/h3-query-source.d.ts +0 -4
- package/dist/sources/h3-query-source.d.ts.map +0 -1
- package/dist/sources/h3-query-source.js +0 -22
- package/dist/sources/h3-table-source.d.ts +0 -4
- package/dist/sources/h3-table-source.d.ts.map +0 -1
- package/dist/sources/h3-table-source.js +0 -19
- package/dist/sources/h3-tileset-source.d.ts +0 -4
- package/dist/sources/h3-tileset-source.d.ts.map +0 -1
- package/dist/sources/h3-tileset-source.js +0 -6
- package/dist/sources/index.d.ts +0 -28
- package/dist/sources/index.d.ts.map +0 -1
- package/dist/sources/index.js +0 -13
- package/dist/sources/quadbin-query-source.d.ts +0 -4
- package/dist/sources/quadbin-query-source.d.ts.map +0 -1
- package/dist/sources/quadbin-query-source.js +0 -22
- package/dist/sources/quadbin-table-source.d.ts +0 -4
- package/dist/sources/quadbin-table-source.d.ts.map +0 -1
- package/dist/sources/quadbin-table-source.js +0 -19
- package/dist/sources/quadbin-tileset-source.d.ts +0 -4
- package/dist/sources/quadbin-tileset-source.d.ts.map +0 -1
- package/dist/sources/quadbin-tileset-source.js +0 -6
- package/dist/sources/raster-source.d.ts +0 -4
- package/dist/sources/raster-source.d.ts.map +0 -1
- package/dist/sources/raster-source.js +0 -9
- package/dist/sources/types.d.ts +0 -219
- package/dist/sources/types.d.ts.map +0 -1
- package/dist/sources/types.js +0 -1
- package/dist/sources/vector-query-source.d.ts +0 -4
- package/dist/sources/vector-query-source.d.ts.map +0 -1
- package/dist/sources/vector-query-source.js +0 -22
- package/dist/sources/vector-table-source.d.ts +0 -4
- package/dist/sources/vector-table-source.d.ts.map +0 -1
- package/dist/sources/vector-table-source.js +0 -19
- package/dist/sources/vector-tileset-source.d.ts +0 -4
- package/dist/sources/vector-tileset-source.d.ts.map +0 -1
- package/dist/sources/vector-tileset-source.js +0 -6
- package/src/api/carto-api-error.ts +0 -68
- package/src/api/common.ts +0 -6
- package/src/api/endpoints.ts +0 -69
- package/src/api/query.ts +0 -42
- package/src/api/request-with-parameters.ts +0 -117
- package/src/sources/base-source.ts +0 -79
- package/src/sources/boundary-query-source.ts +0 -39
- package/src/sources/boundary-table-source.ts +0 -33
- package/src/sources/h3-query-source.ts +0 -55
- package/src/sources/h3-table-source.ts +0 -51
- package/src/sources/h3-tileset-source.ts +0 -14
- package/src/sources/index.ts +0 -45
- package/src/sources/quadbin-query-source.ts +0 -56
- package/src/sources/quadbin-table-source.ts +0 -52
- package/src/sources/quadbin-tileset-source.ts +0 -14
- package/src/sources/raster-source.ts +0 -17
- package/src/sources/types.ts +0 -231
- package/src/sources/vector-query-source.ts +0 -57
- package/src/sources/vector-table-source.ts +0 -51
- package/src/sources/vector-tileset-source.ts +0 -14
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
export default `\
|
|
2
6
|
#version 300 es
|
|
3
7
|
#define SHADER_NAME raster-layer-vertex-shader
|
|
@@ -11,16 +15,6 @@ in vec4 instanceLineColors;
|
|
|
11
15
|
|
|
12
16
|
in vec3 instancePickingColors;
|
|
13
17
|
|
|
14
|
-
// Custom uniforms
|
|
15
|
-
uniform float opacity;
|
|
16
|
-
uniform bool extruded;
|
|
17
|
-
uniform bool stroked;
|
|
18
|
-
uniform bool isStroke;
|
|
19
|
-
uniform float coverage;
|
|
20
|
-
uniform float elevationScale;
|
|
21
|
-
uniform float widthScale;
|
|
22
|
-
uniform vec3 offset;
|
|
23
|
-
|
|
24
18
|
// Result
|
|
25
19
|
out vec4 vColor;
|
|
26
20
|
#ifdef FLAT_SHADING
|
|
@@ -29,25 +23,25 @@ out vec4 position_commonspace;
|
|
|
29
23
|
|
|
30
24
|
void main(void) {
|
|
31
25
|
// Rather than positioning using attribute, layout pixel grid using gl_InstanceID
|
|
32
|
-
vec2 common_position = offset.xy;
|
|
33
|
-
float scale =
|
|
26
|
+
vec2 common_position = column.offset.xy;
|
|
27
|
+
float scale = column.widthScale; // Re-use widthScale prop to pass cell scale
|
|
34
28
|
|
|
35
29
|
int yIndex = - (gl_InstanceID / BLOCK_WIDTH);
|
|
36
30
|
int xIndex = gl_InstanceID + (yIndex * BLOCK_WIDTH);
|
|
37
31
|
common_position += scale * vec2(float(xIndex), float(yIndex - 1));
|
|
38
32
|
|
|
39
|
-
vec4 color = isStroke ? instanceLineColors : instanceFillColors;
|
|
33
|
+
vec4 color = column.isStroke ? instanceLineColors : instanceFillColors;
|
|
40
34
|
|
|
41
35
|
// if alpha == 0.0 or z < 0.0, do not render element
|
|
42
36
|
float shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0);
|
|
43
|
-
float cellWidth = coverage * scale;
|
|
37
|
+
float cellWidth = column.coverage * scale;
|
|
44
38
|
|
|
45
39
|
// Get position directly from quadbin, rather than projecting
|
|
46
40
|
// Important to set geometry.position before using project_ methods below
|
|
47
41
|
// as geometry.worldPosition is not set (we don't know our lat/long)
|
|
48
42
|
geometry.position = vec4(common_position, 0.0, 1.0);
|
|
49
|
-
if (
|
|
50
|
-
geometry.position.xyz -=
|
|
43
|
+
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
|
|
44
|
+
geometry.position.xyz -= project.commonOrigin;
|
|
51
45
|
}
|
|
52
46
|
|
|
53
47
|
// calculate elevation, if 3d not enabled set to 0
|
|
@@ -56,11 +50,11 @@ void main(void) {
|
|
|
56
50
|
// calculate stroke offset
|
|
57
51
|
float strokeOffsetRatio = 1.0;
|
|
58
52
|
|
|
59
|
-
if (extruded) {
|
|
60
|
-
elevation = instanceElevations * (positions.z + 1.0) / 2.0 * elevationScale;
|
|
61
|
-
} else if (stroked) {
|
|
62
|
-
float halfOffset = project_pixel_size(widthScale) / cellWidth;
|
|
63
|
-
if (isStroke) {
|
|
53
|
+
if (column.extruded) {
|
|
54
|
+
elevation = instanceElevations * (positions.z + 1.0) / 2.0 * column.elevationScale;
|
|
55
|
+
} else if (column.stroked) {
|
|
56
|
+
float halfOffset = project_pixel_size(column.widthScale) / cellWidth;
|
|
57
|
+
if (column.isStroke) {
|
|
64
58
|
strokeOffsetRatio -= sign(positions.z) * halfOffset;
|
|
65
59
|
} else {
|
|
66
60
|
strokeOffsetRatio -= halfOffset;
|
|
@@ -81,16 +75,16 @@ void main(void) {
|
|
|
81
75
|
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
|
82
76
|
|
|
83
77
|
// Light calculations
|
|
84
|
-
if (extruded && !isStroke) {
|
|
78
|
+
if (column.extruded && !column.isStroke) {
|
|
85
79
|
#ifdef FLAT_SHADING
|
|
86
80
|
position_commonspace = geometry.position;
|
|
87
|
-
vColor = vec4(color.rgb, color.a * opacity);
|
|
81
|
+
vColor = vec4(color.rgb, color.a * layer.opacity);
|
|
88
82
|
#else
|
|
89
|
-
vec3 lightColor = lighting_getLightColor(color.rgb,
|
|
90
|
-
vColor = vec4(lightColor, color.a * opacity);
|
|
83
|
+
vec3 lightColor = lighting_getLightColor(color.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
|
|
84
|
+
vColor = vec4(lightColor, color.a * layer.opacity);
|
|
91
85
|
#endif
|
|
92
86
|
} else {
|
|
93
|
-
vColor = vec4(color.rgb, color.a * opacity);
|
|
87
|
+
vColor = vec4(color.rgb, color.a * layer.opacity);
|
|
94
88
|
}
|
|
95
89
|
|
|
96
90
|
DECKGL_FILTER_COLOR(vColor, geometry);
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {
|
|
2
6
|
Accessor,
|
|
3
7
|
CompositeLayer,
|
|
@@ -113,7 +117,8 @@ export default class RasterLayer<DataT = any, ExtraProps = {}> extends Composite
|
|
|
113
117
|
|
|
114
118
|
const blockSize = data.blockSize ?? 0;
|
|
115
119
|
const [xOffset, yOffset, scale] = quadbinToOffset(tileIndex);
|
|
116
|
-
const offset = [xOffset, yOffset
|
|
120
|
+
const offset = [xOffset, yOffset];
|
|
121
|
+
const lineWidthScale = scale / blockSize;
|
|
117
122
|
|
|
118
123
|
// Filled Column Layer
|
|
119
124
|
const CellLayer = this.getSubLayerClass('column', RasterColumnLayer);
|
|
@@ -136,6 +141,7 @@ export default class RasterLayer<DataT = any, ExtraProps = {}> extends Composite
|
|
|
136
141
|
},
|
|
137
142
|
dataComparator: wrappedDataComparator,
|
|
138
143
|
offset,
|
|
144
|
+
lineWidthScale, // Re-use widthScale prop to pass cell scale,
|
|
139
145
|
highlightedObjectIndex,
|
|
140
146
|
highlightColor
|
|
141
147
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {CompositeLayer, CompositeLayerProps, DefaultProps, Layer, LayersList} from '@deck.gl/core';
|
|
2
6
|
import RasterLayer, {RasterLayerProps} from './raster-layer';
|
|
3
7
|
import QuadbinTileset2D from './quadbin-tileset-2d';
|
|
4
|
-
import type {TilejsonResult} from '
|
|
8
|
+
import type {TilejsonResult} from '@carto/api-client';
|
|
5
9
|
import {injectAccessToken, TilejsonPropType} from './utils';
|
|
6
10
|
import {DEFAULT_TILE_SIZE} from '../constants';
|
|
7
11
|
import {TileLayer, TileLayerProps} from '@deck.gl/geo-layers';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {readPackedTypedArray} from './fast-pbf';
|
|
2
6
|
import {Indices, IndexScheme} from './spatialjson-utils';
|
|
3
7
|
import {NumericProp, NumericPropKeyValueReader, PropertiesReader} from './carto-tile';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import earcut from 'earcut';
|
|
2
6
|
import {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
3
7
|
import type {BinaryFeatureCollection, BinaryPolygonFeature, TypedArray} from '@loaders.gl/schema';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
// Optimized (100X speed improvement) reading function for binary data
|
|
2
6
|
export function readPackedTypedArray(TypedArray, pbf, obj) {
|
|
3
7
|
const end = pbf.type === 2 ? pbf.readVarint() + pbf.pos : pbf.pos + 1;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {registerLoaders} from '@loaders.gl/core';
|
|
2
6
|
import {DefaultProps, LayerProps} from '@deck.gl/core';
|
|
3
7
|
import CartoRasterTileLoader from './schema/carto-raster-tile-loader';
|
package/src/layers/utils.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {log} from '@deck.gl/core';
|
|
2
6
|
import {Tile as PropertiesTile} from './schema/carto-properties-tile';
|
|
3
7
|
import {Tile as VectorTile} from './schema/carto-tile';
|
|
4
8
|
import {_deepEqual as deepEqual} from '@deck.gl/core';
|
|
5
|
-
import type {TilejsonResult} from '
|
|
9
|
+
import type {TilejsonResult} from '@carto/api-client';
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* Adds access token to Authorization header in loadOptions
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {registerLoaders} from '@loaders.gl/core';
|
|
2
6
|
import CartoPropertiesTileLoader from './schema/carto-properties-tile-loader';
|
|
3
7
|
import CartoVectorTileLoader from './schema/carto-vector-tile-loader';
|
|
@@ -15,7 +19,7 @@ import {
|
|
|
15
19
|
} from '@deck.gl/geo-layers';
|
|
16
20
|
import {GeoJsonLayer} from '@deck.gl/layers';
|
|
17
21
|
|
|
18
|
-
import type {TilejsonResult} from '
|
|
22
|
+
import type {TilejsonResult} from '@carto/api-client';
|
|
19
23
|
import {TilejsonPropType, injectAccessToken, mergeBoundaryData} from './utils';
|
|
20
24
|
import {DEFAULT_TILE_SIZE} from '../constants';
|
|
21
25
|
|
package/src/style/palette.ts
CHANGED
package/src/style/utils.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { APIErrorContext } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* Custom error for reported errors in CARTO Maps API.
|
|
5
|
-
* Provides useful debugging information in console and context for applications.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
export declare class CartoAPIError extends Error {
|
|
9
|
-
/** Source error from server */
|
|
10
|
-
error: Error;
|
|
11
|
-
/** Context (API call & parameters) in which error occured */
|
|
12
|
-
errorContext: APIErrorContext;
|
|
13
|
-
/** Response from server */
|
|
14
|
-
response?: Response;
|
|
15
|
-
/** JSON Response from server */
|
|
16
|
-
responseJson?: any;
|
|
17
|
-
constructor(error: Error, errorContext: APIErrorContext, response?: Response, responseJson?: any);
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=carto-api-error.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"carto-api-error.d.ts","sourceRoot":"","sources":["../../src/api/carto-api-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAC,mBAAgB;AAE7C;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,+BAA+B;IAC/B,KAAK,EAAE,KAAK,CAAC;IAEb,6DAA6D;IAC7D,YAAY,EAAE,eAAe,CAAC;IAE9B,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB,gCAAgC;IAChC,YAAY,CAAC,EAAE,GAAG,CAAC;gBAGjB,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,eAAe,EAC7B,QAAQ,CAAC,EAAE,QAAQ,EACnB,YAAY,CAAC,EAAE,GAAG;CAmCrB"}
|
|
@@ -1,48 +0,0 @@
|
|
|
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, responseJson) {
|
|
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.responseJson = responseJson;
|
|
39
|
-
this.error = error;
|
|
40
|
-
this.errorContext = errorContext;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Converts camelCase to Camel Case
|
|
45
|
-
*/
|
|
46
|
-
function formatErrorKey(key) {
|
|
47
|
-
return key.replace(/([A-Z])/g, ' $1').replace(/^./, s => s.toUpperCase());
|
|
48
|
-
}
|
package/dist/api/common.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_API_BASE_URL = "https://gcp-us-east1.api.carto.com";
|
|
2
|
-
export declare const DEFAULT_CLIENT = "deck-gl-carto";
|
|
3
|
-
export declare const V3_MINOR_VERSION = "3.4";
|
|
4
|
-
export declare const DEFAULT_MAX_LENGTH_URL = 7000;
|
|
5
|
-
//# sourceMappingURL=common.d.ts.map
|
package/dist/api/common.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/api/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,uCAAuC,CAAC;AACzE,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AAGtC,eAAO,MAAM,sBAAsB,OAAO,CAAC"}
|
package/dist/api/common.js
DELETED
package/dist/api/endpoints.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { MapType } from "./types.js";
|
|
2
|
-
export type V3Endpoint = 'maps' | 'stats' | 'sql';
|
|
3
|
-
export declare function buildPublicMapUrl({ apiBaseUrl, cartoMapId }: {
|
|
4
|
-
apiBaseUrl: string;
|
|
5
|
-
cartoMapId: string;
|
|
6
|
-
}): string;
|
|
7
|
-
export declare function buildStatsUrl({ attribute, apiBaseUrl, connectionName, source, type }: {
|
|
8
|
-
attribute: string;
|
|
9
|
-
apiBaseUrl: string;
|
|
10
|
-
connectionName: string;
|
|
11
|
-
source: string;
|
|
12
|
-
type: MapType;
|
|
13
|
-
}): string;
|
|
14
|
-
export declare function buildSourceUrl({ apiBaseUrl, connectionName, endpoint }: {
|
|
15
|
-
apiBaseUrl: string;
|
|
16
|
-
connectionName: string;
|
|
17
|
-
endpoint: MapType;
|
|
18
|
-
}): string;
|
|
19
|
-
export declare function buildQueryUrl({ apiBaseUrl, connectionName }: {
|
|
20
|
-
apiBaseUrl: string;
|
|
21
|
-
connectionName: string;
|
|
22
|
-
}): string;
|
|
23
|
-
//# sourceMappingURL=endpoints.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/api/endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,mBAAgB;AAEhC,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAelD,wBAAgB,iBAAiB,CAAC,EAChC,UAAU,EACV,UAAU,EACX,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAET;AAED,wBAAgB,aAAa,CAAC,EAC5B,SAAS,EACT,UAAU,EACV,cAAc,EACd,MAAM,EACN,IAAI,EACL,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf,GAAG,MAAM,CAOT;AAED,wBAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,cAAc,EACd,QAAQ,EACT,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;CACnB,GAAG,MAAM,CAET;AAED,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,cAAc,EACf,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,MAAM,CAET"}
|
package/dist/api/endpoints.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/api/query.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { SourceOptions, QuerySourceOptions, QueryResult } from "../sources/types.js";
|
|
2
|
-
export type QueryOptions = SourceOptions & Omit<QuerySourceOptions, 'spatialDataColumn'>;
|
|
3
|
-
export declare const query: (options: QueryOptions) => Promise<QueryResult>;
|
|
4
|
-
//# sourceMappingURL=query.d.ts.map
|
package/dist/api/query.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/api/query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAC,4BAAyB;AAKrF,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,IAAI,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;AAGzF,eAAO,MAAM,KAAK,YAA4B,YAAY,KAAG,QAAQ,WAAW,CAgC/E,CAAC"}
|
package/dist/api/query.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { SOURCE_DEFAULTS } from "../sources/index.js";
|
|
2
|
-
import { buildQueryUrl } from "./endpoints.js";
|
|
3
|
-
import { requestWithParameters } from "./request-with-parameters.js";
|
|
4
|
-
export const query = async function (options) {
|
|
5
|
-
const { apiBaseUrl = SOURCE_DEFAULTS.apiBaseUrl, clientId = SOURCE_DEFAULTS.clientId, maxLengthURL = SOURCE_DEFAULTS.maxLengthURL, connectionName, sqlQuery, queryParameters } = options;
|
|
6
|
-
const urlParameters = { q: sqlQuery };
|
|
7
|
-
if (queryParameters) {
|
|
8
|
-
urlParameters.queryParameters = JSON.stringify(queryParameters);
|
|
9
|
-
}
|
|
10
|
-
const baseUrl = buildQueryUrl({ apiBaseUrl, connectionName });
|
|
11
|
-
const headers = { Authorization: `Bearer ${options.accessToken}`, ...options.headers };
|
|
12
|
-
const parameters = { client: clientId, ...urlParameters };
|
|
13
|
-
const errorContext = {
|
|
14
|
-
requestType: 'SQL',
|
|
15
|
-
connection: options.connectionName,
|
|
16
|
-
type: 'query',
|
|
17
|
-
source: JSON.stringify(parameters, undefined, 2)
|
|
18
|
-
};
|
|
19
|
-
return await requestWithParameters({
|
|
20
|
-
baseUrl,
|
|
21
|
-
parameters,
|
|
22
|
-
headers,
|
|
23
|
-
errorContext,
|
|
24
|
-
maxLengthURL
|
|
25
|
-
});
|
|
26
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { APIErrorContext } from "./types.js";
|
|
2
|
-
export declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL }: {
|
|
3
|
-
baseUrl: string;
|
|
4
|
-
parameters?: Record<string, unknown>;
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
errorContext: APIErrorContext;
|
|
7
|
-
maxLengthURL?: number;
|
|
8
|
-
}): Promise<T>;
|
|
9
|
-
//# sourceMappingURL=request-with-parameters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-with-parameters.d.ts","sourceRoot":"","sources":["../../src/api/request-with-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,mBAAgB;AAmB7C,wBAAsB,qBAAqB,CAAC,CAAC,GAAG,GAAG,EAAE,EACnD,OAAO,EACP,UAAe,EACf,OAAO,EAAE,aAAkB,EAC3B,YAAY,EACZ,YAAqC,EACtC,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,YAAY,EAAE,eAAe,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,CAAC,CAAC,CAsCb"}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { VERSION } from '@deck.gl/core';
|
|
2
|
-
import { isPureObject } from "../utils.js";
|
|
3
|
-
import { CartoAPIError } from "./carto-api-error.js";
|
|
4
|
-
import { DEFAULT_MAX_LENGTH_URL, V3_MINOR_VERSION } from "./common.js";
|
|
5
|
-
/**
|
|
6
|
-
* Parameters added to all requests issued with `requestWithParameters()`.
|
|
7
|
-
* These parameters override parameters already in the base URL, but not
|
|
8
|
-
* user-provided parameters.
|
|
9
|
-
*/
|
|
10
|
-
const DEFAULT_PARAMETERS = {
|
|
11
|
-
v: V3_MINOR_VERSION,
|
|
12
|
-
deckglVersion: VERSION
|
|
13
|
-
};
|
|
14
|
-
const DEFAULT_HEADERS = {
|
|
15
|
-
Accept: 'application/json',
|
|
16
|
-
'Content-Type': 'application/json'
|
|
17
|
-
};
|
|
18
|
-
const REQUEST_CACHE = new Map();
|
|
19
|
-
export async function requestWithParameters({ baseUrl, parameters = {}, headers: customHeaders = {}, errorContext, maxLengthURL = DEFAULT_MAX_LENGTH_URL }) {
|
|
20
|
-
parameters = { ...DEFAULT_PARAMETERS, ...parameters };
|
|
21
|
-
baseUrl = excludeURLParameters(baseUrl, Object.keys(parameters));
|
|
22
|
-
const key = createCacheKey(baseUrl, parameters, customHeaders);
|
|
23
|
-
if (REQUEST_CACHE.has(key)) {
|
|
24
|
-
return REQUEST_CACHE.get(key);
|
|
25
|
-
}
|
|
26
|
-
const url = createURLWithParameters(baseUrl, parameters);
|
|
27
|
-
const headers = { ...DEFAULT_HEADERS, ...customHeaders };
|
|
28
|
-
/* global fetch */
|
|
29
|
-
const fetchPromise = url.length > maxLengthURL
|
|
30
|
-
? fetch(baseUrl, { method: 'POST', body: JSON.stringify(parameters), headers })
|
|
31
|
-
: fetch(url, { headers });
|
|
32
|
-
let response;
|
|
33
|
-
let responseJson;
|
|
34
|
-
const jsonPromise = fetchPromise
|
|
35
|
-
.then((_response) => {
|
|
36
|
-
response = _response;
|
|
37
|
-
return response.json();
|
|
38
|
-
})
|
|
39
|
-
.then((json) => {
|
|
40
|
-
responseJson = json;
|
|
41
|
-
if (!response || !response.ok) {
|
|
42
|
-
throw new Error(json.error);
|
|
43
|
-
}
|
|
44
|
-
return json;
|
|
45
|
-
})
|
|
46
|
-
.catch((error) => {
|
|
47
|
-
REQUEST_CACHE.delete(key);
|
|
48
|
-
throw new CartoAPIError(error, errorContext, response, responseJson);
|
|
49
|
-
});
|
|
50
|
-
REQUEST_CACHE.set(key, jsonPromise);
|
|
51
|
-
return jsonPromise;
|
|
52
|
-
}
|
|
53
|
-
function createCacheKey(baseUrl, parameters, headers) {
|
|
54
|
-
const parameterEntries = Object.entries(parameters).sort(([a], [b]) => (a > b ? 1 : -1));
|
|
55
|
-
const headerEntries = Object.entries(headers).sort(([a], [b]) => (a > b ? 1 : -1));
|
|
56
|
-
return JSON.stringify({ baseUrl, parameters: parameterEntries, headers: headerEntries });
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Appends query string parameters to a URL. Existing URL parameters are kept,
|
|
60
|
-
* unless there is a conflict, in which case the new parameters override
|
|
61
|
-
* those already in the URL.
|
|
62
|
-
*/
|
|
63
|
-
function createURLWithParameters(baseUrlString, parameters) {
|
|
64
|
-
const baseUrl = new URL(baseUrlString);
|
|
65
|
-
for (const [key, value] of Object.entries(parameters)) {
|
|
66
|
-
if (isPureObject(value) || Array.isArray(value)) {
|
|
67
|
-
baseUrl.searchParams.set(key, JSON.stringify(value));
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
baseUrl.searchParams.set(key, value.toString());
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return baseUrl.toString();
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Deletes query string parameters from a URL.
|
|
77
|
-
*/
|
|
78
|
-
function excludeURLParameters(baseUrlString, parameters) {
|
|
79
|
-
const baseUrl = new URL(baseUrlString);
|
|
80
|
-
for (const param of parameters) {
|
|
81
|
-
if (baseUrl.searchParams.has(param)) {
|
|
82
|
-
baseUrl.searchParams.delete(param);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return baseUrl.toString();
|
|
86
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { MapType } from "../api/types.js";
|
|
2
|
-
import type { GeojsonResult, JsonResult, SourceOptionalOptions, SourceRequiredOptions, TilejsonResult } from "./types.js";
|
|
3
|
-
export declare const SOURCE_DEFAULTS: SourceOptionalOptions;
|
|
4
|
-
export declare function baseSource<UrlParameters extends Record<string, unknown>>(endpoint: MapType, options: Partial<SourceOptionalOptions> & SourceRequiredOptions, urlParameters: UrlParameters): Promise<TilejsonResult | GeojsonResult | JsonResult>;
|
|
5
|
-
//# sourceMappingURL=base-source.d.ts.map
|