@deck.gl/carto 8.7.0-beta.5 → 8.7.0-beta.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.
- package/dist/dist.dev.js +379 -326
- package/dist/es5/api/index.js.map +1 -1
- package/dist/es5/api/layer-map.js +8 -8
- package/dist/es5/api/layer-map.js.map +1 -1
- package/dist/es5/api/maps-api-common.js +15 -1
- package/dist/es5/api/maps-api-common.js.map +1 -1
- package/dist/es5/api/maps-client.js +15 -18
- package/dist/es5/api/maps-client.js.map +1 -1
- package/dist/es5/api/maps-v3-client.js +234 -176
- package/dist/es5/api/maps-v3-client.js.map +1 -1
- package/dist/es5/api/parseMap.js +5 -8
- package/dist/es5/api/parseMap.js.map +1 -1
- package/dist/es5/basemap.js +7 -7
- package/dist/es5/basemap.js.map +1 -1
- package/dist/es5/config.js.map +1 -1
- package/dist/es5/index.js +4 -4
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/layers/carto-layer.js +2 -2
- package/dist/es5/layers/carto-layer.js.map +1 -1
- package/dist/es5/layers/{carto-dynamic-tile-layer.js → carto-tile-layer.js} +23 -23
- package/dist/es5/layers/carto-tile-layer.js.map +1 -0
- package/dist/es5/layers/schema/{carto-dynamic-tile.js → carto-tile.js} +1 -1
- package/dist/es5/layers/schema/carto-tile.js.map +1 -0
- package/dist/es5/style/color-bins-style.js +1 -1
- package/dist/es5/style/color-bins-style.js.map +1 -1
- package/dist/es5/style/color-categories-style.js +1 -1
- package/dist/es5/style/color-categories-style.js.map +1 -1
- package/dist/es5/style/color-continuous-style.js +1 -1
- package/dist/es5/style/color-continuous-style.js.map +1 -1
- package/dist/es5/style/palette.js +1 -6
- package/dist/es5/style/palette.js.map +1 -1
- package/dist/es5/style/utils.js +2 -6
- package/dist/es5/style/utils.js.map +1 -1
- package/dist/es5/utils.js +13 -0
- package/dist/es5/utils.js.map +1 -0
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/layer-map.js +5 -4
- package/dist/esm/api/layer-map.js.map +1 -1
- package/dist/esm/api/maps-api-common.js +14 -0
- package/dist/esm/api/maps-api-common.js.map +1 -1
- package/dist/esm/api/maps-client.js +6 -10
- package/dist/esm/api/maps-client.js.map +1 -1
- package/dist/esm/api/maps-v3-client.js +68 -37
- package/dist/esm/api/maps-v3-client.js.map +1 -1
- package/dist/esm/api/parseMap.js +4 -3
- package/dist/esm/api/parseMap.js.map +1 -1
- package/dist/esm/basemap.js +7 -7
- package/dist/esm/basemap.js.map +1 -1
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/layers/carto-layer.js +2 -2
- package/dist/esm/layers/carto-layer.js.map +1 -1
- package/dist/esm/layers/{carto-dynamic-tile-layer.js → carto-tile-layer.js} +15 -15
- package/dist/esm/layers/carto-tile-layer.js.map +1 -0
- package/dist/esm/layers/schema/{carto-dynamic-tile.js → carto-tile.js} +1 -1
- package/dist/esm/layers/schema/carto-tile.js.map +1 -0
- package/dist/esm/style/color-bins-style.js +1 -1
- package/dist/esm/style/color-bins-style.js.map +1 -1
- package/dist/esm/style/color-categories-style.js +1 -1
- package/dist/esm/style/color-categories-style.js.map +1 -1
- package/dist/esm/style/color-continuous-style.js +1 -1
- package/dist/esm/style/color-continuous-style.js.map +1 -1
- package/dist/esm/style/palette.js +1 -6
- package/dist/esm/style/palette.js.map +1 -1
- package/dist/esm/style/utils.js +2 -6
- package/dist/esm/style/utils.js.map +1 -1
- package/dist/esm/utils.js +5 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist.min.js +2 -2
- package/package.json +8 -2
- package/src/api/{index.js → index.ts} +0 -0
- package/src/api/{layer-map.js → layer-map.ts} +25 -14
- package/src/api/maps-api-common.ts +76 -0
- package/src/api/{maps-client.js → maps-client.ts} +55 -20
- package/src/api/{maps-v3-client.js → maps-v3-client.ts} +143 -56
- package/src/api/{parseMap.js → parseMap.ts} +7 -6
- package/src/basemap.ts +10 -0
- package/src/{config.js → config.ts} +22 -6
- package/src/{index.js → index.ts} +2 -2
- package/src/layers/carto-layer.js +2 -2
- package/src/layers/{carto-dynamic-tile-layer.js → carto-tile-layer.js} +13 -13
- package/src/layers/schema/{carto-dynamic-tile.js → carto-tile.js} +0 -0
- package/src/style/color-bins-style.ts +26 -0
- package/src/style/{color-categories-style.js → color-categories-style.ts} +10 -4
- package/src/style/color-continuous-style.ts +25 -0
- package/src/style/{palette.js → palette.ts} +18 -15
- package/src/style/{utils.js → utils.ts} +7 -10
- package/src/utils.ts +5 -0
- package/dist/es5/layers/carto-dynamic-tile-layer.js.map +0 -1
- package/dist/es5/layers/schema/carto-dynamic-tile.js.map +0 -1
- package/dist/esm/layers/carto-dynamic-tile-layer.js.map +0 -1
- package/dist/esm/layers/schema/carto-dynamic-tile.js.map +0 -1
- package/src/api/maps-api-common.js +0 -41
- package/src/basemap.js +0 -10
- package/src/style/color-bins-style.js +0 -21
- package/src/style/color-continuous-style.js +0 -20
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.7.0-beta.
|
|
5
|
+
"version": "8.7.0-beta.6",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@loaders.gl/loader-utils": "^3.1.5",
|
|
36
36
|
"@loaders.gl/mvt": "^3.1.5",
|
|
37
37
|
"@loaders.gl/tiles": "^3.1.5",
|
|
38
|
+
"@luma.gl/constants": "^8.5.10",
|
|
38
39
|
"@math.gl/web-mercator": "^3.5.7",
|
|
39
40
|
"cartocolor": "^4.0.2",
|
|
40
41
|
"d3-array": "^2.8.0",
|
|
@@ -44,11 +45,16 @@
|
|
|
44
45
|
"moment-timezone": "^0.5.33",
|
|
45
46
|
"pbf": "^3.2.1"
|
|
46
47
|
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/d3-array": "^3.0.2",
|
|
50
|
+
"@types/d3-color": "^1.4.2",
|
|
51
|
+
"@types/d3-scale": "^3.0.0"
|
|
52
|
+
},
|
|
47
53
|
"peerDependencies": {
|
|
48
54
|
"@deck.gl/core": "^8.0.0",
|
|
49
55
|
"@deck.gl/geo-layers": "^8.0.0",
|
|
50
56
|
"@deck.gl/layers": "^8.0.0",
|
|
51
57
|
"@loaders.gl/core": "^3.1.5"
|
|
52
58
|
},
|
|
53
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "d6eefe2e0992999416b2362340f86402b1f25b33"
|
|
54
60
|
}
|
|
File without changes
|
|
@@ -11,10 +11,11 @@ import {
|
|
|
11
11
|
} from 'd3-scale';
|
|
12
12
|
import {format as d3Format} from 'd3-format';
|
|
13
13
|
import moment from 'moment-timezone';
|
|
14
|
-
import {log} from '@deck.gl/core';
|
|
15
14
|
import {H3HexagonLayer, MVTLayer} from '@deck.gl/geo-layers';
|
|
16
15
|
import {GeoJsonLayer} from '@deck.gl/layers';
|
|
17
|
-
import
|
|
16
|
+
import CartoTileLayer from '../layers/carto-tile-layer';
|
|
17
|
+
import {TILE_FORMATS} from './maps-api-common';
|
|
18
|
+
import {assert} from '../utils';
|
|
18
19
|
|
|
19
20
|
const SCALE_FUNCS = {
|
|
20
21
|
linear: scaleLinear,
|
|
@@ -25,6 +26,7 @@ const SCALE_FUNCS = {
|
|
|
25
26
|
quantize: scaleQuantize,
|
|
26
27
|
sqrt: scaleSqrt
|
|
27
28
|
};
|
|
29
|
+
export type SCALE_TYPE = keyof typeof SCALE_FUNCS;
|
|
28
30
|
|
|
29
31
|
// Kepler -> Deck.gl
|
|
30
32
|
const sharedPropMap = {
|
|
@@ -64,7 +66,11 @@ function mergePropMaps(a, b) {
|
|
|
64
66
|
return {...a, ...b, visConfig: {...a.visConfig, ...b.visConfig}};
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
export function getLayer(
|
|
69
|
+
export function getLayer(
|
|
70
|
+
type: string,
|
|
71
|
+
config,
|
|
72
|
+
dataset
|
|
73
|
+
): {Layer: any; propMap: any; defaultProps: any} {
|
|
68
74
|
if (type === 'mvt' || type === 'tileset') {
|
|
69
75
|
return getTileLayer(dataset);
|
|
70
76
|
}
|
|
@@ -92,8 +98,7 @@ export function getLayer(type, config, dataset) {
|
|
|
92
98
|
}
|
|
93
99
|
}[type];
|
|
94
100
|
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
assert(layer, `Unsupported layer type: ${type}`);
|
|
97
102
|
return layer;
|
|
98
103
|
}
|
|
99
104
|
|
|
@@ -107,7 +112,7 @@ function getTileLayer(dataset) {
|
|
|
107
112
|
const formatTiles = new URL(tileUrl).searchParams.get('formatTiles') || TILE_FORMATS.MVT;
|
|
108
113
|
|
|
109
114
|
return {
|
|
110
|
-
Layer: formatTiles === TILE_FORMATS.MVT ? MVTLayer :
|
|
115
|
+
Layer: formatTiles === TILE_FORMATS.MVT ? MVTLayer : CartoTileLayer,
|
|
111
116
|
propMap: sharedPropMap,
|
|
112
117
|
defaultProps: {
|
|
113
118
|
...defaultProps,
|
|
@@ -119,7 +124,7 @@ function getTileLayer(dataset) {
|
|
|
119
124
|
};
|
|
120
125
|
}
|
|
121
126
|
|
|
122
|
-
function domainFromAttribute(attribute, scaleType) {
|
|
127
|
+
function domainFromAttribute(attribute, scaleType: SCALE_TYPE) {
|
|
123
128
|
if (scaleType === 'ordinal' || scaleType === 'point') {
|
|
124
129
|
return attribute.categories.map(c => c.category).filter(c => c !== undefined && c !== null);
|
|
125
130
|
}
|
|
@@ -131,13 +136,13 @@ function domainFromAttribute(attribute, scaleType) {
|
|
|
131
136
|
return [min, attribute.max];
|
|
132
137
|
}
|
|
133
138
|
|
|
134
|
-
function domainFromValues(values, scaleType) {
|
|
139
|
+
function domainFromValues(values, scaleType: SCALE_TYPE) {
|
|
135
140
|
if (scaleType === 'ordinal') {
|
|
136
141
|
return [...new Set(values)].sort();
|
|
137
142
|
} else if (scaleType === 'quantile') {
|
|
138
143
|
return values.sort((a, b) => a - b);
|
|
139
144
|
} else if (scaleType === 'log') {
|
|
140
|
-
const [d0, d1] = extent(values);
|
|
145
|
+
const [d0, d1] = extent(values as number[]);
|
|
141
146
|
return [d0 === 0 ? 1e-5 : d0, d1];
|
|
142
147
|
}
|
|
143
148
|
return extent(values);
|
|
@@ -171,8 +176,14 @@ function normalizeAccessor(accessor, data) {
|
|
|
171
176
|
return accessor;
|
|
172
177
|
}
|
|
173
178
|
|
|
174
|
-
export function getColorAccessor(
|
|
175
|
-
|
|
179
|
+
export function getColorAccessor(
|
|
180
|
+
{name},
|
|
181
|
+
scaleType: SCALE_TYPE,
|
|
182
|
+
{colors},
|
|
183
|
+
opacity: number | undefined,
|
|
184
|
+
data: any
|
|
185
|
+
) {
|
|
186
|
+
const scale = SCALE_FUNCS[scaleType as any]();
|
|
176
187
|
scale.domain(calculateDomain(data, name, scaleType));
|
|
177
188
|
scale.range(colors);
|
|
178
189
|
const alpha = opacity !== undefined ? Math.round(255 * Math.pow(opacity, 1 / 2.2)) : 255;
|
|
@@ -184,8 +195,8 @@ export function getColorAccessor({name}, scaleType, {colors}, opacity, data) {
|
|
|
184
195
|
return normalizeAccessor(accessor, data);
|
|
185
196
|
}
|
|
186
197
|
|
|
187
|
-
export function getSizeAccessor({name}, scaleType, range
|
|
188
|
-
const scale = SCALE_FUNCS[scaleType]();
|
|
198
|
+
export function getSizeAccessor({name}, scaleType: SCALE_TYPE, range: Iterable<Range>, data: any) {
|
|
199
|
+
const scale = SCALE_FUNCS[scaleType as any]();
|
|
189
200
|
scale.domain(calculateDomain(data, name, scaleType));
|
|
190
201
|
scale.range(range);
|
|
191
202
|
|
|
@@ -195,7 +206,7 @@ export function getSizeAccessor({name}, scaleType, range, data) {
|
|
|
195
206
|
return normalizeAccessor(accessor, data);
|
|
196
207
|
}
|
|
197
208
|
|
|
198
|
-
const FORMATS = {
|
|
209
|
+
const FORMATS: Record<string, (value: any) => string> = {
|
|
199
210
|
date: s => moment.utc(s).format('MM/DD/YY HH:mm:ssa'),
|
|
200
211
|
integer: d3Format('i'),
|
|
201
212
|
float: d3Format('.5f'),
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export const DEFAULT_USER_COMPONENT_IN_URL = '{user}';
|
|
2
|
+
export const DEFAULT_REGION_COMPONENT_IN_URL = '{region}';
|
|
3
|
+
|
|
4
|
+
export type ValuesOf<T extends {}> = T[keyof T];
|
|
5
|
+
export const API_VERSIONS = {
|
|
6
|
+
V1: 'v1',
|
|
7
|
+
V2: 'v2',
|
|
8
|
+
V3: 'v3'
|
|
9
|
+
} as const;
|
|
10
|
+
export type ApiVersion = ValuesOf<typeof API_VERSIONS>;
|
|
11
|
+
|
|
12
|
+
export const DEFAULT_MAPS_URL_FORMAT = {
|
|
13
|
+
[API_VERSIONS.V1]: `https://${DEFAULT_USER_COMPONENT_IN_URL}.carto.com/api/v1/map`,
|
|
14
|
+
[API_VERSIONS.V2]: `https://maps-api-v2.${DEFAULT_REGION_COMPONENT_IN_URL}.carto.com/user/${DEFAULT_USER_COMPONENT_IN_URL}`
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
export const MAP_TYPES = {
|
|
18
|
+
QUERY: 'query',
|
|
19
|
+
TABLE: 'table',
|
|
20
|
+
TILESET: 'tileset'
|
|
21
|
+
} as const;
|
|
22
|
+
export type MapType = ValuesOf<typeof MAP_TYPES>;
|
|
23
|
+
|
|
24
|
+
// AVAILABLE FORMATS
|
|
25
|
+
export const FORMATS = {
|
|
26
|
+
GEOJSON: 'geojson',
|
|
27
|
+
NDJSON: 'ndjson',
|
|
28
|
+
TILEJSON: 'tilejson',
|
|
29
|
+
JSON: 'json'
|
|
30
|
+
} as const;
|
|
31
|
+
export type Format = ValuesOf<typeof FORMATS>;
|
|
32
|
+
|
|
33
|
+
// AVAILABLE FORMATS FOR TILES
|
|
34
|
+
export const TILE_FORMATS = {
|
|
35
|
+
MVT: 'mvt',
|
|
36
|
+
GEOJSON: 'geojson',
|
|
37
|
+
BINARY: 'binary'
|
|
38
|
+
} as const;
|
|
39
|
+
export type TileFormat = ValuesOf<typeof TILE_FORMATS>;
|
|
40
|
+
|
|
41
|
+
export enum SchemaFieldType {
|
|
42
|
+
Number = 'number',
|
|
43
|
+
Bigint = 'bigint',
|
|
44
|
+
String = 'string',
|
|
45
|
+
Geometry = 'geometry',
|
|
46
|
+
Timestamp = 'timestamp',
|
|
47
|
+
Object = 'object',
|
|
48
|
+
Boolean = 'boolean',
|
|
49
|
+
Variant = 'variant',
|
|
50
|
+
Unknown = 'unknown'
|
|
51
|
+
}
|
|
52
|
+
export interface SchemaField {
|
|
53
|
+
name: string;
|
|
54
|
+
type: SchemaFieldType; // Field type in the CARTO stack, common for all providers
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface MapInstantiation extends MapInstantiationFormats {
|
|
58
|
+
nrows: number;
|
|
59
|
+
size?: number;
|
|
60
|
+
schema?: SchemaField[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
type MapInstantiationFormats = Record<
|
|
64
|
+
Format,
|
|
65
|
+
{
|
|
66
|
+
url: string[];
|
|
67
|
+
error?: any;
|
|
68
|
+
}
|
|
69
|
+
>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Simple encode parameter
|
|
73
|
+
*/
|
|
74
|
+
export function encodeParameter(name: string, value: string | boolean | number): string {
|
|
75
|
+
return `${name}=${encodeURIComponent(value)}`;
|
|
76
|
+
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Maps API Client for Maps API v1 and Maps API v2
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ClassicCredentials,
|
|
6
|
+
defaultClassicCredentials,
|
|
7
|
+
defaultCloudNativeCredentials,
|
|
8
|
+
getDefaultCredentials
|
|
9
|
+
} from '../config';
|
|
5
10
|
import {
|
|
6
11
|
API_VERSIONS,
|
|
7
12
|
DEFAULT_MAPS_URL_FORMAT,
|
|
8
13
|
DEFAULT_REGION_COMPONENT_IN_URL,
|
|
9
14
|
DEFAULT_USER_COMPONENT_IN_URL,
|
|
10
15
|
encodeParameter,
|
|
16
|
+
MapType,
|
|
11
17
|
MAP_TYPES
|
|
12
18
|
} from './maps-api-common';
|
|
13
19
|
|
|
@@ -22,24 +28,29 @@ const TILE_EXTENT = 4096;
|
|
|
22
28
|
/**
|
|
23
29
|
* Obtain a TileJson from Maps API v1 and v2
|
|
24
30
|
*/
|
|
25
|
-
export async function getDataV2({
|
|
31
|
+
export async function getDataV2({
|
|
32
|
+
type,
|
|
33
|
+
source,
|
|
34
|
+
credentials
|
|
35
|
+
}: {
|
|
36
|
+
type: MapType;
|
|
37
|
+
source: string;
|
|
38
|
+
credentials?: Partial<ClassicCredentials>;
|
|
39
|
+
}) {
|
|
26
40
|
const defaultCredentials = getDefaultCredentials();
|
|
27
|
-
const apiVersion =
|
|
41
|
+
const apiVersion = credentials?.apiVersion || defaultCredentials.apiVersion;
|
|
28
42
|
// Only pick up default credentials if they have been defined for
|
|
29
43
|
// correct API version
|
|
30
44
|
const localCreds = {
|
|
31
|
-
...defaultClassicCredentials,
|
|
45
|
+
...(apiVersion === API_VERSIONS.V3 ? defaultCloudNativeCredentials : defaultClassicCredentials),
|
|
46
|
+
mapsUrl: DEFAULT_MAPS_URL_FORMAT[apiVersion],
|
|
32
47
|
...(defaultCredentials.apiVersion === apiVersion && defaultCredentials),
|
|
33
48
|
...credentials
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!localCreds.mapsUrl) {
|
|
37
|
-
localCreds.mapsUrl = DEFAULT_MAPS_URL_FORMAT[apiVersion];
|
|
38
|
-
}
|
|
49
|
+
} as unknown as Required<ClassicCredentials>;
|
|
39
50
|
|
|
40
|
-
let url;
|
|
51
|
+
let url: string;
|
|
41
52
|
|
|
42
|
-
const connection = type ===
|
|
53
|
+
const connection = type === MAP_TYPES.TILESET ? CONNECTIONS.BIGQUERY : CONNECTIONS.CARTO;
|
|
43
54
|
|
|
44
55
|
switch (apiVersion) {
|
|
45
56
|
case API_VERSIONS.V1:
|
|
@@ -64,12 +75,11 @@ export async function getDataV2({type, source, credentials}) {
|
|
|
64
75
|
/**
|
|
65
76
|
* Request against Maps API
|
|
66
77
|
*/
|
|
67
|
-
async function request({url, credentials}) {
|
|
78
|
+
async function request({url, credentials}: {url: string; credentials: ClassicCredentials}) {
|
|
68
79
|
let response;
|
|
69
80
|
|
|
70
81
|
try {
|
|
71
82
|
/* global fetch */
|
|
72
|
-
/* eslint no-undef: "error" */
|
|
73
83
|
response = await fetch(url, {
|
|
74
84
|
headers: {
|
|
75
85
|
Accept: 'application/json'
|
|
@@ -91,7 +101,15 @@ async function request({url, credentials}) {
|
|
|
91
101
|
/**
|
|
92
102
|
* Display proper message from Maps API error
|
|
93
103
|
*/
|
|
94
|
-
function dealWithError({
|
|
104
|
+
function dealWithError({
|
|
105
|
+
response,
|
|
106
|
+
json,
|
|
107
|
+
credentials
|
|
108
|
+
}: {
|
|
109
|
+
response: Response;
|
|
110
|
+
json: any;
|
|
111
|
+
credentials: ClassicCredentials;
|
|
112
|
+
}) {
|
|
95
113
|
switch (response.status) {
|
|
96
114
|
case 401:
|
|
97
115
|
throw new Error(
|
|
@@ -109,22 +127,38 @@ function dealWithError({response, json, credentials}) {
|
|
|
109
127
|
}
|
|
110
128
|
}
|
|
111
129
|
|
|
112
|
-
function initURLParameters(credentials) {
|
|
130
|
+
function initURLParameters(credentials: ClassicCredentials): string[] {
|
|
113
131
|
const encodedApiKey = encodeParameter('api_key', credentials.apiKey);
|
|
114
|
-
const encodedClient = encodeParameter('client',
|
|
132
|
+
const encodedClient = encodeParameter('client', 'deck-gl-carto');
|
|
115
133
|
return [encodedApiKey, encodedClient];
|
|
116
134
|
}
|
|
117
135
|
|
|
118
136
|
/**
|
|
119
137
|
* Build a URL with all required parameters
|
|
120
138
|
*/
|
|
121
|
-
function buildURLMapsAPIv1({
|
|
139
|
+
function buildURLMapsAPIv1({
|
|
140
|
+
mapConfig,
|
|
141
|
+
credentials
|
|
142
|
+
}: {
|
|
143
|
+
mapConfig: unknown;
|
|
144
|
+
credentials: Required<ClassicCredentials>;
|
|
145
|
+
}): string {
|
|
122
146
|
const parameters = initURLParameters(credentials);
|
|
123
147
|
const cfg = JSON.stringify(mapConfig);
|
|
124
148
|
return `${mapsUrl(credentials)}?${parameters.join('&')}&${encodeParameter('config', cfg)}`;
|
|
125
149
|
}
|
|
126
150
|
|
|
127
|
-
function buildURLMapsAPIv2({
|
|
151
|
+
function buildURLMapsAPIv2({
|
|
152
|
+
connection,
|
|
153
|
+
type,
|
|
154
|
+
source,
|
|
155
|
+
credentials
|
|
156
|
+
}: {
|
|
157
|
+
connection: string;
|
|
158
|
+
type: MapType;
|
|
159
|
+
source: string;
|
|
160
|
+
credentials: Required<ClassicCredentials>;
|
|
161
|
+
}): string {
|
|
128
162
|
const parameters = initURLParameters(credentials);
|
|
129
163
|
// Query type is mapped to 'sql' at maps api v1
|
|
130
164
|
const mapsApiType = type === MAP_TYPES.QUERY ? 'sql' : type;
|
|
@@ -136,13 +170,13 @@ function buildURLMapsAPIv2({connection, type, source, credentials}) {
|
|
|
136
170
|
/**
|
|
137
171
|
* Prepare a url valid for the specified user
|
|
138
172
|
*/
|
|
139
|
-
function mapsUrl(credentials) {
|
|
173
|
+
function mapsUrl(credentials: Required<ClassicCredentials>) {
|
|
140
174
|
return credentials.mapsUrl
|
|
141
175
|
.replace(DEFAULT_USER_COMPONENT_IN_URL, credentials.username)
|
|
142
176
|
.replace(DEFAULT_REGION_COMPONENT_IN_URL, credentials.region);
|
|
143
177
|
}
|
|
144
178
|
|
|
145
|
-
function createMapConfig(sql) {
|
|
179
|
+
function createMapConfig(sql: string) {
|
|
146
180
|
return {
|
|
147
181
|
version: '1.3.1',
|
|
148
182
|
buffersize: {
|
|
@@ -153,6 +187,7 @@ function createMapConfig(sql) {
|
|
|
153
187
|
type: 'mapnik',
|
|
154
188
|
options: {
|
|
155
189
|
sql,
|
|
190
|
+
// eslint-disable-next-line camelcase
|
|
156
191
|
vector_extent: TILE_EXTENT
|
|
157
192
|
}
|
|
158
193
|
}
|