@deck.gl/carto 8.8.3 → 8.8.6

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 (96) hide show
  1. package/dist/dist.dev.js +1382 -1153
  2. package/dist/es5/api/index.js.map +1 -1
  3. package/dist/es5/api/layer-map.js +104 -17
  4. package/dist/es5/api/layer-map.js.map +1 -1
  5. package/dist/es5/api/maps-api-common.js.map +1 -1
  6. package/dist/es5/api/maps-v3-client.js +213 -47
  7. package/dist/es5/api/maps-v3-client.js.map +1 -1
  8. package/dist/es5/api/parseMap.js +14 -4
  9. package/dist/es5/api/parseMap.js.map +1 -1
  10. package/dist/es5/config.js +11 -2
  11. package/dist/es5/config.js.map +1 -1
  12. package/dist/es5/index.js.map +1 -1
  13. package/dist/es5/layers/carto-layer.js +10 -23
  14. package/dist/es5/layers/carto-layer.js.map +1 -1
  15. package/dist/es5/style/color-bins-style.js.map +1 -1
  16. package/dist/es5/style/color-categories-style.js.map +1 -1
  17. package/dist/es5/style/color-continuous-style.js.map +1 -1
  18. package/dist/es5/style/utils.js +3 -1
  19. package/dist/es5/style/utils.js.map +1 -1
  20. package/dist/esm/api/index.js.map +1 -1
  21. package/dist/esm/api/layer-map.js +79 -14
  22. package/dist/esm/api/layer-map.js.map +1 -1
  23. package/dist/esm/api/maps-api-common.js.map +1 -1
  24. package/dist/esm/api/maps-v3-client.js +111 -11
  25. package/dist/esm/api/maps-v3-client.js.map +1 -1
  26. package/dist/esm/api/parseMap.js +18 -4
  27. package/dist/esm/api/parseMap.js.map +1 -1
  28. package/dist/esm/config.js +10 -2
  29. package/dist/esm/config.js.map +1 -1
  30. package/dist/esm/index.js.map +1 -1
  31. package/dist/esm/layers/carto-layer.js +7 -19
  32. package/dist/esm/layers/carto-layer.js.map +1 -1
  33. package/dist/esm/style/color-bins-style.js.map +1 -1
  34. package/dist/esm/style/color-categories-style.js.map +1 -1
  35. package/dist/esm/style/color-continuous-style.js.map +1 -1
  36. package/dist/esm/style/utils.js +3 -1
  37. package/dist/esm/style/utils.js.map +1 -1
  38. package/dist.min.js +138 -138
  39. package/package.json +9 -9
  40. package/src/api/index.ts +1 -0
  41. package/src/api/layer-map.ts +76 -13
  42. package/src/api/maps-api-common.ts +8 -0
  43. package/src/api/maps-v3-client.ts +116 -12
  44. package/src/api/parseMap.ts +6 -2
  45. package/src/config.ts +12 -2
  46. package/src/index.ts +1 -1
  47. package/src/layers/carto-layer.ts +19 -32
  48. package/src/style/color-bins-style.ts +25 -3
  49. package/src/style/color-categories-style.ts +28 -4
  50. package/src/style/color-continuous-style.ts +25 -3
  51. package/src/style/utils.ts +8 -4
  52. package/typed/api/index.d.ts +1 -0
  53. package/typed/api/index.d.ts.map +1 -1
  54. package/typed/api/layer-map.d.ts +12 -4
  55. package/typed/api/layer-map.d.ts.map +1 -1
  56. package/typed/api/maps-api-common.d.ts +4 -0
  57. package/typed/api/maps-api-common.d.ts.map +1 -1
  58. package/typed/api/maps-v3-client.d.ts +4 -3
  59. package/typed/api/maps-v3-client.d.ts.map +1 -1
  60. package/typed/config.d.ts +2 -0
  61. package/typed/config.d.ts.map +1 -1
  62. package/typed/index.d.ts +1 -0
  63. package/typed/index.d.ts.map +1 -1
  64. package/typed/layers/carto-layer.d.ts +5 -8
  65. package/typed/layers/carto-layer.d.ts.map +1 -1
  66. package/typed/style/color-bins-style.d.ts +22 -3
  67. package/typed/style/color-bins-style.d.ts.map +1 -1
  68. package/typed/style/color-categories-style.d.ts +24 -4
  69. package/typed/style/color-categories-style.d.ts.map +1 -1
  70. package/typed/style/color-continuous-style.d.ts +22 -3
  71. package/typed/style/color-continuous-style.d.ts.map +1 -1
  72. package/typed/style/utils.d.ts +3 -6
  73. package/typed/style/utils.d.ts.map +1 -1
  74. package/typed/api/index.js +0 -3
  75. package/typed/api/layer-map.js +0 -264
  76. package/typed/api/maps-api-common.js +0 -50
  77. package/typed/api/maps-client.js +0 -125
  78. package/typed/api/maps-v3-client.js +0 -304
  79. package/typed/api/parseMap.js +0 -178
  80. package/typed/basemap.js +0 -9
  81. package/typed/config.js +0 -35
  82. package/typed/index.js +0 -10
  83. package/typed/layers/carto-layer.js +0 -173
  84. package/typed/layers/carto-tile-layer.js +0 -105
  85. package/typed/layers/h3-tile-layer.js +0 -47
  86. package/typed/layers/h3-tileset-2d.js +0 -85
  87. package/typed/layers/quadkey-tile-layer.js +0 -42
  88. package/typed/layers/quadkey-tileset-2d.js +0 -36
  89. package/typed/layers/schema/carto-tile.js +0 -161
  90. package/typed/layers/spatial-index-tile-layer.js +0 -40
  91. package/typed/style/color-bins-style.js +0 -12
  92. package/typed/style/color-categories-style.js +0 -16
  93. package/typed/style/color-continuous-style.js +0 -12
  94. package/typed/style/palette.js +0 -62
  95. package/typed/style/utils.js +0 -15
  96. package/typed/utils.js +0 -4
@@ -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
- }