@swissgeo/coordinates 1.0.0-rc.1 → 1.0.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.
Files changed (39) hide show
  1. package/README.md +119 -0
  2. package/dist/index.cjs +7 -0
  3. package/dist/index.d.ts +1 -12
  4. package/dist/index.js +8012 -18103
  5. package/dist/ol.cjs +1 -0
  6. package/dist/ol.d.ts +11 -0
  7. package/dist/ol.js +4467 -0
  8. package/dist/registerProj4-BuUOcPpF.cjs +23 -0
  9. package/dist/registerProj4-CwR_kPOz.js +10172 -0
  10. package/eslint.config.mts +12 -0
  11. package/index.html +14 -0
  12. package/package.json +30 -23
  13. package/setup-vitest.ts +8 -0
  14. package/src/DevApp.vue +66 -0
  15. package/src/__test__/coordinatesUtils.spec.ts +178 -0
  16. package/src/__test__/extentUtils.spec.ts +92 -0
  17. package/src/coordinatesUtils.ts +188 -0
  18. package/src/dev.ts +6 -0
  19. package/src/extentUtils.ts +196 -0
  20. package/src/index.ts +29 -0
  21. package/src/ol.ts +53 -0
  22. package/src/proj/CoordinateSystem.ts +315 -0
  23. package/src/proj/CoordinateSystemBounds.ts +170 -0
  24. package/src/proj/CustomCoordinateSystem.ts +58 -0
  25. package/src/proj/LV03CoordinateSystem.ts +23 -0
  26. package/src/proj/LV95CoordinateSystem.ts +35 -0
  27. package/src/proj/StandardCoordinateSystem.ts +22 -0
  28. package/src/proj/SwissCoordinateSystem.ts +233 -0
  29. package/src/proj/WGS84CoordinateSystem.ts +97 -0
  30. package/src/proj/WebMercatorCoordinateSystem.ts +89 -0
  31. package/src/proj/__test__/CoordinateSystem.spec.ts +63 -0
  32. package/src/proj/__test__/CoordinateSystemBounds.spec.ts +252 -0
  33. package/src/proj/__test__/SwissCoordinateSystem.spec.ts +136 -0
  34. package/src/proj/index.ts +65 -0
  35. package/src/proj/types.ts +22 -0
  36. package/src/registerProj4.ts +38 -0
  37. package/tsconfig.json +4 -0
  38. package/vite.config.ts +46 -0
  39. package/dist/index.umd.cjs +0 -29
