@deck.gl/carto 9.0.13 → 9.0.15
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 +17 -0
- package/dist/api/basemap.d.ts.map +1 -0
- package/dist/api/basemap.js +76 -0
- package/dist/api/fetch-map.d.ts +10 -12
- package/dist/api/fetch-map.d.ts.map +1 -1
- package/dist/api/fetch-map.js +7 -3
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/parse-map.d.ts +21 -1
- package/dist/api/parse-map.d.ts.map +1 -1
- package/dist/api/parse-map.js +1 -0
- package/dist/api/query.d.ts.map +1 -1
- package/dist/api/query.js +4 -3
- package/dist/api/request-with-parameters.d.ts +1 -1
- package/dist/api/request-with-parameters.d.ts.map +1 -1
- package/dist/api/request-with-parameters.js +6 -3
- package/dist/api/types.d.ts +82 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/basemap.d.ts +17 -0
- package/dist/basemap.d.ts.map +1 -1
- package/dist/basemap.js +97 -7
- package/dist/cartoRasterTile-worker.js +1 -1
- package/dist/cartoSpatialTile-worker.js +1 -1
- package/dist/cartoVectorTile-worker.js +1 -1
- package/dist/dist.dev.js +1745 -2368
- package/dist/index.cjs +270 -89
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/layers/heatmap.d.ts +3 -2
- package/dist/layers/heatmap.d.ts.map +1 -1
- package/dist/layers/heatmap.js +18 -6
- package/dist/layers/quadbin-heatmap-tile-layer.d.ts +5 -2
- package/dist/layers/quadbin-heatmap-tile-layer.d.ts.map +1 -1
- package/dist/layers/quadbin-heatmap-tile-layer.js +3 -2
- package/dist/layers/schema/carto-raster-tile-loader.js +1 -1
- package/dist/layers/schema/carto-spatial-tile-loader.js +1 -1
- package/dist/layers/schema/carto-vector-tile-loader.js +1 -1
- package/dist/sources/base-source.d.ts +1 -1
- package/dist/sources/base-source.d.ts.map +1 -1
- package/dist/sources/boundary-query-source.js +2 -2
- package/dist/sources/boundary-table-source.js +1 -1
- package/dist/sources/h3-query-source.js +1 -1
- package/dist/sources/quadbin-query-source.js +1 -1
- package/dist/sources/vector-query-source.js +2 -2
- package/dist/sources/vector-table-source.js +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -0
- package/dist.min.js +21 -15
- package/package.json +6 -6
- package/src/api/basemap.ts +100 -0
- package/src/api/fetch-map.ts +20 -6
- package/src/api/index.ts +11 -2
- package/src/api/parse-map.ts +24 -3
- package/src/api/query.ts +4 -2
- package/src/api/request-with-parameters.ts +12 -9
- package/src/api/types.ts +103 -1
- package/src/basemap.ts +134 -7
- package/src/index.ts +14 -2
- package/src/layers/heatmap.ts +23 -8
- package/src/layers/quadbin-heatmap-tile-layer.ts +8 -5
- package/src/sources/base-source.ts +1 -1
- package/src/sources/boundary-query-source.ts +4 -4
- package/src/sources/boundary-table-source.ts +2 -2
- package/src/sources/h3-query-source.ts +2 -2
- package/src/sources/quadbin-query-source.ts +2 -2
- package/src/sources/vector-query-source.ts +4 -4
- package/src/sources/vector-table-source.ts +2 -2
- package/src/utils.ts +5 -0
package/dist/index.cjs
CHANGED
|
@@ -36,12 +36,18 @@ __export(dist_exports, {
|
|
|
36
36
|
RasterTileLayer: () => RasterTileLayer,
|
|
37
37
|
SOURCE_DEFAULTS: () => SOURCE_DEFAULTS,
|
|
38
38
|
VectorTileLayer: () => VectorTileLayer,
|
|
39
|
+
_GOOGLE_BASEMAPS: () => GOOGLE_BASEMAPS,
|
|
39
40
|
_PointLabelLayer: () => PointLabelLayer,
|
|
41
|
+
_STYLE_LAYER_GROUPS: () => STYLE_LAYER_GROUPS,
|
|
42
|
+
_applyLayerGroupFilters: () => applyLayerGroupFilters,
|
|
43
|
+
_fetchStyle: () => fetchStyle,
|
|
44
|
+
_getStyleUrl: () => getStyleUrl,
|
|
40
45
|
boundaryQuerySource: () => boundaryQuerySource,
|
|
41
46
|
boundaryTableSource: () => boundaryTableSource,
|
|
42
47
|
colorBins: () => colorBins,
|
|
43
48
|
colorCategories: () => colorCategories,
|
|
44
49
|
colorContinuous: () => colorContinuous,
|
|
50
|
+
fetchBasemapProps: () => fetchBasemapProps,
|
|
45
51
|
fetchMap: () => fetchMap,
|
|
46
52
|
h3QuerySource: () => h3QuerySource,
|
|
47
53
|
h3TableSource: () => h3TableSource,
|
|
@@ -263,9 +269,11 @@ function scaleIdentity() {
|
|
|
263
269
|
};
|
|
264
270
|
return scale;
|
|
265
271
|
}
|
|
272
|
+
var isObject = (x) => x !== null && typeof x === "object";
|
|
273
|
+
var isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
|
|
266
274
|
|
|
267
275
|
// dist/layers/schema/carto-raster-tile-loader.js
|
|
268
|
-
var VERSION = true ? "9.0.
|
|
276
|
+
var VERSION = true ? "9.0.15" : "latest";
|
|
269
277
|
var id = "cartoRasterTile";
|
|
270
278
|
var DEFAULT_OPTIONS = {
|
|
271
279
|
cartoRasterTile: {
|
|
@@ -536,7 +544,7 @@ function binaryToSpatialjson(binary) {
|
|
|
536
544
|
}
|
|
537
545
|
|
|
538
546
|
// dist/layers/schema/carto-spatial-tile-loader.js
|
|
539
|
-
var VERSION2 = true ? "9.0.
|
|
547
|
+
var VERSION2 = true ? "9.0.15" : "latest";
|
|
540
548
|
var id2 = "cartoSpatialTile";
|
|
541
549
|
var DEFAULT_OPTIONS2 = {
|
|
542
550
|
cartoSpatialTile: {
|
|
@@ -1042,6 +1050,7 @@ var import_layers2 = require("@deck.gl/layers");
|
|
|
1042
1050
|
// dist/layers/heatmap.js
|
|
1043
1051
|
var import_shadertools = require("@luma.gl/shadertools");
|
|
1044
1052
|
var fs = `uniform heatmapUniforms {
|
|
1053
|
+
vec2 delta;
|
|
1045
1054
|
float radiusPixels;
|
|
1046
1055
|
vec2 colorDomain;
|
|
1047
1056
|
vec3 color1;
|
|
@@ -1081,24 +1090,29 @@ float f = (value - range.x) / (range.y - range.x);
|
|
|
1081
1090
|
return mix(c1, c2, f) / 255.0;
|
|
1082
1091
|
}
|
|
1083
1092
|
const vec3 SHIFT = vec3(1.0, 256.0, 256.0 * 256.0);
|
|
1093
|
+
vec4 pack(float value) {
|
|
1094
|
+
return vec4(mod(vec3(value, floor(value / SHIFT.yz)), 256.0), 255.0) / 255.0;
|
|
1095
|
+
}
|
|
1084
1096
|
float unpack(vec3 color) {
|
|
1085
1097
|
return 255.0 * dot(color, SHIFT);
|
|
1086
1098
|
}
|
|
1087
1099
|
vec4 heatmap_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
1100
|
+
bool firstPass = (heatmap.delta.y < 0.5);
|
|
1088
1101
|
float accumulator = 0.0;
|
|
1089
1102
|
float offset = 0.5 * random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
1090
1103
|
const float sigma = SUPPORT / 3.0;
|
|
1091
1104
|
const float a = -0.5 / (sigma * sigma);
|
|
1092
|
-
const float w0 =
|
|
1105
|
+
const float w0 = 0.3989422804014327 / sigma;
|
|
1093
1106
|
for (float t = -SUPPORT; t <= SUPPORT; t++) {
|
|
1094
|
-
|
|
1095
|
-
vec2 percent = (vec2(s, t) + offset - 0.5) / SUPPORT;
|
|
1107
|
+
vec2 percent = (t * heatmap.delta + offset - 0.5) / SUPPORT;
|
|
1096
1108
|
vec2 delta = percent * heatmap.radiusPixels / texSize;
|
|
1097
1109
|
vec4 offsetColor = texture(source, texCoord + delta);
|
|
1098
1110
|
float value = unpack(offsetColor.rgb);
|
|
1099
|
-
float weight = w0 * exp(a *
|
|
1111
|
+
float weight = w0 * exp(a * t * t);
|
|
1100
1112
|
accumulator += value * weight;
|
|
1101
1113
|
}
|
|
1114
|
+
if (firstPass) {
|
|
1115
|
+
return pack(accumulator);
|
|
1102
1116
|
}
|
|
1103
1117
|
float f = (accumulator - heatmap.colorDomain[0]) / (heatmap.colorDomain[1] - heatmap.colorDomain[0]);
|
|
1104
1118
|
vec4 color = vec4(0.0);
|
|
@@ -1120,6 +1134,7 @@ var defaultColorRange = [
|
|
|
1120
1134
|
var heatmap = {
|
|
1121
1135
|
name: "heatmap",
|
|
1122
1136
|
uniformPropTypes: {
|
|
1137
|
+
delta: { value: [0, 1] },
|
|
1123
1138
|
radiusPixels: { value: 20, min: 0, softMax: 100 },
|
|
1124
1139
|
colorDomain: { value: [0, 1] },
|
|
1125
1140
|
color1: { value: [0, 0, 0] },
|
|
@@ -1131,6 +1146,7 @@ var heatmap = {
|
|
|
1131
1146
|
opacity: { value: 1, min: 0, max: 1 }
|
|
1132
1147
|
},
|
|
1133
1148
|
uniformTypes: {
|
|
1149
|
+
delta: "vec2<f32>",
|
|
1134
1150
|
radiusPixels: "f32",
|
|
1135
1151
|
colorDomain: "vec2<f32>",
|
|
1136
1152
|
color1: "vec3<f32>",
|
|
@@ -1142,9 +1158,10 @@ var heatmap = {
|
|
|
1142
1158
|
opacity: "f32"
|
|
1143
1159
|
},
|
|
1144
1160
|
getUniforms: (opts) => {
|
|
1145
|
-
const { colorRange = defaultColorRange, radiusPixels = 20, colorDomain = [0, 1], opacity = 1 } = opts;
|
|
1161
|
+
const { delta = [1, 0], colorRange = defaultColorRange, radiusPixels = 20, colorDomain = [0, 1], opacity = 1 } = opts;
|
|
1146
1162
|
const [color1, color2, color3, color4, color5, color6] = colorRange;
|
|
1147
1163
|
return {
|
|
1164
|
+
delta,
|
|
1148
1165
|
color1,
|
|
1149
1166
|
color2,
|
|
1150
1167
|
color3,
|
|
@@ -1158,7 +1175,10 @@ var heatmap = {
|
|
|
1158
1175
|
},
|
|
1159
1176
|
dependencies: [import_shadertools.random],
|
|
1160
1177
|
fs,
|
|
1161
|
-
passes: [
|
|
1178
|
+
passes: [
|
|
1179
|
+
{ sampler: true, uniforms: { delta: [1, 0] } },
|
|
1180
|
+
{ sampler: true, uniforms: { delta: [0, 1] } }
|
|
1181
|
+
]
|
|
1162
1182
|
};
|
|
1163
1183
|
|
|
1164
1184
|
// dist/layers/post-process-utils.js
|
|
@@ -1293,7 +1313,7 @@ var _RTTSolidPolygonLayer = class extends RTTModifier(import_layers2.SolidPolygo
|
|
|
1293
1313
|
float value = 255.0 * dot(SHIFT, color.rgb);
|
|
1294
1314
|
|
|
1295
1315
|
// Keep "power" delivered to screen constant when tiles update
|
|
1296
|
-
float relativeZoom = log2(
|
|
1316
|
+
float relativeZoom = log2(project.scale) - cellResolution + 3.5; // range 0-1
|
|
1297
1317
|
float relativeArea = pow(2.0, -2.0 * relativeZoom); // range 0.25-1
|
|
1298
1318
|
value *= relativeArea;
|
|
1299
1319
|
|
|
@@ -1321,7 +1341,7 @@ function encodeWeight(w) {
|
|
|
1321
1341
|
return [w % 256, Math.floor(w / 256), Math.floor(w / (256 * 256))];
|
|
1322
1342
|
}
|
|
1323
1343
|
var defaultProps6 = {
|
|
1324
|
-
|
|
1344
|
+
data: TilejsonPropType,
|
|
1325
1345
|
getWeight: { type: "accessor", value: 1 }
|
|
1326
1346
|
};
|
|
1327
1347
|
var _QuadbinHeatmapTileLayer = class extends import_core9.CompositeLayer {
|
|
@@ -1619,7 +1639,7 @@ var carto_properties_tile_loader_default = CartoPropertiesTileLoader;
|
|
|
1619
1639
|
|
|
1620
1640
|
// dist/layers/schema/carto-vector-tile-loader.js
|
|
1621
1641
|
var import_earcut = __toESM(require("earcut"), 1);
|
|
1622
|
-
var VERSION3 = true ? "9.0.
|
|
1642
|
+
var VERSION3 = true ? "9.0.15" : "latest";
|
|
1623
1643
|
var id3 = "cartoVectorTile";
|
|
1624
1644
|
var DEFAULT_OPTIONS3 = {
|
|
1625
1645
|
cartoVectorTile: {
|
|
@@ -1777,15 +1797,140 @@ var VectorTileLayer = _VectorTileLayer;
|
|
|
1777
1797
|
_VectorTileLayer.defaultProps = defaultProps9;
|
|
1778
1798
|
})();
|
|
1779
1799
|
|
|
1800
|
+
// dist/api/carto-api-error.js
|
|
1801
|
+
var CartoAPIError = class extends Error {
|
|
1802
|
+
constructor(error, errorContext, response) {
|
|
1803
|
+
let responseString = "Failed to connect";
|
|
1804
|
+
if (response) {
|
|
1805
|
+
responseString = "Server returned: ";
|
|
1806
|
+
if (response.status === 400) {
|
|
1807
|
+
responseString += "Bad request";
|
|
1808
|
+
} else if (response.status === 401 || response.status === 403) {
|
|
1809
|
+
responseString += "Unauthorized access";
|
|
1810
|
+
} else if (response.status === 404) {
|
|
1811
|
+
responseString += "Not found";
|
|
1812
|
+
} else {
|
|
1813
|
+
responseString += "Error";
|
|
1814
|
+
}
|
|
1815
|
+
responseString += ` (${response.status}):`;
|
|
1816
|
+
}
|
|
1817
|
+
responseString += ` ${error.message || error}`;
|
|
1818
|
+
let message = `${errorContext.requestType} API request failed`;
|
|
1819
|
+
message += `
|
|
1820
|
+
${responseString}`;
|
|
1821
|
+
for (const key of Object.keys(errorContext)) {
|
|
1822
|
+
if (key === "requestType")
|
|
1823
|
+
continue;
|
|
1824
|
+
message += `
|
|
1825
|
+
${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
1826
|
+
}
|
|
1827
|
+
message += "\n";
|
|
1828
|
+
super(message);
|
|
1829
|
+
this.name = "CartoAPIError";
|
|
1830
|
+
this.response = response;
|
|
1831
|
+
this.error = error;
|
|
1832
|
+
this.errorContext = errorContext;
|
|
1833
|
+
}
|
|
1834
|
+
};
|
|
1835
|
+
function formatErrorKey(key) {
|
|
1836
|
+
return key.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase());
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1780
1839
|
// dist/basemap.js
|
|
1781
|
-
var
|
|
1840
|
+
var cartoStyleUrlTemplate = "https://basemaps.cartocdn.com/gl/{basemap}-gl-style/style.json";
|
|
1841
|
+
var CARTO_MAP_STYLES = ["positron", "dark-matter", "voyager"];
|
|
1842
|
+
var GOOGLE_BASEMAPS = {
|
|
1843
|
+
roadmap: {
|
|
1844
|
+
mapTypeId: "roadmap",
|
|
1845
|
+
mapId: "3754c817b510f791"
|
|
1846
|
+
},
|
|
1847
|
+
"google-positron": {
|
|
1848
|
+
mapTypeId: "roadmap",
|
|
1849
|
+
mapId: "ea84ae4203ef21cd"
|
|
1850
|
+
},
|
|
1851
|
+
"google-dark-matter": {
|
|
1852
|
+
mapTypeId: "roadmap",
|
|
1853
|
+
mapId: "2fccc3b36c22a0e2"
|
|
1854
|
+
},
|
|
1855
|
+
"google-voyager": {
|
|
1856
|
+
mapTypeId: "roadmap",
|
|
1857
|
+
mapId: "885caf1e15bb9ef2"
|
|
1858
|
+
},
|
|
1859
|
+
satellite: {
|
|
1860
|
+
mapTypeId: "satellite"
|
|
1861
|
+
},
|
|
1862
|
+
hybrid: {
|
|
1863
|
+
mapTypeId: "hybrid"
|
|
1864
|
+
},
|
|
1865
|
+
terrain: {
|
|
1866
|
+
mapTypeId: "terrain"
|
|
1867
|
+
}
|
|
1868
|
+
};
|
|
1869
|
+
var STYLE_LAYER_GROUPS = [
|
|
1870
|
+
{
|
|
1871
|
+
slug: "label",
|
|
1872
|
+
filter: ({ id: id4 }) => Boolean(id4.match(/(?=(label|_label|place-|place_|poi-|poi_|watername_|roadname_|housenumber))/)),
|
|
1873
|
+
defaultVisibility: true
|
|
1874
|
+
},
|
|
1875
|
+
{
|
|
1876
|
+
slug: "road",
|
|
1877
|
+
filter: ({ id: id4 }) => Boolean(id4.match(/(?=(road|railway|tunnel|street|bridge))(?!.*label)/)),
|
|
1878
|
+
defaultVisibility: true
|
|
1879
|
+
},
|
|
1880
|
+
{
|
|
1881
|
+
slug: "border",
|
|
1882
|
+
filter: ({ id: id4 }) => Boolean(id4.match(/border|boundaries|boundary_/)),
|
|
1883
|
+
defaultVisibility: false
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
slug: "building",
|
|
1887
|
+
filter: ({ id: id4 }) => Boolean(id4.match(/building/)),
|
|
1888
|
+
defaultVisibility: true
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
slug: "water",
|
|
1892
|
+
filter: ({ id: id4 }) => Boolean(id4.match(/(?=(water|stream|ferry))/)),
|
|
1893
|
+
defaultVisibility: true
|
|
1894
|
+
},
|
|
1895
|
+
{
|
|
1896
|
+
slug: "land",
|
|
1897
|
+
filter: ({ id: id4 }) => Boolean(id4.match(/(?=(parks|landcover|industrial|sand|hillshade|park_))/)),
|
|
1898
|
+
defaultVisibility: true
|
|
1899
|
+
}
|
|
1900
|
+
];
|
|
1901
|
+
function applyLayerGroupFilters(style, visibleLayerGroups) {
|
|
1902
|
+
if (!Array.isArray(style == null ? void 0 : style.layers)) {
|
|
1903
|
+
return style;
|
|
1904
|
+
}
|
|
1905
|
+
const removedLayerFilters = STYLE_LAYER_GROUPS.filter((lg) => !visibleLayerGroups[lg.slug]).map((lg) => lg.filter);
|
|
1906
|
+
const visibleLayers = style.layers.filter((layer) => removedLayerFilters.every((match) => !match(layer)));
|
|
1907
|
+
return {
|
|
1908
|
+
...style,
|
|
1909
|
+
layers: visibleLayers
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
function someLayerGroupsDisabled(visibleLayerGroups) {
|
|
1913
|
+
return visibleLayerGroups && Object.values(visibleLayerGroups).every(Boolean) === false;
|
|
1914
|
+
}
|
|
1915
|
+
function getStyleUrl(styleType) {
|
|
1916
|
+
return cartoStyleUrlTemplate.replace("{basemap}", styleType);
|
|
1917
|
+
}
|
|
1918
|
+
async function fetchStyle({ styleUrl, errorContext }) {
|
|
1919
|
+
let response;
|
|
1920
|
+
return await fetch(styleUrl, { mode: "cors" }).then((res) => {
|
|
1921
|
+
response = res;
|
|
1922
|
+
return res.json();
|
|
1923
|
+
}).catch((error) => {
|
|
1924
|
+
throw new CartoAPIError(error, { ...errorContext, requestType: "Basemap style" }, response);
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1782
1927
|
var basemap_default = {
|
|
1783
|
-
VOYAGER:
|
|
1784
|
-
POSITRON:
|
|
1785
|
-
DARK_MATTER:
|
|
1786
|
-
VOYAGER_NOLABELS:
|
|
1787
|
-
POSITRON_NOLABELS:
|
|
1788
|
-
DARK_MATTER_NOLABELS:
|
|
1928
|
+
VOYAGER: getStyleUrl("voyager"),
|
|
1929
|
+
POSITRON: getStyleUrl("positron"),
|
|
1930
|
+
DARK_MATTER: getStyleUrl("dark-matter"),
|
|
1931
|
+
VOYAGER_NOLABELS: getStyleUrl("voyager-nolabels"),
|
|
1932
|
+
POSITRON_NOLABELS: getStyleUrl("positron-nolabels"),
|
|
1933
|
+
DARK_MATTER_NOLABELS: getStyleUrl("dark-matter-nolabels")
|
|
1789
1934
|
};
|
|
1790
1935
|
|
|
1791
1936
|
// dist/style/color-bins-style.js
|
|
@@ -1896,45 +2041,6 @@ function colorContinuous({ attr, domain, colors = DEFAULT_PALETTE, nullColor = N
|
|
|
1896
2041
|
};
|
|
1897
2042
|
}
|
|
1898
2043
|
|
|
1899
|
-
// dist/api/carto-api-error.js
|
|
1900
|
-
var CartoAPIError = class extends Error {
|
|
1901
|
-
constructor(error, errorContext, response) {
|
|
1902
|
-
let responseString = "Failed to connect";
|
|
1903
|
-
if (response) {
|
|
1904
|
-
responseString = "Server returned: ";
|
|
1905
|
-
if (response.status === 400) {
|
|
1906
|
-
responseString += "Bad request";
|
|
1907
|
-
} else if (response.status === 401 || response.status === 403) {
|
|
1908
|
-
responseString += "Unauthorized access";
|
|
1909
|
-
} else if (response.status === 404) {
|
|
1910
|
-
responseString += "Not found";
|
|
1911
|
-
} else {
|
|
1912
|
-
responseString += "Error";
|
|
1913
|
-
}
|
|
1914
|
-
responseString += ` (${response.status}):`;
|
|
1915
|
-
}
|
|
1916
|
-
responseString += ` ${error.message || error}`;
|
|
1917
|
-
let message = `${errorContext.requestType} API request failed`;
|
|
1918
|
-
message += `
|
|
1919
|
-
${responseString}`;
|
|
1920
|
-
for (const key of Object.keys(errorContext)) {
|
|
1921
|
-
if (key === "requestType")
|
|
1922
|
-
continue;
|
|
1923
|
-
message += `
|
|
1924
|
-
${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
1925
|
-
}
|
|
1926
|
-
message += "\n";
|
|
1927
|
-
super(message);
|
|
1928
|
-
this.name = "CartoAPIError";
|
|
1929
|
-
this.response = response;
|
|
1930
|
-
this.error = error;
|
|
1931
|
-
this.errorContext = errorContext;
|
|
1932
|
-
}
|
|
1933
|
-
};
|
|
1934
|
-
function formatErrorKey(key) {
|
|
1935
|
-
return key.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase());
|
|
1936
|
-
}
|
|
1937
|
-
|
|
1938
2044
|
// dist/api/common.js
|
|
1939
2045
|
var import_core13 = require("@deck.gl/core");
|
|
1940
2046
|
var DEFAULT_API_BASE_URL = "https://gcp-us-east1.api.carto.com";
|
|
@@ -1975,17 +2081,21 @@ function buildQueryUrl({ apiBaseUrl, connectionName }) {
|
|
|
1975
2081
|
|
|
1976
2082
|
// dist/api/request-with-parameters.js
|
|
1977
2083
|
function encodeParameter(name, value) {
|
|
2084
|
+
if (isPureObject(value) || Array.isArray(value)) {
|
|
2085
|
+
return `${name}=${encodeURIComponent(JSON.stringify(value))}`;
|
|
2086
|
+
}
|
|
1978
2087
|
return `${name}=${encodeURIComponent(value)}`;
|
|
1979
2088
|
}
|
|
1980
2089
|
var REQUEST_CACHE = /* @__PURE__ */ new Map();
|
|
1981
|
-
async function requestWithParameters({ baseUrl
|
|
1982
|
-
|
|
2090
|
+
async function requestWithParameters({ baseUrl, parameters, headers: customHeaders, errorContext }) {
|
|
2091
|
+
parameters = { ...DEFAULT_PARAMETERS, ...parameters };
|
|
2092
|
+
const key = createCacheKey(baseUrl, parameters || {}, customHeaders || {});
|
|
1983
2093
|
if (REQUEST_CACHE.has(key)) {
|
|
1984
2094
|
return REQUEST_CACHE.get(key);
|
|
1985
2095
|
}
|
|
1986
|
-
const url = parameters ? createURLWithParameters(
|
|
2096
|
+
const url = parameters ? createURLWithParameters(baseUrl, parameters) : baseUrl;
|
|
1987
2097
|
const headers = { ...DEFAULT_HEADERS, ...customHeaders };
|
|
1988
|
-
const fetchPromise = url.length > MAX_GET_LENGTH ? fetch(
|
|
2098
|
+
const fetchPromise = url.length > MAX_GET_LENGTH ? fetch(baseUrl, { method: "POST", body: JSON.stringify(parameters), headers }) : fetch(url, { headers });
|
|
1989
2099
|
let response;
|
|
1990
2100
|
const jsonPromise = fetchPromise.then((_response) => {
|
|
1991
2101
|
response = _response;
|
|
@@ -2002,16 +2112,14 @@ async function requestWithParameters({ baseUrl: baseUrl2, parameters, headers: c
|
|
|
2002
2112
|
REQUEST_CACHE.set(key, jsonPromise);
|
|
2003
2113
|
return jsonPromise;
|
|
2004
2114
|
}
|
|
2005
|
-
function createCacheKey(
|
|
2115
|
+
function createCacheKey(baseUrl, parameters, headers) {
|
|
2006
2116
|
const parameterEntries = Object.entries(parameters).sort(([a], [b]) => a > b ? 1 : -1);
|
|
2007
2117
|
const headerEntries = Object.entries(headers).sort(([a], [b]) => a > b ? 1 : -1);
|
|
2008
|
-
return JSON.stringify({ baseUrl
|
|
2118
|
+
return JSON.stringify({ baseUrl, parameters: parameterEntries, headers: headerEntries });
|
|
2009
2119
|
}
|
|
2010
|
-
function createURLWithParameters(
|
|
2011
|
-
const encodedParameters = Object.entries(
|
|
2012
|
-
|
|
2013
|
-
});
|
|
2014
|
-
return `${baseUrl2}?${encodedParameters.join("&")}`;
|
|
2120
|
+
function createURLWithParameters(baseUrl, parameters) {
|
|
2121
|
+
const encodedParameters = Object.entries(parameters).map(([key, value]) => encodeParameter(key, value));
|
|
2122
|
+
return `${baseUrl}?${encodedParameters.join("&")}`;
|
|
2015
2123
|
}
|
|
2016
2124
|
|
|
2017
2125
|
// dist/sources/base-source.js
|
|
@@ -2029,7 +2137,7 @@ async function baseSource(endpoint, options, urlParameters) {
|
|
|
2029
2137
|
mergedOptions[key] = optionalOptions[key];
|
|
2030
2138
|
}
|
|
2031
2139
|
}
|
|
2032
|
-
const
|
|
2140
|
+
const baseUrl = buildSourceUrl(mergedOptions);
|
|
2033
2141
|
const { clientId, format } = mergedOptions;
|
|
2034
2142
|
const headers = { Authorization: `Bearer ${options.accessToken}`, ...options.headers };
|
|
2035
2143
|
const parameters = { client: clientId, ...urlParameters };
|
|
@@ -2040,7 +2148,7 @@ async function baseSource(endpoint, options, urlParameters) {
|
|
|
2040
2148
|
source: JSON.stringify(parameters, void 0, 2)
|
|
2041
2149
|
};
|
|
2042
2150
|
const mapInstantiation = await requestWithParameters({
|
|
2043
|
-
baseUrl
|
|
2151
|
+
baseUrl,
|
|
2044
2152
|
parameters,
|
|
2045
2153
|
headers,
|
|
2046
2154
|
errorContext
|
|
@@ -2080,10 +2188,10 @@ var boundaryQuerySource = async function(options) {
|
|
|
2080
2188
|
urlParameters.columns = columns.join(",");
|
|
2081
2189
|
}
|
|
2082
2190
|
if (filters) {
|
|
2083
|
-
urlParameters.filters =
|
|
2191
|
+
urlParameters.filters = filters;
|
|
2084
2192
|
}
|
|
2085
2193
|
if (queryParameters) {
|
|
2086
|
-
urlParameters.queryParameters =
|
|
2194
|
+
urlParameters.queryParameters = queryParameters;
|
|
2087
2195
|
}
|
|
2088
2196
|
return baseSource("boundary", options, urlParameters);
|
|
2089
2197
|
};
|
|
@@ -2100,7 +2208,7 @@ var boundaryTableSource = async function(options) {
|
|
|
2100
2208
|
urlParameters.columns = columns.join(",");
|
|
2101
2209
|
}
|
|
2102
2210
|
if (filters) {
|
|
2103
|
-
urlParameters.filters =
|
|
2211
|
+
urlParameters.filters = filters;
|
|
2104
2212
|
}
|
|
2105
2213
|
return baseSource("boundary", options, urlParameters);
|
|
2106
2214
|
};
|
|
@@ -2118,7 +2226,7 @@ var h3QuerySource = async function(options) {
|
|
|
2118
2226
|
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
2119
2227
|
}
|
|
2120
2228
|
if (queryParameters) {
|
|
2121
|
-
urlParameters.queryParameters =
|
|
2229
|
+
urlParameters.queryParameters = queryParameters;
|
|
2122
2230
|
}
|
|
2123
2231
|
return baseSource("query", options, urlParameters);
|
|
2124
2232
|
};
|
|
@@ -2165,7 +2273,7 @@ var quadbinQuerySource = async function(options) {
|
|
|
2165
2273
|
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
2166
2274
|
}
|
|
2167
2275
|
if (queryParameters) {
|
|
2168
|
-
urlParameters.queryParameters =
|
|
2276
|
+
urlParameters.queryParameters = queryParameters;
|
|
2169
2277
|
}
|
|
2170
2278
|
return baseSource("query", options, urlParameters);
|
|
2171
2279
|
};
|
|
@@ -2205,10 +2313,10 @@ var vectorQuerySource = async function(options) {
|
|
|
2205
2313
|
urlParameters.columns = columns.join(",");
|
|
2206
2314
|
}
|
|
2207
2315
|
if (filters) {
|
|
2208
|
-
urlParameters.filters =
|
|
2316
|
+
urlParameters.filters = filters;
|
|
2209
2317
|
}
|
|
2210
2318
|
if (queryParameters) {
|
|
2211
|
-
urlParameters.queryParameters =
|
|
2319
|
+
urlParameters.queryParameters = queryParameters;
|
|
2212
2320
|
}
|
|
2213
2321
|
return baseSource("query", options, urlParameters);
|
|
2214
2322
|
};
|
|
@@ -2226,7 +2334,7 @@ var vectorTableSource = async function(options) {
|
|
|
2226
2334
|
urlParameters.columns = columns.join(",");
|
|
2227
2335
|
}
|
|
2228
2336
|
if (filters) {
|
|
2229
|
-
urlParameters.filters =
|
|
2337
|
+
urlParameters.filters = filters;
|
|
2230
2338
|
}
|
|
2231
2339
|
return baseSource("table", options, urlParameters);
|
|
2232
2340
|
};
|
|
@@ -2839,6 +2947,75 @@ function createLoadOptions(accessToken) {
|
|
|
2839
2947
|
};
|
|
2840
2948
|
}
|
|
2841
2949
|
|
|
2950
|
+
// dist/api/basemap.js
|
|
2951
|
+
var CUSTOM_STYLE_ID_PREFIX = "custom:";
|
|
2952
|
+
var DEFAULT_CARTO_STYLE = "positron";
|
|
2953
|
+
function mapLibreViewpros(config) {
|
|
2954
|
+
const { longitude, latitude, ...rest } = config.mapState;
|
|
2955
|
+
return {
|
|
2956
|
+
center: [longitude, latitude],
|
|
2957
|
+
...rest
|
|
2958
|
+
};
|
|
2959
|
+
}
|
|
2960
|
+
async function fetchBasemapProps({ config, errorContext, applyLayerFilters = true }) {
|
|
2961
|
+
var _a;
|
|
2962
|
+
const { mapStyle } = config;
|
|
2963
|
+
const styleType = mapStyle.styleType || DEFAULT_CARTO_STYLE;
|
|
2964
|
+
if (styleType.startsWith(CUSTOM_STYLE_ID_PREFIX)) {
|
|
2965
|
+
const currentCustomStyle = (_a = config.customBaseMaps) == null ? void 0 : _a.customStyle;
|
|
2966
|
+
if (currentCustomStyle) {
|
|
2967
|
+
return {
|
|
2968
|
+
type: "maplibre",
|
|
2969
|
+
props: {
|
|
2970
|
+
style: currentCustomStyle.style || currentCustomStyle.url,
|
|
2971
|
+
...mapLibreViewpros(config)
|
|
2972
|
+
},
|
|
2973
|
+
attribution: currentCustomStyle.customAttribution
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
if (CARTO_MAP_STYLES.includes(styleType)) {
|
|
2978
|
+
const { visibleLayerGroups } = mapStyle;
|
|
2979
|
+
const styleUrl = getStyleUrl(styleType);
|
|
2980
|
+
let style = styleUrl;
|
|
2981
|
+
let rawStyle = styleUrl;
|
|
2982
|
+
if (applyLayerFilters && visibleLayerGroups && someLayerGroupsDisabled(visibleLayerGroups)) {
|
|
2983
|
+
rawStyle = await fetchStyle({ styleUrl, errorContext });
|
|
2984
|
+
style = applyLayerGroupFilters(rawStyle, visibleLayerGroups);
|
|
2985
|
+
}
|
|
2986
|
+
return {
|
|
2987
|
+
type: "maplibre",
|
|
2988
|
+
props: {
|
|
2989
|
+
style,
|
|
2990
|
+
...mapLibreViewpros(config)
|
|
2991
|
+
},
|
|
2992
|
+
visibleLayerGroups,
|
|
2993
|
+
rawStyle
|
|
2994
|
+
};
|
|
2995
|
+
}
|
|
2996
|
+
const googleBasemapDef = GOOGLE_BASEMAPS[styleType];
|
|
2997
|
+
if (googleBasemapDef) {
|
|
2998
|
+
const { mapState } = config;
|
|
2999
|
+
return {
|
|
3000
|
+
type: "google-maps",
|
|
3001
|
+
props: {
|
|
3002
|
+
...googleBasemapDef,
|
|
3003
|
+
center: { lat: mapState.latitude, lng: mapState.longitude },
|
|
3004
|
+
zoom: mapState.zoom + 1,
|
|
3005
|
+
tilt: mapState.pitch,
|
|
3006
|
+
heading: mapState.bearing
|
|
3007
|
+
}
|
|
3008
|
+
};
|
|
3009
|
+
}
|
|
3010
|
+
return {
|
|
3011
|
+
type: "maplibre",
|
|
3012
|
+
props: {
|
|
3013
|
+
style: getStyleUrl(DEFAULT_CARTO_STYLE),
|
|
3014
|
+
...mapLibreViewpros(config)
|
|
3015
|
+
}
|
|
3016
|
+
};
|
|
3017
|
+
}
|
|
3018
|
+
|
|
2842
3019
|
// dist/api/fetch-map.js
|
|
2843
3020
|
async function _fetchMapDataset(dataset, accessToken, apiBaseUrl, clientId, headers) {
|
|
2844
3021
|
const { aggregationExp, aggregationResLevel, connectionName, columns, format, geoColumn, source, type, queryParameters } = dataset;
|
|
@@ -2902,7 +3079,7 @@ async function _fetchTilestats(attribute, dataset, accessToken, apiBaseUrl) {
|
|
|
2902
3079
|
if (!("tilestats" in data)) {
|
|
2903
3080
|
throw new CartoAPIError(new Error(`Invalid dataset for tilestats: ${id4}`), errorContext);
|
|
2904
3081
|
}
|
|
2905
|
-
const
|
|
3082
|
+
const baseUrl = buildStatsUrl({ attribute, apiBaseUrl, ...dataset });
|
|
2906
3083
|
const client = new URLSearchParams(data.tiles[0]).get("client");
|
|
2907
3084
|
const headers = { Authorization: `Bearer ${accessToken}` };
|
|
2908
3085
|
const parameters = {};
|
|
@@ -2916,7 +3093,7 @@ async function _fetchTilestats(attribute, dataset, accessToken, apiBaseUrl) {
|
|
|
2916
3093
|
}
|
|
2917
3094
|
}
|
|
2918
3095
|
const stats = await requestWithParameters({
|
|
2919
|
-
baseUrl
|
|
3096
|
+
baseUrl,
|
|
2920
3097
|
headers,
|
|
2921
3098
|
parameters,
|
|
2922
3099
|
errorContext
|
|
@@ -2962,9 +3139,9 @@ async function fetchMap({ apiBaseUrl = DEFAULT_API_BASE_URL, cartoMapId, clientI
|
|
|
2962
3139
|
assert(typeof onNewData === "function", "`onNewData` must be a function");
|
|
2963
3140
|
assert(typeof autoRefresh === "number" && autoRefresh > 0, "`autoRefresh` must be a positive number");
|
|
2964
3141
|
}
|
|
2965
|
-
const
|
|
3142
|
+
const baseUrl = buildPublicMapUrl({ apiBaseUrl, cartoMapId });
|
|
2966
3143
|
const errorContext = { requestType: "Public map", mapId: cartoMapId };
|
|
2967
|
-
const map = await requestWithParameters({ baseUrl
|
|
3144
|
+
const map = await requestWithParameters({ baseUrl, headers, errorContext });
|
|
2968
3145
|
let stopAutoRefresh;
|
|
2969
3146
|
if (autoRefresh) {
|
|
2970
3147
|
const intervalId = setInterval(async () => {
|
|
@@ -2991,9 +3168,12 @@ async function fetchMap({ apiBaseUrl = DEFAULT_API_BASE_URL, cartoMapId, clientI
|
|
|
2991
3168
|
}
|
|
2992
3169
|
}
|
|
2993
3170
|
});
|
|
2994
|
-
|
|
3171
|
+
const [basemap] = await Promise.all([
|
|
3172
|
+
fetchBasemapProps({ config: map.keplerMapConfig.config, errorContext }),
|
|
3173
|
+
fillInMapDatasets(map, clientId, apiBaseUrl, headers)
|
|
3174
|
+
]);
|
|
2995
3175
|
await fillInTileStats(map, apiBaseUrl);
|
|
2996
|
-
const out = { ...parseMap(map), ...{ stopAutoRefresh } };
|
|
3176
|
+
const out = { ...parseMap(map), basemap, ...{ stopAutoRefresh } };
|
|
2997
3177
|
const textLayers = out.layers.filter((layer) => {
|
|
2998
3178
|
const pointType = layer.props.pointType || "";
|
|
2999
3179
|
return pointType.includes("text");
|
|
@@ -3007,22 +3187,23 @@ async function fetchMap({ apiBaseUrl = DEFAULT_API_BASE_URL, cartoMapId, clientI
|
|
|
3007
3187
|
|
|
3008
3188
|
// dist/api/query.js
|
|
3009
3189
|
var query = async function(options) {
|
|
3010
|
-
const { apiBaseUrl = SOURCE_DEFAULTS.apiBaseUrl, connectionName, sqlQuery, queryParameters } = options;
|
|
3190
|
+
const { apiBaseUrl = SOURCE_DEFAULTS.apiBaseUrl, clientId = SOURCE_DEFAULTS.clientId, connectionName, sqlQuery, queryParameters } = options;
|
|
3011
3191
|
const urlParameters = { q: sqlQuery };
|
|
3012
3192
|
if (queryParameters) {
|
|
3013
3193
|
urlParameters.queryParameters = JSON.stringify(queryParameters);
|
|
3014
3194
|
}
|
|
3015
|
-
const
|
|
3195
|
+
const baseUrl = buildQueryUrl({ apiBaseUrl, connectionName });
|
|
3016
3196
|
const headers = { Authorization: `Bearer ${options.accessToken}`, ...options.headers };
|
|
3197
|
+
const parameters = { client: clientId, ...urlParameters };
|
|
3017
3198
|
const errorContext = {
|
|
3018
3199
|
requestType: "SQL",
|
|
3019
3200
|
connection: options.connectionName,
|
|
3020
3201
|
type: "query",
|
|
3021
|
-
source: JSON.stringify(
|
|
3202
|
+
source: JSON.stringify(parameters, void 0, 2)
|
|
3022
3203
|
};
|
|
3023
3204
|
return await requestWithParameters({
|
|
3024
|
-
baseUrl
|
|
3025
|
-
parameters
|
|
3205
|
+
baseUrl,
|
|
3206
|
+
parameters,
|
|
3026
3207
|
headers,
|
|
3027
3208
|
errorContext
|
|
3028
3209
|
});
|