@deck.gl/carto 8.8.4 → 8.8.7

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 (125) hide show
  1. package/dist/dist.dev.js +31412 -22945
  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 +230 -57
  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 +15 -23
  14. package/dist/es5/layers/carto-layer.js.map +1 -1
  15. package/dist/es5/layers/carto-tile-layer.js +1 -1
  16. package/dist/es5/layers/carto-tile-layer.js.map +1 -1
  17. package/dist/es5/layers/quadbin-utils.js +2 -0
  18. package/dist/es5/layers/quadbin-utils.js.map +1 -1
  19. package/dist/es5/layers/schema/carto-spatial-tile-loader.js +99 -0
  20. package/dist/es5/layers/schema/carto-spatial-tile-loader.js.map +1 -0
  21. package/dist/es5/layers/schema/carto-spatial-tile.js +117 -0
  22. package/dist/es5/layers/schema/carto-spatial-tile.js.map +1 -0
  23. package/dist/es5/layers/schema/carto-tile.js +5 -1
  24. package/dist/es5/layers/schema/carto-tile.js.map +1 -1
  25. package/dist/es5/layers/schema/spatialjson-utils.js +41 -0
  26. package/dist/es5/layers/schema/spatialjson-utils.js.map +1 -0
  27. package/dist/es5/layers/spatial-index-tile-layer.js +6 -0
  28. package/dist/es5/layers/spatial-index-tile-layer.js.map +1 -1
  29. package/dist/esm/api/index.js.map +1 -1
  30. package/dist/esm/api/layer-map.js +79 -14
  31. package/dist/esm/api/layer-map.js.map +1 -1
  32. package/dist/esm/api/maps-api-common.js.map +1 -1
  33. package/dist/esm/api/maps-v3-client.js +129 -16
  34. package/dist/esm/api/maps-v3-client.js.map +1 -1
  35. package/dist/esm/api/parseMap.js +18 -4
  36. package/dist/esm/api/parseMap.js.map +1 -1
  37. package/dist/esm/config.js +10 -2
  38. package/dist/esm/config.js.map +1 -1
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/layers/carto-layer.js +12 -19
  41. package/dist/esm/layers/carto-layer.js.map +1 -1
  42. package/dist/esm/layers/carto-tile-layer.js +1 -1
  43. package/dist/esm/layers/carto-tile-layer.js.map +1 -1
  44. package/dist/esm/layers/quadbin-utils.js +2 -5
  45. package/dist/esm/layers/quadbin-utils.js.map +1 -1
  46. package/dist/esm/layers/schema/carto-spatial-tile-loader.js +56 -0
  47. package/dist/esm/layers/schema/carto-spatial-tile-loader.js.map +1 -0
  48. package/dist/esm/layers/schema/carto-spatial-tile.js +72 -0
  49. package/dist/esm/layers/schema/carto-spatial-tile.js.map +1 -0
  50. package/dist/esm/layers/schema/carto-tile.js +2 -2
  51. package/dist/esm/layers/schema/carto-tile.js.map +1 -1
  52. package/dist/esm/layers/schema/spatialjson-utils.js +26 -0
  53. package/dist/esm/layers/schema/spatialjson-utils.js.map +1 -0
  54. package/dist/esm/layers/spatial-index-tile-layer.js +3 -0
  55. package/dist/esm/layers/spatial-index-tile-layer.js.map +1 -1
  56. package/dist.min.js +138 -138
  57. package/package.json +2 -2
  58. package/src/api/index.ts +1 -0
  59. package/src/api/layer-map.ts +76 -13
  60. package/src/api/maps-api-common.ts +8 -0
  61. package/src/api/maps-v3-client.ts +148 -21
  62. package/src/api/parseMap.ts +6 -2
  63. package/src/config.ts +12 -2
  64. package/src/index.ts +1 -1
  65. package/src/layers/carto-layer.ts +26 -33
  66. package/src/layers/carto-tile-layer.ts +6 -3
  67. package/src/layers/quadbin-utils.ts +2 -2
  68. package/src/layers/schema/carto-spatial-tile-loader.ts +59 -0
  69. package/src/layers/schema/carto-spatial-tile.ts +83 -0
  70. package/src/layers/schema/carto-tile.ts +6 -6
  71. package/src/layers/schema/spatialjson-utils.ts +35 -0
  72. package/src/layers/spatial-index-tile-layer.ts +4 -0
  73. package/typed/api/index.d.ts +1 -0
  74. package/typed/api/index.d.ts.map +1 -1
  75. package/typed/api/layer-map.d.ts +12 -4
  76. package/typed/api/layer-map.d.ts.map +1 -1
  77. package/typed/api/maps-api-common.d.ts +4 -0
  78. package/typed/api/maps-api-common.d.ts.map +1 -1
  79. package/typed/api/maps-v3-client.d.ts +8 -4
  80. package/typed/api/maps-v3-client.d.ts.map +1 -1
  81. package/typed/config.d.ts +2 -0
  82. package/typed/config.d.ts.map +1 -1
  83. package/typed/index.d.ts +1 -0
  84. package/typed/index.d.ts.map +1 -1
  85. package/typed/layers/carto-layer.d.ts +8 -8
  86. package/typed/layers/carto-layer.d.ts.map +1 -1
  87. package/typed/layers/carto-tile-layer.d.ts.map +1 -1
  88. package/typed/layers/quadbin-utils.d.ts +2 -0
  89. package/typed/layers/quadbin-utils.d.ts.map +1 -1
  90. package/typed/layers/schema/carto-spatial-tile-loader.d.ts +4 -0
  91. package/typed/layers/schema/carto-spatial-tile-loader.d.ts.map +1 -0
  92. package/typed/layers/schema/carto-spatial-tile.d.ts +21 -0
  93. package/typed/layers/schema/carto-spatial-tile.d.ts.map +1 -0
  94. package/typed/layers/schema/carto-tile.d.ts +15 -3
  95. package/typed/layers/schema/carto-tile.d.ts.map +1 -1
  96. package/typed/layers/schema/spatialjson-utils.d.ts +25 -0
  97. package/typed/layers/schema/spatialjson-utils.d.ts.map +1 -0
  98. package/typed/layers/spatial-index-tile-layer.d.ts.map +1 -1
  99. package/typed/api/index.js +0 -3
  100. package/typed/api/layer-map.js +0 -264
  101. package/typed/api/maps-api-common.js +0 -50
  102. package/typed/api/maps-client.js +0 -125
  103. package/typed/api/maps-v3-client.js +0 -304
  104. package/typed/api/parseMap.js +0 -178
  105. package/typed/basemap.js +0 -9
  106. package/typed/config.js +0 -35
  107. package/typed/index.js +0 -10
  108. package/typed/layers/carto-layer.js +0 -173
  109. package/typed/layers/carto-tile-layer.js +0 -105
  110. package/typed/layers/h3-tile-layer.js +0 -47
  111. package/typed/layers/h3-tileset-2d.js +0 -85
  112. package/typed/layers/quadkey-tile-layer.d.ts +0 -21
  113. package/typed/layers/quadkey-tile-layer.d.ts.map +0 -1
  114. package/typed/layers/quadkey-tile-layer.js +0 -42
  115. package/typed/layers/quadkey-tileset-2d.d.ts +0 -15
  116. package/typed/layers/quadkey-tileset-2d.d.ts.map +0 -1
  117. package/typed/layers/quadkey-tileset-2d.js +0 -36
  118. package/typed/layers/schema/carto-tile.js +0 -161
  119. package/typed/layers/spatial-index-tile-layer.js +0 -40
  120. package/typed/style/color-bins-style.js +0 -12
  121. package/typed/style/color-categories-style.js +0 -16
  122. package/typed/style/color-continuous-style.js +0 -12
  123. package/typed/style/palette.js +0 -62
  124. package/typed/style/utils.js +0 -15
  125. package/typed/utils.js +0 -4
