@deck.gl/carto 8.8.3 → 8.8.4

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@deck.gl/carto",
3
3
  "description": "CARTO official integration with Deck.gl. Build geospatial applications using CARTO and Deck.gl.",
4
4
  "license": "MIT",
5
- "version": "8.8.3",
5
+ "version": "8.8.4",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -32,12 +32,12 @@
32
32
  "prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env.dev"
33
33
  },
34
34
  "dependencies": {
35
- "@loaders.gl/gis": "^3.2.0",
36
- "@loaders.gl/loader-utils": "^3.2.0",
37
- "@loaders.gl/mvt": "^3.2.0",
38
- "@loaders.gl/tiles": "^3.2.0",
39
- "@luma.gl/constants": "^8.5.14",
40
- "@math.gl/web-mercator": "^3.6.0",
35
+ "@loaders.gl/gis": "^3.2.5",
36
+ "@loaders.gl/loader-utils": "^3.2.5",
37
+ "@loaders.gl/mvt": "^3.2.5",
38
+ "@loaders.gl/tiles": "^3.2.5",
39
+ "@luma.gl/constants": "^8.5.16",
40
+ "@math.gl/web-mercator": "^3.6.2",
41
41
  "cartocolor": "^4.0.2",
42
42
  "d3-array": "^2.8.0",
43
43
  "d3-color": "^2.0.0",
@@ -48,7 +48,7 @@
48
48
  "pbf": "^3.2.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@loaders.gl/schema": "^3.2.0",
51
+ "@loaders.gl/schema": "^3.2.5",
52
52
  "@types/d3-array": "^3.0.2",
53
53
  "@types/d3-color": "^1.4.2",
54
54
  "@types/d3-scale": "^3.0.0"
@@ -61,5 +61,5 @@
61
61
  "@deck.gl/layers": "^8.0.0",
62
62
  "@loaders.gl/core": "^3.0.0"
63
63
  },
64
- "gitHead": "e31e8c1885597eed40dcc404a5b3d05265995713"
64
+ "gitHead": "faab03adb63f2e2470d9c202dd740610be2ebc22"
65
65
  }
@@ -1,18 +1,40 @@
1
1
  import {scaleThreshold} from 'd3-scale';
2
+ import {AccessorFunction} from '@deck.gl/core';
3
+ import {Feature} from 'geojson';
2
4
  import getPalette, {Color, DEFAULT_PALETTE, NULL_COLOR} from './palette';
3
5
  import {assert, AttributeSelector, getAttrValue} from './utils';
4
6
 
