@deck.gl/carto 8.7.0-beta.5 → 8.7.0
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 +398 -343
- 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 +237 -177
- 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 +20 -18
- package/dist/es5/layers/carto-layer.js.map +1 -1
- package/dist/es5/layers/{carto-dynamic-tile-layer.js → carto-tile-layer.js} +24 -24
- 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 +72 -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 +15 -17
- package/dist/esm/layers/carto-layer.js.map +1 -1
- package/dist/esm/layers/{carto-dynamic-tile-layer.js → carto-tile-layer.js} +16 -16
- 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 +4 -4
- 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} +146 -57
- 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 +13 -12
- package/src/layers/{carto-dynamic-tile-layer.js → carto-tile-layer.js} +14 -14
- 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
|
@@ -24,6 +24,8 @@ var _parseMap = require("./parseMap");
|
|
|
24
24
|
|
|
25
25
|
var _core = require("@deck.gl/core");
|
|
26
26
|
|
|
27
|
+
var _utils = require("../utils");
|
|
28
|
+
|
|
27
29
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
28
30
|
|
|
29
31
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -37,12 +39,12 @@ function request(_x) {
|
|
|
37
39
|
|
|
38
40
|
function _request() {
|
|
39
41
|
_request = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(_ref) {
|
|
40
|
-
var method, url,
|
|
42
|
+
var method, url, accessToken, body, headers;
|
|
41
43
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
42
44
|
while (1) {
|
|
43
45
|
switch (_context.prev = _context.next) {
|
|
44
46
|
case 0:
|
|
45
|
-
method = _ref.method, url = _ref.url,
|
|
47
|
+
method = _ref.method, url = _ref.url, accessToken = _ref.accessToken, body = _ref.body;
|
|
46
48
|
headers = {
|
|
47
49
|
Accept: 'application/json'
|
|
48
50
|
};
|
|
@@ -64,9 +66,7 @@ function _request() {
|
|
|
64
66
|
});
|
|
65
67
|
|
|
66
68
|
case 7:
|
|
67
|
-
|
|
68
|
-
_context.next = 13;
|
|
69
|
-
break;
|
|
69
|
+
return _context.abrupt("return", _context.sent);
|
|
70
70
|
|
|
71
71
|
case 10:
|
|
72
72
|
_context.prev = 10;
|
|
@@ -74,19 +74,42 @@ function _request() {
|
|
|
74
74
|
throw new Error("Failed to connect to Maps API: ".concat(_context.t0));
|
|
75
75
|
|
|
76
76
|
case 13:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
case "end":
|
|
78
|
+
return _context.stop();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}, _callee, null, [[4, 10]]);
|
|
82
|
+
}));
|
|
83
|
+
return _request.apply(this, arguments);
|
|
84
|
+
}
|
|
81
85
|
|
|
82
|
-
|
|
86
|
+
function requestJson(_x2) {
|
|
87
|
+
return _requestJson.apply(this, arguments);
|
|
88
|
+
}
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
function _requestJson() {
|
|
91
|
+
_requestJson = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref2) {
|
|
92
|
+
var method, url, accessToken, body, response, json;
|
|
93
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
94
|
+
while (1) {
|
|
95
|
+
switch (_context2.prev = _context2.next) {
|
|
96
|
+
case 0:
|
|
97
|
+
method = _ref2.method, url = _ref2.url, accessToken = _ref2.accessToken, body = _ref2.body;
|
|
98
|
+
_context2.next = 3;
|
|
99
|
+
return request({
|
|
100
|
+
method: method,
|
|
101
|
+
url: url,
|
|
102
|
+
accessToken: accessToken,
|
|
103
|
+
body: body
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
case 3:
|
|
107
|
+
response = _context2.sent;
|
|
108
|
+
_context2.next = 6;
|
|
86
109
|
return response.json();
|
|
87
110
|
|
|
88
|
-
case
|
|
89
|
-
json =
|
|
111
|
+
case 6:
|
|
112
|
+
json = _context2.sent;
|
|
90
113
|
|
|
91
114
|
if (!response.ok) {
|
|
92
115
|
dealWithError({
|
|
@@ -95,21 +118,69 @@ function _request() {
|
|
|
95
118
|
});
|
|
96
119
|
}
|
|
97
120
|
|
|
98
|
-
return
|
|
121
|
+
return _context2.abrupt("return", json);
|
|
99
122
|
|
|
100
|
-
case
|
|
123
|
+
case 9:
|
|
101
124
|
case "end":
|
|
102
|
-
return
|
|
125
|
+
return _context2.stop();
|
|
103
126
|
}
|
|
104
127
|
}
|
|
105
|
-
},
|
|
128
|
+
}, _callee2);
|
|
106
129
|
}));
|
|
107
|
-
return
|
|
130
|
+
return _requestJson.apply(this, arguments);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function requestData(_x3) {
|
|
134
|
+
return _requestData.apply(this, arguments);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function _requestData() {
|
|
138
|
+
_requestData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(_ref3) {
|
|
139
|
+
var method, url, accessToken, format, body, data;
|
|
140
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
141
|
+
while (1) {
|
|
142
|
+
switch (_context3.prev = _context3.next) {
|
|
143
|
+
case 0:
|
|
144
|
+
method = _ref3.method, url = _ref3.url, accessToken = _ref3.accessToken, format = _ref3.format, body = _ref3.body;
|
|
145
|
+
|
|
146
|
+
if (!(format === _mapsApiCommon.FORMATS.NDJSON)) {
|
|
147
|
+
_context3.next = 3;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return _context3.abrupt("return", request({
|
|
152
|
+
method: method,
|
|
153
|
+
url: url,
|
|
154
|
+
accessToken: accessToken,
|
|
155
|
+
body: body
|
|
156
|
+
}));
|
|
157
|
+
|
|
158
|
+
case 3:
|
|
159
|
+
_context3.next = 5;
|
|
160
|
+
return requestJson({
|
|
161
|
+
method: method,
|
|
162
|
+
url: url,
|
|
163
|
+
accessToken: accessToken,
|
|
164
|
+
body: body
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
case 5:
|
|
168
|
+
data = _context3.sent;
|
|
169
|
+
return _context3.abrupt("return", data.rows ? data.rows : data);
|
|
170
|
+
|
|
171
|
+
case 7:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context3.stop();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}, _callee3);
|
|
177
|
+
}));
|
|
178
|
+
return _requestData.apply(this, arguments);
|
|
108
179
|
}
|
|
109
180
|
|
|
110
|
-
function dealWithError(
|
|
111
|
-
var response =
|
|
112
|
-
error =
|
|
181
|
+
function dealWithError(_ref4) {
|
|
182
|
+
var response = _ref4.response,
|
|
183
|
+
error = _ref4.error;
|
|
113
184
|
|
|
114
185
|
switch (response.status) {
|
|
115
186
|
case 400:
|
|
@@ -124,13 +195,13 @@ function dealWithError(_ref2) {
|
|
|
124
195
|
}
|
|
125
196
|
}
|
|
126
197
|
|
|
127
|
-
function getParameters(
|
|
128
|
-
var type =
|
|
129
|
-
source =
|
|
130
|
-
geoColumn =
|
|
131
|
-
columns =
|
|
132
|
-
schema =
|
|
133
|
-
clientId =
|
|
198
|
+
function getParameters(_ref5) {
|
|
199
|
+
var type = _ref5.type,
|
|
200
|
+
source = _ref5.source,
|
|
201
|
+
geoColumn = _ref5.geoColumn,
|
|
202
|
+
columns = _ref5.columns,
|
|
203
|
+
schema = _ref5.schema,
|
|
204
|
+
clientId = _ref5.clientId;
|
|
134
205
|
var parameters = [(0, _mapsApiCommon.encodeParameter)('client', clientId || DEFAULT_CLIENT)];
|
|
135
206
|
|
|
136
207
|
if (schema) {
|
|
@@ -153,18 +224,18 @@ function getParameters(_ref3) {
|
|
|
153
224
|
return parameters.join('&');
|
|
154
225
|
}
|
|
155
226
|
|
|
156
|
-
function mapInstantiation(
|
|
227
|
+
function mapInstantiation(_x4) {
|
|
157
228
|
return _mapInstantiation.apply(this, arguments);
|
|
158
229
|
}
|
|
159
230
|
|
|
160
231
|
function _mapInstantiation() {
|
|
161
|
-
_mapInstantiation = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function
|
|
162
|
-
var type, source, connection, credentials, geoColumn, columns, schema, clientId, baseUrl, url, accessToken,
|
|
163
|
-
return _regenerator.default.wrap(function
|
|
232
|
+
_mapInstantiation = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4(_ref6) {
|
|
233
|
+
var type, source, connection, credentials, geoColumn, columns, schema, clientId, baseUrl, url, accessToken, body;
|
|
234
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
164
235
|
while (1) {
|
|
165
|
-
switch (
|
|
236
|
+
switch (_context4.prev = _context4.next) {
|
|
166
237
|
case 0:
|
|
167
|
-
type =
|
|
238
|
+
type = _ref6.type, source = _ref6.source, connection = _ref6.connection, credentials = _ref6.credentials, geoColumn = _ref6.geoColumn, columns = _ref6.columns, schema = _ref6.schema, clientId = _ref6.clientId;
|
|
168
239
|
baseUrl = "".concat(credentials.mapsUrl, "/").concat(connection, "/").concat(type);
|
|
169
240
|
url = "".concat(baseUrl, "?").concat(getParameters({
|
|
170
241
|
type: type,
|
|
@@ -175,10 +246,9 @@ function _mapInstantiation() {
|
|
|
175
246
|
clientId: clientId
|
|
176
247
|
}));
|
|
177
248
|
accessToken = credentials.accessToken;
|
|
178
|
-
format = 'json';
|
|
179
249
|
|
|
180
250
|
if (!(url.length > MAX_GET_LENGTH && type === _mapsApiCommon.MAP_TYPES.QUERY)) {
|
|
181
|
-
|
|
251
|
+
_context4.next = 9;
|
|
182
252
|
break;
|
|
183
253
|
}
|
|
184
254
|
|
|
@@ -186,35 +256,33 @@ function _mapInstantiation() {
|
|
|
186
256
|
q: source,
|
|
187
257
|
client: clientId || DEFAULT_CLIENT
|
|
188
258
|
});
|
|
189
|
-
|
|
190
|
-
return
|
|
259
|
+
_context4.next = 8;
|
|
260
|
+
return requestJson({
|
|
191
261
|
method: 'POST',
|
|
192
262
|
url: baseUrl,
|
|
193
|
-
format: format,
|
|
194
263
|
accessToken: accessToken,
|
|
195
264
|
body: body
|
|
196
265
|
});
|
|
197
266
|
|
|
198
|
-
case
|
|
199
|
-
return
|
|
267
|
+
case 8:
|
|
268
|
+
return _context4.abrupt("return", _context4.sent);
|
|
200
269
|
|
|
201
|
-
case
|
|
202
|
-
|
|
203
|
-
return
|
|
270
|
+
case 9:
|
|
271
|
+
_context4.next = 11;
|
|
272
|
+
return requestJson({
|
|
204
273
|
url: url,
|
|
205
|
-
format: format,
|
|
206
274
|
accessToken: accessToken
|
|
207
275
|
});
|
|
208
276
|
|
|
209
|
-
case
|
|
210
|
-
return
|
|
277
|
+
case 11:
|
|
278
|
+
return _context4.abrupt("return", _context4.sent);
|
|
211
279
|
|
|
212
|
-
case
|
|
280
|
+
case 12:
|
|
213
281
|
case "end":
|
|
214
|
-
return
|
|
282
|
+
return _context4.stop();
|
|
215
283
|
}
|
|
216
284
|
}
|
|
217
|
-
},
|
|
285
|
+
}, _callee4);
|
|
218
286
|
}));
|
|
219
287
|
return _mapInstantiation.apply(this, arguments);
|
|
220
288
|
}
|
|
@@ -229,39 +297,33 @@ function getUrlFromMetadata(metadata, format) {
|
|
|
229
297
|
return null;
|
|
230
298
|
}
|
|
231
299
|
|
|
232
|
-
function checkFetchLayerDataParameters(
|
|
233
|
-
var type =
|
|
234
|
-
source =
|
|
235
|
-
connection =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
_core.log.assert(localCreds.apiVersion === _mapsApiCommon.API_VERSIONS.V3, 'Method only available for v3');
|
|
245
|
-
|
|
246
|
-
_core.log.assert(localCreds.apiBaseUrl, 'Must define apiBaseUrl');
|
|
247
|
-
|
|
248
|
-
_core.log.assert(localCreds.accessToken, 'Must define an accessToken');
|
|
300
|
+
function checkFetchLayerDataParameters(_ref7) {
|
|
301
|
+
var type = _ref7.type,
|
|
302
|
+
source = _ref7.source,
|
|
303
|
+
connection = _ref7.connection,
|
|
304
|
+
credentials = _ref7.credentials;
|
|
305
|
+
(0, _utils.assert)(connection, 'Must define connection');
|
|
306
|
+
(0, _utils.assert)(type, 'Must define a type');
|
|
307
|
+
(0, _utils.assert)(source, 'Must define a source');
|
|
308
|
+
(0, _utils.assert)(credentials.apiVersion === _mapsApiCommon.API_VERSIONS.V3, 'Method only available for v3');
|
|
309
|
+
(0, _utils.assert)(credentials.apiBaseUrl, 'Must define apiBaseUrl');
|
|
310
|
+
(0, _utils.assert)(credentials.accessToken, 'Must define an accessToken');
|
|
249
311
|
}
|
|
250
312
|
|
|
251
|
-
function fetchLayerData(
|
|
313
|
+
function fetchLayerData(_x5) {
|
|
252
314
|
return _fetchLayerData.apply(this, arguments);
|
|
253
315
|
}
|
|
254
316
|
|
|
255
317
|
function _fetchLayerData() {
|
|
256
|
-
_fetchLayerData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function
|
|
318
|
+
_fetchLayerData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(_ref8) {
|
|
257
319
|
var type, source, connection, credentials, geoColumn, columns, format, schema, clientId, _yield$_fetchDataUrl, url, accessToken, mapFormat, metadata, data, result;
|
|
258
320
|
|
|
259
|
-
return _regenerator.default.wrap(function
|
|
321
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
260
322
|
while (1) {
|
|
261
|
-
switch (
|
|
323
|
+
switch (_context5.prev = _context5.next) {
|
|
262
324
|
case 0:
|
|
263
|
-
type =
|
|
264
|
-
|
|
325
|
+
type = _ref8.type, source = _ref8.source, connection = _ref8.connection, credentials = _ref8.credentials, geoColumn = _ref8.geoColumn, columns = _ref8.columns, format = _ref8.format, schema = _ref8.schema, clientId = _ref8.clientId;
|
|
326
|
+
_context5.next = 3;
|
|
265
327
|
return _fetchDataUrl({
|
|
266
328
|
type: type,
|
|
267
329
|
source: source,
|
|
@@ -275,20 +337,20 @@ function _fetchLayerData() {
|
|
|
275
337
|
});
|
|
276
338
|
|
|
277
339
|
case 3:
|
|
278
|
-
_yield$_fetchDataUrl =
|
|
340
|
+
_yield$_fetchDataUrl = _context5.sent;
|
|
279
341
|
url = _yield$_fetchDataUrl.url;
|
|
280
342
|
accessToken = _yield$_fetchDataUrl.accessToken;
|
|
281
343
|
mapFormat = _yield$_fetchDataUrl.mapFormat;
|
|
282
344
|
metadata = _yield$_fetchDataUrl.metadata;
|
|
283
|
-
|
|
284
|
-
return
|
|
345
|
+
_context5.next = 10;
|
|
346
|
+
return requestData({
|
|
285
347
|
url: url,
|
|
286
348
|
format: mapFormat,
|
|
287
349
|
accessToken: accessToken
|
|
288
350
|
});
|
|
289
351
|
|
|
290
352
|
case 10:
|
|
291
|
-
data =
|
|
353
|
+
data = _context5.sent;
|
|
292
354
|
result = {
|
|
293
355
|
data: data,
|
|
294
356
|
format: mapFormat
|
|
@@ -298,45 +360,45 @@ function _fetchLayerData() {
|
|
|
298
360
|
result.schema = metadata.schema;
|
|
299
361
|
}
|
|
300
362
|
|
|
301
|
-
return
|
|
363
|
+
return _context5.abrupt("return", result);
|
|
302
364
|
|
|
303
365
|
case 14:
|
|
304
366
|
case "end":
|
|
305
|
-
return
|
|
367
|
+
return _context5.stop();
|
|
306
368
|
}
|
|
307
369
|
}
|
|
308
|
-
},
|
|
370
|
+
}, _callee5);
|
|
309
371
|
}));
|
|
310
372
|
return _fetchLayerData.apply(this, arguments);
|
|
311
373
|
}
|
|
312
374
|
|
|
313
|
-
function _fetchDataUrl(
|
|
375
|
+
function _fetchDataUrl(_x6) {
|
|
314
376
|
return _fetchDataUrl2.apply(this, arguments);
|
|
315
377
|
}
|
|
316
378
|
|
|
317
379
|
function _fetchDataUrl2() {
|
|
318
|
-
_fetchDataUrl2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function
|
|
380
|
+
_fetchDataUrl2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6(_ref9) {
|
|
319
381
|
var type, source, connection, credentials, geoColumn, columns, format, schema, clientId, defaultCredentials, localCreds, metadata, url, mapFormat, prioritizedFormats, _i, _prioritizedFormats, f, accessToken;
|
|
320
382
|
|
|
321
|
-
return _regenerator.default.wrap(function
|
|
383
|
+
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
322
384
|
while (1) {
|
|
323
|
-
switch (
|
|
385
|
+
switch (_context6.prev = _context6.next) {
|
|
324
386
|
case 0:
|
|
325
|
-
type =
|
|
387
|
+
type = _ref9.type, source = _ref9.source, connection = _ref9.connection, credentials = _ref9.credentials, geoColumn = _ref9.geoColumn, columns = _ref9.columns, format = _ref9.format, schema = _ref9.schema, clientId = _ref9.clientId;
|
|
326
388
|
defaultCredentials = (0, _config.getDefaultCredentials)();
|
|
327
389
|
localCreds = _objectSpread(_objectSpread({}, defaultCredentials.apiVersion === _mapsApiCommon.API_VERSIONS.V3 && defaultCredentials), credentials);
|
|
328
390
|
checkFetchLayerDataParameters({
|
|
329
391
|
type: type,
|
|
330
392
|
source: source,
|
|
331
393
|
connection: connection,
|
|
332
|
-
|
|
394
|
+
credentials: localCreds
|
|
333
395
|
});
|
|
334
396
|
|
|
335
397
|
if (!localCreds.mapsUrl) {
|
|
336
398
|
localCreds.mapsUrl = (0, _config.buildMapsUrlFromBase)(localCreds.apiBaseUrl);
|
|
337
399
|
}
|
|
338
400
|
|
|
339
|
-
|
|
401
|
+
_context6.next = 7;
|
|
340
402
|
return mapInstantiation({
|
|
341
403
|
type: type,
|
|
342
404
|
source: source,
|
|
@@ -349,28 +411,27 @@ function _fetchDataUrl2() {
|
|
|
349
411
|
});
|
|
350
412
|
|
|
351
413
|
case 7:
|
|
352
|
-
metadata =
|
|
414
|
+
metadata = _context6.sent;
|
|
415
|
+
url = null;
|
|
353
416
|
|
|
354
417
|
if (!format) {
|
|
355
|
-
|
|
418
|
+
_context6.next = 15;
|
|
356
419
|
break;
|
|
357
420
|
}
|
|
358
421
|
|
|
359
422
|
mapFormat = format;
|
|
360
423
|
url = getUrlFromMetadata(metadata, format);
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
_context4.next = 25;
|
|
424
|
+
(0, _utils.assert)(url, "Format ".concat(format, " not available"));
|
|
425
|
+
_context6.next = 27;
|
|
365
426
|
break;
|
|
366
427
|
|
|
367
|
-
case
|
|
428
|
+
case 15:
|
|
368
429
|
prioritizedFormats = [_mapsApiCommon.FORMATS.GEOJSON, _mapsApiCommon.FORMATS.JSON, _mapsApiCommon.FORMATS.NDJSON, _mapsApiCommon.FORMATS.TILEJSON];
|
|
369
430
|
_i = 0, _prioritizedFormats = prioritizedFormats;
|
|
370
431
|
|
|
371
|
-
case
|
|
432
|
+
case 17:
|
|
372
433
|
if (!(_i < _prioritizedFormats.length)) {
|
|
373
|
-
|
|
434
|
+
_context6.next = 26;
|
|
374
435
|
break;
|
|
375
436
|
}
|
|
376
437
|
|
|
@@ -378,53 +439,56 @@ function _fetchDataUrl2() {
|
|
|
378
439
|
url = getUrlFromMetadata(metadata, f);
|
|
379
440
|
|
|
380
441
|
if (!url) {
|
|
381
|
-
|
|
442
|
+
_context6.next = 23;
|
|
382
443
|
break;
|
|
383
444
|
}
|
|
384
445
|
|
|
385
446
|
mapFormat = f;
|
|
386
|
-
return
|
|
447
|
+
return _context6.abrupt("break", 26);
|
|
387
448
|
|
|
388
|
-
case
|
|
449
|
+
case 23:
|
|
389
450
|
_i++;
|
|
390
|
-
|
|
451
|
+
_context6.next = 17;
|
|
391
452
|
break;
|
|
392
453
|
|
|
393
|
-
case
|
|
454
|
+
case 26:
|
|
455
|
+
(0, _utils.assert)(url && mapFormat, 'Unsupported data formats received from backend.');
|
|
456
|
+
|
|
457
|
+
case 27:
|
|
394
458
|
accessToken = localCreds.accessToken;
|
|
395
|
-
return
|
|
459
|
+
return _context6.abrupt("return", {
|
|
396
460
|
url: url,
|
|
397
461
|
accessToken: accessToken,
|
|
398
462
|
mapFormat: mapFormat,
|
|
399
463
|
metadata: metadata
|
|
400
464
|
});
|
|
401
465
|
|
|
402
|
-
case
|
|
466
|
+
case 29:
|
|
403
467
|
case "end":
|
|
404
|
-
return
|
|
468
|
+
return _context6.stop();
|
|
405
469
|
}
|
|
406
470
|
}
|
|
407
|
-
},
|
|
471
|
+
}, _callee6);
|
|
408
472
|
}));
|
|
409
473
|
return _fetchDataUrl2.apply(this, arguments);
|
|
410
474
|
}
|
|
411
475
|
|
|
412
|
-
function getData(
|
|
476
|
+
function getData(_x7) {
|
|
413
477
|
return _getData.apply(this, arguments);
|
|
414
478
|
}
|
|
415
479
|
|
|
416
480
|
function _getData() {
|
|
417
|
-
_getData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function
|
|
481
|
+
_getData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(_ref10) {
|
|
418
482
|
var type, source, connection, credentials, geoColumn, columns, format, clientId, layerData;
|
|
419
|
-
return _regenerator.default.wrap(function
|
|
483
|
+
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
420
484
|
while (1) {
|
|
421
|
-
switch (
|
|
485
|
+
switch (_context7.prev = _context7.next) {
|
|
422
486
|
case 0:
|
|
423
|
-
type =
|
|
487
|
+
type = _ref10.type, source = _ref10.source, connection = _ref10.connection, credentials = _ref10.credentials, geoColumn = _ref10.geoColumn, columns = _ref10.columns, format = _ref10.format, clientId = _ref10.clientId;
|
|
424
488
|
|
|
425
489
|
_core.log.deprecated('getData', 'fetchLayerData')();
|
|
426
490
|
|
|
427
|
-
|
|
491
|
+
_context7.next = 4;
|
|
428
492
|
return fetchLayerData({
|
|
429
493
|
type: type,
|
|
430
494
|
source: source,
|
|
@@ -438,169 +502,165 @@ function _getData() {
|
|
|
438
502
|
});
|
|
439
503
|
|
|
440
504
|
case 4:
|
|
441
|
-
layerData =
|
|
442
|
-
return
|
|
505
|
+
layerData = _context7.sent;
|
|
506
|
+
return _context7.abrupt("return", layerData.data);
|
|
443
507
|
|
|
444
508
|
case 6:
|
|
445
509
|
case "end":
|
|
446
|
-
return
|
|
510
|
+
return _context7.stop();
|
|
447
511
|
}
|
|
448
512
|
}
|
|
449
|
-
},
|
|
513
|
+
}, _callee7);
|
|
450
514
|
}));
|
|
451
515
|
return _getData.apply(this, arguments);
|
|
452
516
|
}
|
|
453
517
|
|
|
454
|
-
function _fetchMapDataset(
|
|
518
|
+
function _fetchMapDataset(_x8, _x9, _x10, _x11) {
|
|
455
519
|
return _fetchMapDataset2.apply(this, arguments);
|
|
456
520
|
}
|
|
457
521
|
|
|
458
522
|
function _fetchMapDataset2() {
|
|
459
|
-
_fetchMapDataset2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function
|
|
460
|
-
var connection, source, type, _yield$_fetchDataUrl2, url, mapFormat, cache
|
|
523
|
+
_fetchMapDataset2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee8(dataset, accessToken, credentials, clientId) {
|
|
524
|
+
var connection, columns, geoColumn, source, type, _yield$_fetchDataUrl2, url, mapFormat, cache;
|
|
461
525
|
|
|
462
|
-
return _regenerator.default.wrap(function
|
|
526
|
+
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
463
527
|
while (1) {
|
|
464
|
-
switch (
|
|
528
|
+
switch (_context8.prev = _context8.next) {
|
|
465
529
|
case 0:
|
|
466
|
-
connection = dataset.connectionName, source = dataset.source, type = dataset.type;
|
|
467
|
-
|
|
530
|
+
connection = dataset.connectionName, columns = dataset.columns, geoColumn = dataset.geoColumn, source = dataset.source, type = dataset.type;
|
|
531
|
+
_context8.next = 3;
|
|
468
532
|
return _fetchDataUrl({
|
|
469
533
|
credentials: _objectSpread(_objectSpread({}, credentials), {}, {
|
|
470
534
|
accessToken: accessToken
|
|
471
535
|
}),
|
|
472
536
|
connection: connection,
|
|
537
|
+
columns: columns,
|
|
538
|
+
geoColumn: geoColumn,
|
|
473
539
|
source: source,
|
|
474
540
|
type: type,
|
|
475
541
|
clientId: clientId
|
|
476
542
|
});
|
|
477
543
|
|
|
478
544
|
case 3:
|
|
479
|
-
_yield$_fetchDataUrl2 =
|
|
545
|
+
_yield$_fetchDataUrl2 = _context8.sent;
|
|
480
546
|
url = _yield$_fetchDataUrl2.url;
|
|
481
547
|
mapFormat = _yield$_fetchDataUrl2.mapFormat;
|
|
482
|
-
cache = parseInt(new URL(url).searchParams.get('cache'), 10);
|
|
548
|
+
cache = parseInt(new URL(url).searchParams.get('cache') || '', 10);
|
|
483
549
|
|
|
484
550
|
if (!(cache && dataset.cache === cache)) {
|
|
485
|
-
|
|
551
|
+
_context8.next = 9;
|
|
486
552
|
break;
|
|
487
553
|
}
|
|
488
554
|
|
|
489
|
-
return
|
|
555
|
+
return _context8.abrupt("return", false);
|
|
490
556
|
|
|
491
557
|
case 9:
|
|
492
558
|
dataset.cache = cache;
|
|
493
|
-
|
|
494
|
-
return
|
|
559
|
+
_context8.next = 12;
|
|
560
|
+
return requestData({
|
|
495
561
|
url: url,
|
|
496
562
|
format: mapFormat,
|
|
497
563
|
accessToken: accessToken
|
|
498
564
|
});
|
|
499
565
|
|
|
500
566
|
case 12:
|
|
501
|
-
data =
|
|
502
|
-
|
|
503
|
-
return _context6.abrupt("return", true);
|
|
567
|
+
dataset.data = _context8.sent;
|
|
568
|
+
return _context8.abrupt("return", true);
|
|
504
569
|
|
|
505
|
-
case
|
|
570
|
+
case 14:
|
|
506
571
|
case "end":
|
|
507
|
-
return
|
|
572
|
+
return _context8.stop();
|
|
508
573
|
}
|
|
509
574
|
}
|
|
510
|
-
},
|
|
575
|
+
}, _callee8);
|
|
511
576
|
}));
|
|
512
577
|
return _fetchMapDataset2.apply(this, arguments);
|
|
513
578
|
}
|
|
514
579
|
|
|
515
|
-
function fillInMapDatasets(
|
|
580
|
+
function fillInMapDatasets(_x12, _x13, _x14) {
|
|
516
581
|
return _fillInMapDatasets.apply(this, arguments);
|
|
517
582
|
}
|
|
518
583
|
|
|
519
584
|
function _fillInMapDatasets() {
|
|
520
|
-
_fillInMapDatasets = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function
|
|
585
|
+
_fillInMapDatasets = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee9(_ref11, clientId, credentials) {
|
|
521
586
|
var datasets, token, promises;
|
|
522
|
-
return _regenerator.default.wrap(function
|
|
587
|
+
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
523
588
|
while (1) {
|
|
524
|
-
switch (
|
|
589
|
+
switch (_context9.prev = _context9.next) {
|
|
525
590
|
case 0:
|
|
526
|
-
datasets =
|
|
591
|
+
datasets = _ref11.datasets, token = _ref11.token;
|
|
527
592
|
promises = datasets.map(function (dataset) {
|
|
528
593
|
return _fetchMapDataset(dataset, token, credentials, clientId);
|
|
529
594
|
});
|
|
530
|
-
|
|
595
|
+
_context9.next = 4;
|
|
531
596
|
return Promise.all(promises);
|
|
532
597
|
|
|
533
598
|
case 4:
|
|
534
|
-
return
|
|
599
|
+
return _context9.abrupt("return", _context9.sent);
|
|
535
600
|
|
|
536
601
|
case 5:
|
|
537
602
|
case "end":
|
|
538
|
-
return
|
|
603
|
+
return _context9.stop();
|
|
539
604
|
}
|
|
540
605
|
}
|
|
541
|
-
},
|
|
606
|
+
}, _callee9);
|
|
542
607
|
}));
|
|
543
608
|
return _fillInMapDatasets.apply(this, arguments);
|
|
544
609
|
}
|
|
545
610
|
|
|
546
|
-
function fetchMap(
|
|
611
|
+
function fetchMap(_x15) {
|
|
547
612
|
return _fetchMap.apply(this, arguments);
|
|
548
613
|
}
|
|
549
614
|
|
|
550
615
|
function _fetchMap() {
|
|
551
|
-
_fetchMap = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function
|
|
616
|
+
_fetchMap = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee11(_ref12) {
|
|
552
617
|
var cartoMapId, clientId, credentials, autoRefresh, onNewData, defaultCredentials, localCreds, accessToken, url, map, stopAutoRefresh, intervalId;
|
|
553
|
-
return _regenerator.default.wrap(function
|
|
618
|
+
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
554
619
|
while (1) {
|
|
555
|
-
switch (
|
|
620
|
+
switch (_context11.prev = _context11.next) {
|
|
556
621
|
case 0:
|
|
557
|
-
cartoMapId =
|
|
622
|
+
cartoMapId = _ref12.cartoMapId, clientId = _ref12.clientId, credentials = _ref12.credentials, autoRefresh = _ref12.autoRefresh, onNewData = _ref12.onNewData;
|
|
558
623
|
defaultCredentials = (0, _config.getDefaultCredentials)();
|
|
559
624
|
localCreds = _objectSpread(_objectSpread({}, defaultCredentials.apiVersion === _mapsApiCommon.API_VERSIONS.V3 && defaultCredentials), credentials);
|
|
560
625
|
accessToken = localCreds.accessToken;
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
_core.log.assert(localCreds.apiVersion === _mapsApiCommon.API_VERSIONS.V3, 'Method only available for v3');
|
|
565
|
-
|
|
566
|
-
_core.log.assert(localCreds.apiBaseUrl, 'Must define apiBaseUrl');
|
|
626
|
+
(0, _utils.assert)(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})');
|
|
627
|
+
(0, _utils.assert)(localCreds.apiVersion === _mapsApiCommon.API_VERSIONS.V3, 'Method only available for v3');
|
|
628
|
+
(0, _utils.assert)(localCreds.apiBaseUrl, 'Must define apiBaseUrl');
|
|
567
629
|
|
|
568
630
|
if (!localCreds.mapsUrl) {
|
|
569
631
|
localCreds.mapsUrl = (0, _config.buildMapsUrlFromBase)(localCreds.apiBaseUrl);
|
|
570
632
|
}
|
|
571
633
|
|
|
572
634
|
if (autoRefresh || onNewData) {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
_core.log.assert(autoRefresh > 0, '`autoRefresh` must be a positive number');
|
|
635
|
+
(0, _utils.assert)(onNewData, 'Must define `onNewData` when using autoRefresh');
|
|
636
|
+
(0, _utils.assert)(typeof onNewData === 'function', '`onNewData` must be a function');
|
|
637
|
+
(0, _utils.assert)(typeof autoRefresh === 'number' && autoRefresh > 0, '`autoRefresh` must be a positive number');
|
|
578
638
|
}
|
|
579
639
|
|
|
580
640
|
url = "".concat(localCreds.mapsUrl, "/public/").concat(cartoMapId);
|
|
581
|
-
|
|
582
|
-
return
|
|
641
|
+
_context11.next = 12;
|
|
642
|
+
return requestJson({
|
|
583
643
|
url: url,
|
|
584
644
|
accessToken: accessToken
|
|
585
645
|
});
|
|
586
646
|
|
|
587
647
|
case 12:
|
|
588
|
-
map =
|
|
648
|
+
map = _context11.sent;
|
|
589
649
|
|
|
590
650
|
if (autoRefresh) {
|
|
591
|
-
intervalId = setInterval((0, _asyncToGenerator2.default)(_regenerator.default.mark(function
|
|
651
|
+
intervalId = setInterval((0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee10() {
|
|
592
652
|
var changed;
|
|
593
|
-
return _regenerator.default.wrap(function
|
|
653
|
+
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
594
654
|
while (1) {
|
|
595
|
-
switch (
|
|
655
|
+
switch (_context10.prev = _context10.next) {
|
|
596
656
|
case 0:
|
|
597
|
-
|
|
598
|
-
return fillInMapDatasets(map, clientId,
|
|
657
|
+
_context10.next = 2;
|
|
658
|
+
return fillInMapDatasets(map, clientId, localCreds);
|
|
599
659
|
|
|
600
660
|
case 2:
|
|
601
|
-
changed =
|
|
661
|
+
changed = _context10.sent;
|
|
602
662
|
|
|
603
|
-
if (changed.some(function (v) {
|
|
663
|
+
if (onNewData && changed.some(function (v) {
|
|
604
664
|
return v === true;
|
|
605
665
|
})) {
|
|
606
666
|
onNewData((0, _parseMap.parseMap)(map));
|
|
@@ -608,10 +668,10 @@ function _fetchMap() {
|
|
|
608
668
|
|
|
609
669
|
case 4:
|
|
610
670
|
case "end":
|
|
611
|
-
return
|
|
671
|
+
return _context10.stop();
|
|
612
672
|
}
|
|
613
673
|
}
|
|
614
|
-
},
|
|
674
|
+
}, _callee10);
|
|
615
675
|
})), autoRefresh * 1000);
|
|
616
676
|
|
|
617
677
|
stopAutoRefresh = function stopAutoRefresh() {
|
|
@@ -619,20 +679,20 @@ function _fetchMap() {
|
|
|
619
679
|
};
|
|
620
680
|
}
|
|
621
681
|
|
|
622
|
-
|
|
623
|
-
return fillInMapDatasets(map, clientId,
|
|
682
|
+
_context11.next = 16;
|
|
683
|
+
return fillInMapDatasets(map, clientId, localCreds);
|
|
624
684
|
|
|
625
685
|
case 16:
|
|
626
|
-
return
|
|
686
|
+
return _context11.abrupt("return", _objectSpread(_objectSpread({}, (0, _parseMap.parseMap)(map)), {
|
|
627
687
|
stopAutoRefresh: stopAutoRefresh
|
|
628
688
|
}));
|
|
629
689
|
|
|
630
690
|
case 17:
|
|
631
691
|
case "end":
|
|
632
|
-
return
|
|
692
|
+
return _context11.stop();
|
|
633
693
|
}
|
|
634
694
|
}
|
|
635
|
-
},
|
|
695
|
+
}, _callee11);
|
|
636
696
|
}));
|
|
637
697
|
return _fetchMap.apply(this, arguments);
|
|
638
698
|
}
|