@deck.gl/carto 9.0.26 → 9.0.27
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/cartoRasterTile-worker.js +1 -1
- package/dist/cartoSpatialTile-worker.js +1 -1
- package/dist/cartoVectorTile-worker.js +1 -1
- package/dist/dist.dev.js +68 -53
- package/dist/index.cjs +63 -53
- package/dist/index.cjs.map +3 -3
- package/dist/layers/cluster-tile-layer.d.ts.map +1 -1
- package/dist/layers/cluster-tile-layer.js +7 -6
- package/dist/layers/cluster-utils.d.ts +18 -6
- package/dist/layers/cluster-utils.d.ts.map +1 -1
- package/dist/layers/cluster-utils.js +19 -3
- 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/style/color-bins-style.js +2 -2
- package/dist/style/color-categories-style.js +2 -2
- package/dist/style/color-continuous-style.js +2 -2
- package/dist/style/utils.d.ts +2 -2
- package/dist/style/utils.d.ts.map +1 -1
- package/dist/style/utils.js +2 -2
- package/dist.min.js +8 -8
- package/package.json +2 -2
- package/src/layers/cluster-tile-layer.ts +13 -6
- package/src/layers/cluster-utils.ts +33 -6
- package/src/style/color-bins-style.ts +2 -2
- package/src/style/color-categories-style.ts +2 -2
- package/src/style/color-continuous-style.ts +2 -2
- package/src/style/utils.ts +6 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-tile-layer.d.ts","sourceRoot":"","sources":["../../src/layers/cluster-tile-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAGL,cAAc,EACd,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAE/C,OAAO,EACL,QAAQ,EACR,YAAY,EAC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;AAoGF,MAAM,CAAC,OAAO,OAAO,gBAAgB,CACnC,kBAAkB,GAAG,GAAG,EACxB,UAAU,SAAS,EAAE,GAAG,EAAE,CAC1B,SAAQ,cAAc,CAAC,UAAU,GAAG,QAAQ,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACzF,MAAM,CAAC,SAAS,SAAsB;IACtC,MAAM,CAAC,YAAY,+CAAgB;IAEnC,cAAc,IAAI,GAAG;IAQrB,YAAY,IAAI,KAAK,GAAG,IAAI,GAAG,UAAU;CAiB1C"}
|
|
@@ -36,23 +36,24 @@ class ClusterGeoJsonLayer extends TileLayer {
|
|
|
36
36
|
const { clusterLevel, getPosition, getWeight } = this.props;
|
|
37
37
|
const properties = extractAggregationProperties(visibleTiles[0]);
|
|
38
38
|
const data = [];
|
|
39
|
+
let needsUpdate = false;
|
|
39
40
|
for (const tile of visibleTiles) {
|
|
40
41
|
// Calculate aggregation based on viewport zoom
|
|
41
42
|
const overZoom = Math.round(zoom - tile.zoom);
|
|
42
43
|
const aggregationLevels = Math.round(clusterLevel) - overZoom;
|
|
43
|
-
aggregateTile(tile, aggregationLevels, properties, getPosition, getWeight);
|
|
44
|
+
const didAggregate = aggregateTile(tile, aggregationLevels, properties, getPosition, getWeight);
|
|
45
|
+
needsUpdate ||= didAggregate;
|
|
44
46
|
data.push(...tile.userData[aggregationLevels]);
|
|
45
47
|
}
|
|
46
48
|
data.sort((a, b) => Number(b.count - a.count));
|
|
47
49
|
const clusterIds = data?.map((tile) => tile.id);
|
|
48
|
-
|
|
50
|
+
needsUpdate ||= !deepEqual(clusterIds, this.state.clusterIds, 1);
|
|
49
51
|
this.setState({ clusterIds });
|
|
50
52
|
if (needsUpdate) {
|
|
51
53
|
const stats = computeAggregationStats(data, properties);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
this.setState({ data: clustersToBinary(data) });
|
|
54
|
+
const binaryData = clustersToBinary(data);
|
|
55
|
+
binaryData.points.attributes = { stats };
|
|
56
|
+
this.setState({ data: binaryData });
|
|
56
57
|
}
|
|
57
58
|
const props = {
|
|
58
59
|
...this.props,
|
|
@@ -10,21 +10,33 @@ export type ClusteredFeaturePropertiesT<FeaturePropertiesT> = FeaturePropertiesT
|
|
|
10
10
|
id: bigint;
|
|
11
11
|
count: number;
|
|
12
12
|
position: [number, number];
|
|
13
|
-
stats: Record<keyof FeaturePropertiesT, {
|
|
14
|
-
min: number;
|
|
15
|
-
max: number;
|
|
16
|
-
}>;
|
|
17
13
|
};
|
|
18
14
|
export type ParsedQuadbinCell<FeaturePropertiesT> = {
|
|
19
15
|
id: bigint;
|
|
20
16
|
properties: FeaturePropertiesT;
|
|
21
17
|
};
|
|
22
18
|
export type ParsedQuadbinTile<FeaturePropertiesT> = ParsedQuadbinCell<FeaturePropertiesT>[];
|
|
23
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Aggregates tile by specified properties, caching result in tile.userData
|
|
21
|
+
*
|
|
22
|
+
* @returns true if data was aggregated, false if cache used
|
|
23
|
+
*/
|
|
24
|
+
export declare function aggregateTile<FeaturePropertiesT>(tile: Tile2DHeader<ParsedQuadbinTile<FeaturePropertiesT>>, aggregationLevels: number, properties: AggregationProperties<FeaturePropertiesT> | undefined, getPosition: Accessor<ParsedQuadbinCell<FeaturePropertiesT>, [number, number]>, getWeight: Accessor<ParsedQuadbinCell<FeaturePropertiesT>, number>): boolean;
|
|
24
25
|
export declare function extractAggregationProperties<FeaturePropertiesT extends {}>(tile: Tile2DHeader<ParsedQuadbinTile<FeaturePropertiesT>>): AggregationProperties<FeaturePropertiesT>;
|
|
25
26
|
export declare function computeAggregationStats<FeaturePropertiesT>(data: ClusteredFeaturePropertiesT<FeaturePropertiesT>[], properties: AggregationProperties<FeaturePropertiesT>): Record<keyof FeaturePropertiesT, {
|
|
26
27
|
min: number;
|
|
27
28
|
max: number;
|
|
28
29
|
}>;
|
|
29
|
-
|
|
30
|
+
type BinaryFeatureCollectionWithStats<FeaturePropertiesT> = Omit<BinaryFeatureCollection, 'points'> & {
|
|
31
|
+
points: BinaryFeatureCollection['points'] & {
|
|
32
|
+
attributes?: {
|
|
33
|
+
stats: Record<keyof FeaturePropertiesT, {
|
|
34
|
+
min: number;
|
|
35
|
+
max: number;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare function clustersToBinary<FeaturePropertiesT>(data: ClusteredFeaturePropertiesT<FeaturePropertiesT>[]): BinaryFeatureCollectionWithStats<FeaturePropertiesT>;
|
|
41
|
+
export {};
|
|
30
42
|
//# sourceMappingURL=cluster-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-utils.d.ts","sourceRoot":"","sources":["../../src/layers/cluster-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"cluster-utils.d.ts","sourceRoot":"","sources":["../../src/layers/cluster-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAC,QAAQ,EAAM,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAE3D,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAC9E,MAAM,MAAM,qBAAqB,CAAC,kBAAkB,IAAI;IACtD,WAAW,EAAE,WAAW,CAAC;IACzB,IAAI,EAAE,MAAM,kBAAkB,CAAC;CAChC,EAAE,CAAC;AACJ,MAAM,MAAM,2BAA2B,CAAC,kBAAkB,IAAI,kBAAkB,GAAG;IACjF,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,C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AC;SACrE,CAAC;KACH,CAAC;CACH,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,kBAAkB,EACjD,IAAI,EAAE,2BAA2B,CAAC,kBAAkB,CAAC,EAAE,GACtD,gCAAgC,CAAC,kBAAkB,CAAC,CA8BtD"}
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { cellToParent } from 'quadbin';
|
|
2
|
+
import { log } from '@deck.gl/core';
|
|
3
|
+
/**
|
|
4
|
+
* Aggregates tile by specified properties, caching result in tile.userData
|
|
5
|
+
*
|
|
6
|
+
* @returns true if data was aggregated, false if cache used
|
|
7
|
+
*/
|
|
2
8
|
export function aggregateTile(tile, aggregationLevels, properties = [], getPosition, getWeight) {
|
|
3
9
|
if (!tile.content)
|
|
4
|
-
return;
|
|
10
|
+
return false;
|
|
5
11
|
// Aggregate on demand and cache result
|
|
6
12
|
if (!tile.userData)
|
|
7
13
|
tile.userData = {};
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
const cell0 = tile.userData[aggregationLevels]?.[0];
|
|
15
|
+
if (cell0) {
|
|
16
|
+
// Have already aggregated this tile
|
|
17
|
+
if (properties.every(property => property.name in cell0)) {
|
|
18
|
+
// Use cached result
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
// Aggregated properties have changed, re-aggregate
|
|
22
|
+
tile.userData = {};
|
|
23
|
+
}
|
|
10
24
|
const out = {};
|
|
11
25
|
for (const cell of tile.content) {
|
|
12
26
|
let id = cell.id;
|
|
@@ -56,6 +70,7 @@ export function aggregateTile(tile, aggregationLevels, properties = [], getPosit
|
|
|
56
70
|
}
|
|
57
71
|
}
|
|
58
72
|
tile.userData[aggregationLevels] = Object.values(out);
|
|
73
|
+
return true;
|
|
59
74
|
}
|
|
60
75
|
export function extractAggregationProperties(tile) {
|
|
61
76
|
const properties = [];
|
|
@@ -63,6 +78,7 @@ export function extractAggregationProperties(tile) {
|
|
|
63
78
|
for (const name of Object.keys(tile.content[0].properties)) {
|
|
64
79
|
let aggregation = name.split('_').pop().toLowerCase();
|
|
65
80
|
if (!validAggregations.includes(aggregation)) {
|
|
81
|
+
log.warn(`No valid aggregation present in ${name} property`)();
|
|
66
82
|
aggregation = 'any';
|
|
67
83
|
}
|
|
68
84
|
properties.push({ name: name, aggregation });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TileReader } from "./carto-raster-tile.js";
|
|
2
2
|
import { parsePbf } from "./tile-loader-utils.js";
|
|
3
3
|
import { getWorkerUrl } from "../../utils.js";
|
|
4
|
-
const VERSION = typeof "9.0.
|
|
4
|
+
const VERSION = typeof "9.0.27" !== 'undefined' ? "9.0.27" : 'latest';
|
|
5
5
|
const id = 'cartoRasterTile';
|
|
6
6
|
const DEFAULT_OPTIONS = {
|
|
7
7
|
cartoRasterTile: {
|
|
@@ -2,7 +2,7 @@ import { TileReader } from "./carto-spatial-tile.js";
|
|
|
2
2
|
import { parsePbf } from "./tile-loader-utils.js";
|
|
3
3
|
import { getWorkerUrl } from "../../utils.js";
|
|
4
4
|
import { binaryToSpatialjson } from "./spatialjson-utils.js";
|
|
5
|
-
const VERSION = typeof "9.0.
|
|
5
|
+
const VERSION = typeof "9.0.27" !== 'undefined' ? "9.0.27" : 'latest';
|
|
6
6
|
const id = 'cartoSpatialTile';
|
|
7
7
|
const DEFAULT_OPTIONS = {
|
|
8
8
|
cartoSpatialTile: {
|
|
@@ -2,7 +2,7 @@ import earcut from 'earcut';
|
|
|
2
2
|
import { TileReader } from "./carto-tile.js";
|
|
3
3
|
import { parsePbf } from "./tile-loader-utils.js";
|
|
4
4
|
import { getWorkerUrl } from "../../utils.js";
|
|
5
|
-
const VERSION = typeof "9.0.
|
|
5
|
+
const VERSION = typeof "9.0.27" !== 'undefined' ? "9.0.27" : 'latest';
|
|
6
6
|
const id = 'cartoVectorTile';
|
|
7
7
|
const DEFAULT_OPTIONS = {
|
|
8
8
|
cartoVectorTile: {
|
|
@@ -14,8 +14,8 @@ export default function colorBins({ attr, domain, colors = DEFAULT_PALETTE, null
|
|
|
14
14
|
assert(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
|
|
15
15
|
const palette = typeof colors === 'string' ? getPalette(colors, domain.length + 1) : colors;
|
|
16
16
|
const color = scaleThreshold().domain(domain).range(palette);
|
|
17
|
-
return d => {
|
|
18
|
-
const value = getAttrValue(attr, d);
|
|
17
|
+
return (d, info) => {
|
|
18
|
+
const value = getAttrValue(attr, d, info);
|
|
19
19
|
return typeof value === 'number' && Number.isFinite(value) ? color(value) : nullColor;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
@@ -16,8 +16,8 @@ export default function colorCategories({ attr, domain, colors = DEFAULT_PALETTE
|
|
|
16
16
|
for (const [i, c] of domain.entries()) {
|
|
17
17
|
colorsByCategory[c] = palette[i];
|
|
18
18
|
}
|
|
19
|
-
return d => {
|
|
20
|
-
const value = getAttrValue(attr, d);
|
|
19
|
+
return (d, info) => {
|
|
20
|
+
const value = getAttrValue(attr, d, info);
|
|
21
21
|
return (typeof value === 'number' && Number.isFinite(value)) || typeof value === 'string'
|
|
22
22
|
? colorsByCategory[value] || othersColor
|
|
23
23
|
: nullColor;
|
|
@@ -14,8 +14,8 @@ export default function colorContinuous({ attr, domain, colors = DEFAULT_PALETTE
|
|
|
14
14
|
assert(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
|
|
15
15
|
const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;
|
|
16
16
|
const color = scaleLinear().domain(domain).range(palette);
|
|
17
|
-
return d => {
|
|
18
|
-
const value = getAttrValue(attr, d);
|
|
17
|
+
return (d, info) => {
|
|
18
|
+
const value = getAttrValue(attr, d, info);
|
|
19
19
|
return typeof value === 'number' && Number.isFinite(value) ? color(value) : nullColor;
|
|
20
20
|
};
|
|
21
21
|
}
|
package/dist/style/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Feature } from 'geojson';
|
|
2
|
-
export type AttributeSelector<DataT = Feature, OutT = any> = string | ((d: DataT) => OutT);
|
|
3
|
-
export declare function getAttrValue<DataT = Feature, OutT = any>(attr: string | AttributeSelector<DataT, OutT>, d: DataT): OutT;
|
|
2
|
+
export type AttributeSelector<DataT = Feature, OutT = any> = string | ((d: DataT, info: any) => OutT);
|
|
3
|
+
export declare function getAttrValue<DataT = Feature, OutT = any>(attr: string | AttributeSelector<DataT, OutT>, d: DataT, info: any): OutT;
|
|
4
4
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/style/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAKhC,MAAM,MAAM,iBAAiB,CAAC,KAAK,GAAG,OAAO,EAAE,IAAI,GAAG,GAAG,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/style/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAKhC,MAAM,MAAM,iBAAiB,CAAC,KAAK,GAAG,OAAO,EAAE,IAAI,GAAG,GAAG,IACrD,MAAM,GACN,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC;AAEpC,wBAAgB,YAAY,CAAC,KAAK,GAAG,OAAO,EAAE,IAAI,GAAG,GAAG,EACtD,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,EAC7C,CAAC,EAAE,KAAK,EACR,IAAI,EAAE,GAAG,GACR,IAAI,CASN"}
|
package/dist/style/utils.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { assert } from "../utils.js";
|
|
2
2
|
const ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);
|
|
3
|
-
export function getAttrValue(attr, d) {
|
|
3
|
+
export function getAttrValue(attr, d, info) {
|
|
4
4
|
assert(typeof d === 'object', 'Expected "data" to be an object');
|
|
5
5
|
assert(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected "attr" to be a function or string');
|
|
6
6
|
// Is function
|
|
7
7
|
if (typeof attr === 'function') {
|
|
8
|
-
return attr(d);
|
|
8
|
+
return attr(d, info);
|
|
9
9
|
}
|
|
10
10
|
return d?.properties?.[attr];
|
|
11
11
|
}
|