package/dist/ol.js ADDED
@@ -0,0 +1,4467 @@
1
+ import { v as Oe, L as P, E as _t } from "./registerProj4-CwR_kPOz.js";
2
+ const Le = {
3
+ /**
4
+ * Triggered when a property is changed.
5
+ * @event module:ol/Object.ObjectEvent#propertychange
6
+ * @api
7
+ */
8
+ PROPERTYCHANGE: "propertychange"
9
+ }, be = {
10
+ /**
11
+ * Generic change event. Triggered when the revision counter is increased.
12
+ * @event module:ol/events/Event~BaseEvent#change
13
+ * @api
14
+ */
15
+ CHANGE: "change"
16
+ };
17
+ class Ue {
18
+ constructor() {
19
+ this.disposed = !1;
20
+ }
21
+ /**
22
+ * Clean up.
23
+ */
24
+ dispose() {
25
+ this.disposed || (this.disposed = !0, this.disposeInternal());
26
+ }
27
+ /**
28
+ * Extension point for disposable objects.
29
+ * @protected
30
+ */
31
+ disposeInternal() {
32
+ }
33
+ }
34
+ function le(i, t) {
35
+ return i > t ? 1 : i < t ? -1 : 0;
36
+ }
37
+ function wt(i, t, e) {
38
+ if (i[0] <= t)
39
+ return 0;
40
+ const n = i.length;
41
+ if (t <= i[n - 1])
42
+ return n - 1;
43
+ if (typeof e == "function") {
44
+ for (let s = 1; s < n; ++s) {
45
+ const r = i[s];
46
+ if (r === t)
47
+ return s;
48
+ if (r < t)
49
+ return e(t, i[s - 1], r) > 0 ? s - 1 : s;
50
+ }
51
+ return n - 1;
52
+ }
53
+ if (e > 0) {
54
+ for (let s = 1; s < n; ++s)
55
+ if (i[s] < t)
56
+ return s - 1;
57
+ return n - 1;
58
+ }
59
+ if (e < 0) {
60
+ for (let s = 1; s < n; ++s)
61
+ if (i[s] <= t)
62
+ return s;
63
+ return n - 1;
64
+ }
65
+ for (let s = 1; s < n; ++s) {
66
+ if (i[s] == t)
67
+ return s;
68
+ if (i[s] < t)
69
+ return i[s - 1] - t < t - i[s] ? s - 1 : s;
70
+ }
71
+ return n - 1;
72
+ }
73
+ function Ve(i, t) {
74
+ const e = Array.isArray(t) ? t : [t], n = e.length;
75
+ for (let s = 0; s < n; s++)
76
+ i[i.length] = e[s];
77
+ }
78
+ function De(i, t) {
79
+ const e = i.length;
80
+ if (e !== t.length)
81
+ return !1;
82
+ for (let n = 0; n < e; n++)
83
+ if (i[n] !== t[n])
84
+ return !1;
85
+ return !0;
86
+ }
87
+ function We(i, t, e) {
88
+ const n = t || le;
89
+ return i.every(function(s, r) {
90
+ if (r === 0)
91
+ return !0;
92
+ const o = n(i[r - 1], s);
93
+ return !(o > 0 || o === 0);
94
+ });
95
+ }
96
+ function Ct() {
97
+ }
98
+ function $e(i) {
99
+ let t, e, n;
100
+ return function() {
101
+ const s = Array.prototype.slice.call(arguments);
102
+ return (!e || this !== n || !De(s, e)) && (n = this, e = s, t = i.apply(this, arguments)), t;
103
+ };
104
+ }
105
+ function ue(i) {
106
+ for (const t in i)
107
+ delete i[t];
108
+ }
109
+ function He(i) {
110
+ let t;
111
+ for (t in i)
112
+ return !1;
113
+ return !t;
114
+ }
115
+ class he {
116
+ /**
117
+ * @param {string} type Type.
118
+ */
119
+ constructor(t) {
120
+ this.propagationStopped, this.defaultPrevented, this.type = t, this.target = null;
121
+ }
122
+ /**
123
+ * Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events
124
+ * will be fired.
125
+ * @api
126
+ */
127
+ preventDefault() {
128
+ this.defaultPrevented = !0;
129
+ }
130
+ /**
131
+ * Stop event propagation.
132
+ * @api
133
+ */
134
+ stopPropagation() {
135
+ this.propagationStopped = !0;
136
+ }
137
+ }
138
+ class ke extends Ue {
139
+ /**
140
+ * @param {*} [target] Default event target for dispatched events.
141
+ */
142
+ constructor(t) {
143
+ super(), this.eventTarget_ = t, this.pendingRemovals_ = null, this.dispatching_ = null, this.listeners_ = null;
144
+ }
145
+ /**
146
+ * @param {string} type Type.
147
+ * @param {import("../events.js").Listener} listener Listener.
148
+ */
149
+ addEventListener(t, e) {
150
+ if (!t || !e)
151
+ return;
152
+ const n = this.listeners_ || (this.listeners_ = {}), s = n[t] || (n[t] = []);
153
+ s.includes(e) || s.push(e);
154
+ }
155
+ /**
156
+ * Dispatches an event and calls all listeners listening for events
157
+ * of this type. The event parameter can either be a string or an
158
+ * Object with a `type` property.
159
+ *
160
+ * @param {import("./Event.js").default|string} event Event object.
161
+ * @return {boolean|undefined} `false` if anyone called preventDefault on the
162
+ * event object or if any of the listeners returned false.
163
+ * @api
164
+ */
165
+ dispatchEvent(t) {
166
+ const e = typeof t == "string", n = e ? t : t.type, s = this.listeners_ && this.listeners_[n];
167
+ if (!s)
168
+ return;
169
+ const r = e ? new he(t) : (
170
+ /** @type {Event} */
171
+ t
172
+ );
173
+ r.target || (r.target = this.eventTarget_ || this);
174
+ const o = this.dispatching_ || (this.dispatching_ = {}), a = this.pendingRemovals_ || (this.pendingRemovals_ = {});
175
+ n in o || (o[n] = 0, a[n] = 0), ++o[n];
176
+ let l;
177
+ for (let h = 0, u = s.length; h < u; ++h)
178
+ if ("handleEvent" in s[h] ? l = /** @type {import("../events.js").ListenerObject} */
179
+ s[h].handleEvent(r) : l = /** @type {import("../events.js").ListenerFunction} */
180
+ s[h].call(this, r), l === !1 || r.propagationStopped) {
181
+ l = !1;
182
+ break;
183
+ }
184
+ if (--o[n] === 0) {
185
+ let h = a[n];
186
+ for (delete a[n]; h--; )
187
+ this.removeEventListener(n, Ct);
188
+ delete o[n];
189
+ }
190
+ return l;
191
+ }
192
+ /**
193
+ * Clean up.
194
+ * @override
195
+ */
196
+ disposeInternal() {
197
+ this.listeners_ && ue(this.listeners_);
198
+ }
199
+ /**
200
+ * Get the listeners for a specified event type. Listeners are returned in the
201
+ * order that they will be called in.
202
+ *
203
+ * @param {string} type Type.
204
+ * @return {Array<import("../events.js").Listener>|undefined} Listeners.
205
+ */
206
+ getListeners(t) {
207
+ return this.listeners_ && this.listeners_[t] || void 0;
208
+ }
209
+ /**
210
+ * @param {string} [type] Type. If not provided,
211
+ * `true` will be returned if this event target has any listeners.
212
+ * @return {boolean} Has listeners.
213
+ */
214
+ hasListener(t) {
215
+ return this.listeners_ ? t ? t in this.listeners_ : Object.keys(this.listeners_).length > 0 : !1;
216
+ }
217
+ /**
218
+ * @param {string} type Type.
219
+ * @param {import("../events.js").Listener} listener Listener.
220
+ */
221
+ removeEventListener(t, e) {
222
+ if (!this.listeners_)
223
+ return;
224
+ const n = this.listeners_[t];
225
+ if (!n)
226
+ return;
227
+ const s = n.indexOf(e);
228
+ s !== -1 && (this.pendingRemovals_ && t in this.pendingRemovals_ ? (n[s] = Ct, ++this.pendingRemovals_[t]) : (n.splice(s, 1), n.length === 0 && delete this.listeners_[t]));
229
+ }
230
+ }
231
+ function Et(i, t, e, n, s) {
232
+ if (s) {
233
+ const o = e;
234
+ e = function(a) {
235
+ return i.removeEventListener(t, e), o.call(this, a);
236
+ };
237
+ }
238
+ const r = {
239
+ target: i,
240
+ type: t,
241
+ listener: e
242
+ };
243
+ return i.addEventListener(t, e), r;
244
+ }
245
+ function jt(i, t, e, n) {
246
+ return Et(i, t, e, n, !0);
247
+ }
248
+ function zt(i) {
249
+ i && i.target && (i.target.removeEventListener(i.type, i.listener), ue(i));
250
+ }
251
+ class qe extends ke {
252
+ constructor() {
253
+ super(), this.on = /** @type {ObservableOnSignature<import("./events").EventsKey>} */
254
+ this.onInternal, this.once = /** @type {ObservableOnSignature<import("./events").EventsKey>} */
255
+ this.onceInternal, this.un = /** @type {ObservableOnSignature<void>} */
256
+ this.unInternal, this.revision_ = 0;
257
+ }
258
+ /**
259
+ * Increases the revision counter and dispatches a 'change' event.
260
+ * @api
261
+ */
262
+ changed() {
263
+ ++this.revision_, this.dispatchEvent(be.CHANGE);
264
+ }
265
+ /**
266
+ * Get the version number for this object. Each time the object is modified,
267
+ * its version number will be incremented.
268
+ * @return {number} Revision.
269
+ * @api
270
+ */
271
+ getRevision() {
272
+ return this.revision_;
273
+ }
274
+ /**
275
+ * @param {string|Array<string>} type Type.
276
+ * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
277
+ * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
278
+ * @protected
279
+ */
280
+ onInternal(t, e) {
281
+ if (Array.isArray(t)) {
282
+ const n = t.length, s = new Array(n);
283
+ for (let r = 0; r < n; ++r)
284
+ s[r] = Et(this, t[r], e);
285
+ return s;
286
+ }
287
+ return Et(
288
+ this,
289
+ /** @type {string} */
290
+ t,
291
+ e
292
+ );
293
+ }
294
+ /**
295
+ * @param {string|Array<string>} type Type.
296
+ * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
297
+ * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
298
+ * @protected
299
+ */
300
+ onceInternal(t, e) {
301
+ let n;
302
+ if (Array.isArray(t)) {
303
+ const s = t.length;
304
+ n = new Array(s);
305
+ for (let r = 0; r < s; ++r)
306
+ n[r] = jt(this, t[r], e);
307
+ } else
308
+ n = jt(
309
+ this,
310
+ /** @type {string} */
311
+ t,
312
+ e
313
+ );
314
+ return e.ol_key = n, n;
315
+ }
316
+ /**
317
+ * Unlisten for a certain type of event.
318
+ * @param {string|Array<string>} type Type.
319
+ * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
320
+ * @protected
321
+ */
322
+ unInternal(t, e) {
323
+ const n = (
324
+ /** @type {Object} */
325
+ e.ol_key
326
+ );
327
+ if (n)
328
+ Be(n);
329
+ else if (Array.isArray(t))
330
+ for (let s = 0, r = t.length; s < r; ++s)
331
+ this.removeEventListener(t[s], e);
332
+ else
333
+ this.removeEventListener(t, e);
334
+ }
335
+ }
336
+ function Be(i) {
337
+ if (Array.isArray(i))
338
+ for (let t = 0, e = i.length; t < e; ++t)
339
+ zt(i[t]);
340
+ else
341
+ zt(
342
+ /** @type {import("./events.js").EventsKey} */
343
+ i
344
+ );
345
+ }
346
+ function E() {
347
+ throw new Error("Unimplemented abstract method.");
348
+ }
349
+ let Ke = 0;
350
+ function Je(i) {
351
+ return i.ol_uid || (i.ol_uid = String(++Ke));
352
+ }
353
+ class Gt extends he {
354
+ /**
355
+ * @param {string} type The event type.
356
+ * @param {string} key The property name.
357
+ * @param {*} oldValue The old value for `key`.
358
+ */
359
+ constructor(t, e, n) {
360
+ super(t), this.key = e, this.oldValue = n;
361
+ }
362
+ }
363
+ class ce extends qe {
364
+ /**
365
+ * @param {Object<string, *>} [values] An object with key-value pairs.
366
+ */
367
+ constructor(t) {
368
+ super(), this.on, this.once, this.un, Je(this), this.values_ = null, t !== void 0 && this.setProperties(t);
369
+ }
370
+ /**
371
+ * Gets a value.
372
+ * @param {string} key Key name.
373
+ * @return {*} Value.
374
+ * @api
375
+ */
376
+ get(t) {
377
+ let e;
378
+ return this.values_ && this.values_.hasOwnProperty(t) && (e = this.values_[t]), e;
379
+ }
380
+ /**
381
+ * Get a list of object property names.
382
+ * @return {Array<string>} List of property names.
383
+ * @api
384
+ */
385
+ getKeys() {
386
+ return this.values_ && Object.keys(this.values_) || [];
387
+ }
388
+ /**
389
+ * Get an object of all property names and values.
390
+ * @return {Object<string, *>} Object.
391
+ * @api
392
+ */
393
+ getProperties() {
394
+ return this.values_ && Object.assign({}, this.values_) || {};
395
+ }
396
+ /**
397
+ * Get an object of all property names and values.
398
+ * @return {Object<string, *>?} Object.
399
+ */
400
+ getPropertiesInternal() {
401
+ return this.values_;
402
+ }
403
+ /**
404
+ * @return {boolean} The object has properties.
405
+ */
406
+ hasProperties() {
407
+ return !!this.values_;
408
+ }
409
+ /**
410
+ * @param {string} key Key name.
411
+ * @param {*} oldValue Old value.
412
+ */
413
+ notify(t, e) {
414
+ let n;
415
+ n = `change:${t}`, this.hasListener(n) && this.dispatchEvent(new Gt(n, t, e)), n = Le.PROPERTYCHANGE, this.hasListener(n) && this.dispatchEvent(new Gt(n, t, e));
416
+ }
417
+ /**
418
+ * @param {string} key Key name.
419
+ * @param {import("./events.js").Listener} listener Listener.
420
+ */
421
+ addChangeListener(t, e) {
422
+ this.addEventListener(`change:${t}`, e);
423
+ }
424
+ /**
425
+ * @param {string} key Key name.
426
+ * @param {import("./events.js").Listener} listener Listener.
427
+ */
428
+ removeChangeListener(t, e) {
429
+ this.removeEventListener(`change:${t}`, e);
430
+ }
431
+ /**
432
+ * Sets a value.
433
+ * @param {string} key Key name.
434
+ * @param {*} value Value.
435
+ * @param {boolean} [silent] Update without triggering an event.
436
+ * @api
437
+ */
438
+ set(t, e, n) {
439
+ const s = this.values_ || (this.values_ = {});
440
+ if (n)
441
+ s[t] = e;
442
+ else {
443
+ const r = s[t];
444
+ s[t] = e, r !== e && this.notify(t, r);
445
+ }
446
+ }
447
+ /**
448
+ * Sets a collection of key-value pairs. Note that this changes any existing
449
+ * properties and adds new ones (it does not remove any existing properties).
450
+ * @param {Object<string, *>} values Values.
451
+ * @param {boolean} [silent] Update without triggering an event.
452
+ * @api
453
+ */
454
+ setProperties(t, e) {
455
+ for (const n in t)
456
+ this.set(n, t[n], e);
457
+ }
458
+ /**
459
+ * Apply any properties from another object without triggering events.
460
+ * @param {BaseObject} source The source object.
461
+ * @protected
462
+ */
463
+ applyProperties(t) {
464
+ t.values_ && Object.assign(this.values_ || (this.values_ = {}), t.values_);
465
+ }
466
+ /**
467
+ * Unsets a property.
468
+ * @param {string} key Key name.
469
+ * @param {boolean} [silent] Unset without triggering an event.
470
+ * @api
471
+ */
472
+ unset(t, e) {
473
+ if (this.values_ && t in this.values_) {
474
+ const n = this.values_[t];
475
+ delete this.values_[t], He(this.values_) && (this.values_ = null), e || this.notify(t, n);
476
+ }
477
+ }
478
+ }
479
+ function y(i, t) {
480
+ if (!i)
481
+ throw new Error(t);
482
+ }
483
+ const M = {
484
+ UNKNOWN: 0,
485
+ INTERSECTING: 1,
486
+ ABOVE: 2,
487
+ RIGHT: 4,
488
+ BELOW: 8,
489
+ LEFT: 16
490
+ };
491
+ function fe(i, t, e) {
492
+ let n, s;
493
+ return t < i[0] ? n = i[0] - t : i[2] < t ? n = t - i[2] : n = 0, e < i[1] ? s = i[1] - e : i[3] < e ? s = e - i[3] : s = 0, n * n + s * s;
494
+ }
495
+ function Qe(i, t, e) {
496
+ return i[0] <= t && t <= i[2] && i[1] <= e && e <= i[3];
497
+ }
498
+ function Ot(i, t) {
499
+ const e = i[0], n = i[1], s = i[2], r = i[3], o = t[0], a = t[1];
500
+ let l = M.UNKNOWN;
501
+ return o < e ? l = l | M.LEFT : o > s && (l = l | M.RIGHT), a < n ? l = l | M.BELOW : a > r && (l = l | M.ABOVE), l === M.UNKNOWN && (l = M.INTERSECTING), l;
502
+ }
503
+ function ge() {
504
+ return [1 / 0, 1 / 0, -1 / 0, -1 / 0];
505
+ }
506
+ function ct(i, t, e, n, s) {
507
+ return s ? (s[0] = i, s[1] = t, s[2] = e, s[3] = n, s) : [i, t, e, n];
508
+ }
509
+ function de(i) {
510
+ return ct(1 / 0, 1 / 0, -1 / 0, -1 / 0, i);
511
+ }
512
+ function tn(i, t) {
513
+ const e = i[0], n = i[1];
514
+ return ct(e, n, e, n, t);
515
+ }
516
+ function en(i, t, e, n, s) {
517
+ const r = de(s);
518
+ return me(r, i, t, e, n);
519
+ }
520
+ function me(i, t, e, n, s) {
521
+ for (; e < n; e += s)
522
+ nn(i, t[e], t[e + 1]);
523
+ return i;
524
+ }
525
+ function nn(i, t, e) {
526
+ i[0] = Math.min(i[0], t), i[1] = Math.min(i[1], e), i[2] = Math.max(i[2], t), i[3] = Math.max(i[3], e);
527
+ }
528
+ function sn(i, t) {
529
+ let e;
530
+ return e = t(rn(i)), e || (e = t(on(i)), e) || (e = t(un(i)), e) || (e = t(_e(i)), e) ? e : !1;
531
+ }
532
+ function rn(i) {
533
+ return [i[0], i[1]];
534
+ }
535
+ function on(i) {
536
+ return [i[2], i[1]];
537
+ }
538
+ function rt(i) {
539
+ return [(i[0] + i[2]) / 2, (i[1] + i[3]) / 2];
540
+ }
541
+ function an(i, t, e, n, s) {
542
+ const [r, o, a, l, h, u, c, f] = ln(
543
+ i,
544
+ t,
545
+ e,
546
+ n
547
+ );
548
+ return ct(
549
+ Math.min(r, a, h, c),
550
+ Math.min(o, l, u, f),
551
+ Math.max(r, a, h, c),
552
+ Math.max(o, l, u, f),
553
+ s
554
+ );
555
+ }
556
+ function ln(i, t, e, n) {
557
+ const s = t * n[0] / 2, r = t * n[1] / 2, o = Math.cos(e), a = Math.sin(e), l = s * o, h = s * a, u = r * o, c = r * a, f = i[0], g = i[1];
558
+ return [
559
+ f - l + c,
560
+ g - h - u,
561
+ f - l - c,
562
+ g - h + u,
563
+ f + l - c,
564
+ g + h + u,
565
+ f + l + c,
566
+ g + h - u,
567
+ f - l + c,
568
+ g - h - u
569
+ ];
570
+ }
571
+ function k(i) {
572
+ return i[3] - i[1];
573
+ }
574
+ function _e(i) {
575
+ return [i[0], i[3]];
576
+ }
577
+ function un(i) {
578
+ return [i[2], i[3]];
579
+ }
580
+ function D(i) {
581
+ return i[2] - i[0];
582
+ }
583
+ function hn(i, t) {
584
+ return i[0] <= t[2] && i[2] >= t[0] && i[1] <= t[3] && i[3] >= t[1];
585
+ }
586
+ function Re(i) {
587
+ return i[2] < i[0] || i[3] < i[1];
588
+ }
589
+ function cn(i, t) {
590
+ return t ? (t[0] = i[0], t[1] = i[1], t[2] = i[2], t[3] = i[3], t) : i;
591
+ }
592
+ function fn(i, t, e) {
593
+ let n = !1;
594
+ const s = Ot(i, t), r = Ot(i, e);
595
+ if (s === M.INTERSECTING || r === M.INTERSECTING)
596
+ n = !0;
597
+ else {
598
+ const o = i[0], a = i[1], l = i[2], h = i[3], u = t[0], c = t[1], f = e[0], g = e[1], d = (g - c) / (f - u);
599
+ let m, _;
600
+ r & M.ABOVE && !(s & M.ABOVE) && (m = f - (g - h) / d, n = m >= o && m <= l), !n && r & M.RIGHT && !(s & M.RIGHT) && (_ = g - (f - l) * d, n = _ >= a && _ <= h), !n && r & M.BELOW && !(s & M.BELOW) && (m = f - (g - a) / d, n = m >= o && m <= l), !n && r & M.LEFT && !(s & M.LEFT) && (_ = g - (f - o) * d, n = _ >= a && _ <= h);
601
+ }
602
+ return n;
603
+ }
604
+ function p(i, t, e) {
605
+ return Math.min(Math.max(i, t), e);
606
+ }
607
+ function gn(i, t, e, n, s, r) {
608
+ const o = s - e, a = r - n;
609
+ if (o !== 0 || a !== 0) {
610
+ const l = ((i - e) * o + (t - n) * a) / (o * o + a * a);
611
+ l > 1 ? (e = s, n = r) : l > 0 && (e += o * l, n += a * l);
612
+ }
613
+ return U(i, t, e, n);
614
+ }
615
+ function U(i, t, e, n) {
616
+ const s = e - i, r = n - t;
617
+ return s * s + r * r;
618
+ }
619
+ function Lt(i) {
620
+ return i * 180 / Math.PI;
621
+ }
622
+ function H(i) {
623
+ return i * Math.PI / 180;
624
+ }
625
+ function bt(i, t) {
626
+ const e = i % t;
627
+ return e * t < 0 ? e + t : e;
628
+ }
629
+ function dn(i, t, e) {
630
+ return i + e * (t - i);
631
+ }
632
+ function xe(i, t) {
633
+ const e = Math.pow(10, t);
634
+ return Math.round(i * e) / e;
635
+ }
636
+ function K(i, t) {
637
+ return Math.floor(xe(i, t));
638
+ }
639
+ function J(i, t) {
640
+ return Math.ceil(xe(i, t));
641
+ }
642
+ function Tt(i, t, e) {
643
+ if (i >= t && i < e)
644
+ return i;
645
+ const n = e - t;
646
+ return ((i - t) % n + n) % n + t;
647
+ }
648
+ function mn(...i) {
649
+ console.warn(...i);
650
+ }
651
+ function _n(i, t) {
652
+ return i[0] += +t[0], i[1] += +t[1], i;
653
+ }
654
+ function ot(i, t) {
655
+ let e = !0;
656
+ for (let n = i.length - 1; n >= 0; --n)
657
+ if (i[n] != t[n]) {
658
+ e = !1;
659
+ break;
660
+ }
661
+ return e;
662
+ }
663
+ function Rn(i, t) {
664
+ const e = Math.cos(t), n = Math.sin(t), s = i[0] * e - i[1] * n, r = i[1] * e + i[0] * n;
665
+ return i[0] = s, i[1] = r, i;
666
+ }
667
+ function xn(i, t, e) {
668
+ const n = t.getExtent();
669
+ let s = 0;
670
+ return t.canWrapX() && (i[0] < n[0] || i[0] > n[2]) && (e = e || D(n), s = Math.floor(
671
+ (i[0] - n[0]) / e
672
+ )), s;
673
+ }
674
+ const Me = {
675
+ // use the radius of the Normal sphere
676
+ radians: 6370997 / (2 * Math.PI),
677
+ degrees: 2 * Math.PI * 6370997 / 360,
678
+ ft: 0.3048,
679
+ m: 1,
680
+ "us-ft": 1200 / 3937
681
+ };
682
+ class ft {
683
+ /**
684
+ * @param {Options} options Projection options.
685
+ */
686
+ constructor(t) {
687
+ this.code_ = t.code, this.units_ = /** @type {import("./Units.js").Units} */
688
+ t.units, this.extent_ = t.extent !== void 0 ? t.extent : null, this.worldExtent_ = t.worldExtent !== void 0 ? t.worldExtent : null, this.axisOrientation_ = t.axisOrientation !== void 0 ? t.axisOrientation : "enu", this.global_ = t.global !== void 0 ? t.global : !1, this.canWrapX_ = !!(this.global_ && this.extent_), this.getPointResolutionFunc_ = t.getPointResolution, this.defaultTileGrid_ = null, this.metersPerUnit_ = t.metersPerUnit;
689
+ }
690
+ /**
691
+ * @return {boolean} The projection is suitable for wrapping the x-axis
692
+ */
693
+ canWrapX() {
694
+ return this.canWrapX_;
695
+ }
696
+ /**
697
+ * Get the code for this projection, e.g. 'EPSG:4326'.
698
+ * @return {string} Code.
699
+ * @api
700
+ */
701
+ getCode() {
702
+ return this.code_;
703
+ }
704
+ /**
705
+ * Get the validity extent for this projection.
706
+ * @return {import("../extent.js").Extent} Extent.
707
+ * @api
708
+ */
709
+ getExtent() {
710
+ return this.extent_;
711
+ }
712
+ /**
713
+ * Get the units of this projection.
714
+ * @return {import("./Units.js").Units} Units.
715
+ * @api
716
+ */
717
+ getUnits() {
718
+ return this.units_;
719
+ }
720
+ /**
721
+ * Get the amount of meters per unit of this projection. If the projection is
722
+ * not configured with `metersPerUnit` or a units identifier, the return is
723
+ * `undefined`.
724
+ * @return {number|undefined} Meters.
725
+ * @api
726
+ */
727
+ getMetersPerUnit() {
728
+ return this.metersPerUnit_ || Me[this.units_];
729
+ }
730
+ /**
731
+ * Get the world extent for this projection.
732
+ * @return {import("../extent.js").Extent} Extent.
733
+ * @api
734
+ */
735
+ getWorldExtent() {
736
+ return this.worldExtent_;
737
+ }
738
+ /**
739
+ * Get the axis orientation of this projection.
740
+ * Example values are:
741
+ * enu - the default easting, northing, elevation.
742
+ * neu - northing, easting, up - useful for "lat/long" geographic coordinates,
743
+ * or south orientated transverse mercator.
744
+ * wnu - westing, northing, up - some planetary coordinate systems have
745
+ * "west positive" coordinate systems
746
+ * @return {string} Axis orientation.
747
+ * @api
748
+ */
749
+ getAxisOrientation() {
750
+ return this.axisOrientation_;
751
+ }
752
+ /**
753
+ * Is this projection a global projection which spans the whole world?
754
+ * @return {boolean} Whether the projection is global.
755
+ * @api
756
+ */
757
+ isGlobal() {
758
+ return this.global_;
759
+ }
760
+ /**
761
+ * Set if the projection is a global projection which spans the whole world
762
+ * @param {boolean} global Whether the projection is global.
763
+ * @api
764
+ */
765
+ setGlobal(t) {
766
+ this.global_ = t, this.canWrapX_ = !!(t && this.extent_);
767
+ }
768
+ /**
769
+ * @return {import("../tilegrid/TileGrid.js").default} The default tile grid.
770
+ */
771
+ getDefaultTileGrid() {
772
+ return this.defaultTileGrid_;
773
+ }
774
+ /**
775
+ * @param {import("../tilegrid/TileGrid.js").default} tileGrid The default tile grid.
776
+ */
777
+ setDefaultTileGrid(t) {
778
+ this.defaultTileGrid_ = t;
779
+ }
780
+ /**
781
+ * Set the validity extent for this projection.
782
+ * @param {import("../extent.js").Extent} extent Extent.
783
+ * @api
784
+ */
785
+ setExtent(t) {
786
+ this.extent_ = t, this.canWrapX_ = !!(this.global_ && t);
787
+ }
788
+ /**
789
+ * Set the world extent for this projection.
790
+ * @param {import("../extent.js").Extent} worldExtent World extent
791
+ * [minlon, minlat, maxlon, maxlat].
792
+ * @api
793
+ */
794
+ setWorldExtent(t) {
795
+ this.worldExtent_ = t;
796
+ }
797
+ /**
798
+ * Set the getPointResolution function (see {@link module:ol/proj.getPointResolution}
799
+ * for this projection.
800
+ * @param {function(number, import("../coordinate.js").Coordinate):number} func Function
801
+ * @api
802
+ */
803
+ setGetPointResolution(t) {
804
+ this.getPointResolutionFunc_ = t;
805
+ }
806
+ /**
807
+ * Get the custom point resolution function for this projection (if set).
808
+ * @return {GetPointResolution|undefined} The custom point
809
+ * resolution function (if set).
810
+ */
811
+ getPointResolutionFunc() {
812
+ return this.getPointResolutionFunc_;
813
+ }
814
+ }
815
+ const B = 6378137, b = Math.PI * B, Mn = [-b, -b, b, b], Cn = [-180, -85, 180, 85], Q = B * Math.log(Math.tan(Math.PI / 2));
816
+ class z extends ft {
817
+ /**
818
+ * @param {string} code Code.
819
+ */
820
+ constructor(t) {
821
+ super({
822
+ code: t,
823
+ units: "m",
824
+ extent: Mn,
825
+ global: !0,
826
+ worldExtent: Cn,
827
+ getPointResolution: function(e, n) {
828
+ return e / Math.cosh(n[1] / B);
829
+ }
830
+ });
831
+ }
832
+ }
833
+ const Ut = [
834
+ new z("EPSG:3857"),
835
+ new z("EPSG:102100"),
836
+ new z("EPSG:102113"),
837
+ new z("EPSG:900913"),
838
+ new z("http://www.opengis.net/def/crs/EPSG/0/3857"),
839
+ new z("http://www.opengis.net/gml/srs/epsg.xml#3857")
840
+ ];
841
+ function En(i, t, e, n) {
842
+ const s = i.length;
843
+ e = e > 1 ? e : 2, n = n ?? e, t === void 0 && (e > 2 ? t = i.slice() : t = new Array(s));
844
+ for (let r = 0; r < s; r += n) {
845
+ t[r] = b * i[r] / 180;
846
+ let o = B * Math.log(Math.tan(Math.PI * (+i[r + 1] + 90) / 360));
847
+ o > Q ? o = Q : o < -Q && (o = -Q), t[r + 1] = o;
848
+ }
849
+ return t;
850
+ }
851
+ function Tn(i, t, e, n) {
852
+ const s = i.length;
853
+ e = e > 1 ? e : 2, n = n ?? e, t === void 0 && (e > 2 ? t = i.slice() : t = new Array(s));
854
+ for (let r = 0; r < s; r += n)
855
+ t[r] = 180 * i[r] / b, t[r + 1] = 360 * Math.atan(Math.exp(i[r + 1] / B)) / Math.PI - 90;
856
+ return t;
857
+ }
858
+ const pn = 6378137, Vt = [-180, -90, 180, 90], In = Math.PI * pn / 180;
859
+ class X extends ft {
860
+ /**
861
+ * @param {string} code Code.
862
+ * @param {string} [axisOrientation] Axis orientation.
863
+ */
864
+ constructor(t, e) {
865
+ super({
866
+ code: t,
867
+ units: "degrees",
868
+ extent: Vt,
869
+ axisOrientation: e,
870
+ global: !0,
871
+ metersPerUnit: In,
872
+ worldExtent: Vt
873
+ });
874
+ }
875
+ }
876
+ const Dt = [
877
+ new X("CRS:84"),
878
+ new X("EPSG:4326", "neu"),
879
+ new X("urn:ogc:def:crs:OGC:1.3:CRS84"),
880
+ new X("urn:ogc:def:crs:OGC:2:84"),
881
+ new X("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),
882
+ new X("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"),
883
+ new X("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")
884
+ ];
885
+ let pt = {};
886
+ function it(i) {
887
+ return pt[i] || pt[i.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/, "EPSG:$3")] || null;
888
+ }
889
+ function yn(i, t) {
890
+ pt[i] = t;
891
+ }
892
+ let V = {};
893
+ function Z(i, t, e) {
894
+ const n = i.getCode(), s = t.getCode();
895
+ n in V || (V[n] = {}), V[n][s] = e;
896
+ }
897
+ function st(i, t) {
898
+ return i in V && t in V[i] ? V[i][t] : null;
899
+ }
900
+ const at = 0.9996, T = 669438e-8, gt = T * T, dt = gt * T, N = T / (1 - T), Wt = Math.sqrt(1 - T), W = (1 - Wt) / (1 + Wt), Ce = W * W, St = Ce * W, At = St * W, Ee = At * W, Te = 1 - T / 4 - 3 * gt / 64 - 5 * dt / 256, wn = 3 * T / 8 + 3 * gt / 32 + 45 * dt / 1024, Sn = 15 * gt / 256 + 45 * dt / 1024, An = 35 * dt / 3072, vn = 3 / 2 * W - 27 / 32 * St + 269 / 512 * Ee, Pn = 21 / 16 * Ce - 55 / 32 * At, Fn = 151 / 96 * St - 417 / 128 * Ee, Xn = 1097 / 512 * At, lt = 6378137;
901
+ function Nn(i, t, e) {
902
+ const n = i - 5e5, o = (e.north ? t : t - 1e7) / at / (lt * Te), a = o + vn * Math.sin(2 * o) + Pn * Math.sin(4 * o) + Fn * Math.sin(6 * o) + Xn * Math.sin(8 * o), l = Math.sin(a), h = l * l, u = Math.cos(a), c = l / u, f = c * c, g = f * f, d = 1 - T * h, m = Math.sqrt(1 - T * h), _ = lt / m, x = (1 - T) / d, R = N * u ** 2, w = R * R, C = n / (_ * at), F = C * C, $ = F * C, Yt = $ * C, Zt = Yt * C, ze = Zt * C, Ge = a - c / x * (F / 2 - Yt / 24 * (5 + 3 * f + 10 * R - 4 * w - 9 * N)) + ze / 720 * (61 + 90 * f + 298 * R + 45 * g - 252 * N - 3 * w);
903
+ let mt = (C - $ / 6 * (1 + 2 * f + R) + Zt / 120 * (5 - 2 * R + 28 * f - 3 * w + 8 * N + 24 * g)) / u;
904
+ return mt = Tt(
905
+ mt + H(pe(e.number)),
906
+ -Math.PI,
907
+ Math.PI
908
+ ), [Lt(mt), Lt(Ge)];
909
+ }
910
+ const $t = -80, Ht = 84, Yn = -180, Zn = 180;
911
+ function jn(i, t, e) {
912
+ i = Tt(i, Yn, Zn), t < $t ? t = $t : t > Ht && (t = Ht);
913
+ const n = H(t), s = Math.sin(n), r = Math.cos(n), o = s / r, a = o * o, l = a * a, h = H(i), u = pe(e.number), c = H(u), f = lt / Math.sqrt(1 - T * s ** 2), g = N * r ** 2, d = r * Tt(h - c, -Math.PI, Math.PI), m = d * d, _ = m * d, x = _ * d, R = x * d, w = R * d, C = lt * (Te * n - wn * Math.sin(2 * n) + Sn * Math.sin(4 * n) - An * Math.sin(6 * n)), F = at * f * (d + _ / 6 * (1 - a + g) + R / 120 * (5 - 18 * a + l + 72 * g - 58 * N)) + 5e5;
914
+ let $ = at * (C + f * o * (m / 2 + x / 24 * (5 - a + 9 * g + 4 * g ** 2) + w / 720 * (61 - 58 * a + l + 600 * g - 330 * N)));
915
+ return e.north || ($ += 1e7), [F, $];
916
+ }
917
+ function pe(i) {
918
+ return (i - 1) * 6 - 180 + 3;
919
+ }
920
+ const zn = [
921
+ /^EPSG:(\d+)$/,
922
+ /^urn:ogc:def:crs:EPSG::(\d+)$/,
923
+ /^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/
924
+ ];
925
+ function Ie(i) {
926
+ let t = 0;
927
+ for (const s of zn) {
928
+ const r = i.match(s);
929
+ if (r) {
930
+ t = parseInt(r[1]);
931
+ break;
932
+ }
933
+ }
934
+ if (!t)
935
+ return null;
936
+ let e = 0, n = !1;
937
+ return t > 32700 && t < 32761 ? e = t - 32700 : t > 32600 && t < 32661 && (n = !0, e = t - 32600), e ? { number: e, north: n } : null;
938
+ }
939
+ function kt(i, t) {
940
+ return function(e, n, s, r) {
941
+ const o = e.length;
942
+ s = s > 1 ? s : 2, r = r ?? s, n || (s > 2 ? n = e.slice() : n = new Array(o));
943
+ for (let a = 0; a < o; a += r) {
944
+ const l = e[a], h = e[a + 1], u = i(l, h, t);
945
+ n[a] = u[0], n[a + 1] = u[1];
946
+ }
947
+ return n;
948
+ };
949
+ }
950
+ function Gn(i) {
951
+ return Ie(i) ? new ft({ code: i, units: "m" }) : null;
952
+ }
953
+ function On(i) {
954
+ const t = Ie(i.getCode());
955
+ return t ? {
956
+ forward: kt(jn, t),
957
+ inverse: kt(Nn, t)
958
+ } : null;
959
+ }
960
+ const Ln = [On], bn = [Gn];
961
+ let It = !0;
962
+ function Un(i) {
963
+ It = !1;
964
+ }
965
+ function ye(i, t) {
966
+ if (t !== void 0) {
967
+ for (let e = 0, n = i.length; e < n; ++e)
968
+ t[e] = i[e];
969
+ t = t;
970
+ } else
971
+ t = i.slice();
972
+ return t;
973
+ }
974
+ function ut(i) {
975
+ yn(i.getCode(), i), Z(i, i, ye);
976
+ }
977
+ function Vn(i) {
978
+ i.forEach(ut);
979
+ }
980
+ function j(i) {
981
+ if (typeof i != "string")
982
+ return i;
983
+ const t = it(i);
984
+ if (t)
985
+ return t;
986
+ for (const e of bn) {
987
+ const n = e(i);
988
+ if (n)
989
+ return n;
990
+ }
991
+ return null;
992
+ }
993
+ function yt(i) {
994
+ Vn(i), i.forEach(function(t) {
995
+ i.forEach(function(e) {
996
+ t !== e && Z(t, e, ye);
997
+ });
998
+ });
999
+ }
1000
+ function Dn(i, t, e, n) {
1001
+ i.forEach(function(s) {
1002
+ t.forEach(function(r) {
1003
+ Z(s, r, e), Z(r, s, n);
1004
+ });
1005
+ });
1006
+ }
1007
+ function vt(i, t) {
1008
+ return i ? typeof i == "string" ? j(i) : (
1009
+ /** @type {Projection} */
1010
+ i
1011
+ ) : j(t);
1012
+ }
1013
+ function qt(i) {
1014
+ return (
1015
+ /**
1016
+ * @param {Array<number>} input Input.
1017
+ * @param {Array<number>} [output] Output.
1018
+ * @param {number} [dimension] Dimensions that should be transformed.
1019
+ * @param {number} [stride] Stride.
1020
+ * @return {Array<number>} Output.
1021
+ */
1022
+ function(t, e, n, s) {
1023
+ const r = t.length;
1024
+ n = n !== void 0 ? n : 2, s = s ?? n, e = e !== void 0 ? e : new Array(r);
1025
+ for (let o = 0; o < r; o += s) {
1026
+ const a = i(t.slice(o, o + n)), l = a.length;
1027
+ for (let h = 0, u = s; h < u; ++h)
1028
+ e[o + h] = h >= l ? t[o + h] : a[h];
1029
+ }
1030
+ return e;
1031
+ }
1032
+ );
1033
+ }
1034
+ function Wn(i, t, e, n) {
1035
+ const s = j(i), r = j(t);
1036
+ Z(
1037
+ s,
1038
+ r,
1039
+ qt(e)
1040
+ ), Z(
1041
+ r,
1042
+ s,
1043
+ qt(n)
1044
+ );
1045
+ }
1046
+ function $n(i, t) {
1047
+ const e = i.getCode(), n = t.getCode();
1048
+ let s = st(e, n);
1049
+ if (s)
1050
+ return s;
1051
+ let r = null, o = null;
1052
+ for (const l of Ln)
1053
+ r || (r = l(i)), o || (o = l(t));
1054
+ if (!r && !o)
1055
+ return null;
1056
+ const a = "EPSG:4326";
1057
+ if (o)
1058
+ if (r)
1059
+ s = Rt(
1060
+ r.inverse,
1061
+ o.forward
1062
+ );
1063
+ else {
1064
+ const l = st(e, a);
1065
+ l && (s = Rt(
1066
+ l,
1067
+ o.forward
1068
+ ));
1069
+ }
1070
+ else {
1071
+ const l = st(a, n);
1072
+ l && (s = Rt(
1073
+ r.inverse,
1074
+ l
1075
+ ));
1076
+ }
1077
+ return s && (ut(i), ut(t), Z(i, t, s)), s;
1078
+ }
1079
+ function Rt(i, t) {
1080
+ return function(e, n, s, r) {
1081
+ return n = i(e, n, s, r), t(n, n, s, r);
1082
+ };
1083
+ }
1084
+ function Bt(i, t) {
1085
+ const e = j(i), n = j(t);
1086
+ return $n(e, n);
1087
+ }
1088
+ function Kt(i, t) {
1089
+ return i;
1090
+ }
1091
+ function S(i, t) {
1092
+ return It && !ot(i, [0, 0]) && i[0] >= -180 && i[0] <= 180 && i[1] >= -90 && i[1] <= 90 && (It = !1, mn(
1093
+ "Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates."
1094
+ )), i;
1095
+ }
1096
+ function Hn(i, t) {
1097
+ return i;
1098
+ }
1099
+ function tt(i, t) {
1100
+ return i;
1101
+ }
1102
+ function Jt(i, t, e) {
1103
+ return function(n) {
1104
+ let s, r;
1105
+ if (i.canWrapX()) {
1106
+ const o = i.getExtent(), a = D(o);
1107
+ n = n.slice(0), r = xn(n, i, a), r && (n[0] = n[0] - r * a), n[0] = p(n[0], o[0], o[2]), n[1] = p(n[1], o[1], o[3]), s = e(n);
1108
+ } else
1109
+ s = e(n);
1110
+ return r && t.canWrapX() && (s[0] += r * D(t.getExtent())), s;
1111
+ };
1112
+ }
1113
+ function kn() {
1114
+ yt(Ut), yt(Dt), Dn(
1115
+ Dt,
1116
+ Ut,
1117
+ En,
1118
+ Tn
1119
+ );
1120
+ }
1121
+ kn();
1122
+ new Array(6);
1123
+ function qn() {
1124
+ return [1, 0, 0, 1, 0, 0];
1125
+ }
1126
+ function Bn(i, t, e, n, s, r, o, a) {
1127
+ const l = Math.sin(r), h = Math.cos(r);
1128
+ return i[0] = n * h, i[1] = s * l, i[2] = -n * l, i[3] = s * h, i[4] = o * n * h - a * n * l + t, i[5] = o * s * l + a * s * h + e, i;
1129
+ }
1130
+ function Kn(i, t, e, n, s, r, o) {
1131
+ r = r || [], o = o || 2;
1132
+ let a = 0;
1133
+ for (let l = t; l < e; l += n) {
1134
+ const h = i[l], u = i[l + 1];
1135
+ r[a++] = s[0] * h + s[2] * u + s[4], r[a++] = s[1] * h + s[3] * u + s[5];
1136
+ for (let c = 2; c < o; c++)
1137
+ r[a++] = i[l + c];
1138
+ }
1139
+ return r && r.length != a && (r.length = a), r;
1140
+ }
1141
+ function Jn(i, t, e, n, s, r, o) {
1142
+ o = o || [];
1143
+ const a = Math.cos(s), l = Math.sin(s), h = r[0], u = r[1];
1144
+ let c = 0;
1145
+ for (let f = t; f < e; f += n) {
1146
+ const g = i[f] - h, d = i[f + 1] - u;
1147
+ o[c++] = h + g * a - d * l, o[c++] = u + g * l + d * a;
1148
+ for (let m = f + 2; m < f + n; ++m)
1149
+ o[c++] = i[m];
1150
+ }
1151
+ return o && o.length != c && (o.length = c), o;
1152
+ }
1153
+ function Qn(i, t, e, n, s, r, o, a) {
1154
+ a = a || [];
1155
+ const l = o[0], h = o[1];
1156
+ let u = 0;
1157
+ for (let c = t; c < e; c += n) {
1158
+ const f = i[c] - l, g = i[c + 1] - h;
1159
+ a[u++] = l + s * f, a[u++] = h + r * g;
1160
+ for (let d = c + 2; d < c + n; ++d)
1161
+ a[u++] = i[d];
1162
+ }
1163
+ return a && a.length != u && (a.length = u), a;
1164
+ }
1165
+ function ti(i, t, e, n, s, r, o) {
1166
+ o = o || [];
1167
+ let a = 0;
1168
+ for (let l = t; l < e; l += n) {
1169
+ o[a++] = i[l] + s, o[a++] = i[l + 1] + r;
1170
+ for (let h = l + 2; h < l + n; ++h)
1171
+ o[a++] = i[h];
1172
+ }
1173
+ return o && o.length != a && (o.length = a), o;
1174
+ }
1175
+ const Qt = qn(), ei = [NaN, NaN];
1176
+ class ni extends ce {
1177
+ constructor() {
1178
+ super(), this.extent_ = ge(), this.extentRevision_ = -1, this.simplifiedGeometryMaxMinSquaredTolerance = 0, this.simplifiedGeometryRevision = 0, this.simplifyTransformedInternal = $e(
1179
+ (t, e, n) => {
1180
+ if (!n)
1181
+ return this.getSimplifiedGeometry(e);
1182
+ const s = this.clone();
1183
+ return s.applyTransform(n), s.getSimplifiedGeometry(e);
1184
+ }
1185
+ );
1186
+ }
1187
+ /**
1188
+ * Get a transformed and simplified version of the geometry.
1189
+ * @abstract
1190
+ * @param {number} squaredTolerance Squared tolerance.
1191
+ * @param {import("../proj.js").TransformFunction} [transform] Optional transform function.
1192
+ * @return {Geometry} Simplified geometry.
1193
+ */
1194
+ simplifyTransformed(t, e) {
1195
+ return this.simplifyTransformedInternal(
1196
+ this.getRevision(),
1197
+ t,
1198
+ e
1199
+ );
1200
+ }
1201
+ /**
1202
+ * Make a complete copy of the geometry.
1203
+ * @abstract
1204
+ * @return {!Geometry} Clone.
1205
+ */
1206
+ clone() {
1207
+ return E();
1208
+ }
1209
+ /**
1210
+ * @abstract
1211
+ * @param {number} x X.
1212
+ * @param {number} y Y.
1213
+ * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
1214
+ * @param {number} minSquaredDistance Minimum squared distance.
1215
+ * @return {number} Minimum squared distance.
1216
+ */
1217
+ closestPointXY(t, e, n, s) {
1218
+ return E();
1219
+ }
1220
+ /**
1221
+ * @param {number} x X.
1222
+ * @param {number} y Y.
1223
+ * @return {boolean} Contains (x, y).
1224
+ */
1225
+ containsXY(t, e) {
1226
+ return this.closestPointXY(t, e, ei, Number.MIN_VALUE) === 0;
1227
+ }
1228
+ /**
1229
+ * Return the closest point of the geometry to the passed point as
1230
+ * {@link module:ol/coordinate~Coordinate coordinate}.
1231
+ * @param {import("../coordinate.js").Coordinate} point Point.
1232
+ * @param {import("../coordinate.js").Coordinate} [closestPoint] Closest point.
1233
+ * @return {import("../coordinate.js").Coordinate} Closest point.
1234
+ * @api
1235
+ */
1236
+ getClosestPoint(t, e) {
1237
+ return e = e || [NaN, NaN], this.closestPointXY(t[0], t[1], e, 1 / 0), e;
1238
+ }
1239
+ /**
1240
+ * Returns true if this geometry includes the specified coordinate. If the
1241
+ * coordinate is on the boundary of the geometry, returns false.
1242
+ * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
1243
+ * @return {boolean} Contains coordinate.
1244
+ * @api
1245
+ */
1246
+ intersectsCoordinate(t) {
1247
+ return this.containsXY(t[0], t[1]);
1248
+ }
1249
+ /**
1250
+ * @abstract
1251
+ * @param {import("../extent.js").Extent} extent Extent.
1252
+ * @protected
1253
+ * @return {import("../extent.js").Extent} extent Extent.
1254
+ */
1255
+ computeExtent(t) {
1256
+ return E();
1257
+ }
1258
+ /**
1259
+ * Get the extent of the geometry.
1260
+ * @param {import("../extent.js").Extent} [extent] Extent.
1261
+ * @return {import("../extent.js").Extent} extent Extent.
1262
+ * @api
1263
+ */
1264
+ getExtent(t) {
1265
+ if (this.extentRevision_ != this.getRevision()) {
1266
+ const e = this.computeExtent(this.extent_);
1267
+ (isNaN(e[0]) || isNaN(e[1])) && de(e), this.extentRevision_ = this.getRevision();
1268
+ }
1269
+ return cn(this.extent_, t);
1270
+ }
1271
+ /**
1272
+ * Rotate the geometry around a given coordinate. This modifies the geometry
1273
+ * coordinates in place.
1274
+ * @abstract
1275
+ * @param {number} angle Rotation angle in radians.
1276
+ * @param {import("../coordinate.js").Coordinate} anchor The rotation center.
1277
+ * @api
1278
+ */
1279
+ rotate(t, e) {
1280
+ E();
1281
+ }
1282
+ /**
1283
+ * Scale the geometry (with an optional origin). This modifies the geometry
1284
+ * coordinates in place.
1285
+ * @abstract
1286
+ * @param {number} sx The scaling factor in the x-direction.
1287
+ * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
1288
+ * @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
1289
+ * of the geometry extent).
1290
+ * @api
1291
+ */
1292
+ scale(t, e, n) {
1293
+ E();
1294
+ }
1295
+ /**
1296
+ * Create a simplified version of this geometry. For linestrings, this uses
1297
+ * the [Douglas Peucker](https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm)
1298
+ * algorithm. For polygons, a quantization-based
1299
+ * simplification is used to preserve topology.
1300
+ * @param {number} tolerance The tolerance distance for simplification.
1301
+ * @return {Geometry} A new, simplified version of the original geometry.
1302
+ * @api
1303
+ */
1304
+ simplify(t) {
1305
+ return this.getSimplifiedGeometry(t * t);
1306
+ }
1307
+ /**
1308
+ * Create a simplified version of this geometry using the Douglas Peucker
1309
+ * algorithm.
1310
+ * See https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm.
1311
+ * @abstract
1312
+ * @param {number} squaredTolerance Squared tolerance.
1313
+ * @return {Geometry} Simplified geometry.
1314
+ */
1315
+ getSimplifiedGeometry(t) {
1316
+ return E();
1317
+ }
1318
+ /**
1319
+ * Get the type of this geometry.
1320
+ * @abstract
1321
+ * @return {Type} Geometry type.
1322
+ */
1323
+ getType() {
1324
+ return E();
1325
+ }
1326
+ /**
1327
+ * Apply a transform function to the coordinates of the geometry.
1328
+ * The geometry is modified in place.
1329
+ * If you do not want the geometry modified in place, first `clone()` it and
1330
+ * then use this function on the clone.
1331
+ * @abstract
1332
+ * @param {import("../proj.js").TransformFunction} transformFn Transform function.
1333
+ * Called with a flat array of geometry coordinates.
1334
+ */
1335
+ applyTransform(t) {
1336
+ E();
1337
+ }
1338
+ /**
1339
+ * Test if the geometry and the passed extent intersect.
1340
+ * @abstract
1341
+ * @param {import("../extent.js").Extent} extent Extent.
1342
+ * @return {boolean} `true` if the geometry and the extent intersect.
1343
+ */
1344
+ intersectsExtent(t) {
1345
+ return E();
1346
+ }
1347
+ /**
1348
+ * Translate the geometry. This modifies the geometry coordinates in place. If
1349
+ * instead you want a new geometry, first `clone()` this geometry.
1350
+ * @abstract
1351
+ * @param {number} deltaX Delta X.
1352
+ * @param {number} deltaY Delta Y.
1353
+ * @api
1354
+ */
1355
+ translate(t, e) {
1356
+ E();
1357
+ }
1358
+ /**
1359
+ * Transform each coordinate of the geometry from one coordinate reference
1360
+ * system to another. The geometry is modified in place.
1361
+ * For example, a line will be transformed to a line and a circle to a circle.
1362
+ * If you do not want the geometry modified in place, first `clone()` it and
1363
+ * then use this function on the clone.
1364
+ *
1365
+ * @param {import("../proj.js").ProjectionLike} source The current projection. Can be a
1366
+ * string identifier or a {@link module:ol/proj/Projection~Projection} object.
1367
+ * @param {import("../proj.js").ProjectionLike} destination The desired projection. Can be a
1368
+ * string identifier or a {@link module:ol/proj/Projection~Projection} object.
1369
+ * @return {this} This geometry. Note that original geometry is
1370
+ * modified in place.
1371
+ * @api
1372
+ */
1373
+ transform(t, e) {
1374
+ const n = j(t), s = n.getUnits() == "tile-pixels" ? function(r, o, a) {
1375
+ const l = n.getExtent(), h = n.getWorldExtent(), u = k(h) / k(l);
1376
+ Bn(
1377
+ Qt,
1378
+ h[0],
1379
+ h[3],
1380
+ u,
1381
+ -u,
1382
+ 0,
1383
+ 0,
1384
+ 0
1385
+ );
1386
+ const c = Kn(
1387
+ r,
1388
+ 0,
1389
+ r.length,
1390
+ a,
1391
+ Qt,
1392
+ o
1393
+ ), f = Bt(n, e);
1394
+ return f ? f(c, c, a) : c;
1395
+ } : Bt(n, e);
1396
+ return this.applyTransform(s), this;
1397
+ }
1398
+ }
1399
+ class Pt extends ni {
1400
+ constructor() {
1401
+ super(), this.layout = "XY", this.stride = 2, this.flatCoordinates;
1402
+ }
1403
+ /**
1404
+ * @param {import("../extent.js").Extent} extent Extent.
1405
+ * @protected
1406
+ * @return {import("../extent.js").Extent} extent Extent.
1407
+ * @override
1408
+ */
1409
+ computeExtent(t) {
1410
+ return en(
1411
+ this.flatCoordinates,
1412
+ 0,
1413
+ this.flatCoordinates.length,
1414
+ this.stride,
1415
+ t
1416
+ );
1417
+ }
1418
+ /**
1419
+ * @abstract
1420
+ * @return {Array<*> | null} Coordinates.
1421
+ */
1422
+ getCoordinates() {
1423
+ return E();
1424
+ }
1425
+ /**
1426
+ * Return the first coordinate of the geometry.
1427
+ * @return {import("../coordinate.js").Coordinate} First coordinate.
1428
+ * @api
1429
+ */
1430
+ getFirstCoordinate() {
1431
+ return this.flatCoordinates.slice(0, this.stride);
1432
+ }
1433
+ /**
1434
+ * @return {Array<number>} Flat coordinates.
1435
+ */
1436
+ getFlatCoordinates() {
1437
+ return this.flatCoordinates;
1438
+ }
1439
+ /**
1440
+ * Return the last coordinate of the geometry.
1441
+ * @return {import("../coordinate.js").Coordinate} Last point.
1442
+ * @api
1443
+ */
1444
+ getLastCoordinate() {
1445
+ return this.flatCoordinates.slice(
1446
+ this.flatCoordinates.length - this.stride
1447
+ );
1448
+ }
1449
+ /**
1450
+ * Return the {@link import("./Geometry.js").GeometryLayout layout} of the geometry.
1451
+ * @return {import("./Geometry.js").GeometryLayout} Layout.
1452
+ * @api
1453
+ */
1454
+ getLayout() {
1455
+ return this.layout;
1456
+ }
1457
+ /**
1458
+ * Create a simplified version of this geometry using the Douglas Peucker algorithm.
1459
+ * @param {number} squaredTolerance Squared tolerance.
1460
+ * @return {SimpleGeometry} Simplified geometry.
1461
+ * @override
1462
+ */
1463
+ getSimplifiedGeometry(t) {
1464
+ if (this.simplifiedGeometryRevision !== this.getRevision() && (this.simplifiedGeometryMaxMinSquaredTolerance = 0, this.simplifiedGeometryRevision = this.getRevision()), t < 0 || this.simplifiedGeometryMaxMinSquaredTolerance !== 0 && t <= this.simplifiedGeometryMaxMinSquaredTolerance)
1465
+ return this;
1466
+ const e = this.getSimplifiedGeometryInternal(t);
1467
+ return e.getFlatCoordinates().length < this.flatCoordinates.length ? e : (this.simplifiedGeometryMaxMinSquaredTolerance = t, this);
1468
+ }
1469
+ /**
1470
+ * @param {number} squaredTolerance Squared tolerance.
1471
+ * @return {SimpleGeometry} Simplified geometry.
1472
+ * @protected
1473
+ */
1474
+ getSimplifiedGeometryInternal(t) {
1475
+ return this;
1476
+ }
1477
+ /**
1478
+ * @return {number} Stride.
1479
+ */
1480
+ getStride() {
1481
+ return this.stride;
1482
+ }
1483
+ /**
1484
+ * @param {import("./Geometry.js").GeometryLayout} layout Layout.
1485
+ * @param {Array<number>} flatCoordinates Flat coordinates.
1486
+ */
1487
+ setFlatCoordinates(t, e) {
1488
+ this.stride = te(t), this.layout = t, this.flatCoordinates = e;
1489
+ }
1490
+ /**
1491
+ * @abstract
1492
+ * @param {!Array<*>} coordinates Coordinates.
1493
+ * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
1494
+ */
1495
+ setCoordinates(t, e) {
1496
+ E();
1497
+ }
1498
+ /**
1499
+ * @param {import("./Geometry.js").GeometryLayout|undefined} layout Layout.
1500
+ * @param {Array<*>} coordinates Coordinates.
1501
+ * @param {number} nesting Nesting.
1502
+ * @protected
1503
+ */
1504
+ setLayout(t, e, n) {
1505
+ let s;
1506
+ if (t)
1507
+ s = te(t);
1508
+ else {
1509
+ for (let r = 0; r < n; ++r) {
1510
+ if (e.length === 0) {
1511
+ this.layout = "XY", this.stride = 2;
1512
+ return;
1513
+ }
1514
+ e = /** @type {Array<unknown>} */
1515
+ e[0];
1516
+ }
1517
+ s = e.length, t = ii(s);
1518
+ }
1519
+ this.layout = t, this.stride = s;
1520
+ }
1521
+ /**
1522
+ * Apply a transform function to the coordinates of the geometry.
1523
+ * The geometry is modified in place.
1524
+ * If you do not want the geometry modified in place, first `clone()` it and
1525
+ * then use this function on the clone.
1526
+ * @param {import("../proj.js").TransformFunction} transformFn Transform function.
1527
+ * Called with a flat array of geometry coordinates.
1528
+ * @api
1529
+ * @override
1530
+ */
1531
+ applyTransform(t) {
1532
+ this.flatCoordinates && (t(
1533
+ this.flatCoordinates,
1534
+ this.flatCoordinates,
1535
+ this.layout.startsWith("XYZ") ? 3 : 2,
1536
+ this.stride
1537
+ ), this.changed());
1538
+ }
1539
+ /**
1540
+ * Rotate the geometry around a given coordinate. This modifies the geometry
1541
+ * coordinates in place.
1542
+ * @param {number} angle Rotation angle in counter-clockwise radians.
1543
+ * @param {import("../coordinate.js").Coordinate} anchor The rotation center.
1544
+ * @api
1545
+ * @override
1546
+ */
1547
+ rotate(t, e) {
1548
+ const n = this.getFlatCoordinates();
1549
+ if (n) {
1550
+ const s = this.getStride();
1551
+ Jn(
1552
+ n,
1553
+ 0,
1554
+ n.length,
1555
+ s,
1556
+ t,
1557
+ e,
1558
+ n
1559
+ ), this.changed();
1560
+ }
1561
+ }
1562
+ /**
1563
+ * Scale the geometry (with an optional origin). This modifies the geometry
1564
+ * coordinates in place.
1565
+ * @param {number} sx The scaling factor in the x-direction.
1566
+ * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
1567
+ * @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
1568
+ * of the geometry extent).
1569
+ * @api
1570
+ * @override
1571
+ */
1572
+ scale(t, e, n) {
1573
+ e === void 0 && (e = t), n || (n = rt(this.getExtent()));
1574
+ const s = this.getFlatCoordinates();
1575
+ if (s) {
1576
+ const r = this.getStride();
1577
+ Qn(
1578
+ s,
1579
+ 0,
1580
+ s.length,
1581
+ r,
1582
+ t,
1583
+ e,
1584
+ n,
1585
+ s
1586
+ ), this.changed();
1587
+ }
1588
+ }
1589
+ /**
1590
+ * Translate the geometry. This modifies the geometry coordinates in place. If
1591
+ * instead you want a new geometry, first `clone()` this geometry.
1592
+ * @param {number} deltaX Delta X.
1593
+ * @param {number} deltaY Delta Y.
1594
+ * @api
1595
+ * @override
1596
+ */
1597
+ translate(t, e) {
1598
+ const n = this.getFlatCoordinates();
1599
+ if (n) {
1600
+ const s = this.getStride();
1601
+ ti(
1602
+ n,
1603
+ 0,
1604
+ n.length,
1605
+ s,
1606
+ t,
1607
+ e,
1608
+ n
1609
+ ), this.changed();
1610
+ }
1611
+ }
1612
+ }
1613
+ function ii(i) {
1614
+ let t;
1615
+ return i == 2 ? t = "XY" : i == 3 ? t = "XYZ" : i == 4 && (t = "XYZM"), /** @type {import("./Geometry.js").GeometryLayout} */
1616
+ t;
1617
+ }
1618
+ function te(i) {
1619
+ let t;
1620
+ return i == "XY" ? t = 2 : i == "XYZ" || i == "XYM" ? t = 3 : i == "XYZM" && (t = 4), /** @type {number} */
1621
+ t;
1622
+ }
1623
+ function we(i, t, e, n) {
1624
+ let s = 0;
1625
+ const r = i[e - n], o = i[e - n + 1];
1626
+ let a = 0, l = 0;
1627
+ for (; t < e; t += n) {
1628
+ const h = i[t] - r, u = i[t + 1] - o;
1629
+ s += l * h - a * u, a = h, l = u;
1630
+ }
1631
+ return s / 2;
1632
+ }
1633
+ function si(i, t, e, n) {
1634
+ let s = 0;
1635
+ for (let r = 0, o = e.length; r < o; ++r) {
1636
+ const a = e[r];
1637
+ s += we(i, t, a, n), t = a;
1638
+ }
1639
+ return s;
1640
+ }
1641
+ function ee(i, t, e, n, s, r, o) {
1642
+ const a = i[t], l = i[t + 1], h = i[e] - a, u = i[e + 1] - l;
1643
+ let c;
1644
+ if (h === 0 && u === 0)
1645
+ c = t;
1646
+ else {
1647
+ const f = ((s - a) * h + (r - l) * u) / (h * h + u * u);
1648
+ if (f > 1)
1649
+ c = e;
1650
+ else if (f > 0) {
1651
+ for (let g = 0; g < n; ++g)
1652
+ o[g] = dn(
1653
+ i[t + g],
1654
+ i[e + g],
1655
+ f
1656
+ );
1657
+ o.length = n;
1658
+ return;
1659
+ } else
1660
+ c = t;
1661
+ }
1662
+ for (let f = 0; f < n; ++f)
1663
+ o[f] = i[c + f];
1664
+ o.length = n;
1665
+ }
1666
+ function Se(i, t, e, n, s) {
1667
+ let r = i[t], o = i[t + 1];
1668
+ for (t += n; t < e; t += n) {
1669
+ const a = i[t], l = i[t + 1], h = U(r, o, a, l);
1670
+ h > s && (s = h), r = a, o = l;
1671
+ }
1672
+ return s;
1673
+ }
1674
+ function ri(i, t, e, n, s) {
1675
+ for (let r = 0, o = e.length; r < o; ++r) {
1676
+ const a = e[r];
1677
+ s = Se(i, t, a, n, s), t = a;
1678
+ }
1679
+ return s;
1680
+ }
1681
+ function Ae(i, t, e, n, s, r, o, a, l, h, u) {
1682
+ if (t == e)
1683
+ return h;
1684
+ let c, f;
1685
+ if (s === 0) {
1686
+ if (f = U(
1687
+ o,
1688
+ a,
1689
+ i[t],
1690
+ i[t + 1]
1691
+ ), f < h) {
1692
+ for (c = 0; c < n; ++c)
1693
+ l[c] = i[t + c];
1694
+ return l.length = n, f;
1695
+ }
1696
+ return h;
1697
+ }
1698
+ u = u || [NaN, NaN];
1699
+ let g = t + n;
1700
+ for (; g < e; )
1701
+ if (ee(
1702
+ i,
1703
+ g - n,
1704
+ g,
1705
+ n,
1706
+ o,
1707
+ a,
1708
+ u
1709
+ ), f = U(o, a, u[0], u[1]), f < h) {
1710
+ for (h = f, c = 0; c < n; ++c)
1711
+ l[c] = u[c];
1712
+ l.length = n, g += n;
1713
+ } else
1714
+ g += n * Math.max(
1715
+ (Math.sqrt(f) - Math.sqrt(h)) / s | 0,
1716
+ 1
1717
+ );
1718
+ if (ee(
1719
+ i,
1720
+ e - n,
1721
+ t,
1722
+ n,
1723
+ o,
1724
+ a,
1725
+ u
1726
+ ), f = U(o, a, u[0], u[1]), f < h) {
1727
+ for (h = f, c = 0; c < n; ++c)
1728
+ l[c] = u[c];
1729
+ l.length = n;
1730
+ }
1731
+ return h;
1732
+ }
1733
+ function oi(i, t, e, n, s, r, o, a, l, h, u) {
1734
+ u = u || [NaN, NaN];
1735
+ for (let c = 0, f = e.length; c < f; ++c) {
1736
+ const g = e[c];
1737
+ h = Ae(
1738
+ i,
1739
+ t,
1740
+ g,
1741
+ n,
1742
+ s,
1743
+ r,
1744
+ o,
1745
+ a,
1746
+ l,
1747
+ h,
1748
+ u
1749
+ ), t = g;
1750
+ }
1751
+ return h;
1752
+ }
1753
+ function ai(i, t, e, n) {
1754
+ for (let s = 0, r = e.length; s < r; ++s)
1755
+ i[t++] = e[s];
1756
+ return t;
1757
+ }
1758
+ function ve(i, t, e, n) {
1759
+ for (let s = 0, r = e.length; s < r; ++s) {
1760
+ const o = e[s];
1761
+ for (let a = 0; a < n; ++a)
1762
+ i[t++] = o[a];
1763
+ }
1764
+ return t;
1765
+ }
1766
+ function li(i, t, e, n, s) {
1767
+ s = s || [];
1768
+ let r = 0;
1769
+ for (let o = 0, a = e.length; o < a; ++o) {
1770
+ const l = ve(
1771
+ i,
1772
+ t,
1773
+ e[o],
1774
+ n
1775
+ );
1776
+ s[r++] = l, t = l;
1777
+ }
1778
+ return s.length = r, s;
1779
+ }
1780
+ function Pe(i, t, e, n, s) {
1781
+ s = s !== void 0 ? s : [];
1782
+ let r = 0;
1783
+ for (let o = t; o < e; o += n)
1784
+ s[r++] = i.slice(o, o + n);
1785
+ return s.length = r, s;
1786
+ }
1787
+ function ui(i, t, e, n, s) {
1788
+ s = s !== void 0 ? s : [];
1789
+ let r = 0;
1790
+ for (let o = 0, a = e.length; o < a; ++o) {
1791
+ const l = e[o];
1792
+ s[r++] = Pe(
1793
+ i,
1794
+ t,
1795
+ l,
1796
+ n,
1797
+ s[r]
1798
+ ), t = l;
1799
+ }
1800
+ return s.length = r, s;
1801
+ }
1802
+ function hi(i, t, e, n, s, r, o) {
1803
+ const a = (e - t) / n;
1804
+ if (a < 3) {
1805
+ for (; t < e; t += n)
1806
+ r[o++] = i[t], r[o++] = i[t + 1];
1807
+ return o;
1808
+ }
1809
+ const l = new Array(a);
1810
+ l[0] = 1, l[a - 1] = 1;
1811
+ const h = [t, e - n];
1812
+ let u = 0;
1813
+ for (; h.length > 0; ) {
1814
+ const c = h.pop(), f = h.pop();
1815
+ let g = 0;
1816
+ const d = i[f], m = i[f + 1], _ = i[c], x = i[c + 1];
1817
+ for (let R = f + n; R < c; R += n) {
1818
+ const w = i[R], C = i[R + 1], F = gn(w, C, d, m, _, x);
1819
+ F > g && (u = R, g = F);
1820
+ }
1821
+ g > s && (l[(u - t) / n] = 1, f + n < u && h.push(f, u), u + n < c && h.push(u, c));
1822
+ }
1823
+ for (let c = 0; c < a; ++c)
1824
+ l[c] && (r[o++] = i[t + c * n], r[o++] = i[t + c * n + 1]);
1825
+ return o;
1826
+ }
1827
+ function G(i, t) {
1828
+ return t * Math.round(i / t);
1829
+ }
1830
+ function ci(i, t, e, n, s, r, o) {
1831
+ if (t == e)
1832
+ return o;
1833
+ let a = G(i[t], s), l = G(i[t + 1], s);
1834
+ t += n, r[o++] = a, r[o++] = l;
1835
+ let h, u;
1836
+ do
1837
+ if (h = G(i[t], s), u = G(i[t + 1], s), t += n, t == e)
1838
+ return r[o++] = h, r[o++] = u, o;
1839
+ while (h == a && u == l);
1840
+ for (; t < e; ) {
1841
+ const c = G(i[t], s), f = G(i[t + 1], s);
1842
+ if (t += n, c == h && f == u)
1843
+ continue;
1844
+ const g = h - a, d = u - l, m = c - a, _ = f - l;
1845
+ if (g * _ == d * m && (g < 0 && m < g || g == m || g > 0 && m > g) && (d < 0 && _ < d || d == _ || d > 0 && _ > d)) {
1846
+ h = c, u = f;
1847
+ continue;
1848
+ }
1849
+ r[o++] = h, r[o++] = u, a = h, l = u, h = c, u = f;
1850
+ }
1851
+ return r[o++] = h, r[o++] = u, o;
1852
+ }
1853
+ function fi(i, t, e, n, s, r, o, a) {
1854
+ for (let l = 0, h = e.length; l < h; ++l) {
1855
+ const u = e[l];
1856
+ o = ci(
1857
+ i,
1858
+ t,
1859
+ u,
1860
+ n,
1861
+ s,
1862
+ r,
1863
+ o
1864
+ ), a.push(o), t = u;
1865
+ }
1866
+ return o;
1867
+ }
1868
+ class q extends Pt {
1869
+ /**
1870
+ * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
1871
+ * For internal use, flat coordinates in combination with `layout` are also accepted.
1872
+ * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
1873
+ */
1874
+ constructor(t, e) {
1875
+ super(), this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, e !== void 0 && !Array.isArray(t[0]) ? this.setFlatCoordinates(
1876
+ e,
1877
+ /** @type {Array<number>} */
1878
+ t
1879
+ ) : this.setCoordinates(
1880
+ /** @type {Array<import("../coordinate.js").Coordinate>} */
1881
+ t,
1882
+ e
1883
+ );
1884
+ }
1885
+ /**
1886
+ * Make a complete copy of the geometry.
1887
+ * @return {!LinearRing} Clone.
1888
+ * @api
1889
+ * @override
1890
+ */
1891
+ clone() {
1892
+ return new q(this.flatCoordinates.slice(), this.layout);
1893
+ }
1894
+ /**
1895
+ * @param {number} x X.
1896
+ * @param {number} y Y.
1897
+ * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
1898
+ * @param {number} minSquaredDistance Minimum squared distance.
1899
+ * @return {number} Minimum squared distance.
1900
+ * @override
1901
+ */
1902
+ closestPointXY(t, e, n, s) {
1903
+ return s < fe(this.getExtent(), t, e) ? s : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt(
1904
+ Se(
1905
+ this.flatCoordinates,
1906
+ 0,
1907
+ this.flatCoordinates.length,
1908
+ this.stride,
1909
+ 0
1910
+ )
1911
+ ), this.maxDeltaRevision_ = this.getRevision()), Ae(
1912
+ this.flatCoordinates,
1913
+ 0,
1914
+ this.flatCoordinates.length,
1915
+ this.stride,
1916
+ this.maxDelta_,
1917
+ !0,
1918
+ t,
1919
+ e,
1920
+ n,
1921
+ s
1922
+ ));
1923
+ }
1924
+ /**
1925
+ * Return the area of the linear ring on projected plane.
1926
+ * @return {number} Area (on projected plane).
1927
+ * @api
1928
+ */
1929
+ getArea() {
1930
+ return we(
1931
+ this.flatCoordinates,
1932
+ 0,
1933
+ this.flatCoordinates.length,
1934
+ this.stride
1935
+ );
1936
+ }
1937
+ /**
1938
+ * Return the coordinates of the linear ring.
1939
+ * @return {Array<import("../coordinate.js").Coordinate>} Coordinates.
1940
+ * @api
1941
+ * @override
1942
+ */
1943
+ getCoordinates() {
1944
+ return Pe(
1945
+ this.flatCoordinates,
1946
+ 0,
1947
+ this.flatCoordinates.length,
1948
+ this.stride
1949
+ );
1950
+ }
1951
+ /**
1952
+ * @param {number} squaredTolerance Squared tolerance.
1953
+ * @return {LinearRing} Simplified LinearRing.
1954
+ * @protected
1955
+ * @override
1956
+ */
1957
+ getSimplifiedGeometryInternal(t) {
1958
+ const e = [];
1959
+ return e.length = hi(
1960
+ this.flatCoordinates,
1961
+ 0,
1962
+ this.flatCoordinates.length,
1963
+ this.stride,
1964
+ t,
1965
+ e,
1966
+ 0
1967
+ ), new q(e, "XY");
1968
+ }
1969
+ /**
1970
+ * Get the type of this geometry.
1971
+ * @return {import("./Geometry.js").Type} Geometry type.
1972
+ * @api
1973
+ * @override
1974
+ */
1975
+ getType() {
1976
+ return "LinearRing";
1977
+ }
1978
+ /**
1979
+ * Test if the geometry and the passed extent intersect.
1980
+ * @param {import("../extent.js").Extent} extent Extent.
1981
+ * @return {boolean} `true` if the geometry and the extent intersect.
1982
+ * @api
1983
+ * @override
1984
+ */
1985
+ intersectsExtent(t) {
1986
+ return !1;
1987
+ }
1988
+ /**
1989
+ * Set the coordinates of the linear ring.
1990
+ * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
1991
+ * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
1992
+ * @api
1993
+ * @override
1994
+ */
1995
+ setCoordinates(t, e) {
1996
+ this.setLayout(e, t, 1), this.flatCoordinates || (this.flatCoordinates = []), this.flatCoordinates.length = ve(
1997
+ this.flatCoordinates,
1998
+ 0,
1999
+ t,
2000
+ this.stride
2001
+ ), this.changed();
2002
+ }
2003
+ }
2004
+ class Ft extends Pt {
2005
+ /**
2006
+ * @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
2007
+ * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
2008
+ */
2009
+ constructor(t, e) {
2010
+ super(), this.setCoordinates(t, e);
2011
+ }
2012
+ /**
2013
+ * Make a complete copy of the geometry.
2014
+ * @return {!Point} Clone.
2015
+ * @api
2016
+ * @override
2017
+ */
2018
+ clone() {
2019
+ const t = new Ft(this.flatCoordinates.slice(), this.layout);
2020
+ return t.applyProperties(this), t;
2021
+ }
2022
+ /**
2023
+ * @param {number} x X.
2024
+ * @param {number} y Y.
2025
+ * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
2026
+ * @param {number} minSquaredDistance Minimum squared distance.
2027
+ * @return {number} Minimum squared distance.
2028
+ * @override
2029
+ */
2030
+ closestPointXY(t, e, n, s) {
2031
+ const r = this.flatCoordinates, o = U(
2032
+ t,
2033
+ e,
2034
+ r[0],
2035
+ r[1]
2036
+ );
2037
+ if (o < s) {
2038
+ const a = this.stride;
2039
+ for (let l = 0; l < a; ++l)
2040
+ n[l] = r[l];
2041
+ return n.length = a, o;
2042
+ }
2043
+ return s;
2044
+ }
2045
+ /**
2046
+ * Return the coordinate of the point.
2047
+ * @return {import("../coordinate.js").Coordinate} Coordinates.
2048
+ * @api
2049
+ * @override
2050
+ */
2051
+ getCoordinates() {
2052
+ return this.flatCoordinates.slice();
2053
+ }
2054
+ /**
2055
+ * @param {import("../extent.js").Extent} extent Extent.
2056
+ * @protected
2057
+ * @return {import("../extent.js").Extent} extent Extent.
2058
+ * @override
2059
+ */
2060
+ computeExtent(t) {
2061
+ return tn(this.flatCoordinates, t);
2062
+ }
2063
+ /**
2064
+ * Get the type of this geometry.
2065
+ * @return {import("./Geometry.js").Type} Geometry type.
2066
+ * @api
2067
+ * @override
2068
+ */
2069
+ getType() {
2070
+ return "Point";
2071
+ }
2072
+ /**
2073
+ * Test if the geometry and the passed extent intersect.
2074
+ * @param {import("../extent.js").Extent} extent Extent.
2075
+ * @return {boolean} `true` if the geometry and the extent intersect.
2076
+ * @api
2077
+ * @override
2078
+ */
2079
+ intersectsExtent(t) {
2080
+ return Qe(t, this.flatCoordinates[0], this.flatCoordinates[1]);
2081
+ }
2082
+ /**
2083
+ * @param {!Array<*>} coordinates Coordinates.
2084
+ * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
2085
+ * @api
2086
+ * @override
2087
+ */
2088
+ setCoordinates(t, e) {
2089
+ this.setLayout(e, t, 0), this.flatCoordinates || (this.flatCoordinates = []), this.flatCoordinates.length = ai(
2090
+ this.flatCoordinates,
2091
+ 0,
2092
+ t,
2093
+ this.stride
2094
+ ), this.changed();
2095
+ }
2096
+ }
2097
+ function gi(i, t, e, n, s) {
2098
+ return !sn(
2099
+ s,
2100
+ /**
2101
+ * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
2102
+ * @return {boolean} Contains (x, y).
2103
+ */
2104
+ function(o) {
2105
+ return !Y(
2106
+ i,
2107
+ t,
2108
+ e,
2109
+ n,
2110
+ o[0],
2111
+ o[1]
2112
+ );
2113
+ }
2114
+ );
2115
+ }
2116
+ function Y(i, t, e, n, s, r) {
2117
+ let o = 0, a = i[e - n], l = i[e - n + 1];
2118
+ for (; t < e; t += n) {
2119
+ const h = i[t], u = i[t + 1];
2120
+ l <= r ? u > r && (h - a) * (r - l) - (s - a) * (u - l) > 0 && o++ : u <= r && (h - a) * (r - l) - (s - a) * (u - l) < 0 && o--, a = h, l = u;
2121
+ }
2122
+ return o !== 0;
2123
+ }
2124
+ function Fe(i, t, e, n, s, r) {
2125
+ if (e.length === 0 || !Y(i, t, e[0], n, s, r))
2126
+ return !1;
2127
+ for (let o = 1, a = e.length; o < a; ++o)
2128
+ if (Y(i, e[o - 1], e[o], n, s, r))
2129
+ return !1;
2130
+ return !0;
2131
+ }
2132
+ function di(i, t, e, n, s, r, o) {
2133
+ let a, l, h, u, c, f, g;
2134
+ const d = s[r + 1], m = [];
2135
+ for (let R = 0, w = e.length; R < w; ++R) {
2136
+ const C = e[R];
2137
+ for (u = i[C - n], f = i[C - n + 1], a = t; a < C; a += n)
2138
+ c = i[a], g = i[a + 1], (d <= f && g <= d || f <= d && d <= g) && (h = (d - f) / (g - f) * (c - u) + u, m.push(h)), u = c, f = g;
2139
+ }
2140
+ let _ = NaN, x = -1 / 0;
2141
+ for (m.sort(le), u = m[0], a = 1, l = m.length; a < l; ++a) {
2142
+ c = m[a];
2143
+ const R = Math.abs(c - u);
2144
+ R > x && (h = (u + c) / 2, Fe(i, t, e, n, h, d) && (_ = h, x = R)), u = c;
2145
+ }
2146
+ return isNaN(_) && (_ = s[r]), [_, d, x];
2147
+ }
2148
+ function mi(i, t, e, n, s) {
2149
+ let r;
2150
+ for (t += n; t < e; t += n)
2151
+ if (r = s(
2152
+ i.slice(t - n, t),
2153
+ i.slice(t, t + n)
2154
+ ), r)
2155
+ return r;
2156
+ return !1;
2157
+ }
2158
+ function Xe(i, t, e, n, s, r) {
2159
+ return r = r ?? me(ge(), i, t, e, n), hn(s, r) ? r[0] >= s[0] && r[2] <= s[2] || r[1] >= s[1] && r[3] <= s[3] ? !0 : mi(
2160
+ i,
2161
+ t,
2162
+ e,
2163
+ n,
2164
+ /**
2165
+ * @param {import("../../coordinate.js").Coordinate} point1 Start point.
2166
+ * @param {import("../../coordinate.js").Coordinate} point2 End point.
2167
+ * @return {boolean} `true` if the segment and the extent intersect,
2168
+ * `false` otherwise.
2169
+ */
2170
+ function(o, a) {
2171
+ return fn(s, o, a);
2172
+ }
2173
+ ) : !1;
2174
+ }
2175
+ function Ne(i, t, e, n, s) {
2176
+ return !!(Xe(i, t, e, n, s) || Y(
2177
+ i,
2178
+ t,
2179
+ e,
2180
+ n,
2181
+ s[0],
2182
+ s[1]
2183
+ ) || Y(
2184
+ i,
2185
+ t,
2186
+ e,
2187
+ n,
2188
+ s[0],
2189
+ s[3]
2190
+ ) || Y(
2191
+ i,
2192
+ t,
2193
+ e,
2194
+ n,
2195
+ s[2],
2196
+ s[1]
2197
+ ) || Y(
2198
+ i,
2199
+ t,
2200
+ e,
2201
+ n,
2202
+ s[2],
2203
+ s[3]
2204
+ ));
2205
+ }
2206
+ function _i(i, t, e, n, s) {
2207
+ if (!Ne(i, t, e[0], n, s))
2208
+ return !1;
2209
+ if (e.length === 1)
2210
+ return !0;
2211
+ for (let r = 1, o = e.length; r < o; ++r)
2212
+ if (gi(
2213
+ i,
2214
+ e[r - 1],
2215
+ e[r],
2216
+ n,
2217
+ s
2218
+ ) && !Xe(
2219
+ i,
2220
+ e[r - 1],
2221
+ e[r],
2222
+ n,
2223
+ s
2224
+ ))
2225
+ return !1;
2226
+ return !0;
2227
+ }
2228
+ function Ri(i, t, e, n) {
2229
+ for (; t < e - n; ) {
2230
+ for (let s = 0; s < n; ++s) {
2231
+ const r = i[t + s];
2232
+ i[t + s] = i[e - n + s], i[e - n + s] = r;
2233
+ }
2234
+ t += n, e -= n;
2235
+ }
2236
+ }
2237
+ function Ye(i, t, e, n) {
2238
+ let s = 0, r = i[e - n], o = i[e - n + 1];
2239
+ for (; t < e; t += n) {
2240
+ const a = i[t], l = i[t + 1];
2241
+ s += (a - r) * (l + o), r = a, o = l;
2242
+ }
2243
+ return s === 0 ? void 0 : s > 0;
2244
+ }
2245
+ function xi(i, t, e, n, s) {
2246
+ s = s !== void 0 ? s : !1;
2247
+ for (let r = 0, o = e.length; r < o; ++r) {
2248
+ const a = e[r], l = Ye(
2249
+ i,
2250
+ t,
2251
+ a,
2252
+ n
2253
+ );
2254
+ if (r === 0) {
2255
+ if (s && l || !s && !l)
2256
+ return !1;
2257
+ } else if (s && !l || !s && l)
2258
+ return !1;
2259
+ t = a;
2260
+ }
2261
+ return !0;
2262
+ }
2263
+ function ne(i, t, e, n, s) {
2264
+ s = s !== void 0 ? s : !1;
2265
+ for (let r = 0, o = e.length; r < o; ++r) {
2266
+ const a = e[r], l = Ye(
2267
+ i,
2268
+ t,
2269
+ a,
2270
+ n
2271
+ );
2272
+ (r === 0 ? s && l || !s && !l : s && !l || !s && l) && Ri(i, t, a, n), t = a;
2273
+ }
2274
+ return t;
2275
+ }
2276
+ class ht extends Pt {
2277
+ /**
2278
+ * @param {!Array<Array<import("../coordinate.js").Coordinate>>|!Array<number>} coordinates
2279
+ * Array of linear rings that define the polygon. The first linear ring of the
2280
+ * array defines the outer-boundary or surface of the polygon. Each subsequent
2281
+ * linear ring defines a hole in the surface of the polygon. A linear ring is
2282
+ * an array of vertices' coordinates where the first coordinate and the last are
2283
+ * equivalent. (For internal use, flat coordinates in combination with
2284
+ * `layout` and `ends` are also accepted.)
2285
+ * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
2286
+ * @param {Array<number>} [ends] Ends (for internal use with flat coordinates).
2287
+ */
2288
+ constructor(t, e, n) {
2289
+ super(), this.ends_ = [], this.flatInteriorPointRevision_ = -1, this.flatInteriorPoint_ = null, this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, this.orientedRevision_ = -1, this.orientedFlatCoordinates_ = null, e !== void 0 && n ? (this.setFlatCoordinates(
2290
+ e,
2291
+ /** @type {Array<number>} */
2292
+ t
2293
+ ), this.ends_ = n) : this.setCoordinates(
2294
+ /** @type {Array<Array<import("../coordinate.js").Coordinate>>} */
2295
+ t,
2296
+ e
2297
+ );
2298
+ }
2299
+ /**
2300
+ * Append the passed linear ring to this polygon.
2301
+ * @param {LinearRing} linearRing Linear ring.
2302
+ * @api
2303
+ */
2304
+ appendLinearRing(t) {
2305
+ this.flatCoordinates ? Ve(this.flatCoordinates, t.getFlatCoordinates()) : this.flatCoordinates = t.getFlatCoordinates().slice(), this.ends_.push(this.flatCoordinates.length), this.changed();
2306
+ }
2307
+ /**
2308
+ * Make a complete copy of the geometry.
2309
+ * @return {!Polygon} Clone.
2310
+ * @api
2311
+ * @override
2312
+ */
2313
+ clone() {
2314
+ const t = new ht(
2315
+ this.flatCoordinates.slice(),
2316
+ this.layout,
2317
+ this.ends_.slice()
2318
+ );
2319
+ return t.applyProperties(this), t;
2320
+ }
2321
+ /**
2322
+ * @param {number} x X.
2323
+ * @param {number} y Y.
2324
+ * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
2325
+ * @param {number} minSquaredDistance Minimum squared distance.
2326
+ * @return {number} Minimum squared distance.
2327
+ * @override
2328
+ */
2329
+ closestPointXY(t, e, n, s) {
2330
+ return s < fe(this.getExtent(), t, e) ? s : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt(
2331
+ ri(
2332
+ this.flatCoordinates,
2333
+ 0,
2334
+ this.ends_,
2335
+ this.stride,
2336
+ 0
2337
+ )
2338
+ ), this.maxDeltaRevision_ = this.getRevision()), oi(
2339
+ this.flatCoordinates,
2340
+ 0,
2341
+ this.ends_,
2342
+ this.stride,
2343
+ this.maxDelta_,
2344
+ !0,
2345
+ t,
2346
+ e,
2347
+ n,
2348
+ s
2349
+ ));
2350
+ }
2351
+ /**
2352
+ * @param {number} x X.
2353
+ * @param {number} y Y.
2354
+ * @return {boolean} Contains (x, y).
2355
+ * @override
2356
+ */
2357
+ containsXY(t, e) {
2358
+ return Fe(
2359
+ this.getOrientedFlatCoordinates(),
2360
+ 0,
2361
+ this.ends_,
2362
+ this.stride,
2363
+ t,
2364
+ e
2365
+ );
2366
+ }
2367
+ /**
2368
+ * Return the area of the polygon on projected plane.
2369
+ * @return {number} Area (on projected plane).
2370
+ * @api
2371
+ */
2372
+ getArea() {
2373
+ return si(
2374
+ this.getOrientedFlatCoordinates(),
2375
+ 0,
2376
+ this.ends_,
2377
+ this.stride
2378
+ );
2379
+ }
2380
+ /**
2381
+ * Get the coordinate array for this geometry. This array has the structure
2382
+ * of a GeoJSON coordinate array for polygons.
2383
+ *
2384
+ * @param {boolean} [right] Orient coordinates according to the right-hand
2385
+ * rule (counter-clockwise for exterior and clockwise for interior rings).
2386
+ * If `false`, coordinates will be oriented according to the left-hand rule
2387
+ * (clockwise for exterior and counter-clockwise for interior rings).
2388
+ * By default, coordinate orientation will depend on how the geometry was
2389
+ * constructed.
2390
+ * @return {Array<Array<import("../coordinate.js").Coordinate>>} Coordinates.
2391
+ * @api
2392
+ * @override
2393
+ */
2394
+ getCoordinates(t) {
2395
+ let e;
2396
+ return t !== void 0 ? (e = this.getOrientedFlatCoordinates().slice(), ne(e, 0, this.ends_, this.stride, t)) : e = this.flatCoordinates, ui(e, 0, this.ends_, this.stride);
2397
+ }
2398
+ /**
2399
+ * @return {Array<number>} Ends.
2400
+ */
2401
+ getEnds() {
2402
+ return this.ends_;
2403
+ }
2404
+ /**
2405
+ * @return {Array<number>} Interior point.
2406
+ */
2407
+ getFlatInteriorPoint() {
2408
+ if (this.flatInteriorPointRevision_ != this.getRevision()) {
2409
+ const t = rt(this.getExtent());
2410
+ this.flatInteriorPoint_ = di(
2411
+ this.getOrientedFlatCoordinates(),
2412
+ 0,
2413
+ this.ends_,
2414
+ this.stride,
2415
+ t,
2416
+ 0
2417
+ ), this.flatInteriorPointRevision_ = this.getRevision();
2418
+ }
2419
+ return (
2420
+ /** @type {import("../coordinate.js").Coordinate} */
2421
+ this.flatInteriorPoint_
2422
+ );
2423
+ }
2424
+ /**
2425
+ * Return an interior point of the polygon.
2426
+ * @return {Point} Interior point as XYM coordinate, where M is the
2427
+ * length of the horizontal intersection that the point belongs to.
2428
+ * @api
2429
+ */
2430
+ getInteriorPoint() {
2431
+ return new Ft(this.getFlatInteriorPoint(), "XYM");
2432
+ }
2433
+ /**
2434
+ * Return the number of rings of the polygon, this includes the exterior
2435
+ * ring and any interior rings.
2436
+ *
2437
+ * @return {number} Number of rings.
2438
+ * @api
2439
+ */
2440
+ getLinearRingCount() {
2441
+ return this.ends_.length;
2442
+ }
2443
+ /**
2444
+ * Return the Nth linear ring of the polygon geometry. Return `null` if the
2445
+ * given index is out of range.
2446
+ * The exterior linear ring is available at index `0` and the interior rings
2447
+ * at index `1` and beyond.
2448
+ *
2449
+ * @param {number} index Index.
2450
+ * @return {LinearRing|null} Linear ring.
2451
+ * @api
2452
+ */
2453
+ getLinearRing(t) {
2454
+ return t < 0 || this.ends_.length <= t ? null : new q(
2455
+ this.flatCoordinates.slice(
2456
+ t === 0 ? 0 : this.ends_[t - 1],
2457
+ this.ends_[t]
2458
+ ),
2459
+ this.layout
2460
+ );
2461
+ }
2462
+ /**
2463
+ * Return the linear rings of the polygon.
2464
+ * @return {Array<LinearRing>} Linear rings.
2465
+ * @api
2466
+ */
2467
+ getLinearRings() {
2468
+ const t = this.layout, e = this.flatCoordinates, n = this.ends_, s = [];
2469
+ let r = 0;
2470
+ for (let o = 0, a = n.length; o < a; ++o) {
2471
+ const l = n[o], h = new q(
2472
+ e.slice(r, l),
2473
+ t
2474
+ );
2475
+ s.push(h), r = l;
2476
+ }
2477
+ return s;
2478
+ }
2479
+ /**
2480
+ * @return {Array<number>} Oriented flat coordinates.
2481
+ */
2482
+ getOrientedFlatCoordinates() {
2483
+ if (this.orientedRevision_ != this.getRevision()) {
2484
+ const t = this.flatCoordinates;
2485
+ xi(t, 0, this.ends_, this.stride) ? this.orientedFlatCoordinates_ = t : (this.orientedFlatCoordinates_ = t.slice(), this.orientedFlatCoordinates_.length = ne(
2486
+ this.orientedFlatCoordinates_,
2487
+ 0,
2488
+ this.ends_,
2489
+ this.stride
2490
+ )), this.orientedRevision_ = this.getRevision();
2491
+ }
2492
+ return (
2493
+ /** @type {Array<number>} */
2494
+ this.orientedFlatCoordinates_
2495
+ );
2496
+ }
2497
+ /**
2498
+ * @param {number} squaredTolerance Squared tolerance.
2499
+ * @return {Polygon} Simplified Polygon.
2500
+ * @protected
2501
+ * @override
2502
+ */
2503
+ getSimplifiedGeometryInternal(t) {
2504
+ const e = [], n = [];
2505
+ return e.length = fi(
2506
+ this.flatCoordinates,
2507
+ 0,
2508
+ this.ends_,
2509
+ this.stride,
2510
+ Math.sqrt(t),
2511
+ e,
2512
+ 0,
2513
+ n
2514
+ ), new ht(e, "XY", n);
2515
+ }
2516
+ /**
2517
+ * Get the type of this geometry.
2518
+ * @return {import("./Geometry.js").Type} Geometry type.
2519
+ * @api
2520
+ * @override
2521
+ */
2522
+ getType() {
2523
+ return "Polygon";
2524
+ }
2525
+ /**
2526
+ * Test if the geometry and the passed extent intersect.
2527
+ * @param {import("../extent.js").Extent} extent Extent.
2528
+ * @return {boolean} `true` if the geometry and the extent intersect.
2529
+ * @api
2530
+ * @override
2531
+ */
2532
+ intersectsExtent(t) {
2533
+ return _i(
2534
+ this.getOrientedFlatCoordinates(),
2535
+ 0,
2536
+ this.ends_,
2537
+ this.stride,
2538
+ t
2539
+ );
2540
+ }
2541
+ /**
2542
+ * Set the coordinates of the polygon.
2543
+ * @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates.
2544
+ * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
2545
+ * @api
2546
+ * @override
2547
+ */
2548
+ setCoordinates(t, e) {
2549
+ this.setLayout(e, t, 2), this.flatCoordinates || (this.flatCoordinates = []);
2550
+ const n = li(
2551
+ this.flatCoordinates,
2552
+ 0,
2553
+ t,
2554
+ this.stride,
2555
+ this.ends_
2556
+ );
2557
+ this.flatCoordinates.length = n.length === 0 ? 0 : n[n.length - 1], this.changed();
2558
+ }
2559
+ }
2560
+ function ie(i) {
2561
+ if (Re(i))
2562
+ throw new Error("Cannot create polygon from empty extent");
2563
+ const t = i[0], e = i[1], n = i[2], s = i[3], r = [
2564
+ t,
2565
+ e,
2566
+ t,
2567
+ s,
2568
+ n,
2569
+ s,
2570
+ n,
2571
+ e,
2572
+ t,
2573
+ e
2574
+ ];
2575
+ return new ht(r, "XY", [r.length]);
2576
+ }
2577
+ function et(i, t) {
2578
+ return Array.isArray(i) ? i : (t === void 0 ? t = [i, i] : (t[0] = i, t[1] = i), t);
2579
+ }
2580
+ const A = {
2581
+ ANIMATING: 0,
2582
+ INTERACTING: 1
2583
+ }, I = {
2584
+ CENTER: "center",
2585
+ RESOLUTION: "resolution",
2586
+ ROTATION: "rotation"
2587
+ };
2588
+ function se(i, t, e) {
2589
+ return (
2590
+ /**
2591
+ * @param {import("./coordinate.js").Coordinate|undefined} center Center.
2592
+ * @param {number|undefined} resolution Resolution.
2593
+ * @param {import("./size.js").Size} size Viewport size; unused if `onlyCenter` was specified.
2594
+ * @param {boolean} [isMoving] True if an interaction or animation is in progress.
2595
+ * @param {Array<number>} [centerShift] Shift between map center and viewport center.
2596
+ * @return {import("./coordinate.js").Coordinate|undefined} Center.
2597
+ */
2598
+ function(n, s, r, o, a) {
2599
+ if (!n)
2600
+ return;
2601
+ if (!s && !t)
2602
+ return n;
2603
+ const l = t ? 0 : r[0] * s, h = t ? 0 : r[1] * s, u = a ? a[0] : 0, c = a ? a[1] : 0;
2604
+ let f = i[0] + l / 2 + u, g = i[2] - l / 2 + u, d = i[1] + h / 2 + c, m = i[3] - h / 2 + c;
2605
+ f > g && (f = (g + f) / 2, g = f), d > m && (d = (m + d) / 2, m = d);
2606
+ let _ = p(n[0], f, g), x = p(n[1], d, m);
2607
+ if (o && e && s) {
2608
+ const R = 30 * s;
2609
+ _ += -R * Math.log(1 + Math.max(0, f - n[0]) / R) + R * Math.log(1 + Math.max(0, n[0] - g) / R), x += -R * Math.log(1 + Math.max(0, d - n[1]) / R) + R * Math.log(1 + Math.max(0, n[1] - m) / R);
2610
+ }
2611
+ return [_, x];
2612
+ }
2613
+ );
2614
+ }
2615
+ function Mi(i) {
2616
+ return i;
2617
+ }
2618
+ function Ci(i) {
2619
+ return Math.pow(i, 3);
2620
+ }
2621
+ function Ei(i) {
2622
+ return 1 - Ci(1 - i);
2623
+ }
2624
+ function Ti(i) {
2625
+ return 3 * i * i - 2 * i * i * i;
2626
+ }
2627
+ function Xt(i, t, e, n) {
2628
+ const s = D(t) / e[0], r = k(t) / e[1];
2629
+ return n ? Math.min(i, Math.max(s, r)) : Math.min(i, Math.min(s, r));
2630
+ }
2631
+ function Nt(i, t, e) {
2632
+ let n = Math.min(i, t);
2633
+ const s = 50;
2634
+ return n *= Math.log(1 + s * Math.max(0, i / t - 1)) / s + 1, e && (n = Math.max(n, e), n /= Math.log(1 + s * Math.max(0, e / i - 1)) / s + 1), p(n, e / 2, t * 2);
2635
+ }
2636
+ function pi(i, t, e, n) {
2637
+ return t = t !== void 0 ? t : !0, /**
2638
+ * @param {number|undefined} resolution Resolution.
2639
+ * @param {number} direction Direction.
2640
+ * @param {import("./size.js").Size} size Viewport size.
2641
+ * @param {boolean} [isMoving] True if an interaction or animation is in progress.
2642
+ * @return {number|undefined} Resolution.
2643
+ */
2644
+ function(s, r, o, a) {
2645
+ if (s !== void 0) {
2646
+ const l = i[0], h = i[i.length - 1], u = e ? Xt(
2647
+ l,
2648
+ e,
2649
+ o,
2650
+ n
2651
+ ) : l;
2652
+ if (a)
2653
+ return t ? Nt(
2654
+ s,
2655
+ u,
2656
+ h
2657
+ ) : p(s, h, u);
2658
+ const c = Math.min(u, s), f = Math.floor(wt(i, c, r));
2659
+ return i[f] > u && f < i.length - 1 ? i[f + 1] : i[f];
2660
+ }
2661
+ };
2662
+ }
2663
+ function Ii(i, t, e, n, s, r) {
2664
+ return n = n !== void 0 ? n : !0, e = e !== void 0 ? e : 0, /**
2665
+ * @param {number|undefined} resolution Resolution.
2666
+ * @param {number} direction Direction.
2667
+ * @param {import("./size.js").Size} size Viewport size.
2668
+ * @param {boolean} [isMoving] True if an interaction or animation is in progress.
2669
+ * @return {number|undefined} Resolution.
2670
+ */
2671
+ function(o, a, l, h) {
2672
+ if (o !== void 0) {
2673
+ const u = s ? Xt(
2674
+ t,
2675
+ s,
2676
+ l,
2677
+ r
2678
+ ) : t;
2679
+ if (h)
2680
+ return n ? Nt(
2681
+ o,
2682
+ u,
2683
+ e
2684
+ ) : p(o, e, u);
2685
+ const c = 1e-9, f = Math.ceil(
2686
+ Math.log(t / u) / Math.log(i) - c
2687
+ ), g = -a * (0.5 - c) + 0.5, d = Math.min(u, o), m = Math.floor(
2688
+ Math.log(t / d) / Math.log(i) + g
2689
+ ), _ = Math.max(f, m), x = t / Math.pow(i, _);
2690
+ return p(x, e, u);
2691
+ }
2692
+ };
2693
+ }
2694
+ function re(i, t, e, n, s) {
2695
+ return e = e !== void 0 ? e : !0, /**
2696
+ * @param {number|undefined} resolution Resolution.
2697
+ * @param {number} direction Direction.
2698
+ * @param {import("./size.js").Size} size Viewport size.
2699
+ * @param {boolean} [isMoving] True if an interaction or animation is in progress.
2700
+ * @return {number|undefined} Resolution.
2701
+ */
2702
+ function(r, o, a, l) {
2703
+ if (r !== void 0) {
2704
+ const h = n ? Xt(
2705
+ i,
2706
+ n,
2707
+ a,
2708
+ s
2709
+ ) : i;
2710
+ return !e || !l ? p(r, t, h) : Nt(
2711
+ r,
2712
+ h,
2713
+ t
2714
+ );
2715
+ }
2716
+ };
2717
+ }
2718
+ function yi(i) {
2719
+ if (i !== void 0)
2720
+ return 0;
2721
+ }
2722
+ function oe(i) {
2723
+ if (i !== void 0)
2724
+ return i;
2725
+ }
2726
+ function wi(i) {
2727
+ const t = 2 * Math.PI / i;
2728
+ return (
2729
+ /**
2730
+ * @param {number|undefined} rotation Rotation.
2731
+ * @param {boolean} [isMoving] True if an interaction or animation is in progress.
2732
+ * @return {number|undefined} Rotation.
2733
+ */
2734
+ function(e, n) {
2735
+ if (n)
2736
+ return e;
2737
+ if (e !== void 0)
2738
+ return e = Math.floor(e / t + 0.5) * t, e;
2739
+ }
2740
+ );
2741
+ }
2742
+ function Si(i) {
2743
+ const t = H(5);
2744
+ return (
2745
+ /**
2746
+ * @param {number|undefined} rotation Rotation.
2747
+ * @param {boolean} [isMoving] True if an interaction or animation is in progress.
2748
+ * @return {number|undefined} Rotation.
2749
+ */
2750
+ function(e, n) {
2751
+ return n || e === void 0 ? e : Math.abs(e) <= t ? 0 : e;
2752
+ }
2753
+ );
2754
+ }
2755
+ const Ze = 256, xt = 0;
2756
+ class Ai extends ce {
2757
+ /**
2758
+ * @param {ViewOptions} [options] View options.
2759
+ */
2760
+ constructor(t) {
2761
+ super(), this.on, this.once, this.un, t = Object.assign({}, t), this.hints_ = [0, 0], this.animations_ = [], this.updateAnimationKey_, this.projection_ = vt(t.projection, "EPSG:3857"), this.viewportSize_ = [100, 100], this.targetCenter_ = null, this.targetResolution_, this.targetRotation_, this.nextCenter_ = null, this.nextResolution_, this.nextRotation_, this.cancelAnchor_ = void 0, t.projection && Un(), t.center && (t.center = S(t.center, this.projection_)), t.extent && (t.extent = tt(t.extent, this.projection_)), this.applyOptions_(t);
2762
+ }
2763
+ /**
2764
+ * Set up the view with the given options.
2765
+ * @param {ViewOptions} options View options.
2766
+ */
2767
+ applyOptions_(t) {
2768
+ const e = Object.assign({}, t);
2769
+ for (const a in I)
2770
+ delete e[a];
2771
+ this.setProperties(e, !0);
2772
+ const n = Pi(t);
2773
+ this.maxResolution_ = n.maxResolution, this.minResolution_ = n.minResolution, this.zoomFactor_ = n.zoomFactor, this.resolutions_ = t.resolutions, this.padding_ = t.padding, this.minZoom_ = n.minZoom;
2774
+ const s = vi(t), r = n.constraint, o = Fi(t);
2775
+ this.constraints_ = {
2776
+ center: s,
2777
+ resolution: r,
2778
+ rotation: o
2779
+ }, this.setRotation(t.rotation !== void 0 ? t.rotation : 0), this.setCenterInternal(
2780
+ t.center !== void 0 ? t.center : null
2781
+ ), t.resolution !== void 0 ? this.setResolution(t.resolution) : t.zoom !== void 0 && this.setZoom(t.zoom);
2782
+ }
2783
+ /**
2784
+ * Padding (in css pixels).
2785
+ * If the map viewport is partially covered with other content (overlays) along
2786
+ * its edges, this setting allows to shift the center of the viewport away from that
2787
+ * content. The order of the values in the array is top, right, bottom, left.
2788
+ * The default is no padding, which is equivalent to `[0, 0, 0, 0]`.
2789
+ * @type {Array<number>|undefined}
2790
+ * @api
2791
+ */
2792
+ get padding() {
2793
+ return this.padding_;
2794
+ }
2795
+ set padding(t) {
2796
+ let e = this.padding_;
2797
+ this.padding_ = t;
2798
+ const n = this.getCenterInternal();
2799
+ if (n) {
2800
+ const s = t || [0, 0, 0, 0];
2801
+ e = e || [0, 0, 0, 0];
2802
+ const r = this.getResolution(), o = r / 2 * (s[3] - e[3] + e[1] - s[1]), a = r / 2 * (s[0] - e[0] + e[2] - s[2]);
2803
+ this.setCenterInternal([n[0] + o, n[1] - a]);
2804
+ }
2805
+ }
2806
+ /**
2807
+ * Get an updated version of the view options used to construct the view. The
2808
+ * current resolution (or zoom), center, and rotation are applied to any stored
2809
+ * options. The provided options can be used to apply new min/max zoom or
2810
+ * resolution limits.
2811
+ * @param {ViewOptions} newOptions New options to be applied.
2812
+ * @return {ViewOptions} New options updated with the current view state.
2813
+ */
2814
+ getUpdatedOptions_(t) {
2815
+ const e = this.getProperties();
2816
+ return e.resolution !== void 0 ? e.resolution = this.getResolution() : e.zoom = this.getZoom(), e.center = this.getCenterInternal(), e.rotation = this.getRotation(), Object.assign({}, e, t);
2817
+ }
2818
+ /**
2819
+ * Animate the view. The view's center, zoom (or resolution), and rotation
2820
+ * can be animated for smooth transitions between view states. For example,
2821
+ * to animate the view to a new zoom level:
2822
+ *
2823
+ * view.animate({zoom: view.getZoom() + 1});
2824
+ *
2825
+ * By default, the animation lasts one second and uses in-and-out easing. You
2826
+ * can customize this behavior by including `duration` (in milliseconds) and
2827
+ * `easing` options (see {@link module:ol/easing}).
2828
+ *
2829
+ * To chain together multiple animations, call the method with multiple
2830
+ * animation objects. For example, to first zoom and then pan:
2831
+ *
2832
+ * view.animate({zoom: 10}, {center: [0, 0]});
2833
+ *
2834
+ * If you provide a function as the last argument to the animate method, it
2835
+ * will get called at the end of an animation series. The callback will be
2836
+ * called with `true` if the animation series completed on its own or `false`
2837
+ * if it was cancelled.
2838
+ *
2839
+ * Animations are cancelled by user interactions (e.g. dragging the map) or by
2840
+ * calling `view.setCenter()`, `view.setResolution()`, or `view.setRotation()`
2841
+ * (or another method that calls one of these).
2842
+ *
2843
+ * @param {...(AnimationOptions|function(boolean): void)} var_args Animation
2844
+ * options. Multiple animations can be run in series by passing multiple
2845
+ * options objects. To run multiple animations in parallel, call the method
2846
+ * multiple times. An optional callback can be provided as a final
2847
+ * argument. The callback will be called with a boolean indicating whether
2848
+ * the animation completed without being cancelled.
2849
+ * @api
2850
+ */
2851
+ animate(t) {
2852
+ this.isDef() && !this.getAnimating() && this.resolveConstraints(0);
2853
+ const e = new Array(arguments.length);
2854
+ for (let n = 0; n < e.length; ++n) {
2855
+ let s = arguments[n];
2856
+ s.center && (s = Object.assign({}, s), s.center = S(
2857
+ s.center,
2858
+ this.getProjection()
2859
+ )), s.anchor && (s = Object.assign({}, s), s.anchor = S(
2860
+ s.anchor,
2861
+ this.getProjection()
2862
+ )), e[n] = s;
2863
+ }
2864
+ this.animateInternal.apply(this, e);
2865
+ }
2866
+ /**
2867
+ * @param {...(AnimationOptions|function(boolean): void)} var_args Animation options.
2868
+ */
2869
+ animateInternal(t) {
2870
+ let e = arguments.length, n;
2871
+ e > 1 && typeof arguments[e - 1] == "function" && (n = arguments[e - 1], --e);
2872
+ let s = 0;
2873
+ for (; s < e && !this.isDef(); ++s) {
2874
+ const u = arguments[s];
2875
+ u.center && this.setCenterInternal(u.center), u.zoom !== void 0 ? this.setZoom(u.zoom) : u.resolution && this.setResolution(u.resolution), u.rotation !== void 0 && this.setRotation(u.rotation);
2876
+ }
2877
+ if (s === e) {
2878
+ n && nt(n, !0);
2879
+ return;
2880
+ }
2881
+ let r = Date.now(), o = this.targetCenter_.slice(), a = this.targetResolution_, l = this.targetRotation_;
2882
+ const h = [];
2883
+ for (; s < e; ++s) {
2884
+ const u = (
2885
+ /** @type {AnimationOptions} */
2886
+ arguments[s]
2887
+ ), c = {
2888
+ start: r,
2889
+ complete: !1,
2890
+ anchor: u.anchor,
2891
+ duration: u.duration !== void 0 ? u.duration : 1e3,
2892
+ easing: u.easing || Ti,
2893
+ callback: n
2894
+ };
2895
+ if (u.center && (c.sourceCenter = o, c.targetCenter = u.center.slice(), o = c.targetCenter), u.zoom !== void 0 ? (c.sourceResolution = a, c.targetResolution = this.getResolutionForZoom(u.zoom), a = c.targetResolution) : u.resolution && (c.sourceResolution = a, c.targetResolution = u.resolution, a = c.targetResolution), u.rotation !== void 0) {
2896
+ c.sourceRotation = l;
2897
+ const f = bt(u.rotation - l + Math.PI, 2 * Math.PI) - Math.PI;
2898
+ c.targetRotation = l + f, l = c.targetRotation;
2899
+ }
2900
+ Xi(c) ? c.complete = !0 : r += c.duration, h.push(c);
2901
+ }
2902
+ this.animations_.push(h), this.setHint(A.ANIMATING, 1), this.updateAnimations_();
2903
+ }
2904
+ /**
2905
+ * Determine if the view is being animated.
2906
+ * @return {boolean} The view is being animated.
2907
+ * @api
2908
+ */
2909
+ getAnimating() {
2910
+ return this.hints_[A.ANIMATING] > 0;
2911
+ }
2912
+ /**
2913
+ * Determine if the user is interacting with the view, such as panning or zooming.
2914
+ * @return {boolean} The view is being interacted with.
2915
+ * @api
2916
+ */
2917
+ getInteracting() {
2918
+ return this.hints_[A.INTERACTING] > 0;
2919
+ }
2920
+ /**
2921
+ * Cancel any ongoing animations.
2922
+ * @api
2923
+ */
2924
+ cancelAnimations() {
2925
+ this.setHint(A.ANIMATING, -this.hints_[A.ANIMATING]);
2926
+ let t;
2927
+ for (let e = 0, n = this.animations_.length; e < n; ++e) {
2928
+ const s = this.animations_[e];
2929
+ if (s[0].callback && nt(s[0].callback, !1), !t)
2930
+ for (let r = 0, o = s.length; r < o; ++r) {
2931
+ const a = s[r];
2932
+ if (!a.complete) {
2933
+ t = a.anchor;
2934
+ break;
2935
+ }
2936
+ }
2937
+ }
2938
+ this.animations_.length = 0, this.cancelAnchor_ = t, this.nextCenter_ = null, this.nextResolution_ = NaN, this.nextRotation_ = NaN;
2939
+ }
2940
+ /**
2941
+ * Update all animations.
2942
+ */
2943
+ updateAnimations_() {
2944
+ if (this.updateAnimationKey_ !== void 0 && (cancelAnimationFrame(this.updateAnimationKey_), this.updateAnimationKey_ = void 0), !this.getAnimating())
2945
+ return;
2946
+ const t = Date.now();
2947
+ let e = !1;
2948
+ for (let n = this.animations_.length - 1; n >= 0; --n) {
2949
+ const s = this.animations_[n];
2950
+ let r = !0;
2951
+ for (let o = 0, a = s.length; o < a; ++o) {
2952
+ const l = s[o];
2953
+ if (l.complete)
2954
+ continue;
2955
+ const h = t - l.start;
2956
+ let u = l.duration > 0 ? h / l.duration : 1;
2957
+ u >= 1 ? (l.complete = !0, u = 1) : r = !1;
2958
+ const c = l.easing(u);
2959
+ if (l.sourceCenter) {
2960
+ const f = l.sourceCenter[0], g = l.sourceCenter[1], d = l.targetCenter[0], m = l.targetCenter[1];
2961
+ this.nextCenter_ = l.targetCenter;
2962
+ const _ = f + c * (d - f), x = g + c * (m - g);
2963
+ this.targetCenter_ = [_, x];
2964
+ }
2965
+ if (l.sourceResolution && l.targetResolution) {
2966
+ const f = c === 1 ? l.targetResolution : l.sourceResolution + c * (l.targetResolution - l.sourceResolution);
2967
+ if (l.anchor) {
2968
+ const g = this.getViewportSize_(this.getRotation()), d = this.constraints_.resolution(
2969
+ f,
2970
+ 0,
2971
+ g,
2972
+ !0
2973
+ );
2974
+ this.targetCenter_ = this.calculateCenterZoom(
2975
+ d,
2976
+ l.anchor
2977
+ );
2978
+ }
2979
+ this.nextResolution_ = l.targetResolution, this.targetResolution_ = f, this.applyTargetState_(!0);
2980
+ }
2981
+ if (l.sourceRotation !== void 0 && l.targetRotation !== void 0) {
2982
+ const f = c === 1 ? bt(l.targetRotation + Math.PI, 2 * Math.PI) - Math.PI : l.sourceRotation + c * (l.targetRotation - l.sourceRotation);
2983
+ if (l.anchor) {
2984
+ const g = this.constraints_.rotation(
2985
+ f,
2986
+ !0
2987
+ );
2988
+ this.targetCenter_ = this.calculateCenterRotate(
2989
+ g,
2990
+ l.anchor
2991
+ );
2992
+ }
2993
+ this.nextRotation_ = l.targetRotation, this.targetRotation_ = f;
2994
+ }
2995
+ if (this.applyTargetState_(!0), e = !0, !l.complete)
2996
+ break;
2997
+ }
2998
+ if (r) {
2999
+ this.animations_[n] = null, this.setHint(A.ANIMATING, -1), this.nextCenter_ = null, this.nextResolution_ = NaN, this.nextRotation_ = NaN;
3000
+ const o = s[0].callback;
3001
+ o && nt(o, !0);
3002
+ }
3003
+ }
3004
+ this.animations_ = this.animations_.filter(Boolean), e && this.updateAnimationKey_ === void 0 && (this.updateAnimationKey_ = requestAnimationFrame(
3005
+ this.updateAnimations_.bind(this)
3006
+ ));
3007
+ }
3008
+ /**
3009
+ * @param {number} rotation Target rotation.
3010
+ * @param {import("./coordinate.js").Coordinate} anchor Rotation anchor.
3011
+ * @return {import("./coordinate.js").Coordinate|undefined} Center for rotation and anchor.
3012
+ */
3013
+ calculateCenterRotate(t, e) {
3014
+ let n;
3015
+ const s = this.getCenterInternal();
3016
+ return s !== void 0 && (n = [s[0] - e[0], s[1] - e[1]], Rn(n, t - this.getRotation()), _n(n, e)), n;
3017
+ }
3018
+ /**
3019
+ * @param {number} resolution Target resolution.
3020
+ * @param {import("./coordinate.js").Coordinate} anchor Zoom anchor.
3021
+ * @return {import("./coordinate.js").Coordinate|undefined} Center for resolution and anchor.
3022
+ */
3023
+ calculateCenterZoom(t, e) {
3024
+ let n;
3025
+ const s = this.getCenterInternal(), r = this.getResolution();
3026
+ if (s !== void 0 && r !== void 0) {
3027
+ const o = e[0] - t * (e[0] - s[0]) / r, a = e[1] - t * (e[1] - s[1]) / r;
3028
+ n = [o, a];
3029
+ }
3030
+ return n;
3031
+ }
3032
+ /**
3033
+ * Returns the current viewport size.
3034
+ * @private
3035
+ * @param {number} [rotation] Take into account the rotation of the viewport when giving the size
3036
+ * @return {import("./size.js").Size} Viewport size or `[100, 100]` when no viewport is found.
3037
+ */
3038
+ getViewportSize_(t) {
3039
+ const e = this.viewportSize_;
3040
+ if (t) {
3041
+ const n = e[0], s = e[1];
3042
+ return [
3043
+ Math.abs(n * Math.cos(t)) + Math.abs(s * Math.sin(t)),
3044
+ Math.abs(n * Math.sin(t)) + Math.abs(s * Math.cos(t))
3045
+ ];
3046
+ }
3047
+ return e;
3048
+ }
3049
+ /**
3050
+ * Stores the viewport size on the view. The viewport size is not read every time from the DOM
3051
+ * to avoid performance hit and layout reflow.
3052
+ * This should be done on map size change.
3053
+ * Note: the constraints are not resolved during an animation to avoid stopping it
3054
+ * @param {import("./size.js").Size} [size] Viewport size; if undefined, [100, 100] is assumed
3055
+ */
3056
+ setViewportSize(t) {
3057
+ this.viewportSize_ = Array.isArray(t) ? t.slice() : [100, 100], this.getAnimating() || this.resolveConstraints(0);
3058
+ }
3059
+ /**
3060
+ * Get the view center.
3061
+ * @return {import("./coordinate.js").Coordinate|undefined} The center of the view.
3062
+ * @observable
3063
+ * @api
3064
+ */
3065
+ getCenter() {
3066
+ const t = this.getCenterInternal();
3067
+ return t && Kt(t, this.getProjection());
3068
+ }
3069
+ /**
3070
+ * Get the view center without transforming to user projection.
3071
+ * @return {import("./coordinate.js").Coordinate|undefined} The center of the view.
3072
+ */
3073
+ getCenterInternal() {
3074
+ return (
3075
+ /** @type {import("./coordinate.js").Coordinate|undefined} */
3076
+ this.get(I.CENTER)
3077
+ );
3078
+ }
3079
+ /**
3080
+ * @return {Constraints} Constraints.
3081
+ */
3082
+ getConstraints() {
3083
+ return this.constraints_;
3084
+ }
3085
+ /**
3086
+ * @return {boolean} Resolution constraint is set
3087
+ */
3088
+ getConstrainResolution() {
3089
+ return this.get("constrainResolution");
3090
+ }
3091
+ /**
3092
+ * @param {Array<number>} [hints] Destination array.
3093
+ * @return {Array<number>} Hint.
3094
+ */
3095
+ getHints(t) {
3096
+ return t !== void 0 ? (t[0] = this.hints_[0], t[1] = this.hints_[1], t) : this.hints_.slice();
3097
+ }
3098
+ /**
3099
+ * Calculate the extent for the current view state and the passed box size.
3100
+ * @param {import("./size.js").Size} [size] The pixel dimensions of the box
3101
+ * into which the calculated extent should fit. Defaults to the size of the
3102
+ * map the view is associated with.
3103
+ * If no map or multiple maps are connected to the view, provide the desired
3104
+ * box size (e.g. `map.getSize()`).
3105
+ * @return {import("./extent.js").Extent} Extent.
3106
+ * @api
3107
+ */
3108
+ calculateExtent(t) {
3109
+ const e = this.calculateExtentInternal(t);
3110
+ return Hn(e, this.getProjection());
3111
+ }
3112
+ /**
3113
+ * @param {import("./size.js").Size} [size] Box pixel size. If not provided,
3114
+ * the map's last known viewport size will be used.
3115
+ * @return {import("./extent.js").Extent} Extent.
3116
+ */
3117
+ calculateExtentInternal(t) {
3118
+ t = t || this.getViewportSizeMinusPadding_();
3119
+ const e = (
3120
+ /** @type {!import("./coordinate.js").Coordinate} */
3121
+ this.getCenterInternal()
3122
+ );
3123
+ y(e, "The view center is not defined");
3124
+ const n = (
3125
+ /** @type {!number} */
3126
+ this.getResolution()
3127
+ );
3128
+ y(n !== void 0, "The view resolution is not defined");
3129
+ const s = (
3130
+ /** @type {!number} */
3131
+ this.getRotation()
3132
+ );
3133
+ return y(s !== void 0, "The view rotation is not defined"), an(e, n, s, t);
3134
+ }
3135
+ /**
3136
+ * Get the maximum resolution of the view.
3137
+ * @return {number} The maximum resolution of the view.
3138
+ * @api
3139
+ */
3140
+ getMaxResolution() {
3141
+ return this.maxResolution_;
3142
+ }
3143
+ /**
3144
+ * Get the minimum resolution of the view.
3145
+ * @return {number} The minimum resolution of the view.
3146
+ * @api
3147
+ */
3148
+ getMinResolution() {
3149
+ return this.minResolution_;
3150
+ }
3151
+ /**
3152
+ * Get the maximum zoom level for the view.
3153
+ * @return {number} The maximum zoom level.
3154
+ * @api
3155
+ */
3156
+ getMaxZoom() {
3157
+ return (
3158
+ /** @type {number} */
3159
+ this.getZoomForResolution(this.minResolution_)
3160
+ );
3161
+ }
3162
+ /**
3163
+ * Set a new maximum zoom level for the view.
3164
+ * @param {number} zoom The maximum zoom level.
3165
+ * @api
3166
+ */
3167
+ setMaxZoom(t) {
3168
+ this.applyOptions_(this.getUpdatedOptions_({ maxZoom: t }));
3169
+ }
3170
+ /**
3171
+ * Get the minimum zoom level for the view.
3172
+ * @return {number} The minimum zoom level.
3173
+ * @api
3174
+ */
3175
+ getMinZoom() {
3176
+ return (
3177
+ /** @type {number} */
3178
+ this.getZoomForResolution(this.maxResolution_)
3179
+ );
3180
+ }
3181
+ /**
3182
+ * Set a new minimum zoom level for the view.
3183
+ * @param {number} zoom The minimum zoom level.
3184
+ * @api
3185
+ */
3186
+ setMinZoom(t) {
3187
+ this.applyOptions_(this.getUpdatedOptions_({ minZoom: t }));
3188
+ }
3189
+ /**
3190
+ * Set whether the view should allow intermediary zoom levels.
3191
+ * @param {boolean} enabled Whether the resolution is constrained.
3192
+ * @api
3193
+ */
3194
+ setConstrainResolution(t) {
3195
+ this.applyOptions_(this.getUpdatedOptions_({ constrainResolution: t }));
3196
+ }
3197
+ /**
3198
+ * Get the view projection.
3199
+ * @return {import("./proj/Projection.js").default} The projection of the view.
3200
+ * @api
3201
+ */
3202
+ getProjection() {
3203
+ return this.projection_;
3204
+ }
3205
+ /**
3206
+ * Get the view resolution.
3207
+ * @return {number|undefined} The resolution of the view.
3208
+ * @observable
3209
+ * @api
3210
+ */
3211
+ getResolution() {
3212
+ return (
3213
+ /** @type {number|undefined} */
3214
+ this.get(I.RESOLUTION)
3215
+ );
3216
+ }
3217
+ /**
3218
+ * Get the resolutions for the view. This returns the array of resolutions
3219
+ * passed to the constructor of the View, or undefined if none were given.
3220
+ * @return {Array<number>|undefined} The resolutions of the view.
3221
+ * @api
3222
+ */
3223
+ getResolutions() {
3224
+ return this.resolutions_;
3225
+ }
3226
+ /**
3227
+ * Get the resolution for a provided extent (in map units) and size (in pixels).
3228
+ * @param {import("./extent.js").Extent} extent Extent.
3229
+ * @param {import("./size.js").Size} [size] Box pixel size.
3230
+ * @return {number} The resolution at which the provided extent will render at
3231
+ * the given size.
3232
+ * @api
3233
+ */
3234
+ getResolutionForExtent(t, e) {
3235
+ return this.getResolutionForExtentInternal(
3236
+ tt(t, this.getProjection()),
3237
+ e
3238
+ );
3239
+ }
3240
+ /**
3241
+ * Get the resolution for a provided extent (in map units) and size (in pixels).
3242
+ * @param {import("./extent.js").Extent} extent Extent.
3243
+ * @param {import("./size.js").Size} [size] Box pixel size.
3244
+ * @return {number} The resolution at which the provided extent will render at
3245
+ * the given size.
3246
+ */
3247
+ getResolutionForExtentInternal(t, e) {
3248
+ e = e || this.getViewportSizeMinusPadding_();
3249
+ const n = D(t) / e[0], s = k(t) / e[1];
3250
+ return Math.max(n, s);
3251
+ }
3252
+ /**
3253
+ * Return a function that returns a value between 0 and 1 for a
3254
+ * resolution. Exponential scaling is assumed.
3255
+ * @param {number} [power] Power.
3256
+ * @return {function(number): number} Resolution for value function.
3257
+ */
3258
+ getResolutionForValueFunction(t) {
3259
+ t = t || 2;
3260
+ const e = this.getConstrainedResolution(this.maxResolution_), n = this.minResolution_, s = Math.log(e / n) / Math.log(t);
3261
+ return (
3262
+ /**
3263
+ * @param {number} value Value.
3264
+ * @return {number} Resolution.
3265
+ */
3266
+ function(r) {
3267
+ return e / Math.pow(t, r * s);
3268
+ }
3269
+ );
3270
+ }
3271
+ /**
3272
+ * Get the view rotation.
3273
+ * @return {number} The rotation of the view in radians.
3274
+ * @observable
3275
+ * @api
3276
+ */
3277
+ getRotation() {
3278
+ return (
3279
+ /** @type {number} */
3280
+ this.get(I.ROTATION)
3281
+ );
3282
+ }
3283
+ /**
3284
+ * Return a function that returns a resolution for a value between
3285
+ * 0 and 1. Exponential scaling is assumed.
3286
+ * @param {number} [power] Power.
3287
+ * @return {function(number): number} Value for resolution function.
3288
+ */
3289
+ getValueForResolutionFunction(t) {
3290
+ const e = Math.log(t || 2), n = this.getConstrainedResolution(this.maxResolution_), s = this.minResolution_, r = Math.log(n / s) / e;
3291
+ return (
3292
+ /**
3293
+ * @param {number} resolution Resolution.
3294
+ * @return {number} Value.
3295
+ */
3296
+ function(o) {
3297
+ return Math.log(n / o) / e / r;
3298
+ }
3299
+ );
3300
+ }
3301
+ /**
3302
+ * Returns the size of the viewport minus padding.
3303
+ * @private
3304
+ * @param {number} [rotation] Take into account the rotation of the viewport when giving the size
3305
+ * @return {import("./size.js").Size} Viewport size reduced by the padding.
3306
+ */
3307
+ getViewportSizeMinusPadding_(t) {
3308
+ let e = this.getViewportSize_(t);
3309
+ const n = this.padding_;
3310
+ return n && (e = [
3311
+ e[0] - n[1] - n[3],
3312
+ e[1] - n[0] - n[2]
3313
+ ]), e;
3314
+ }
3315
+ /**
3316
+ * @return {State} View state.
3317
+ */
3318
+ getState() {
3319
+ const t = this.getProjection(), e = this.getResolution(), n = this.getRotation();
3320
+ let s = (
3321
+ /** @type {import("./coordinate.js").Coordinate} */
3322
+ this.getCenterInternal()
3323
+ );
3324
+ const r = this.padding_;
3325
+ if (r) {
3326
+ const o = this.getViewportSizeMinusPadding_();
3327
+ s = Mt(
3328
+ s,
3329
+ this.getViewportSize_(),
3330
+ [o[0] / 2 + r[3], o[1] / 2 + r[0]],
3331
+ e,
3332
+ n
3333
+ );
3334
+ }
3335
+ return {
3336
+ center: s.slice(0),
3337
+ projection: t !== void 0 ? t : null,
3338
+ resolution: e,
3339
+ nextCenter: this.nextCenter_,
3340
+ nextResolution: this.nextResolution_,
3341
+ nextRotation: this.nextRotation_,
3342
+ rotation: n,
3343
+ zoom: this.getZoom()
3344
+ };
3345
+ }
3346
+ /**
3347
+ * @return {ViewStateLayerStateExtent} Like `FrameState`, but just `viewState` and `extent`.
3348
+ */
3349
+ getViewStateAndExtent() {
3350
+ return {
3351
+ viewState: this.getState(),
3352
+ extent: this.calculateExtent()
3353
+ };
3354
+ }
3355
+ /**
3356
+ * Get the current zoom level. This method may return non-integer zoom levels
3357
+ * if the view does not constrain the resolution, or if an interaction or
3358
+ * animation is underway.
3359
+ * @return {number|undefined} Zoom.
3360
+ * @api
3361
+ */
3362
+ getZoom() {
3363
+ let t;
3364
+ const e = this.getResolution();
3365
+ return e !== void 0 && (t = this.getZoomForResolution(e)), t;
3366
+ }
3367
+ /**
3368
+ * Get the zoom level for a resolution.
3369
+ * @param {number} resolution The resolution.
3370
+ * @return {number|undefined} The zoom level for the provided resolution.
3371
+ * @api
3372
+ */
3373
+ getZoomForResolution(t) {
3374
+ let e = this.minZoom_ || 0, n, s;
3375
+ if (this.resolutions_) {
3376
+ const r = wt(this.resolutions_, t, 1);
3377
+ e = r, n = this.resolutions_[r], r == this.resolutions_.length - 1 ? s = 2 : s = n / this.resolutions_[r + 1];
3378
+ } else
3379
+ n = this.maxResolution_, s = this.zoomFactor_;
3380
+ return e + Math.log(n / t) / Math.log(s);
3381
+ }
3382
+ /**
3383
+ * Get the resolution for a zoom level.
3384
+ * @param {number} zoom Zoom level.
3385
+ * @return {number} The view resolution for the provided zoom level.
3386
+ * @api
3387
+ */
3388
+ getResolutionForZoom(t) {
3389
+ if (this.resolutions_?.length) {
3390
+ if (this.resolutions_.length === 1)
3391
+ return this.resolutions_[0];
3392
+ const e = p(
3393
+ Math.floor(t),
3394
+ 0,
3395
+ this.resolutions_.length - 2
3396
+ ), n = this.resolutions_[e] / this.resolutions_[e + 1];
3397
+ return this.resolutions_[e] / Math.pow(n, p(t - e, 0, 1));
3398
+ }
3399
+ return this.maxResolution_ / Math.pow(this.zoomFactor_, t - this.minZoom_);
3400
+ }
3401
+ /**
3402
+ * Fit the given geometry or extent based on the given map size and border.
3403
+ * The size is pixel dimensions of the box to fit the extent into.
3404
+ * In most cases you will want to use the map size, that is `map.getSize()`.
3405
+ * Takes care of the map angle.
3406
+ * @param {import("./geom/SimpleGeometry.js").default|import("./extent.js").Extent} geometryOrExtent The geometry or
3407
+ * extent to fit the view to.
3408
+ * @param {FitOptions} [options] Options.
3409
+ * @api
3410
+ */
3411
+ fit(t, e) {
3412
+ let n;
3413
+ if (y(
3414
+ Array.isArray(t) || typeof /** @type {?} */
3415
+ t.getSimplifiedGeometry == "function",
3416
+ "Invalid extent or geometry provided as `geometry`"
3417
+ ), Array.isArray(t)) {
3418
+ y(
3419
+ !Re(t),
3420
+ "Cannot fit empty extent provided as `geometry`"
3421
+ );
3422
+ const s = tt(t, this.getProjection());
3423
+ n = ie(s);
3424
+ } else if (t.getType() === "Circle") {
3425
+ const s = tt(
3426
+ t.getExtent(),
3427
+ this.getProjection()
3428
+ );
3429
+ n = ie(s), n.rotate(this.getRotation(), rt(s));
3430
+ } else
3431
+ n = t;
3432
+ this.fitInternal(n, e);
3433
+ }
3434
+ /**
3435
+ * Calculate rotated extent
3436
+ * @param {import("./geom/SimpleGeometry.js").default} geometry The geometry.
3437
+ * @return {import("./extent").Extent} The rotated extent for the geometry.
3438
+ */
3439
+ rotatedExtentForGeometry(t) {
3440
+ const e = this.getRotation(), n = Math.cos(e), s = Math.sin(-e), r = t.getFlatCoordinates(), o = t.getStride();
3441
+ let a = 1 / 0, l = 1 / 0, h = -1 / 0, u = -1 / 0;
3442
+ for (let c = 0, f = r.length; c < f; c += o) {
3443
+ const g = r[c] * n - r[c + 1] * s, d = r[c] * s + r[c + 1] * n;
3444
+ a = Math.min(a, g), l = Math.min(l, d), h = Math.max(h, g), u = Math.max(u, d);
3445
+ }
3446
+ return [a, l, h, u];
3447
+ }
3448
+ /**
3449
+ * @param {import("./geom/SimpleGeometry.js").default} geometry The geometry.
3450
+ * @param {FitOptions} [options] Options.
3451
+ */
3452
+ fitInternal(t, e) {
3453
+ e = e || {};
3454
+ let n = e.size;
3455
+ n || (n = this.getViewportSizeMinusPadding_());
3456
+ const s = e.padding !== void 0 ? e.padding : [0, 0, 0, 0], r = e.nearest !== void 0 ? e.nearest : !1;
3457
+ let o;
3458
+ e.minResolution !== void 0 ? o = e.minResolution : e.maxZoom !== void 0 ? o = this.getResolutionForZoom(e.maxZoom) : o = 0;
3459
+ const a = this.rotatedExtentForGeometry(t);
3460
+ let l = this.getResolutionForExtentInternal(a, [
3461
+ n[0] - s[1] - s[3],
3462
+ n[1] - s[0] - s[2]
3463
+ ]);
3464
+ l = isNaN(l) ? o : Math.max(l, o), l = this.getConstrainedResolution(l, r ? 0 : 1);
3465
+ const h = this.getRotation(), u = Math.sin(h), c = Math.cos(h), f = rt(a);
3466
+ f[0] += (s[1] - s[3]) / 2 * l, f[1] += (s[0] - s[2]) / 2 * l;
3467
+ const g = f[0] * c - f[1] * u, d = f[1] * c + f[0] * u, m = this.getConstrainedCenter([g, d], l), _ = e.callback ? e.callback : Ct;
3468
+ e.duration !== void 0 ? this.animateInternal(
3469
+ {
3470
+ resolution: l,
3471
+ center: m,
3472
+ duration: e.duration,
3473
+ easing: e.easing
3474
+ },
3475
+ _
3476
+ ) : (this.targetResolution_ = l, this.targetCenter_ = m, this.applyTargetState_(!1, !0), nt(_, !0));
3477
+ }
3478
+ /**
3479
+ * Center on coordinate and view position.
3480
+ * @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
3481
+ * @param {import("./size.js").Size} size Box pixel size.
3482
+ * @param {import("./pixel.js").Pixel} position Position on the view to center on.
3483
+ * @api
3484
+ */
3485
+ centerOn(t, e, n) {
3486
+ this.centerOnInternal(
3487
+ S(t, this.getProjection()),
3488
+ e,
3489
+ n
3490
+ );
3491
+ }
3492
+ /**
3493
+ * @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
3494
+ * @param {import("./size.js").Size} size Box pixel size.
3495
+ * @param {import("./pixel.js").Pixel} position Position on the view to center on.
3496
+ */
3497
+ centerOnInternal(t, e, n) {
3498
+ this.setCenterInternal(
3499
+ Mt(
3500
+ t,
3501
+ e,
3502
+ n,
3503
+ this.getResolution(),
3504
+ this.getRotation()
3505
+ )
3506
+ );
3507
+ }
3508
+ /**
3509
+ * Calculates the shift between map and viewport center.
3510
+ * @param {import("./coordinate.js").Coordinate} center Center.
3511
+ * @param {number} resolution Resolution.
3512
+ * @param {number} rotation Rotation.
3513
+ * @param {import("./size.js").Size} size Size.
3514
+ * @return {Array<number>|undefined} Center shift.
3515
+ */
3516
+ calculateCenterShift(t, e, n, s) {
3517
+ let r;
3518
+ const o = this.padding_;
3519
+ if (o && t) {
3520
+ const a = this.getViewportSizeMinusPadding_(-n), l = Mt(
3521
+ t,
3522
+ s,
3523
+ [a[0] / 2 + o[3], a[1] / 2 + o[0]],
3524
+ e,
3525
+ n
3526
+ );
3527
+ r = [
3528
+ t[0] - l[0],
3529
+ t[1] - l[1]
3530
+ ];
3531
+ }
3532
+ return r;
3533
+ }
3534
+ /**
3535
+ * @return {boolean} Is defined.
3536
+ */
3537
+ isDef() {
3538
+ return !!this.getCenterInternal() && this.getResolution() !== void 0;
3539
+ }
3540
+ /**
3541
+ * Adds relative coordinates to the center of the view. Any extent constraint will apply.
3542
+ * @param {import("./coordinate.js").Coordinate} deltaCoordinates Relative value to add.
3543
+ * @api
3544
+ */
3545
+ adjustCenter(t) {
3546
+ const e = Kt(this.targetCenter_, this.getProjection());
3547
+ this.setCenter([
3548
+ e[0] + t[0],
3549
+ e[1] + t[1]
3550
+ ]);
3551
+ }
3552
+ /**
3553
+ * Adds relative coordinates to the center of the view. Any extent constraint will apply.
3554
+ * @param {import("./coordinate.js").Coordinate} deltaCoordinates Relative value to add.
3555
+ */
3556
+ adjustCenterInternal(t) {
3557
+ const e = this.targetCenter_;
3558
+ this.setCenterInternal([
3559
+ e[0] + t[0],
3560
+ e[1] + t[1]
3561
+ ]);
3562
+ }
3563
+ /**
3564
+ * Multiply the view resolution by a ratio, optionally using an anchor. Any resolution
3565
+ * constraint will apply.
3566
+ * @param {number} ratio The ratio to apply on the view resolution.
3567
+ * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
3568
+ * @api
3569
+ */
3570
+ adjustResolution(t, e) {
3571
+ e = e && S(e, this.getProjection()), this.adjustResolutionInternal(t, e);
3572
+ }
3573
+ /**
3574
+ * Multiply the view resolution by a ratio, optionally using an anchor. Any resolution
3575
+ * constraint will apply.
3576
+ * @param {number} ratio The ratio to apply on the view resolution.
3577
+ * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
3578
+ */
3579
+ adjustResolutionInternal(t, e) {
3580
+ const n = this.getAnimating() || this.getInteracting(), s = this.getViewportSize_(this.getRotation()), r = this.constraints_.resolution(
3581
+ this.targetResolution_ * t,
3582
+ 0,
3583
+ s,
3584
+ n
3585
+ );
3586
+ e && (this.targetCenter_ = this.calculateCenterZoom(r, e)), this.targetResolution_ *= t, this.applyTargetState_();
3587
+ }
3588
+ /**
3589
+ * Adds a value to the view zoom level, optionally using an anchor. Any resolution
3590
+ * constraint will apply.
3591
+ * @param {number} delta Relative value to add to the zoom level.
3592
+ * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
3593
+ * @api
3594
+ */
3595
+ adjustZoom(t, e) {
3596
+ this.adjustResolution(Math.pow(this.zoomFactor_, -t), e);
3597
+ }
3598
+ /**
3599
+ * Adds a value to the view rotation, optionally using an anchor. Any rotation
3600
+ * constraint will apply.
3601
+ * @param {number} delta Relative value to add to the zoom rotation, in radians.
3602
+ * @param {import("./coordinate.js").Coordinate} [anchor] The rotation center.
3603
+ * @api
3604
+ */
3605
+ adjustRotation(t, e) {
3606
+ e && (e = S(e, this.getProjection())), this.adjustRotationInternal(t, e);
3607
+ }
3608
+ /**
3609
+ * @param {number} delta Relative value to add to the zoom rotation, in radians.
3610
+ * @param {import("./coordinate.js").Coordinate} [anchor] The rotation center.
3611
+ */
3612
+ adjustRotationInternal(t, e) {
3613
+ const n = this.getAnimating() || this.getInteracting(), s = this.constraints_.rotation(
3614
+ this.targetRotation_ + t,
3615
+ n
3616
+ );
3617
+ e && (this.targetCenter_ = this.calculateCenterRotate(s, e)), this.targetRotation_ += t, this.applyTargetState_();
3618
+ }
3619
+ /**
3620
+ * Set the center of the current view. Any extent constraint will apply.
3621
+ * @param {import("./coordinate.js").Coordinate|undefined} center The center of the view.
3622
+ * @observable
3623
+ * @api
3624
+ */
3625
+ setCenter(t) {
3626
+ this.setCenterInternal(
3627
+ t && S(t, this.getProjection())
3628
+ );
3629
+ }
3630
+ /**
3631
+ * Set the center using the view projection (not the user projection).
3632
+ * @param {import("./coordinate.js").Coordinate|undefined} center The center of the view.
3633
+ */
3634
+ setCenterInternal(t) {
3635
+ this.targetCenter_ = t, this.applyTargetState_();
3636
+ }
3637
+ /**
3638
+ * @param {import("./ViewHint.js").default} hint Hint.
3639
+ * @param {number} delta Delta.
3640
+ * @return {number} New value.
3641
+ */
3642
+ setHint(t, e) {
3643
+ return this.hints_[t] += e, this.changed(), this.hints_[t];
3644
+ }
3645
+ /**
3646
+ * Set the resolution for this view. Any resolution constraint will apply.
3647
+ * @param {number|undefined} resolution The resolution of the view.
3648
+ * @observable
3649
+ * @api
3650
+ */
3651
+ setResolution(t) {
3652
+ this.targetResolution_ = t, this.applyTargetState_();
3653
+ }
3654
+ /**
3655
+ * Set the rotation for this view. Any rotation constraint will apply.
3656
+ * @param {number} rotation The rotation of the view in radians.
3657
+ * @observable
3658
+ * @api
3659
+ */
3660
+ setRotation(t) {
3661
+ this.targetRotation_ = t, this.applyTargetState_();
3662
+ }
3663
+ /**
3664
+ * Zoom to a specific zoom level. Any resolution constrain will apply.
3665
+ * @param {number} zoom Zoom level.
3666
+ * @api
3667
+ */
3668
+ setZoom(t) {
3669
+ this.setResolution(this.getResolutionForZoom(t));
3670
+ }
3671
+ /**
3672
+ * Recompute rotation/resolution/center based on target values.
3673
+ * Note: we have to compute rotation first, then resolution and center considering that
3674
+ * parameters can influence one another in case a view extent constraint is present.
3675
+ * @param {boolean} [doNotCancelAnims] Do not cancel animations.
3676
+ * @param {boolean} [forceMoving] Apply constraints as if the view is moving.
3677
+ * @private
3678
+ */
3679
+ applyTargetState_(t, e) {
3680
+ const n = this.getAnimating() || this.getInteracting() || e, s = this.constraints_.rotation(
3681
+ this.targetRotation_,
3682
+ n
3683
+ ), r = this.getViewportSize_(s), o = this.constraints_.resolution(
3684
+ this.targetResolution_,
3685
+ 0,
3686
+ r,
3687
+ n
3688
+ ), a = this.constraints_.center(
3689
+ this.targetCenter_,
3690
+ o,
3691
+ r,
3692
+ n,
3693
+ this.calculateCenterShift(
3694
+ this.targetCenter_,
3695
+ o,
3696
+ s,
3697
+ r
3698
+ )
3699
+ );
3700
+ this.get(I.ROTATION) !== s && this.set(I.ROTATION, s), this.get(I.RESOLUTION) !== o && (this.set(I.RESOLUTION, o), this.set("zoom", this.getZoom(), !0)), (!a || !this.get(I.CENTER) || !ot(this.get(I.CENTER), a)) && this.set(I.CENTER, a), this.getAnimating() && !t && this.cancelAnimations(), this.cancelAnchor_ = void 0;
3701
+ }
3702
+ /**
3703
+ * If any constraints need to be applied, an animation will be triggered.
3704
+ * This is typically done on interaction end.
3705
+ * Note: calling this with a duration of 0 will apply the constrained values straight away,
3706
+ * without animation.
3707
+ * @param {number} [duration] The animation duration in ms.
3708
+ * @param {number} [resolutionDirection] Which direction to zoom.
3709
+ * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
3710
+ */
3711
+ resolveConstraints(t, e, n) {
3712
+ t = t !== void 0 ? t : 200;
3713
+ const s = e || 0, r = this.constraints_.rotation(this.targetRotation_), o = this.getViewportSize_(r), a = this.constraints_.resolution(
3714
+ this.targetResolution_,
3715
+ s,
3716
+ o
3717
+ ), l = this.constraints_.center(
3718
+ this.targetCenter_,
3719
+ a,
3720
+ o,
3721
+ !1,
3722
+ this.calculateCenterShift(
3723
+ this.targetCenter_,
3724
+ a,
3725
+ r,
3726
+ o
3727
+ )
3728
+ );
3729
+ if (t === 0 && !this.cancelAnchor_) {
3730
+ this.targetResolution_ = a, this.targetRotation_ = r, this.targetCenter_ = l, this.applyTargetState_();
3731
+ return;
3732
+ }
3733
+ n = n || (t === 0 ? this.cancelAnchor_ : void 0), this.cancelAnchor_ = void 0, (this.getResolution() !== a || this.getRotation() !== r || !this.getCenterInternal() || !ot(this.getCenterInternal(), l)) && (this.getAnimating() && this.cancelAnimations(), this.animateInternal({
3734
+ rotation: r,
3735
+ center: l,
3736
+ resolution: a,
3737
+ duration: t,
3738
+ easing: Ei,
3739
+ anchor: n
3740
+ }));
3741
+ }
3742
+ /**
3743
+ * Notify the View that an interaction has started.
3744
+ * The view state will be resolved to a stable one if needed
3745
+ * (depending on its constraints).
3746
+ * @api
3747
+ */
3748
+ beginInteraction() {
3749
+ this.resolveConstraints(0), this.setHint(A.INTERACTING, 1);
3750
+ }
3751
+ /**
3752
+ * Notify the View that an interaction has ended. The view state will be resolved
3753
+ * to a stable one if needed (depending on its constraints).
3754
+ * @param {number} [duration] Animation duration in ms.
3755
+ * @param {number} [resolutionDirection] Which direction to zoom.
3756
+ * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
3757
+ * @api
3758
+ */
3759
+ endInteraction(t, e, n) {
3760
+ n = n && S(n, this.getProjection()), this.endInteractionInternal(t, e, n);
3761
+ }
3762
+ /**
3763
+ * Notify the View that an interaction has ended. The view state will be resolved
3764
+ * to a stable one if needed (depending on its constraints).
3765
+ * @param {number} [duration] Animation duration in ms.
3766
+ * @param {number} [resolutionDirection] Which direction to zoom.
3767
+ * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
3768
+ */
3769
+ endInteractionInternal(t, e, n) {
3770
+ this.getInteracting() && (this.setHint(A.INTERACTING, -1), this.resolveConstraints(t, e, n));
3771
+ }
3772
+ /**
3773
+ * Get a valid position for the view center according to the current constraints.
3774
+ * @param {import("./coordinate.js").Coordinate|undefined} targetCenter Target center position.
3775
+ * @param {number} [targetResolution] Target resolution. If not supplied, the current one will be used.
3776
+ * This is useful to guess a valid center position at a different zoom level.
3777
+ * @return {import("./coordinate.js").Coordinate|undefined} Valid center position.
3778
+ */
3779
+ getConstrainedCenter(t, e) {
3780
+ const n = this.getViewportSize_(this.getRotation());
3781
+ return this.constraints_.center(
3782
+ t,
3783
+ e || this.getResolution(),
3784
+ n
3785
+ );
3786
+ }
3787
+ /**
3788
+ * Get a valid zoom level according to the current view constraints.
3789
+ * @param {number|undefined} targetZoom Target zoom.
3790
+ * @param {number} [direction] Indicate which resolution should be used
3791
+ * by a renderer if the view resolution does not match any resolution of the tile source.
3792
+ * If 0, the nearest resolution will be used. If 1, the nearest lower resolution
3793
+ * will be used. If -1, the nearest higher resolution will be used.
3794
+ * @return {number|undefined} Valid zoom level.
3795
+ */
3796
+ getConstrainedZoom(t, e) {
3797
+ const n = this.getResolutionForZoom(t);
3798
+ return this.getZoomForResolution(
3799
+ this.getConstrainedResolution(n, e)
3800
+ );
3801
+ }
3802
+ /**
3803
+ * Get a valid resolution according to the current view constraints.
3804
+ * @param {number|undefined} targetResolution Target resolution.
3805
+ * @param {number} [direction] Indicate which resolution should be used
3806
+ * by a renderer if the view resolution does not match any resolution of the tile source.
3807
+ * If 0, the nearest resolution will be used. If 1, the nearest lower resolution
3808
+ * will be used. If -1, the nearest higher resolution will be used.
3809
+ * @return {number|undefined} Valid resolution.
3810
+ */
3811
+ getConstrainedResolution(t, e) {
3812
+ e = e || 0;
3813
+ const n = this.getViewportSize_(this.getRotation());
3814
+ return this.constraints_.resolution(t, e, n);
3815
+ }
3816
+ }
3817
+ function nt(i, t) {
3818
+ setTimeout(function() {
3819
+ i(t);
3820
+ }, 0);
3821
+ }
3822
+ function vi(i) {
3823
+ if (i.extent !== void 0) {
3824
+ const e = i.smoothExtentConstraint !== void 0 ? i.smoothExtentConstraint : !0;
3825
+ return se(i.extent, i.constrainOnlyCenter, e);
3826
+ }
3827
+ const t = vt(i.projection, "EPSG:3857");
3828
+ if (i.multiWorld !== !0 && t.isGlobal()) {
3829
+ const e = t.getExtent().slice();
3830
+ return e[0] = -1 / 0, e[2] = 1 / 0, se(e, !1, !1);
3831
+ }
3832
+ return Mi;
3833
+ }
3834
+ function Pi(i) {
3835
+ let t, e, n, o = i.minZoom !== void 0 ? i.minZoom : xt, a = i.maxZoom !== void 0 ? i.maxZoom : 28;
3836
+ const l = i.zoomFactor !== void 0 ? i.zoomFactor : 2, h = i.multiWorld !== void 0 ? i.multiWorld : !1, u = i.smoothResolutionConstraint !== void 0 ? i.smoothResolutionConstraint : !0, c = i.showFullExtent !== void 0 ? i.showFullExtent : !1, f = vt(i.projection, "EPSG:3857"), g = f.getExtent();
3837
+ let d = i.constrainOnlyCenter, m = i.extent;
3838
+ if (!h && !m && f.isGlobal() && (d = !1, m = g), i.resolutions !== void 0) {
3839
+ const _ = i.resolutions;
3840
+ e = _[o], n = _[a] !== void 0 ? _[a] : _[_.length - 1], i.constrainResolution ? t = pi(
3841
+ _,
3842
+ u,
3843
+ !d && m,
3844
+ c
3845
+ ) : t = re(
3846
+ e,
3847
+ n,
3848
+ u,
3849
+ !d && m,
3850
+ c
3851
+ );
3852
+ } else {
3853
+ const x = (g ? Math.max(D(g), k(g)) : (
3854
+ // use an extent that can fit the whole world if need be
3855
+ 360 * Me.degrees / f.getMetersPerUnit()
3856
+ )) / Ze / Math.pow(2, xt), R = x / Math.pow(2, 28 - xt);
3857
+ e = i.maxResolution, e !== void 0 ? o = 0 : e = x / Math.pow(l, o), n = i.minResolution, n === void 0 && (i.maxZoom !== void 0 ? i.maxResolution !== void 0 ? n = e / Math.pow(l, a) : n = x / Math.pow(l, a) : n = R), a = o + Math.floor(
3858
+ Math.log(e / n) / Math.log(l)
3859
+ ), n = e / Math.pow(l, a - o), i.constrainResolution ? t = Ii(
3860
+ l,
3861
+ e,
3862
+ n,
3863
+ u,
3864
+ !d && m,
3865
+ c
3866
+ ) : t = re(
3867
+ e,
3868
+ n,
3869
+ u,
3870
+ !d && m,
3871
+ c
3872
+ );
3873
+ }
3874
+ return {
3875
+ constraint: t,
3876
+ maxResolution: e,
3877
+ minResolution: n,
3878
+ minZoom: o,
3879
+ zoomFactor: l
3880
+ };
3881
+ }
3882
+ function Fi(i) {
3883
+ if (i.enableRotation !== void 0 ? i.enableRotation : !0) {
3884
+ const e = i.constrainRotation;
3885
+ return e === void 0 || e === !0 ? Si() : e === !1 ? oe : typeof e == "number" ? wi(e) : oe;
3886
+ }
3887
+ return yi;
3888
+ }
3889
+ function Xi(i) {
3890
+ return !(i.sourceCenter && i.targetCenter && !ot(i.sourceCenter, i.targetCenter) || i.sourceResolution !== i.targetResolution || i.sourceRotation !== i.targetRotation);
3891
+ }
3892
+ function Mt(i, t, e, n, s) {
3893
+ const r = Math.cos(-s);
3894
+ let o = Math.sin(-s), a = i[0] * r - i[1] * o, l = i[1] * r + i[0] * o;
3895
+ a += (t[0] / 2 - e[0]) * n, l += (e[1] - t[1] / 2) * n, o = -o;
3896
+ const h = a * r - l * o, u = l * r + a * o;
3897
+ return [h, u];
3898
+ }
3899
+ class je {
3900
+ /**
3901
+ * @param {number} minX Minimum X.
3902
+ * @param {number} maxX Maximum X.
3903
+ * @param {number} minY Minimum Y.
3904
+ * @param {number} maxY Maximum Y.
3905
+ */
3906
+ constructor(t, e, n, s) {
3907
+ this.minX = t, this.maxX = e, this.minY = n, this.maxY = s;
3908
+ }
3909
+ /**
3910
+ * @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
3911
+ * @return {boolean} Contains tile coordinate.
3912
+ */
3913
+ contains(t) {
3914
+ return this.containsXY(t[1], t[2]);
3915
+ }
3916
+ /**
3917
+ * @param {TileRange} tileRange Tile range.
3918
+ * @return {boolean} Contains.
3919
+ */
3920
+ containsTileRange(t) {
3921
+ return this.minX <= t.minX && t.maxX <= this.maxX && this.minY <= t.minY && t.maxY <= this.maxY;
3922
+ }
3923
+ /**
3924
+ * @param {number} x Tile coordinate x.
3925
+ * @param {number} y Tile coordinate y.
3926
+ * @return {boolean} Contains coordinate.
3927
+ */
3928
+ containsXY(t, e) {
3929
+ return this.minX <= t && t <= this.maxX && this.minY <= e && e <= this.maxY;
3930
+ }
3931
+ /**
3932
+ * @param {TileRange} tileRange Tile range.
3933
+ * @return {boolean} Equals.
3934
+ */
3935
+ equals(t) {
3936
+ return this.minX == t.minX && this.minY == t.minY && this.maxX == t.maxX && this.maxY == t.maxY;
3937
+ }
3938
+ /**
3939
+ * @param {TileRange} tileRange Tile range.
3940
+ */
3941
+ extend(t) {
3942
+ t.minX < this.minX && (this.minX = t.minX), t.maxX > this.maxX && (this.maxX = t.maxX), t.minY < this.minY && (this.minY = t.minY), t.maxY > this.maxY && (this.maxY = t.maxY);
3943
+ }
3944
+ /**
3945
+ * @return {number} Height.
3946
+ */
3947
+ getHeight() {
3948
+ return this.maxY - this.minY + 1;
3949
+ }
3950
+ /**
3951
+ * @return {import("./size.js").Size} Size.
3952
+ */
3953
+ getSize() {
3954
+ return [this.getWidth(), this.getHeight()];
3955
+ }
3956
+ /**
3957
+ * @return {number} Width.
3958
+ */
3959
+ getWidth() {
3960
+ return this.maxX - this.minX + 1;
3961
+ }
3962
+ /**
3963
+ * @param {TileRange} tileRange Tile range.
3964
+ * @return {boolean} Intersects.
3965
+ */
3966
+ intersects(t) {
3967
+ return this.minX <= t.maxX && this.maxX >= t.minX && this.minY <= t.maxY && this.maxY >= t.minY;
3968
+ }
3969
+ }
3970
+ function O(i, t, e, n, s) {
3971
+ return s !== void 0 ? (s.minX = i, s.maxX = t, s.minY = e, s.maxY = n, s) : new je(i, t, e, n);
3972
+ }
3973
+ function Ni(i) {
3974
+ const t = Object.keys(i.defs), e = t.length;
3975
+ let n, s;
3976
+ for (n = 0; n < e; ++n) {
3977
+ const r = t[n];
3978
+ if (!it(r)) {
3979
+ const o = i.defs(r);
3980
+ let a = (
3981
+ /** @type {import("./Units.js").Units} */
3982
+ o.units
3983
+ );
3984
+ !a && o.projName === "longlat" && (a = "degrees"), ut(
3985
+ new ft({
3986
+ code: r,
3987
+ axisOrientation: o.axis,
3988
+ metersPerUnit: o.to_meter,
3989
+ units: a
3990
+ })
3991
+ );
3992
+ }
3993
+ }
3994
+ for (n = 0; n < e; ++n) {
3995
+ const r = t[n], o = it(r);
3996
+ for (s = 0; s < e; ++s) {
3997
+ const a = t[s], l = it(a);
3998
+ if (!st(r, a))
3999
+ if (i.defs[r] === i.defs[a])
4000
+ yt([o, l]);
4001
+ else {
4002
+ const h = i(r, a);
4003
+ Wn(
4004
+ o,
4005
+ l,
4006
+ Jt(o, l, h.forward),
4007
+ Jt(l, o, h.inverse)
4008
+ );
4009
+ }
4010
+ }
4011
+ }
4012
+ }
4013
+ function ae(i, t, e, n) {
4014
+ return n !== void 0 ? (n[0] = i, n[1] = t, n[2] = e, n) : [i, t, e];
4015
+ }
4016
+ const L = [0, 0, 0], v = 5;
4017
+ class Yi {
4018
+ /**
4019
+ * @param {Options} options Tile grid options.
4020
+ */
4021
+ constructor(t) {
4022
+ this.minZoom = t.minZoom !== void 0 ? t.minZoom : 0, this.resolutions_ = t.resolutions, y(
4023
+ We(
4024
+ this.resolutions_,
4025
+ /**
4026
+ * @param {number} a First resolution
4027
+ * @param {number} b Second resolution
4028
+ * @return {number} Comparison result
4029
+ */
4030
+ (s, r) => r - s
4031
+ ),
4032
+ "`resolutions` must be sorted in descending order"
4033
+ );
4034
+ let e;
4035
+ if (!t.origins) {
4036
+ for (let s = 0, r = this.resolutions_.length - 1; s < r; ++s)
4037
+ if (!e)
4038
+ e = this.resolutions_[s] / this.resolutions_[s + 1];
4039
+ else if (this.resolutions_[s] / this.resolutions_[s + 1] !== e) {
4040
+ e = void 0;
4041
+ break;
4042
+ }
4043
+ }
4044
+ this.zoomFactor_ = e, this.maxZoom = this.resolutions_.length - 1, this.origin_ = t.origin !== void 0 ? t.origin : null, this.origins_ = null, t.origins !== void 0 && (this.origins_ = t.origins, y(
4045
+ this.origins_.length == this.resolutions_.length,
4046
+ "Number of `origins` and `resolutions` must be equal"
4047
+ ));
4048
+ const n = t.extent;
4049
+ n !== void 0 && !this.origin_ && !this.origins_ && (this.origin_ = _e(n)), y(
4050
+ !this.origin_ && this.origins_ || this.origin_ && !this.origins_,
4051
+ "Either `origin` or `origins` must be configured, never both"
4052
+ ), this.tileSizes_ = null, t.tileSizes !== void 0 && (this.tileSizes_ = t.tileSizes, y(
4053
+ this.tileSizes_.length == this.resolutions_.length,
4054
+ "Number of `tileSizes` and `resolutions` must be equal"
4055
+ )), this.tileSize_ = t.tileSize !== void 0 ? t.tileSize : this.tileSizes_ ? null : Ze, y(
4056
+ !this.tileSize_ && this.tileSizes_ || this.tileSize_ && !this.tileSizes_,
4057
+ "Either `tileSize` or `tileSizes` must be configured, never both"
4058
+ ), this.extent_ = n !== void 0 ? n : null, this.fullTileRanges_ = null, this.tmpSize_ = [0, 0], this.tmpExtent_ = [0, 0, 0, 0], t.sizes !== void 0 ? this.fullTileRanges_ = t.sizes.map((s, r) => {
4059
+ const o = new je(
4060
+ Math.min(0, s[0]),
4061
+ Math.max(s[0] - 1, -1),
4062
+ Math.min(0, s[1]),
4063
+ Math.max(s[1] - 1, -1)
4064
+ );
4065
+ if (n) {
4066
+ const a = this.getTileRangeForExtentAndZ(n, r);
4067
+ o.minX = Math.max(a.minX, o.minX), o.maxX = Math.min(a.maxX, o.maxX), o.minY = Math.max(a.minY, o.minY), o.maxY = Math.min(a.maxY, o.maxY);
4068
+ }
4069
+ return o;
4070
+ }) : n && this.calculateTileRanges_(n);
4071
+ }
4072
+ /**
4073
+ * Call a function with each tile coordinate for a given extent and zoom level.
4074
+ *
4075
+ * @param {import("../extent.js").Extent} extent Extent.
4076
+ * @param {number} zoom Integer zoom level.
4077
+ * @param {function(import("../tilecoord.js").TileCoord): void} callback Function called with each tile coordinate.
4078
+ * @api
4079
+ */
4080
+ forEachTileCoord(t, e, n) {
4081
+ const s = this.getTileRangeForExtentAndZ(t, e);
4082
+ for (let r = s.minX, o = s.maxX; r <= o; ++r)
4083
+ for (let a = s.minY, l = s.maxY; a <= l; ++a)
4084
+ n([e, r, a]);
4085
+ }
4086
+ /**
4087
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
4088
+ * @param {function(number, import("../TileRange.js").default): boolean} callback Callback.
4089
+ * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
4090
+ * @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object.
4091
+ * @return {boolean} Callback succeeded.
4092
+ */
4093
+ forEachTileCoordParentTileRange(t, e, n, s) {
4094
+ let r, o, a, l = null, h = t[0] - 1;
4095
+ for (this.zoomFactor_ === 2 ? (o = t[1], a = t[2]) : l = this.getTileCoordExtent(t, s); h >= this.minZoom; ) {
4096
+ if (o !== void 0 && a !== void 0 ? (o = Math.floor(o / 2), a = Math.floor(a / 2), r = O(o, o, a, a, n)) : r = this.getTileRangeForExtentAndZ(
4097
+ l,
4098
+ h,
4099
+ n
4100
+ ), e(h, r))
4101
+ return !0;
4102
+ --h;
4103
+ }
4104
+ return !1;
4105
+ }
4106
+ /**
4107
+ * Get the extent for this tile grid, if it was configured.
4108
+ * @return {import("../extent.js").Extent} Extent.
4109
+ * @api
4110
+ */
4111
+ getExtent() {
4112
+ return this.extent_;
4113
+ }
4114
+ /**
4115
+ * Get the maximum zoom level for the grid.
4116
+ * @return {number} Max zoom.
4117
+ * @api
4118
+ */
4119
+ getMaxZoom() {
4120
+ return this.maxZoom;
4121
+ }
4122
+ /**
4123
+ * Get the minimum zoom level for the grid.
4124
+ * @return {number} Min zoom.
4125
+ * @api
4126
+ */
4127
+ getMinZoom() {
4128
+ return this.minZoom;
4129
+ }
4130
+ /**
4131
+ * Get the origin for the grid at the given zoom level.
4132
+ * @param {number} z Integer zoom level.
4133
+ * @return {import("../coordinate.js").Coordinate} Origin.
4134
+ * @api
4135
+ */
4136
+ getOrigin(t) {
4137
+ return this.origin_ ? this.origin_ : this.origins_[t];
4138
+ }
4139
+ /**
4140
+ * Get the resolution for the given zoom level.
4141
+ * @param {number} z Integer zoom level.
4142
+ * @return {number} Resolution.
4143
+ * @api
4144
+ */
4145
+ getResolution(t) {
4146
+ return this.resolutions_[t];
4147
+ }
4148
+ /**
4149
+ * Get the list of resolutions for the tile grid.
4150
+ * @return {Array<number>} Resolutions.
4151
+ * @api
4152
+ */
4153
+ getResolutions() {
4154
+ return this.resolutions_;
4155
+ }
4156
+ /**
4157
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
4158
+ * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
4159
+ * @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object.
4160
+ * @return {import("../TileRange.js").default|null} Tile range.
4161
+ */
4162
+ getTileCoordChildTileRange(t, e, n) {
4163
+ if (t[0] < this.maxZoom) {
4164
+ if (this.zoomFactor_ === 2) {
4165
+ const r = t[1] * 2, o = t[2] * 2;
4166
+ return O(
4167
+ r,
4168
+ r + 1,
4169
+ o,
4170
+ o + 1,
4171
+ e
4172
+ );
4173
+ }
4174
+ const s = this.getTileCoordExtent(
4175
+ t,
4176
+ n || this.tmpExtent_
4177
+ );
4178
+ return this.getTileRangeForExtentAndZ(
4179
+ s,
4180
+ t[0] + 1,
4181
+ e
4182
+ );
4183
+ }
4184
+ return null;
4185
+ }
4186
+ /**
4187
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
4188
+ * @param {number} z Integer zoom level.
4189
+ * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
4190
+ * @return {import("../TileRange.js").default|null} Tile range.
4191
+ */
4192
+ getTileRangeForTileCoordAndZ(t, e, n) {
4193
+ if (e > this.maxZoom || e < this.minZoom)
4194
+ return null;
4195
+ const s = t[0], r = t[1], o = t[2];
4196
+ if (e === s)
4197
+ return O(
4198
+ r,
4199
+ o,
4200
+ r,
4201
+ o,
4202
+ n
4203
+ );
4204
+ if (this.zoomFactor_) {
4205
+ const l = Math.pow(this.zoomFactor_, e - s), h = Math.floor(r * l), u = Math.floor(o * l);
4206
+ if (e < s)
4207
+ return O(h, h, u, u, n);
4208
+ const c = Math.floor(l * (r + 1)) - 1, f = Math.floor(l * (o + 1)) - 1;
4209
+ return O(h, c, u, f, n);
4210
+ }
4211
+ const a = this.getTileCoordExtent(t, this.tmpExtent_);
4212
+ return this.getTileRangeForExtentAndZ(a, e, n);
4213
+ }
4214
+ /**
4215
+ * Get a tile range for the given extent and integer zoom level.
4216
+ * @param {import("../extent.js").Extent} extent Extent.
4217
+ * @param {number} z Integer zoom level.
4218
+ * @param {import("../TileRange.js").default} [tempTileRange] Temporary tile range object.
4219
+ * @return {import("../TileRange.js").default} Tile range.
4220
+ */
4221
+ getTileRangeForExtentAndZ(t, e, n) {
4222
+ this.getTileCoordForXYAndZ_(t[0], t[3], e, !1, L);
4223
+ const s = L[1], r = L[2];
4224
+ this.getTileCoordForXYAndZ_(t[2], t[1], e, !0, L);
4225
+ const o = L[1], a = L[2];
4226
+ return O(s, o, r, a, n);
4227
+ }
4228
+ /**
4229
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
4230
+ * @return {import("../coordinate.js").Coordinate} Tile center.
4231
+ */
4232
+ getTileCoordCenter(t) {
4233
+ const e = this.getOrigin(t[0]), n = this.getResolution(t[0]), s = et(this.getTileSize(t[0]), this.tmpSize_);
4234
+ return [
4235
+ e[0] + (t[1] + 0.5) * s[0] * n,
4236
+ e[1] - (t[2] + 0.5) * s[1] * n
4237
+ ];
4238
+ }
4239
+ /**
4240
+ * Get the extent of a tile coordinate.
4241
+ *
4242
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
4243
+ * @param {import("../extent.js").Extent} [tempExtent] Temporary extent object.
4244
+ * @return {import("../extent.js").Extent} Extent.
4245
+ * @api
4246
+ */
4247
+ getTileCoordExtent(t, e) {
4248
+ const n = this.getOrigin(t[0]), s = this.getResolution(t[0]), r = et(this.getTileSize(t[0]), this.tmpSize_), o = n[0] + t[1] * r[0] * s, a = n[1] - (t[2] + 1) * r[1] * s, l = o + r[0] * s, h = a + r[1] * s;
4249
+ return ct(o, a, l, h, e);
4250
+ }
4251
+ /**
4252
+ * Get the tile coordinate for the given map coordinate and resolution. This
4253
+ * method considers that coordinates that intersect tile boundaries should be
4254
+ * assigned the higher tile coordinate.
4255
+ *
4256
+ * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
4257
+ * @param {number} resolution Resolution.
4258
+ * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
4259
+ * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
4260
+ * @api
4261
+ */
4262
+ getTileCoordForCoordAndResolution(t, e, n) {
4263
+ return this.getTileCoordForXYAndResolution_(
4264
+ t[0],
4265
+ t[1],
4266
+ e,
4267
+ !1,
4268
+ n
4269
+ );
4270
+ }
4271
+ /**
4272
+ * Note that this method should not be called for resolutions that correspond
4273
+ * to an integer zoom level. Instead call the `getTileCoordForXYAndZ_` method.
4274
+ * @param {number} x X.
4275
+ * @param {number} y Y.
4276
+ * @param {number} resolution Resolution (for a non-integer zoom level).
4277
+ * @param {boolean} reverseIntersectionPolicy Instead of letting edge
4278
+ * intersections go to the higher tile coordinate, let edge intersections
4279
+ * go to the lower tile coordinate.
4280
+ * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
4281
+ * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
4282
+ * @private
4283
+ */
4284
+ getTileCoordForXYAndResolution_(t, e, n, s, r) {
4285
+ const o = this.getZForResolution(n), a = n / this.getResolution(o), l = this.getOrigin(o), h = et(this.getTileSize(o), this.tmpSize_);
4286
+ let u = a * (t - l[0]) / n / h[0], c = a * (l[1] - e) / n / h[1];
4287
+ return s ? (u = J(u, v) - 1, c = J(c, v) - 1) : (u = K(u, v), c = K(c, v)), ae(o, u, c, r);
4288
+ }
4289
+ /**
4290
+ * Although there is repetition between this method and `getTileCoordForXYAndResolution_`,
4291
+ * they should have separate implementations. This method is for integer zoom
4292
+ * levels. The other method should only be called for resolutions corresponding
4293
+ * to non-integer zoom levels.
4294
+ * @param {number} x Map x coordinate.
4295
+ * @param {number} y Map y coordinate.
4296
+ * @param {number} z Integer zoom level.
4297
+ * @param {boolean} reverseIntersectionPolicy Instead of letting edge
4298
+ * intersections go to the higher tile coordinate, let edge intersections
4299
+ * go to the lower tile coordinate.
4300
+ * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
4301
+ * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
4302
+ * @private
4303
+ */
4304
+ getTileCoordForXYAndZ_(t, e, n, s, r) {
4305
+ const o = this.getOrigin(n), a = this.getResolution(n), l = et(this.getTileSize(n), this.tmpSize_);
4306
+ let h = (t - o[0]) / a / l[0], u = (o[1] - e) / a / l[1];
4307
+ return s ? (h = J(h, v) - 1, u = J(u, v) - 1) : (h = K(h, v), u = K(u, v)), ae(n, h, u, r);
4308
+ }
4309
+ /**
4310
+ * Get a tile coordinate given a map coordinate and zoom level.
4311
+ * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
4312
+ * @param {number} z Integer zoom level, e.g. the result of a `getZForResolution()` method call
4313
+ * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
4314
+ * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
4315
+ * @api
4316
+ */
4317
+ getTileCoordForCoordAndZ(t, e, n) {
4318
+ return this.getTileCoordForXYAndZ_(
4319
+ t[0],
4320
+ t[1],
4321
+ e,
4322
+ !1,
4323
+ n
4324
+ );
4325
+ }
4326
+ /**
4327
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
4328
+ * @return {number} Tile resolution.
4329
+ */
4330
+ getTileCoordResolution(t) {
4331
+ return this.resolutions_[t[0]];
4332
+ }
4333
+ /**
4334
+ * Get the tile size for a zoom level. The type of the return value matches the
4335
+ * `tileSize` or `tileSizes` that the tile grid was configured with. To always
4336
+ * get an {@link import("../size.js").Size}, run the result through {@link module:ol/size.toSize}.
4337
+ * @param {number} z Z.
4338
+ * @return {number|import("../size.js").Size} Tile size.
4339
+ * @api
4340
+ */
4341
+ getTileSize(t) {
4342
+ return this.tileSize_ ? this.tileSize_ : this.tileSizes_[t];
4343
+ }
4344
+ /**
4345
+ * @param {number} z Zoom level.
4346
+ * @return {import("../TileRange.js").default|null} Extent tile range for the specified zoom level.
4347
+ */
4348
+ getFullTileRange(t) {
4349
+ return this.fullTileRanges_ ? this.fullTileRanges_[t] : this.extent_ ? this.getTileRangeForExtentAndZ(this.extent_, t) : null;
4350
+ }
4351
+ /**
4352
+ * @param {number} resolution Resolution.
4353
+ * @param {number|import("../array.js").NearestDirectionFunction} [opt_direction]
4354
+ * If 0, the nearest resolution will be used.
4355
+ * If 1, the nearest higher resolution (lower Z) will be used. If -1, the
4356
+ * nearest lower resolution (higher Z) will be used. Default is 0.
4357
+ * Use a {@link module:ol/array~NearestDirectionFunction} for more precise control.
4358
+ *
4359
+ * For example to change tile Z at the midpoint of zoom levels
4360
+ * ```js
4361
+ * function(value, high, low) {
4362
+ * return value - low * Math.sqrt(high / low);
4363
+ * }
4364
+ * ```
4365
+ * @return {number} Z.
4366
+ * @api
4367
+ */
4368
+ getZForResolution(t, e) {
4369
+ const n = wt(
4370
+ this.resolutions_,
4371
+ t,
4372
+ e || 0
4373
+ );
4374
+ return p(n, this.minZoom, this.maxZoom);
4375
+ }
4376
+ /**
4377
+ * The tile with the provided tile coordinate intersects the given viewport.
4378
+ * @param {import('../tilecoord.js').TileCoord} tileCoord Tile coordinate.
4379
+ * @param {Array<number>} viewport Viewport as returned from {@link module:ol/extent.getRotatedViewport}.
4380
+ * @return {boolean} The tile with the provided tile coordinate intersects the given viewport.
4381
+ */
4382
+ tileCoordIntersectsViewport(t, e) {
4383
+ return Ne(
4384
+ e,
4385
+ 0,
4386
+ e.length,
4387
+ 2,
4388
+ this.getTileCoordExtent(t)
4389
+ );
4390
+ }
4391
+ /**
4392
+ * @param {!import("../extent.js").Extent} extent Extent for this tile grid.
4393
+ * @private
4394
+ */
4395
+ calculateTileRanges_(t) {
4396
+ const e = this.resolutions_.length, n = new Array(e);
4397
+ for (let s = this.minZoom; s < e; ++s)
4398
+ n[s] = this.getTileRangeForExtentAndZ(t, s);
4399
+ this.fullTileRanges_ = n;
4400
+ }
4401
+ }
4402
+ class Zi extends Yi {
4403
+ /**
4404
+ * @param {Options} options WMTS options.
4405
+ */
4406
+ constructor(t) {
4407
+ super({
4408
+ extent: t.extent,
4409
+ origin: t.origin,
4410
+ origins: t.origins,
4411
+ resolutions: t.resolutions,
4412
+ tileSize: t.tileSize,
4413
+ tileSizes: t.tileSizes,
4414
+ sizes: t.sizes
4415
+ }), this.matrixIds_ = t.matrixIds;
4416
+ }
4417
+ /**
4418
+ * @param {number} z Z.
4419
+ * @return {string} MatrixId..
4420
+ */
4421
+ getMatrixId(t) {
4422
+ return this.matrixIds_[t];
4423
+ }
4424
+ /**
4425
+ * Get the list of matrix identifiers.
4426
+ * @return {Array<string>} MatrixIds.
4427
+ * @api
4428
+ */
4429
+ getMatrixIds() {
4430
+ return this.matrixIds_;
4431
+ }
4432
+ }
4433
+ function Gi(i) {
4434
+ Oe(i), Ni(i);
4435
+ }
4436
+ function ji(i) {
4437
+ const t = P.getResolutionSteps(), e = t.find(
4438
+ (n) => n.resolution === i
4439
+ );
4440
+ return e ? t.indexOf(e) : t.length - 1;
4441
+ }
4442
+ function Oi(i = 0.25) {
4443
+ const t = ji(i);
4444
+ let e = P.getResolutionSteps();
4445
+ return e.length > t && (e = e.slice(0, t + 1)), new Zi({
4446
+ resolutions: e.map((n) => n.resolution),
4447
+ origin: P.getTileOrigin(),
4448
+ matrixIds: e.map((n, s) => s.toString()),
4449
+ extent: P.bounds?.flatten
4450
+ });
4451
+ }
4452
+ function Li() {
4453
+ return new Ai({
4454
+ projection: P.epsg,
4455
+ center: P.bounds.center,
4456
+ zoom: P.getDefaultZoom(),
4457
+ minResolution: _t[_t.length - 1],
4458
+ resolutions: _t,
4459
+ extent: P.bounds.flatten,
4460
+ constrainOnlyCenter: !0
4461
+ });
4462
+ }
4463
+ export {
4464
+ Oi as getLV95TileGrid,
4465
+ Li as getLV95View,
4466
+ Gi as registerSwissGeoProjections
4467
+ };