zhihao-ui 1.2.11 → 1.2.12

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 (31) hide show
  1. package/dist/es/{BaseInfo-Dv-eon6t.js → BaseInfo-CX8jhSiU.js} +1 -1
  2. package/dist/es/{Button-DBbUF88w.js → Button-Dayz-XVx.js} +2 -2
  3. package/dist/es/{DatePicker-CWQoV03Q.js → DatePicker-vfIj425T.js} +2 -2
  4. package/dist/es/{DetailHeader-C_mAB8-2.js → DetailHeader-DrlhwY52.js} +3 -3
  5. package/dist/es/{DetailSubTitle-DD7Yllhf.js → DetailSubTitle-QEEHnjR_.js} +2 -2
  6. package/dist/es/{Dialog-DyDSVm-6.js → Dialog-CLQwwXs6.js} +3 -3
  7. package/dist/es/{DiyDataTable-CpkKeWkY.js → DiyDataTable-CjU8lE1d.js} +4 -4
  8. package/dist/es/{EditInfoPair-D0b5jY5Y.js → EditInfoPair-BAkhPrrp.js} +3 -3
  9. package/dist/es/{FileWrapper-CMSYWmEz.js → FileWrapper-WvZK7e6H.js} +4 -4
  10. package/dist/es/{Grid-B5O9dZNI.js → Grid-B8GjLkPJ.js} +1 -1
  11. package/dist/es/{InfoPair-Do3sSVw-.js → InfoPair-CVRcV6zN.js} +3 -3
  12. package/dist/es/{Input-DVpd0Yte.js → Input-D3aG3Fqg.js} +3 -3
  13. package/dist/es/{Loading-DwtfOhMD.js → Loading-CJ0YVxxE.js} +2 -2
  14. package/dist/es/{Map-B8_d8utt.js → Map-CjPsc0XI.js} +827 -712
  15. package/dist/es/{MessageBox-BowhqMYW.js → MessageBox-CMjFYHiw.js} +2 -2
  16. package/dist/es/{MoneyInput-CaTrJLi1.js → MoneyInput-Ctz5oyHG.js} +5 -5
  17. package/dist/es/{PageHeadPanel-_mKu2rMQ.js → PageHeadPanel-B13UDwTh.js} +2 -2
  18. package/dist/es/{ToolTips-BTCP0N--.js → ToolTips-ZGKTR5KG.js} +3 -3
  19. package/dist/es/index.js +21 -21
  20. package/dist/es/{utils-DZ8-2Fg2.js → utils-DR-4CNcy.js} +1 -1
  21. package/dist/es/{vendor-BY-fHNA3.js → vendor-qv9XzgYI.js} +1595 -1595
  22. package/dist/index.css +1 -1
  23. package/dist/types/components/Map/Map.vue.d.ts +7 -3
  24. package/dist/types/components/Map/components/toolPanel.vue.d.ts +16 -1
  25. package/dist/types/components/Map/index.d.ts +30 -12
  26. package/dist/types/components/Map/render/canvasRender/renderTrackStyle.d.ts +1 -0
  27. package/dist/types/components/Map/render/drawPolygon.d.ts +2 -2
  28. package/dist/types/components/Map/render/renderTrack.d.ts +2 -2
  29. package/dist/umd/index.css +1 -1
  30. package/dist/umd/index.umd.cjs +16 -16
  31. package/package.json +1 -1
@@ -45384,1950 +45384,1950 @@ class N6 extends $l {
45384
45384
  Object.assign(this.styleVariables_, e), this.changed();
45385
45385
  }
45386
45386
  }