@@ -25,6 +25,12 @@ var _core = require("@deck.gl/core");
25
25
 
26
26
  var _utils = require("../utils");
27
27
 
28
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
29
+
30
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
31
+
32
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
33
+
28
34
  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; }
29
35
 
30
36
  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; }
@@ -38,15 +44,15 @@ function request(_x) {
38
44
 
39
45
  function _request() {
40
46
  _request = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(_ref) {
41
- var method, url, accessToken, body, headers;
47
+ var method, url, customHeaders, accessToken, body, headers;
42
48
  return _regenerator.default.wrap(function _callee$(_context) {
43
49
  while (1) {
44
50
  switch (_context.prev = _context.next) {
45
51
  case 0:
46
- method = _ref.method, url = _ref.url, accessToken = _ref.accessToken, body = _ref.body;
47
- headers = {
52
+ method = _ref.method, url = _ref.url, customHeaders = _ref.headers, accessToken = _ref.accessToken, body = _ref.body;
53
+ headers = _objectSpread(_objectSpread({}, customHeaders), {}, {
48
54
  Accept: 'application/json'
49
- };
55
+ });
50
56
 
51
57
  if (accessToken) {
52
58
  headers.Authorization = "Bearer ".concat(accessToken);
@@ -88,16 +94,17 @@ function requestJson(_x2) {
88
94
 
89
95
  function _requestJson() {
90
96
  _requestJson = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref2) {
91
- var method, url, accessToken, body, response, json;
97
+ var method, url, headers, accessToken, body, response, json;
92
98
  return _regenerator.default.wrap(function _callee2$(_context2) {
93
99
  while (1) {
94
100
  switch (_context2.prev = _context2.next) {
95
101
  case 0:
96
- method = _ref2.method, url = _ref2.url, accessToken = _ref2.accessToken, body = _ref2.body;
102
+ method = _ref2.method, url = _ref2.url, headers = _ref2.headers, accessToken = _ref2.accessToken, body = _ref2.body;
97
103
  _context2.next = 3;
98
104
  return request({
99
105
  method: method,
100
106
  url: url,
107
+ headers: headers,
101
108
  accessToken: accessToken,
102
109
  body: body
103
110
  });
@@ -201,11 +208,16 @@ function getParameters(_ref5) {
201
208
  columns = _ref5.columns,
202
209
  clientId = _ref5.clientId,
203
210
  aggregationExp = _ref5.aggregationExp,
204
- aggregationResLevel = _ref5.aggregationResLevel;
211
+ aggregationResLevel = _ref5.aggregationResLevel,
212
+ queryParameters = _ref5.queryParameters;
205
213
  var parameters = [(0, _mapsApiCommon.encodeParameter)('client', clientId || DEFAULT_CLIENT)];
206
214
  var sourceName = type === _mapsApiCommon.MAP_TYPES.QUERY ? 'q' : 'name';
207
215
  parameters.push((0, _mapsApiCommon.encodeParameter)(sourceName, source));
208
216
 
217
+ if (queryParameters) {
218
+ parameters.push((0, _mapsApiCommon.encodeParameter)('queryParameters', JSON.stringify(queryParameters)));
219
+ }
220
+
209
221
  if (geoColumn) {
210
222
  parameters.push((0, _mapsApiCommon.encodeParameter)('geo_column', geoColumn));
211
223
  }
@@ -216,6 +228,8 @@ function getParameters(_ref5) {
216
228
 
217
229
  if (aggregationExp) {
218
230
  parameters.push((0, _mapsApiCommon.encodeParameter)('aggregationExp', aggregationExp));
231
+ } else if (isSpatialIndexGeoColumn(geoColumn)) {
232
+ parameters.push((0, _mapsApiCommon.encodeParameter)('aggregationExp', '1 AS value'));
219
233
  }
220
234
 
221
235
  if (aggregationResLevel) {
@@ -225,18 +239,23 @@ function getParameters(_ref5) {
225
239
  return parameters.join('&');
226
240
  }
227
241
 
242
+ function isSpatialIndexGeoColumn(geoColumn) {
243
+ var spatialIndex = geoColumn === null || geoColumn === void 0 ? void 0 : geoColumn.split(':')[0];
244
+ return spatialIndex === 'h3' || spatialIndex === 'quadbin';
245
+ }
246
+
228
247
  function mapInstantiation(_x4) {
229
248
  return _mapInstantiation.apply(this, arguments);
230
249
  }
231
250
 
232
251
  function _mapInstantiation() {
233
252
  _mapInstantiation = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4(_ref6) {
234
- var type, source, connection, credentials, geoColumn, columns, clientId, aggregationExp, aggregationResLevel, baseUrl, url, accessToken, body;
253
+ var type, source, connection, credentials, geoColumn, columns, clientId, headers, aggregationExp, aggregationResLevel, queryParameters, baseUrl, url, accessToken, body;
235
254
  return _regenerator.default.wrap(function _callee4$(_context4) {
236
255
  while (1) {
237
256
  switch (_context4.prev = _context4.next) {
238
257
  case 0:
239
- type = _ref6.type, source = _ref6.source, connection = _ref6.connection, credentials = _ref6.credentials, geoColumn = _ref6.geoColumn, columns = _ref6.columns, clientId = _ref6.clientId, aggregationExp = _ref6.aggregationExp, aggregationResLevel = _ref6.aggregationResLevel;
258
+ type = _ref6.type, source = _ref6.source, connection = _ref6.connection, credentials = _ref6.credentials, geoColumn = _ref6.geoColumn, columns = _ref6.columns, clientId = _ref6.clientId, headers = _ref6.headers, aggregationExp = _ref6.aggregationExp, aggregationResLevel = _ref6.aggregationResLevel, queryParameters = _ref6.queryParameters;
240
259
  baseUrl = "".concat(credentials.mapsUrl, "/").concat(connection, "/").concat(type);
241
260
  url = "".concat(baseUrl, "?").concat(getParameters({
242
261
  type: type,
@@ -244,8 +263,9 @@ function _mapInstantiation() {
244
263
  geoColumn: geoColumn,
245
264
  columns: columns,
246
265
  clientId: clientId,
266
+ aggregationResLevel: aggregationResLevel,
247
267
  aggregationExp: aggregationExp,
248
- aggregationResLevel: aggregationResLevel
268
+ queryParameters: queryParameters
249
269
  }));
250
270
  accessToken = credentials.accessToken;
251
271
 
@@ -256,12 +276,14 @@ function _mapInstantiation() {
256
276
 
257
277
  body = JSON.stringify({
258
278
  q: source,
259
- client: clientId || DEFAULT_CLIENT
279
+ client: clientId || DEFAULT_CLIENT,
280
+ queryParameters: queryParameters
260
281
  });
261
282
  _context4.next = 8;
262
283
  return requestJson({
263
284
  method: 'POST',
264
285
  url: baseUrl,
286
+ headers: headers,
265
287
  accessToken: accessToken,
266
288
  body: body
267
289
  });
@@ -273,6 +295,7 @@ function _mapInstantiation() {
273
295
  _context4.next = 11;
274
296
  return requestJson({
275
297
  url: url,
298
+ headers: headers,
276
299
  accessToken: accessToken
277
300
  });
278
301
 
@@ -337,13 +360,13 @@ function fetchLayerData(_x5) {
337
360
 
338
361
  function _fetchLayerData() {
339
362
  _fetchLayerData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(_ref8) {
340
- var type, source, connection, credentials, geoColumn, columns, format, formatTiles, clientId, aggregationExp, aggregationResLevel, _yield$_fetchDataUrl, url, accessToken, mapFormat, metadata, data, result;
363
+ var type, source, connection, credentials, geoColumn, columns, format, formatTiles, clientId, headers, aggregationExp, aggregationResLevel, queryParameters, _yield$_fetchDataUrl, url, accessToken, mapFormat, metadata, data, result;
341
364
 
342
365
  return _regenerator.default.wrap(function _callee5$(_context5) {
343
366
  while (1) {
344
367
  switch (_context5.prev = _context5.next) {
345
368
  case 0:
346
- type = _ref8.type, source = _ref8.source, connection = _ref8.connection, credentials = _ref8.credentials, geoColumn = _ref8.geoColumn, columns = _ref8.columns, format = _ref8.format, formatTiles = _ref8.formatTiles, clientId = _ref8.clientId, aggregationExp = _ref8.aggregationExp, aggregationResLevel = _ref8.aggregationResLevel;
369
+ type = _ref8.type, source = _ref8.source, connection = _ref8.connection, credentials = _ref8.credentials, geoColumn = _ref8.geoColumn, columns = _ref8.columns, format = _ref8.format, formatTiles = _ref8.formatTiles, clientId = _ref8.clientId, headers = _ref8.headers, aggregationExp = _ref8.aggregationExp, aggregationResLevel = _ref8.aggregationResLevel, queryParameters = _ref8.queryParameters;
347
370
  _context5.next = 3;
348
371
  return _fetchDataUrl({
349
372
  type: type,
@@ -355,8 +378,10 @@ function _fetchLayerData() {
355
378
  format: format,
356
379
  formatTiles: formatTiles,
357
380
  clientId: clientId,
381
+ headers: headers,
358
382
  aggregationExp: aggregationExp,
359
- aggregationResLevel: aggregationResLevel
383
+ aggregationResLevel: aggregationResLevel,
384
+ queryParameters: queryParameters
360
385
  });
361
386
 
362
387
  case 3:
@@ -397,13 +422,13 @@ function _fetchDataUrl(_x6) {
397
422
 
398
423
  function _fetchDataUrl2() {
399
424
  _fetchDataUrl2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6(_ref9) {
400
- var type, source, connection, credentials, geoColumn, columns, format, formatTiles, clientId, aggregationExp, aggregationResLevel, defaultCredentials, localCreds, metadata, url, mapFormat, prioritizedFormats, _i, _prioritizedFormats, f, accessToken;
425
+ var type, source, connection, credentials, geoColumn, columns, format, formatTiles, clientId, headers, aggregationExp, aggregationResLevel, queryParameters, defaultCredentials, localCreds, metadata, url, mapFormat, prioritizedFormats, _i, _prioritizedFormats, f, accessToken;
401
426
 
402
427
  return _regenerator.default.wrap(function _callee6$(_context6) {
403
428
  while (1) {
404
429
  switch (_context6.prev = _context6.next) {
405
430
  case 0:
406
- type = _ref9.type, source = _ref9.source, connection = _ref9.connection, credentials = _ref9.credentials, geoColumn = _ref9.geoColumn, columns = _ref9.columns, format = _ref9.format, formatTiles = _ref9.formatTiles, clientId = _ref9.clientId, aggregationExp = _ref9.aggregationExp, aggregationResLevel = _ref9.aggregationResLevel;
431
+ type = _ref9.type, source = _ref9.source, connection = _ref9.connection, credentials = _ref9.credentials, geoColumn = _ref9.geoColumn, columns = _ref9.columns, format = _ref9.format, formatTiles = _ref9.formatTiles, clientId = _ref9.clientId, headers = _ref9.headers, aggregationExp = _ref9.aggregationExp, aggregationResLevel = _ref9.aggregationResLevel, queryParameters = _ref9.queryParameters;
407
432
  defaultCredentials = (0, _config.getDefaultCredentials)();
408
433
  localCreds = _objectSpread(_objectSpread({}, defaultCredentials.apiVersion === _mapsApiCommon.API_VERSIONS.V3 && defaultCredentials), credentials);
409
434
  checkFetchLayerDataParameters({
@@ -430,8 +455,10 @@ function _fetchDataUrl2() {
430
455
  geoColumn: geoColumn,
431
456
  columns: columns,
432
457
  clientId: clientId,
458
+ headers: headers,
433
459
  aggregationExp: aggregationExp,
434
- aggregationResLevel: aggregationResLevel
460
+ aggregationResLevel: aggregationResLevel,
461
+ queryParameters: queryParameters
435
462
  });
436
463
 
437
464
  case 7:
@@ -503,21 +530,23 @@ function _fetchDataUrl2() {
503
530
  return _fetchDataUrl2.apply(this, arguments);
504
531
  }
505
532
 
506
- function _fetchMapDataset(_x7, _x8, _x9, _x10) {
533
+ function _fetchMapDataset(_x7, _x8, _x9, _x10, _x11, _x12) {
507
534
  return _fetchMapDataset2.apply(this, arguments);
508
535
  }
509
536
 
510
537
  function _fetchMapDataset2() {
511
- _fetchMapDataset2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(dataset, accessToken, credentials, clientId) {
512
- var connection, columns, format, geoColumn, source, type, _yield$_fetchDataUrl2, url, mapFormat, cache;
538
+ _fetchMapDataset2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(dataset, accessToken, credentials, clientId, headers, queryParameters) {
539
+ var aggregationExp, aggregationResLevel, connection, columns, format, geoColumn, source, type, _yield$_fetchDataUrl2, url, mapFormat, cache;
513
540
 
514
541
  return _regenerator.default.wrap(function _callee7$(_context7) {
515
542
  while (1) {
516
543
  switch (_context7.prev = _context7.next) {
517
544
  case 0:
518
- connection = dataset.connectionName, columns = dataset.columns, format = dataset.format, geoColumn = dataset.geoColumn, source = dataset.source, type = dataset.type;
545
+ aggregationExp = dataset.aggregationExp, aggregationResLevel = dataset.aggregationResLevel, connection = dataset.connectionName, columns = dataset.columns, format = dataset.format, geoColumn = dataset.geoColumn, source = dataset.source, type = dataset.type;
519
546
  _context7.next = 3;
520
547
  return _fetchDataUrl({
548
+ aggregationExp: aggregationExp,
549
+ aggregationResLevel: aggregationResLevel,
521
550
  clientId: clientId,
522
551
  credentials: _objectSpread(_objectSpread({}, credentials), {}, {
523
552
  accessToken: accessToken
@@ -526,8 +555,10 @@ function _fetchMapDataset2() {
526
555
  columns: columns,
527
556
  format: format,
528
557
  geoColumn: geoColumn,
558
+ headers: headers,
529
559
  source: source,
530
- type: type
560
+ type: type,
561
+ queryParameters: queryParameters
531
562
  });
532
563
 
533
564
  case 3:
@@ -566,49 +597,186 @@ function _fetchMapDataset2() {
566
597
  return _fetchMapDataset2.apply(this, arguments);
567
598
  }
568
599
 
569
- function fillInMapDatasets(_x11, _x12, _x13) {
600
+ function _fetchTilestats(_x13, _x14, _x15, _x16) {
601
+ return _fetchTilestats2.apply(this, arguments);
602
+ }
603
+
604
+ function _fetchTilestats2() {
605
+ _fetchTilestats2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee8(attribute, dataset, accessToken, credentials) {
606
+ var connection, source, type, statsUrl, url, stats, attributes, index;
607
+ return _regenerator.default.wrap(function _callee8$(_context8) {
608
+ while (1) {
609
+ switch (_context8.prev = _context8.next) {
610
+ case 0:
611
+ connection = dataset.connectionName, source = dataset.source, type = dataset.type;
612
+ statsUrl = (0, _config.buildStatsUrlFromBase)(credentials.apiBaseUrl);
613
+ url = "".concat(statsUrl, "/").concat(connection, "/");
614
+
615
+ if (type === _mapsApiCommon.MAP_TYPES.QUERY) {
616
+ url += "".concat(attribute, "?q=").concat(source);
617
+ } else {
618
+ url += "".concat(source, "/").concat(attribute);
619
+ }
620
+
621
+ _context8.next = 6;
622
+ return requestData({
623
+ url: url,
624
+ format: _mapsApiCommon.FORMATS.JSON,
625
+ accessToken: accessToken
626
+ });
627
+
628
+ case 6:
629
+ stats = _context8.sent;
630
+ attributes = dataset.data.tilestats.layers[0].attributes;
631
+ index = attributes.findIndex(function (d) {
632
+ return d.attribute === attribute;
633
+ });
634
+ attributes[index] = stats;
635
+ return _context8.abrupt("return", true);
636
+
637
+ case 11:
638
+ case "end":
639
+ return _context8.stop();
640
+ }
641
+ }
642
+ }, _callee8);
643
+ }));
644
+ return _fetchTilestats2.apply(this, arguments);
645
+ }
646
+
647
+ function fillInMapDatasets(_x17, _x18, _x19, _x20) {
570
648
  return _fillInMapDatasets.apply(this, arguments);
571
649
  }
572
650
 
573
651
  function _fillInMapDatasets() {
574
- _fillInMapDatasets = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee8(_ref10, clientId, credentials) {
652
+ _fillInMapDatasets = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee9(_ref10, clientId, credentials, headers) {
575
653
  var datasets, token, promises;
576
- return _regenerator.default.wrap(function _callee8$(_context8) {
654
+ return _regenerator.default.wrap(function _callee9$(_context9) {
577
655
  while (1) {
578
- switch (_context8.prev = _context8.next) {
656
+ switch (_context9.prev = _context9.next) {
579
657
  case 0:
580
658
  datasets = _ref10.datasets, token = _ref10.token;
581
659
  promises = datasets.map(function (dataset) {
582
- return _fetchMapDataset(dataset, token, credentials, clientId);
660
+ return _fetchMapDataset(dataset, token, credentials, clientId, headers);
583
661
  });
584
- _context8.next = 4;
662
+ _context9.next = 4;
585
663
  return Promise.all(promises);
586
664
 
587
665
  case 4:
588
- return _context8.abrupt("return", _context8.sent);
666
+ return _context9.abrupt("return", _context9.sent);
589
667
 
590
668
  case 5:
591
669
  case "end":
592
- return _context8.stop();
670
+ return _context9.stop();
593
671
  }
594
672
  }
595
- }, _callee8);
673
+ }, _callee9);
596
674
  }));
597
675
  return _fillInMapDatasets.apply(this, arguments);
598
676
  }
599
677
 
600
- function fetchMap(_x14) {
601
- return _fetchMap.apply(this, arguments);
678
+ function fillInTileStats(_x21, _x22) {
679
+ return _fillInTileStats.apply(this, arguments);
602
680
  }
603
681
 
604
- function _fetchMap() {
605
- _fetchMap = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee10(_ref11) {
606
- var cartoMapId, clientId, credentials, autoRefresh, onNewData, defaultCredentials, localCreds, accessToken, url, map, stopAutoRefresh, intervalId, geojsonLayers, geojsonDatasetIds;
682
+ function _fillInTileStats() {
683
+ _fillInTileStats = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee10(_ref11, credentials) {
684
+ var datasets, keplerMapConfig, token, attributes, layers, _iterator, _step, _loop2, filteredAttributes, _loop, _i2, _attributes, promises;
685
+
607
686
  return _regenerator.default.wrap(function _callee10$(_context10) {
608
687
  while (1) {
609
688
  switch (_context10.prev = _context10.next) {
610
689
  case 0:
611
- cartoMapId = _ref11.cartoMapId, clientId = _ref11.clientId, credentials = _ref11.credentials, autoRefresh = _ref11.autoRefresh, onNewData = _ref11.onNewData;
690
+ datasets = _ref11.datasets, keplerMapConfig = _ref11.keplerMapConfig, token = _ref11.token;
691
+ attributes = [];
692
+ layers = keplerMapConfig.config.visState.layers;
693
+ _iterator = _createForOfIteratorHelper(layers);
694
+
695
+ try {
696
+ _loop2 = function _loop2() {
697
+ var layer = _step.value;
698
+
699
+ for (var _i3 = 0, _Object$keys = Object.keys(layer.visualChannels); _i3 < _Object$keys.length; _i3++) {
700
+ var _layer$visualChannels;
701
+
702
+ var channel = _Object$keys[_i3];
703
+ var attribute = (_layer$visualChannels = layer.visualChannels[channel]) === null || _layer$visualChannels === void 0 ? void 0 : _layer$visualChannels.name;
704
+
705
+ if (attribute) {
706
+ var dataset = datasets.find(function (d) {
707
+ return d.id === layer.config.dataId;
708
+ });
709
+
710
+ if (dataset.data.tilestats && dataset.type !== _mapsApiCommon.MAP_TYPES.TILESET) {
711
+ attributes.push({
712
+ attribute: attribute,
713
+ dataset: dataset
714
+ });
715
+ }
716
+ }
717
+ }
718
+ };
719
+
720
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
721
+ _loop2();
722
+ }
723
+ } catch (err) {
724
+ _iterator.e(err);
725
+ } finally {
726
+ _iterator.f();
727
+ }
728
+
729
+ filteredAttributes = [];
730
+
731
+ _loop = function _loop() {
732
+ var a = _attributes[_i2];
733
+
734
+ if (!filteredAttributes.find(function (_ref13) {
735
+ var attribute = _ref13.attribute,
736
+ dataset = _ref13.dataset;
737
+ return attribute === a.attribute && dataset === a.dataset;
738
+ })) {
739
+ filteredAttributes.push(a);
740
+ }
741
+ };
742
+
743
+ for (_i2 = 0, _attributes = attributes; _i2 < _attributes.length; _i2++) {
744
+ _loop();
745
+ }
746
+
747
+ promises = filteredAttributes.map(function (_ref14) {
748
+ var attribute = _ref14.attribute,
749
+ dataset = _ref14.dataset;
750
+ return _fetchTilestats(attribute, dataset, token, credentials);
751
+ });
752
+ _context10.next = 11;
753
+ return Promise.all(promises);
754
+
755
+ case 11:
756
+ return _context10.abrupt("return", _context10.sent);
757
+
758
+ case 12:
759
+ case "end":
760
+ return _context10.stop();
761
+ }
762
+ }
763
+ }, _callee10);
764
+ }));
765
+ return _fillInTileStats.apply(this, arguments);
766
+ }
767
+
768
+ function fetchMap(_x23) {
769
+ return _fetchMap.apply(this, arguments);
770
+ }
771
+
772
+ function _fetchMap() {
773
+ _fetchMap = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee12(_ref12) {
774
+ var cartoMapId, clientId, credentials, headers, autoRefresh, onNewData, defaultCredentials, localCreds, accessToken, url, map, stopAutoRefresh, intervalId, geojsonLayers, geojsonDatasetIds;
775
+ return _regenerator.default.wrap(function _callee12$(_context12) {
776
+ while (1) {
777
+ switch (_context12.prev = _context12.next) {
778
+ case 0:
779
+ cartoMapId = _ref12.cartoMapId, clientId = _ref12.clientId, credentials = _ref12.credentials, headers = _ref12.headers, autoRefresh = _ref12.autoRefresh, onNewData = _ref12.onNewData;
612
780
  defaultCredentials = (0, _config.getDefaultCredentials)();
613
781
  localCreds = _objectSpread(_objectSpread({}, defaultCredentials.apiVersion === _mapsApiCommon.API_VERSIONS.V3 && defaultCredentials), credentials);
614
782
  accessToken = localCreds.accessToken;
@@ -627,27 +795,28 @@ function _fetchMap() {
627
795
  }
628
796
 
629
797
  url = "".concat(localCreds.mapsUrl, "/public/").concat(cartoMapId);
630
- _context10.next = 12;
798
+ _context12.next = 12;
631
799
  return requestJson({
632
800
  url: url,
801
+ headers: headers,
633
802
  accessToken: accessToken
634
803
  });
635
804
 
636
805
  case 12:
637
- map = _context10.sent;
806
+ map = _context12.sent;
638
807
 
639
808
  if (autoRefresh) {
640
- intervalId = setInterval((0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee9() {
809
+ intervalId = setInterval((0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee11() {
641
810
  var changed;
642
- return _regenerator.default.wrap(function _callee9$(_context9) {
811
+ return _regenerator.default.wrap(function _callee11$(_context11) {
643
812
  while (1) {
644
- switch (_context9.prev = _context9.next) {
813
+ switch (_context11.prev = _context11.next) {
645
814
  case 0:
646
- _context9.next = 2;
647
- return fillInMapDatasets(map, clientId, localCreds);
815
+ _context11.next = 2;
816
+ return fillInMapDatasets(map, clientId, localCreds, headers);
648
817
 
649
818
  case 2:
650
- changed = _context9.sent;
819
+ changed = _context11.sent;
651
820
 
652
821
  if (onNewData && changed.some(function (v) {
653
822
  return v === true;
@@ -657,10 +826,10 @@ function _fetchMap() {
657
826
 
658
827
  case 4:
659
828
  case "end":
660
- return _context9.stop();
829
+ return _context11.stop();
661
830
  }
662
831
  }
663
- }, _callee9);
832
+ }, _callee11);
664
833
  })), autoRefresh * 1000);
665
834
 
666
835
  stopAutoRefresh = function stopAutoRefresh() {
@@ -668,12 +837,12 @@ function _fetchMap() {
668
837
  };
669
838
  }
670
839
 
671
- geojsonLayers = map.keplerMapConfig.config.visState.layers.filter(function (_ref13) {
672
- var type = _ref13.type;
840
+ geojsonLayers = map.keplerMapConfig.config.visState.layers.filter(function (_ref16) {
841
+ var type = _ref16.type;
673
842
  return type === 'geojson' || type === 'point';
674
843
  });
675
- geojsonDatasetIds = geojsonLayers.map(function (_ref14) {
676
- var config = _ref14.config;
844
+ geojsonDatasetIds = geojsonLayers.map(function (_ref17) {
845
+ var config = _ref17.config;
677
846
  return config.dataId;
678
847
  });
679
848
  map.datasets.forEach(function (dataset) {
@@ -681,20 +850,24 @@ function _fetchMap() {
681
850
  dataset.format = 'geojson';
682
851
  }
683
852
  });
684
- _context10.next = 19;
685
- return fillInMapDatasets(map, clientId, localCreds);
853
+ _context12.next = 19;
854
+ return fillInMapDatasets(map, clientId, localCreds, headers);
686
855
 
687
856
  case 19:
688
- return _context10.abrupt("return", _objectSpread(_objectSpread({}, (0, _parseMap.parseMap)(map)), {
857
+ _context12.next = 21;
858
+ return fillInTileStats(map, localCreds);
859
+
860
+ case 21:
861
+ return _context12.abrupt("return", _objectSpread(_objectSpread({}, (0, _parseMap.parseMap)(map)), {
689
862
  stopAutoRefresh: stopAutoRefresh
690
863
  }));
691
864
 
692
- case 20:
865
+ case 22:
693
866
  case "end":
694
- return _context10.stop();
867
+ return _context12.stop();
695
868
  }
696
869
  }
697
- }, _callee10);
870
+ }, _callee12);
698
871
  }));
699
872
  return _fetchMap.apply(this, arguments);
700
873
  }