5
- export default function colorBins({
7
+ /**
8
+ * Helper function for quickly creating a color bins style based on `d3` `scaleThreshold`.
9
+ *
10
+ * Data values of each attribute are rounded down to the nearest value in the domain and are then
11
+ * styled with the corresponding color.
12
+ *
13
+ * @return accessor that maps objects to `Color` values
14
+ */
15
+ export default function colorBins<DataT = Feature>({
6
16
  attr,
7
17
  domain,
8
18
  colors = DEFAULT_PALETTE,
9
19
  nullColor = NULL_COLOR
10
20
  }: {
11
- attr: AttributeSelector;
21
+ /** Attribute or column to symbolize by. */
22
+ attr: AttributeSelector<DataT, number>;
23
+
24
+ /** Category list. Must be a valid list of categories. */
12
25
  domain: number[];
26
+
27
+ /**
28
+ * Color assigned to each domain value.
29
+ *
30
+ * Either Array of colors in RGBA or valid named CARTOColors palette.
31
+ * @default `PurpOr`
32
+ */
13
33
  colors?: string | Color[];
34
+
35
+ /** Color for null values. @default: [204, 204, 204] */
14
36
  nullColor?: Color;
15
- }): AttributeSelector {
37
+ }): AccessorFunction<DataT, Color> {
16
38
  assert(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
17
39
 
18
40
  const palette = typeof colors === 'string' ? getPalette(colors, domain.length + 1) : colors;
@@ -1,19 +1,43 @@
1
+ import {AccessorFunction} from '@deck.gl/core';
2
+ import {Feature} from 'geojson';
1
3
  import getPalette, {Color, DEFAULT_PALETTE, NULL_COLOR, OTHERS_COLOR} from './palette';
2
4
  import {assert, AttributeSelector, getAttrValue} from './utils';
3
5
 
4
- export default function colorCategories({
6
+ /**
7
+ * Helper function for quickly creating a color category style.
8
+ *
9
+ * Data values of each attribute listed in the domain are mapped one to one
10
+ * with corresponding colors in the range.
11
+ *
12
+ * @return accessor that maps objects to `Color` values
13
+ */
14
+ export default function colorCategories<DataT = Feature>({
5
15
  attr,
6
16
  domain,
7
17
  colors = DEFAULT_PALETTE,
8
18
  nullColor = NULL_COLOR,
9
19
  othersColor = OTHERS_COLOR
10
20
  }: {
11
- attr: AttributeSelector;
12
- domain: number[];
21
+ /** Attribute or column to symbolize by */
22
+ attr: string | AttributeSelector<DataT, number | string>;
23
+
24
+ /** Category list. Must be a valid list of categories. */
25
+ domain: number[] | string[];
26
+
27
+ /**
28
+ * Color assigned to each domain value.
29
+ *
30
+ * Either Array of colors in RGBA or valid named CARTOColors palette.
31
+ * @default `PurpOr`
32
+ */
13
33
  colors: string | Color[];
34
+
35
+ /** Color for null values. @default: [204, 204, 204] */
14
36
  nullColor?: Color;
37
+
38
+ /** Fallback color for a category not correctly assigned. @default: [119, 119, 119] */
15
39
  othersColor?: Color;
16
- }): AttributeSelector {
40
+ }): AccessorFunction<DataT, Color> {
17
41
  assert(Array.isArray(domain), 'Expected "domain" to be an array of numbers or strings');
18
42
 
19
43
  const colorsByCategory = {};
@@ -1,18 +1,40 @@
1
+ import {AccessorFunction} from '@deck.gl/core';
1
2
  import {scaleLinear} from 'd3-scale';
3
+ import {Feature} from 'geojson';
2
4
  import getPalette, {Color, DEFAULT_PALETTE, NULL_COLOR} from './palette';
3
5
  import {assert, AttributeSelector, getAttrValue} from './utils';
4
6
 
5
- export default function colorContinuous({
7
+ /**
8
+ * Helper function for quickly creating a color continuous style.
9
+ *
10
+ * Data values of each field are interpolated linearly across values in the domain and
11
+ * are then styled with a blend of the corresponding color in the range.
12
+ *
13
+ * @return accessor that maps objects to `Color` values
14
+ */
15
+ export default function colorContinuous<DataT = Feature>({
6
16
  attr,
7
17
  domain,
8
18
  colors = DEFAULT_PALETTE,
9
19
  nullColor = NULL_COLOR
10
20
  }: {
11
- attr: AttributeSelector;
21
+ /** Attribute or column to symbolize by. */
22
+ attr: AttributeSelector<DataT, number>;
23
+
24
+ /** Attribute domain to define the data range. */
12
25
  domain: number[];
26
+
27
+ /**
28
+ * Color assigned to each domain value.
29
+ *
30
+ * Either Array of colors in RGBA or valid named CARTOColors palette.
31
+ * @default `PurpOr`
32
+ */
13
33
  colors?: string | Color[];
34
+
35
+ /** Color for null values. @default: [204, 204, 204]*/
14
36
  nullColor?: Color;
15
- }): AttributeSelector {
37
+ }): AccessorFunction<DataT, Color> {
16
38
  assert(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
17
39
 
18
40
  const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;
@@ -1,9 +1,13 @@
1
+ import {Feature} from 'geojson';
2
+
1
3
  const ALLOWED_ATTR_TYPES = Object.freeze(['function', 'string']);
2
4
 
3
- type Row = {properties: Record<string, unknown>};
4
- export type AttributeSelector = string | ((d: Row) => unknown);
5
+ export type AttributeSelector<DataT = Feature, OutT = any> = string | ((d: DataT) => OutT);
5
6
 
6
- export function getAttrValue(attr: AttributeSelector, d: Row): unknown {
7
+ export function getAttrValue<DataT = Feature, OutT = any>(
8
+ attr: string | AttributeSelector<DataT, OutT>,
9
+ d: DataT
10
+ ): OutT {
7
11
  assert(typeof d === 'object', 'Expected "data" to be an object');
8
12
  assert(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected "attr" to be a function or string');
9
13
 
@@ -11,7 +15,7 @@ export function getAttrValue(attr: AttributeSelector, d: Row): unknown {
11
15
  if (typeof attr === 'function') {
12
16
  return attr(d);
13
17
  }
14
- return d.properties[attr];
18
+ return (d as unknown as Feature)?.properties?.[attr] as OutT;
15
19
  }
16
20
 
17
21
  export function assert(condition, message = ''): asserts condition {
@@ -1,9 +1,28 @@
1
+ import { AccessorFunction } from '@deck.gl/core/typed';
2
+ import { Feature } from 'geojson';
1
3
  import { Color } from './palette';
2
4
  import { AttributeSelector } from './utils';
3
- export default function colorBins({ attr, domain, colors, nullColor }: {
4
- attr: AttributeSelector;
5
+ /**
6
+ * Helper function for quickly creating a color bins style based on `d3` `scaleThreshold`.
7
+ *
8
+ * Data values of each attribute are rounded down to the nearest value in the domain and are then
9
+ * styled with the corresponding color.
10
+ *
11
+ * @return accessor that maps objects to `Color` values
12
+ */
13
+ export default function colorBins<DataT = Feature>({ attr, domain, colors, nullColor }: {
14
+ /** Attribute or column to symbolize by. */
15
+ attr: AttributeSelector<DataT, number>;
16
+ /** Category list. Must be a valid list of categories. */
5
17
  domain: number[];
18
+ /**
19
+ * Color assigned to each domain value.
20
+ *
21
+ * Either Array of colors in RGBA or valid named CARTOColors palette.
22
+ * @default `PurpOr`
23
+ */
6
24
  colors?: string | Color[];
25
+ /** Color for null values. @default: [204, 204, 204] */
7
26
  nullColor?: Color;
8
- }): AttributeSelector;
27
+ }): AccessorFunction<DataT, Color>;
9
28
  //# sourceMappingURL=color-bins-style.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"color-bins-style.d.ts","sourceRoot":"","sources":["../../src/style/color-bins-style.ts"],"names":[],"mappings":"AACA,OAAmB,EAAC,KAAK,EAA8B,MAAM,WAAW,CAAC;AACzE,OAAO,EAAS,iBAAiB,EAAe,MAAM,SAAS,CAAC;AAEhE,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,IAAI,EACJ,MAAM,EACN,MAAwB,EACxB,SAAsB,EACvB,EAAE;IACD,IAAI,EAAE,iBAAiB,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,CAAC;IAC1B,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,GAAG,iBAAiB,CAWpB"}
1
+ {"version":3,"file":"color-bins-style.d.ts","sourceRoot":"","sources":["../../src/style/color-bins-style.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAChC,OAAmB,EAAC,KAAK,EAA8B,MAAM,WAAW,CAAC;AACzE,OAAO,EAAS,iBAAiB,EAAe,MAAM,SAAS,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAK,GAAG,OAAO,EAAE,EACjD,IAAI,EACJ,MAAM,EACN,MAAwB,EACxB,SAAsB,EACvB,EAAE;IACD,2CAA2C;IAC3C,IAAI,EAAE,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEvC,yDAAyD;IACzD,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,CAAC;IAE1B,uDAAuD;IACvD,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,GAAG,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAWjC"}
@@ -1,10 +1,30 @@
1
+ import { AccessorFunction } from '@deck.gl/core/typed';
2
+ import { Feature } from 'geojson';
1
3
  import { Color } from './palette';
2
4
  import { AttributeSelector } from './utils';
3
- export default function colorCategories({ attr, domain, colors, nullColor, othersColor }: {
4
- attr: AttributeSelector;
5
- domain: number[];
5
+ /**
6
+ * Helper function for quickly creating a color category style.
7
+ *
8
+ * Data values of each attribute listed in the domain are mapped one to one
9
+ * with corresponding colors in the range.
10
+ *
11
+ * @return accessor that maps objects to `Color` values
12
+ */
13
+ export default function colorCategories<DataT = Feature>({ attr, domain, colors, nullColor, othersColor }: {
14
+ /** Attribute or column to symbolize by */
15
+ attr: string | AttributeSelector<DataT, number | string>;
16
+ /** Category list. Must be a valid list of categories. */
17
+ domain: number[] | string[];
18
+ /**
19
+ * Color assigned to each domain value.
20
+ *
21
+ * Either Array of colors in RGBA or valid named CARTOColors palette.
22
+ * @default `PurpOr`
23
+ */
6
24
  colors: string | Color[];
25
+ /** Color for null values. @default: [204, 204, 204] */
7
26
  nullColor?: Color;
27
+ /** Fallback color for a category not correctly assigned. @default: [119, 119, 119] */
8
28
  othersColor?: Color;
9
- }): AttributeSelector;
29
+ }): AccessorFunction<DataT, Color>;
10
30
  //# sourceMappingURL=color-categories-style.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"color-categories-style.d.ts","sourceRoot":"","sources":["../../src/style/color-categories-style.ts"],"names":[],"mappings":"AAAA,OAAmB,EAAC,KAAK,EAA4C,MAAM,WAAW,CAAC;AACvF,OAAO,EAAS,iBAAiB,EAAe,MAAM,SAAS,CAAC;AAEhE,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,IAAI,EACJ,MAAM,EACN,MAAwB,EACxB,SAAsB,EACtB,WAA0B,EAC3B,EAAE;IACD,IAAI,EAAE,iBAAiB,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,GAAG,iBAAiB,CAgBpB"}
1
+ {"version":3,"file":"color-categories-style.d.ts","sourceRoot":"","sources":["../../src/style/color-categories-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAChC,OAAmB,EAAC,KAAK,EAA4C,MAAM,WAAW,CAAC;AACvF,OAAO,EAAS,iBAAiB,EAAe,MAAM,SAAS,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,GAAG,OAAO,EAAE,EACvD,IAAI,EACJ,MAAM,EACN,MAAwB,EACxB,SAAsB,EACtB,WAA0B,EAC3B,EAAE;IACD,0CAA0C;IAC1C,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAEzD,yDAAyD;IACzD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAE5B;;;;;OAKG;IACH,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,CAAC;IAEzB,uDAAuD;IACvD,SAAS,CAAC,EAAE,KAAK,CAAC;IAElB,sFAAsF;IACtF,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,GAAG,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAgBjC"}
@@ -1,9 +1,28 @@
1
+ import { AccessorFunction } from '@deck.gl/core/typed';
2
+ import { Feature } from 'geojson';
1
3
  import { Color } from './palette';
2
4
  import { AttributeSelector } from './utils';
3
- export default function colorContinuous({ attr, domain, colors, nullColor }: {
4
- attr: AttributeSelector;
5
+ /**
6
+ * Helper function for quickly creating a color continuous style.
7
+ *
8
+ * Data values of each field are interpolated linearly across values in the domain and
9
+ * are then styled with a blend of the corresponding color in the range.
10
+ *
11
+ * @return accessor that maps objects to `Color` values
12
+ */
13
+ export default function colorContinuous<DataT = Feature>({ attr, domain, colors, nullColor }: {
14
+ /** Attribute or column to symbolize by. */
15
+ attr: AttributeSelector<DataT, number>;
16
+ /** Attribute domain to define the data range. */
5
17
  domain: number[];
18
+ /**
19
+ * Color assigned to each domain value.
20
+ *
21
+ * Either Array of colors in RGBA or valid named CARTOColors palette.
22
+ * @default `PurpOr`
23
+ */
6
24
  colors?: string | Color[];
25
+ /** Color for null values. @default: [204, 204, 204]*/
7
26
  nullColor?: Color;
8
- }): AttributeSelector;
27
+ }): AccessorFunction<DataT, Color>;
9
28
  //# sourceMappingURL=color-continuous-style.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"color-continuous-style.d.ts","sourceRoot":"","sources":["../../src/style/color-continuous-style.ts"],"names":[],"mappings":"AACA,OAAmB,EAAC,KAAK,EAA8B,MAAM,WAAW,CAAC;AACzE,OAAO,EAAS,iBAAiB,EAAe,MAAM,SAAS,CAAC;AAEhE,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,IAAI,EACJ,MAAM,EACN,MAAwB,EACxB,SAAsB,EACvB,EAAE;IACD,IAAI,EAAE,iBAAiB,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,CAAC;IAC1B,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,GAAG,iBAAiB,CAUpB"}
1
+ {"version":3,"file":"color-continuous-style.d.ts","sourceRoot":"","sources":["../../src/style/color-continuous-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAChC,OAAmB,EAAC,KAAK,EAA8B,MAAM,WAAW,CAAC;AACzE,OAAO,EAAS,iBAAiB,EAAe,MAAM,SAAS,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,GAAG,OAAO,EAAE,EACvD,IAAI,EACJ,MAAM,EACN,MAAwB,EACxB,SAAsB,EACvB,EAAE;IACD,2CAA2C;IAC3C,IAAI,EAAE,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEvC,iDAAiD;IACjD,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,CAAC;IAE1B,sDAAsD;IACtD,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,GAAG,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAUjC"}
@@ -1,8 +1,5 @@
1
- declare type Row = {
2
- properties: Record<string, unknown>;
3
- };
4
- export declare type AttributeSelector = string | ((d: Row) => unknown);
5
- export declare function getAttrValue(attr: AttributeSelector, d: Row): unknown;
1
+ import { Feature } from 'geojson';
2
+ export declare 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;
6
4
  export declare function assert(condition: any, message?: string): asserts condition;
7
- export {};
8
5
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/style/utils.ts"],"names":[],"mappings":"AAEA,aAAK,GAAG,GAAG;IAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAC,CAAC;AACjD,oBAAY,iBAAiB,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC;AAE/D,wBAAgB,YAAY,CAAC,IAAI,EAAE,iBAAiB,EAAE,CAAC,EAAE,GAAG,GAAG,OAAO,CASrE;AAED,wBAAgB,MAAM,CAAC,SAAS,KAAA,EAAE,OAAO,SAAK,GAAG,OAAO,CAAC,SAAS,CAIjE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/style/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAIhC,oBAAY,iBAAiB,CAAC,KAAK,GAAG,OAAO,EAAE,IAAI,GAAG,GAAG,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC;AAE3F,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,GACP,IAAI,CASN;AAED,wBAAgB,MAAM,CAAC,SAAS,KAAA,EAAE,OAAO,SAAK,GAAG,OAAO,CAAC,SAAS,CAIjE"}