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