@deck.gl/carto 9.1.9 → 9.1.11
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/fetch-map.d.ts.map +1 -1
- package/dist/api/fetch-map.js +1 -0
- package/dist/api/fetch-map.js.map +1 -1
- package/dist/api/parse-map.d.ts.map +1 -1
- package/dist/api/parse-map.js.map +1 -1
- package/dist/cartoPropertiesTile-worker.js +9 -1
- package/dist/cartoRasterTile-worker.js +9 -1
- package/dist/cartoSpatialTile-worker.js +9 -1
- package/dist/cartoVectorTile-worker.js +9 -1
- package/dist/dist.dev.js +469 -138
- package/dist/index.cjs +423 -139
- package/dist/index.cjs.map +4 -4
- package/dist/layers/cluster-tile-layer.d.ts.map +1 -1
- package/dist/layers/cluster-tile-layer.js +6 -5
- package/dist/layers/cluster-tile-layer.js.map +1 -1
- package/dist/layers/cluster-utils.d.ts.map +1 -1
- package/dist/layers/cluster-utils.js +3 -28
- package/dist/layers/cluster-utils.js.map +1 -1
- package/dist/layers/h3-tile-layer.d.ts.map +1 -1
- package/dist/layers/h3-tile-layer.js +5 -5
- package/dist/layers/h3-tile-layer.js.map +1 -1
- package/dist/layers/heatmap-tile-layer.d.ts.map +1 -1
- package/dist/layers/heatmap-tile-layer.js.map +1 -1
- package/dist/layers/label-utils.d.ts +7 -0
- package/dist/layers/label-utils.d.ts.map +1 -0
- package/dist/layers/label-utils.js +218 -0
- package/dist/layers/label-utils.js.map +1 -0
- package/dist/layers/point-label-layer.d.ts +6 -0
- package/dist/layers/point-label-layer.d.ts.map +1 -1
- package/dist/layers/point-label-layer.js +13 -1
- package/dist/layers/point-label-layer.js.map +1 -1
- package/dist/layers/quadbin-tile-layer.d.ts.map +1 -1
- package/dist/layers/quadbin-tile-layer.js +5 -5
- package/dist/layers/quadbin-tile-layer.js.map +1 -1
- package/dist/layers/raster-tile-layer.js +4 -4
- package/dist/layers/raster-tile-layer.js.map +1 -1
- package/dist/layers/schema/carto-properties-tile-loader.js +1 -1
- package/dist/layers/schema/carto-properties-tile-loader.js.map +1 -1
- package/dist/layers/schema/carto-raster-tile-loader.js +1 -1
- package/dist/layers/schema/carto-raster-tile-loader.js.map +1 -1
- package/dist/layers/schema/carto-spatial-tile-loader.js +1 -1
- package/dist/layers/schema/carto-spatial-tile-loader.js.map +1 -1
- package/dist/layers/schema/carto-tile.d.ts +3 -1
- package/dist/layers/schema/carto-tile.d.ts.map +1 -1
- package/dist/layers/schema/carto-tile.js.map +1 -1
- package/dist/layers/schema/carto-vector-tile-loader.js +1 -1
- package/dist/layers/schema/carto-vector-tile-loader.js.map +1 -1
- package/dist/layers/schema/spatialjson-utils.d.ts +4 -7
- package/dist/layers/schema/spatialjson-utils.d.ts.map +1 -1
- package/dist/layers/schema/spatialjson-utils.js.map +1 -1
- package/dist/layers/utils.d.ts +3 -2
- package/dist/layers/utils.d.ts.map +1 -1
- package/dist/layers/utils.js +28 -7
- package/dist/layers/utils.js.map +1 -1
- package/dist/layers/vector-tile-layer.d.ts +12 -4
- package/dist/layers/vector-tile-layer.d.ts.map +1 -1
- package/dist/layers/vector-tile-layer.js +76 -35
- package/dist/layers/vector-tile-layer.js.map +1 -1
- package/dist/utils.d.ts +6 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +53 -0
- package/dist/utils.js.map +1 -1
- package/dist.min.js +12 -12
- package/package.json +2 -2
- package/src/api/fetch-map.ts +2 -0
- package/src/api/parse-map.ts +2 -0
- package/src/layers/cluster-tile-layer.ts +7 -5
- package/src/layers/cluster-utils.ts +3 -29
- package/src/layers/h3-tile-layer.ts +6 -6
- package/src/layers/heatmap-tile-layer.ts +2 -0
- package/src/layers/label-utils.ts +304 -0
- package/src/layers/point-label-layer.ts +18 -1
- package/src/layers/quadbin-tile-layer.ts +6 -6
- package/src/layers/raster-tile-layer.ts +4 -4
- package/src/layers/schema/carto-tile.ts +3 -1
- package/src/layers/schema/spatialjson-utils.ts +4 -3
- package/src/layers/utils.ts +31 -7
- package/src/layers/vector-tile-layer.ts +100 -42
- package/src/utils.ts +79 -0
package/dist/dist.dev.js
CHANGED
|
@@ -11519,7 +11519,110 @@ var __exports__ = (() => {
|
|
|
11519
11519
|
}
|
|
11520
11520
|
|
|
11521
11521
|
// src/layers/cluster-utils.ts
|
|
11522
|
+
var import_core2 = __toESM(require_core2(), 1);
|
|
11523
|
+
|
|
11524
|
+
// src/utils.ts
|
|
11522
11525
|
var import_core = __toESM(require_core2(), 1);
|
|
11526
|
+
function assert2(condition, message) {
|
|
11527
|
+
import_core.log.assert(condition, message);
|
|
11528
|
+
}
|
|
11529
|
+
function createBinaryProxy(data, index2) {
|
|
11530
|
+
const { properties, numericProps } = data;
|
|
11531
|
+
return new Proxy(properties[index2] || {}, {
|
|
11532
|
+
get(target, property) {
|
|
11533
|
+
if (property in numericProps) {
|
|
11534
|
+
return numericProps[property].value[index2];
|
|
11535
|
+
}
|
|
11536
|
+
return target[property];
|
|
11537
|
+
},
|
|
11538
|
+
has(target, property) {
|
|
11539
|
+
return property in numericProps || property in target;
|
|
11540
|
+
},
|
|
11541
|
+
ownKeys(target) {
|
|
11542
|
+
return [...Object.keys(numericProps), ...Reflect.ownKeys(target)];
|
|
11543
|
+
},
|
|
11544
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
11545
|
+
return { enumerable: true, configurable: true };
|
|
11546
|
+
}
|
|
11547
|
+
});
|
|
11548
|
+
}
|
|
11549
|
+
function getWorkerUrl(id5, version) {
|
|
11550
|
+
return `https://unpkg.com/@deck.gl/carto@${version}/dist/${id5}-worker.js`;
|
|
11551
|
+
}
|
|
11552
|
+
function scaleIdentity() {
|
|
11553
|
+
let unknown;
|
|
11554
|
+
function scale(x) {
|
|
11555
|
+
return x === null ? unknown : x;
|
|
11556
|
+
}
|
|
11557
|
+
scale.invert = scale;
|
|
11558
|
+
scale.domain = scale.range = (d) => d;
|
|
11559
|
+
scale.unknown = (u) => {
|
|
11560
|
+
if (u) {
|
|
11561
|
+
unknown = u;
|
|
11562
|
+
}
|
|
11563
|
+
return unknown;
|
|
11564
|
+
};
|
|
11565
|
+
scale.copy = () => {
|
|
11566
|
+
const scaleCopy = scaleIdentity();
|
|
11567
|
+
scaleCopy.unknown(unknown);
|
|
11568
|
+
return scaleCopy;
|
|
11569
|
+
};
|
|
11570
|
+
return scale;
|
|
11571
|
+
}
|
|
11572
|
+
var EMPTY_UINT16ARRAY = new Uint16Array();
|
|
11573
|
+
var EMPTY_BINARY_PROPS = {
|
|
11574
|
+
positions: { value: new Float32Array(), size: 2 },
|
|
11575
|
+
properties: [],
|
|
11576
|
+
numericProps: {},
|
|
11577
|
+
featureIds: { value: EMPTY_UINT16ARRAY, size: 1 },
|
|
11578
|
+
globalFeatureIds: { value: EMPTY_UINT16ARRAY, size: 1 }
|
|
11579
|
+
};
|
|
11580
|
+
function createEmptyBinary() {
|
|
11581
|
+
return {
|
|
11582
|
+
shape: "binary-feature-collection",
|
|
11583
|
+
points: {
|
|
11584
|
+
type: "Point",
|
|
11585
|
+
...EMPTY_BINARY_PROPS
|
|
11586
|
+
},
|
|
11587
|
+
lines: {
|
|
11588
|
+
type: "LineString",
|
|
11589
|
+
pathIndices: { value: EMPTY_UINT16ARRAY, size: 1 },
|
|
11590
|
+
...EMPTY_BINARY_PROPS
|
|
11591
|
+
},
|
|
11592
|
+
polygons: {
|
|
11593
|
+
type: "Polygon",
|
|
11594
|
+
polygonIndices: { value: EMPTY_UINT16ARRAY, size: 1 },
|
|
11595
|
+
primitivePolygonIndices: { value: EMPTY_UINT16ARRAY, size: 1 },
|
|
11596
|
+
...EMPTY_BINARY_PROPS
|
|
11597
|
+
}
|
|
11598
|
+
};
|
|
11599
|
+
}
|
|
11600
|
+
function createBinaryPointFeature(positions, featureIds, globalFeatureIds, numericProps, properties, size = 2) {
|
|
11601
|
+
return {
|
|
11602
|
+
type: "Point",
|
|
11603
|
+
positions: { value: new Float32Array(positions), size },
|
|
11604
|
+
featureIds: { value: new Uint16Array(featureIds), size: 1 },
|
|
11605
|
+
globalFeatureIds: { value: new Uint32Array(globalFeatureIds), size: 1 },
|
|
11606
|
+
numericProps,
|
|
11607
|
+
properties
|
|
11608
|
+
};
|
|
11609
|
+
}
|
|
11610
|
+
function initializeNumericProps(numPoints, sourceProps) {
|
|
11611
|
+
const numericProps = {};
|
|
11612
|
+
if (sourceProps) {
|
|
11613
|
+
Object.keys(sourceProps).forEach((prop) => {
|
|
11614
|
+
numericProps[prop] = { value: new Float32Array(numPoints), size: 1 };
|
|
11615
|
+
});
|
|
11616
|
+
}
|
|
11617
|
+
return numericProps;
|
|
11618
|
+
}
|
|
11619
|
+
function copyNumericProps(sourceProps, targetProps, sourceIndex, targetIndex) {
|
|
11620
|
+
Object.keys(sourceProps).forEach((prop) => {
|
|
11621
|
+
targetProps[prop].value[targetIndex] = sourceProps[prop].value[sourceIndex];
|
|
11622
|
+
});
|
|
11623
|
+
}
|
|
11624
|
+
|
|
11625
|
+
// src/layers/cluster-utils.ts
|
|
11523
11626
|
function aggregateTile(tile, tileAggregationCache, aggregationLevels, properties = [], getPosition, getWeight) {
|
|
11524
11627
|
if (!tile.content)
|
|
11525
11628
|
return false;
|
|
@@ -11579,7 +11682,7 @@ var __exports__ = (() => {
|
|
|
11579
11682
|
for (const name of Object.keys(tile.content[0].properties)) {
|
|
11580
11683
|
let aggregation = name.split("_").pop().toLowerCase();
|
|
11581
11684
|
if (!validAggregations.includes(aggregation)) {
|
|
11582
|
-
|
|
11685
|
+
import_core2.log.warn(`No valid aggregation present in ${name} property`)();
|
|
11583
11686
|
aggregation = "any";
|
|
11584
11687
|
}
|
|
11585
11688
|
properties.push({ name, aggregation });
|
|
@@ -11599,14 +11702,6 @@ var __exports__ = (() => {
|
|
|
11599
11702
|
}
|
|
11600
11703
|
return stats;
|
|
11601
11704
|
}
|
|
11602
|
-
var EMPTY_UINT16ARRAY = new Uint16Array();
|
|
11603
|
-
var EMPTY_BINARY_PROPS = {
|
|
11604
|
-
positions: { value: new Float32Array(), size: 2 },
|
|
11605
|
-
properties: [],
|
|
11606
|
-
numericProps: {},
|
|
11607
|
-
featureIds: { value: EMPTY_UINT16ARRAY, size: 1 },
|
|
11608
|
-
globalFeatureIds: { value: EMPTY_UINT16ARRAY, size: 1 }
|
|
11609
|
-
};
|
|
11610
11705
|
function clustersToBinary(data) {
|
|
11611
11706
|
const positions = new Float32Array(data.length * 2);
|
|
11612
11707
|
const featureIds = new Uint16Array(data.length);
|
|
@@ -11615,26 +11710,8 @@ var __exports__ = (() => {
|
|
|
11615
11710
|
featureIds[i] = i;
|
|
11616
11711
|
}
|
|
11617
11712
|
return {
|
|
11618
|
-
|
|
11619
|
-
points: {
|
|
11620
|
-
type: "Point",
|
|
11621
|
-
positions: { value: positions, size: 2 },
|
|
11622
|
-
properties: data,
|
|
11623
|
-
numericProps: {},
|
|
11624
|
-
featureIds: { value: featureIds, size: 1 },
|
|
11625
|
-
globalFeatureIds: { value: featureIds, size: 1 }
|
|
11626
|
-
},
|
|
11627
|
-
lines: {
|
|
11628
|
-
type: "LineString",
|
|
11629
|
-
pathIndices: { value: EMPTY_UINT16ARRAY, size: 1 },
|
|
11630
|
-
...EMPTY_BINARY_PROPS
|
|
11631
|
-
},
|
|
11632
|
-
polygons: {
|
|
11633
|
-
type: "Polygon",
|
|
11634
|
-
polygonIndices: { value: EMPTY_UINT16ARRAY, size: 1 },
|
|
11635
|
-
primitivePolygonIndices: { value: EMPTY_UINT16ARRAY, size: 1 },
|
|
11636
|
-
...EMPTY_BINARY_PROPS
|
|
11637
|
-
}
|
|
11713
|
+
...createEmptyBinary(),
|
|
11714
|
+
points: createBinaryPointFeature(positions, featureIds, featureIds, {}, data)
|
|
11638
11715
|
};
|
|
11639
11716
|
}
|
|
11640
11717
|
|
|
@@ -12212,55 +12289,6 @@ var __exports__ = (() => {
|
|
|
12212
12289
|
return tile;
|
|
12213
12290
|
}
|
|
12214
12291
|
|
|
12215
|
-
// src/utils.ts
|
|
12216
|
-
var import_core2 = __toESM(require_core2(), 1);
|
|
12217
|
-
function assert2(condition, message) {
|
|
12218
|
-
import_core2.log.assert(condition, message);
|
|
12219
|
-
}
|
|
12220
|
-
function createBinaryProxy(data, index2) {
|
|
12221
|
-
const { properties, numericProps } = data;
|
|
12222
|
-
return new Proxy(properties[index2] || {}, {
|
|
12223
|
-
get(target, property) {
|
|
12224
|
-
if (property in numericProps) {
|
|
12225
|
-
return numericProps[property].value[index2];
|
|
12226
|
-
}
|
|
12227
|
-
return target[property];
|
|
12228
|
-
},
|
|
12229
|
-
has(target, property) {
|
|
12230
|
-
return property in numericProps || property in target;
|
|
12231
|
-
},
|
|
12232
|
-
ownKeys(target) {
|
|
12233
|
-
return [...Object.keys(numericProps), ...Reflect.ownKeys(target)];
|
|
12234
|
-
},
|
|
12235
|
-
getOwnPropertyDescriptor(target, prop) {
|
|
12236
|
-
return { enumerable: true, configurable: true };
|
|
12237
|
-
}
|
|
12238
|
-
});
|
|
12239
|
-
}
|
|
12240
|
-
function getWorkerUrl(id5, version) {
|
|
12241
|
-
return `https://unpkg.com/@deck.gl/carto@${version}/dist/${id5}-worker.js`;
|
|
12242
|
-
}
|
|
12243
|
-
function scaleIdentity() {
|
|
12244
|
-
let unknown;
|
|
12245
|
-
function scale(x) {
|
|
12246
|
-
return x === null ? unknown : x;
|
|
12247
|
-
}
|
|
12248
|
-
scale.invert = scale;
|
|
12249
|
-
scale.domain = scale.range = (d) => d;
|
|
12250
|
-
scale.unknown = (u) => {
|
|
12251
|
-
if (u) {
|
|
12252
|
-
unknown = u;
|
|
12253
|
-
}
|
|
12254
|
-
return unknown;
|
|
12255
|
-
};
|
|
12256
|
-
scale.copy = () => {
|
|
12257
|
-
const scaleCopy = scaleIdentity();
|
|
12258
|
-
scaleCopy.unknown(unknown);
|
|
12259
|
-
return scaleCopy;
|
|
12260
|
-
};
|
|
12261
|
-
return scale;
|
|
12262
|
-
}
|
|
12263
|
-
|
|
12264
12292
|
// src/layers/schema/spatialjson-utils.ts
|
|
12265
12293
|
function binaryToSpatialjson(binary) {
|
|
12266
12294
|
const { cells, scheme } = binary;
|
|
@@ -12313,13 +12341,29 @@ var __exports__ = (() => {
|
|
|
12313
12341
|
// src/layers/utils.ts
|
|
12314
12342
|
var import_core3 = __toESM(require_core2(), 1);
|
|
12315
12343
|
var import_core4 = __toESM(require_core2(), 1);
|
|
12316
|
-
function
|
|
12317
|
-
if (!loadOptions
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12344
|
+
function mergeLoadOptions(loadOptions, additionalOptions, depth = 0) {
|
|
12345
|
+
if (!loadOptions) {
|
|
12346
|
+
return additionalOptions;
|
|
12347
|
+
}
|
|
12348
|
+
if (!additionalOptions) {
|
|
12349
|
+
return loadOptions;
|
|
12350
|
+
}
|
|
12351
|
+
if (depth > 10) {
|
|
12352
|
+
return additionalOptions;
|
|
12353
|
+
}
|
|
12354
|
+
const result = { ...loadOptions };
|
|
12355
|
+
for (const key in additionalOptions) {
|
|
12356
|
+
const value = additionalOptions[key];
|
|
12357
|
+
if (value === loadOptions || value === additionalOptions) {
|
|
12358
|
+
continue;
|
|
12359
|
+
}
|
|
12360
|
+
if (typeof value === "object" && value !== null) {
|
|
12361
|
+
result[key] = mergeLoadOptions(loadOptions[key], value, depth + 1);
|
|
12362
|
+
} else {
|
|
12363
|
+
result[key] = value;
|
|
12364
|
+
}
|
|
12322
12365
|
}
|
|
12366
|
+
return result;
|
|
12323
12367
|
}
|
|
12324
12368
|
function mergeBoundaryData(geometry, properties) {
|
|
12325
12369
|
const mapping = {};
|
|
@@ -12472,11 +12516,11 @@ var __exports__ = (() => {
|
|
|
12472
12516
|
ClusterGeoJsonLayer.defaultProps = defaultProps;
|
|
12473
12517
|
var ClusterTileLayer = class extends import_core6.CompositeLayer {
|
|
12474
12518
|
getLoadOptions() {
|
|
12475
|
-
const loadOptions = super.getLoadOptions() || {};
|
|
12476
12519
|
const tileJSON = this.props.data;
|
|
12477
|
-
|
|
12478
|
-
|
|
12479
|
-
|
|
12520
|
+
return mergeLoadOptions(super.getLoadOptions(), {
|
|
12521
|
+
fetch: { headers: { Authorization: `Bearer ${tileJSON.accessToken}` } },
|
|
12522
|
+
cartoSpatialTile: { scheme: "quadbin" }
|
|
12523
|
+
});
|
|
12480
12524
|
}
|
|
12481
12525
|
renderLayers() {
|
|
12482
12526
|
const tileJSON = this.props.data;
|
|
@@ -12696,11 +12740,11 @@ var __exports__ = (() => {
|
|
|
12696
12740
|
import_geo_layers5.H3HexagonLayer._checkH3Lib();
|
|
12697
12741
|
}
|
|
12698
12742
|
getLoadOptions() {
|
|
12699
|
-
const loadOptions = super.getLoadOptions() || {};
|
|
12700
12743
|
const tileJSON = this.props.data;
|
|
12701
|
-
|
|
12702
|
-
|
|
12703
|
-
|
|
12744
|
+
return mergeLoadOptions(super.getLoadOptions(), {
|
|
12745
|
+
fetch: { headers: { Authorization: `Bearer ${tileJSON.accessToken}` } },
|
|
12746
|
+
cartoSpatialTile: { scheme: "h3" }
|
|
12747
|
+
});
|
|
12704
12748
|
}
|
|
12705
12749
|
renderLayers() {
|
|
12706
12750
|
const tileJSON = this.props.data;
|
|
@@ -13045,11 +13089,11 @@ vec4 heatmap_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
13045
13089
|
};
|
|
13046
13090
|
var QuadbinTileLayer = class extends import_core10.CompositeLayer {
|
|
13047
13091
|
getLoadOptions() {
|
|
13048
|
-
const loadOptions = super.getLoadOptions() || {};
|
|
13049
13092
|
const tileJSON = this.props.data;
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13093
|
+
return mergeLoadOptions(super.getLoadOptions(), {
|
|
13094
|
+
fetch: { headers: { Authorization: `Bearer ${tileJSON.accessToken}` } },
|
|
13095
|
+
cartoSpatialTile: { scheme: "quadbin" }
|
|
13096
|
+
});
|
|
13053
13097
|
}
|
|
13054
13098
|
renderLayers() {
|
|
13055
13099
|
const tileJSON = this.props.data;
|
|
@@ -13410,6 +13454,12 @@ vec4 heatmap_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
13410
13454
|
getTextAnchor,
|
|
13411
13455
|
updateTriggers
|
|
13412
13456
|
} = this.props;
|
|
13457
|
+
if (sizeScale < 2) {
|
|
13458
|
+
const propName = this.parent?.props?.textSizeScale ? "textSizeScale" : "sizeScale";
|
|
13459
|
+
import_core12.log.warn(
|
|
13460
|
+
`${propName} has small value (${sizeScale}). Note getTextSize is not supported on PointLabelLayer`
|
|
13461
|
+
)();
|
|
13462
|
+
}
|
|
13413
13463
|
return new EnhancedTextLayer(
|
|
13414
13464
|
this.getSubLayerProps({
|
|
13415
13465
|
id: id5,
|
|
@@ -13837,10 +13887,10 @@ void main(void) {
|
|
|
13837
13887
|
};
|
|
13838
13888
|
var RasterTileLayer = class extends import_core14.CompositeLayer {
|
|
13839
13889
|
getLoadOptions() {
|
|
13840
|
-
const loadOptions = super.getLoadOptions() || {};
|
|
13841
13890
|
const tileJSON = this.props.data;
|
|
13842
|
-
|
|
13843
|
-
|
|
13891
|
+
return mergeLoadOptions(super.getLoadOptions(), {
|
|
13892
|
+
fetch: { headers: { Authorization: `Bearer ${tileJSON.accessToken}` } }
|
|
13893
|
+
});
|
|
13844
13894
|
}
|
|
13845
13895
|
renderLayers() {
|
|
13846
13896
|
const tileJSON = this.props.data;
|
|
@@ -13979,9 +14029,247 @@ void main(void) {
|
|
|
13979
14029
|
var import_extensions = __toESM(require_extensions(), 1);
|
|
13980
14030
|
var import_geo_layers8 = __toESM(require_geo_layers(), 1);
|
|
13981
14031
|
var import_layers5 = __toESM(require_layers(), 1);
|
|
14032
|
+
|
|
14033
|
+
// src/layers/label-utils.ts
|
|
14034
|
+
function createPointsFromLines(lines, uniqueIdProperty) {
|
|
14035
|
+
const hasNumericUniqueId = uniqueIdProperty ? uniqueIdProperty in lines.numericProps : false;
|
|
14036
|
+
const idToLineInfo = /* @__PURE__ */ new Map();
|
|
14037
|
+
for (let i = 0; i < lines.pathIndices.value.length - 1; i++) {
|
|
14038
|
+
const pathIndex = lines.pathIndices.value[i];
|
|
14039
|
+
const featureId = lines.featureIds.value[pathIndex];
|
|
14040
|
+
let uniqueId;
|
|
14041
|
+
if (uniqueIdProperty === void 0) {
|
|
14042
|
+
uniqueId = featureId;
|
|
14043
|
+
} else if (hasNumericUniqueId) {
|
|
14044
|
+
uniqueId = lines.numericProps[uniqueIdProperty].value[pathIndex];
|
|
14045
|
+
} else if (lines.properties[featureId] && uniqueIdProperty in lines.properties[featureId]) {
|
|
14046
|
+
uniqueId = lines.properties[featureId][uniqueIdProperty];
|
|
14047
|
+
} else {
|
|
14048
|
+
uniqueId = void 0;
|
|
14049
|
+
}
|
|
14050
|
+
const length = getLineLength(lines, i);
|
|
14051
|
+
if (!idToLineInfo.has(uniqueId) || length > idToLineInfo.get(uniqueId).length) {
|
|
14052
|
+
idToLineInfo.set(uniqueId, { index: i, length });
|
|
14053
|
+
}
|
|
14054
|
+
}
|
|
14055
|
+
const positions = [];
|
|
14056
|
+
const properties = [];
|
|
14057
|
+
const featureIds = [];
|
|
14058
|
+
const globalFeatureIds = [];
|
|
14059
|
+
const numericProps = initializeNumericProps(idToLineInfo.size, lines.numericProps);
|
|
14060
|
+
let pointIndex = 0;
|
|
14061
|
+
for (const [_, { index: index2 }] of idToLineInfo) {
|
|
14062
|
+
const midpoint = getLineMidpoint(lines, index2);
|
|
14063
|
+
positions.push(...midpoint);
|
|
14064
|
+
const pathIndex = lines.pathIndices.value[index2];
|
|
14065
|
+
const featureId = lines.featureIds.value[pathIndex];
|
|
14066
|
+
featureIds.push(pointIndex);
|
|
14067
|
+
properties.push(lines.properties[featureId]);
|
|
14068
|
+
globalFeatureIds.push(lines.globalFeatureIds.value[pathIndex]);
|
|
14069
|
+
copyNumericProps(lines.numericProps, numericProps, pathIndex, pointIndex);
|
|
14070
|
+
pointIndex++;
|
|
14071
|
+
}
|
|
14072
|
+
return createBinaryPointFeature(
|
|
14073
|
+
positions,
|
|
14074
|
+
featureIds,
|
|
14075
|
+
globalFeatureIds,
|
|
14076
|
+
numericProps,
|
|
14077
|
+
properties
|
|
14078
|
+
);
|
|
14079
|
+
}
|
|
14080
|
+
function createPointsFromPolygons(polygons, tileBbox, props) {
|
|
14081
|
+
const { west, south, east, north } = tileBbox;
|
|
14082
|
+
const tileArea = (east - west) * (north - south);
|
|
14083
|
+
const minPolygonArea = tileArea * 1e-4;
|
|
14084
|
+
const positions = [];
|
|
14085
|
+
const properties = [];
|
|
14086
|
+
const featureIds = [];
|
|
14087
|
+
const globalFeatureIds = [];
|
|
14088
|
+
const numericProps = initializeNumericProps(
|
|
14089
|
+
polygons.polygonIndices.value.length - 1,
|
|
14090
|
+
polygons.numericProps
|
|
14091
|
+
);
|
|
14092
|
+
let pointIndex = 0;
|
|
14093
|
+
let triangleIndex = 0;
|
|
14094
|
+
const { extruded } = props;
|
|
14095
|
+
for (let i = 0; i < polygons.polygonIndices.value.length - 1; i++) {
|
|
14096
|
+
const startIndex = polygons.polygonIndices.value[i];
|
|
14097
|
+
const endIndex = polygons.polygonIndices.value[i + 1];
|
|
14098
|
+
if (getPolygonArea(polygons, i) < minPolygonArea) {
|
|
14099
|
+
continue;
|
|
14100
|
+
}
|
|
14101
|
+
const centroid = getPolygonCentroid(polygons, i);
|
|
14102
|
+
let maxArea = -1;
|
|
14103
|
+
let largestTriangleCenter = [0, 0];
|
|
14104
|
+
let centroidIsInside = false;
|
|
14105
|
+
while (triangleIndex < polygons.triangles.value.length) {
|
|
14106
|
+
const i1 = polygons.triangles.value[triangleIndex];
|
|
14107
|
+
if (i1 >= endIndex) {
|
|
14108
|
+
break;
|
|
14109
|
+
}
|
|
14110
|
+
if (centroidIsInside) {
|
|
14111
|
+
triangleIndex += 3;
|
|
14112
|
+
continue;
|
|
14113
|
+
}
|
|
14114
|
+
const i2 = polygons.triangles.value[triangleIndex + 1];
|
|
14115
|
+
const i3 = polygons.triangles.value[triangleIndex + 2];
|
|
14116
|
+
const v1 = polygons.positions.value.subarray(
|
|
14117
|
+
i1 * polygons.positions.size,
|
|
14118
|
+
i1 * polygons.positions.size + polygons.positions.size
|
|
14119
|
+
);
|
|
14120
|
+
const v2 = polygons.positions.value.subarray(
|
|
14121
|
+
i2 * polygons.positions.size,
|
|
14122
|
+
i2 * polygons.positions.size + polygons.positions.size
|
|
14123
|
+
);
|
|
14124
|
+
const v3 = polygons.positions.value.subarray(
|
|
14125
|
+
i3 * polygons.positions.size,
|
|
14126
|
+
i3 * polygons.positions.size + polygons.positions.size
|
|
14127
|
+
);
|
|
14128
|
+
if (isPointInTriangle(centroid, v1, v2, v3)) {
|
|
14129
|
+
centroidIsInside = true;
|
|
14130
|
+
} else {
|
|
14131
|
+
const area = getTriangleArea(v1, v2, v3);
|
|
14132
|
+
if (area > maxArea) {
|
|
14133
|
+
maxArea = area;
|
|
14134
|
+
largestTriangleCenter = [(v1[0] + v2[0] + v3[0]) / 3, (v1[1] + v2[1] + v3[1]) / 3];
|
|
14135
|
+
}
|
|
14136
|
+
}
|
|
14137
|
+
triangleIndex += 3;
|
|
14138
|
+
}
|
|
14139
|
+
const labelPoint = centroidIsInside ? centroid : largestTriangleCenter;
|
|
14140
|
+
if (isPointInBounds(labelPoint, tileBbox)) {
|
|
14141
|
+
positions.push(...labelPoint);
|
|
14142
|
+
const featureId = polygons.featureIds.value[startIndex];
|
|
14143
|
+
if (extruded) {
|
|
14144
|
+
const elevation = props.getElevation(void 0, {
|
|
14145
|
+
data: polygons,
|
|
14146
|
+
index: featureId
|
|
14147
|
+
});
|
|
14148
|
+
positions.push(elevation * props.elevationScale);
|
|
14149
|
+
}
|
|
14150
|
+
properties.push(polygons.properties[featureId]);
|
|
14151
|
+
featureIds.push(pointIndex);
|
|
14152
|
+
globalFeatureIds.push(polygons.globalFeatureIds.value[startIndex]);
|
|
14153
|
+
copyNumericProps(polygons.numericProps, numericProps, startIndex, pointIndex);
|
|
14154
|
+
pointIndex++;
|
|
14155
|
+
}
|
|
14156
|
+
}
|
|
14157
|
+
if (polygons.numericProps) {
|
|
14158
|
+
Object.keys(numericProps).forEach((prop) => {
|
|
14159
|
+
numericProps[prop].value = numericProps[prop].value.slice(0, pointIndex);
|
|
14160
|
+
});
|
|
14161
|
+
}
|
|
14162
|
+
return createBinaryPointFeature(
|
|
14163
|
+
positions,
|
|
14164
|
+
featureIds,
|
|
14165
|
+
globalFeatureIds,
|
|
14166
|
+
numericProps,
|
|
14167
|
+
properties,
|
|
14168
|
+
extruded ? 3 : 2
|
|
14169
|
+
);
|
|
14170
|
+
}
|
|
14171
|
+
function getPolygonArea(polygons, index2) {
|
|
14172
|
+
const {
|
|
14173
|
+
positions: { value: positions, size },
|
|
14174
|
+
polygonIndices: { value: indices },
|
|
14175
|
+
triangles: { value: triangles }
|
|
14176
|
+
} = polygons;
|
|
14177
|
+
const startIndex = indices[index2];
|
|
14178
|
+
const endIndex = indices[index2 + 1];
|
|
14179
|
+
let area = 0;
|
|
14180
|
+
let triangleIndex = 0;
|
|
14181
|
+
while (triangleIndex < triangles.length) {
|
|
14182
|
+
const i1 = triangles[triangleIndex];
|
|
14183
|
+
if (i1 >= startIndex)
|
|
14184
|
+
break;
|
|
14185
|
+
triangleIndex += 3;
|
|
14186
|
+
}
|
|
14187
|
+
while (triangleIndex < triangles.length) {
|
|
14188
|
+
const i1 = triangles[triangleIndex];
|
|
14189
|
+
if (i1 >= endIndex)
|
|
14190
|
+
break;
|
|
14191
|
+
const i2 = triangles[triangleIndex + 1];
|
|
14192
|
+
const i3 = triangles[triangleIndex + 2];
|
|
14193
|
+
const v1 = positions.subarray(i1 * size, i1 * size + size);
|
|
14194
|
+
const v2 = positions.subarray(i2 * size, i2 * size + size);
|
|
14195
|
+
const v3 = positions.subarray(i3 * size, i3 * size + size);
|
|
14196
|
+
area += getTriangleArea(v1, v2, v3);
|
|
14197
|
+
triangleIndex += 3;
|
|
14198
|
+
}
|
|
14199
|
+
return area;
|
|
14200
|
+
}
|
|
14201
|
+
function isPointInBounds([x, y], { west, east, south, north }) {
|
|
14202
|
+
return x >= west && x < east && y >= south && y < north;
|
|
14203
|
+
}
|
|
14204
|
+
function isPointInTriangle(p, v1, v2, v3) {
|
|
14205
|
+
const area = Math.abs((v2[0] - v1[0]) * (v3[1] - v1[1]) - (v3[0] - v1[0]) * (v2[1] - v1[1])) / 2;
|
|
14206
|
+
const area1 = Math.abs((v1[0] - p[0]) * (v2[1] - p[1]) - (v2[0] - p[0]) * (v1[1] - p[1])) / 2;
|
|
14207
|
+
const area2 = Math.abs((v2[0] - p[0]) * (v3[1] - p[1]) - (v3[0] - p[0]) * (v2[1] - p[1])) / 2;
|
|
14208
|
+
const area3 = Math.abs((v3[0] - p[0]) * (v1[1] - p[1]) - (v1[0] - p[0]) * (v3[1] - p[1])) / 2;
|
|
14209
|
+
return Math.abs(area - (area1 + area2 + area3)) < 1e-10;
|
|
14210
|
+
}
|
|
14211
|
+
function getTriangleArea([x1, y1], [x2, y2], [x3, y3]) {
|
|
14212
|
+
return Math.abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2);
|
|
14213
|
+
}
|
|
14214
|
+
function getPolygonCentroid(polygons, index2) {
|
|
14215
|
+
const {
|
|
14216
|
+
positions: { value: positions, size }
|
|
14217
|
+
} = polygons;
|
|
14218
|
+
const startIndex = size * polygons.polygonIndices.value[index2];
|
|
14219
|
+
const endIndex = size * polygons.polygonIndices.value[index2 + 1];
|
|
14220
|
+
let minX = Infinity;
|
|
14221
|
+
let minY = Infinity;
|
|
14222
|
+
let maxX = -Infinity;
|
|
14223
|
+
let maxY = -Infinity;
|
|
14224
|
+
for (let i = startIndex; i < endIndex; i += size) {
|
|
14225
|
+
const [x, y] = positions.subarray(i, i + 2);
|
|
14226
|
+
minX = Math.min(minX, x);
|
|
14227
|
+
minY = Math.min(minY, y);
|
|
14228
|
+
maxX = Math.max(maxX, x);
|
|
14229
|
+
maxY = Math.max(maxY, y);
|
|
14230
|
+
}
|
|
14231
|
+
return [(minX + maxX) / 2, (minY + maxY) / 2];
|
|
14232
|
+
}
|
|
14233
|
+
function getSegmentLength(lines, index2) {
|
|
14234
|
+
const {
|
|
14235
|
+
positions: { value }
|
|
14236
|
+
} = lines;
|
|
14237
|
+
const [x1, y1, x2, y2] = value.subarray(index2, index2 + 4);
|
|
14238
|
+
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
|
|
14239
|
+
}
|
|
14240
|
+
function getLineLength(lines, index2) {
|
|
14241
|
+
const {
|
|
14242
|
+
positions: { size }
|
|
14243
|
+
} = lines;
|
|
14244
|
+
const startIndex = size * lines.pathIndices.value[index2];
|
|
14245
|
+
const endIndex = size * lines.pathIndices.value[index2 + 1];
|
|
14246
|
+
let length = 0;
|
|
14247
|
+
for (let j = startIndex; j < endIndex; j += size) {
|
|
14248
|
+
length += getSegmentLength(lines, j);
|
|
14249
|
+
}
|
|
14250
|
+
return length;
|
|
14251
|
+
}
|
|
14252
|
+
function getLineMidpoint(lines, index2) {
|
|
14253
|
+
const {
|
|
14254
|
+
positions: { value: positions },
|
|
14255
|
+
pathIndices: { value: pathIndices }
|
|
14256
|
+
} = lines;
|
|
14257
|
+
const startIndex = pathIndices[index2] * 2;
|
|
14258
|
+
const endIndex = pathIndices[index2 + 1] * 2;
|
|
14259
|
+
const numPoints = (endIndex - startIndex) / 2;
|
|
14260
|
+
if (numPoints === 2) {
|
|
14261
|
+
const [x1, y1, x2, y2] = positions.subarray(startIndex, startIndex + 4);
|
|
14262
|
+
return [(x1 + x2) / 2, (y1 + y2) / 2];
|
|
14263
|
+
}
|
|
14264
|
+
const midPointIndex = startIndex + Math.floor(numPoints / 2) * 2;
|
|
14265
|
+
return [positions[midPointIndex], positions[midPointIndex + 1]];
|
|
14266
|
+
}
|
|
14267
|
+
|
|
14268
|
+
// src/layers/vector-tile-layer.ts
|
|
13982
14269
|
(0, import_core16.registerLoaders)([carto_properties_tile_loader_default, carto_vector_tile_loader_default]);
|
|
13983
14270
|
var defaultProps10 = {
|
|
13984
14271
|
...import_geo_layers8.MVTLayer.defaultProps,
|
|
14272
|
+
autoLabels: false,
|
|
13985
14273
|
data: TilejsonPropType,
|
|
13986
14274
|
dataComparator: TilejsonPropType.equal,
|
|
13987
14275
|
tileSize: DEFAULT_TILE_SIZE
|
|
@@ -14004,11 +14292,12 @@ void main(void) {
|
|
|
14004
14292
|
}
|
|
14005
14293
|
}
|
|
14006
14294
|
getLoadOptions() {
|
|
14007
|
-
const loadOptions = super.getLoadOptions() || {};
|
|
14008
14295
|
const tileJSON = this.props.data;
|
|
14009
|
-
|
|
14010
|
-
|
|
14011
|
-
|
|
14296
|
+
return mergeLoadOptions(super.getLoadOptions(), {
|
|
14297
|
+
fetch: { headers: { Authorization: `Bearer ${tileJSON.accessToken}` } },
|
|
14298
|
+
gis: { format: "binary" }
|
|
14299
|
+
// Use binary for MVT loading
|
|
14300
|
+
});
|
|
14012
14301
|
}
|
|
14013
14302
|
/* eslint-disable camelcase */
|
|
14014
14303
|
async getTileData(tile) {
|
|
@@ -14045,24 +14334,8 @@ void main(void) {
|
|
|
14045
14334
|
if (props.data === null) {
|
|
14046
14335
|
return null;
|
|
14047
14336
|
}
|
|
14048
|
-
if (this.state.mvt) {
|
|
14049
|
-
return super.renderSubLayers(props);
|
|
14050
|
-
}
|
|
14051
14337
|
const tileBbox = props.tile.bbox;
|
|
14052
|
-
const
|
|
14053
|
-
const extensions = [new import_extensions.ClipExtension(), ...props.extensions || []];
|
|
14054
|
-
const clipProps = {
|
|
14055
|
-
clipBounds: [west, south, east, north]
|
|
14056
|
-
};
|
|
14057
|
-
const applyClipExtensionToSublayerProps = (subLayerId) => {
|
|
14058
|
-
return {
|
|
14059
|
-
[subLayerId]: {
|
|
14060
|
-
...clipProps,
|
|
14061
|
-
...props?._subLayerProps?.[subLayerId],
|
|
14062
|
-
extensions: [...extensions, ...props?._subLayerProps?.[subLayerId]?.extensions || []]
|
|
14063
|
-
}
|
|
14064
|
-
};
|
|
14065
|
-
};
|
|
14338
|
+
const subLayers = [];
|
|
14066
14339
|
const defaultToPointLabelLayer = {
|
|
14067
14340
|
"points-text": {
|
|
14068
14341
|
type: PointLabelLayer,
|
|
@@ -14074,20 +14347,78 @@ void main(void) {
|
|
|
14074
14347
|
]
|
|
14075
14348
|
}
|
|
14076
14349
|
};
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14350
|
+
if (this.state.mvt) {
|
|
14351
|
+
subLayers.push(super.renderSubLayers(props));
|
|
14352
|
+
} else {
|
|
14353
|
+
const { west, south, east, north } = tileBbox;
|
|
14354
|
+
const extensions = [new import_extensions.ClipExtension(), ...props.extensions || []];
|
|
14355
|
+
const clipProps = {
|
|
14356
|
+
clipBounds: [west, south, east, north]
|
|
14357
|
+
};
|
|
14358
|
+
const applyClipExtensionToSublayerProps = (subLayerId) => {
|
|
14359
|
+
return {
|
|
14360
|
+
[subLayerId]: {
|
|
14361
|
+
...clipProps,
|
|
14362
|
+
...props?._subLayerProps?.[subLayerId],
|
|
14363
|
+
extensions: [...extensions, ...props?._subLayerProps?.[subLayerId]?.extensions || []]
|
|
14364
|
+
}
|
|
14365
|
+
};
|
|
14366
|
+
};
|
|
14367
|
+
const subLayerProps = {
|
|
14368
|
+
...props,
|
|
14369
|
+
data: { ...props.data, tileBbox },
|
|
14370
|
+
autoHighlight: false,
|
|
14371
|
+
// Do not perform clipping on points (#9059)
|
|
14372
|
+
_subLayerProps: {
|
|
14373
|
+
...props._subLayerProps,
|
|
14374
|
+
...defaultToPointLabelLayer,
|
|
14375
|
+
...applyClipExtensionToSublayerProps("polygons-fill"),
|
|
14376
|
+
...applyClipExtensionToSublayerProps("polygons-stroke"),
|
|
14377
|
+
...applyClipExtensionToSublayerProps("linestrings")
|
|
14378
|
+
}
|
|
14379
|
+
};
|
|
14380
|
+
subLayers.push(new import_layers5.GeoJsonLayer(subLayerProps));
|
|
14381
|
+
}
|
|
14382
|
+
if (subLayers[0] && props.autoLabels) {
|
|
14383
|
+
const labelData = createEmptyBinary();
|
|
14384
|
+
if (props.data.lines && props.data.lines.positions.value.length > 0) {
|
|
14385
|
+
labelData.points = createPointsFromLines(
|
|
14386
|
+
props.data.lines,
|
|
14387
|
+
typeof props.autoLabels === "object" ? props.autoLabels.uniqueIdProperty : void 0
|
|
14388
|
+
);
|
|
14087
14389
|
}
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14390
|
+
if (props.data.polygons && props.data.polygons.positions.value.length > 0) {
|
|
14391
|
+
labelData.points = createPointsFromPolygons(props.data.polygons, tileBbox, props);
|
|
14392
|
+
}
|
|
14393
|
+
subLayers.push(
|
|
14394
|
+
subLayers[0].clone({
|
|
14395
|
+
id: `${props.id}-labels`,
|
|
14396
|
+
data: labelData,
|
|
14397
|
+
pickable: false,
|
|
14398
|
+
autoHighlight: false
|
|
14399
|
+
})
|
|
14400
|
+
);
|
|
14401
|
+
}
|
|
14402
|
+
return subLayers;
|
|
14403
|
+
}
|
|
14404
|
+
renderLayers() {
|
|
14405
|
+
const layers = super.renderLayers();
|
|
14406
|
+
if (!this.props.autoLabels) {
|
|
14407
|
+
return layers;
|
|
14408
|
+
}
|
|
14409
|
+
const validLayers = layers.flat().filter(Boolean);
|
|
14410
|
+
validLayers.sort((a, b) => {
|
|
14411
|
+
const aHasLabel = a.id.includes("labels");
|
|
14412
|
+
const bHasLabel = b.id.includes("labels");
|
|
14413
|
+
if (aHasLabel && !bHasLabel)
|
|
14414
|
+
return 1;
|
|
14415
|
+
if (!aHasLabel && bHasLabel)
|
|
14416
|
+
return -1;
|
|
14417
|
+
return 0;
|
|
14418
|
+
});
|
|
14419
|
+
return validLayers.map(
|
|
14420
|
+
(l) => l.id.includes("labels") ? l.clone({ highlightedObjectIndex: -1 }) : l
|
|
14421
|
+
);
|
|
14091
14422
|
}
|
|
14092
14423
|
_isWGS84() {
|
|
14093
14424
|
if (this.state.mvt)
|
|
@@ -17232,9 +17563,9 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
17232
17563
|
};
|
|
17233
17564
|
return scale;
|
|
17234
17565
|
}
|
|
17235
|
-
function
|
|
17566
|
+
function log6() {
|
|
17236
17567
|
const scale = loggish(transformer()).domain([1, 10]);
|
|
17237
|
-
scale.copy = () => copy2(scale,
|
|
17568
|
+
scale.copy = () => copy2(scale, log6()).base(scale.base());
|
|
17238
17569
|
initRange.apply(scale, arguments);
|
|
17239
17570
|
return scale;
|
|
17240
17571
|
}
|
|
@@ -18896,7 +19227,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
18896
19227
|
var SCALE_FUNCS = {
|
|
18897
19228
|
linear: linear2,
|
|
18898
19229
|
ordinal,
|
|
18899
|
-
log:
|
|
19230
|
+
log: log6,
|
|
18900
19231
|
point,
|
|
18901
19232
|
quantile: quantile2,
|
|
18902
19233
|
quantize,
|
|
@@ -19271,9 +19602,9 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
19271
19602
|
assert2(dataset, `No dataset matching dataId: ${dataId}`);
|
|
19272
19603
|
const { data } = dataset;
|
|
19273
19604
|
assert2(data, `No data loaded for dataId: ${dataId}`);
|
|
19274
|
-
const { Layer:
|
|
19605
|
+
const { Layer: Layer8, propMap, defaultProps: defaultProps12 } = getLayer(type, config, dataset);
|
|
19275
19606
|
const styleProps = createStyleProps(config, propMap);
|
|
19276
|
-
return new
|
|
19607
|
+
return new Layer8({
|
|
19277
19608
|
id: id5,
|
|
19278
19609
|
data,
|
|
19279
19610
|
...defaultProps12,
|