@carto/api-client 0.5.1-alpha.0 → 0.5.1-alpha.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/build/api-client.cjs +12 -11
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.js +12 -11
- package/build/api-client.js.map +1 -1
- package/build/worker.js +12 -11
- package/build/worker.js.map +1 -1
- package/package.json +1 -1
- package/src/filters/tileFeaturesGeometries.ts +22 -17
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"homepage": "https://github.com/CartoDB/carto-api-client#readme",
|
|
9
9
|
"author": "Don McCurdy <donmccurdy@carto.com>",
|
|
10
10
|
"packageManager": "yarn@4.3.1",
|
|
11
|
-
"version": "0.5.1-alpha.
|
|
11
|
+
"version": "0.5.1-alpha.1",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
@@ -23,7 +23,9 @@ import {
|
|
|
23
23
|
BinaryAttribute,
|
|
24
24
|
BinaryFeature,
|
|
25
25
|
BinaryGeometryType,
|
|
26
|
+
BinaryLineFeature,
|
|
26
27
|
BinaryPointFeature,
|
|
28
|
+
BinaryPolygonFeature,
|
|
27
29
|
TypedArrayConstructor,
|
|
28
30
|
} from '@loaders.gl/schema';
|
|
29
31
|
|
|
@@ -89,8 +91,6 @@ export function tileFeaturesGeometries({
|
|
|
89
91
|
? transformToTileCoords(clippedGeometryToIntersect.geometry, bbox)
|
|
90
92
|
: clippedGeometryToIntersect.geometry;
|
|
91
93
|
|
|
92
|
-
createIndicesForPoints(tile.data.points!);
|
|
93
|
-
|
|
94
94
|
calculateFeatures({
|
|
95
95
|
map,
|
|
96
96
|
tileIsFullyVisible,
|
|
@@ -214,7 +214,7 @@ function addIntersectedFeaturesInTile({
|
|
|
214
214
|
uniqueIdProperty?: string;
|
|
215
215
|
options?: TileFeatureExtractOptions;
|
|
216
216
|
}) {
|
|
217
|
-
const indices = getIndices(data);
|
|
217
|
+
const indices = getIndices(data, type);
|
|
218
218
|
const storeGeometry = options?.storeGeometry || false;
|
|
219
219
|
|
|
220
220
|
for (let i = 0; i < indices.length - 1; i++) {
|
|
@@ -235,21 +235,24 @@ function addIntersectedFeaturesInTile({
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
// Despite TypeScript, 'data.type' is OPTIONAL. So 'type' must be passed in
|
|
239
|
+
// separately. Observed missing .type for Redshift tilesets, 2025-04-09.
|
|
240
|
+
function getIndices(data: BinaryFeature, type: BinaryGeometryType) {
|
|
239
241
|
let indices: BinaryAttribute;
|
|
240
|
-
switch (
|
|
241
|
-
case '
|
|
242
|
-
|
|
243
|
-
indices = data.pointIndices;
|
|
242
|
+
switch (type) {
|
|
243
|
+
case 'Polygon':
|
|
244
|
+
indices = (data as BinaryPolygonFeature).primitivePolygonIndices;
|
|
244
245
|
break;
|
|
245
246
|
case 'LineString':
|
|
246
|
-
indices = data.pathIndices;
|
|
247
|
+
indices = (data as BinaryLineFeature).pathIndices;
|
|
247
248
|
break;
|
|
248
|
-
case '
|
|
249
|
-
indices = data
|
|
249
|
+
case 'Point':
|
|
250
|
+
indices = createIndicesForPoints(data as BinaryPointFeature);
|
|
250
251
|
break;
|
|
251
252
|
default:
|
|
252
|
-
throw new Error(
|
|
253
|
+
throw new Error(
|
|
254
|
+
`Unsupported geometry type: ${type as unknown as string}`
|
|
255
|
+
);
|
|
253
256
|
}
|
|
254
257
|
return indices.value;
|
|
255
258
|
}
|
|
@@ -408,7 +411,7 @@ function addAllFeaturesInTile({
|
|
|
408
411
|
uniqueIdProperty?: string;
|
|
409
412
|
options?: TileFeatureExtractOptions;
|
|
410
413
|
}) {
|
|
411
|
-
const indices = getIndices(data);
|
|
414
|
+
const indices = getIndices(data, type);
|
|
412
415
|
const storeGeometry = options?.storeGeometry || false;
|
|
413
416
|
for (let i = 0; i < indices.length - 1; i++) {
|
|
414
417
|
const startIndex = indices[i];
|
|
@@ -427,7 +430,11 @@ function addAllFeaturesInTile({
|
|
|
427
430
|
}
|
|
428
431
|
}
|
|
429
432
|
|
|
430
|
-
|
|
433
|
+
/**
|
|
434
|
+
* BinaryPointFeature does not include indices, so we generate in-memory
|
|
435
|
+
* indices to allow processing points similarly to other topologies.
|
|
436
|
+
*/
|
|
437
|
+
function createIndicesForPoints(data: BinaryPointFeature): BinaryAttribute {
|
|
431
438
|
const featureIds = data.featureIds.value;
|
|
432
439
|
const lastFeatureId = featureIds[featureIds.length - 1];
|
|
433
440
|
const PointIndicesArray = featureIds.constructor as TypedArrayConstructor;
|
|
@@ -438,7 +445,5 @@ function createIndicesForPoints(data: BinaryPointFeature) {
|
|
|
438
445
|
};
|
|
439
446
|
pointIndices.value.set(featureIds);
|
|
440
447
|
pointIndices.value.set([lastFeatureId + 1], featureIds.length);
|
|
441
|
-
|
|
442
|
-
// @ts-expect-error Missing or changed types?
|
|
443
|
-
data.pointIndices = pointIndices;
|
|
448
|
+
return pointIndices;
|
|
444
449
|
}
|