@deck.gl/carto 8.9.21 → 8.9.23

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.
Files changed (37) hide show
  1. package/LICENSE +1 -1
  2. package/dist/dist.dev.js +4 -1
  3. package/dist/es5/layers/quadbin-layer.js +3 -0
  4. package/dist/es5/layers/quadbin-layer.js.map +1 -1
  5. package/dist/esm/layers/quadbin-layer.js +4 -1
  6. package/dist/esm/layers/quadbin-layer.js.map +1 -1
  7. package/dist.min.js +15 -15
  8. package/package.json +2 -2
  9. package/src/layers/quadbin-layer.ts +2 -1
  10. package/typed/layers/quadbin-layer.d.ts.map +1 -1
  11. package/typed/api/index.js +0 -3
  12. package/typed/api/layer-map.js +0 -264
  13. package/typed/api/maps-api-common.js +0 -50
  14. package/typed/api/maps-client.js +0 -125
  15. package/typed/api/maps-v3-client.js +0 -304
  16. package/typed/api/parseMap.js +0 -178
  17. package/typed/basemap.js +0 -9
  18. package/typed/config.js +0 -35
  19. package/typed/index.js +0 -10
  20. package/typed/layers/carto-layer.js +0 -173
  21. package/typed/layers/carto-tile-layer.js +0 -105
  22. package/typed/layers/h3-tile-layer.js +0 -47
  23. package/typed/layers/h3-tileset-2d.js +0 -85
  24. package/typed/layers/quadkey-tile-layer.d.ts +0 -21
  25. package/typed/layers/quadkey-tile-layer.d.ts.map +0 -1
  26. package/typed/layers/quadkey-tile-layer.js +0 -42
  27. package/typed/layers/quadkey-tileset-2d.d.ts +0 -15
  28. package/typed/layers/quadkey-tileset-2d.d.ts.map +0 -1
  29. package/typed/layers/quadkey-tileset-2d.js +0 -36
  30. package/typed/layers/schema/carto-tile.js +0 -161
  31. package/typed/layers/spatial-index-tile-layer.js +0 -40
  32. package/typed/style/color-bins-style.js +0 -12
  33. package/typed/style/color-categories-style.js +0 -16
  34. package/typed/style/color-continuous-style.js +0 -12
  35. package/typed/style/palette.js +0 -62
  36. package/typed/style/utils.js +0 -15
  37. package/typed/utils.js +0 -4
