@nextgis/geocoder 2.4.1 → 3.0.0-alpha.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/lib/geocoder.cjs.js +54 -65
- package/lib/geocoder.cjs.js.map +1 -1
- package/lib/geocoder.cjs.prod.js +1 -1
- package/lib/geocoder.cjs.prod.js.map +1 -1
- package/lib/geocoder.esm-browser.js +447 -650
- package/lib/geocoder.esm-browser.js.map +1 -1
- package/lib/geocoder.esm-browser.prod.js +1 -1
- package/lib/geocoder.esm-browser.prod.js.map +1 -1
- package/lib/geocoder.esm-bundler.js +54 -65
- package/lib/geocoder.esm-bundler.js.map +1 -1
- package/lib/geocoder.esm-bundler.prod.js +1 -1
- package/lib/geocoder.esm-bundler.prod.js.map +1 -1
- package/lib/geocoder.global.js +447 -650
- package/lib/geocoder.global.js.map +1 -1
- package/lib/geocoder.global.prod.js +1 -1
- package/lib/geocoder.global.prod.js.map +1 -1
- package/lib/index.d.ts +6 -7
- package/package.json +7 -7
package/lib/geocoder.global.js
CHANGED
|
@@ -1,309 +1,7 @@
|
|
|
1
|
-
/** Bundle of @nextgis/geocoder; version:
|
|
1
|
+
/** Bundle of @nextgis/geocoder; version: 3.0.0-alpha.0; author: NextGIS */
|
|
2
2
|
var Geocoder = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
var __defProp$g = Object.defineProperty;
|
|
6
|
-
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
-
var __publicField$e = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
-
class CancelError extends Error {
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
__publicField$e(this, "name", "CancelError");
|
|
12
|
-
Object.setPrototypeOf(this, CancelError.prototype);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
var __defProp$f = Object.defineProperty;
|
|
17
|
-
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
18
|
-
var __publicField$d = (obj, key, value) => __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
19
|
-
class PromiseControl {
|
|
20
|
-
constructor(options = {}) {
|
|
21
|
-
this.options = options;
|
|
22
|
-
__publicField$d(this, "_promises", /* @__PURE__ */ new Map());
|
|
23
|
-
}
|
|
24
|
-
get isLoaded() {
|
|
25
|
-
return this._promises.size > 0;
|
|
26
|
-
}
|
|
27
|
-
remove(promise) {
|
|
28
|
-
if (this._promises.has(promise)) {
|
|
29
|
-
this._promises.delete(promise);
|
|
30
|
-
this._onStop();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
get(promise) {
|
|
34
|
-
return this._promises.get(promise);
|
|
35
|
-
}
|
|
36
|
-
add(promise, name) {
|
|
37
|
-
const key = name ? name : promise;
|
|
38
|
-
const exist = this._promises.get(key);
|
|
39
|
-
if (this.options.onStart && !this.isLoaded) {
|
|
40
|
-
this.options.onStart();
|
|
41
|
-
}
|
|
42
|
-
if (exist) {
|
|
43
|
-
return exist;
|
|
44
|
-
}
|
|
45
|
-
this._promises.set(key, promise);
|
|
46
|
-
promise.finally(() => {
|
|
47
|
-
this.remove(key);
|
|
48
|
-
});
|
|
49
|
-
return promise;
|
|
50
|
-
}
|
|
51
|
-
abort() {
|
|
52
|
-
if (this.isLoaded) {
|
|
53
|
-
this._promises.forEach((x) => {
|
|
54
|
-
if (x.cancel) {
|
|
55
|
-
x.cancel();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
this._promises.clear();
|
|
59
|
-
this._onStop();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
waitFunc(func, name = "") {
|
|
63
|
-
name = name || func.name;
|
|
64
|
-
const exist = this.get(name);
|
|
65
|
-
if (exist) {
|
|
66
|
-
return exist;
|
|
67
|
-
}
|
|
68
|
-
return this.add(func(), name);
|
|
69
|
-
}
|
|
70
|
-
WaitForMe(name = "") {
|
|
71
|
-
const get = this.get.bind(this);
|
|
72
|
-
const add = this.add.bind(this);
|
|
73
|
-
return function(target, key, descriptor) {
|
|
74
|
-
const originalMethod = descriptor.value;
|
|
75
|
-
name = name || key;
|
|
76
|
-
descriptor.value = function(...args) {
|
|
77
|
-
const exist = get(name);
|
|
78
|
-
if (exist) {
|
|
79
|
-
return exist;
|
|
80
|
-
}
|
|
81
|
-
const result = add(originalMethod.apply(this, args), name);
|
|
82
|
-
return result;
|
|
83
|
-
};
|
|
84
|
-
return descriptor;
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
/** @deprecated use {@link PromiseControl.WaitForMe } instead */
|
|
88
|
-
GetOrCreateDecorator(name = "") {
|
|
89
|
-
return this.WaitForMe(name);
|
|
90
|
-
}
|
|
91
|
-
_onStop() {
|
|
92
|
-
if (this.options.onStop && !this.isLoaded) {
|
|
93
|
-
this.options.onStop();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
var __defProp$e = Object.defineProperty;
|
|
99
|
-
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
100
|
-
var __publicField$c = (obj, key, value) => __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
101
|
-
class TimeoutError extends Error {
|
|
102
|
-
constructor() {
|
|
103
|
-
super();
|
|
104
|
-
__publicField$c(this, "name", "TimeoutError");
|
|
105
|
-
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
var __defProp$d = Object.defineProperty;
|
|
110
|
-
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
111
|
-
var __publicField$b = (obj, key, value) => __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
112
|
-
var _a;
|
|
113
|
-
const handleCallback = (resolve, reject, callback, r) => {
|
|
114
|
-
try {
|
|
115
|
-
resolve(callback(r));
|
|
116
|
-
} catch (e) {
|
|
117
|
-
reject(e);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
let ID$2 = 0;
|
|
121
|
-
_a = Symbol.toStringTag;
|
|
122
|
-
const _CancelablePromise = class _CancelablePromise {
|
|
123
|
-
constructor(executor, timeout) {
|
|
124
|
-
// @ts-ignore
|
|
125
|
-
__publicField$b(this, _a);
|
|
126
|
-
__publicField$b(this, "id", ID$2++);
|
|
127
|
-
__publicField$b(this, "_isCanceled", false);
|
|
128
|
-
__publicField$b(this, "_isPending", true);
|
|
129
|
-
__publicField$b(this, "_promise");
|
|
130
|
-
__publicField$b(this, "_cancelPromise");
|
|
131
|
-
__publicField$b(this, "_cancelHandlers", []);
|
|
132
|
-
__publicField$b(this, "_setCanceledCallback");
|
|
133
|
-
__publicField$b(this, "_parentPromise");
|
|
134
|
-
__publicField$b(this, "_children", []);
|
|
135
|
-
this._cancelPromise = new Promise((resolve_, reject_) => {
|
|
136
|
-
this._setCanceledCallback = (er) => resolve_(er || new CancelError());
|
|
137
|
-
});
|
|
138
|
-
const promises = [
|
|
139
|
-
this._cancelPromise,
|
|
140
|
-
new Promise((resolve, reject) => {
|
|
141
|
-
const onResolve = (value) => {
|
|
142
|
-
if (value instanceof _CancelablePromise) {
|
|
143
|
-
this.attach(value);
|
|
144
|
-
} else {
|
|
145
|
-
this._isPending = false;
|
|
146
|
-
}
|
|
147
|
-
resolve(value);
|
|
148
|
-
};
|
|
149
|
-
const onReject = (error) => {
|
|
150
|
-
this._isPending = false;
|
|
151
|
-
reject(error);
|
|
152
|
-
};
|
|
153
|
-
const onCancel = (handler) => {
|
|
154
|
-
if (!this._isPending) {
|
|
155
|
-
throw new Error(
|
|
156
|
-
"The `onCancel` handler was attached after the promise settled."
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
this._cancelHandlers.push(handler);
|
|
160
|
-
};
|
|
161
|
-
return executor(onResolve, onReject, onCancel);
|
|
162
|
-
})
|
|
163
|
-
];
|
|
164
|
-
if (timeout) {
|
|
165
|
-
promises.push(
|
|
166
|
-
new Promise((resolve, reject) => {
|
|
167
|
-
setTimeout(() => {
|
|
168
|
-
if (this._isPending) {
|
|
169
|
-
try {
|
|
170
|
-
this.cancel();
|
|
171
|
-
} finally {
|
|
172
|
-
reject(new TimeoutError());
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}, timeout);
|
|
176
|
-
})
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
this._promise = Promise.race(promises);
|
|
180
|
-
}
|
|
181
|
-
static createControl(opt) {
|
|
182
|
-
return new PromiseControl(opt);
|
|
183
|
-
}
|
|
184
|
-
static resolve(value) {
|
|
185
|
-
return new _CancelablePromise((resolve) => resolve(value));
|
|
186
|
-
}
|
|
187
|
-
static reject(value) {
|
|
188
|
-
return new _CancelablePromise((resolve, reject) => reject(value));
|
|
189
|
-
}
|
|
190
|
-
static all(values) {
|
|
191
|
-
return new _CancelablePromise((resolve, reject) => {
|
|
192
|
-
Promise.all(values).then(resolve).catch(reject);
|
|
193
|
-
}).catch((er) => {
|
|
194
|
-
if (er instanceof this.CancelError) {
|
|
195
|
-
for (const v of values) {
|
|
196
|
-
const v_ = v;
|
|
197
|
-
if ("cancel" in v_) {
|
|
198
|
-
v_.cancel();
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
throw er;
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
attach(p) {
|
|
206
|
-
if (this._isCanceled) {
|
|
207
|
-
p.cancel();
|
|
208
|
-
} else {
|
|
209
|
-
this._children.push(p);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
then(onfulfilled, onrejected) {
|
|
213
|
-
const p = new _CancelablePromise((resolve, reject) => {
|
|
214
|
-
if (this._promise) {
|
|
215
|
-
const reject_ = (r) => {
|
|
216
|
-
if (onrejected) {
|
|
217
|
-
handleCallback(resolve, reject, onrejected, r);
|
|
218
|
-
} else {
|
|
219
|
-
reject(r);
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
this._promise.then((r) => {
|
|
223
|
-
if (this._isCanceled) {
|
|
224
|
-
reject_(r);
|
|
225
|
-
} else {
|
|
226
|
-
if (onfulfilled) {
|
|
227
|
-
handleCallback(resolve, reject, onfulfilled, r);
|
|
228
|
-
} else {
|
|
229
|
-
resolve(r);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}, reject_);
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
p._parentPromise = this;
|
|
236
|
-
this._children.push(p);
|
|
237
|
-
return p;
|
|
238
|
-
}
|
|
239
|
-
catch(onrejected) {
|
|
240
|
-
if (this._isCanceled && onrejected) {
|
|
241
|
-
onrejected(new CancelError());
|
|
242
|
-
}
|
|
243
|
-
return this.then(void 0, onrejected);
|
|
244
|
-
}
|
|
245
|
-
finally(onfinally) {
|
|
246
|
-
if (this._promise) {
|
|
247
|
-
return this._promise.finally(onfinally);
|
|
248
|
-
}
|
|
249
|
-
if (this._isCanceled) {
|
|
250
|
-
return Promise.reject(new CancelError());
|
|
251
|
-
}
|
|
252
|
-
return Promise.reject(onfinally);
|
|
253
|
-
}
|
|
254
|
-
cancel() {
|
|
255
|
-
if (this._isCanceled || !this._isPending) {
|
|
256
|
-
return this;
|
|
257
|
-
}
|
|
258
|
-
this._isCanceled = true;
|
|
259
|
-
const parent = this._getTopParent();
|
|
260
|
-
if (parent) {
|
|
261
|
-
parent.cancel();
|
|
262
|
-
}
|
|
263
|
-
if (this._children) {
|
|
264
|
-
this._children.forEach((x) => x.cancel());
|
|
265
|
-
}
|
|
266
|
-
if (this._isPending) {
|
|
267
|
-
if (this._cancelHandlers.length) {
|
|
268
|
-
try {
|
|
269
|
-
for (const handler of this._cancelHandlers) {
|
|
270
|
-
handler();
|
|
271
|
-
}
|
|
272
|
-
} catch (error) {
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
if (this._setCanceledCallback) {
|
|
276
|
-
this._setCanceledCallback();
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
this._destroy();
|
|
280
|
-
return this;
|
|
281
|
-
}
|
|
282
|
-
_getTopParent() {
|
|
283
|
-
let parent = this._parentPromise;
|
|
284
|
-
let hasParent = !!parent;
|
|
285
|
-
while (hasParent) {
|
|
286
|
-
if (parent && parent._parentPromise) {
|
|
287
|
-
parent = parent._parentPromise;
|
|
288
|
-
hasParent = !!parent;
|
|
289
|
-
} else {
|
|
290
|
-
hasParent = false;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return parent;
|
|
294
|
-
}
|
|
295
|
-
_destroy() {
|
|
296
|
-
this._setCanceledCallback = void 0;
|
|
297
|
-
this._cancelPromise = void 0;
|
|
298
|
-
this._promise = void 0;
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
__publicField$b(_CancelablePromise, "CancelError", CancelError);
|
|
302
|
-
__publicField$b(_CancelablePromise, "TimeoutError", TimeoutError);
|
|
303
|
-
__publicField$b(_CancelablePromise, "PromiseControl", PromiseControl);
|
|
304
|
-
let CancelablePromise = _CancelablePromise;
|
|
305
|
-
Object.setPrototypeOf(CancelablePromise.prototype, Promise.prototype);
|
|
306
|
-
|
|
307
5
|
function defined(val) {
|
|
308
6
|
return val !== void 0 && val !== null;
|
|
309
7
|
}
|
|
@@ -386,7 +84,7 @@ var Geocoder = (function (exports) {
|
|
|
386
84
|
}
|
|
387
85
|
|
|
388
86
|
function round(val, toFixed) {
|
|
389
|
-
const n =
|
|
87
|
+
const n = 1;
|
|
390
88
|
return Math.round((val + Number.EPSILON) * n) / n;
|
|
391
89
|
}
|
|
392
90
|
|
|
@@ -409,28 +107,28 @@ var Geocoder = (function (exports) {
|
|
|
409
107
|
}
|
|
410
108
|
}
|
|
411
109
|
|
|
412
|
-
var __defProp$
|
|
110
|
+
var __defProp$d = Object.defineProperty;
|
|
413
111
|
var __defProps$3 = Object.defineProperties;
|
|
414
112
|
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
415
|
-
var __getOwnPropSymbols$
|
|
416
|
-
var __hasOwnProp$
|
|
417
|
-
var __propIsEnum$
|
|
113
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
114
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
115
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
418
116
|
var __knownSymbol$2 = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
419
|
-
var __defNormalProp$
|
|
420
|
-
var __spreadValues$
|
|
117
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
118
|
+
var __spreadValues$6 = (a, b) => {
|
|
421
119
|
for (var prop in b || (b = {}))
|
|
422
|
-
if (__hasOwnProp$
|
|
423
|
-
__defNormalProp$
|
|
424
|
-
if (__getOwnPropSymbols$
|
|
425
|
-
for (var prop of __getOwnPropSymbols$
|
|
426
|
-
if (__propIsEnum$
|
|
427
|
-
__defNormalProp$
|
|
120
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
121
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
122
|
+
if (__getOwnPropSymbols$6)
|
|
123
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
124
|
+
if (__propIsEnum$6.call(b, prop))
|
|
125
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
428
126
|
}
|
|
429
127
|
return a;
|
|
430
128
|
};
|
|
431
129
|
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
432
|
-
var __publicField$a = (obj, key, value) => __defNormalProp$
|
|
433
|
-
var __async$
|
|
130
|
+
var __publicField$a = (obj, key, value) => __defNormalProp$d(obj, key + "" , value);
|
|
131
|
+
var __async$5 = (__this, __arguments, generator) => {
|
|
434
132
|
return new Promise((resolve, reject) => {
|
|
435
133
|
var fulfilled = (value) => {
|
|
436
134
|
try {
|
|
@@ -494,7 +192,7 @@ var Geocoder = (function (exports) {
|
|
|
494
192
|
for (var iter = __forAwait(results), more, temp, error; more = !(temp = yield new __await$2(iter.next())).done; more = false) {
|
|
495
193
|
const r = temp.value;
|
|
496
194
|
allProvidersFailed = false;
|
|
497
|
-
yield __spreadProps$3(__spreadValues$
|
|
195
|
+
yield __spreadProps$3(__spreadValues$6({}, r), { provider, _id: ID$1++ });
|
|
498
196
|
}
|
|
499
197
|
} catch (temp) {
|
|
500
198
|
error = [temp];
|
|
@@ -524,7 +222,7 @@ var Geocoder = (function (exports) {
|
|
|
524
222
|
if (item.provider) {
|
|
525
223
|
return item.provider.result(item);
|
|
526
224
|
}
|
|
527
|
-
return
|
|
225
|
+
return Promise.resolve(void 0);
|
|
528
226
|
}
|
|
529
227
|
reverse(coordinates) {
|
|
530
228
|
return __asyncGenerator$2(this, null, function* () {
|
|
@@ -537,7 +235,7 @@ var Geocoder = (function (exports) {
|
|
|
537
235
|
try {
|
|
538
236
|
for (var iter = __forAwait(results), more, temp, error; more = !(temp = yield new __await$2(iter.next())).done; more = false) {
|
|
539
237
|
const r = temp.value;
|
|
540
|
-
yield __spreadProps$3(__spreadValues$
|
|
238
|
+
yield __spreadProps$3(__spreadValues$6({}, r), { provider, _id: ID$1++ });
|
|
541
239
|
}
|
|
542
240
|
} catch (temp) {
|
|
543
241
|
error = [temp];
|
|
@@ -561,7 +259,7 @@ var Geocoder = (function (exports) {
|
|
|
561
259
|
* @returns A promise that resolves to the first reverse geocoding result, or undefined if no results are found.
|
|
562
260
|
*/
|
|
563
261
|
reverseGeocodeFirstResult(coordinates) {
|
|
564
|
-
return __async$
|
|
262
|
+
return __async$5(this, null, function* () {
|
|
565
263
|
for (const provider of this.providers) {
|
|
566
264
|
if (typeof provider.reverse === "function") {
|
|
567
265
|
try {
|
|
@@ -590,9 +288,9 @@ var Geocoder = (function (exports) {
|
|
|
590
288
|
}
|
|
591
289
|
}
|
|
592
290
|
|
|
593
|
-
var __defProp$
|
|
594
|
-
var __defNormalProp$
|
|
595
|
-
var __publicField$9 = (obj, key, value) => __defNormalProp$
|
|
291
|
+
var __defProp$c = Object.defineProperty;
|
|
292
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
293
|
+
var __publicField$9 = (obj, key, value) => __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
596
294
|
class BaseProvider extends BaseGeocoder {
|
|
597
295
|
constructor() {
|
|
598
296
|
super(...arguments);
|
|
@@ -1081,9 +779,9 @@ var Geocoder = (function (exports) {
|
|
|
1081
779
|
return ret;
|
|
1082
780
|
}
|
|
1083
781
|
|
|
1084
|
-
var __defProp$
|
|
1085
|
-
var __defNormalProp$
|
|
1086
|
-
var __publicField$8 = (obj, key, value) => __defNormalProp$
|
|
782
|
+
var __defProp$b = Object.defineProperty;
|
|
783
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
784
|
+
var __publicField$8 = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1087
785
|
const _Cache = class _Cache {
|
|
1088
786
|
constructor(options = {}) {
|
|
1089
787
|
__publicField$8(this, "cache", []);
|
|
@@ -1119,8 +817,7 @@ var Geocoder = (function (exports) {
|
|
|
1119
817
|
* // somewhere else in the code
|
|
1120
818
|
* const item = await cache.addFull('foo', getItemFunc).then((resp) => {
|
|
1121
819
|
* console.log(resp); // 'New item'
|
|
1122
|
-
* })
|
|
1123
|
-
*
|
|
820
|
+
* });
|
|
1124
821
|
* ```
|
|
1125
822
|
*/
|
|
1126
823
|
addFull(key, valueToSet, props) {
|
|
@@ -1135,13 +832,11 @@ var Geocoder = (function (exports) {
|
|
|
1135
832
|
} else {
|
|
1136
833
|
value = valueToSet;
|
|
1137
834
|
}
|
|
1138
|
-
const
|
|
835
|
+
const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
|
|
1139
836
|
const cacheItem = {
|
|
1140
837
|
key,
|
|
1141
838
|
value,
|
|
1142
|
-
props:
|
|
1143
|
-
// TODO: remove backward compatibility use only props
|
|
1144
|
-
options: props_
|
|
839
|
+
props: nonEmptyProps
|
|
1145
840
|
};
|
|
1146
841
|
if (onlyFull && !full(value)) {
|
|
1147
842
|
return value;
|
|
@@ -1150,7 +845,6 @@ var Geocoder = (function (exports) {
|
|
|
1150
845
|
if (value instanceof Promise) {
|
|
1151
846
|
value.catch((er) => {
|
|
1152
847
|
this.delete(key, props);
|
|
1153
|
-
throw er;
|
|
1154
848
|
});
|
|
1155
849
|
if (onlyFull) {
|
|
1156
850
|
value.then((x) => {
|
|
@@ -1169,9 +863,7 @@ var Geocoder = (function (exports) {
|
|
|
1169
863
|
}
|
|
1170
864
|
match(key, props) {
|
|
1171
865
|
const cacheRecord = this._find(key, props);
|
|
1172
|
-
|
|
1173
|
-
return cacheRecord.value;
|
|
1174
|
-
}
|
|
866
|
+
return cacheRecord == null ? void 0 : cacheRecord.value;
|
|
1175
867
|
}
|
|
1176
868
|
matchAll(key, props) {
|
|
1177
869
|
if (key) {
|
|
@@ -1180,37 +872,30 @@ var Geocoder = (function (exports) {
|
|
|
1180
872
|
return this.cache.map((x) => x.value);
|
|
1181
873
|
}
|
|
1182
874
|
delete(keyOrItem, props) {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
for (const e of exist) {
|
|
1190
|
-
const index = this.cache.indexOf(e);
|
|
1191
|
-
this.cache.splice(index, 1);
|
|
875
|
+
const itemsToDelete = typeof keyOrItem === "string" ? this.cache.filter((x) => this._filter(x, keyOrItem, props)) : [keyOrItem];
|
|
876
|
+
for (const item of itemsToDelete) {
|
|
877
|
+
const index = this.cache.indexOf(item);
|
|
878
|
+
if (index !== -1) {
|
|
879
|
+
this.cache.splice(index, 1);
|
|
880
|
+
}
|
|
1192
881
|
}
|
|
1193
882
|
}
|
|
1194
883
|
_find(key, props) {
|
|
1195
884
|
return this.cache.find((x) => this._filter(x, key, props));
|
|
1196
885
|
}
|
|
1197
886
|
_filter(item, key, props) {
|
|
1198
|
-
if (item.key
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
}
|
|
1203
|
-
return true;
|
|
1204
|
-
}
|
|
1205
|
-
return false;
|
|
887
|
+
if (item.key !== key) return false;
|
|
888
|
+
if (!props) return true;
|
|
889
|
+
const itemProps = item.props;
|
|
890
|
+
return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
|
|
1206
891
|
}
|
|
1207
892
|
};
|
|
1208
893
|
__publicField$8(_Cache, "instance", {});
|
|
1209
894
|
let Cache = _Cache;
|
|
1210
895
|
|
|
1211
|
-
var __defProp$
|
|
1212
|
-
var __defNormalProp$
|
|
1213
|
-
var __publicField$7 = (obj, key, value) => __defNormalProp$
|
|
896
|
+
var __defProp$a = Object.defineProperty;
|
|
897
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
898
|
+
var __publicField$7 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1214
899
|
class NgwError extends Error {
|
|
1215
900
|
constructor(er) {
|
|
1216
901
|
super();
|
|
@@ -1227,9 +912,9 @@ var Geocoder = (function (exports) {
|
|
|
1227
912
|
}
|
|
1228
913
|
}
|
|
1229
914
|
|
|
1230
|
-
var __defProp$
|
|
1231
|
-
var __defNormalProp$
|
|
1232
|
-
var __publicField$6 = (obj, key, value) => __defNormalProp$
|
|
915
|
+
var __defProp$9 = Object.defineProperty;
|
|
916
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
917
|
+
var __publicField$6 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1233
918
|
class ResourceNotFoundError extends NgwError {
|
|
1234
919
|
constructor(obj) {
|
|
1235
920
|
super(obj);
|
|
@@ -1268,27 +953,24 @@ var Geocoder = (function (exports) {
|
|
|
1268
953
|
return query;
|
|
1269
954
|
}
|
|
1270
955
|
|
|
1271
|
-
var __defProp$
|
|
1272
|
-
var
|
|
1273
|
-
var
|
|
1274
|
-
var
|
|
1275
|
-
var
|
|
1276
|
-
var
|
|
1277
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1278
|
-
var __spreadValues$4 = (a, b) => {
|
|
956
|
+
var __defProp$8 = Object.defineProperty;
|
|
957
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
958
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
959
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
960
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
961
|
+
var __spreadValues$5 = (a, b) => {
|
|
1279
962
|
for (var prop in b || (b = {}))
|
|
1280
|
-
if (__hasOwnProp$
|
|
1281
|
-
__defNormalProp$
|
|
1282
|
-
if (__getOwnPropSymbols$
|
|
1283
|
-
for (var prop of __getOwnPropSymbols$
|
|
1284
|
-
if (__propIsEnum$
|
|
1285
|
-
__defNormalProp$
|
|
963
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
964
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
965
|
+
if (__getOwnPropSymbols$5)
|
|
966
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
967
|
+
if (__propIsEnum$5.call(b, prop))
|
|
968
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
1286
969
|
}
|
|
1287
970
|
return a;
|
|
1288
971
|
};
|
|
1289
|
-
var
|
|
1290
|
-
var
|
|
1291
|
-
var __async = (__this, __arguments, generator) => {
|
|
972
|
+
var __publicField$5 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
973
|
+
var __async$4 = (__this, __arguments, generator) => {
|
|
1292
974
|
return new Promise((resolve, reject) => {
|
|
1293
975
|
var fulfilled = (value) => {
|
|
1294
976
|
try {
|
|
@@ -1329,39 +1011,27 @@ var Geocoder = (function (exports) {
|
|
|
1329
1011
|
* Fetching resource would be cached to speed up next call
|
|
1330
1012
|
*/
|
|
1331
1013
|
getOne(resource, requestOptions) {
|
|
1332
|
-
const
|
|
1333
|
-
|
|
1334
|
-
const opt = __spreadProps$2(__spreadValues$4({}, requestOptions), { cache: false });
|
|
1335
|
-
if (typeof resource === "string") {
|
|
1336
|
-
forCache.keyname = resource;
|
|
1337
|
-
} else if (typeof resource === "number") {
|
|
1338
|
-
forCache.id = resource;
|
|
1339
|
-
} else if (isObject(resource)) {
|
|
1014
|
+
const opt = __spreadValues$5({}, requestOptions);
|
|
1015
|
+
if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
|
|
1340
1016
|
if (resource.id !== void 0) {
|
|
1341
|
-
|
|
1017
|
+
resource.id;
|
|
1342
1018
|
} else {
|
|
1343
1019
|
if (resource.keyname) {
|
|
1344
|
-
|
|
1020
|
+
resource.keyname;
|
|
1345
1021
|
}
|
|
1346
1022
|
if (resource.display_name) {
|
|
1347
|
-
|
|
1023
|
+
resource.display_name;
|
|
1348
1024
|
}
|
|
1349
1025
|
}
|
|
1350
1026
|
}
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
return this._fetchResourceBy(resource, opt);
|
|
1358
|
-
}
|
|
1359
|
-
return CancelablePromise.resolve(void 0);
|
|
1360
|
-
};
|
|
1361
|
-
if (requestOptions == null ? void 0 : requestOptions.cache) {
|
|
1362
|
-
return cache.addFull("resource", makeRequest, forCache);
|
|
1027
|
+
if (typeof resource === "string") {
|
|
1028
|
+
return this._fetchResourceBy({ keyname: resource }, opt);
|
|
1029
|
+
} else if (typeof resource === "number") {
|
|
1030
|
+
return this._fetchResourceById(resource, opt);
|
|
1031
|
+
} else if (isObject(resource)) {
|
|
1032
|
+
return this._fetchResourceBy(resource, opt);
|
|
1363
1033
|
}
|
|
1364
|
-
return
|
|
1034
|
+
return Promise.resolve(void 0);
|
|
1365
1035
|
}
|
|
1366
1036
|
getOneOrFail(resource, requestOptions) {
|
|
1367
1037
|
return this.getOne(resource, requestOptions).then((res) => {
|
|
@@ -1383,7 +1053,7 @@ var Geocoder = (function (exports) {
|
|
|
1383
1053
|
*/
|
|
1384
1054
|
getId(resource, requestOptions) {
|
|
1385
1055
|
if (typeof resource === "number") {
|
|
1386
|
-
return
|
|
1056
|
+
return Promise.resolve(resource);
|
|
1387
1057
|
} else if (typeof resource === "string" || isObject(resource)) {
|
|
1388
1058
|
return this.getOne(resource, requestOptions).then((res) => {
|
|
1389
1059
|
if (res) {
|
|
@@ -1391,7 +1061,7 @@ var Geocoder = (function (exports) {
|
|
|
1391
1061
|
}
|
|
1392
1062
|
});
|
|
1393
1063
|
}
|
|
1394
|
-
return
|
|
1064
|
+
return Promise.resolve(void 0);
|
|
1395
1065
|
}
|
|
1396
1066
|
/**
|
|
1397
1067
|
* A fast way to retrieve resource ID for any resource definition.
|
|
@@ -1418,12 +1088,12 @@ var Geocoder = (function (exports) {
|
|
|
1418
1088
|
} else {
|
|
1419
1089
|
Object.assign(query, resourceToQuery(resource));
|
|
1420
1090
|
}
|
|
1421
|
-
return this.connector.get("resource.search", requestOptions, __spreadValues$
|
|
1091
|
+
return this.connector.get("resource.search", requestOptions, __spreadValues$5({
|
|
1422
1092
|
serialization: "full"
|
|
1423
1093
|
}, query)).then((resources) => {
|
|
1424
|
-
if (resources) {
|
|
1094
|
+
if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
|
|
1425
1095
|
for (const x of resources) {
|
|
1426
|
-
this.cache.add("resource.item",
|
|
1096
|
+
this.cache.add("resource.item", Promise.resolve(x), {
|
|
1427
1097
|
id: x.resource.id
|
|
1428
1098
|
});
|
|
1429
1099
|
}
|
|
@@ -1439,7 +1109,7 @@ var Geocoder = (function (exports) {
|
|
|
1439
1109
|
if (child) {
|
|
1440
1110
|
return this.getOne(child.resource.parent.id, requestOptions);
|
|
1441
1111
|
}
|
|
1442
|
-
return
|
|
1112
|
+
return Promise.resolve(void 0);
|
|
1443
1113
|
});
|
|
1444
1114
|
}
|
|
1445
1115
|
getChildrenOf(resource, requestOptions) {
|
|
@@ -1469,18 +1139,16 @@ var Geocoder = (function (exports) {
|
|
|
1469
1139
|
});
|
|
1470
1140
|
}
|
|
1471
1141
|
_getChildrenOf(parent, requestOptions, _items = []) {
|
|
1472
|
-
return this.connector.get(
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
{
|
|
1476
|
-
parent
|
|
1477
|
-
}
|
|
1478
|
-
).then((items) => {
|
|
1142
|
+
return this.connector.get("resource.collection", requestOptions, {
|
|
1143
|
+
parent
|
|
1144
|
+
}).then((items) => {
|
|
1479
1145
|
const recursivePromises = [];
|
|
1480
1146
|
for (const item of items) {
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1147
|
+
if (requestOptions == null ? void 0 : requestOptions.cache) {
|
|
1148
|
+
this.cache.add("resource.item", Promise.resolve(item), {
|
|
1149
|
+
id: item.resource.id
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1484
1152
|
_items.push(item);
|
|
1485
1153
|
if ((requestOptions == null ? void 0 : requestOptions.recursive) && item.resource.children) {
|
|
1486
1154
|
recursivePromises.push(
|
|
@@ -1489,7 +1157,7 @@ var Geocoder = (function (exports) {
|
|
|
1489
1157
|
}
|
|
1490
1158
|
}
|
|
1491
1159
|
if (recursivePromises.length) {
|
|
1492
|
-
return
|
|
1160
|
+
return Promise.all(recursivePromises).then(() => {
|
|
1493
1161
|
return _items;
|
|
1494
1162
|
});
|
|
1495
1163
|
}
|
|
@@ -1497,11 +1165,12 @@ var Geocoder = (function (exports) {
|
|
|
1497
1165
|
});
|
|
1498
1166
|
}
|
|
1499
1167
|
_cleanResourceItemCache(id) {
|
|
1500
|
-
return __async(this, null, function* () {
|
|
1168
|
+
return __async$4(this, null, function* () {
|
|
1169
|
+
var _a;
|
|
1501
1170
|
const all = this.cache.all();
|
|
1502
1171
|
const toDelete = [];
|
|
1503
1172
|
for (const c of all) {
|
|
1504
|
-
const cid = c.
|
|
1173
|
+
const cid = (_a = c.props) == null ? void 0 : _a.id;
|
|
1505
1174
|
if (["resource.item", "resource"].includes(c.key) && cid !== void 0) {
|
|
1506
1175
|
if (typeof cid === "number") {
|
|
1507
1176
|
if (cid === id) {
|
|
@@ -1521,18 +1190,7 @@ var Geocoder = (function (exports) {
|
|
|
1521
1190
|
});
|
|
1522
1191
|
}
|
|
1523
1192
|
_fetchResourceById(id, requestOptions) {
|
|
1524
|
-
|
|
1525
|
-
if (requestOptions == null ? void 0 : requestOptions.cache) {
|
|
1526
|
-
return this.cache.add("resource.item", promise, {
|
|
1527
|
-
id
|
|
1528
|
-
}).catch((er) => {
|
|
1529
|
-
if (!(er instanceof ResourceNotFoundError)) {
|
|
1530
|
-
throw er;
|
|
1531
|
-
}
|
|
1532
|
-
return void 0;
|
|
1533
|
-
});
|
|
1534
|
-
}
|
|
1535
|
-
return promise();
|
|
1193
|
+
return this.connector.get("resource.item", requestOptions, { id });
|
|
1536
1194
|
}
|
|
1537
1195
|
_fetchResourceBy(resource, requestOptions) {
|
|
1538
1196
|
return this.getMany(resource, requestOptions).then((resources) => {
|
|
@@ -1540,7 +1198,7 @@ var Geocoder = (function (exports) {
|
|
|
1540
1198
|
});
|
|
1541
1199
|
}
|
|
1542
1200
|
_resourceCacheFilter(resource) {
|
|
1543
|
-
return
|
|
1201
|
+
return Promise.all(this.cache.matchAll("resource.item")).then(
|
|
1544
1202
|
(resources) => {
|
|
1545
1203
|
const items = [];
|
|
1546
1204
|
resources.filter((x) => {
|
|
@@ -1584,9 +1242,16 @@ var Geocoder = (function (exports) {
|
|
|
1584
1242
|
}
|
|
1585
1243
|
}
|
|
1586
1244
|
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1245
|
+
class AbortError extends Error {
|
|
1246
|
+
constructor(message = "AbortError") {
|
|
1247
|
+
super(message);
|
|
1248
|
+
this.name = "AbortError";
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
var __defProp$7 = Object.defineProperty;
|
|
1253
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1254
|
+
var __publicField$4 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1590
1255
|
class InsufficientPermissionsError extends NgwError {
|
|
1591
1256
|
constructor(obj) {
|
|
1592
1257
|
super(obj);
|
|
@@ -1609,64 +1274,96 @@ var Geocoder = (function (exports) {
|
|
|
1609
1274
|
});
|
|
1610
1275
|
}
|
|
1611
1276
|
|
|
1277
|
+
var __defProp$6 = Object.defineProperty;
|
|
1278
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
1279
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
1280
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
1281
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1282
|
+
var __spreadValues$4 = (a, b) => {
|
|
1283
|
+
for (var prop in b || (b = {}))
|
|
1284
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
1285
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
1286
|
+
if (__getOwnPropSymbols$4)
|
|
1287
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
1288
|
+
if (__propIsEnum$4.call(b, prop))
|
|
1289
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
1290
|
+
}
|
|
1291
|
+
return a;
|
|
1292
|
+
};
|
|
1293
|
+
var __async$3 = (__this, __arguments, generator) => {
|
|
1294
|
+
return new Promise((resolve, reject) => {
|
|
1295
|
+
var fulfilled = (value) => {
|
|
1296
|
+
try {
|
|
1297
|
+
step(generator.next(value));
|
|
1298
|
+
} catch (e) {
|
|
1299
|
+
reject(e);
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
var rejected = (value) => {
|
|
1303
|
+
try {
|
|
1304
|
+
step(generator.throw(value));
|
|
1305
|
+
} catch (e) {
|
|
1306
|
+
reject(e);
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1310
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
1311
|
+
});
|
|
1312
|
+
};
|
|
1612
1313
|
function apiRequest(opt) {
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
"`" + arg + "` url api argument is not specified"
|
|
1628
|
-
);
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
if (url) {
|
|
1632
|
-
url = template(url, replaceParams);
|
|
1314
|
+
return __async$3(this, null, function* () {
|
|
1315
|
+
const { params, name, connector, requestOptions } = opt;
|
|
1316
|
+
const apiItems = yield connector.connect();
|
|
1317
|
+
let apiItem = apiItems && apiItems[name];
|
|
1318
|
+
if (apiItem) {
|
|
1319
|
+
apiItem = [...apiItem];
|
|
1320
|
+
let url = apiItem.shift();
|
|
1321
|
+
if (apiItem.length) {
|
|
1322
|
+
const replaceParams = {};
|
|
1323
|
+
for (let fry = 0; fry < apiItem.length; fry++) {
|
|
1324
|
+
const arg = apiItem[fry];
|
|
1325
|
+
replaceParams[fry] = `{${arg}}`;
|
|
1326
|
+
if (params[arg] === void 0) {
|
|
1327
|
+
throw new Error(`\`${arg}\` URL API argument is not specified`);
|
|
1633
1328
|
}
|
|
1634
1329
|
}
|
|
1635
|
-
if (
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
url = url + "?" + paramArray.join("&");
|
|
1330
|
+
if (url) {
|
|
1331
|
+
url = template(url, replaceParams);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
if (params) {
|
|
1335
|
+
const paramArray = [];
|
|
1336
|
+
const paramList = params.paramList;
|
|
1337
|
+
if (Array.isArray(paramList)) {
|
|
1338
|
+
paramList.forEach(([key, value]) => {
|
|
1339
|
+
paramArray.push(`${key}=${value}`);
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
for (const p in params) {
|
|
1343
|
+
if (apiItem.indexOf(p) === -1) {
|
|
1344
|
+
paramArray.push(`${p}=${params[p]}`);
|
|
1651
1345
|
}
|
|
1652
1346
|
}
|
|
1653
|
-
if (
|
|
1654
|
-
|
|
1655
|
-
} else {
|
|
1656
|
-
reject(new Error("request url is not set"));
|
|
1347
|
+
if (paramArray.length) {
|
|
1348
|
+
url = `${url}?${paramArray.join("&")}`;
|
|
1657
1349
|
}
|
|
1350
|
+
}
|
|
1351
|
+
if (url) {
|
|
1352
|
+
return connector.makeQuery(url, params, __spreadValues$4({
|
|
1353
|
+
cacheName: name
|
|
1354
|
+
}, requestOptions));
|
|
1658
1355
|
} else {
|
|
1659
|
-
|
|
1356
|
+
throw new Error("Request URL is not set");
|
|
1660
1357
|
}
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
}
|
|
1358
|
+
} else {
|
|
1359
|
+
return void 0;
|
|
1360
|
+
}
|
|
1664
1361
|
});
|
|
1665
1362
|
}
|
|
1666
1363
|
|
|
1667
1364
|
var __defProp$5 = Object.defineProperty;
|
|
1668
1365
|
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1669
|
-
var __publicField$3 = (obj, key, value) => __defNormalProp$5(obj,
|
|
1366
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$5(obj, key + "" , value);
|
|
1670
1367
|
class NetworkError extends Error {
|
|
1671
1368
|
constructor(url) {
|
|
1672
1369
|
super();
|
|
@@ -1760,6 +1457,8 @@ var Geocoder = (function (exports) {
|
|
|
1760
1457
|
}
|
|
1761
1458
|
|
|
1762
1459
|
var __defProp$4 = Object.defineProperty;
|
|
1460
|
+
var __defProps$2 = Object.defineProperties;
|
|
1461
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
1763
1462
|
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
1764
1463
|
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1765
1464
|
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
@@ -1775,8 +1474,42 @@ var Geocoder = (function (exports) {
|
|
|
1775
1474
|
}
|
|
1776
1475
|
return a;
|
|
1777
1476
|
};
|
|
1477
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
1478
|
+
var __objRest = (source, exclude) => {
|
|
1479
|
+
var target = {};
|
|
1480
|
+
for (var prop in source)
|
|
1481
|
+
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1482
|
+
target[prop] = source[prop];
|
|
1483
|
+
if (source != null && __getOwnPropSymbols$3)
|
|
1484
|
+
for (var prop of __getOwnPropSymbols$3(source)) {
|
|
1485
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
|
|
1486
|
+
target[prop] = source[prop];
|
|
1487
|
+
}
|
|
1488
|
+
return target;
|
|
1489
|
+
};
|
|
1778
1490
|
var __publicField$2 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1491
|
+
var __async$2 = (__this, __arguments, generator) => {
|
|
1492
|
+
return new Promise((resolve, reject) => {
|
|
1493
|
+
var fulfilled = (value) => {
|
|
1494
|
+
try {
|
|
1495
|
+
step(generator.next(value));
|
|
1496
|
+
} catch (e) {
|
|
1497
|
+
reject(e);
|
|
1498
|
+
}
|
|
1499
|
+
};
|
|
1500
|
+
var rejected = (value) => {
|
|
1501
|
+
try {
|
|
1502
|
+
step(generator.throw(value));
|
|
1503
|
+
} catch (e) {
|
|
1504
|
+
reject(e);
|
|
1505
|
+
}
|
|
1506
|
+
};
|
|
1507
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1508
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
1509
|
+
});
|
|
1510
|
+
};
|
|
1779
1511
|
let ID = 0;
|
|
1512
|
+
let REQUEST_ID = 0;
|
|
1780
1513
|
class NgwConnector {
|
|
1781
1514
|
constructor(options) {
|
|
1782
1515
|
this.options = options;
|
|
@@ -1786,7 +1519,7 @@ var Geocoder = (function (exports) {
|
|
|
1786
1519
|
__publicField$2(this, "resources");
|
|
1787
1520
|
__publicField$2(this, "cache");
|
|
1788
1521
|
__publicField$2(this, "routeStr", "/api/component/pyramid/route");
|
|
1789
|
-
__publicField$2(this, "activeRequests",
|
|
1522
|
+
__publicField$2(this, "activeRequests", {});
|
|
1790
1523
|
__publicField$2(this, "requestTransform");
|
|
1791
1524
|
const exist = findConnector(options);
|
|
1792
1525
|
this.cache = new Cache({ namespace: options.cacheId });
|
|
@@ -1843,29 +1576,27 @@ var Geocoder = (function (exports) {
|
|
|
1843
1576
|
* ```
|
|
1844
1577
|
*/
|
|
1845
1578
|
connect() {
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
const makeQuery = () => {
|
|
1849
|
-
return this.makeQuery(this.routeStr, {}, {}).then((route) => {
|
|
1850
|
-
resolve(route);
|
|
1851
|
-
}).catch((er) => {
|
|
1852
|
-
reject(er);
|
|
1853
|
-
});
|
|
1854
|
-
};
|
|
1579
|
+
return __async$2(this, null, function* () {
|
|
1580
|
+
const auth = this.options.auth;
|
|
1855
1581
|
if (auth) {
|
|
1856
1582
|
const { login, password } = auth;
|
|
1857
1583
|
if (login && password) {
|
|
1858
|
-
|
|
1859
|
-
return makeQuery();
|
|
1860
|
-
}).catch((er) => reject(er));
|
|
1584
|
+
yield this._login({ login, password });
|
|
1861
1585
|
}
|
|
1862
1586
|
}
|
|
1863
|
-
return makeQuery(
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1587
|
+
return yield this.makeQuery(
|
|
1588
|
+
this.routeStr,
|
|
1589
|
+
{},
|
|
1590
|
+
{
|
|
1591
|
+
cacheName: "route",
|
|
1592
|
+
cache: true,
|
|
1593
|
+
cacheProps: {
|
|
1594
|
+
id: this.id,
|
|
1595
|
+
auth,
|
|
1596
|
+
baseUrl: this.options.baseUrl
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
);
|
|
1869
1600
|
});
|
|
1870
1601
|
}
|
|
1871
1602
|
/**
|
|
@@ -1889,20 +1620,22 @@ var Geocoder = (function (exports) {
|
|
|
1889
1620
|
this.emitter.emit("logout");
|
|
1890
1621
|
}
|
|
1891
1622
|
getUserInfo(credentials, options) {
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1623
|
+
return __async$2(this, null, function* () {
|
|
1624
|
+
if (this.user && this.user.id) {
|
|
1625
|
+
return this.user;
|
|
1626
|
+
}
|
|
1627
|
+
if (credentials) {
|
|
1628
|
+
this.options.auth = credentials;
|
|
1629
|
+
}
|
|
1630
|
+
const options_ = __spreadValues$3({
|
|
1631
|
+
headers: this.getAuthorizationHeaders(credentials)
|
|
1632
|
+
}, options);
|
|
1633
|
+
return this.makeQuery(
|
|
1634
|
+
"/api/component/auth/current_user",
|
|
1635
|
+
{},
|
|
1636
|
+
options_
|
|
1637
|
+
);
|
|
1638
|
+
});
|
|
1906
1639
|
}
|
|
1907
1640
|
/**
|
|
1908
1641
|
* Obtaining the required Headers for authentication of requests in the NGW.
|
|
@@ -1911,7 +1644,7 @@ var Geocoder = (function (exports) {
|
|
|
1911
1644
|
const client = this.makeClientId(credentials);
|
|
1912
1645
|
if (client) {
|
|
1913
1646
|
return {
|
|
1914
|
-
Authorization:
|
|
1647
|
+
Authorization: `Basic ${client}`
|
|
1915
1648
|
};
|
|
1916
1649
|
}
|
|
1917
1650
|
}
|
|
@@ -1919,21 +1652,22 @@ var Geocoder = (function (exports) {
|
|
|
1919
1652
|
credentials = credentials || this.options.auth;
|
|
1920
1653
|
if (credentials) {
|
|
1921
1654
|
const { login, password } = credentials;
|
|
1922
|
-
const str =
|
|
1655
|
+
const str = `${login}:${password}`;
|
|
1656
|
+
const encodedStr = encodeURIComponent(str);
|
|
1923
1657
|
{
|
|
1924
|
-
return window.btoa(
|
|
1658
|
+
return window.btoa(encodedStr);
|
|
1925
1659
|
}
|
|
1926
1660
|
}
|
|
1927
1661
|
}
|
|
1928
1662
|
/** Stop all api requests */
|
|
1929
1663
|
abort() {
|
|
1930
|
-
for (const
|
|
1931
|
-
|
|
1664
|
+
for (const abortController of Object.values(this.activeRequests)) {
|
|
1665
|
+
abortController.abort();
|
|
1932
1666
|
}
|
|
1933
|
-
this.activeRequests =
|
|
1667
|
+
this.activeRequests = {};
|
|
1934
1668
|
}
|
|
1935
1669
|
getActiveApiRequests() {
|
|
1936
|
-
return
|
|
1670
|
+
return __spreadValues$3({}, this.activeRequests);
|
|
1937
1671
|
}
|
|
1938
1672
|
/**
|
|
1939
1673
|
* Send request to NGW api router.
|
|
@@ -1965,23 +1699,10 @@ var Geocoder = (function (exports) {
|
|
|
1965
1699
|
* ```
|
|
1966
1700
|
*/
|
|
1967
1701
|
apiRequest(name, params_ = {}, requestOptions = {}) {
|
|
1968
|
-
var _a
|
|
1969
|
-
const { method, headers, withCredentials, responseType } = requestOptions;
|
|
1702
|
+
var _a;
|
|
1970
1703
|
params_ = (_a = requestOptions.params) != null ? _a : params_;
|
|
1971
1704
|
const params = objectRemoveEmpty(params_);
|
|
1972
|
-
|
|
1973
|
-
if (requestOptions.cache && method === "GET") {
|
|
1974
|
-
return this.cache.add(name, makeApiRequest, __spreadValues$3({
|
|
1975
|
-
params
|
|
1976
|
-
}, objectRemoveEmpty({
|
|
1977
|
-
headers,
|
|
1978
|
-
withCredentials,
|
|
1979
|
-
responseType,
|
|
1980
|
-
baseUrl: this.options.baseUrl,
|
|
1981
|
-
userId: (_b = this.user) == null ? void 0 : _b.id
|
|
1982
|
-
})));
|
|
1983
|
-
}
|
|
1984
|
-
return makeApiRequest();
|
|
1705
|
+
return apiRequest({ name, params, requestOptions, connector: this });
|
|
1985
1706
|
}
|
|
1986
1707
|
/**
|
|
1987
1708
|
* Shortcut method for send POST request to NGW.
|
|
@@ -2071,17 +1792,67 @@ var Geocoder = (function (exports) {
|
|
|
2071
1792
|
* @param params - Query params
|
|
2072
1793
|
* @param options - Request options
|
|
2073
1794
|
*/
|
|
2074
|
-
makeQuery(
|
|
2075
|
-
|
|
2076
|
-
|
|
1795
|
+
makeQuery(_0, _1) {
|
|
1796
|
+
return __async$2(this, arguments, function* (url, params, options = {}) {
|
|
1797
|
+
var _b;
|
|
1798
|
+
url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
|
|
1799
|
+
if (!url) {
|
|
1800
|
+
throw new Error("Empty `url` not allowed");
|
|
1801
|
+
}
|
|
2077
1802
|
if (params) {
|
|
2078
|
-
|
|
1803
|
+
const _a = params, restParams = __objRest(_a, ["paramList"]);
|
|
1804
|
+
url = template(url, restParams);
|
|
2079
1805
|
}
|
|
2080
1806
|
url = encodeURI(fixUrlStr(url));
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
1807
|
+
const {
|
|
1808
|
+
cache,
|
|
1809
|
+
signal: externalSignal,
|
|
1810
|
+
method = "GET",
|
|
1811
|
+
headers,
|
|
1812
|
+
cacheName,
|
|
1813
|
+
cacheProps,
|
|
1814
|
+
responseType,
|
|
1815
|
+
withCredentials
|
|
1816
|
+
} = options;
|
|
1817
|
+
const internalAbortController = new AbortController();
|
|
1818
|
+
const internalSignal = internalAbortController.signal;
|
|
1819
|
+
if (externalSignal) {
|
|
1820
|
+
if (externalSignal.aborted) {
|
|
1821
|
+
throw new AbortError();
|
|
1822
|
+
}
|
|
1823
|
+
externalSignal.addEventListener("abort", () => {
|
|
1824
|
+
internalAbortController.abort();
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
options.signal = internalSignal;
|
|
1828
|
+
const createPromise = () => __async$2(this, null, function* () {
|
|
1829
|
+
const id = REQUEST_ID++;
|
|
1830
|
+
this.activeRequests[id] = internalAbortController;
|
|
1831
|
+
try {
|
|
1832
|
+
return this._loadData(url, options);
|
|
1833
|
+
} finally {
|
|
1834
|
+
this._cleanActiveRequest(id);
|
|
1835
|
+
}
|
|
1836
|
+
});
|
|
1837
|
+
if (cache && method === "GET") {
|
|
1838
|
+
const cacheOptions = cacheProps ? cacheProps : __spreadProps$2(__spreadValues$3({}, objectRemoveEmpty({
|
|
1839
|
+
headers,
|
|
1840
|
+
withCredentials,
|
|
1841
|
+
responseType,
|
|
1842
|
+
baseUrl: this.options.baseUrl,
|
|
1843
|
+
userId: (_b = this.user) == null ? void 0 : _b.id
|
|
1844
|
+
})), {
|
|
1845
|
+
params
|
|
1846
|
+
});
|
|
1847
|
+
return this.cache.add(
|
|
1848
|
+
cacheName || url,
|
|
1849
|
+
createPromise,
|
|
1850
|
+
cacheOptions,
|
|
1851
|
+
false
|
|
1852
|
+
);
|
|
1853
|
+
}
|
|
1854
|
+
return createPromise();
|
|
1855
|
+
});
|
|
2085
1856
|
}
|
|
2086
1857
|
// -------------------------------------------------------------------------
|
|
2087
1858
|
// Resource Methods
|
|
@@ -2163,10 +1934,8 @@ var Geocoder = (function (exports) {
|
|
|
2163
1934
|
*/
|
|
2164
1935
|
_loadData(url, options) {
|
|
2165
1936
|
options.responseType = options.responseType || "json";
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
}
|
|
2169
|
-
const request = new CancelablePromise((resolve, reject, onCancel) => {
|
|
1937
|
+
return new Promise((resolve, reject) => {
|
|
1938
|
+
var _a;
|
|
2170
1939
|
if (this.user) {
|
|
2171
1940
|
options = options || {};
|
|
2172
1941
|
options.headers = __spreadValues$3(__spreadValues$3({}, this.getAuthorizationHeaders()), options.headers);
|
|
@@ -2176,13 +1945,18 @@ var Geocoder = (function (exports) {
|
|
|
2176
1945
|
url = transUrl;
|
|
2177
1946
|
options = transOptions;
|
|
2178
1947
|
}
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
1948
|
+
let runOnAbort = void 0;
|
|
1949
|
+
loadData(url, resolve, options, reject, (handler) => {
|
|
1950
|
+
runOnAbort = handler;
|
|
1951
|
+
});
|
|
1952
|
+
(_a = options.signal) == null ? void 0 : _a.addEventListener("abort", () => {
|
|
1953
|
+
if (runOnAbort !== void 0) {
|
|
1954
|
+
runOnAbort();
|
|
1955
|
+
}
|
|
1956
|
+
reject(new AbortError());
|
|
1957
|
+
});
|
|
2183
1958
|
}).catch((httpError) => {
|
|
2184
|
-
|
|
2185
|
-
if (httpError instanceof CancelablePromise.CancelError) ; else {
|
|
1959
|
+
if (httpError.name !== "AbortError") {
|
|
2186
1960
|
{
|
|
2187
1961
|
console.warn("DEV WARN", httpError);
|
|
2188
1962
|
}
|
|
@@ -2191,31 +1965,24 @@ var Geocoder = (function (exports) {
|
|
|
2191
1965
|
throw er;
|
|
2192
1966
|
}
|
|
2193
1967
|
}
|
|
1968
|
+
throw httpError;
|
|
2194
1969
|
});
|
|
2195
|
-
if (options.signal && typeof options.signal.addEventListener === "function") {
|
|
2196
|
-
options.signal.addEventListener("abort", () => {
|
|
2197
|
-
request.cancel();
|
|
2198
|
-
this._cleanActiveRequests(request);
|
|
2199
|
-
});
|
|
2200
|
-
}
|
|
2201
|
-
this.activeRequests.push(request);
|
|
2202
|
-
return request;
|
|
2203
1970
|
}
|
|
2204
1971
|
_login(credentials, options) {
|
|
2205
|
-
return this
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
1972
|
+
return __async$2(this, null, function* () {
|
|
1973
|
+
try {
|
|
1974
|
+
const data = yield this.getUserInfo(credentials, options);
|
|
1975
|
+
this.user = data;
|
|
1976
|
+
this.emitter.emit("login", data);
|
|
1977
|
+
return data;
|
|
1978
|
+
} catch (er) {
|
|
1979
|
+
this.emitter.emit("login:error", er);
|
|
1980
|
+
throw er;
|
|
1981
|
+
}
|
|
2212
1982
|
});
|
|
2213
1983
|
}
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
if (activeRequestIndex !== -1) {
|
|
2217
|
-
this.activeRequests.splice(activeRequestIndex, 1);
|
|
2218
|
-
}
|
|
1984
|
+
_cleanActiveRequest(requestId) {
|
|
1985
|
+
delete this.activeRequests[requestId];
|
|
2219
1986
|
}
|
|
2220
1987
|
_handleHttpError(er) {
|
|
2221
1988
|
if (er) {
|
|
@@ -2324,6 +2091,26 @@ var Geocoder = (function (exports) {
|
|
|
2324
2091
|
return a;
|
|
2325
2092
|
};
|
|
2326
2093
|
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
2094
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
2095
|
+
return new Promise((resolve, reject) => {
|
|
2096
|
+
var fulfilled = (value) => {
|
|
2097
|
+
try {
|
|
2098
|
+
step(generator.next(value));
|
|
2099
|
+
} catch (e) {
|
|
2100
|
+
reject(e);
|
|
2101
|
+
}
|
|
2102
|
+
};
|
|
2103
|
+
var rejected = (value) => {
|
|
2104
|
+
try {
|
|
2105
|
+
step(generator.throw(value));
|
|
2106
|
+
} catch (e) {
|
|
2107
|
+
reject(e);
|
|
2108
|
+
}
|
|
2109
|
+
};
|
|
2110
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2111
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
2112
|
+
});
|
|
2113
|
+
};
|
|
2327
2114
|
const FEATURE_REQUEST_PARAMS = {
|
|
2328
2115
|
srs: 4326,
|
|
2329
2116
|
geom_format: "geojson"
|
|
@@ -2354,10 +2141,9 @@ var Geocoder = (function (exports) {
|
|
|
2354
2141
|
}
|
|
2355
2142
|
}
|
|
2356
2143
|
function createFeatureFieldFilterQueries(opt) {
|
|
2357
|
-
|
|
2358
|
-
opt
|
|
2359
|
-
|
|
2360
|
-
return CancelablePromise.all(queries).then((itemsParts) => {
|
|
2144
|
+
return __async$1(this, null, function* () {
|
|
2145
|
+
const queries = getQueries(opt);
|
|
2146
|
+
const itemsParts = yield Promise.all(queries);
|
|
2361
2147
|
const ids = [];
|
|
2362
2148
|
const items = [];
|
|
2363
2149
|
for (const part of itemsParts) {
|
|
@@ -2545,13 +2331,34 @@ var Geocoder = (function (exports) {
|
|
|
2545
2331
|
return a;
|
|
2546
2332
|
};
|
|
2547
2333
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
2334
|
+
var __async = (__this, __arguments, generator) => {
|
|
2335
|
+
return new Promise((resolve, reject) => {
|
|
2336
|
+
var fulfilled = (value) => {
|
|
2337
|
+
try {
|
|
2338
|
+
step(generator.next(value));
|
|
2339
|
+
} catch (e) {
|
|
2340
|
+
reject(e);
|
|
2341
|
+
}
|
|
2342
|
+
};
|
|
2343
|
+
var rejected = (value) => {
|
|
2344
|
+
try {
|
|
2345
|
+
step(generator.throw(value));
|
|
2346
|
+
} catch (e) {
|
|
2347
|
+
reject(e);
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2350
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2351
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
2352
|
+
});
|
|
2353
|
+
};
|
|
2548
2354
|
function fetchNgwLayerItems(options) {
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2355
|
+
return __async(this, null, function* () {
|
|
2356
|
+
var _a;
|
|
2357
|
+
const filters = options.filters;
|
|
2358
|
+
if (filters) {
|
|
2359
|
+
let data = yield createFeatureFieldFilterQueries(__spreadProps(__spreadValues$1({}, options), {
|
|
2360
|
+
filters
|
|
2361
|
+
}));
|
|
2555
2362
|
const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : isFilterWithAnyCase(filters);
|
|
2556
2363
|
if (clientFilterValidate) {
|
|
2557
2364
|
data = data.filter((y) => {
|
|
@@ -2563,10 +2370,10 @@ var Geocoder = (function (exports) {
|
|
|
2563
2370
|
});
|
|
2564
2371
|
}
|
|
2565
2372
|
return data;
|
|
2566
|
-
}
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
}
|
|
2373
|
+
} else {
|
|
2374
|
+
return fetchNgwLayerItemsRequest(options);
|
|
2375
|
+
}
|
|
2376
|
+
});
|
|
2570
2377
|
}
|
|
2571
2378
|
function isFilterWithAnyCase(filters) {
|
|
2572
2379
|
if (filters[0] === "any") {
|
|
@@ -2783,14 +2590,14 @@ var Geocoder = (function (exports) {
|
|
|
2783
2590
|
constructor(options) {
|
|
2784
2591
|
super(options);
|
|
2785
2592
|
__publicField(this, "searchUrl", "https://nominatim.openstreetmap.org");
|
|
2786
|
-
__publicField(this, "
|
|
2593
|
+
__publicField(this, "_abort", []);
|
|
2787
2594
|
if (options && options.searchUrl) {
|
|
2788
2595
|
this.searchUrl = options.searchUrl;
|
|
2789
2596
|
}
|
|
2790
2597
|
}
|
|
2791
2598
|
abort() {
|
|
2792
|
-
this.
|
|
2793
|
-
this.
|
|
2599
|
+
this._abort.forEach((x) => x());
|
|
2600
|
+
this._abort = [];
|
|
2794
2601
|
}
|
|
2795
2602
|
search(val) {
|
|
2796
2603
|
return __asyncGenerator(this, null, function* () {
|
|
@@ -2798,39 +2605,34 @@ var Geocoder = (function (exports) {
|
|
|
2798
2605
|
// `${this.baseUrl}/search?format=geojson&polygon_geojson=1${window.locale === 'ru' ? '&accept-language=ru-RU,en-US' : ''}&q=${val}`
|
|
2799
2606
|
`${this.searchUrl}/search?format=geojson&polygon_geojson=1&q=${val}`
|
|
2800
2607
|
);
|
|
2801
|
-
const request = new
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
} catch (er) {
|
|
2818
|
-
reject(er);
|
|
2819
|
-
}
|
|
2820
|
-
};
|
|
2821
|
-
xhr.onerror = (er) => {
|
|
2608
|
+
const request = new Promise((resolve, reject) => {
|
|
2609
|
+
const xhr = new XMLHttpRequest();
|
|
2610
|
+
xhr.open("GET", url, true);
|
|
2611
|
+
xhr.onload = () => {
|
|
2612
|
+
try {
|
|
2613
|
+
const geojson = JSON.parse(xhr.responseText);
|
|
2614
|
+
const features = geojson.features.map((x) => {
|
|
2615
|
+
return {
|
|
2616
|
+
geom: x,
|
|
2617
|
+
extent: x.bbox,
|
|
2618
|
+
text: x.properties && x.properties.display_name,
|
|
2619
|
+
query: val
|
|
2620
|
+
};
|
|
2621
|
+
});
|
|
2622
|
+
resolve(features);
|
|
2623
|
+
} catch (er) {
|
|
2822
2624
|
reject(er);
|
|
2823
|
-
}
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2625
|
+
}
|
|
2626
|
+
};
|
|
2627
|
+
xhr.onerror = (er) => {
|
|
2628
|
+
reject(er);
|
|
2629
|
+
};
|
|
2630
|
+
this._abort.push(xhr.abort);
|
|
2631
|
+
xhr.send();
|
|
2632
|
+
}).catch((er) => {
|
|
2830
2633
|
if (er.name === "CancelError") ;
|
|
2831
2634
|
throw er;
|
|
2832
2635
|
});
|
|
2833
|
-
this._requests.push(request);
|
|
2834
2636
|
const items = yield new __await(request);
|
|
2835
2637
|
if (items) {
|
|
2836
2638
|
for (const i of items) {
|
|
@@ -2841,7 +2643,7 @@ var Geocoder = (function (exports) {
|
|
|
2841
2643
|
});
|
|
2842
2644
|
}
|
|
2843
2645
|
result(model) {
|
|
2844
|
-
return
|
|
2646
|
+
return Promise.resolve({
|
|
2845
2647
|
text: model.text,
|
|
2846
2648
|
extent: model.extent || [],
|
|
2847
2649
|
geom: model.geom
|
|
@@ -2853,38 +2655,33 @@ var Geocoder = (function (exports) {
|
|
|
2853
2655
|
const url = fixUrlStr(
|
|
2854
2656
|
`${this.searchUrl}/reverse?format=geojson&lat=${lat}&lon=${lng}`
|
|
2855
2657
|
);
|
|
2856
|
-
const request = new
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
} catch (er) {
|
|
2872
|
-
reject(er);
|
|
2873
|
-
}
|
|
2874
|
-
};
|
|
2875
|
-
xhr.onerror = (er) => {
|
|
2658
|
+
const request = new Promise((resolve, reject) => {
|
|
2659
|
+
const xhr = new XMLHttpRequest();
|
|
2660
|
+
xhr.open("GET", url, true);
|
|
2661
|
+
xhr.onload = () => {
|
|
2662
|
+
try {
|
|
2663
|
+
const geojson = JSON.parse(xhr.responseText);
|
|
2664
|
+
const feature = geojson.features[0];
|
|
2665
|
+
const result = {
|
|
2666
|
+
geom: feature,
|
|
2667
|
+
extent: feature.bbox,
|
|
2668
|
+
text: feature.properties && feature.properties.display_name,
|
|
2669
|
+
query: `${lat}, ${lng}`
|
|
2670
|
+
};
|
|
2671
|
+
resolve(result);
|
|
2672
|
+
} catch (er) {
|
|
2876
2673
|
reject(er);
|
|
2877
|
-
}
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2674
|
+
}
|
|
2675
|
+
};
|
|
2676
|
+
xhr.onerror = (er) => {
|
|
2677
|
+
reject(er);
|
|
2678
|
+
};
|
|
2679
|
+
this._abort.push(xhr.abort);
|
|
2680
|
+
xhr.send();
|
|
2681
|
+
}).catch((er) => {
|
|
2884
2682
|
if (er.name === "CancelError") ;
|
|
2885
2683
|
throw er;
|
|
2886
2684
|
});
|
|
2887
|
-
this._requests.push(request);
|
|
2888
2685
|
const item = yield new __await(request);
|
|
2889
2686
|
if (item) {
|
|
2890
2687
|
item.result = () => this.result(item);
|