45387
- const dh = "units", R8 = [1, 2, 5], Sa = 25.4 / 0.28;
45388
- class $6 extends md {
45389
- /**
45390
- * @param {Options} [options] Scale line options.
45391
- */
45392
- constructor(e) {
45393
- e = e || {};
45394
- const n = document.createElement("div");
45395
- n.style.pointerEvents = "none", super({
45396
- element: n,
45397
- render: e.render,
45398
- target: e.target
45399
- }), this.on, this.once, this.un;
45400
- const i = e.className !== void 0 ? e.className : e.bar ? "ol-scale-bar" : "ol-scale-line";
45401
- this.innerElement_ = document.createElement("div"), this.innerElement_.className = i + "-inner", this.element.className = i + " " + Ll, this.element.appendChild(this.innerElement_), this.viewState_ = null, this.minWidth_ = e.minWidth !== void 0 ? e.minWidth : 64, this.maxWidth_ = e.maxWidth, this.renderedVisible_ = !1, this.renderedWidth_ = void 0, this.renderedHTML_ = "", this.addChangeListener(dh, this.handleUnitsChanged_), this.setUnits(e.units || "metric"), this.scaleBar_ = e.bar || !1, this.scaleBarSteps_ = e.steps || 4, this.scaleBarText_ = e.text || !1, this.dpi_ = e.dpi || void 0;
45387
+ class R8 {
45388
+ constructor() {
45389
+ this.dataProjection = void 0, this.defaultFeatureProjection = void 0, this.featureClass = /** @type {FeatureToFeatureClass<FeatureType>} */
45390
+ Ki, this.supportedMediaTypes = null;
45402
45391
  }
45403
45392
  /**
45404
- * Return the units to use in the scale line.
45405
- * @return {Units} The units
45406
- * to use in the scale line.
45407
- * @observable
45408
- * @api
45393
+ * Adds the data projection to the read options.
45394
+ * @param {Document|Element|Object|string} source Source.
45395
+ * @param {ReadOptions} [options] Options.
45396
+ * @return {ReadOptions|undefined} Options.
45397
+ * @protected
45409
45398
  */
45410
- getUnits() {
45411
- return this.get(dh);
45399
+ getReadOptions(e, n) {
45400
+ if (n) {
45401
+ let i = n.dataProjection ? Vt(n.dataProjection) : this.readProjection(e);
45402
+ n.extent && i && i.getUnits() === "tile-pixels" && (i = Vt(i), i.setWorldExtent(n.extent)), n = {
45403
+ dataProjection: i,
45404
+ featureProjection: n.featureProjection
45405
+ };
45406
+ }
45407
+ return this.adaptOptions(n);
45412
45408
  }
45413
45409
  /**
45414
- * @private
45410
+ * Sets the `dataProjection` on the options, if no `dataProjection`
45411
+ * is set.
45412
+ * @param {WriteOptions|ReadOptions|undefined} options
45413
+ * Options.
45414
+ * @protected
45415
+ * @return {WriteOptions|ReadOptions|undefined}
45416
+ * Updated options.
45415
45417
  */
45416
- handleUnitsChanged_() {
45417
- this.updateElement_();
45418
+ adaptOptions(e) {
45419
+ return Object.assign(
45420
+ {
45421
+ dataProjection: this.dataProjection,
45422
+ featureProjection: this.defaultFeatureProjection,
45423
+ featureClass: this.featureClass
45424
+ },
45425
+ e
45426
+ );
45418
45427
  }
45419
45428
  /**
45420
- * Set the units to use in the scale line.
45421
- * @param {Units} units The units to use in the scale line.
45422
- * @observable
45423
- * @api
45429
+ * @abstract
45430
+ * @return {Type} The format type.
45424
45431
  */
45425
- setUnits(e) {
45426
- this.set(dh, e);
45432
+ getType() {
45433
+ return $e();
45427
45434
  }
45428
45435
  /**
45429
- * Specify the dpi of output device such as printer.
45430
- * @param {number|undefined} dpi The dpi of output device.
45431
- * @api
45436
+ * Read a single feature from a source.
45437
+ *
45438
+ * @abstract
45439
+ * @param {Document|Element|Object|string} source Source.
45440
+ * @param {ReadOptions} [options] Read options.
45441
+ * @return {FeatureType|Array<FeatureType>} Feature.
45432
45442
  */
45433
- setDpi(e) {
45434
- this.dpi_ = e;
45443
+ readFeature(e, n) {
45444
+ return $e();
45435
45445
  }
45436
45446
  /**
45437
- * @private
45447
+ * Read all features from a source.
45448
+ *
45449
+ * @abstract
45450
+ * @param {Document|Element|ArrayBuffer|Object|string} source Source.
45451
+ * @param {ReadOptions} [options] Read options.
45452
+ * @return {Array<FeatureType>} Features.
45438
45453
  */
45439
- updateElement_() {
45440
- const e = this.viewState_;
45441
- if (!e) {
45442
- this.renderedVisible_ && (this.element.style.display = "none", this.renderedVisible_ = !1);
45443
- return;
45444
- }
45445
- const n = e.center, i = e.projection, r = this.getUnits(), s = r == "degrees" ? "degrees" : "m";
45446
- let o = tc(
45447
- i,
45448
- e.resolution,
45449
- n,
45450
- s
45451
- );
45452
- const a = this.minWidth_ * (this.dpi_ || Sa) / Sa, l = this.maxWidth_ !== void 0 ? this.maxWidth_ * (this.dpi_ || Sa) / Sa : void 0;
45453
- let u = a * o, c = "";
45454
- if (r == "degrees") {
45455
- const E = ea.degrees;
45456
- u *= E, u < E / 60 ? (c = "″", o *= 3600) : u < E ? (c = "′", o *= 60) : c = "°";
45457
- } else if (r == "imperial")
45458
- u < 0.9144 ? (c = "in", o /= 0.0254) : u < 1609.344 ? (c = "ft", o /= 0.3048) : (c = "mi", o /= 1609.344);
45459
- else if (r == "nautical")
45460
- o /= 1852, c = "NM";
45461
- else if (r == "metric")
45462
- u < 1e-6 ? (c = "nm", o *= 1e9) : u < 1e-3 ? (c = "μm", o *= 1e6) : u < 1 ? (c = "mm", o *= 1e3) : u < 1e3 ? c = "m" : (c = "km", o /= 1e3);
45463
- else if (r == "us")
45464
- u < 0.9144 ? (c = "in", o *= 39.37) : u < 1609.344 ? (c = "ft", o /= 0.30480061) : (c = "mi", o /= 1609.3472);
45465
- else
45466
- throw new Error("Invalid units");
45467
- let d = 3 * Math.floor(Math.log(a * o) / Math.log(10)), h, p, f, m, _, y;
45468
- for (; ; ) {
45469
- f = Math.floor(d / 3);
45470
- const E = Math.pow(10, f);
45471
- if (h = R8[(d % 3 + 3) % 3] * E, p = Math.round(h / o), isNaN(p)) {
45472
- this.element.style.display = "none", this.renderedVisible_ = !1;
45473
- return;
45474
- }
45475
- if (l !== void 0 && p >= l) {
45476
- h = m, p = _, f = y;
45477
- break;
45478
- } else if (p >= a)
45479
- break;
45480
- m = h, _ = p, y = f, ++d;
45481
- }
45482
- const w = this.scaleBar_ ? this.createScaleBar(p, h, c) : h.toFixed(f < 0 ? -f : 0) + " " + c;
45483
- this.renderedHTML_ != w && (this.innerElement_.innerHTML = w, this.renderedHTML_ = w), this.renderedWidth_ != p && (this.innerElement_.style.width = p + "px", this.renderedWidth_ = p), this.renderedVisible_ || (this.element.style.display = "", this.renderedVisible_ = !0);
45454
+ readFeatures(e, n) {
45455
+ return $e();
45484
45456
  }
45485
45457
  /**
45486
- * @private
45487
- * @param {number} width The current width of the scalebar.
45488
- * @param {number} scale The current scale.
45489
- * @param {string} suffix The suffix to append to the scale text.
45490
- * @return {string} The stringified HTML of the scalebar.
45458
+ * Read a single geometry from a source.
45459
+ *
45460
+ * @abstract
45461
+ * @param {Document|Element|Object|string} source Source.
45462
+ * @param {ReadOptions} [options] Read options.
45463
+ * @return {import("../geom/Geometry.js").default} Geometry.
45491
45464
  */
45492
- createScaleBar(e, n, i) {
45493
- const r = this.getScaleForResolution(), s = r < 1 ? Math.round(1 / r).toLocaleString() + " : 1" : "1 : " + Math.round(r).toLocaleString(), o = this.scaleBarSteps_, a = e / o, l = [this.createMarker("absolute")];
45494
- for (let c = 0; c < o; ++c) {
45495
- const d = c % 2 === 0 ? "ol-scale-singlebar-odd" : "ol-scale-singlebar-even";
45496
- l.push(
45497
- `<div><div class="ol-scale-singlebar ${d}" style="width: ${a}px;"></div>` + this.createMarker("relative") + // render text every second step, except when only 2 steps
45498
- (c % 2 === 0 || o === 2 ? this.createStepText(c, e, !1, n, i) : "") + "</div>"
45499
- );
45500
- }
45501
- return l.push(this.createStepText(o, e, !0, n, i)), (this.scaleBarText_ ? `<div class="ol-scale-text" style="width: ${e}px;">` + s + "</div>" : "") + l.join("");
45465
+ readGeometry(e, n) {
45466
+ return $e();
45502
45467
  }
45503
45468
  /**
45504
- * Creates a marker at given position
45505
- * @param {'absolute'|'relative'} position The position, absolute or relative
45506
- * @return {string} The stringified div containing the marker
45469
+ * Read the projection from a source.
45470
+ *
45471
+ * @abstract
45472
+ * @param {Document|Element|Object|string} source Source.
45473
+ * @return {import("../proj/Projection.js").default|undefined} Projection.
45507
45474
  */
45508
- createMarker(e) {
45509
- return `<div class="ol-scale-step-marker" style="position: ${e}; top: ${e === "absolute" ? 3 : -10}px;"></div>`;
45475
+ readProjection(e) {
45476
+ return $e();
45510
45477
  }
45511
45478
  /**
45512
- * Creates the label for a marker marker at given position
45513
- * @param {number} i The iterator
45514
- * @param {number} width The width the scalebar will currently use
45515
- * @param {boolean} isLast Flag indicating if we add the last step text
45516
- * @param {number} scale The current scale for the whole scalebar
45517
- * @param {string} suffix The suffix for the scale
45518
- * @return {string} The stringified div containing the step text
45479
+ * Encode a feature in this format.
45480
+ *
45481
+ * @abstract
45482
+ * @param {Feature} feature Feature.
45483
+ * @param {WriteOptions} [options] Write options.
45484
+ * @return {string|ArrayBuffer} Result.
45519
45485
  */
45520
- createStepText(e, n, i, r, s) {
45521
- const a = (e === 0 ? 0 : Math.round(r / this.scaleBarSteps_ * e * 100) / 100) + (e === 0 ? "" : " " + s), l = e === 0 ? -3 : n / this.scaleBarSteps_ * -1, u = e === 0 ? 0 : n / this.scaleBarSteps_ * 2;
45522
- return `<div class="ol-scale-step-text" style="margin-left: ${l}px;text-align: ${e === 0 ? "left" : "center"};min-width: ${u}px;left: ${i ? n + "px" : "unset"};">` + a + "</div>";
45486
+ writeFeature(e, n) {
45487
+ return $e();
45523
45488
  }
45524
45489
  /**
45525
- * Returns the appropriate scale for the given resolution and units.
45526
- * @return {number} The appropriate scale.
45490
+ * Encode an array of features in this format.
45491
+ *
45492
+ * @abstract
45493
+ * @param {Array<Feature>} features Features.
45494
+ * @param {WriteOptions} [options] Write options.
45495
+ * @return {string|ArrayBuffer} Result.
45527
45496
  */
45528
- getScaleForResolution() {
45529
- const e = tc(
45530
- this.viewState_.projection,
45531
- this.viewState_.resolution,
45532
- this.viewState_.center,
45533
- "m"
45534
- ), n = this.dpi_ || Sa, i = 1e3 / 25.4;
45535
- return e * i * n;
45497
+ writeFeatures(e, n) {
45498
+ return $e();
45536
45499
  }
45537
45500
  /**
45538
- * Update the scale line element.
45539
- * @param {import("../MapEvent.js").default} mapEvent Map event.
45540
- * @override
45501
+ * Write a single geometry in this format.
45502
+ *
45503
+ * @abstract
45504
+ * @param {import("../geom/Geometry.js").default} geometry Geometry.
45505
+ * @param {WriteOptions} [options] Write options.
45506
+ * @return {string|ArrayBuffer} Result.
45541
45507
  */
45542
- render(e) {
45543
- const n = e.frameState;
45544
- n ? this.viewState_ = n.viewState : this.viewState_ = null, this.updateElement_();
45508
+ writeGeometry(e, n) {
45509
+ return $e();
45545
45510
  }
45546
45511
  }
45547
- const hh = {
45548
- /**
45549
- * Triggered when a tile starts loading.
45550
- * @event module:ol/source/Tile.TileSourceEvent#tileloadstart
45551
- * @api
45552
- */
45553
- TILELOADSTART: "tileloadstart",
45554
- /**
45555
- * Triggered when a tile finishes loading, either when its data is loaded,
45556
- * or when loading was aborted because the tile is no longer needed.
45557
- * @event module:ol/source/Tile.TileSourceEvent#tileloadend
45558
- * @api
45559
- */
45560
- TILELOADEND: "tileloadend",
45561
- /**
45562
- * Triggered if tile loading results in an error. Note that this is not the
45563
- * right place to re-fetch tiles. See {@link module:ol/ImageTile~ImageTile#load}
45564
- * for details.
45565
- * @event module:ol/source/Tile.TileSourceEvent#tileloaderror
45566
- * @api
45567
- */
45568
- TILELOADERROR: "tileloaderror"
45569
- }, bo = [0, 0, 0], ts = 5;
45570
- class Mw {
45571
- /**
45572
- * @param {Options} options Tile grid options.
45573
- */
45574
- constructor(e) {
45575
- this.minZoom = e.minZoom !== void 0 ? e.minZoom : 0, this.resolutions_ = e.resolutions, st(
45576
- c$(
45577
- this.resolutions_,
45578
- /**
45579
- * @param {number} a First resolution
45580
- * @param {number} b Second resolution
45581
- * @return {number} Comparison result
45582
- */
45583
- (r, s) => s - r
45584
- ),
45585
- "`resolutions` must be sorted in descending order"
45586
- );
45587
- let n;
45588
- if (!e.origins) {
45589
- for (let r = 0, s = this.resolutions_.length - 1; r < s; ++r)
45590
- if (!n)
45591
- n = this.resolutions_[r] / this.resolutions_[r + 1];
45592
- else if (this.resolutions_[r] / this.resolutions_[r + 1] !== n) {
45593
- n = void 0;
45594
- break;
45595
- }
45596
- }
45597
- this.zoomFactor_ = n, this.maxZoom = this.resolutions_.length - 1, this.origin_ = e.origin !== void 0 ? e.origin : null, this.origins_ = null, e.origins !== void 0 && (this.origins_ = e.origins, st(
45598
- this.origins_.length == this.resolutions_.length,
45599
- "Number of `origins` and `resolutions` must be equal"
45600
- ));
45601
- const i = e.extent;
45602
- i !== void 0 && !this.origin_ && !this.origins_ && (this.origin_ = $r(i)), st(
45603
- !this.origin_ && this.origins_ || this.origin_ && !this.origins_,
45604
- "Either `origin` or `origins` must be configured, never both"
45605
- ), this.tileSizes_ = null, e.tileSizes !== void 0 && (this.tileSizes_ = e.tileSizes, st(
45606
- this.tileSizes_.length == this.resolutions_.length,
45607
- "Number of `tileSizes` and `resolutions` must be equal"
45608
- )), this.tileSize_ = e.tileSize !== void 0 ? e.tileSize : this.tileSizes_ ? null : _p, st(
45609
- !this.tileSize_ && this.tileSizes_ || this.tileSize_ && !this.tileSizes_,
45610
- "Either `tileSize` or `tileSizes` must be configured, never both"
45611
- ), this.extent_ = i !== void 0 ? i : null, this.fullTileRanges_ = null, this.tmpSize_ = [0, 0], this.tmpExtent_ = [0, 0, 0, 0], e.sizes !== void 0 ? this.fullTileRanges_ = e.sizes.map((r, s) => {
45612
- const o = new Mp(
45613
- Math.min(0, r[0]),
45614
- Math.max(r[0] - 1, -1),
45615
- Math.min(0, r[1]),
45616
- Math.max(r[1] - 1, -1)
45617
- );
45618
- if (i) {
45619
- const a = this.getTileRangeForExtentAndZ(i, s);
45620
- 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);
45621
- }
45622
- return o;
45623
- }) : i && this.calculateTileRanges_(i);
45512
+ function Np(t, e, n) {
45513
+ const i = n ? Vt(n.featureProjection) : null, r = n ? Vt(n.dataProjection) : null;
45514
+ let s = t;
45515
+ if (i && r && !Ou(i, r)) {
45516
+ e && (s = /** @type {T} */
45517
+ t.clone());
45518
+ const o = e ? i : r, a = e ? r : i;
45519
+ o.getUnits() === "tile-pixels" ? s.transform(o, a) : s.applyTransform(tl(o, a));
45520
+ }
45521
+ if (e && n && /** @type {WriteOptions} */
45522
+ n.decimals !== void 0) {
45523
+ const o = Math.pow(
45524
+ 10,
45525
+ /** @type {WriteOptions} */
45526
+ n.decimals
45527
+ ), a = function(l) {
45528
+ for (let u = 0, c = l.length; u < c; ++u)
45529
+ l[u] = Math.round(l[u] * o) / o;
45530
+ return l;
45531
+ };
45532
+ s === t && (s = /** @type {T} */
45533
+ t.clone()), s.applyTransform(a);
45534
+ }
45535
+ return s;
45536
+ }
45537
+ const M8 = {
45538
+ Point: kr,
45539
+ LineString: er,
45540
+ Polygon: or,
45541
+ MultiPoint: Dl,
45542
+ MultiLineString: na,
45543
+ MultiPolygon: ia
45544
+ };
45545
+ function P8(t, e, n) {
45546
+ return Array.isArray(e[0]) ? (O1(t, 0, e, n) || (t = t.slice(), gf(t, 0, e, n)), t) : (sp(t, 0, e, n) || (t = t.slice(), rc(t, 0, e, n)), t);
45547
+ }
45548
+ function Mw(t, e) {
45549
+ var s;
45550
+ const n = t.geometry;
45551
+ if (!n)
45552
+ return [];
45553
+ if (Array.isArray(n))
45554
+ return n.map((o) => Mw({ ...t, geometry: o })).flat();
45555
+ const i = n.type === "MultiPolygon" ? "Polygon" : n.type;
45556
+ if (i === "GeometryCollection" || i === "Circle")
45557
+ throw new Error("Unsupported geometry type: " + i);
45558
+ const r = n.layout.length;
45559
+ return Np(
45560
+ new ri(
45561
+ i,
45562
+ i === "Polygon" ? P8(n.flatCoordinates, n.ends, r) : n.flatCoordinates,
45563
+ (s = n.ends) == null ? void 0 : s.flat(),
45564
+ r,
45565
+ t.properties || {},
45566
+ t.id
45567
+ ).enableSimplifyTransformed(),
45568
+ !1,
45569
+ e
45570
+ );
45571
+ }
45572
+ function $p(t, e) {
45573
+ if (!t)
45574
+ return null;
45575
+ if (Array.isArray(t)) {
45576
+ const i = t.map(
45577
+ (r) => $p(r, e)
45578
+ );
45579
+ return new nl(i);
45580
+ }
45581
+ const n = M8[t.type];
45582
+ return Np(
45583
+ new n(t.flatCoordinates, t.layout, t.ends),
45584
+ !1,
45585
+ e
45586
+ );
45587
+ }
45588
+ class I8 extends R8 {
45589
+ constructor() {
45590
+ super();
45624
45591
  }
45625
45592
  /**
45626
- * Call a function with each tile coordinate for a given extent and zoom level.
45593
+ * @return {import("./Feature.js").Type} Format.
45594
+ * @override
45595
+ */
45596
+ getType() {
45597
+ return "json";
45598
+ }
45599
+ /**
45600
+ * Read a feature. Only works for a single feature. Use `readFeatures` to
45601
+ * read a feature collection.
45627
45602
  *
45628
- * @param {import("../extent.js").Extent} extent Extent.
45629
- * @param {number} zoom Integer zoom level.
45630
- * @param {function(import("../tilecoord.js").TileCoord): void} callback Function called with each tile coordinate.
45603
+ * @param {ArrayBuffer|Document|Element|Object|string} source Source.
45604
+ * @param {import("./Feature.js").ReadOptions} [options] Read options.
45605
+ * @return {FeatureType|Array<FeatureType>} Feature.
45631
45606
  * @api
45607
+ * @override
45632
45608
  */
45633
- forEachTileCoord(e, n, i) {
45634
- const r = this.getTileRangeForExtentAndZ(e, n);
45635
- for (let s = r.minX, o = r.maxX; s <= o; ++s)
45636
- for (let a = r.minY, l = r.maxY; a <= l; ++a)
45637
- i([n, s, a]);
45609
+ readFeature(e, n) {
45610
+ return this.readFeatureFromObject(
45611
+ Eu(e),
45612
+ this.getReadOptions(e, n)
45613
+ );
45638
45614
  }
45639
45615
  /**
45640
- * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
45641
- * @param {function(number, import("../TileRange.js").default): boolean} callback Callback.
45642
- * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
45643
- * @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object.
45644
- * @return {boolean} Callback succeeded.
45616
+ * Read all features. Works with both a single feature and a feature
45617
+ * collection.
45618
+ *
45619
+ * @param {ArrayBuffer|Document|Element|Object|string} source Source.
45620
+ * @param {import("./Feature.js").ReadOptions} [options] Read options.
45621
+ * @return {Array<FeatureType>} Features.
45622
+ * @api
45623
+ * @override
45645
45624
  */
45646
- forEachTileCoordParentTileRange(e, n, i, r) {
45647
- let s, o, a, l = null, u = e[0] - 1;
45648
- for (this.zoomFactor_ === 2 ? (o = e[1], a = e[2]) : l = this.getTileCoordExtent(e, r); u >= this.minZoom; ) {
45649
- if (o !== void 0 && a !== void 0 ? (o = Math.floor(o / 2), a = Math.floor(a / 2), s = mo(o, o, a, a, i)) : s = this.getTileRangeForExtentAndZ(
45650
- l,
45651
- u,
45652
- i
45653
- ), n(u, s))
45654
- return !0;
45655
- --u;
45656
- }
45657
- return !1;
45625
+ readFeatures(e, n) {
45626
+ return this.readFeaturesFromObject(
45627
+ Eu(e),
45628
+ this.getReadOptions(e, n)
45629
+ );
45658
45630
  }
45659
45631
  /**
45660
- * Get the extent for this tile grid, if it was configured.
45661
- * @return {import("../extent.js").Extent} Extent.
45662
- * @api
45632
+ * @abstract
45633
+ * @param {Object} object Object.
45634
+ * @param {import("./Feature.js").ReadOptions} [options] Read options.
45635
+ * @protected
45636
+ * @return {FeatureType|Array<FeatureType>} Feature.
45663
45637
  */
45664
- getExtent() {
45665
- return this.extent_;
45638
+ readFeatureFromObject(e, n) {
45639
+ return $e();
45666
45640
  }
45667
45641
  /**
45668
- * Get the maximum zoom level for the grid.
45669
- * @return {number} Max zoom.
45670
- * @api
45642
+ * @abstract
45643
+ * @param {Object} object Object.
45644
+ * @param {import("./Feature.js").ReadOptions} [options] Read options.
45645
+ * @protected
45646
+ * @return {Array<FeatureType>} Features.
45671
45647
  */
45672
- getMaxZoom() {
45673
- return this.maxZoom;
45648
+ readFeaturesFromObject(e, n) {
45649
+ return $e();
45674
45650
  }
45675
45651
  /**
45676
- * Get the minimum zoom level for the grid.
45677
- * @return {number} Min zoom.
45652
+ * Read a geometry.
45653
+ *
45654
+ * @param {ArrayBuffer|Document|Element|Object|string} source Source.
45655
+ * @param {import("./Feature.js").ReadOptions} [options] Read options.
45656
+ * @return {import("../geom/Geometry.js").default} Geometry.
45678
45657
  * @api
45658
+ * @override
45679
45659
  */
45680
- getMinZoom() {
45681
- return this.minZoom;
45660
+ readGeometry(e, n) {
45661
+ return this.readGeometryFromObject(
45662
+ Eu(e),
45663
+ this.getReadOptions(e, n)
45664
+ );
45682
45665
  }
45683
45666
  /**
45684
- * Get the origin for the grid at the given zoom level.
45685
- * @param {number} z Integer zoom level.
45686
- * @return {import("../coordinate.js").Coordinate} Origin.
45687
- * @api
45667
+ * @abstract
45668
+ * @param {Object} object Object.
45669
+ * @param {import("./Feature.js").ReadOptions} [options] Read options.
45670
+ * @protected
45671
+ * @return {import("../geom/Geometry.js").default} Geometry.
45688
45672
  */
45689
- getOrigin(e) {
45690
- return this.origin_ ? this.origin_ : this.origins_[e];
45673
+ readGeometryFromObject(e, n) {
45674
+ return $e();
45691
45675
  }
45692
45676
  /**
45693
- * Get the resolution for the given zoom level.
45694
- * @param {number} z Integer zoom level.
45695
- * @return {number} Resolution.
45677
+ * Read the projection.
45678
+ *
45679
+ * @param {ArrayBuffer|Document|Element|Object|string} source Source.
45680
+ * @return {import("../proj/Projection.js").default} Projection.
45696
45681
  * @api
45682
+ * @override
45697
45683
  */
45698
- getResolution(e) {
45699
- return this.resolutions_[e];
45684
+ readProjection(e) {
45685
+ return this.readProjectionFromObject(Eu(e));
45700
45686
  }
45701
45687
  /**
45702
- * Get the list of resolutions for the tile grid.
45703
- * @return {Array<number>} Resolutions.
45688
+ * @abstract
45689
+ * @param {Object} object Object.
45690
+ * @protected
45691
+ * @return {import("../proj/Projection.js").default} Projection.
45692
+ */
45693
+ readProjectionFromObject(e) {
45694
+ return $e();
45695
+ }
45696
+ /**
45697
+ * Encode a feature as string.
45698
+ *
45699
+ * @param {import("../Feature.js").default} feature Feature.
45700
+ * @param {import("./Feature.js").WriteOptions} [options] Write options.
45701
+ * @return {string} Encoded feature.
45704
45702
  * @api
45703
+ * @override
45705
45704
  */
45706
- getResolutions() {
45707
- return this.resolutions_;
45705
+ writeFeature(e, n) {
45706
+ return JSON.stringify(this.writeFeatureObject(e, n));
45708
45707
  }
45709
45708
  /**
45710
- * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
45711
- * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
45712
- * @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object.
45713
- * @return {import("../TileRange.js").default|null} Tile range.
45709
+ * @abstract
45710
+ * @param {import("../Feature.js").default} feature Feature.
45711
+ * @param {import("./Feature.js").WriteOptions} [options] Write options.
45712
+ * @return {Object} Object.
45714
45713
  */
45715
- getTileCoordChildTileRange(e, n, i) {
45716
- if (e[0] < this.maxZoom) {
45717
- if (this.zoomFactor_ === 2) {
45718
- const s = e[1] * 2, o = e[2] * 2;
45719
- return mo(
45720
- s,
45721
- s + 1,
45722
- o,
45723
- o + 1,
45724
- n
45725
- );
45726
- }
45727
- const r = this.getTileCoordExtent(
45728
- e,
45729
- i || this.tmpExtent_
45730
- );
45731
- return this.getTileRangeForExtentAndZ(
45732
- r,
45733
- e[0] + 1,
45734
- n
45735
- );
45736
- }
45737
- return null;
45738
- }
45739
- /**
45740
- * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
45741
- * @param {number} z Integer zoom level.
45742
- * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
45743
- * @return {import("../TileRange.js").default|null} Tile range.
45744
- */
45745
- getTileRangeForTileCoordAndZ(e, n, i) {
45746
- if (n > this.maxZoom || n < this.minZoom)
45747
- return null;
45748
- const r = e[0], s = e[1], o = e[2];
45749
- if (n === r)
45750
- return mo(
45751
- s,
45752
- o,
45753
- s,
45754
- o,
45755
- i
45756
- );
45757
- if (this.zoomFactor_) {
45758
- const l = Math.pow(this.zoomFactor_, n - r), u = Math.floor(s * l), c = Math.floor(o * l);
45759
- if (n < r)
45760
- return mo(u, u, c, c, i);
45761
- const d = Math.floor(l * (s + 1)) - 1, h = Math.floor(l * (o + 1)) - 1;
45762
- return mo(u, d, c, h, i);
45763
- }
45764
- const a = this.getTileCoordExtent(e, this.tmpExtent_);
45765
- return this.getTileRangeForExtentAndZ(a, n, i);
45714
+ writeFeatureObject(e, n) {
45715
+ return $e();
45766
45716
  }
45767
45717
  /**
45768
- * Get a tile range for the given extent and integer zoom level.
45769
- * @param {import("../extent.js").Extent} extent Extent.
45770
- * @param {number} z Integer zoom level.
45771
- * @param {import("../TileRange.js").default} [tempTileRange] Temporary tile range object.
45772
- * @return {import("../TileRange.js").default} Tile range.
45718
+ * Encode an array of features as string.
45719
+ *
45720
+ * @param {Array<import("../Feature.js").default>} features Features.
45721
+ * @param {import("./Feature.js").WriteOptions} [options] Write options.
45722
+ * @return {string} Encoded features.
45723
+ * @api
45724
+ * @override
45773
45725
  */
45774
- getTileRangeForExtentAndZ(e, n, i) {
45775
- this.getTileCoordForXYAndZ_(e[0], e[3], n, !1, bo);
45776
- const r = bo[1], s = bo[2];
45777
- this.getTileCoordForXYAndZ_(e[2], e[1], n, !0, bo);
45778
- const o = bo[1], a = bo[2];
45779
- return mo(r, o, s, a, i);
45726
+ writeFeatures(e, n) {
45727
+ return JSON.stringify(this.writeFeaturesObject(e, n));
45780
45728
  }
45781
45729
  /**
45782
- * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
45783
- * @return {import("../coordinate.js").Coordinate} Tile center.
45730
+ * @abstract
45731
+ * @param {Array<import("../Feature.js").default>} features Features.
45732
+ * @param {import("./Feature.js").WriteOptions} [options] Write options.
45733
+ * @return {Object} Object.
45784
45734
  */
45785
- getTileCoordCenter(e) {
45786
- const n = this.getOrigin(e[0]), i = this.getResolution(e[0]), r = $n(this.getTileSize(e[0]), this.tmpSize_);
45787
- return [
45788
- n[0] + (e[1] + 0.5) * r[0] * i,
45789
- n[1] - (e[2] + 0.5) * r[1] * i
45790
- ];
45735
+ writeFeaturesObject(e, n) {
45736
+ return $e();
45791
45737
  }
45792
45738
  /**
45793
- * Get the extent of a tile coordinate.
45739
+ * Encode a geometry as string.
45794
45740
  *
45795
- * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
45796
- * @param {import("../extent.js").Extent} [tempExtent] Temporary extent object.
45797
- * @return {import("../extent.js").Extent} Extent.
45741
+ * @param {import("../geom/Geometry.js").default} geometry Geometry.
45742
+ * @param {import("./Feature.js").WriteOptions} [options] Write options.
45743
+ * @return {string} Encoded geometry.
45798
45744
  * @api
45745
+ * @override
45799
45746
  */
45800
- getTileCoordExtent(e, n) {
45801
- const i = this.getOrigin(e[0]), r = this.getResolution(e[0]), s = $n(this.getTileSize(e[0]), this.tmpSize_), o = i[0] + e[1] * s[0] * r, a = i[1] - (e[2] + 1) * s[1] * r, l = o + s[0] * r, u = a + s[1] * r;
45802
- return Nr(o, a, l, u, n);
45747
+ writeGeometry(e, n) {
45748
+ return JSON.stringify(this.writeGeometryObject(e, n));
45803
45749
  }
45804
45750
  /**
45805
- * Get the tile coordinate for the given map coordinate and resolution. This
45806
- * method considers that coordinates that intersect tile boundaries should be
45807
- * assigned the higher tile coordinate.
45808
- *
45809
- * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
45810
- * @param {number} resolution Resolution.
45811
- * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
45812
- * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
45813
- * @api
45751
+ * @abstract
45752
+ * @param {import("../geom/Geometry.js").default} geometry Geometry.
45753
+ * @param {import("./Feature.js").WriteOptions} [options] Write options.
45754
+ * @return {Object} Object.
45814
45755
  */
45815
- getTileCoordForCoordAndResolution(e, n, i) {
45816
- return this.getTileCoordForXYAndResolution_(
45817
- e[0],
45818
- e[1],
45819
- n,
45820
- !1,
45821
- i
45822
- );
45756
+ writeGeometryObject(e, n) {
45757
+ return $e();
45758
+ }
45759
+ }
45760
+ function Eu(t) {
45761
+ if (typeof t == "string") {
45762
+ const e = JSON.parse(t);
45763
+ return e || null;
45823
45764
  }
45765
+ return t !== null ? t : null;
45766
+ }
45767
+ class $6 extends I8 {
45824
45768
  /**
45825
- * Note that this method should not be called for resolutions that correspond
45826
- * to an integer zoom level. Instead call the `getTileCoordForXYAndZ_` method.
45827
- * @param {number} x X.
45828
- * @param {number} y Y.
45829
- * @param {number} resolution Resolution (for a non-integer zoom level).
45830
- * @param {boolean} reverseIntersectionPolicy Instead of letting edge
45831
- * intersections go to the higher tile coordinate, let edge intersections
45832
- * go to the lower tile coordinate.
45833
- * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
45834
- * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
45835
- * @private
45769
+ * @param {Options<FeatureType>} [options] Options.
45836
45770
  */
45837
- getTileCoordForXYAndResolution_(e, n, i, r, s) {
45838
- const o = this.getZForResolution(i), a = i / this.getResolution(o), l = this.getOrigin(o), u = $n(this.getTileSize(o), this.tmpSize_);
45839
- let c = a * (e - l[0]) / i / u[0], d = a * (l[1] - n) / i / u[1];
45840
- return r ? (c = au(c, ts) - 1, d = au(d, ts) - 1) : (c = ou(c, ts), d = ou(d, ts)), gc(o, c, d, s);
45771
+ constructor(e) {
45772
+ e = e || {}, super(), this.dataProjection = Vt(
45773
+ e.dataProjection ? e.dataProjection : "EPSG:4326"
45774
+ ), e.featureProjection && (this.defaultFeatureProjection = Vt(e.featureProjection)), e.featureClass && (this.featureClass = e.featureClass), this.geometryName_ = e.geometryName, this.extractGeometryName_ = e.extractGeometryName, this.supportedMediaTypes = [
45775
+ "application/geo+json",
45776
+ "application/vnd.geo+json"
45777
+ ];
45841
45778
  }
45842
45779
  /**
45843
- * Although there is repetition between this method and `getTileCoordForXYAndResolution_`,
45844
- * they should have separate implementations. This method is for integer zoom
45845
- * levels. The other method should only be called for resolutions corresponding
45846
- * to non-integer zoom levels.
45847
- * @param {number} x Map x coordinate.
45848
- * @param {number} y Map y coordinate.
45849
- * @param {number} z Integer zoom level.
45850
- * @param {boolean} reverseIntersectionPolicy Instead of letting edge
45851
- * intersections go to the higher tile coordinate, let edge intersections
45852
- * go to the lower tile coordinate.
45853
- * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
45854
- * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
45855
- * @private
45780
+ * @param {Object} object Object.
45781
+ * @param {import("./Feature.js").ReadOptions} [options] Read options.
45782
+ * @protected
45783
+ * @return {FeatureType|Array<FeatureType>} Feature.
45784
+ * @override
45856
45785
  */
45857
- getTileCoordForXYAndZ_(e, n, i, r, s) {
45858
- const o = this.getOrigin(i), a = this.getResolution(i), l = $n(this.getTileSize(i), this.tmpSize_);
45859
- let u = (e - o[0]) / a / l[0], c = (o[1] - n) / a / l[1];
45860
- return r ? (u = au(u, ts) - 1, c = au(c, ts) - 1) : (u = ou(u, ts), c = ou(c, ts)), gc(i, u, c, s);
45786
+ readFeatureFromObject(e, n) {
45787
+ let i = null;
45788
+ e.type === "Feature" ? i = /** @type {GeoJSONFeature} */
45789
+ e : i = {
45790
+ type: "Feature",
45791
+ geometry: (
45792
+ /** @type {GeoJSONGeometry} */
45793
+ e
45794
+ ),
45795
+ properties: null
45796
+ };
45797
+ const r = Bp(i.geometry);
45798
+ if (this.featureClass === ri)
45799
+ return (
45800
+ /** @type {FeatureType|Array<FeatureType>} */
45801
+ Mw(
45802
+ {
45803
+ geometry: r,
45804
+ id: i.id,
45805
+ properties: i.properties
45806
+ },
45807
+ n
45808
+ )
45809
+ );
45810
+ const s = new Ki();
45811
+ return this.geometryName_ ? s.setGeometryName(this.geometryName_) : this.extractGeometryName_ && i.geometry_name && s.setGeometryName(i.geometry_name), s.setGeometry($p(r, n)), "id" in i && s.setId(i.id), i.properties && s.setProperties(i.properties, !0), /** @type {FeatureType|Array<FeatureType>} */
45812
+ s;
45861
45813
  }
45862
45814
  /**
45863
- * Get a tile coordinate given a map coordinate and zoom level.
45864
- * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
45865
- * @param {number} z Integer zoom level, e.g. the result of a `getZForResolution()` method call
45866
- * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
45867
- * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
45868
- * @api
45815
+ * @param {Object} object Object.
45816
+ * @param {import("./Feature.js").ReadOptions} [options] Read options.
45817
+ * @protected
45818
+ * @return {Array<FeatureType>} Features.
45819
+ * @override
45869
45820
  */
45870
- getTileCoordForCoordAndZ(e, n, i) {
45871
- return this.getTileCoordForXYAndZ_(
45872
- e[0],
45873
- e[1],
45874
- n,
45875
- !1,
45876
- i
45821
+ readFeaturesFromObject(e, n) {
45822
+ const i = (
45823
+ /** @type {GeoJSONObject} */
45824
+ e
45825
+ );
45826
+ let r = null;
45827
+ if (i.type === "FeatureCollection") {
45828
+ const s = (
45829
+ /** @type {GeoJSONFeatureCollection} */
45830
+ e
45831
+ );
45832
+ r = [];
45833
+ const o = s.features;
45834
+ for (let a = 0, l = o.length; a < l; ++a) {
45835
+ const u = this.readFeatureFromObject(
45836
+ o[a],
45837
+ n
45838
+ );
45839
+ u && r.push(u);
45840
+ }
45841
+ } else
45842
+ r = [this.readFeatureFromObject(e, n)];
45843
+ return (
45844
+ /** @type {Array<FeatureType>} */
45845
+ r.flat()
45877
45846
  );
45878
45847
  }
45879
45848
  /**
45880
- * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
45881
- * @return {number} Tile resolution.
45849
+ * @param {GeoJSONGeometry} object Object.
45850
+ * @param {import("./Feature.js").ReadOptions} [options] Read options.
45851
+ * @protected
45852
+ * @return {import("../geom/Geometry.js").default} Geometry.
45853
+ * @override
45882
45854
  */
45883
- getTileCoordResolution(e) {
45884
- return this.resolutions_[e[0]];
45855
+ readGeometryFromObject(e, n) {
45856
+ return k8(e, n);
45885
45857
  }
45886
45858
  /**
45887
- * Get the tile size for a zoom level. The type of the return value matches the
45888
- * `tileSize` or `tileSizes` that the tile grid was configured with. To always
45889
- * get an {@link import("../size.js").Size}, run the result through {@link module:ol/size.toSize}.
45890
- * @param {number} z Z.
45891
- * @return {number|import("../size.js").Size} Tile size.
45892
- * @api
45859
+ * @param {Object} object Object.
45860
+ * @protected
45861
+ * @return {import("../proj/Projection.js").default} Projection.
45862
+ * @override
45893
45863
  */
45894
- getTileSize(e) {
45895
- return this.tileSize_ ? this.tileSize_ : this.tileSizes_[e];
45864
+ readProjectionFromObject(e) {
45865
+ const n = e.crs;
45866
+ let i;
45867
+ if (n)
45868
+ if (n.type == "name")
45869
+ i = Vt(n.properties.name);
45870
+ else if (n.type === "EPSG")
45871
+ i = Vt("EPSG:" + n.properties.code);
45872
+ else
45873
+ throw new Error("Unknown SRS type");
45874
+ else
45875
+ i = this.dataProjection;
45876
+ return (
45877
+ /** @type {import("../proj/Projection.js").default} */
45878
+ i
45879
+ );
45896
45880
  }
45897
45881
  /**
45898
- * @param {number} z Zoom level.
45899
- * @return {import("../TileRange.js").default|null} Extent tile range for the specified zoom level.
45882
+ * Encode a feature as a GeoJSON Feature object.
45883
+ *
45884
+ * @param {import("../Feature.js").default} feature Feature.
45885
+ * @param {import("./Feature.js").WriteOptions} [options] Write options.
45886
+ * @return {GeoJSONFeature} Object.
45887
+ * @api
45888
+ * @override
45900
45889
  */
45901
- getFullTileRange(e) {
45902
- return this.fullTileRanges_ ? this.fullTileRanges_[e] : this.extent_ ? this.getTileRangeForExtentAndZ(this.extent_, e) : null;
45890
+ writeFeatureObject(e, n) {
45891
+ n = this.adaptOptions(n);
45892
+ const i = {
45893
+ type: "Feature",
45894
+ geometry: null,
45895
+ properties: null
45896
+ }, r = e.getId();
45897
+ if (r !== void 0 && (i.id = r), !e.hasProperties())
45898
+ return i;
45899
+ const s = e.getProperties(), o = e.getGeometry();
45900
+ return o && (i.geometry = Tf(o, n), delete s[e.getGeometryName()]), Xs(s) || (i.properties = s), i;
45903
45901
  }
45904
45902
  /**
45905
- * @param {number} resolution Resolution.
45906
- * @param {number|import("../array.js").NearestDirectionFunction} [opt_direction]
45907
- * If 0, the nearest resolution will be used.
45908
- * If 1, the nearest higher resolution (lower Z) will be used. If -1, the
45909
- * nearest lower resolution (higher Z) will be used. Default is 0.
45910
- * Use a {@link module:ol/array~NearestDirectionFunction} for more precise control.
45903
+ * Encode an array of features as a GeoJSON object.
45911
45904
  *
45912
- * For example to change tile Z at the midpoint of zoom levels
45913
- * ```js
45914
- * function(value, high, low) {
45915
- * return value - low * Math.sqrt(high / low);
45916
- * }
45917
- * ```
45918
- * @return {number} Z.
45905
+ * @param {Array<import("../Feature.js").default>} features Features.
45906
+ * @param {import("./Feature.js").WriteOptions} [options] Write options.
45907
+ * @return {GeoJSONFeatureCollection} GeoJSON Object.
45919
45908
  * @api
45909
+ * @override
45920
45910
  */
45921
- getZForResolution(e, n) {
45922
- const i = Lg(
45923
- this.resolutions_,
45924
- e,
45925
- n || 0
45926
- );
45927
- return Wt(i, this.minZoom, this.maxZoom);
45911
+ writeFeaturesObject(e, n) {
45912
+ n = this.adaptOptions(n);
45913
+ const i = [];
45914
+ for (let r = 0, s = e.length; r < s; ++r)
45915
+ i.push(this.writeFeatureObject(e[r], n));
45916
+ return {
45917
+ type: "FeatureCollection",
45918
+ features: i
45919
+ };
45928
45920
  }
45929
45921
  /**
45930
- * The tile with the provided tile coordinate intersects the given viewport.
45931
- * @param {import('../tilecoord.js').TileCoord} tileCoord Tile coordinate.
45932
- * @param {Array<number>} viewport Viewport as returned from {@link module:ol/extent.getRotatedViewport}.
45933
- * @return {boolean} The tile with the provided tile coordinate intersects the given viewport.
45922
+ * Encode a geometry as a GeoJSON object.
45923
+ *
45924
+ * @param {import("../geom/Geometry.js").default} geometry Geometry.
45925
+ * @param {import("./Feature.js").WriteOptions} [options] Write options.
45926
+ * @return {GeoJSONGeometry|GeoJSONGeometryCollection} Object.
45927
+ * @api
45928
+ * @override
45934
45929
  */
45935
- tileCoordIntersectsViewport(e, n) {
45936
- return P1(
45937
- n,
45938
- 0,
45939
- n.length,
45940
- 2,
45941
- this.getTileCoordExtent(e)
45942
- );
45930
+ writeGeometryObject(e, n) {
45931
+ return Tf(e, this.adaptOptions(n));
45943
45932
  }
45944
- /**
45945
- * @param {!import("../extent.js").Extent} extent Extent for this tile grid.
45946
- * @private
45947
- */
45948
- calculateTileRanges_(e) {
45949
- const n = this.resolutions_.length, i = new Array(n);
45950
- for (let r = this.minZoom; r < n; ++r)
45951
- i[r] = this.getTileRangeForExtentAndZ(e, r);
45952
- this.fullTileRanges_ = i;
45933
+ }
45934
+ function Bp(t, e) {
45935
+ if (!t)
45936
+ return null;
45937
+ let n;
45938
+ switch (t.type) {
45939
+ case "Point": {
45940
+ n = O8(
45941
+ /** @type {GeoJSONPoint} */
45942
+ t
45943
+ );
45944
+ break;
45945
+ }
45946
+ case "LineString": {
45947
+ n = D8(
45948
+ /** @type {GeoJSONLineString} */
45949
+ t
45950
+ );
45951
+ break;
45952
+ }
45953
+ case "Polygon": {
45954
+ n = $8(
45955
+ /** @type {GeoJSONPolygon} */
45956
+ t
45957
+ );
45958
+ break;
45959
+ }
45960
+ case "MultiPoint": {
45961
+ n = F8(
45962
+ /** @type {GeoJSONMultiPoint} */
45963
+ t
45964
+ );
45965
+ break;
45966
+ }
45967
+ case "MultiLineString": {
45968
+ n = L8(
45969
+ /** @type {GeoJSONMultiLineString} */
45970
+ t
45971
+ );
45972
+ break;
45973
+ }
45974
+ case "MultiPolygon": {
45975
+ n = N8(
45976
+ /** @type {GeoJSONMultiPolygon} */
45977
+ t
45978
+ );
45979
+ break;
45980
+ }
45981
+ case "GeometryCollection": {
45982
+ n = A8(
45983
+ /** @type {GeoJSONGeometryCollection} */
45984
+ t
45985
+ );
45986
+ break;
45987
+ }
45988
+ default:
45989
+ throw new Error("Unsupported GeoJSON type: " + t.type);
45953
45990
  }
45991
+ return n;
45954
45992
  }
45955
- function Pw(t) {
45956
- let e = t.getDefaultTileGrid();
45957
- return e || (e = k8(t), t.setDefaultTileGrid(e)), e;
45993
+ function k8(t, e) {
45994
+ const n = Bp(t);
45995
+ return $p(n, e);
45958
45996
  }
45959
- function M8(t, e, n) {
45960
- const i = e[0], r = t.getTileCoordCenter(e), s = Np(n);
45961
- if (!Jo(s, r)) {
45962
- const o = nt(s), a = Math.ceil(
45963
- (s[0] - r[0]) / o
45964
- );
45965
- return r[0] += o * a, t.getTileCoordForCoordAndZ(r, i);
45966
- }
45967
- return e;
45997
+ function A8(t, e) {
45998
+ return t.geometries.map(
45999
+ /**
46000
+ * @param {GeoJSONGeometry} geometry Geometry.
46001
+ * @return {import("./Feature.js").GeometryObject} geometry Geometry.
46002
+ */
46003
+ function(i) {
46004
+ return Bp(i);
46005
+ }
46006
+ );
45968
46007
  }
45969
- function P8(t, e, n, i) {
45970
- i = i !== void 0 ? i : "top-left";
45971
- const r = Iw(t, e, n);
45972
- return new Mw({
45973
- extent: t,
45974
- origin: w$(t, i),
45975
- resolutions: r,
45976
- tileSize: n
45977
- });
46008
+ function O8(t) {
46009
+ const e = t.coordinates;
46010
+ return {
46011
+ type: "Point",
46012
+ flatCoordinates: e,
46013
+ layout: io(e.length)
46014
+ };
45978
46015
  }
45979
- function I8(t) {
45980
- const e = t || {}, n = e.extent || Vt("EPSG:3857").getExtent(), i = {
45981
- extent: n,
45982
- minZoom: e.minZoom,
45983
- tileSize: e.tileSize,
45984
- resolutions: Iw(
45985
- n,
45986
- e.maxZoom,
45987
- e.tileSize,
45988
- e.maxResolution
45989
- )
46016
+ function D8(t) {
46017
+ var i;
46018
+ const e = t.coordinates, n = e.flat();
46019
+ return {
46020
+ type: "LineString",
46021
+ flatCoordinates: n,
46022
+ ends: [n.length],
46023
+ layout: io(((i = e[0]) == null ? void 0 : i.length) || 2)
45990
46024
  };
45991
- return new Mw(i);
45992
46025
  }
45993
- function Iw(t, e, n, i) {
45994
- e = e !== void 0 ? e : x4, n = $n(n !== void 0 ? n : _p);
45995
- const r = an(t), s = nt(t);
45996
- i = i > 0 ? i : Math.max(s / n[0], r / n[1]);
45997
- const o = e + 1, a = new Array(o);
45998
- for (let l = 0; l < o; ++l)
45999
- a[l] = i / Math.pow(2, l);
46000
- return a;
46026
+ function L8(t) {
46027
+ var s, o;
46028
+ const e = t.coordinates, n = ((o = (s = e[0]) == null ? void 0 : s[0]) == null ? void 0 : o.length) || 2, i = [], r = Ol(i, 0, e, n);
46029
+ return {
46030
+ type: "MultiLineString",
46031
+ flatCoordinates: i,
46032
+ ends: r,
46033
+ layout: io(n)
46034
+ };
46001
46035
  }
46002
- function k8(t, e, n, i) {
46003
- const r = Np(t);
46004
- return P8(r, e, n, i);
46036
+ function F8(t) {
46037
+ var n;
46038
+ const e = t.coordinates;
46039
+ return {
46040
+ type: "MultiPoint",
46041
+ flatCoordinates: e.flat(),
46042
+ layout: io(((n = e[0]) == null ? void 0 : n.length) || 2)
46043
+ };
46005
46044
  }
46006
- function Np(t) {
46007
- t = Vt(t);
46008
- let e = t.getExtent();
46009
- if (!e) {
46010
- const n = 180 * ea.degrees / t.getMetersPerUnit();
46011
- e = Nr(-n, -n, n, n);
46012
- }
46013
- return e;
46045
+ function N8(t) {
46046
+ var s, o;
46047
+ const e = t.coordinates, n = [], i = ((o = (s = e[0]) == null ? void 0 : s[0]) == null ? void 0 : o[0].length) || 2, r = C1(
46048
+ n,
46049
+ 0,
46050
+ e,
46051
+ i
46052
+ );
46053
+ return {
46054
+ type: "MultiPolygon",
46055
+ flatCoordinates: n,
46056
+ ends: r,
46057
+ layout: io(i)
46058
+ };
46014
46059
  }
46015
- class A8 extends L1 {
46016
- /**
46017
- * @param {Options} options SourceTile source options.
46018
- */
46019
- constructor(e) {
46020
- super({
46021
- attributions: e.attributions,
46022
- attributionsCollapsible: e.attributionsCollapsible,
46023
- projection: e.projection,
46024
- state: e.state,
46025
- wrapX: e.wrapX,
46026
- interpolate: e.interpolate
46027
- }), this.on, this.once, this.un, this.tilePixelRatio_ = e.tilePixelRatio !== void 0 ? e.tilePixelRatio : 1, this.tileGrid = e.tileGrid !== void 0 ? e.tileGrid : null;
46028
- const n = [256, 256];
46029
- this.tileGrid && $n(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()), n), this.tmpSize = [0, 0], this.key_ = e.key || Xe(this), this.tileOptions = {
46030
- transition: e.transition,
46031
- interpolate: e.interpolate
46032
- }, this.zDirection = e.zDirection ? e.zDirection : 0;
46033
- }
46034
- /**
46035
- * @param {import("../proj/Projection.js").default} projection Projection.
46036
- * @return {number} Gutter.
46037
- */
46038
- getGutterForProjection(e) {
46039
- return 0;
46060
+ function $8(t) {
46061
+ var s, o;
46062
+ const e = t.coordinates, n = [], i = (o = (s = e[0]) == null ? void 0 : s[0]) == null ? void 0 : o.length, r = Ol(n, 0, e, i);
46063
+ return {
46064
+ type: "Polygon",
46065
+ flatCoordinates: n,
46066
+ ends: r,
46067
+ layout: io(i)
46068
+ };
46069
+ }
46070
+ function Tf(t, e) {
46071
+ t = Np(t, !0, e);
46072
+ const n = t.getType();
46073
+ let i;
46074
+ switch (n) {
46075
+ case "Point": {
46076
+ i = U8(
46077
+ /** @type {import("../geom/Point.js").default} */
46078
+ t
46079
+ );
46080
+ break;
46081
+ }
46082
+ case "LineString": {
46083
+ i = G8(
46084
+ /** @type {import("../geom/LineString.js").default} */
46085
+ t
46086
+ );
46087
+ break;
46088
+ }
46089
+ case "Polygon": {
46090
+ i = V8(
46091
+ /** @type {import("../geom/Polygon.js").default} */
46092
+ t,
46093
+ e
46094
+ );
46095
+ break;
46096
+ }
46097
+ case "MultiPoint": {
46098
+ i = z8(
46099
+ /** @type {import("../geom/MultiPoint.js").default} */
46100
+ t
46101
+ );
46102
+ break;
46103
+ }
46104
+ case "MultiLineString": {
46105
+ i = W8(
46106
+ /** @type {import("../geom/MultiLineString.js").default} */
46107
+ t
46108
+ );
46109
+ break;
46110
+ }
46111
+ case "MultiPolygon": {
46112
+ i = Y8(
46113
+ /** @type {import("../geom/MultiPolygon.js").default} */
46114
+ t,
46115
+ e
46116
+ );
46117
+ break;
46118
+ }
46119
+ case "GeometryCollection": {
46120
+ i = B8(
46121
+ /** @type {import("../geom/GeometryCollection.js").default} */
46122
+ t,
46123
+ e
46124
+ );
46125
+ break;
46126
+ }
46127
+ case "Circle": {
46128
+ i = {
46129
+ type: "GeometryCollection",
46130
+ geometries: []
46131
+ };
46132
+ break;
46133
+ }
46134
+ default:
46135
+ throw new Error("Unsupported geometry type: " + n);
46040
46136
  }
46137
+ return i;
46138
+ }
46139
+ function B8(t, e) {
46140
+ return e = Object.assign({}, e), delete e.featureProjection, {
46141
+ type: "GeometryCollection",
46142
+ geometries: t.getGeometriesArray().map(function(i) {
46143
+ return Tf(i, e);
46144
+ })
46145
+ };
46146
+ }
46147
+ function G8(t, e) {
46148
+ return {
46149
+ type: "LineString",
46150
+ coordinates: t.getCoordinates()
46151
+ };
46152
+ }
46153
+ function W8(t, e) {
46154
+ return {
46155
+ type: "MultiLineString",
46156
+ coordinates: t.getCoordinates()
46157
+ };
46158
+ }
46159
+ function z8(t, e) {
46160
+ return {
46161
+ type: "MultiPoint",
46162
+ coordinates: t.getCoordinates()
46163
+ };
46164
+ }
46165
+ function Y8(t, e) {
46166
+ let n;
46167
+ return e && (n = e.rightHanded), {
46168
+ type: "MultiPolygon",
46169
+ coordinates: t.getCoordinates(n)
46170
+ };
46171
+ }
46172
+ function U8(t, e) {
46173
+ return {
46174
+ type: "Point",
46175
+ coordinates: t.getCoordinates()
46176
+ };
46177
+ }
46178
+ function V8(t, e) {
46179
+ let n;
46180
+ return e && (n = e.rightHanded), {
46181
+ type: "Polygon",
46182
+ coordinates: t.getCoordinates(n)
46183
+ };
46184
+ }
46185
+ const dh = "units", j8 = [1, 2, 5], Sa = 25.4 / 0.28;
46186
+ class B6 extends md {
46041
46187
  /**
46042
- * Return the key to be used for all tiles in the source.
46043
- * @return {string} The key for all tiles.
46188
+ * @param {Options} [options] Scale line options.
46044
46189
  */
46045
- getKey() {
46046
- return this.key_;
46190
+ constructor(e) {
46191
+ e = e || {};
46192
+ const n = document.createElement("div");
46193
+ n.style.pointerEvents = "none", super({
46194
+ element: n,
46195
+ render: e.render,
46196
+ target: e.target
46197
+ }), this.on, this.once, this.un;
46198
+ const i = e.className !== void 0 ? e.className : e.bar ? "ol-scale-bar" : "ol-scale-line";
46199
+ this.innerElement_ = document.createElement("div"), this.innerElement_.className = i + "-inner", this.element.className = i + " " + Ll, this.element.appendChild(this.innerElement_), this.viewState_ = null, this.minWidth_ = e.minWidth !== void 0 ? e.minWidth : 64, this.maxWidth_ = e.maxWidth, this.renderedVisible_ = !1, this.renderedWidth_ = void 0, this.renderedHTML_ = "", this.addChangeListener(dh, this.handleUnitsChanged_), this.setUnits(e.units || "metric"), this.scaleBar_ = e.bar || !1, this.scaleBarSteps_ = e.steps || 4, this.scaleBarText_ = e.text || !1, this.dpi_ = e.dpi || void 0;
46047
46200
  }
46048
46201
  /**
46049
- * Set the value to be used as the key for all tiles in the source.
46050
- * @param {string} key The key for tiles.
46051
- * @protected
46202
+ * Return the units to use in the scale line.
46203
+ * @return {Units} The units
46204
+ * to use in the scale line.
46205
+ * @observable
46206
+ * @api
46052
46207
  */
46053
- setKey(e) {
46054
- this.key_ !== e && (this.key_ = e, this.changed());
46208
+ getUnits() {
46209
+ return this.get(dh);
46055
46210
  }
46056
46211
  /**
46057
- * @param {import("../proj/Projection").default} [projection] Projection.
46058
- * @return {Array<number>|null} Resolutions.
46059
- * @override
46212
+ * @private
46060
46213
  */
46061
- getResolutions(e) {
46062
- const n = e ? this.getTileGridForProjection(e) : this.tileGrid;
46063
- return n ? n.getResolutions() : null;
46214
+ handleUnitsChanged_() {
46215
+ this.updateElement_();
46064
46216
  }
46065
46217
  /**
46066
- * @abstract
46067
- * @param {number} z Tile coordinate z.
46068
- * @param {number} x Tile coordinate x.
46069
- * @param {number} y Tile coordinate y.
46070
- * @param {number} pixelRatio Pixel ratio.
46071
- * @param {import("../proj/Projection.js").default} projection Projection.
46072
- * @return {TileType|null} Tile.
46218
+ * Set the units to use in the scale line.
46219
+ * @param {Units} units The units to use in the scale line.
46220
+ * @observable
46221
+ * @api
46073
46222
  */
46074
- getTile(e, n, i, r, s) {
46075
- return $e();
46223
+ setUnits(e) {
46224
+ this.set(dh, e);
46076
46225
  }
46077
46226
  /**
46078
- * Return the tile grid of the tile source.
46079
- * @return {import("../tilegrid/TileGrid.js").default|null} Tile grid.
46227
+ * Specify the dpi of output device such as printer.
46228
+ * @param {number|undefined} dpi The dpi of output device.
46080
46229
  * @api
46081
46230
  */
46082
- getTileGrid() {
46083
- return this.tileGrid;
46231
+ setDpi(e) {
46232
+ this.dpi_ = e;
46084
46233
  }
46085
46234
  /**
46086
- * @param {import("../proj/Projection.js").default} projection Projection.
46087
- * @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
46235
+ * @private
46088
46236
  */
46089
- getTileGridForProjection(e) {
46090
- return this.tileGrid ? this.tileGrid : Pw(e);
46237
+ updateElement_() {
46238
+ const e = this.viewState_;
46239
+ if (!e) {
46240
+ this.renderedVisible_ && (this.element.style.display = "none", this.renderedVisible_ = !1);
46241
+ return;
46242
+ }
46243
+ const n = e.center, i = e.projection, r = this.getUnits(), s = r == "degrees" ? "degrees" : "m";
46244
+ let o = tc(
46245
+ i,
46246
+ e.resolution,
46247
+ n,
46248
+ s
46249
+ );
46250
+ const a = this.minWidth_ * (this.dpi_ || Sa) / Sa, l = this.maxWidth_ !== void 0 ? this.maxWidth_ * (this.dpi_ || Sa) / Sa : void 0;
46251
+ let u = a * o, c = "";
46252
+ if (r == "degrees") {
46253
+ const E = ea.degrees;
46254
+ u *= E, u < E / 60 ? (c = "″", o *= 3600) : u < E ? (c = "′", o *= 60) : c = "°";
46255
+ } else if (r == "imperial")
46256
+ u < 0.9144 ? (c = "in", o /= 0.0254) : u < 1609.344 ? (c = "ft", o /= 0.3048) : (c = "mi", o /= 1609.344);
46257
+ else if (r == "nautical")
46258
+ o /= 1852, c = "NM";
46259
+ else if (r == "metric")
46260
+ u < 1e-6 ? (c = "nm", o *= 1e9) : u < 1e-3 ? (c = "μm", o *= 1e6) : u < 1 ? (c = "mm", o *= 1e3) : u < 1e3 ? c = "m" : (c = "km", o /= 1e3);
46261
+ else if (r == "us")
46262
+ u < 0.9144 ? (c = "in", o *= 39.37) : u < 1609.344 ? (c = "ft", o /= 0.30480061) : (c = "mi", o /= 1609.3472);
46263
+ else
46264
+ throw new Error("Invalid units");
46265
+ let d = 3 * Math.floor(Math.log(a * o) / Math.log(10)), h, p, f, m, _, y;
46266
+ for (; ; ) {
46267
+ f = Math.floor(d / 3);
46268
+ const E = Math.pow(10, f);
46269
+ if (h = j8[(d % 3 + 3) % 3] * E, p = Math.round(h / o), isNaN(p)) {
46270
+ this.element.style.display = "none", this.renderedVisible_ = !1;
46271
+ return;
46272
+ }
46273
+ if (l !== void 0 && p >= l) {
46274
+ h = m, p = _, f = y;
46275
+ break;
46276
+ } else if (p >= a)
46277
+ break;
46278
+ m = h, _ = p, y = f, ++d;
46279
+ }
46280
+ const w = this.scaleBar_ ? this.createScaleBar(p, h, c) : h.toFixed(f < 0 ? -f : 0) + " " + c;
46281
+ this.renderedHTML_ != w && (this.innerElement_.innerHTML = w, this.renderedHTML_ = w), this.renderedWidth_ != p && (this.innerElement_.style.width = p + "px", this.renderedWidth_ = p), this.renderedVisible_ || (this.element.style.display = "", this.renderedVisible_ = !0);
46091
46282
  }
46092
46283
  /**
46093
- * Get the tile pixel ratio for this source. Subclasses may override this
46094
- * method, which is meant to return a supported pixel ratio that matches the
46095
- * provided `pixelRatio` as close as possible.
46096
- * @param {number} pixelRatio Pixel ratio.
46097
- * @return {number} Tile pixel ratio.
46284
+ * @private
46285
+ * @param {number} width The current width of the scalebar.
46286
+ * @param {number} scale The current scale.
46287
+ * @param {string} suffix The suffix to append to the scale text.
46288
+ * @return {string} The stringified HTML of the scalebar.
46098
46289
  */
46099
- getTilePixelRatio(e) {
46100
- return this.tilePixelRatio_;
46290
+ createScaleBar(e, n, i) {
46291
+ const r = this.getScaleForResolution(), s = r < 1 ? Math.round(1 / r).toLocaleString() + " : 1" : "1 : " + Math.round(r).toLocaleString(), o = this.scaleBarSteps_, a = e / o, l = [this.createMarker("absolute")];
46292
+ for (let c = 0; c < o; ++c) {
46293
+ const d = c % 2 === 0 ? "ol-scale-singlebar-odd" : "ol-scale-singlebar-even";
46294
+ l.push(
46295
+ `<div><div class="ol-scale-singlebar ${d}" style="width: ${a}px;"></div>` + this.createMarker("relative") + // render text every second step, except when only 2 steps
46296
+ (c % 2 === 0 || o === 2 ? this.createStepText(c, e, !1, n, i) : "") + "</div>"
46297
+ );
46298
+ }
46299
+ return l.push(this.createStepText(o, e, !0, n, i)), (this.scaleBarText_ ? `<div class="ol-scale-text" style="width: ${e}px;">` + s + "</div>" : "") + l.join("");
46101
46300
  }
46102
46301
  /**
46103
- * @param {number} z Z.
46104
- * @param {number} pixelRatio Pixel ratio.
46105
- * @param {import("../proj/Projection.js").default} projection Projection.
46106
- * @return {import("../size.js").Size} Tile size.
46302
+ * Creates a marker at given position
46303
+ * @param {'absolute'|'relative'} position The position, absolute or relative
46304
+ * @return {string} The stringified div containing the marker
46107
46305
  */
46108
- getTilePixelSize(e, n, i) {
46109
- const r = this.getTileGridForProjection(i), s = this.getTilePixelRatio(n), o = $n(r.getTileSize(e), this.tmpSize);
46110
- return s == 1 ? o : K3(o, s, this.tmpSize);
46306
+ createMarker(e) {
46307
+ return `<div class="ol-scale-step-marker" style="position: ${e}; top: ${e === "absolute" ? 3 : -10}px;"></div>`;
46111
46308
  }
46112
46309
  /**
46113
- * Returns a tile coordinate wrapped around the x-axis. When the tile coordinate
46114
- * is outside the resolution and extent range of the tile grid, `null` will be
46115
- * returned.
46116
- * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
46117
- * @param {import("../proj/Projection.js").default} [projection] Projection.
46118
- * @return {import("../tilecoord.js").TileCoord} Tile coordinate to be passed to the tileUrlFunction or
46119
- * null if no tile URL should be created for the passed `tileCoord`.
46310
+ * Creates the label for a marker marker at given position
46311
+ * @param {number} i The iterator
46312
+ * @param {number} width The width the scalebar will currently use
46313
+ * @param {boolean} isLast Flag indicating if we add the last step text
46314
+ * @param {number} scale The current scale for the whole scalebar
46315
+ * @param {string} suffix The suffix for the scale
46316
+ * @return {string} The stringified div containing the step text
46120
46317
  */
46121
- getTileCoordForTileUrlFunction(e, n) {
46122
- const i = n !== void 0 ? n : this.getProjection(), r = n !== void 0 ? this.getTileGridForProjection(i) : this.tileGrid || this.getTileGridForProjection(i);
46123
- return this.getWrapX() && i.isGlobal() && (e = M8(r, e, i)), bB(e, r) ? e : null;
46318
+ createStepText(e, n, i, r, s) {
46319
+ const a = (e === 0 ? 0 : Math.round(r / this.scaleBarSteps_ * e * 100) / 100) + (e === 0 ? "" : " " + s), l = e === 0 ? -3 : n / this.scaleBarSteps_ * -1, u = e === 0 ? 0 : n / this.scaleBarSteps_ * 2;
46320
+ return `<div class="ol-scale-step-text" style="margin-left: ${l}px;text-align: ${e === 0 ? "left" : "center"};min-width: ${u}px;left: ${i ? n + "px" : "unset"};">` + a + "</div>";
46124
46321
  }
46125
46322
  /**
46126
- * Remove all cached reprojected tiles from the source. The next render cycle will create new tiles.
46127
- * @api
46323
+ * Returns the appropriate scale for the given resolution and units.
46324
+ * @return {number} The appropriate scale.
46128
46325
  */
46129
- clear() {
46326
+ getScaleForResolution() {
46327
+ const e = tc(
46328
+ this.viewState_.projection,
46329
+ this.viewState_.resolution,
46330
+ this.viewState_.center,
46331
+ "m"
46332
+ ), n = this.dpi_ || Sa, i = 1e3 / 25.4;
46333
+ return e * i * n;
46130
46334
  }
46131
46335
  /**
46336
+ * Update the scale line element.
46337
+ * @param {import("../MapEvent.js").default} mapEvent Map event.
46132
46338
  * @override
46133
46339
  */
46134
- refresh() {
46135
- this.clear(), super.refresh();
46340
+ render(e) {
46341
+ const n = e.frameState;
46342
+ n ? this.viewState_ = n.viewState : this.viewState_ = null, this.updateElement_();
46136
46343
  }
46137
46344
  }
46138
- class O8 extends Ui {
46345
+ const hh = {
46139
46346
  /**
46140
- * @param {string} type Type.
46141
- * @param {import("../Tile.js").default} tile The tile.
46347
+ * Triggered when a tile starts loading.
46348
+ * @event module:ol/source/Tile.TileSourceEvent#tileloadstart
46349
+ * @api
46142
46350
  */
46143
- constructor(e, n) {
46144
- super(e), this.tile = n;
46145
- }
46146
- }
46147
- const D8 = /\{z\}/g, L8 = /\{x\}/g, F8 = /\{y\}/g, N8 = /\{-y\}/g;
46148
- function $8(t, e, n, i, r) {
46149
- return t.replace(D8, e.toString()).replace(L8, n.toString()).replace(F8, i.toString()).replace(N8, function() {
46150
- if (r === void 0)
46151
- throw new Error(
46152
- "If the URL template has a {-y} placeholder, the grid extent must be known"
46153
- );
46154
- return (r - i).toString();
46155
- });
46156
- }
46157
- function B8(t) {
46158
- const e = [];
46159
- let n = /\{([a-z])-([a-z])\}/.exec(t);
46160
- if (n) {
46161
- const i = n[1].charCodeAt(0), r = n[2].charCodeAt(0);
46162
- let s;
46163
- for (s = i; s <= r; ++s)
46164
- e.push(t.replace(n[0], String.fromCharCode(s)));
46165
- return e;
46166
- }
46167
- if (n = /\{(\d+)-(\d+)\}/.exec(t), n) {
46168
- const i = parseInt(n[2], 10);
46169
- for (let r = parseInt(n[1], 10); r <= i; r++)
46170
- e.push(t.replace(n[0], r.toString()));
46171
- return e;
46172
- }
46173
- return e.push(t), e;
46174
- }
46175
- function G8(t, e) {
46176
- return (
46177
- /**
46178
- * @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
46179
- * @param {number} pixelRatio Pixel ratio.
46180
- * @param {import("./proj/Projection.js").default} projection Projection.
46181
- * @return {string|undefined} Tile URL.
46182
- */
46183
- function(n, i, r) {
46184
- if (!n)
46185
- return;
46186
- let s;
46187
- const o = n[0];
46188
- if (e) {
46189
- const a = e.getFullTileRange(o);
46190
- a && (s = a.getHeight() - 1);
46191
- }
46192
- return $8(t, o, n[1], n[2], s);
46193
- }
46194
- );
46195
- }
46196
- function W8(t, e) {
46197
- const n = t.length, i = new Array(n);
46198
- for (let r = 0; r < n; ++r)
46199
- i[r] = G8(t[r], e);
46200
- return z8(i);
46201
- }
46202
- function z8(t) {
46203
- return t.length === 1 ? t[0] : (
46204
- /**
46205
- * @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
46206
- * @param {number} pixelRatio Pixel ratio.
46207
- * @param {import("./proj/Projection.js").default} projection Projection.
46208
- * @return {string|undefined} Tile URL.
46209
- */
46210
- function(e, n, i) {
46211
- if (!e)
46212
- return;
46213
- const r = _B(e), s = Bs(r, t.length);
46214
- return t[s](e, n, i);
46215
- }
46216
- );
46217
- }
46218
- class $p extends A8 {
46351
+ TILELOADSTART: "tileloadstart",
46219
46352
  /**
46220
- * @param {Options} options Image tile options.
46353
+ * Triggered when a tile finishes loading, either when its data is loaded,
46354
+ * or when loading was aborted because the tile is no longer needed.
46355
+ * @event module:ol/source/Tile.TileSourceEvent#tileloadend
46356
+ * @api
46221
46357
  */
46222
- constructor(e) {
46223
- super({
46224
- attributions: e.attributions,
46225
- cacheSize: e.cacheSize,
46226
- projection: e.projection,
46227
- state: e.state,
46228
- tileGrid: e.tileGrid,
46229
- tilePixelRatio: e.tilePixelRatio,
46230
- wrapX: e.wrapX,
46231
- transition: e.transition,
46232
- interpolate: e.interpolate,
46233
- key: e.key,
46234
- attributionsCollapsible: e.attributionsCollapsible,
46235
- zDirection: e.zDirection
46236
- }), this.generateTileUrlFunction_ = this.tileUrlFunction === $p.prototype.tileUrlFunction, this.tileLoadFunction = e.tileLoadFunction, e.tileUrlFunction && (this.tileUrlFunction = e.tileUrlFunction), this.urls = null, e.urls ? this.setUrls(e.urls) : e.url && this.setUrl(e.url), this.tileLoadingKeys_ = {};
46237
- }
46358
+ TILELOADEND: "tileloadend",
46238
46359
  /**
46239
- * Deprecated. Use an ImageTile source instead.
46240
- * Return the tile load function of the source.
46241
- * @return {import("../Tile.js").LoadFunction} TileLoadFunction
46360
+ * Triggered if tile loading results in an error. Note that this is not the
46361
+ * right place to re-fetch tiles. See {@link module:ol/ImageTile~ImageTile#load}
46362
+ * for details.
46363
+ * @event module:ol/source/Tile.TileSourceEvent#tileloaderror
46242
46364
  * @api
46243
46365
  */
46244
- getTileLoadFunction() {
46245
- return this.tileLoadFunction;
46246
- }
46366
+ TILELOADERROR: "tileloaderror"
46367
+ }, bo = [0, 0, 0], ts = 5;
46368
+ class Pw {
46247
46369
  /**
46248
- * Deprecated. Use an ImageTile source instead.
46249
- * Return the tile URL function of the source.
46250
- * @return {import("../Tile.js").UrlFunction} TileUrlFunction
46251
- * @api
46370
+ * @param {Options} options Tile grid options.
46252
46371
  */
46253
- getTileUrlFunction() {
46254
- return Object.getPrototypeOf(this).tileUrlFunction === this.tileUrlFunction ? this.tileUrlFunction.bind(this) : this.tileUrlFunction;
46372
+ constructor(e) {
46373
+ this.minZoom = e.minZoom !== void 0 ? e.minZoom : 0, this.resolutions_ = e.resolutions, st(
46374
+ c$(
46375
+ this.resolutions_,
46376
+ /**
46377
+ * @param {number} a First resolution
46378
+ * @param {number} b Second resolution
46379
+ * @return {number} Comparison result
46380
+ */
46381
+ (r, s) => s - r
46382
+ ),
46383
+ "`resolutions` must be sorted in descending order"
46384
+ );
46385
+ let n;
46386
+ if (!e.origins) {
46387
+ for (let r = 0, s = this.resolutions_.length - 1; r < s; ++r)
46388
+ if (!n)
46389
+ n = this.resolutions_[r] / this.resolutions_[r + 1];
46390
+ else if (this.resolutions_[r] / this.resolutions_[r + 1] !== n) {
46391
+ n = void 0;
46392
+ break;
46393
+ }
46394
+ }
46395
+ this.zoomFactor_ = n, this.maxZoom = this.resolutions_.length - 1, this.origin_ = e.origin !== void 0 ? e.origin : null, this.origins_ = null, e.origins !== void 0 && (this.origins_ = e.origins, st(
46396
+ this.origins_.length == this.resolutions_.length,
46397
+ "Number of `origins` and `resolutions` must be equal"
46398
+ ));
46399
+ const i = e.extent;
46400
+ i !== void 0 && !this.origin_ && !this.origins_ && (this.origin_ = $r(i)), st(
46401
+ !this.origin_ && this.origins_ || this.origin_ && !this.origins_,
46402
+ "Either `origin` or `origins` must be configured, never both"
46403
+ ), this.tileSizes_ = null, e.tileSizes !== void 0 && (this.tileSizes_ = e.tileSizes, st(
46404
+ this.tileSizes_.length == this.resolutions_.length,
46405
+ "Number of `tileSizes` and `resolutions` must be equal"
46406
+ )), this.tileSize_ = e.tileSize !== void 0 ? e.tileSize : this.tileSizes_ ? null : _p, st(
46407
+ !this.tileSize_ && this.tileSizes_ || this.tileSize_ && !this.tileSizes_,
46408
+ "Either `tileSize` or `tileSizes` must be configured, never both"
46409
+ ), this.extent_ = i !== void 0 ? i : null, this.fullTileRanges_ = null, this.tmpSize_ = [0, 0], this.tmpExtent_ = [0, 0, 0, 0], e.sizes !== void 0 ? this.fullTileRanges_ = e.sizes.map((r, s) => {
46410
+ const o = new Mp(
46411
+ Math.min(0, r[0]),
46412
+ Math.max(r[0] - 1, -1),
46413
+ Math.min(0, r[1]),
46414
+ Math.max(r[1] - 1, -1)
46415
+ );
46416
+ if (i) {
46417
+ const a = this.getTileRangeForExtentAndZ(i, s);
46418
+ 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);
46419
+ }
46420
+ return o;
46421
+ }) : i && this.calculateTileRanges_(i);
46255
46422
  }
46256
46423
  /**
46257
- * Deprecated. Use an ImageTile source instead.
46258
- * Return the URLs used for this source.
46259
- * When a tileUrlFunction is used instead of url or urls,
46260
- * null will be returned.
46261
- * @return {!Array<string>|null} URLs.
46424
+ * Call a function with each tile coordinate for a given extent and zoom level.
46425
+ *
46426
+ * @param {import("../extent.js").Extent} extent Extent.
46427
+ * @param {number} zoom Integer zoom level.
46428
+ * @param {function(import("../tilecoord.js").TileCoord): void} callback Function called with each tile coordinate.
46262
46429
  * @api
46263
46430
  */
46264
- getUrls() {
46265
- return this.urls;
46431
+ forEachTileCoord(e, n, i) {
46432
+ const r = this.getTileRangeForExtentAndZ(e, n);
46433
+ for (let s = r.minX, o = r.maxX; s <= o; ++s)
46434
+ for (let a = r.minY, l = r.maxY; a <= l; ++a)
46435
+ i([n, s, a]);
46266
46436
  }
46267
46437
  /**
46268
- * Handle tile change events.
46269
- * @param {import("../events/Event.js").default} event Event.
46270
- * @protected
46438
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
46439
+ * @param {function(number, import("../TileRange.js").default): boolean} callback Callback.
46440
+ * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
46441
+ * @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object.
46442
+ * @return {boolean} Callback succeeded.
46271
46443
  */
46272
- handleTileChange(e) {
46273
- const n = (
46274
- /** @type {import("../Tile.js").default} */
46275
- e.target
46276
- ), i = Xe(n), r = n.getState();
46277
- let s;
46278
- r == be.LOADING ? (this.tileLoadingKeys_[i] = !0, s = hh.TILELOADSTART) : i in this.tileLoadingKeys_ && (delete this.tileLoadingKeys_[i], s = r == be.ERROR ? hh.TILELOADERROR : r == be.LOADED ? hh.TILELOADEND : void 0), s != null && this.dispatchEvent(new O8(s, n));
46444
+ forEachTileCoordParentTileRange(e, n, i, r) {
46445
+ let s, o, a, l = null, u = e[0] - 1;
46446
+ for (this.zoomFactor_ === 2 ? (o = e[1], a = e[2]) : l = this.getTileCoordExtent(e, r); u >= this.minZoom; ) {
46447
+ if (o !== void 0 && a !== void 0 ? (o = Math.floor(o / 2), a = Math.floor(a / 2), s = mo(o, o, a, a, i)) : s = this.getTileRangeForExtentAndZ(
46448
+ l,
46449
+ u,
46450
+ i
46451
+ ), n(u, s))
46452
+ return !0;
46453
+ --u;
46454
+ }
46455
+ return !1;
46279
46456
  }
46280
46457
  /**
46281
- * Deprecated. Use an ImageTile source instead.
46282
- * Set the tile load function of the source.
46283
- * @param {import("../Tile.js").LoadFunction} tileLoadFunction Tile load function.
46458
+ * Get the extent for this tile grid, if it was configured.
46459
+ * @return {import("../extent.js").Extent} Extent.
46284
46460
  * @api
46285
46461
  */
46286
- setTileLoadFunction(e) {
46287
- this.tileLoadFunction = e, this.changed();
46462
+ getExtent() {
46463
+ return this.extent_;
46288
46464
  }
46289
46465
  /**
46290
- * Deprecated. Use an ImageTile source instead.
46291
- * Set the tile URL function of the source.
46292
- * @param {import("../Tile.js").UrlFunction} tileUrlFunction Tile URL function.
46293
- * @param {string} [key] Optional new tile key for the source.
46466
+ * Get the maximum zoom level for the grid.
46467
+ * @return {number} Max zoom.
46294
46468
  * @api
46295
46469
  */
46296
- setTileUrlFunction(e, n) {
46297
- this.tileUrlFunction = e, typeof n < "u" ? this.setKey(n) : this.changed();
46470
+ getMaxZoom() {
46471
+ return this.maxZoom;
46298
46472
  }
46299
46473
  /**
46300
- * Set the URL to use for requests.
46301
- * @param {string} url URL.
46474
+ * Get the minimum zoom level for the grid.
46475
+ * @return {number} Min zoom.
46302
46476
  * @api
46303
46477
  */
46304
- setUrl(e) {
46305
- const n = B8(e);
46306
- this.urls = n, this.setUrls(n);
46478
+ getMinZoom() {
46479
+ return this.minZoom;
46307
46480
  }
46308
46481
  /**
46309
- * Deprecated. Use an ImageTile source instead.
46310
- * Set the URLs to use for requests.
46311
- * @param {Array<string>} urls URLs.
46482
+ * Get the origin for the grid at the given zoom level.
46483
+ * @param {number} z Integer zoom level.
46484
+ * @return {import("../coordinate.js").Coordinate} Origin.
46312
46485
  * @api
46313
46486
  */
46314
- setUrls(e) {
46315
- this.urls = e;
46316
- const n = e.join(`
46317
- `);
46318
- this.generateTileUrlFunction_ ? this.setTileUrlFunction(W8(e, this.tileGrid), n) : this.setKey(n);
46487
+ getOrigin(e) {
46488
+ return this.origin_ ? this.origin_ : this.origins_[e];
46319
46489
  }
46320
46490
  /**
46321
- * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
46322
- * @param {number} pixelRatio Pixel ratio.
46323
- * @param {import("../proj/Projection.js").default} projection Projection.
46324
- * @return {string|undefined} Tile URL.
46491
+ * Get the resolution for the given zoom level.
46492
+ * @param {number} z Integer zoom level.
46493
+ * @return {number} Resolution.
46494
+ * @api
46325
46495
  */
46326
- tileUrlFunction(e, n, i) {
46496
+ getResolution(e) {
46497
+ return this.resolutions_[e];
46327
46498
  }
46328
- }
46329
- class Y8 extends $p {
46330
46499
  /**
46331
- * @param {!Options} options Image tile options.
46500
+ * Get the list of resolutions for the tile grid.
46501
+ * @return {Array<number>} Resolutions.
46502
+ * @api
46332
46503
  */
46333
- constructor(e) {
46334
- super({
46335
- attributions: e.attributions,
46336
- cacheSize: e.cacheSize,
46337
- projection: e.projection,
46338
- state: e.state,
46339
- tileGrid: e.tileGrid,
46340
- tileLoadFunction: e.tileLoadFunction ? e.tileLoadFunction : U8,
46341
- tilePixelRatio: e.tilePixelRatio,
46342
- tileUrlFunction: e.tileUrlFunction,
46343
- url: e.url,
46344
- urls: e.urls,
46345
- wrapX: e.wrapX,
46346
- transition: e.transition,
46347
- interpolate: e.interpolate !== void 0 ? e.interpolate : !0,
46348
- key: e.key,
46349
- attributionsCollapsible: e.attributionsCollapsible,
46350
- zDirection: e.zDirection
46351
- }), this.crossOrigin = e.crossOrigin !== void 0 ? e.crossOrigin : null, this.tileClass = e.tileClass !== void 0 ? e.tileClass : mw, this.tileGridForProjection = {}, this.reprojectionErrorThreshold_ = e.reprojectionErrorThreshold, this.renderReprojectionEdges_ = !1;
46504
+ getResolutions() {
46505
+ return this.resolutions_;
46352
46506
  }
46353
46507
  /**
46354
- * @param {import("../proj/Projection.js").default} projection Projection.
46355
- * @return {number} Gutter.
46356
- * @override
46508
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
46509
+ * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
46510
+ * @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object.
46511
+ * @return {import("../TileRange.js").default|null} Tile range.
46357
46512
  */
46358
- getGutterForProjection(e) {
46359
- return this.getProjection() && e && !Ou(this.getProjection(), e) ? 0 : this.getGutter();
46513
+ getTileCoordChildTileRange(e, n, i) {
46514
+ if (e[0] < this.maxZoom) {
46515
+ if (this.zoomFactor_ === 2) {
46516
+ const s = e[1] * 2, o = e[2] * 2;
46517
+ return mo(
46518
+ s,
46519
+ s + 1,
46520
+ o,
46521
+ o + 1,
46522
+ n
46523
+ );
46524
+ }
46525
+ const r = this.getTileCoordExtent(
46526
+ e,
46527
+ i || this.tmpExtent_
46528
+ );
46529
+ return this.getTileRangeForExtentAndZ(
46530
+ r,
46531
+ e[0] + 1,
46532
+ n
46533
+ );
46534
+ }
46535
+ return null;
46360
46536
  }
46361
46537
  /**
46362
- * @return {number} Gutter.
46538
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
46539
+ * @param {number} z Integer zoom level.
46540
+ * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
46541
+ * @return {import("../TileRange.js").default|null} Tile range.
46363
46542
  */
46364
- getGutter() {
46365
- return 0;
46543
+ getTileRangeForTileCoordAndZ(e, n, i) {
46544
+ if (n > this.maxZoom || n < this.minZoom)
46545
+ return null;
46546
+ const r = e[0], s = e[1], o = e[2];
46547
+ if (n === r)
46548
+ return mo(
46549
+ s,
46550
+ o,
46551
+ s,
46552
+ o,
46553
+ i
46554
+ );
46555
+ if (this.zoomFactor_) {
46556
+ const l = Math.pow(this.zoomFactor_, n - r), u = Math.floor(s * l), c = Math.floor(o * l);
46557
+ if (n < r)
46558
+ return mo(u, u, c, c, i);
46559
+ const d = Math.floor(l * (s + 1)) - 1, h = Math.floor(l * (o + 1)) - 1;
46560
+ return mo(u, d, c, h, i);
46561
+ }
46562
+ const a = this.getTileCoordExtent(e, this.tmpExtent_);
46563
+ return this.getTileRangeForExtentAndZ(a, n, i);
46366
46564
  }
46367
46565
  /**
46368
- * Return the key to be used for all tiles in the source.
46369
- * @return {string} The key for all tiles.
46370
- * @override
46566
+ * Get a tile range for the given extent and integer zoom level.
46567
+ * @param {import("../extent.js").Extent} extent Extent.
46568
+ * @param {number} z Integer zoom level.
46569
+ * @param {import("../TileRange.js").default} [tempTileRange] Temporary tile range object.
46570
+ * @return {import("../TileRange.js").default} Tile range.
46371
46571
  */
46372
- getKey() {
46373
- let e = super.getKey();
46374
- return this.getInterpolate() || (e += ":disable-interpolation"), e;
46572
+ getTileRangeForExtentAndZ(e, n, i) {
46573
+ this.getTileCoordForXYAndZ_(e[0], e[3], n, !1, bo);
46574
+ const r = bo[1], s = bo[2];
46575
+ this.getTileCoordForXYAndZ_(e[2], e[1], n, !0, bo);
46576
+ const o = bo[1], a = bo[2];
46577
+ return mo(r, o, s, a, i);
46375
46578
  }
46376
46579
  /**
46377
- * @param {import("../proj/Projection.js").default} projection Projection.
46378
- * @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
46379
- * @override
46580
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
46581
+ * @return {import("../coordinate.js").Coordinate} Tile center.
46380
46582
  */
46381
- getTileGridForProjection(e) {
46382
- const n = this.getProjection();
46383
- if (this.tileGrid && (!n || Ou(n, e)))
46384
- return this.tileGrid;
46385
- const i = Xe(e);
46386
- return i in this.tileGridForProjection || (this.tileGridForProjection[i] = Pw(e)), this.tileGridForProjection[i];
46583
+ getTileCoordCenter(e) {
46584
+ const n = this.getOrigin(e[0]), i = this.getResolution(e[0]), r = $n(this.getTileSize(e[0]), this.tmpSize_);
46585
+ return [
46586
+ n[0] + (e[1] + 0.5) * r[0] * i,
46587
+ n[1] - (e[2] + 0.5) * r[1] * i
46588
+ ];
46387
46589
  }
46388
46590
  /**
46389
- * @param {number} z Tile coordinate z.
46390
- * @param {number} x Tile coordinate x.
46391
- * @param {number} y Tile coordinate y.
46392
- * @param {number} pixelRatio Pixel ratio.
46393
- * @param {import("../proj/Projection.js").default} projection Projection.
46394
- * @param {string} key The key set on the tile.
46395
- * @return {!ImageTile} Tile.
46396
- * @private
46591
+ * Get the extent of a tile coordinate.
46592
+ *
46593
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
46594
+ * @param {import("../extent.js").Extent} [tempExtent] Temporary extent object.
46595
+ * @return {import("../extent.js").Extent} Extent.
46596
+ * @api
46397
46597
  */
46398
- createTile_(e, n, i, r, s, o) {
46399
- const a = [e, n, i], l = this.getTileCoordForTileUrlFunction(
46400
- a,
46401
- s
46402
- ), u = l ? this.tileUrlFunction(l, r, s) : void 0, c = new this.tileClass(
46403
- a,
46404
- u !== void 0 ? be.IDLE : be.EMPTY,
46405
- u !== void 0 ? u : "",
46406
- this.crossOrigin,
46407
- this.tileLoadFunction,
46408
- this.tileOptions
46409
- );
46410
- return c.key = o, c.addEventListener(ze.CHANGE, this.handleTileChange.bind(this)), c;
46598
+ getTileCoordExtent(e, n) {
46599
+ const i = this.getOrigin(e[0]), r = this.getResolution(e[0]), s = $n(this.getTileSize(e[0]), this.tmpSize_), o = i[0] + e[1] * s[0] * r, a = i[1] - (e[2] + 1) * s[1] * r, l = o + s[0] * r, u = a + s[1] * r;
46600
+ return Nr(o, a, l, u, n);
46411
46601
  }
46412
46602
  /**
46413
- * @param {number} z Tile coordinate z.
46414
- * @param {number} x Tile coordinate x.
46415
- * @param {number} y Tile coordinate y.
46416
- * @param {number} pixelRatio Pixel ratio.
46417
- * @param {import("../proj/Projection.js").default} projection Projection.
46418
- * @return {!(ImageTile|ReprojTile)} Tile.
46419
- * @override
46603
+ * Get the tile coordinate for the given map coordinate and resolution. This
46604
+ * method considers that coordinates that intersect tile boundaries should be
46605
+ * assigned the higher tile coordinate.
46606
+ *
46607
+ * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
46608
+ * @param {number} resolution Resolution.
46609
+ * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
46610
+ * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
46611
+ * @api
46420
46612
  */
46421
- getTile(e, n, i, r, s) {
46422
- const o = this.getProjection();
46423
- if (!o || !s || Ou(o, s))
46424
- return this.getTileInternal(
46425
- e,
46426
- n,
46427
- i,
46428
- r,
46429
- o || s
46430
- );
46431
- const a = [e, n, i], l = this.getKey(), u = this.getTileGridForProjection(o), c = this.getTileGridForProjection(s), d = this.getTileCoordForTileUrlFunction(
46432
- a,
46433
- s
46434
- ), h = new Cf(
46435
- o,
46436
- u,
46437
- s,
46438
- c,
46439
- a,
46440
- d,
46441
- this.getTilePixelRatio(r),
46442
- this.getGutter(),
46443
- (p, f, m, _) => this.getTileInternal(p, f, m, _, o),
46444
- this.reprojectionErrorThreshold_,
46445
- this.renderReprojectionEdges_,
46446
- this.tileOptions
46613
+ getTileCoordForCoordAndResolution(e, n, i) {
46614
+ return this.getTileCoordForXYAndResolution_(
46615
+ e[0],
46616
+ e[1],
46617
+ n,
46618
+ !1,
46619
+ i
46447
46620
  );
46448
- return h.key = l, h;
46449
46621
  }
46450
46622
  /**
46451
- * @param {number} z Tile coordinate z.
46452
- * @param {number} x Tile coordinate x.
46453
- * @param {number} y Tile coordinate y.
46454
- * @param {number} pixelRatio Pixel ratio.
46455
- * @param {!import("../proj/Projection.js").default} projection Projection.
46456
- * @return {!ImageTile} Tile.
46457
- * @protected
46458
- */
46459
- getTileInternal(e, n, i, r, s) {
46460
- const o = this.getKey();
46461
- return this.createTile_(e, n, i, r, s, o);
46623
+ * Note that this method should not be called for resolutions that correspond
46624
+ * to an integer zoom level. Instead call the `getTileCoordForXYAndZ_` method.
46625
+ * @param {number} x X.
46626
+ * @param {number} y Y.
46627
+ * @param {number} resolution Resolution (for a non-integer zoom level).
46628
+ * @param {boolean} reverseIntersectionPolicy Instead of letting edge
46629
+ * intersections go to the higher tile coordinate, let edge intersections
46630
+ * go to the lower tile coordinate.
46631
+ * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
46632
+ * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
46633
+ * @private
46634
+ */
46635
+ getTileCoordForXYAndResolution_(e, n, i, r, s) {
46636
+ const o = this.getZForResolution(i), a = i / this.getResolution(o), l = this.getOrigin(o), u = $n(this.getTileSize(o), this.tmpSize_);
46637
+ let c = a * (e - l[0]) / i / u[0], d = a * (l[1] - n) / i / u[1];
46638
+ return r ? (c = au(c, ts) - 1, d = au(d, ts) - 1) : (c = ou(c, ts), d = ou(d, ts)), gc(o, c, d, s);
46462
46639
  }
46463
46640
  /**
46464
- * Sets whether to render reprojection edges or not (usually for debugging).
46465
- * @param {boolean} render Render the edges.
46641
+ * Although there is repetition between this method and `getTileCoordForXYAndResolution_`,
46642
+ * they should have separate implementations. This method is for integer zoom
46643
+ * levels. The other method should only be called for resolutions corresponding
46644
+ * to non-integer zoom levels.
46645
+ * @param {number} x Map x coordinate.
46646
+ * @param {number} y Map y coordinate.
46647
+ * @param {number} z Integer zoom level.
46648
+ * @param {boolean} reverseIntersectionPolicy Instead of letting edge
46649
+ * intersections go to the higher tile coordinate, let edge intersections
46650
+ * go to the lower tile coordinate.
46651
+ * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
46652
+ * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
46653
+ * @private
46654
+ */
46655
+ getTileCoordForXYAndZ_(e, n, i, r, s) {
46656
+ const o = this.getOrigin(i), a = this.getResolution(i), l = $n(this.getTileSize(i), this.tmpSize_);
46657
+ let u = (e - o[0]) / a / l[0], c = (o[1] - n) / a / l[1];
46658
+ return r ? (u = au(u, ts) - 1, c = au(c, ts) - 1) : (u = ou(u, ts), c = ou(c, ts)), gc(i, u, c, s);
46659
+ }
46660
+ /**
46661
+ * Get a tile coordinate given a map coordinate and zoom level.
46662
+ * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
46663
+ * @param {number} z Integer zoom level, e.g. the result of a `getZForResolution()` method call
46664
+ * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
46665
+ * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
46466
46666
  * @api
46467
46667
  */
46468
- setRenderReprojectionEdges(e) {
46469
- this.renderReprojectionEdges_ != e && (this.renderReprojectionEdges_ = e, this.changed());
46668
+ getTileCoordForCoordAndZ(e, n, i) {
46669
+ return this.getTileCoordForXYAndZ_(
46670
+ e[0],
46671
+ e[1],
46672
+ n,
46673
+ !1,
46674
+ i
46675
+ );
46470
46676
  }
46471
46677
  /**
46472
- * Sets the tile grid to use when reprojecting the tiles to the given
46473
- * projection instead of the default tile grid for the projection.
46474
- *
46475
- * This can be useful when the default tile grid cannot be created
46476
- * (e.g. projection has no extent defined) or
46477
- * for optimization reasons (custom tile size, resolutions, ...).
46678
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
46679
+ * @return {number} Tile resolution.
46680
+ */
46681
+ getTileCoordResolution(e) {
46682
+ return this.resolutions_[e[0]];
46683
+ }
46684
+ /**
46685
+ * Get the tile size for a zoom level. The type of the return value matches the
46686
+ * `tileSize` or `tileSizes` that the tile grid was configured with. To always
46687
+ * get an {@link import("../size.js").Size}, run the result through {@link module:ol/size.toSize}.
46688
+ * @param {number} z Z.
46689
+ * @return {number|import("../size.js").Size} Tile size.
46690
+ * @api
46691
+ */
46692
+ getTileSize(e) {
46693
+ return this.tileSize_ ? this.tileSize_ : this.tileSizes_[e];
46694
+ }
46695
+ /**
46696
+ * @param {number} z Zoom level.
46697
+ * @return {import("../TileRange.js").default|null} Extent tile range for the specified zoom level.
46698
+ */
46699
+ getFullTileRange(e) {
46700
+ return this.fullTileRanges_ ? this.fullTileRanges_[e] : this.extent_ ? this.getTileRangeForExtentAndZ(this.extent_, e) : null;
46701
+ }
46702
+ /**
46703
+ * @param {number} resolution Resolution.
46704
+ * @param {number|import("../array.js").NearestDirectionFunction} [opt_direction]
46705
+ * If 0, the nearest resolution will be used.
46706
+ * If 1, the nearest higher resolution (lower Z) will be used. If -1, the
46707
+ * nearest lower resolution (higher Z) will be used. Default is 0.
46708
+ * Use a {@link module:ol/array~NearestDirectionFunction} for more precise control.
46478
46709
  *
46479
- * @param {import("../proj.js").ProjectionLike} projection Projection.
46480
- * @param {import("../tilegrid/TileGrid.js").default} tilegrid Tile grid to use for the projection.
46710
+ * For example to change tile Z at the midpoint of zoom levels
46711
+ * ```js
46712
+ * function(value, high, low) {
46713
+ * return value - low * Math.sqrt(high / low);
46714
+ * }
46715
+ * ```
46716
+ * @return {number} Z.
46481
46717
  * @api
46482
46718
  */
46483
- setTileGridForProjection(e, n) {
46484
- const i = Vt(e);
46485
- if (i) {
46486
- const r = Xe(i);
46487
- r in this.tileGridForProjection || (this.tileGridForProjection[r] = n);
46488
- }
46719
+ getZForResolution(e, n) {
46720
+ const i = Lg(
46721
+ this.resolutions_,
46722
+ e,
46723
+ n || 0
46724
+ );
46725
+ return Wt(i, this.minZoom, this.maxZoom);
46726
+ }
46727
+ /**
46728
+ * The tile with the provided tile coordinate intersects the given viewport.
46729
+ * @param {import('../tilecoord.js').TileCoord} tileCoord Tile coordinate.
46730
+ * @param {Array<number>} viewport Viewport as returned from {@link module:ol/extent.getRotatedViewport}.
46731
+ * @return {boolean} The tile with the provided tile coordinate intersects the given viewport.
46732
+ */
46733
+ tileCoordIntersectsViewport(e, n) {
46734
+ return P1(
46735
+ n,
46736
+ 0,
46737
+ n.length,
46738
+ 2,
46739
+ this.getTileCoordExtent(e)
46740
+ );
46741
+ }
46742
+ /**
46743
+ * @param {!import("../extent.js").Extent} extent Extent for this tile grid.
46744
+ * @private
46745
+ */
46746
+ calculateTileRanges_(e) {
46747
+ const n = this.resolutions_.length, i = new Array(n);
46748
+ for (let r = this.minZoom; r < n; ++r)
46749
+ i[r] = this.getTileRangeForExtentAndZ(e, r);
46750
+ this.fullTileRanges_ = i;
46489
46751
  }
46490
46752
  }
46491
- function U8(t, e) {
46492
- t.getImage().src = e;
46753
+ function Iw(t) {
46754
+ let e = t.getDefaultTileGrid();
46755
+ return e || (e = Z8(t), t.setDefaultTileGrid(e)), e;
46756
+ }
46757
+ function H8(t, e, n) {
46758
+ const i = e[0], r = t.getTileCoordCenter(e), s = Gp(n);
46759
+ if (!Jo(s, r)) {
46760
+ const o = nt(s), a = Math.ceil(
46761
+ (s[0] - r[0]) / o
46762
+ );
46763
+ return r[0] += o * a, t.getTileCoordForCoordAndZ(r, i);
46764
+ }
46765
+ return e;
46766
+ }
46767
+ function X8(t, e, n, i) {
46768
+ i = i !== void 0 ? i : "top-left";
46769
+ const r = kw(t, e, n);
46770
+ return new Pw({
46771
+ extent: t,
46772
+ origin: w$(t, i),
46773
+ resolutions: r,
46774
+ tileSize: n
46775
+ });
46776
+ }
46777
+ function K8(t) {
46778
+ const e = t || {}, n = e.extent || Vt("EPSG:3857").getExtent(), i = {
46779
+ extent: n,
46780
+ minZoom: e.minZoom,
46781
+ tileSize: e.tileSize,
46782
+ resolutions: kw(
46783
+ n,
46784
+ e.maxZoom,
46785
+ e.tileSize,
46786
+ e.maxResolution
46787
+ )
46788
+ };
46789
+ return new Pw(i);
46790
+ }
46791
+ function kw(t, e, n, i) {
46792
+ e = e !== void 0 ? e : x4, n = $n(n !== void 0 ? n : _p);
46793
+ const r = an(t), s = nt(t);
46794
+ i = i > 0 ? i : Math.max(s / n[0], r / n[1]);
46795
+ const o = e + 1, a = new Array(o);
46796
+ for (let l = 0; l < o; ++l)
46797
+ a[l] = i / Math.pow(2, l);
46798
+ return a;
46799
+ }
46800
+ function Z8(t, e, n, i) {
46801
+ const r = Gp(t);
46802
+ return X8(r, e, n, i);
46803
+ }
46804
+ function Gp(t) {
46805
+ t = Vt(t);
46806
+ let e = t.getExtent();
46807
+ if (!e) {
46808
+ const n = 180 * ea.degrees / t.getMetersPerUnit();
46809
+ e = Nr(-n, -n, n, n);
46810
+ }
46811
+ return e;
46493
46812
  }
46494
- class B6 extends Y8 {
46813
+ class q8 extends L1 {
46495
46814
  /**
46496
- * @param {Options} [options] XYZ options.
46815
+ * @param {Options} options SourceTile source options.
46497
46816
  */
46498
46817
  constructor(e) {
46499
- e = e || {};
46500
- const n = e.projection !== void 0 ? e.projection : "EPSG:3857", i = e.tileGrid !== void 0 ? e.tileGrid : I8({
46501
- extent: Np(n),
46502
- maxResolution: e.maxResolution,
46503
- maxZoom: e.maxZoom,
46504
- minZoom: e.minZoom,
46505
- tileSize: e.tileSize
46506
- });
46507
46818
  super({
46508
46819
  attributions: e.attributions,
46509
- cacheSize: e.cacheSize,
46510
- crossOrigin: e.crossOrigin,
46511
- interpolate: e.interpolate,
46512
- projection: n,
46513
- reprojectionErrorThreshold: e.reprojectionErrorThreshold,
46514
- tileGrid: i,
46515
- tileLoadFunction: e.tileLoadFunction,
46516
- tilePixelRatio: e.tilePixelRatio,
46517
- tileUrlFunction: e.tileUrlFunction,
46518
- url: e.url,
46519
- urls: e.urls,
46520
- wrapX: e.wrapX !== void 0 ? e.wrapX : !0,
46521
- transition: e.transition,
46522
46820
  attributionsCollapsible: e.attributionsCollapsible,
46523
- zDirection: e.zDirection
46524
- }), this.gutter_ = e.gutter !== void 0 ? e.gutter : 0;
46821
+ projection: e.projection,
46822
+ state: e.state,
46823
+ wrapX: e.wrapX,
46824
+ interpolate: e.interpolate
46825
+ }), this.on, this.once, this.un, this.tilePixelRatio_ = e.tilePixelRatio !== void 0 ? e.tilePixelRatio : 1, this.tileGrid = e.tileGrid !== void 0 ? e.tileGrid : null;
46826
+ const n = [256, 256];
46827
+ this.tileGrid && $n(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()), n), this.tmpSize = [0, 0], this.key_ = e.key || Xe(this), this.tileOptions = {
46828
+ transition: e.transition,
46829
+ interpolate: e.interpolate
46830
+ }, this.zDirection = e.zDirection ? e.zDirection : 0;
46525
46831
  }
46526
46832
  /**
46833
+ * @param {import("../proj/Projection.js").default} projection Projection.
46527
46834
  * @return {number} Gutter.
46528
- * @override
46529
46835
  */
46530
- getGutter() {
46531
- return this.gutter_;
46836
+ getGutterForProjection(e) {
46837
+ return 0;
46532
46838
  }
46533
- }
46534
- class V8 {
46535
- constructor() {
46536
- this.dataProjection = void 0, this.defaultFeatureProjection = void 0, this.featureClass = /** @type {FeatureToFeatureClass<FeatureType>} */
46537
- Ki, this.supportedMediaTypes = null;
46839
+ /**
46840
+ * Return the key to be used for all tiles in the source.
46841
+ * @return {string} The key for all tiles.
46842
+ */
46843
+ getKey() {
46844
+ return this.key_;
46538
46845
  }
46539
46846
  /**
46540
- * Adds the data projection to the read options.
46541
- * @param {Document|Element|Object|string} source Source.
46542
- * @param {ReadOptions} [options] Options.
46543
- * @return {ReadOptions|undefined} Options.
46847
+ * Set the value to be used as the key for all tiles in the source.
46848
+ * @param {string} key The key for tiles.
46544
46849
  * @protected
46545
46850
  */
46546
- getReadOptions(e, n) {
46547
- if (n) {
46548
- let i = n.dataProjection ? Vt(n.dataProjection) : this.readProjection(e);
46549
- n.extent && i && i.getUnits() === "tile-pixels" && (i = Vt(i), i.setWorldExtent(n.extent)), n = {
46550
- dataProjection: i,
46551
- featureProjection: n.featureProjection
46552
- };
46553
- }
46554
- return this.adaptOptions(n);
46851
+ setKey(e) {
46852
+ this.key_ !== e && (this.key_ = e, this.changed());
46555
46853
  }
46556
46854
  /**
46557
- * Sets the `dataProjection` on the options, if no `dataProjection`
46558
- * is set.
46559
- * @param {WriteOptions|ReadOptions|undefined} options
46560
- * Options.
46561
- * @protected
46562
- * @return {WriteOptions|ReadOptions|undefined}
46563
- * Updated options.
46855
+ * @param {import("../proj/Projection").default} [projection] Projection.
46856
+ * @return {Array<number>|null} Resolutions.
46857
+ * @override
46564
46858
  */
46565
- adaptOptions(e) {
46566
- return Object.assign(
46567
- {
46568
- dataProjection: this.dataProjection,
46569
- featureProjection: this.defaultFeatureProjection,
46570
- featureClass: this.featureClass
46571
- },
46572
- e
46573
- );
46859
+ getResolutions(e) {
46860
+ const n = e ? this.getTileGridForProjection(e) : this.tileGrid;
46861
+ return n ? n.getResolutions() : null;
46574
46862
  }
46575
46863
  /**
46576
46864
  * @abstract
46577
- * @return {Type} The format type.
46865
+ * @param {number} z Tile coordinate z.
46866
+ * @param {number} x Tile coordinate x.
46867
+ * @param {number} y Tile coordinate y.
46868
+ * @param {number} pixelRatio Pixel ratio.
46869
+ * @param {import("../proj/Projection.js").default} projection Projection.
46870
+ * @return {TileType|null} Tile.
46578
46871
  */
46579
- getType() {
46872
+ getTile(e, n, i, r, s) {
46580
46873
  return $e();
46581
46874
  }
46582
46875
  /**
46583
- * Read a single feature from a source.
46584
- *
46585
- * @abstract
46586
- * @param {Document|Element|Object|string} source Source.
46587
- * @param {ReadOptions} [options] Read options.
46588
- * @return {FeatureType|Array<FeatureType>} Feature.
46876
+ * Return the tile grid of the tile source.
46877
+ * @return {import("../tilegrid/TileGrid.js").default|null} Tile grid.
46878
+ * @api
46589
46879
  */
46590
- readFeature(e, n) {
46591
- return $e();
46880
+ getTileGrid() {
46881
+ return this.tileGrid;
46592
46882
  }
46593
46883
  /**
46594
- * Read all features from a source.
46595
- *
46596
- * @abstract
46597
- * @param {Document|Element|ArrayBuffer|Object|string} source Source.
46598
- * @param {ReadOptions} [options] Read options.
46599
- * @return {Array<FeatureType>} Features.
46884
+ * @param {import("../proj/Projection.js").default} projection Projection.
46885
+ * @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
46600
46886
  */
46601
- readFeatures(e, n) {
46602
- return $e();
46887
+ getTileGridForProjection(e) {
46888
+ return this.tileGrid ? this.tileGrid : Iw(e);
46603
46889
  }
46604
46890
  /**
46605
- * Read a single geometry from a source.
46606
- *
46607
- * @abstract
46608
- * @param {Document|Element|Object|string} source Source.
46609
- * @param {ReadOptions} [options] Read options.
46610
- * @return {import("../geom/Geometry.js").default} Geometry.
46891
+ * Get the tile pixel ratio for this source. Subclasses may override this
46892
+ * method, which is meant to return a supported pixel ratio that matches the
46893
+ * provided `pixelRatio` as close as possible.
46894
+ * @param {number} pixelRatio Pixel ratio.
46895
+ * @return {number} Tile pixel ratio.
46611
46896
  */
46612
- readGeometry(e, n) {
46613
- return $e();
46897
+ getTilePixelRatio(e) {
46898
+ return this.tilePixelRatio_;
46614
46899
  }
46615
46900
  /**
46616
- * Read the projection from a source.
46617
- *
46618
- * @abstract
46619
- * @param {Document|Element|Object|string} source Source.
46620
- * @return {import("../proj/Projection.js").default|undefined} Projection.
46901
+ * @param {number} z Z.
46902
+ * @param {number} pixelRatio Pixel ratio.
46903
+ * @param {import("../proj/Projection.js").default} projection Projection.
46904
+ * @return {import("../size.js").Size} Tile size.
46621
46905
  */
46622
- readProjection(e) {
46623
- return $e();
46906
+ getTilePixelSize(e, n, i) {
46907
+ const r = this.getTileGridForProjection(i), s = this.getTilePixelRatio(n), o = $n(r.getTileSize(e), this.tmpSize);
46908
+ return s == 1 ? o : K3(o, s, this.tmpSize);
46624
46909
  }
46625
46910
  /**
46626
- * Encode a feature in this format.
46627
- *
46628
- * @abstract
46629
- * @param {Feature} feature Feature.
46630
- * @param {WriteOptions} [options] Write options.
46631
- * @return {string|ArrayBuffer} Result.
46911
+ * Returns a tile coordinate wrapped around the x-axis. When the tile coordinate
46912
+ * is outside the resolution and extent range of the tile grid, `null` will be
46913
+ * returned.
46914
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
46915
+ * @param {import("../proj/Projection.js").default} [projection] Projection.
46916
+ * @return {import("../tilecoord.js").TileCoord} Tile coordinate to be passed to the tileUrlFunction or
46917
+ * null if no tile URL should be created for the passed `tileCoord`.
46632
46918
  */
46633
- writeFeature(e, n) {
46634
- return $e();
46919
+ getTileCoordForTileUrlFunction(e, n) {
46920
+ const i = n !== void 0 ? n : this.getProjection(), r = n !== void 0 ? this.getTileGridForProjection(i) : this.tileGrid || this.getTileGridForProjection(i);
46921
+ return this.getWrapX() && i.isGlobal() && (e = H8(r, e, i)), bB(e, r) ? e : null;
46635
46922
  }
46636
46923
  /**
46637
- * Encode an array of features in this format.
46638
- *
46639
- * @abstract
46640
- * @param {Array<Feature>} features Features.
46641
- * @param {WriteOptions} [options] Write options.
46642
- * @return {string|ArrayBuffer} Result.
46924
+ * Remove all cached reprojected tiles from the source. The next render cycle will create new tiles.
46925
+ * @api
46643
46926
  */
46644
- writeFeatures(e, n) {
46645
- return $e();
46927
+ clear() {
46646
46928
  }
46647
46929
  /**
46648
- * Write a single geometry in this format.
46649
- *
46650
- * @abstract
46651
- * @param {import("../geom/Geometry.js").default} geometry Geometry.
46652
- * @param {WriteOptions} [options] Write options.
46653
- * @return {string|ArrayBuffer} Result.
46930
+ * @override
46654
46931
  */
46655
- writeGeometry(e, n) {
46656
- return $e();
46932
+ refresh() {
46933
+ this.clear(), super.refresh();
46657
46934
  }
46658
46935
  }
46659
- function Bp(t, e, n) {
46660
- const i = n ? Vt(n.featureProjection) : null, r = n ? Vt(n.dataProjection) : null;
46661
- let s = t;
46662
- if (i && r && !Ou(i, r)) {
46663
- e && (s = /** @type {T} */
46664
- t.clone());
46665
- const o = e ? i : r, a = e ? r : i;
46666
- o.getUnits() === "tile-pixels" ? s.transform(o, a) : s.applyTransform(tl(o, a));
46667
- }
46668
- if (e && n && /** @type {WriteOptions} */
46669
- n.decimals !== void 0) {
46670
- const o = Math.pow(
46671
- 10,
46672
- /** @type {WriteOptions} */
46673
- n.decimals
46674
- ), a = function(l) {
46675
- for (let u = 0, c = l.length; u < c; ++u)
46676
- l[u] = Math.round(l[u] * o) / o;
46677
- return l;
46678
- };
46679
- s === t && (s = /** @type {T} */
46680
- t.clone()), s.applyTransform(a);
46936
+ class J8 extends Ui {
46937
+ /**
46938
+ * @param {string} type Type.
46939
+ * @param {import("../Tile.js").default} tile The tile.
46940
+ */
46941
+ constructor(e, n) {
46942
+ super(e), this.tile = n;
46681
46943
  }
46682
- return s;
46683
46944
  }
46684
- const j8 = {
46685
- Point: kr,
46686
- LineString: er,
46687
- Polygon: or,
46688
- MultiPoint: Dl,
46689
- MultiLineString: na,
46690
- MultiPolygon: ia
46691
- };
46692
- function H8(t, e, n) {
46693
- return Array.isArray(e[0]) ? (O1(t, 0, e, n) || (t = t.slice(), gf(t, 0, e, n)), t) : (sp(t, 0, e, n) || (t = t.slice(), rc(t, 0, e, n)), t);
46945
+ const Q8 = /\{z\}/g, e6 = /\{x\}/g, t6 = /\{y\}/g, n6 = /\{-y\}/g;
46946
+ function i6(t, e, n, i, r) {
46947
+ return t.replace(Q8, e.toString()).replace(e6, n.toString()).replace(t6, i.toString()).replace(n6, function() {
46948
+ if (r === void 0)
46949
+ throw new Error(
46950
+ "If the URL template has a {-y} placeholder, the grid extent must be known"
46951
+ );
46952
+ return (r - i).toString();
46953
+ });
46694
46954
  }
46695
- function kw(t, e) {
46696
- var s;
46697
- const n = t.geometry;
46698
- if (!n)
46699
- return [];
46700
- if (Array.isArray(n))
46701
- return n.map((o) => kw({ ...t, geometry: o })).flat();
46702
- const i = n.type === "MultiPolygon" ? "Polygon" : n.type;
46703
- if (i === "GeometryCollection" || i === "Circle")
46704
- throw new Error("Unsupported geometry type: " + i);
46705
- const r = n.layout.length;
46706
- return Bp(
46707
- new ri(
46708
- i,
46709
- i === "Polygon" ? H8(n.flatCoordinates, n.ends, r) : n.flatCoordinates,
46710
- (s = n.ends) == null ? void 0 : s.flat(),
46711
- r,
46712
- t.properties || {},
46713
- t.id
46714
- ).enableSimplifyTransformed(),
46715
- !1,
46716
- e
46955
+ function r6(t) {
46956
+ const e = [];
46957
+ let n = /\{([a-z])-([a-z])\}/.exec(t);
46958
+ if (n) {
46959
+ const i = n[1].charCodeAt(0), r = n[2].charCodeAt(0);
46960
+ let s;
46961
+ for (s = i; s <= r; ++s)
46962
+ e.push(t.replace(n[0], String.fromCharCode(s)));
46963
+ return e;
46964
+ }
46965
+ if (n = /\{(\d+)-(\d+)\}/.exec(t), n) {
46966
+ const i = parseInt(n[2], 10);
46967
+ for (let r = parseInt(n[1], 10); r <= i; r++)
46968
+ e.push(t.replace(n[0], r.toString()));
46969
+ return e;
46970
+ }
46971
+ return e.push(t), e;
46972
+ }
46973
+ function s6(t, e) {
46974
+ return (
46975
+ /**
46976
+ * @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
46977
+ * @param {number} pixelRatio Pixel ratio.
46978
+ * @param {import("./proj/Projection.js").default} projection Projection.
46979
+ * @return {string|undefined} Tile URL.
46980
+ */
46981
+ function(n, i, r) {
46982
+ if (!n)
46983
+ return;
46984
+ let s;
46985
+ const o = n[0];
46986
+ if (e) {
46987
+ const a = e.getFullTileRange(o);
46988
+ a && (s = a.getHeight() - 1);
46989
+ }
46990
+ return i6(t, o, n[1], n[2], s);
46991
+ }
46717
46992
  );
46718
46993
  }
46719
- function Gp(t, e) {
46720
- if (!t)
46721
- return null;
46722
- if (Array.isArray(t)) {
46723
- const i = t.map(
46724
- (r) => Gp(r, e)
46725
- );
46726
- return new nl(i);
46727
- }
46728
- const n = j8[t.type];
46729
- return Bp(
46730
- new n(t.flatCoordinates, t.layout, t.ends),
46731
- !1,
46732
- e
46994
+ function o6(t, e) {
46995
+ const n = t.length, i = new Array(n);
46996
+ for (let r = 0; r < n; ++r)
46997
+ i[r] = s6(t[r], e);
46998
+ return a6(i);
46999
+ }
47000
+ function a6(t) {
47001
+ return t.length === 1 ? t[0] : (
47002
+ /**
47003
+ * @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
47004
+ * @param {number} pixelRatio Pixel ratio.
47005
+ * @param {import("./proj/Projection.js").default} projection Projection.
47006
+ * @return {string|undefined} Tile URL.
47007
+ */
47008
+ function(e, n, i) {
47009
+ if (!e)
47010
+ return;
47011
+ const r = _B(e), s = Bs(r, t.length);
47012
+ return t[s](e, n, i);
47013
+ }
46733
47014
  );
46734
47015
  }
46735
- class X8 extends V8 {
46736
- constructor() {
46737
- super();
46738
- }
47016
+ class Wp extends q8 {
46739
47017
  /**
46740
- * @return {import("./Feature.js").Type} Format.
46741
- * @override
47018
+ * @param {Options} options Image tile options.
46742
47019
  */
46743
- getType() {
46744
- return "json";
46745
- }
46746
- /**
46747
- * Read a feature. Only works for a single feature. Use `readFeatures` to
46748
- * read a feature collection.
46749
- *
46750
- * @param {ArrayBuffer|Document|Element|Object|string} source Source.
46751
- * @param {import("./Feature.js").ReadOptions} [options] Read options.
46752
- * @return {FeatureType|Array<FeatureType>} Feature.
47020
+ constructor(e) {
47021
+ super({
47022
+ attributions: e.attributions,
47023
+ cacheSize: e.cacheSize,
47024
+ projection: e.projection,
47025
+ state: e.state,
47026
+ tileGrid: e.tileGrid,
47027
+ tilePixelRatio: e.tilePixelRatio,
47028
+ wrapX: e.wrapX,
47029
+ transition: e.transition,
47030
+ interpolate: e.interpolate,
47031
+ key: e.key,
47032
+ attributionsCollapsible: e.attributionsCollapsible,
47033
+ zDirection: e.zDirection
47034
+ }), this.generateTileUrlFunction_ = this.tileUrlFunction === Wp.prototype.tileUrlFunction, this.tileLoadFunction = e.tileLoadFunction, e.tileUrlFunction && (this.tileUrlFunction = e.tileUrlFunction), this.urls = null, e.urls ? this.setUrls(e.urls) : e.url && this.setUrl(e.url), this.tileLoadingKeys_ = {};
47035
+ }
47036
+ /**
47037
+ * Deprecated. Use an ImageTile source instead.
47038
+ * Return the tile load function of the source.
47039
+ * @return {import("../Tile.js").LoadFunction} TileLoadFunction
46753
47040
  * @api
46754
- * @override
46755
47041
  */
46756
- readFeature(e, n) {
46757
- return this.readFeatureFromObject(
46758
- Eu(e),
46759
- this.getReadOptions(e, n)
46760
- );
47042
+ getTileLoadFunction() {
47043
+ return this.tileLoadFunction;
46761
47044
  }
46762
47045
  /**
46763
- * Read all features. Works with both a single feature and a feature
46764
- * collection.
46765
- *
46766
- * @param {ArrayBuffer|Document|Element|Object|string} source Source.
46767
- * @param {import("./Feature.js").ReadOptions} [options] Read options.
46768
- * @return {Array<FeatureType>} Features.
47046
+ * Deprecated. Use an ImageTile source instead.
47047
+ * Return the tile URL function of the source.
47048
+ * @return {import("../Tile.js").UrlFunction} TileUrlFunction
46769
47049
  * @api
46770
- * @override
46771
47050
  */
46772
- readFeatures(e, n) {
46773
- return this.readFeaturesFromObject(
46774
- Eu(e),
46775
- this.getReadOptions(e, n)
46776
- );
47051
+ getTileUrlFunction() {
47052
+ return Object.getPrototypeOf(this).tileUrlFunction === this.tileUrlFunction ? this.tileUrlFunction.bind(this) : this.tileUrlFunction;
46777
47053
  }
46778
47054
  /**
46779
- * @abstract
46780
- * @param {Object} object Object.
46781
- * @param {import("./Feature.js").ReadOptions} [options] Read options.
46782
- * @protected
46783
- * @return {FeatureType|Array<FeatureType>} Feature.
47055
+ * Deprecated. Use an ImageTile source instead.
47056
+ * Return the URLs used for this source.
47057
+ * When a tileUrlFunction is used instead of url or urls,
47058
+ * null will be returned.
47059
+ * @return {!Array<string>|null} URLs.
47060
+ * @api
46784
47061
  */
46785
- readFeatureFromObject(e, n) {
46786
- return $e();
47062
+ getUrls() {
47063
+ return this.urls;
46787
47064
  }
46788
47065
  /**
46789
- * @abstract
46790
- * @param {Object} object Object.
46791
- * @param {import("./Feature.js").ReadOptions} [options] Read options.
47066
+ * Handle tile change events.
47067
+ * @param {import("../events/Event.js").default} event Event.
46792
47068
  * @protected
46793
- * @return {Array<FeatureType>} Features.
46794
47069
  */
46795
- readFeaturesFromObject(e, n) {
46796
- return $e();
47070
+ handleTileChange(e) {
47071
+ const n = (
47072
+ /** @type {import("../Tile.js").default} */
47073
+ e.target
47074
+ ), i = Xe(n), r = n.getState();
47075
+ let s;
47076
+ r == be.LOADING ? (this.tileLoadingKeys_[i] = !0, s = hh.TILELOADSTART) : i in this.tileLoadingKeys_ && (delete this.tileLoadingKeys_[i], s = r == be.ERROR ? hh.TILELOADERROR : r == be.LOADED ? hh.TILELOADEND : void 0), s != null && this.dispatchEvent(new J8(s, n));
46797
47077
  }
46798
47078
  /**
46799
- * Read a geometry.
46800
- *
46801
- * @param {ArrayBuffer|Document|Element|Object|string} source Source.
46802
- * @param {import("./Feature.js").ReadOptions} [options] Read options.
46803
- * @return {import("../geom/Geometry.js").default} Geometry.
47079
+ * Deprecated. Use an ImageTile source instead.
47080
+ * Set the tile load function of the source.
47081
+ * @param {import("../Tile.js").LoadFunction} tileLoadFunction Tile load function.
46804
47082
  * @api
46805
- * @override
46806
47083
  */
46807
- readGeometry(e, n) {
46808
- return this.readGeometryFromObject(
46809
- Eu(e),
46810
- this.getReadOptions(e, n)
46811
- );
47084
+ setTileLoadFunction(e) {
47085
+ this.tileLoadFunction = e, this.changed();
46812
47086
  }
46813
47087
  /**
46814
- * @abstract
46815
- * @param {Object} object Object.
46816
- * @param {import("./Feature.js").ReadOptions} [options] Read options.
46817
- * @protected
46818
- * @return {import("../geom/Geometry.js").default} Geometry.
47088
+ * Deprecated. Use an ImageTile source instead.
47089
+ * Set the tile URL function of the source.
47090
+ * @param {import("../Tile.js").UrlFunction} tileUrlFunction Tile URL function.
47091
+ * @param {string} [key] Optional new tile key for the source.
47092
+ * @api
46819
47093
  */
46820
- readGeometryFromObject(e, n) {
46821
- return $e();
47094
+ setTileUrlFunction(e, n) {
47095
+ this.tileUrlFunction = e, typeof n < "u" ? this.setKey(n) : this.changed();
46822
47096
  }
46823
47097
  /**
46824
- * Read the projection.
46825
- *
46826
- * @param {ArrayBuffer|Document|Element|Object|string} source Source.
46827
- * @return {import("../proj/Projection.js").default} Projection.
47098
+ * Set the URL to use for requests.
47099
+ * @param {string} url URL.
46828
47100
  * @api
46829
- * @override
46830
47101
  */
46831
- readProjection(e) {
46832
- return this.readProjectionFromObject(Eu(e));
47102
+ setUrl(e) {
47103
+ const n = r6(e);
47104
+ this.urls = n, this.setUrls(n);
46833
47105
  }
46834
47106
  /**
46835
- * @abstract
46836
- * @param {Object} object Object.
46837
- * @protected
46838
- * @return {import("../proj/Projection.js").default} Projection.
47107
+ * Deprecated. Use an ImageTile source instead.
47108
+ * Set the URLs to use for requests.
47109
+ * @param {Array<string>} urls URLs.
47110
+ * @api
46839
47111
  */
46840
- readProjectionFromObject(e) {
46841
- return $e();
47112
+ setUrls(e) {
47113
+ this.urls = e;
47114
+ const n = e.join(`
47115
+ `);
47116
+ this.generateTileUrlFunction_ ? this.setTileUrlFunction(o6(e, this.tileGrid), n) : this.setKey(n);
46842
47117
  }
46843
47118
  /**
46844
- * Encode a feature as string.
46845
- *
46846
- * @param {import("../Feature.js").default} feature Feature.
46847
- * @param {import("./Feature.js").WriteOptions} [options] Write options.
46848
- * @return {string} Encoded feature.
46849
- * @api
46850
- * @override
47119
+ * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
47120
+ * @param {number} pixelRatio Pixel ratio.
47121
+ * @param {import("../proj/Projection.js").default} projection Projection.
47122
+ * @return {string|undefined} Tile URL.
46851
47123
  */
46852
- writeFeature(e, n) {
46853
- return JSON.stringify(this.writeFeatureObject(e, n));
47124
+ tileUrlFunction(e, n, i) {
46854
47125
  }
47126
+ }
47127
+ class l6 extends Wp {
46855
47128
  /**
46856
- * @abstract
46857
- * @param {import("../Feature.js").default} feature Feature.
46858
- * @param {import("./Feature.js").WriteOptions} [options] Write options.
46859
- * @return {Object} Object.
47129
+ * @param {!Options} options Image tile options.
46860
47130
  */
46861
- writeFeatureObject(e, n) {
46862
- return $e();
47131
+ constructor(e) {
47132
+ super({
47133
+ attributions: e.attributions,
47134
+ cacheSize: e.cacheSize,
47135
+ projection: e.projection,
47136
+ state: e.state,
47137
+ tileGrid: e.tileGrid,
47138
+ tileLoadFunction: e.tileLoadFunction ? e.tileLoadFunction : u6,
47139
+ tilePixelRatio: e.tilePixelRatio,
47140
+ tileUrlFunction: e.tileUrlFunction,
47141
+ url: e.url,
47142
+ urls: e.urls,
47143
+ wrapX: e.wrapX,
47144
+ transition: e.transition,
47145
+ interpolate: e.interpolate !== void 0 ? e.interpolate : !0,
47146
+ key: e.key,
47147
+ attributionsCollapsible: e.attributionsCollapsible,
47148
+ zDirection: e.zDirection
47149
+ }), this.crossOrigin = e.crossOrigin !== void 0 ? e.crossOrigin : null, this.tileClass = e.tileClass !== void 0 ? e.tileClass : mw, this.tileGridForProjection = {}, this.reprojectionErrorThreshold_ = e.reprojectionErrorThreshold, this.renderReprojectionEdges_ = !1;
46863
47150
  }
46864
47151
  /**
46865
- * Encode an array of features as string.
46866
- *
46867
- * @param {Array<import("../Feature.js").default>} features Features.
46868
- * @param {import("./Feature.js").WriteOptions} [options] Write options.
46869
- * @return {string} Encoded features.
46870
- * @api
47152
+ * @param {import("../proj/Projection.js").default} projection Projection.
47153
+ * @return {number} Gutter.
46871
47154
  * @override
46872
47155
  */
46873
- writeFeatures(e, n) {
46874
- return JSON.stringify(this.writeFeaturesObject(e, n));
47156
+ getGutterForProjection(e) {
47157
+ return this.getProjection() && e && !Ou(this.getProjection(), e) ? 0 : this.getGutter();
46875
47158
  }
46876
47159
  /**
46877
- * @abstract
46878
- * @param {Array<import("../Feature.js").default>} features Features.
46879
- * @param {import("./Feature.js").WriteOptions} [options] Write options.
46880
- * @return {Object} Object.
47160
+ * @return {number} Gutter.
46881
47161
  */
46882
- writeFeaturesObject(e, n) {
46883
- return $e();
47162
+ getGutter() {
47163
+ return 0;
46884
47164
  }
46885
47165
  /**
46886
- * Encode a geometry as string.
46887
- *
46888
- * @param {import("../geom/Geometry.js").default} geometry Geometry.
46889
- * @param {import("./Feature.js").WriteOptions} [options] Write options.
46890
- * @return {string} Encoded geometry.
46891
- * @api
47166
+ * Return the key to be used for all tiles in the source.
47167
+ * @return {string} The key for all tiles.
46892
47168
  * @override
46893
47169
  */
46894
- writeGeometry(e, n) {
46895
- return JSON.stringify(this.writeGeometryObject(e, n));
47170
+ getKey() {
47171
+ let e = super.getKey();
47172
+ return this.getInterpolate() || (e += ":disable-interpolation"), e;
46896
47173
  }
46897
47174
  /**
46898
- * @abstract
46899
- * @param {import("../geom/Geometry.js").default} geometry Geometry.
46900
- * @param {import("./Feature.js").WriteOptions} [options] Write options.
46901
- * @return {Object} Object.
47175
+ * @param {import("../proj/Projection.js").default} projection Projection.
47176
+ * @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
47177
+ * @override
46902
47178
  */
46903
- writeGeometryObject(e, n) {
46904
- return $e();
46905
- }
46906
- }
46907
- function Eu(t) {
46908
- if (typeof t == "string") {
46909
- const e = JSON.parse(t);
46910
- return e || null;
47179
+ getTileGridForProjection(e) {
47180
+ const n = this.getProjection();
47181
+ if (this.tileGrid && (!n || Ou(n, e)))
47182
+ return this.tileGrid;
47183
+ const i = Xe(e);
47184
+ return i in this.tileGridForProjection || (this.tileGridForProjection[i] = Iw(e)), this.tileGridForProjection[i];
46911
47185
  }
46912
- return t !== null ? t : null;
46913
- }
46914
- class G6 extends X8 {
46915
47186
  /**
46916
- * @param {Options<FeatureType>} [options] Options.
47187
+ * @param {number} z Tile coordinate z.
47188
+ * @param {number} x Tile coordinate x.
47189
+ * @param {number} y Tile coordinate y.
47190
+ * @param {number} pixelRatio Pixel ratio.
47191
+ * @param {import("../proj/Projection.js").default} projection Projection.
47192
+ * @param {string} key The key set on the tile.
47193
+ * @return {!ImageTile} Tile.
47194
+ * @private
46917
47195
  */
46918
- constructor(e) {
46919
- e = e || {}, super(), this.dataProjection = Vt(
46920
- e.dataProjection ? e.dataProjection : "EPSG:4326"
46921
- ), e.featureProjection && (this.defaultFeatureProjection = Vt(e.featureProjection)), e.featureClass && (this.featureClass = e.featureClass), this.geometryName_ = e.geometryName, this.extractGeometryName_ = e.extractGeometryName, this.supportedMediaTypes = [
46922
- "application/geo+json",
46923
- "application/vnd.geo+json"
46924
- ];
47196
+ createTile_(e, n, i, r, s, o) {
47197
+ const a = [e, n, i], l = this.getTileCoordForTileUrlFunction(
47198
+ a,
47199
+ s
47200
+ ), u = l ? this.tileUrlFunction(l, r, s) : void 0, c = new this.tileClass(
47201
+ a,
47202
+ u !== void 0 ? be.IDLE : be.EMPTY,
47203
+ u !== void 0 ? u : "",
47204
+ this.crossOrigin,
47205
+ this.tileLoadFunction,
47206
+ this.tileOptions
47207
+ );
47208
+ return c.key = o, c.addEventListener(ze.CHANGE, this.handleTileChange.bind(this)), c;
46925
47209
  }
46926
47210
  /**
46927
- * @param {Object} object Object.
46928
- * @param {import("./Feature.js").ReadOptions} [options] Read options.
46929
- * @protected
46930
- * @return {FeatureType|Array<FeatureType>} Feature.
46931
- * @override
46932
- */
46933
- readFeatureFromObject(e, n) {
46934
- let i = null;
46935
- e.type === "Feature" ? i = /** @type {GeoJSONFeature} */
46936
- e : i = {
46937
- type: "Feature",
46938
- geometry: (
46939
- /** @type {GeoJSONGeometry} */
46940
- e
46941
- ),
46942
- properties: null
46943
- };
46944
- const r = Wp(i.geometry);
46945
- if (this.featureClass === ri)
46946
- return (
46947
- /** @type {FeatureType|Array<FeatureType>} */
46948
- kw(
46949
- {
46950
- geometry: r,
46951
- id: i.id,
46952
- properties: i.properties
46953
- },
46954
- n
46955
- )
46956
- );
46957
- const s = new Ki();
46958
- return this.geometryName_ ? s.setGeometryName(this.geometryName_) : this.extractGeometryName_ && i.geometry_name && s.setGeometryName(i.geometry_name), s.setGeometry(Gp(r, n)), "id" in i && s.setId(i.id), i.properties && s.setProperties(i.properties, !0), /** @type {FeatureType|Array<FeatureType>} */
46959
- s;
46960
- }
46961
- /**
46962
- * @param {Object} object Object.
46963
- * @param {import("./Feature.js").ReadOptions} [options] Read options.
46964
- * @protected
46965
- * @return {Array<FeatureType>} Features.
47211
+ * @param {number} z Tile coordinate z.
47212
+ * @param {number} x Tile coordinate x.
47213
+ * @param {number} y Tile coordinate y.
47214
+ * @param {number} pixelRatio Pixel ratio.
47215
+ * @param {import("../proj/Projection.js").default} projection Projection.
47216
+ * @return {!(ImageTile|ReprojTile)} Tile.
46966
47217
  * @override
46967
47218
  */
46968
- readFeaturesFromObject(e, n) {
46969
- const i = (
46970
- /** @type {GeoJSONObject} */
46971
- e
46972
- );
46973
- let r = null;
46974
- if (i.type === "FeatureCollection") {
46975
- const s = (
46976
- /** @type {GeoJSONFeatureCollection} */
46977
- e
47219
+ getTile(e, n, i, r, s) {
47220
+ const o = this.getProjection();
47221
+ if (!o || !s || Ou(o, s))
47222
+ return this.getTileInternal(
47223
+ e,
47224
+ n,
47225
+ i,
47226
+ r,
47227
+ o || s
46978
47228
  );
46979
- r = [];
46980
- const o = s.features;
46981
- for (let a = 0, l = o.length; a < l; ++a) {
46982
- const u = this.readFeatureFromObject(
46983
- o[a],
46984
- n
46985
- );
46986
- u && r.push(u);
46987
- }
46988
- } else
46989
- r = [this.readFeatureFromObject(e, n)];
46990
- return (
46991
- /** @type {Array<FeatureType>} */
46992
- r.flat()
47229
+ const a = [e, n, i], l = this.getKey(), u = this.getTileGridForProjection(o), c = this.getTileGridForProjection(s), d = this.getTileCoordForTileUrlFunction(
47230
+ a,
47231
+ s
47232
+ ), h = new Cf(
47233
+ o,
47234
+ u,
47235
+ s,
47236
+ c,
47237
+ a,
47238
+ d,
47239
+ this.getTilePixelRatio(r),
47240
+ this.getGutter(),
47241
+ (p, f, m, _) => this.getTileInternal(p, f, m, _, o),
47242
+ this.reprojectionErrorThreshold_,
47243
+ this.renderReprojectionEdges_,
47244
+ this.tileOptions
46993
47245
  );
47246
+ return h.key = l, h;
46994
47247
  }
46995
47248
  /**
46996
- * @param {GeoJSONGeometry} object Object.
46997
- * @param {import("./Feature.js").ReadOptions} [options] Read options.
47249
+ * @param {number} z Tile coordinate z.
47250
+ * @param {number} x Tile coordinate x.
47251
+ * @param {number} y Tile coordinate y.
47252
+ * @param {number} pixelRatio Pixel ratio.
47253
+ * @param {!import("../proj/Projection.js").default} projection Projection.
47254
+ * @return {!ImageTile} Tile.
46998
47255
  * @protected
46999
- * @return {import("../geom/Geometry.js").default} Geometry.
47000
- * @override
47001
47256
  */
47002
- readGeometryFromObject(e, n) {
47003
- return K8(e, n);
47257
+ getTileInternal(e, n, i, r, s) {
47258
+ const o = this.getKey();
47259
+ return this.createTile_(e, n, i, r, s, o);
47004
47260
  }
47005
47261
  /**
47006
- * @param {Object} object Object.
47007
- * @protected
47008
- * @return {import("../proj/Projection.js").default} Projection.
47009
- * @override
47262
+ * Sets whether to render reprojection edges or not (usually for debugging).
47263
+ * @param {boolean} render Render the edges.
47264
+ * @api
47010
47265
  */
47011
- readProjectionFromObject(e) {
47012
- const n = e.crs;
47013
- let i;
47014
- if (n)
47015
- if (n.type == "name")
47016
- i = Vt(n.properties.name);
47017
- else if (n.type === "EPSG")
47018
- i = Vt("EPSG:" + n.properties.code);
47019
- else
47020
- throw new Error("Unknown SRS type");
47021
- else
47022
- i = this.dataProjection;
47023
- return (
47024
- /** @type {import("../proj/Projection.js").default} */
47025
- i
47026
- );
47266
+ setRenderReprojectionEdges(e) {
47267
+ this.renderReprojectionEdges_ != e && (this.renderReprojectionEdges_ = e, this.changed());
47027
47268
  }
47028
47269
  /**
47029
- * Encode a feature as a GeoJSON Feature object.
47270
+ * Sets the tile grid to use when reprojecting the tiles to the given
47271
+ * projection instead of the default tile grid for the projection.
47030
47272
  *
47031
- * @param {import("../Feature.js").default} feature Feature.
47032
- * @param {import("./Feature.js").WriteOptions} [options] Write options.
47033
- * @return {GeoJSONFeature} Object.
47273
+ * This can be useful when the default tile grid cannot be created
47274
+ * (e.g. projection has no extent defined) or
47275
+ * for optimization reasons (custom tile size, resolutions, ...).
47276
+ *
47277
+ * @param {import("../proj.js").ProjectionLike} projection Projection.
47278
+ * @param {import("../tilegrid/TileGrid.js").default} tilegrid Tile grid to use for the projection.
47034
47279
  * @api
47035
- * @override
47036
47280
  */
47037
- writeFeatureObject(e, n) {
47038
- n = this.adaptOptions(n);
47039
- const i = {
47040
- type: "Feature",
47041
- geometry: null,
47042
- properties: null
47043
- }, r = e.getId();
47044
- if (r !== void 0 && (i.id = r), !e.hasProperties())
47045
- return i;
47046
- const s = e.getProperties(), o = e.getGeometry();
47047
- return o && (i.geometry = Tf(o, n), delete s[e.getGeometryName()]), Xs(s) || (i.properties = s), i;
47281
+ setTileGridForProjection(e, n) {
47282
+ const i = Vt(e);
47283
+ if (i) {
47284
+ const r = Xe(i);
47285
+ r in this.tileGridForProjection || (this.tileGridForProjection[r] = n);
47286
+ }
47048
47287
  }
47288
+ }
47289
+ function u6(t, e) {
47290
+ t.getImage().src = e;
47291
+ }
47292
+ class G6 extends l6 {
47049
47293
  /**
47050
- * Encode an array of features as a GeoJSON object.
47051
- *
47052
- * @param {Array<import("../Feature.js").default>} features Features.
47053
- * @param {import("./Feature.js").WriteOptions} [options] Write options.
47054
- * @return {GeoJSONFeatureCollection} GeoJSON Object.
47055
- * @api
47056
- * @override
47294
+ * @param {Options} [options] XYZ options.
47057
47295
  */
47058
- writeFeaturesObject(e, n) {
47059
- n = this.adaptOptions(n);
47060
- const i = [];
47061
- for (let r = 0, s = e.length; r < s; ++r)
47062
- i.push(this.writeFeatureObject(e[r], n));
47063
- return {
47064
- type: "FeatureCollection",
47065
- features: i
47066
- };
47296
+ constructor(e) {
47297
+ e = e || {};
47298
+ const n = e.projection !== void 0 ? e.projection : "EPSG:3857", i = e.tileGrid !== void 0 ? e.tileGrid : K8({
47299
+ extent: Gp(n),
47300
+ maxResolution: e.maxResolution,
47301
+ maxZoom: e.maxZoom,
47302
+ minZoom: e.minZoom,
47303
+ tileSize: e.tileSize
47304
+ });
47305
+ super({
47306
+ attributions: e.attributions,
47307
+ cacheSize: e.cacheSize,
47308
+ crossOrigin: e.crossOrigin,
47309
+ interpolate: e.interpolate,
47310
+ projection: n,
47311
+ reprojectionErrorThreshold: e.reprojectionErrorThreshold,
47312
+ tileGrid: i,
47313
+ tileLoadFunction: e.tileLoadFunction,
47314
+ tilePixelRatio: e.tilePixelRatio,
47315
+ tileUrlFunction: e.tileUrlFunction,
47316
+ url: e.url,
47317
+ urls: e.urls,
47318
+ wrapX: e.wrapX !== void 0 ? e.wrapX : !0,
47319
+ transition: e.transition,
47320
+ attributionsCollapsible: e.attributionsCollapsible,
47321
+ zDirection: e.zDirection
47322
+ }), this.gutter_ = e.gutter !== void 0 ? e.gutter : 0;
47067
47323
  }
47068
47324
  /**
47069
- * Encode a geometry as a GeoJSON object.
47070
- *
47071
- * @param {import("../geom/Geometry.js").default} geometry Geometry.
47072
- * @param {import("./Feature.js").WriteOptions} [options] Write options.
47073
- * @return {GeoJSONGeometry|GeoJSONGeometryCollection} Object.
47074
- * @api
47325
+ * @return {number} Gutter.
47075
47326
  * @override
47076
47327
  */
47077
- writeGeometryObject(e, n) {
47078
- return Tf(e, this.adaptOptions(n));
47079
- }
47080
- }
47081
- function Wp(t, e) {
47082
- if (!t)
47083
- return null;
47084
- let n;
47085
- switch (t.type) {
47086
- case "Point": {
47087
- n = q8(
47088
- /** @type {GeoJSONPoint} */
47089
- t
47090
- );
47091
- break;
47092
- }
47093
- case "LineString": {
47094
- n = J8(
47095
- /** @type {GeoJSONLineString} */
47096
- t
47097
- );
47098
- break;
47099
- }
47100
- case "Polygon": {
47101
- n = n6(
47102
- /** @type {GeoJSONPolygon} */
47103
- t
47104
- );
47105
- break;
47106
- }
47107
- case "MultiPoint": {
47108
- n = e6(
47109
- /** @type {GeoJSONMultiPoint} */
47110
- t
47111
- );
47112
- break;
47113
- }
47114
- case "MultiLineString": {
47115
- n = Q8(
47116
- /** @type {GeoJSONMultiLineString} */
47117
- t
47118
- );
47119
- break;
47120
- }
47121
- case "MultiPolygon": {
47122
- n = t6(
47123
- /** @type {GeoJSONMultiPolygon} */
47124
- t
47125
- );
47126
- break;
47127
- }
47128
- case "GeometryCollection": {
47129
- n = Z8(
47130
- /** @type {GeoJSONGeometryCollection} */
47131
- t
47132
- );
47133
- break;
47134
- }
47135
- default:
47136
- throw new Error("Unsupported GeoJSON type: " + t.type);
47137
- }
47138
- return n;
47139
- }
47140
- function K8(t, e) {
47141
- const n = Wp(t);
47142
- return Gp(n, e);
47143
- }
47144
- function Z8(t, e) {
47145
- return t.geometries.map(
47146
- /**
47147
- * @param {GeoJSONGeometry} geometry Geometry.
47148
- * @return {import("./Feature.js").GeometryObject} geometry Geometry.
47149
- */
47150
- function(i) {
47151
- return Wp(i);
47152
- }
47153
- );
47154
- }
47155
- function q8(t) {
47156
- const e = t.coordinates;
47157
- return {
47158
- type: "Point",
47159
- flatCoordinates: e,
47160
- layout: io(e.length)
47161
- };
47162
- }
47163
- function J8(t) {
47164
- var i;
47165
- const e = t.coordinates, n = e.flat();
47166
- return {
47167
- type: "LineString",
47168
- flatCoordinates: n,
47169
- ends: [n.length],
47170
- layout: io(((i = e[0]) == null ? void 0 : i.length) || 2)
47171
- };
47172
- }
47173
- function Q8(t) {
47174
- var s, o;
47175
- const e = t.coordinates, n = ((o = (s = e[0]) == null ? void 0 : s[0]) == null ? void 0 : o.length) || 2, i = [], r = Ol(i, 0, e, n);
47176
- return {
47177
- type: "MultiLineString",
47178
- flatCoordinates: i,
47179
- ends: r,
47180
- layout: io(n)
47181
- };
47182
- }
47183
- function e6(t) {
47184
- var n;
47185
- const e = t.coordinates;
47186
- return {
47187
- type: "MultiPoint",
47188
- flatCoordinates: e.flat(),
47189
- layout: io(((n = e[0]) == null ? void 0 : n.length) || 2)
47190
- };
47191
- }
47192
- function t6(t) {
47193
- var s, o;
47194
- const e = t.coordinates, n = [], i = ((o = (s = e[0]) == null ? void 0 : s[0]) == null ? void 0 : o[0].length) || 2, r = C1(
47195
- n,
47196
- 0,
47197
- e,
47198
- i
47199
- );
47200
- return {
47201
- type: "MultiPolygon",
47202
- flatCoordinates: n,
47203
- ends: r,
47204
- layout: io(i)
47205
- };
47206
- }
47207
- function n6(t) {
47208
- var s, o;
47209
- const e = t.coordinates, n = [], i = (o = (s = e[0]) == null ? void 0 : s[0]) == null ? void 0 : o.length, r = Ol(n, 0, e, i);
47210
- return {
47211
- type: "Polygon",
47212
- flatCoordinates: n,
47213
- ends: r,
47214
- layout: io(i)
47215
- };
47216
- }
47217
- function Tf(t, e) {
47218
- t = Bp(t, !0, e);
47219
- const n = t.getType();
47220
- let i;
47221
- switch (n) {
47222
- case "Point": {
47223
- i = l6(
47224
- /** @type {import("../geom/Point.js").default} */
47225
- t
47226
- );
47227
- break;
47228
- }
47229
- case "LineString": {
47230
- i = r6(
47231
- /** @type {import("../geom/LineString.js").default} */
47232
- t
47233
- );
47234
- break;
47235
- }
47236
- case "Polygon": {
47237
- i = u6(
47238
- /** @type {import("../geom/Polygon.js").default} */
47239
- t,
47240
- e
47241
- );
47242
- break;
47243
- }
47244
- case "MultiPoint": {
47245
- i = o6(
47246
- /** @type {import("../geom/MultiPoint.js").default} */
47247
- t
47248
- );
47249
- break;
47250
- }
47251
- case "MultiLineString": {
47252
- i = s6(
47253
- /** @type {import("../geom/MultiLineString.js").default} */
47254
- t
47255
- );
47256
- break;
47257
- }
47258
- case "MultiPolygon": {
47259
- i = a6(
47260
- /** @type {import("../geom/MultiPolygon.js").default} */
47261
- t,
47262
- e
47263
- );
47264
- break;
47265
- }
47266
- case "GeometryCollection": {
47267
- i = i6(
47268
- /** @type {import("../geom/GeometryCollection.js").default} */
47269
- t,
47270
- e
47271
- );
47272
- break;
47273
- }
47274
- case "Circle": {
47275
- i = {
47276
- type: "GeometryCollection",
47277
- geometries: []
47278
- };
47279
- break;
47280
- }
47281
- default:
47282
- throw new Error("Unsupported geometry type: " + n);
47328
+ getGutter() {
47329
+ return this.gutter_;
47283
47330
  }
47284
- return i;
47285
- }
47286
- function i6(t, e) {
47287
- return e = Object.assign({}, e), delete e.featureProjection, {
47288
- type: "GeometryCollection",
47289
- geometries: t.getGeometriesArray().map(function(i) {
47290
- return Tf(i, e);
47291
- })
47292
- };
47293
- }
47294
- function r6(t, e) {
47295
- return {
47296
- type: "LineString",
47297
- coordinates: t.getCoordinates()
47298
- };
47299
- }
47300
- function s6(t, e) {
47301
- return {
47302
- type: "MultiLineString",
47303
- coordinates: t.getCoordinates()
47304
- };
47305
- }
47306
- function o6(t, e) {
47307
- return {
47308
- type: "MultiPoint",
47309
- coordinates: t.getCoordinates()
47310
- };
47311
- }
47312
- function a6(t, e) {
47313
- let n;
47314
- return e && (n = e.rightHanded), {
47315
- type: "MultiPolygon",
47316
- coordinates: t.getCoordinates(n)
47317
- };
47318
- }
47319
- function l6(t, e) {
47320
- return {
47321
- type: "Point",
47322
- coordinates: t.getCoordinates()
47323
- };
47324
- }
47325
- function u6(t, e) {
47326
- let n;
47327
- return e && (n = e.rightHanded), {
47328
- type: "Polygon",
47329
- coordinates: t.getCoordinates(n)
47330
- };
47331
47331
  }
47332
47332
  export {
47333
47333
  F6 as A,
@@ -47336,7 +47336,7 @@ export {
47336
47336
  k6 as D,
47337
47337
  Va as E,
47338
47338
  Ks as F,
47339
- G6 as G,
47339
+ $6 as G,
47340
47340
  Er as H,
47341
47341
  fd as I,
47342
47342
  R6 as J,
@@ -47350,7 +47350,7 @@ export {
47350
47350
  fp as T,
47351
47351
  k3 as V,
47352
47352
  N6 as W,
47353
- B6 as X,
47353
+ G6 as X,
47354
47354
  y6 as a,
47355
47355
  b6 as b,
47356
47356
  w6 as c,
@@ -47369,11 +47369,11 @@ export {
47369
47369
  V5 as p,
47370
47370
  Gs as q,
47371
47371
  x6 as r,
47372
- $6 as s,
47373
- Ki as t,
47372
+ Ki as s,
47373
+ P6 as t,
47374
47374
  h$ as u,
47375
- P6 as v,
47376
- sd as w,
47375
+ sd as v,
47376
+ B6 as w,
47377
47377
  A6 as x,
47378
47378
  I6 as y,
47379
47379
  ms as z