@@ -1,161 +0,0 @@
1
- class KeyValueObjectReader {
2
- static read(pbf, end) {
3
- return pbf.readFields(KeyValueObjectReader._readField, { key: '', value: '' }, end);
4
- }
5
- static _readField(tag, obj, pbf) {
6
- if (tag === 1)
7
- obj.key = pbf.readString();
8
- else if (tag === 2)
9
- obj.value = pbf.readString();
10
- }
11
- }
12
- class PropertiesReader {
13
- static read(pbf, end) {
14
- return pbf.readFields(PropertiesReader._readField, { data: [] }, end);
15
- }
16
- static _readField(tag, obj, pbf) {
17
- if (tag === 1)
18
- obj.data.push(KeyValueObjectReader.read(pbf, pbf.readVarint() + pbf.pos));
19
- }
20
- }
21
- class DoublesReader {
22
- static read(pbf, end) {
23
- // TODO perhaps we can do better and directly map from the source
24
- // ArrayBuffer using ArrayBuffer.slice()
25
- const { value, size } = pbf.readFields(DoublesReader._readField, { value: [], size: 0 }, end);
26
- return { value: new Float32Array(value), size };
27
- }
28
- static _readField(tag, obj, pbf) {
29
- if (tag === 1)
30
- pbf.readPackedDouble(obj.value);
31
- else if (tag === 2)
32
- obj.size = pbf.readVarint(true);
33
- }
34
- }
35
- class IntsReader {
36
- static read(pbf, end) {
37
- const { value, size } = pbf.readFields(IntsReader._readField, { value: [], size: 0 }, end);
38
- return { value: new Uint32Array(value), size };
39
- }
40
- static _readField(tag, obj, pbf) {
41
- if (tag === 1)
42
- pbf.readPackedVarint(obj.value);
43
- else if (tag === 2)
44
- obj.size = pbf.readVarint(true);
45
- }
46
- }
47
- class NumericPropReader {
48
- static read(pbf, end) {
49
- return pbf.readFields(NumericPropReader._readField, { value: [] }, end);
50
- }
51
- static _readField(tag, obj, pbf) {
52
- if (tag === 1)
53
- pbf.readPackedDouble(obj.value);
54
- }
55
- }
56
- class NumericPropKeyValueReader {
57
- static read(pbf, end) {
58
- return pbf.readFields(NumericPropKeyValueReader._readField, { key: '', value: null }, end);
59
- }
60
- static _readField(tag, obj, pbf) {
61
- if (tag === 1)
62
- obj.key = pbf.readString();
63
- else if (tag === 2)
64
- obj.value = NumericPropReader.read(pbf, pbf.readVarint() + pbf.pos);
65
- }
66
- }
67
- class PointsReader {
68
- static read(pbf, end) {
69
- return pbf.readFields(PointsReader._readField, { positions: null, globalFeatureIds: null, featureIds: null, properties: [], numericProps: {} }, end);
70
- }
71
- static _readField(tag, obj, pbf) {
72
- if (tag === 1)
73
- obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);
74
- else if (tag === 2)
75
- obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
76
- else if (tag === 3)
77
- obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
78
- else if (tag === 4)
79
- obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));
80
- else if (tag === 5) {
81
- const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);
82
- obj.numericProps[entry.key] = entry.value;
83
- }
84
- }
85
- }
86
- // Lines ========================================
87
- class LinesReader {
88
- static read(pbf, end) {
89
- return pbf.readFields(LinesReader._readField, {
90
- positions: null,
91
- pathIndices: null,
92
- globalFeatureIds: null,
93
- featureIds: null,
94
- properties: [],
95
- numericProps: {}
96
- }, end);
97
- }
98
- static _readField(tag, obj, pbf) {
99
- if (tag === 1)
100
- obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);
101
- else if (tag === 2)
102
- obj.pathIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
103
- else if (tag === 3)
104
- obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
105
- else if (tag === 4)
106
- obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
107
- else if (tag === 5)
108
- obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));
109
- else if (tag === 6) {
110
- const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);
111
- obj.numericProps[entry.key] = entry.value;
112
- }
113
- }
114
- }
115
- class PolygonsReader {
116
- static read(pbf, end) {
117
- return pbf.readFields(PolygonsReader._readField, {
118
- positions: null,
119
- polygonIndices: null,
120
- globalFeatureIds: null,
121
- featureIds: null,
122
- primitivePolygonIndices: null,
123
- triangles: null,
124
- properties: [],
125
- numericProps: {}
126
- }, end);
127
- }
128
- static _readField(tag, obj, pbf) {
129
- if (tag === 1)
130
- obj.positions = DoublesReader.read(pbf, pbf.readVarint() + pbf.pos);
131
- else if (tag === 2)
132
- obj.polygonIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
133
- else if (tag === 3)
134
- obj.globalFeatureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
135
- else if (tag === 4)
136
- obj.featureIds = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
137
- else if (tag === 5)
138
- obj.primitivePolygonIndices = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
139
- else if (tag === 6)
140
- obj.triangles = IntsReader.read(pbf, pbf.readVarint() + pbf.pos);
141
- else if (tag === 7)
142
- obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));
143
- else if (tag === 8) {
144
- const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);
145
- obj.numericProps[entry.key] = entry.value;
146
- }
147
- }
148
- }
149
- export class TileReader {
150
- static read(pbf, end) {
151
- return pbf.readFields(TileReader._readField, { points: null, lines: null, polygons: null }, end);
152
- }
153
- static _readField(tag, obj, pbf) {
154
- if (tag === 1)
155
- obj.points = PointsReader.read(pbf, pbf.readVarint() + pbf.pos);
156
- else if (tag === 2)
157
- obj.lines = LinesReader.read(pbf, pbf.readVarint() + pbf.pos);
158
- else if (tag === 3)
159
- obj.polygons = PolygonsReader.read(pbf, pbf.readVarint() + pbf.pos);
160
- }
161
- }
@@ -1,40 +0,0 @@
1
- import { TileLayer } from '@deck.gl/geo-layers';
2
- function isFeatureIdDefined(value) {
3
- return value !== undefined && value !== null && value !== '';
4
- }
5
- export default class SpatialIndexTileLayer extends TileLayer {
6
- _updateAutoHighlight(info) {
7
- const { hoveredFeatureId } = this.state;
8
- const hoveredFeature = info.object;
9
- let newHoveredFeatureId;
10
- if (hoveredFeature) {
11
- newHoveredFeatureId = hoveredFeature.id;
12
- }
13
- if (hoveredFeatureId !== newHoveredFeatureId) {
14
- let { highlightColor } = this.props;
15
- if (typeof highlightColor === 'function') {
16
- highlightColor = highlightColor(info);
17
- }
18
- this.setState({
19
- highlightColor,
20
- hoveredFeatureId: newHoveredFeatureId
21
- });
22
- }
23
- }
24
- getSubLayerPropsByTile(tile) {
25
- return {
26
- highlightedObjectIndex: this.getHighlightedObjectIndex(tile),
27
- highlightColor: this.state.highlightColor
28
- };
29
- }
30
- getHighlightedObjectIndex(tile) {
31
- const { hoveredFeatureId } = this.state;
32
- const data = tile.content;
33
- const isFeatureIdPresent = isFeatureIdDefined(hoveredFeatureId);
34
- if (!isFeatureIdPresent || !Array.isArray(data)) {
35
- return -1;
36
- }
37
- return data.findIndex(feature => feature.id === hoveredFeatureId);
38
- }
39
- }
40
- SpatialIndexTileLayer.layerName = 'SpatialIndexTileLayer';
@@ -1,12 +0,0 @@
1
- import { scaleThreshold } from 'd3-scale';
2
- import getPalette, { DEFAULT_PALETTE, NULL_COLOR } from './palette';
3
- import { assert, getAttrValue } from './utils';
4
- export default function colorBins({ attr, domain, colors = DEFAULT_PALETTE, nullColor = NULL_COLOR }) {
5
- assert(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
6
- const palette = typeof colors === 'string' ? getPalette(colors, domain.length + 1) : colors;
7
- const color = scaleThreshold().domain(domain).range(palette);
8
- return d => {
9
- const value = getAttrValue(attr, d);
10
- return typeof value === 'number' && Number.isFinite(value) ? color(value) : nullColor;
11
- };
12
- }
@@ -1,16 +0,0 @@
1
- import getPalette, { DEFAULT_PALETTE, NULL_COLOR, OTHERS_COLOR } from './palette';
2
- import { assert, getAttrValue } from './utils';
3
- export default function colorCategories({ attr, domain, colors = DEFAULT_PALETTE, nullColor = NULL_COLOR, othersColor = OTHERS_COLOR }) {
4
- assert(Array.isArray(domain), 'Expected "domain" to be an array of numbers or strings');
5
- const colorsByCategory = {};
6
- const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;
7
- for (const [i, c] of domain.entries()) {
8
- colorsByCategory[c] = palette[i];
9
- }
10
- return d => {
11
- const value = getAttrValue(attr, d);
12
- return (typeof value === 'number' && Number.isFinite(value)) || typeof value === 'string'
13
- ? colorsByCategory[value] || othersColor
14
- : nullColor;
15
- };
16
- }
@@ -1,12 +0,0 @@
1
- import { scaleLinear } from 'd3-scale';
2
- import getPalette, { DEFAULT_PALETTE, NULL_COLOR } from './palette';
3
- import { assert, getAttrValue } from './utils';
4
- export default function colorContinuous({ attr, domain, colors = DEFAULT_PALETTE, nullColor = NULL_COLOR }) {
5
- assert(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
6
- const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;
7
- const color = scaleLinear().domain(domain).range(palette);
8
- return d => {
9
- const value = getAttrValue(attr, d);
10
- return typeof value === 'number' && Number.isFinite(value) ? color(value) : nullColor;
11
- };
12
- }
@@ -1,62 +0,0 @@
1
- import * as cartoColors from 'cartocolor';
2
- import { assert } from './utils';
3
- export const DEFAULT_PALETTE = 'PurpOr';
4
- export const NULL_COLOR = [204, 204, 204];
5
- export const OTHERS_COLOR = [119, 119, 119];
6
- export default function getPalette(name, numCategories) {
7
- const palette = cartoColors[name];
8
- let paletteIndex = numCategories;
9
- assert(palette, `Palette "${name}" not found. Expected a CARTOColors string`);
10
- const palettesColorVariants = Object.keys(palette)
11
- .filter(p => p !== 'tags')
12
- .map(Number);
13
- const longestPaletteIndex = Math.max(...palettesColorVariants);
14
- const smallestPaletteIndex = Math.min(...palettesColorVariants);
15
- if (!Number.isInteger(numCategories) || numCategories > longestPaletteIndex) {
16
- paletteIndex = longestPaletteIndex;
17
- }
18
- else if (numCategories < smallestPaletteIndex) {
19
- paletteIndex = smallestPaletteIndex;
20
- }
21
- let colors = palette[paletteIndex];
22
- if (palette.tags && palette.tags.includes('qualitative')) {
23
- colors = colors.slice(0, -1);
24
- }
25
- return colors.map(c => hexToRgb(c));
26
- }
27
- export function hexToRgb(hex) {
28
- // Evaluate #ABC
29
- let result = /^#?([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})$/i.exec(hex);
30
- if (result) {
31
- return [
32
- parseInt(result[1] + result[1], 16),
33
- parseInt(result[2] + result[2], 16),
34
- parseInt(result[3] + result[3], 16),
35
- 255
36
- ];
37
- }
38
- // Evaluate #ABCD
39
- result = /^#?([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})$/i.exec(hex);
40
- if (result) {
41
- return [
42
- parseInt(result[1] + result[1], 16),
43
- parseInt(result[2] + result[2], 16),
44
- parseInt(result[3] + result[3], 16),
45
- parseInt(result[4] + result[4], 16)
46
- ];
47
- }
48
- // Evaluate #ABCDEF
49
- result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
50
- if (result) {
51
- return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16), 255];
52
- }
53
- // Evaluate #ABCDEFAF
54
- result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
55
- assert(result, `Hexadecimal color "${hex}" was not parsed correctly`);
56
- return [
57
- parseInt(result[1], 16),
58
- parseInt(result[2], 16),
59
- parseInt(result[3], 16),
60
- parseInt(result[4], 16)
61
- ];
62
- }
@@ -1,15 +0,0 @@
1
- const ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);
2
- export function getAttrValue(attr, d) {
3
- assert(typeof d === 'object', 'Expected "data" to be an object');
4
- assert(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected "attr" to be a function or string');
5
- // Is function
6
- if (typeof attr === 'function') {
7
- return attr(d);
8
- }
9
- return d.properties[attr];
10
- }
11
- export function assert(condition, message = '') {
12
- if (!condition) {
13
- throw new Error(`CARTO style error: ${message}`);
14
- }
15
- }
package/typed/utils.js DELETED
@@ -1,4 +0,0 @@
1
- import { log } from '@deck.gl/core';
2
- export function assert(condition, message) {
3
- log.assert(condition, message);
4
- }