@deck.gl/carto 9.1.0-beta.1 → 9.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/basemap.js +1 -0
- package/dist/api/basemap.js.map +1 -0
- package/dist/api/fetch-map.d.ts.map +1 -1
- package/dist/api/fetch-map.js +30 -23
- package/dist/api/fetch-map.js.map +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/layer-map.js +2 -1
- package/dist/api/layer-map.js.map +1 -0
- package/dist/api/parse-map.js +1 -0
- package/dist/api/parse-map.js.map +1 -0
- package/dist/api/types.js +1 -0
- package/dist/api/types.js.map +1 -0
- package/dist/basemap.js +1 -0
- package/dist/basemap.js.map +1 -0
- package/dist/cartoRasterTile-worker.js +4492 -6
- package/dist/cartoSpatialTile-worker.js +4484 -3
- package/dist/cartoVectorTile-worker.js +4484 -3
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -0
- package/dist/dist.dev.js +5321 -529
- package/dist/index.cjs +126 -60
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +18 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -0
- package/dist/layers/cluster-tile-layer.js +1 -0
- package/dist/layers/cluster-tile-layer.js.map +1 -0
- package/dist/layers/cluster-utils.js +1 -0
- package/dist/layers/cluster-utils.js.map +1 -0
- package/dist/layers/h3-tile-layer.js +1 -0
- package/dist/layers/h3-tile-layer.js.map +1 -0
- package/dist/layers/h3-tileset-2d.js +1 -0
- package/dist/layers/h3-tileset-2d.js.map +1 -0
- package/dist/layers/heatmap-tile-layer.js +1 -0
- package/dist/layers/heatmap-tile-layer.js.map +1 -0
- package/dist/layers/heatmap.js +1 -0
- package/dist/layers/heatmap.js.map +1 -0
- package/dist/layers/point-label-layer.js +1 -0
- package/dist/layers/point-label-layer.js.map +1 -0
- package/dist/layers/post-process-utils.d.ts +14 -9
- package/dist/layers/post-process-utils.d.ts.map +1 -1
- package/dist/layers/post-process-utils.js +25 -0
- package/dist/layers/post-process-utils.js.map +1 -0
- package/dist/layers/quadbin-layer.js +1 -0
- package/dist/layers/quadbin-layer.js.map +1 -0
- package/dist/layers/quadbin-tile-layer.js +1 -0
- package/dist/layers/quadbin-tile-layer.js.map +1 -0
- package/dist/layers/quadbin-tileset-2d.js +1 -0
- package/dist/layers/quadbin-tileset-2d.js.map +1 -0
- package/dist/layers/quadbin-utils.js +1 -0
- package/dist/layers/quadbin-utils.js.map +1 -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 +8 -7
- package/dist/layers/raster-layer-vertex.glsl.js.map +1 -0
- package/dist/layers/raster-layer.d.ts.map +1 -1
- package/dist/layers/raster-layer.js +15 -2
- package/dist/layers/raster-layer.js.map +1 -0
- package/dist/layers/raster-tile-layer.d.ts.map +1 -1
- package/dist/layers/raster-tile-layer.js +18 -3
- package/dist/layers/raster-tile-layer.js.map +1 -0
- package/dist/layers/schema/carto-properties-tile-loader.js +2 -1
- package/dist/layers/schema/carto-properties-tile-loader.js.map +1 -0
- package/dist/layers/schema/carto-properties-tile.js +1 -0
- package/dist/layers/schema/carto-properties-tile.js.map +1 -0
- package/dist/layers/schema/carto-raster-tile-loader.d.ts.map +1 -1
- package/dist/layers/schema/carto-raster-tile-loader.js +9 -3
- package/dist/layers/schema/carto-raster-tile-loader.js.map +1 -0
- package/dist/layers/schema/carto-raster-tile.d.ts +1 -0
- package/dist/layers/schema/carto-raster-tile.d.ts.map +1 -1
- package/dist/layers/schema/carto-raster-tile.js +3 -1
- package/dist/layers/schema/carto-raster-tile.js.map +1 -0
- package/dist/layers/schema/carto-spatial-tile-loader.js +2 -1
- package/dist/layers/schema/carto-spatial-tile-loader.js.map +1 -0
- package/dist/layers/schema/carto-spatial-tile.js +1 -0
- package/dist/layers/schema/carto-spatial-tile.js.map +1 -0
- package/dist/layers/schema/carto-tile.js +1 -0
- package/dist/layers/schema/carto-tile.js.map +1 -0
- package/dist/layers/schema/carto-vector-tile-loader.js +2 -1
- package/dist/layers/schema/carto-vector-tile-loader.js.map +1 -0
- package/dist/layers/schema/fast-pbf.d.ts +5 -1
- package/dist/layers/schema/fast-pbf.d.ts.map +1 -1
- package/dist/layers/schema/fast-pbf.js +12 -2
- package/dist/layers/schema/fast-pbf.js.map +1 -0
- package/dist/layers/schema/spatialjson-utils.js +1 -0
- package/dist/layers/schema/spatialjson-utils.js.map +1 -0
- package/dist/layers/schema/tile-loader-utils.js +1 -0
- package/dist/layers/schema/tile-loader-utils.js.map +1 -0
- package/dist/layers/spatial-index-tile-layer.js +1 -0
- package/dist/layers/spatial-index-tile-layer.js.map +1 -0
- package/dist/layers/utils.js +1 -0
- package/dist/layers/utils.js.map +1 -0
- package/dist/layers/vector-tile-layer.js +1 -0
- package/dist/layers/vector-tile-layer.js.map +1 -0
- package/dist/style/color-bins-style.js +1 -0
- package/dist/style/color-bins-style.js.map +1 -0
- package/dist/style/color-categories-style.js +1 -0
- package/dist/style/color-categories-style.js.map +1 -0
- package/dist/style/color-continuous-style.js +1 -0
- package/dist/style/color-continuous-style.js.map +1 -0
- package/dist/style/palette.js +1 -0
- package/dist/style/palette.js.map +1 -0
- package/dist/style/utils.js +1 -0
- package/dist/style/utils.js.map +1 -0
- package/dist/utils.js +1 -0
- package/dist/utils.js.map +1 -0
- package/dist/workers/cartoRasterTile.js +1 -0
- package/dist/workers/cartoRasterTile.js.map +1 -0
- package/dist/workers/cartoSpatialTile.js +1 -0
- package/dist/workers/cartoSpatialTile.js.map +1 -0
- package/dist/workers/cartoVectorTile.js +1 -0
- package/dist/workers/cartoVectorTile.js.map +1 -0
- package/dist.min.js +22 -19
- package/package.json +11 -11
- package/src/api/fetch-map.ts +42 -55
- package/src/api/layer-map.ts +1 -1
- package/src/index.ts +12 -9
- package/src/layers/post-process-utils.ts +30 -1
- package/src/layers/raster-layer-vertex.glsl.ts +10 -8
- package/src/layers/raster-layer.ts +15 -2
- package/src/layers/raster-tile-layer.ts +26 -4
- package/src/layers/schema/carto-properties-tile-loader.ts +1 -1
- package/src/layers/schema/carto-raster-tile-loader.ts +9 -2
- package/src/layers/schema/carto-raster-tile.ts +3 -1
- package/src/layers/schema/fast-pbf.ts +17 -2
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "CARTO official integration with Deck.gl. Build geospatial applications using CARTO and Deck.gl.",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "9.1.0-beta.
|
|
6
|
+
"version": "9.1.0-beta.3",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@carto/api-client": "^0.4.
|
|
45
|
+
"@carto/api-client": "^0.4.4",
|
|
46
46
|
"@loaders.gl/gis": "^4.2.0",
|
|
47
47
|
"@loaders.gl/loader-utils": "^4.2.0",
|
|
48
48
|
"@loaders.gl/mvt": "^4.2.0",
|
|
49
49
|
"@loaders.gl/schema": "^4.2.0",
|
|
50
50
|
"@loaders.gl/tiles": "^4.2.0",
|
|
51
|
-
"@luma.gl/core": "^9.1.0-beta.
|
|
52
|
-
"@luma.gl/shadertools": "^9.1.0-beta.
|
|
51
|
+
"@luma.gl/core": "^9.1.0-beta.16",
|
|
52
|
+
"@luma.gl/shadertools": "^9.1.0-beta.16",
|
|
53
53
|
"@math.gl/web-mercator": "^4.1.0",
|
|
54
54
|
"@types/d3-array": "^3.0.2",
|
|
55
55
|
"@types/d3-color": "^1.4.2",
|
|
@@ -66,13 +66,13 @@
|
|
|
66
66
|
"quadbin": "^0.2.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@deck.gl/aggregation-layers": "9.
|
|
70
|
-
"@deck.gl/core": "9.
|
|
71
|
-
"@deck.gl/extensions": "9.
|
|
72
|
-
"@deck.gl/geo-layers": "9.
|
|
73
|
-
"@deck.gl/layers": "9.
|
|
69
|
+
"@deck.gl/aggregation-layers": "^9.1.0-beta",
|
|
70
|
+
"@deck.gl/core": "^9.1.0-beta",
|
|
71
|
+
"@deck.gl/extensions": "^9.1.0-beta",
|
|
72
|
+
"@deck.gl/geo-layers": "^9.1.0-beta",
|
|
73
|
+
"@deck.gl/layers": "^9.1.0-beta",
|
|
74
74
|
"@loaders.gl/core": "^4.2.0",
|
|
75
|
-
"@luma.gl/core": "^9.1.0-beta
|
|
75
|
+
"@luma.gl/core": "^9.1.0-beta"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "6625885881202cb753b64c6f2b8ee6f323092075"
|
|
78
78
|
}
|
package/src/api/fetch-map.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
DEFAULT_API_BASE_URL,
|
|
7
7
|
APIErrorContext,
|
|
8
8
|
CartoAPIError,
|
|
9
9
|
GeojsonResult,
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
Format,
|
|
13
13
|
MapType,
|
|
14
14
|
QueryParameters,
|
|
15
|
+
SourceOptions,
|
|
15
16
|
buildPublicMapUrl,
|
|
16
17
|
buildStatsUrl,
|
|
17
18
|
h3QuerySource,
|
|
@@ -45,14 +46,7 @@ type Dataset = {
|
|
|
45
46
|
|
|
46
47
|
/* global clearInterval, setInterval, URL */
|
|
47
48
|
/* eslint-disable complexity, max-statements, max-params */
|
|
48
|
-
async function _fetchMapDataset(
|
|
49
|
-
dataset: Dataset,
|
|
50
|
-
accessToken: string,
|
|
51
|
-
apiBaseUrl: string,
|
|
52
|
-
clientId?: string,
|
|
53
|
-
headers?: Record<string, string>,
|
|
54
|
-
maxLengthURL = SOURCE_DEFAULTS.maxLengthURL
|
|
55
|
-
) {
|
|
49
|
+
async function _fetchMapDataset(dataset: Dataset, context: _FetchMapContext) {
|
|
56
50
|
const {
|
|
57
51
|
aggregationExp,
|
|
58
52
|
aggregationResLevel,
|
|
@@ -66,16 +60,12 @@ async function _fetchMapDataset(
|
|
|
66
60
|
} = dataset;
|
|
67
61
|
|
|
68
62
|
const cache: {value?: number} = {};
|
|
69
|
-
const globalOptions
|
|
70
|
-
|
|
71
|
-
apiBaseUrl,
|
|
63
|
+
const globalOptions = {
|
|
64
|
+
...context,
|
|
72
65
|
cache,
|
|
73
|
-
clientId,
|
|
74
66
|
connectionName,
|
|
75
|
-
format
|
|
76
|
-
|
|
77
|
-
maxLengthURL
|
|
78
|
-
};
|
|
67
|
+
format
|
|
68
|
+
} as SourceOptions;
|
|
79
69
|
|
|
80
70
|
if (type === 'tileset') {
|
|
81
71
|
// TODO do we want a generic tilesetSource?
|
|
@@ -120,14 +110,9 @@ async function _fetchMapDataset(
|
|
|
120
110
|
return cacheChanged;
|
|
121
111
|
}
|
|
122
112
|
|
|
123
|
-
async function _fetchTilestats(
|
|
124
|
-
attribute: string,
|
|
125
|
-
dataset: Dataset,
|
|
126
|
-
accessToken: string,
|
|
127
|
-
apiBaseUrl: string,
|
|
128
|
-
maxLengthURL = SOURCE_DEFAULTS.maxLengthURL
|
|
129
|
-
) {
|
|
113
|
+
async function _fetchTilestats(attribute: string, dataset: Dataset, context: _FetchMapContext) {
|
|
130
114
|
const {connectionName, data, id, source, type, queryParameters} = dataset;
|
|
115
|
+
const {apiBaseUrl} = context;
|
|
131
116
|
const errorContext: APIErrorContext = {
|
|
132
117
|
requestType: 'Tile stats',
|
|
133
118
|
connection: connectionName,
|
|
@@ -140,7 +125,7 @@ async function _fetchTilestats(
|
|
|
140
125
|
|
|
141
126
|
const baseUrl = buildStatsUrl({attribute, apiBaseUrl, ...dataset});
|
|
142
127
|
const client = new URLSearchParams(data.tiles[0]).get('client');
|
|
143
|
-
const headers = {Authorization: `Bearer ${accessToken}`};
|
|
128
|
+
const headers = {Authorization: `Bearer ${context.accessToken}`};
|
|
144
129
|
const parameters: Record<string, string> = {};
|
|
145
130
|
if (client) {
|
|
146
131
|
parameters.client = client;
|
|
@@ -156,7 +141,7 @@ async function _fetchTilestats(
|
|
|
156
141
|
headers,
|
|
157
142
|
parameters,
|
|
158
143
|
errorContext,
|
|
159
|
-
maxLengthURL
|
|
144
|
+
maxLengthURL: context.maxLengthURL
|
|
160
145
|
});
|
|
161
146
|
|
|
162
147
|
// Replace tilestats for attribute with value from API
|
|
@@ -166,23 +151,14 @@ async function _fetchTilestats(
|
|
|
166
151
|
return true;
|
|
167
152
|
}
|
|
168
153
|
|
|
169
|
-
async function fillInMapDatasets(
|
|
170
|
-
|
|
171
|
-
clientId: string,
|
|
172
|
-
apiBaseUrl: string,
|
|
173
|
-
headers?: Record<string, string>,
|
|
174
|
-
maxLengthURL = SOURCE_DEFAULTS.maxLengthURL
|
|
175
|
-
) {
|
|
176
|
-
const promises = datasets.map(dataset =>
|
|
177
|
-
_fetchMapDataset(dataset, token, apiBaseUrl, clientId, headers, maxLengthURL)
|
|
178
|
-
);
|
|
154
|
+
async function fillInMapDatasets({datasets}: {datasets: Dataset[]}, context: _FetchMapContext) {
|
|
155
|
+
const promises = datasets.map(dataset => _fetchMapDataset(dataset, context));
|
|
179
156
|
return await Promise.all(promises);
|
|
180
157
|
}
|
|
181
158
|
|
|
182
159
|
async function fillInTileStats(
|
|
183
|
-
{datasets, keplerMapConfig
|
|
184
|
-
|
|
185
|
-
maxLengthURL = SOURCE_DEFAULTS.maxLengthURL
|
|
160
|
+
{datasets, keplerMapConfig}: {datasets: Dataset[]; keplerMapConfig: any},
|
|
161
|
+
context: _FetchMapContext
|
|
186
162
|
) {
|
|
187
163
|
const attributes: {attribute: string; dataset: any}[] = [];
|
|
188
164
|
const {layers} = keplerMapConfig.config.visState;
|
|
@@ -211,7 +187,7 @@ async function fillInTileStats(
|
|
|
211
187
|
}
|
|
212
188
|
|
|
213
189
|
const promises = filteredAttributes.map(({attribute, dataset}) =>
|
|
214
|
-
_fetchTilestats(attribute, dataset,
|
|
190
|
+
_fetchTilestats(attribute, dataset, context)
|
|
215
191
|
);
|
|
216
192
|
return await Promise.all(promises);
|
|
217
193
|
}
|
|
@@ -260,6 +236,14 @@ export type FetchMapOptions = {
|
|
|
260
236
|
maxLengthURL?: number;
|
|
261
237
|
};
|
|
262
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Context reused while fetching and updating a map with fetchMap().
|
|
241
|
+
*/
|
|
242
|
+
type _FetchMapContext = {apiBaseUrl: string} & Pick<
|
|
243
|
+
FetchMapOptions,
|
|
244
|
+
'accessToken' | 'clientId' | 'headers' | 'maxLengthURL'
|
|
245
|
+
>;
|
|
246
|
+
|
|
263
247
|
export type FetchMapResult = ParseMapResult & {
|
|
264
248
|
/**
|
|
265
249
|
* Basemap properties.
|
|
@@ -271,16 +255,15 @@ export type FetchMapResult = ParseMapResult & {
|
|
|
271
255
|
/* eslint-disable max-statements */
|
|
272
256
|
export async function fetchMap({
|
|
273
257
|
accessToken,
|
|
274
|
-
apiBaseUrl =
|
|
258
|
+
apiBaseUrl = DEFAULT_API_BASE_URL,
|
|
275
259
|
cartoMapId,
|
|
276
|
-
clientId
|
|
277
|
-
headers
|
|
260
|
+
clientId,
|
|
261
|
+
headers,
|
|
278
262
|
autoRefresh,
|
|
279
263
|
onNewData,
|
|
280
|
-
maxLengthURL
|
|
264
|
+
maxLengthURL
|
|
281
265
|
}: FetchMapOptions): Promise<FetchMapResult> {
|
|
282
266
|
assert(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})');
|
|
283
|
-
assert(apiBaseUrl, 'Must define apiBaseUrl');
|
|
284
267
|
|
|
285
268
|
if (accessToken) {
|
|
286
269
|
headers = {Authorization: `Bearer ${accessToken}`, ...headers};
|
|
@@ -298,6 +281,13 @@ export async function fetchMap({
|
|
|
298
281
|
const baseUrl = buildPublicMapUrl({apiBaseUrl, cartoMapId});
|
|
299
282
|
const errorContext: APIErrorContext = {requestType: 'Public map', mapId: cartoMapId};
|
|
300
283
|
const map = await requestWithParameters({baseUrl, headers, errorContext, maxLengthURL});
|
|
284
|
+
const context: _FetchMapContext = {
|
|
285
|
+
accessToken: map.token || accessToken,
|
|
286
|
+
apiBaseUrl,
|
|
287
|
+
clientId,
|
|
288
|
+
headers,
|
|
289
|
+
maxLengthURL
|
|
290
|
+
};
|
|
301
291
|
|
|
302
292
|
// Periodically check if the data has changed. Note that this
|
|
303
293
|
// will not update when a map is published.
|
|
@@ -305,16 +295,13 @@ export async function fetchMap({
|
|
|
305
295
|
if (autoRefresh) {
|
|
306
296
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
307
297
|
const intervalId = setInterval(async () => {
|
|
308
|
-
const changed = await fillInMapDatasets(
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
apiBaseUrl,
|
|
312
|
-
{
|
|
298
|
+
const changed = await fillInMapDatasets(map, {
|
|
299
|
+
...context,
|
|
300
|
+
headers: {
|
|
313
301
|
...headers,
|
|
314
302
|
'If-Modified-Since': new Date().toUTCString()
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
318
305
|
if (onNewData && changed.some(v => v === true)) {
|
|
319
306
|
onNewData(parseMap(map));
|
|
320
307
|
}
|
|
@@ -343,11 +330,11 @@ export async function fetchMap({
|
|
|
343
330
|
fetchBasemapProps({config: map.keplerMapConfig.config, errorContext}),
|
|
344
331
|
|
|
345
332
|
// Mutates map.datasets so that dataset.data contains data
|
|
346
|
-
fillInMapDatasets(map,
|
|
333
|
+
fillInMapDatasets(map, context)
|
|
347
334
|
]);
|
|
348
335
|
|
|
349
336
|
// Mutates attributes in visualChannels to contain tile stats
|
|
350
|
-
await fillInTileStats(map,
|
|
337
|
+
await fillInTileStats(map, context);
|
|
351
338
|
|
|
352
339
|
const out = {...parseMap(map), basemap, ...{stopAutoRefresh}};
|
|
353
340
|
|
package/src/api/layer-map.ts
CHANGED
|
@@ -197,7 +197,7 @@ export function getLayer(
|
|
|
197
197
|
Layer: GeoJsonLayer,
|
|
198
198
|
propMap: {
|
|
199
199
|
columns: {
|
|
200
|
-
altitude: x => ({parameters: {
|
|
200
|
+
altitude: x => ({parameters: {depthWriteEnabled: Boolean(x)}})
|
|
201
201
|
},
|
|
202
202
|
visConfig: {outline: 'stroked'}
|
|
203
203
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import {default as ClusterTileLayer} from './layers/cluster-tile-layer';
|
|
7
7
|
import {default as H3TileLayer} from './layers/h3-tile-layer';
|
|
8
8
|
import {default as HeatmapTileLayer} from './layers/heatmap-tile-layer';
|
|
9
|
-
import {default as
|
|
9
|
+
import {default as PointLabelLayer} from './layers/point-label-layer';
|
|
10
10
|
import {default as QuadbinTileLayer} from './layers/quadbin-tile-layer';
|
|
11
11
|
import {default as RasterTileLayer} from './layers/raster-tile-layer';
|
|
12
12
|
import {default as VectorTileLayer} from './layers/vector-tile-layer';
|
|
@@ -16,7 +16,7 @@ const CARTO_LAYERS = {
|
|
|
16
16
|
ClusterTileLayer,
|
|
17
17
|
H3TileLayer,
|
|
18
18
|
HeatmapTileLayer,
|
|
19
|
-
|
|
19
|
+
PointLabelLayer,
|
|
20
20
|
QuadbinTileLayer,
|
|
21
21
|
RasterTileLayer,
|
|
22
22
|
VectorTileLayer
|
|
@@ -26,7 +26,7 @@ export {
|
|
|
26
26
|
ClusterTileLayer,
|
|
27
27
|
H3TileLayer,
|
|
28
28
|
HeatmapTileLayer,
|
|
29
|
-
|
|
29
|
+
PointLabelLayer,
|
|
30
30
|
QuadbinTileLayer,
|
|
31
31
|
RasterTileLayer,
|
|
32
32
|
VectorTileLayer
|
|
@@ -71,6 +71,8 @@ export type {
|
|
|
71
71
|
GoogleBasemap as _GoogleBasemap
|
|
72
72
|
} from './api/index';
|
|
73
73
|
|
|
74
|
+
// TODO(v10): Consider removing re-exports from '@carto/api-client' below.
|
|
75
|
+
|
|
74
76
|
import {
|
|
75
77
|
boundaryQuerySource,
|
|
76
78
|
boundaryTableSource,
|
|
@@ -83,11 +85,10 @@ import {
|
|
|
83
85
|
quadbinTilesetSource,
|
|
84
86
|
vectorQuerySource,
|
|
85
87
|
vectorTableSource,
|
|
86
|
-
vectorTilesetSource
|
|
87
|
-
SOURCE_DEFAULTS
|
|
88
|
+
vectorTilesetSource
|
|
88
89
|
} from '@carto/api-client';
|
|
89
90
|
|
|
90
|
-
const CARTO_SOURCES = {
|
|
91
|
+
export const CARTO_SOURCES = {
|
|
91
92
|
boundaryQuerySource,
|
|
92
93
|
boundaryTableSource,
|
|
93
94
|
h3QuerySource,
|
|
@@ -115,9 +116,10 @@ export {
|
|
|
115
116
|
vectorQuerySource,
|
|
116
117
|
vectorTableSource,
|
|
117
118
|
vectorTilesetSource,
|
|
118
|
-
|
|
119
|
+
query,
|
|
120
|
+
CartoAPIError,
|
|
119
121
|
SOURCE_DEFAULTS
|
|
120
|
-
};
|
|
122
|
+
} from '@carto/api-client';
|
|
121
123
|
|
|
122
124
|
export type {
|
|
123
125
|
GeojsonResult,
|
|
@@ -138,5 +140,6 @@ export type {
|
|
|
138
140
|
QuadbinTilesetSourceOptions,
|
|
139
141
|
VectorQuerySourceOptions,
|
|
140
142
|
VectorTableSourceOptions,
|
|
141
|
-
VectorTilesetSourceOptions
|
|
143
|
+
VectorTilesetSourceOptions,
|
|
144
|
+
QueryParameters
|
|
142
145
|
} from '@carto/api-client';
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {Framebuffer, TextureProps} from '@luma.gl/core';
|
|
6
|
+
import type {ShaderPass} from '@luma.gl/shadertools';
|
|
6
7
|
import {
|
|
8
|
+
_ConstructorOf,
|
|
7
9
|
CompositeLayer,
|
|
8
10
|
Layer,
|
|
9
11
|
LayerContext,
|
|
@@ -63,8 +65,10 @@ class DrawCallbackLayer extends Layer {
|
|
|
63
65
|
* Resulting layer must be used as a sublayer of a layer created
|
|
64
66
|
* with `PostProcessModifier`
|
|
65
67
|
*/
|
|
66
|
-
export function RTTModifier(BaseLayer) {
|
|
68
|
+
export function RTTModifier<T extends _ConstructorOf<Layer>>(BaseLayer: T): T {
|
|
69
|
+
// @ts-expect-error initializeState is abstract
|
|
67
70
|
return class RTTLayer extends BaseLayer {
|
|
71
|
+
// @ts-expect-error typescript doesn't see static property
|
|
68
72
|
static layerName = `RTT-${BaseLayer.layerName}`;
|
|
69
73
|
|
|
70
74
|
draw(this: RTTLayer, opts: any) {
|
|
@@ -181,5 +185,30 @@ export function PostProcessModifier<T extends Constructor<DrawableCompositeLayer
|
|
|
181
185
|
|
|
182
186
|
this.internalState.renderInProgress = false;
|
|
183
187
|
}
|
|
188
|
+
|
|
189
|
+
_finalize(): void {
|
|
190
|
+
this.internalState.renderBuffers.forEach((fbo: Framebuffer) => {
|
|
191
|
+
fbo.destroy();
|
|
192
|
+
});
|
|
193
|
+
this.internalState.renderBuffers = null;
|
|
194
|
+
this.internalState.postProcess.cleanup();
|
|
195
|
+
}
|
|
184
196
|
};
|
|
185
197
|
}
|
|
198
|
+
|
|
199
|
+
const fs = /* glsl */ `\
|
|
200
|
+
vec4 copy_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
201
|
+
return color;
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Copy
|
|
207
|
+
* Simple module that just copies input color to output
|
|
208
|
+
*/
|
|
209
|
+
export const copy = {
|
|
210
|
+
name: 'copy',
|
|
211
|
+
fs,
|
|
212
|
+
getUniforms: () => ({}),
|
|
213
|
+
passes: [{filter: true}]
|
|
214
|
+
} as const satisfies ShaderPass<{}>;
|
|
@@ -23,12 +23,14 @@ out vec4 position_commonspace;
|
|
|
23
23
|
|
|
24
24
|
void main(void) {
|
|
25
25
|
// Rather than positioning using attribute, layout pixel grid using gl_InstanceID
|
|
26
|
-
vec2
|
|
26
|
+
vec2 tileOrigin = column.offset.xy;
|
|
27
27
|
float scale = column.widthScale; // Re-use widthScale prop to pass cell scale
|
|
28
28
|
|
|
29
29
|
int yIndex = - (gl_InstanceID / BLOCK_WIDTH);
|
|
30
30
|
int xIndex = gl_InstanceID + (yIndex * BLOCK_WIDTH);
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
// Avoid precision issues by applying 0.5 offset here, rather than when laying out vertices
|
|
33
|
+
vec2 cellCenter = scale * vec2(float(xIndex) + 0.5, float(yIndex) - 0.5);
|
|
32
34
|
|
|
33
35
|
vec4 color = column.isStroke ? instanceLineColors : instanceFillColors;
|
|
34
36
|
|
|
@@ -39,7 +41,7 @@ void main(void) {
|
|
|
39
41
|
// Get position directly from quadbin, rather than projecting
|
|
40
42
|
// Important to set geometry.position before using project_ methods below
|
|
41
43
|
// as geometry.worldPosition is not set (we don't know our lat/long)
|
|
42
|
-
geometry.position = vec4(
|
|
44
|
+
geometry.position = vec4(tileOrigin + cellCenter, 0.0, 1.0);
|
|
43
45
|
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
|
|
44
46
|
geometry.position.xyz -= project.commonOrigin;
|
|
45
47
|
}
|
|
@@ -63,12 +65,12 @@ void main(void) {
|
|
|
63
65
|
|
|
64
66
|
geometry.pickingColor = instancePickingColors;
|
|
65
67
|
|
|
66
|
-
//
|
|
67
|
-
vec2
|
|
68
|
-
vec3
|
|
69
|
-
DECKGL_FILTER_SIZE(
|
|
68
|
+
// Cell coordinates centered on origin
|
|
69
|
+
vec2 base = positions.xy * scale * strokeOffsetRatio * column.coverage * shouldRender;
|
|
70
|
+
vec3 cell = vec3(base, project_size(elevation));
|
|
71
|
+
DECKGL_FILTER_SIZE(cell, geometry);
|
|
70
72
|
|
|
71
|
-
geometry.position.xyz +=
|
|
73
|
+
geometry.position.xyz += cell;
|
|
72
74
|
gl_Position = project_common_position_to_clipspace(geometry.position);
|
|
73
75
|
|
|
74
76
|
geometry.normal = project_normal(normals);
|
|
@@ -16,6 +16,7 @@ import {quadbinToOffset} from './quadbin-utils';
|
|
|
16
16
|
import {Raster} from './schema/carto-raster-tile-loader';
|
|
17
17
|
import vs from './raster-layer-vertex.glsl';
|
|
18
18
|
import {createBinaryProxy} from '../utils';
|
|
19
|
+
import {RTTModifier} from './post-process-utils';
|
|
19
20
|
|
|
20
21
|
const defaultProps: DefaultProps<RasterLayerProps> = {
|
|
21
22
|
...ColumnLayer.defaultProps,
|
|
@@ -30,7 +31,8 @@ const defaultProps: DefaultProps<RasterLayerProps> = {
|
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
// Modified ColumnLayer with custom vertex shader
|
|
33
|
-
|
|
34
|
+
// Use RTT to avoid inter-tile seams
|
|
35
|
+
class RasterColumnLayer extends RTTModifier(ColumnLayer) {
|
|
34
36
|
static layerName = 'RasterColumnLayer';
|
|
35
37
|
|
|
36
38
|
getShaders() {
|
|
@@ -143,7 +145,18 @@ export default class RasterLayer<DataT = any, ExtraProps = {}> extends Composite
|
|
|
143
145
|
offset,
|
|
144
146
|
lineWidthScale, // Re-use widthScale prop to pass cell scale,
|
|
145
147
|
highlightedObjectIndex,
|
|
146
|
-
highlightColor
|
|
148
|
+
highlightColor,
|
|
149
|
+
|
|
150
|
+
// RTT requires blending otherwise opacity < 1 blends with black
|
|
151
|
+
// render target
|
|
152
|
+
parameters: {
|
|
153
|
+
blendColorSrcFactor: 'one',
|
|
154
|
+
blendAlphaSrcFactor: 'one',
|
|
155
|
+
blendColorDstFactor: 'zero',
|
|
156
|
+
blendAlphaDstFactor: 'zero',
|
|
157
|
+
blendColorOperation: 'add',
|
|
158
|
+
blendAlphaOperation: 'add'
|
|
159
|
+
}
|
|
147
160
|
}
|
|
148
161
|
);
|
|
149
162
|
}
|
|
@@ -2,13 +2,21 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
CompositeLayer,
|
|
7
|
+
CompositeLayerProps,
|
|
8
|
+
DefaultProps,
|
|
9
|
+
FilterContext,
|
|
10
|
+
Layer,
|
|
11
|
+
LayersList
|
|
12
|
+
} from '@deck.gl/core';
|
|
6
13
|
import RasterLayer, {RasterLayerProps} from './raster-layer';
|
|
7
14
|
import QuadbinTileset2D from './quadbin-tileset-2d';
|
|
8
15
|
import type {TilejsonResult} from '@carto/api-client';
|
|
9
16
|
import {injectAccessToken, TilejsonPropType} from './utils';
|
|
10
17
|
import {DEFAULT_TILE_SIZE} from '../constants';
|
|
11
18
|
import {TileLayer, TileLayerProps} from '@deck.gl/geo-layers';
|
|
19
|
+
import {copy, PostProcessModifier} from './post-process-utils';
|
|
12
20
|
|
|
13
21
|
export const renderSubLayers = props => {
|
|
14
22
|
const tileIndex = props.tile?.index?.q;
|
|
@@ -18,6 +26,7 @@ export const renderSubLayers = props => {
|
|
|
18
26
|
|
|
19
27
|
const defaultProps: DefaultProps<RasterTileLayerProps> = {
|
|
20
28
|
data: TilejsonPropType,
|
|
29
|
+
refinementStrategy: 'no-overlap',
|
|
21
30
|
tileSize: DEFAULT_TILE_SIZE
|
|
22
31
|
};
|
|
23
32
|
|
|
@@ -31,6 +40,16 @@ type _RasterTileLayerProps<DataT> = Omit<RasterLayerProps<DataT>, 'data'> &
|
|
|
31
40
|
data: null | TilejsonResult | Promise<TilejsonResult>;
|
|
32
41
|
};
|
|
33
42
|
|
|
43
|
+
class PostProcessTileLayer extends PostProcessModifier(TileLayer, copy) {
|
|
44
|
+
filterSubLayer(context: FilterContext) {
|
|
45
|
+
// Handle DrawCallbackLayer
|
|
46
|
+
const {tile} = (context.layer as Layer<{tile: any}>).props;
|
|
47
|
+
if (!tile) return true;
|
|
48
|
+
|
|
49
|
+
return super.filterSubLayer(context);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
34
53
|
export default class RasterTileLayer<
|
|
35
54
|
DataT = any,
|
|
36
55
|
ExtraProps extends {} = {}
|
|
@@ -49,8 +68,8 @@ export default class RasterTileLayer<
|
|
|
49
68
|
const tileJSON = this.props.data as TilejsonResult;
|
|
50
69
|
if (!tileJSON) return null;
|
|
51
70
|
|
|
52
|
-
const {tiles: data, minzoom: minZoom, maxzoom: maxZoom} = tileJSON;
|
|
53
|
-
const SubLayerClass = this.getSubLayerClass('tile',
|
|
71
|
+
const {tiles: data, minzoom: minZoom, maxzoom: maxZoom, raster_metadata: metadata} = tileJSON;
|
|
72
|
+
const SubLayerClass = this.getSubLayerClass('tile', PostProcessTileLayer);
|
|
54
73
|
return new SubLayerClass(this.props, {
|
|
55
74
|
id: `raster-tile-layer-${this.props.id}`,
|
|
56
75
|
data,
|
|
@@ -59,7 +78,10 @@ export default class RasterTileLayer<
|
|
|
59
78
|
renderSubLayers,
|
|
60
79
|
minZoom,
|
|
61
80
|
maxZoom,
|
|
62
|
-
loadOptions:
|
|
81
|
+
loadOptions: {
|
|
82
|
+
cartoRasterTile: {metadata},
|
|
83
|
+
...this.getLoadOptions()
|
|
84
|
+
}
|
|
63
85
|
});
|
|
64
86
|
}
|
|
65
87
|
}
|
|
@@ -15,7 +15,7 @@ const CartoPropertiesTileLoader: LoaderWithParser = {
|
|
|
15
15
|
extensions: ['pbf'],
|
|
16
16
|
mimeTypes: ['application/vnd.carto-properties-tile'],
|
|
17
17
|
category: 'geometry',
|
|
18
|
-
worker:
|
|
18
|
+
worker: true,
|
|
19
19
|
parse: async (arrayBuffer, options) => parseCartoPropertiesTile(arrayBuffer, options),
|
|
20
20
|
parseSync: parseCartoPropertiesTile,
|
|
21
21
|
options: {}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {RasterMetadata} from '@carto/api-client';
|
|
6
7
|
|
|
7
8
|
import {TileReader} from './carto-raster-tile';
|
|
8
9
|
import {parsePbf} from './tile-loader-utils';
|
|
@@ -14,12 +15,14 @@ const id = 'cartoRasterTile';
|
|
|
14
15
|
|
|
15
16
|
type CartoRasterTileLoaderOptions = LoaderOptions & {
|
|
16
17
|
cartoRasterTile?: {
|
|
18
|
+
metadata: RasterMetadata | null;
|
|
17
19
|
workerUrl: string;
|
|
18
20
|
};
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
const DEFAULT_OPTIONS: CartoRasterTileLoaderOptions = {
|
|
22
24
|
cartoRasterTile: {
|
|
25
|
+
metadata: null,
|
|
23
26
|
workerUrl: getWorkerUrl(id, VERSION)
|
|
24
27
|
}
|
|
25
28
|
};
|
|
@@ -52,8 +55,12 @@ function parseCartoRasterTile(
|
|
|
52
55
|
arrayBuffer: ArrayBuffer,
|
|
53
56
|
options?: CartoRasterTileLoaderOptions
|
|
54
57
|
): Raster | null {
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
const metadata = options?.cartoRasterTile?.metadata;
|
|
59
|
+
if (!arrayBuffer || !metadata) return null;
|
|
60
|
+
// @ts-expect-error Upstream type needs to be updated
|
|
61
|
+
TileReader.compression = metadata.compression;
|
|
62
|
+
const out = parsePbf(arrayBuffer, TileReader);
|
|
63
|
+
const {bands, blockSize} = out;
|
|
57
64
|
|
|
58
65
|
const numericProps = {};
|
|
59
66
|
for (let i = 0; i < bands.length; i++) {
|
|
@@ -33,12 +33,14 @@ export class BandReader {
|
|
|
33
33
|
throw Error(`Invalid data type: ${obj.type}`);
|
|
34
34
|
}
|
|
35
35
|
obj.data = {};
|
|
36
|
-
|
|
36
|
+
const {compression} = TileReader;
|
|
37
|
+
readPackedTypedArray(TypedArray, pbf, obj.data, {compression});
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
export class TileReader {
|
|
43
|
+
public static compression: null | 'gzip';
|
|
42
44
|
static read(pbf, end) {
|
|
43
45
|
return pbf.readFields(TileReader._readField, {blockSize: 0, bands: []}, end);
|
|
44
46
|
}
|
|
@@ -2,10 +2,25 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
+
import {GZipCompression} from '@loaders.gl/compression';
|
|
6
|
+
|
|
7
|
+
type ReadPackedOptions = {
|
|
8
|
+
compression: null | 'gzip';
|
|
9
|
+
};
|
|
10
|
+
|
|
5
11
|
// Optimized (100X speed improvement) reading function for binary data
|
|
6
|
-
export function readPackedTypedArray(TypedArray, pbf, obj) {
|
|
12
|
+
export function readPackedTypedArray(TypedArray, pbf, obj, options?: ReadPackedOptions) {
|
|
7
13
|
const end = pbf.type === 2 ? pbf.readVarint() + pbf.pos : pbf.pos + 1;
|
|
8
|
-
|
|
14
|
+
const data = pbf.buf.buffer.slice(pbf.pos, end);
|
|
15
|
+
|
|
16
|
+
if (options?.compression === 'gzip') {
|
|
17
|
+
const compression = new GZipCompression();
|
|
18
|
+
const decompressedData = compression.decompressSync(data);
|
|
19
|
+
obj.value = new TypedArray(decompressedData);
|
|
20
|
+
} else {
|
|
21
|
+
obj.value = new TypedArray(data);
|
|
22
|
+
}
|
|
23
|
+
|
|
9
24
|
pbf.pos = end;
|
|
10
25
|
return obj.value;
|
|
11
26
|
}
|