ol-cesium-vue-components
Version:
Vue components for OpenLayers and Cesium integration
8,025 lines • 244 kB
JavaScript
var Fi = Object.defineProperty;
var Oi = (i, t, e) => t in i ? Fi(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
var gn = (i, t, e) => Oi(i, typeof t != "symbol" ? t + "" : t, e);
import { defineComponent as Li, ref as _n, onMounted as bi, getCurrentInstance as Xi, provide as mn, resolveComponent as Ni, createElementBlock as Gi, openBlock as Di, createVNode as Rn, withCtx as zi, createTextVNode as Zi, toDisplayString as ji } from "vue";
import { Map as Yi, View as Ui } from "ol";
import * as Ki from "cesium";
const G = {
UNKNOWN: 0,
INTERSECTING: 1,
ABOVE: 2,
RIGHT: 4,
BELOW: 8,
LEFT: 16
};
function pn(i) {
const t = Ct();
for (let e = 0, n = i.length; e < n; ++e)
se(t, i[e]);
return t;
}
function Wi(i, t, e) {
const n = Math.min.apply(null, i), s = Math.min.apply(null, t), r = Math.max.apply(null, i), o = Math.max.apply(null, t);
return zt(n, s, r, o, e);
}
function Hn(i, t, e) {
let n, s;
return t < i[0] ? n = i[0] - t : i[2] < t ? n = t - i[2] : n = 0, e < i[1] ? s = i[1] - e : i[3] < e ? s = e - i[3] : s = 0, n * n + s * s;
}
function Ue(i, t) {
return Qn(i, t[0], t[1]);
}
function Qn(i, t, e) {
return i[0] <= t && t <= i[2] && i[1] <= e && e <= i[3];
}
function yn(i, t) {
const e = i[0], n = i[1], s = i[2], r = i[3], o = t[0], a = t[1];
let l = G.UNKNOWN;
return o < e ? l = l | G.LEFT : o > s && (l = l | G.RIGHT), a < n ? l = l | G.BELOW : a > r && (l = l | G.ABOVE), l === G.UNKNOWN && (l = G.INTERSECTING), l;
}
function Ct() {
return [1 / 0, 1 / 0, -1 / 0, -1 / 0];
}
function zt(i, t, e, n, s) {
return s ? (s[0] = i, s[1] = t, s[2] = e, s[3] = n, s) : [i, t, e, n];
}
function fe(i) {
return zt(1 / 0, 1 / 0, -1 / 0, -1 / 0, i);
}
function ki(i, t) {
const e = i[0], n = i[1];
return zt(e, n, e, n, t);
}
function Vi(i, t, e, n, s) {
const r = fe(s);
return Jn(r, i, t, e, n);
}
function Bi(i, t) {
return i[0] == t[0] && i[2] == t[2] && i[1] == t[1] && i[3] == t[3];
}
function $i(i, t) {
return t[0] < i[0] && (i[0] = t[0]), t[2] > i[2] && (i[2] = t[2]), t[1] < i[1] && (i[1] = t[1]), t[3] > i[3] && (i[3] = t[3]), i;
}
function se(i, t) {
t[0] < i[0] && (i[0] = t[0]), t[0] > i[2] && (i[2] = t[0]), t[1] < i[1] && (i[1] = t[1]), t[1] > i[3] && (i[3] = t[1]);
}
function Jn(i, t, e, n, s) {
for (; e < n; e += s)
qi(i, t[e], t[e + 1]);
return i;
}
function qi(i, t, e) {
i[0] = Math.min(i[0], t), i[1] = Math.min(i[1], e), i[2] = Math.max(i[2], t), i[3] = Math.max(i[3], e);
}
function ti(i, t) {
let e;
return e = t(ge(i)), e || (e = t(_e(i)), e) || (e = t(me(i)), e) || (e = t(Mt(i)), e) ? e : !1;
}
function Ne(i) {
let t = 0;
return Re(i) || (t = v(i) * W(i)), t;
}
function ge(i) {
return [i[0], i[1]];
}
function _e(i) {
return [i[2], i[1]];
}
function Gt(i) {
return [(i[0] + i[2]) / 2, (i[1] + i[3]) / 2];
}
function Hi(i, t) {
let e;
if (t === "bottom-left")
e = ge(i);
else if (t === "bottom-right")
e = _e(i);
else if (t === "top-left")
e = Mt(i);
else if (t === "top-right")
e = me(i);
else
throw new Error("Invalid corner");
return e;
}
function Qi(i, t, e, n, s) {
const [r, o, a, l, c, h, u, d] = ei(
i,
t,
e,
n
);
return zt(
Math.min(r, a, c, u),
Math.min(o, l, h, d),
Math.max(r, a, c, u),
Math.max(o, l, h, d),
s
);
}
function ei(i, t, e, n) {
const s = t * n[0] / 2, r = t * n[1] / 2, o = Math.cos(e), a = Math.sin(e), l = s * o, c = s * a, h = r * o, u = r * a, d = i[0], g = i[1];
return [
d - l + u,
g - c - h,
d - l - u,
g - c + h,
d + l - u,
g + c + h,
d + l + u,
g + c - h,
d - l + u,
g - c - h
];
}
function W(i) {
return i[3] - i[1];
}
function Ot(i, t, e) {
const n = e || Ct();
return kt(i, t) ? (i[0] > t[0] ? n[0] = i[0] : n[0] = t[0], i[1] > t[1] ? n[1] = i[1] : n[1] = t[1], i[2] < t[2] ? n[2] = i[2] : n[2] = t[2], i[3] < t[3] ? n[3] = i[3] : n[3] = t[3]) : fe(n), n;
}
function Mt(i) {
return [i[0], i[3]];
}
function me(i) {
return [i[2], i[3]];
}
function v(i) {
return i[2] - i[0];
}
function kt(i, t) {
return i[0] <= t[2] && i[2] >= t[0] && i[1] <= t[3] && i[3] >= t[1];
}
function Re(i) {
return i[2] < i[0] || i[3] < i[1];
}
function Ji(i, t) {
return t ? (t[0] = i[0], t[1] = i[1], t[2] = i[2], t[3] = i[3], t) : i;
}
function ts(i, t, e) {
let n = !1;
const s = yn(i, t), r = yn(i, e);
if (s === G.INTERSECTING || r === G.INTERSECTING)
n = !0;
else {
const o = i[0], a = i[1], l = i[2], c = i[3], h = t[0], u = t[1], d = e[0], g = e[1], f = (g - u) / (d - h);
let _, m;
r & G.ABOVE && !(s & G.ABOVE) && (_ = d - (g - c) / f, n = _ >= o && _ <= l), !n && r & G.RIGHT && !(s & G.RIGHT) && (m = g - (d - l) * f, n = m >= a && m <= c), !n && r & G.BELOW && !(s & G.BELOW) && (_ = d - (g - a) / f, n = _ >= o && _ <= l), !n && r & G.LEFT && !(s & G.LEFT) && (m = g - (d - o) * f, n = m >= a && m <= c);
}
return n;
}
function es(i, t, e, n) {
if (Re(i))
return fe(e);
let s = [];
s = [
i[0],
i[1],
i[2],
i[1],
i[2],
i[3],
i[0],
i[3]
], t(s, s, 2);
const r = [], o = [];
for (let a = 0, l = s.length; a < l; a += 2)
r.push(s[a]), o.push(s[a + 1]);
return Wi(r, o, e);
}
function ns(i, t) {
const e = t.getExtent(), n = Gt(i);
if (t.canWrapX() && (n[0] < e[0] || n[0] >= e[2])) {
const s = v(e), o = Math.floor(
(n[0] - e[0]) / s
) * s;
i[0] -= o, i[2] -= o;
}
return i;
}
function is(i, t, e) {
if (t.canWrapX()) {
const n = t.getExtent();
if (!isFinite(i[0]) || !isFinite(i[2]))
return [[n[0], i[1], n[2], i[3]]];
ns(i, t);
const s = v(n);
if (v(i) > s, i[0] < n[0])
return [
[i[0] + s, i[1], n[2], i[3]],
[n[0], i[1], i[2], i[3]]
];
if (i[2] > n[2])
return [
[i[0], i[1], n[2], i[3]],
[n[0], i[1], i[2] - s, i[3]]
];
}
return [i];
}
class ni {
constructor() {
this.disposed = !1;
}
/**
* Clean up.
*/
dispose() {
this.disposed || (this.disposed = !0, this.disposeInternal());
}
/**
* Extension point for disposable objects.
* @protected
*/
disposeInternal() {
}
}
function D(i, t) {
if (!i)
throw new Error(t);
}
class ss {
/**
* @param {number} [highWaterMark] High water mark.
*/
constructor(t) {
this.highWaterMark = t !== void 0 ? t : 2048, this.count_ = 0, this.entries_ = {}, this.oldest_ = null, this.newest_ = null;
}
deleteOldest() {
const t = this.pop();
t instanceof ni && t.dispose();
}
/**
* @return {boolean} Can expire cache.
*/
canExpireCache() {
return this.highWaterMark > 0 && this.getCount() > this.highWaterMark;
}
/**
* Expire the cache. When the cache entry is a {@link module:ol/Disposable~Disposable},
* the entry will be disposed.
* @param {!Object<string, boolean>} [keep] Keys to keep. To be implemented by subclasses.
*/
expireCache(t) {
for (; this.canExpireCache(); )
this.deleteOldest();
}
/**
* FIXME empty description for jsdoc
*/
clear() {
for (; this.oldest_; )
this.deleteOldest();
}
/**
* @param {string} key Key.
* @return {boolean} Contains key.
*/
containsKey(t) {
return this.entries_.hasOwnProperty(t);
}
/**
* @param {function(T, string, LRUCache<T>): ?} f The function
* to call for every entry from the oldest to the newer. This function takes
* 3 arguments (the entry value, the entry key and the LRUCache object).
* The return value is ignored.
*/
forEach(t) {
let e = this.oldest_;
for (; e; )
t(e.value_, e.key_, this), e = e.newer;
}
/**
* @param {string} key Key.
* @param {*} [options] Options (reserved for subclasses).
* @return {T} Value.
*/
get(t, e) {
const n = this.entries_[t];
return D(
n !== void 0,
"Tried to get a value for a key that does not exist in the cache"
), n === this.newest_ || (n === this.oldest_ ? (this.oldest_ = /** @type {Entry} */
this.oldest_.newer, this.oldest_.older = null) : (n.newer.older = n.older, n.older.newer = n.newer), n.newer = null, n.older = this.newest_, this.newest_.newer = n, this.newest_ = n), n.value_;
}
/**
* Remove an entry from the cache.
* @param {string} key The entry key.
* @return {T} The removed entry.
*/
remove(t) {
const e = this.entries_[t];
return D(
e !== void 0,
"Tried to get a value for a key that does not exist in the cache"
), e === this.newest_ ? (this.newest_ = /** @type {Entry} */
e.older, this.newest_ && (this.newest_.newer = null)) : e === this.oldest_ ? (this.oldest_ = /** @type {Entry} */
e.newer, this.oldest_ && (this.oldest_.older = null)) : (e.newer.older = e.older, e.older.newer = e.newer), delete this.entries_[t], --this.count_, e.value_;
}
/**
* @return {number} Count.
*/
getCount() {
return this.count_;
}
/**
* @return {Array<string>} Keys.
*/
getKeys() {
const t = new Array(this.count_);
let e = 0, n;
for (n = this.newest_; n; n = n.older)
t[e++] = n.key_;
return t;
}
/**
* @return {Array<T>} Values.
*/
getValues() {
const t = new Array(this.count_);
let e = 0, n;
for (n = this.newest_; n; n = n.older)
t[e++] = n.value_;
return t;
}
/**
* @return {T} Last value.
*/
peekLast() {
return this.oldest_.value_;
}
/**
* @return {string} Last key.
*/
peekLastKey() {
return this.oldest_.key_;
}
/**
* Get the key of the newest item in the cache. Throws if the cache is empty.
* @return {string} The newest key.
*/
peekFirstKey() {
return this.newest_.key_;
}
/**
* Return an entry without updating least recently used time.
* @param {string} key Key.
* @return {T|undefined} Value.
*/
peek(t) {
var e;
return (e = this.entries_[t]) == null ? void 0 : e.value_;
}
/**
* @return {T} value Value.
*/
pop() {
const t = this.oldest_;
return delete this.entries_[t.key_], t.newer && (t.newer.older = null), this.oldest_ = /** @type {Entry} */
t.newer, this.oldest_ || (this.newest_ = null), --this.count_, t.value_;
}
/**
* @param {string} key Key.
* @param {T} value Value.
*/
replace(t, e) {
this.get(t), this.entries_[t].value_ = e;
}
/**
* @param {string} key Key.
* @param {T} value Value.
*/
set(t, e) {
D(
!(t in this.entries_),
"Tried to set a value for a key that is used already"
);
const n = {
key_: t,
newer: null,
older: this.newest_,
value_: e
};
this.newest_ ? this.newest_.newer = n : this.oldest_ = n, this.newest_ = n, this.entries_[t] = n, ++this.count_;
}
/**
* Set a maximum number of entries for the cache.
* @param {number} size Cache size.
* @api
*/
setSize(t) {
this.highWaterMark = t;
}
}
function rs(...i) {
console.warn(...i);
}
function z(i, t, e) {
return Math.min(Math.max(i, t), e);
}
function os(i, t, e, n, s, r) {
const o = s - e, a = r - n;
if (o !== 0 || a !== 0) {
const l = ((i - e) * o + (t - n) * a) / (o * o + a * a);
l > 1 ? (e = s, n = r) : l > 0 && (e += o * l, n += a * l);
}
return Lt(i, t, e, n);
}
function Lt(i, t, e, n) {
const s = e - i, r = n - t;
return s * s + r * r;
}
function as(i) {
const t = i.length;
for (let n = 0; n < t; n++) {
let s = n, r = Math.abs(i[n][n]);
for (let a = n + 1; a < t; a++) {
const l = Math.abs(i[a][n]);
l > r && (r = l, s = a);
}
if (r === 0)
return null;
const o = i[s];
i[s] = i[n], i[n] = o;
for (let a = n + 1; a < t; a++) {
const l = -i[a][n] / i[n][n];
for (let c = n; c < t + 1; c++)
n == c ? i[a][c] = 0 : i[a][c] += l * i[n][c];
}
}
const e = new Array(t);
for (let n = t - 1; n >= 0; n--) {
e[n] = i[n][t] / i[n][n];
for (let s = n - 1; s >= 0; s--)
i[s][t] -= i[s][n] * e[n];
}
return e;
}
function En(i) {
return i * 180 / Math.PI;
}
function dt(i) {
return i * Math.PI / 180;
}
function bt(i, t) {
const e = i % t;
return e * t < 0 ? e + t : e;
}
function ls(i, t, e) {
return i + e * (t - i);
}
function Ke(i, t) {
const e = Math.pow(10, t);
return Math.round(i * e) / e;
}
function Qt(i, t) {
return Math.floor(Ke(i, t));
}
function Jt(i, t) {
return Math.ceil(Ke(i, t));
}
function Ge(i, t, e) {
if (i >= t && i < e)
return i;
const n = e - t;
return ((i - t) % n + n) % n + t;
}
function cs(i, t) {
return i[0] += +t[0], i[1] += +t[1], i;
}
function oe(i, t) {
let e = !0;
for (let n = i.length - 1; n >= 0; --n)
if (i[n] != t[n]) {
e = !1;
break;
}
return e;
}
function hs(i, t) {
const e = Math.cos(t), n = Math.sin(t), s = i[0] * e - i[1] * n, r = i[1] * e + i[0] * n;
return i[0] = s, i[1] = r, i;
}
const We = {
// use the radius of the Normal sphere
radians: 6370997 / (2 * Math.PI),
degrees: 2 * Math.PI * 6370997 / 360,
ft: 0.3048,
m: 1,
"us-ft": 1200 / 3937
};
class ke {
/**
* @param {Options} options Projection options.
*/
constructor(t) {
this.code_ = t.code, this.units_ = /** @type {import("./Units.js").Units} */
t.units, this.extent_ = t.extent !== void 0 ? t.extent : null, this.worldExtent_ = t.worldExtent !== void 0 ? t.worldExtent : null, this.axisOrientation_ = t.axisOrientation !== void 0 ? t.axisOrientation : "enu", this.global_ = t.global !== void 0 ? t.global : !1, this.canWrapX_ = !!(this.global_ && this.extent_), this.getPointResolutionFunc_ = t.getPointResolution, this.defaultTileGrid_ = null, this.metersPerUnit_ = t.metersPerUnit;
}
/**
* @return {boolean} The projection is suitable for wrapping the x-axis
*/
canWrapX() {
return this.canWrapX_;
}
/**
* Get the code for this projection, e.g. 'EPSG:4326'.
* @return {string} Code.
* @api
*/
getCode() {
return this.code_;
}
/**
* Get the validity extent for this projection.
* @return {import("../extent.js").Extent} Extent.
* @api
*/
getExtent() {
return this.extent_;
}
/**
* Get the units of this projection.
* @return {import("./Units.js").Units} Units.
* @api
*/
getUnits() {
return this.units_;
}
/**
* Get the amount of meters per unit of this projection. If the projection is
* not configured with `metersPerUnit` or a units identifier, the return is
* `undefined`.
* @return {number|undefined} Meters.
* @api
*/
getMetersPerUnit() {
return this.metersPerUnit_ || We[this.units_];
}
/**
* Get the world extent for this projection.
* @return {import("../extent.js").Extent} Extent.
* @api
*/
getWorldExtent() {
return this.worldExtent_;
}
/**
* Get the axis orientation of this projection.
* Example values are:
* enu - the default easting, northing, elevation.
* neu - northing, easting, up - useful for "lat/long" geographic coordinates,
* or south orientated transverse mercator.
* wnu - westing, northing, up - some planetary coordinate systems have
* "west positive" coordinate systems
* @return {string} Axis orientation.
* @api
*/
getAxisOrientation() {
return this.axisOrientation_;
}
/**
* Is this projection a global projection which spans the whole world?
* @return {boolean} Whether the projection is global.
* @api
*/
isGlobal() {
return this.global_;
}
/**
* Set if the projection is a global projection which spans the whole world
* @param {boolean} global Whether the projection is global.
* @api
*/
setGlobal(t) {
this.global_ = t, this.canWrapX_ = !!(t && this.extent_);
}
/**
* @return {import("../tilegrid/TileGrid.js").default} The default tile grid.
*/
getDefaultTileGrid() {
return this.defaultTileGrid_;
}
/**
* @param {import("../tilegrid/TileGrid.js").default} tileGrid The default tile grid.
*/
setDefaultTileGrid(t) {
this.defaultTileGrid_ = t;
}
/**
* Set the validity extent for this projection.
* @param {import("../extent.js").Extent} extent Extent.
* @api
*/
setExtent(t) {
this.extent_ = t, this.canWrapX_ = !!(this.global_ && t);
}
/**
* Set the world extent for this projection.
* @param {import("../extent.js").Extent} worldExtent World extent
* [minlon, minlat, maxlon, maxlat].
* @api
*/
setWorldExtent(t) {
this.worldExtent_ = t;
}
/**
* Set the getPointResolution function (see {@link module:ol/proj.getPointResolution}
* for this projection.
* @param {function(number, import("../coordinate.js").Coordinate):number} func Function
* @api
*/
setGetPointResolution(t) {
this.getPointResolutionFunc_ = t;
}
/**
* Get the custom point resolution function for this projection (if set).
* @return {GetPointResolution|undefined} The custom point
* resolution function (if set).
*/
getPointResolutionFunc() {
return this.getPointResolutionFunc_;
}
}
const Vt = 6378137, Ft = Math.PI * Vt, us = [-Ft, -Ft, Ft, Ft], ds = [-180, -85, 180, 85], te = Vt * Math.log(Math.tan(Math.PI / 2));
class It extends ke {
/**
* @param {string} code Code.
*/
constructor(t) {
super({
code: t,
units: "m",
extent: us,
global: !0,
worldExtent: ds,
getPointResolution: function(e, n) {
return e / Math.cosh(n[1] / Vt);
}
});
}
}
const Tn = [
new It("EPSG:3857"),
new It("EPSG:102100"),
new It("EPSG:102113"),
new It("EPSG:900913"),
new It("http://www.opengis.net/def/crs/EPSG/0/3857"),
new It("http://www.opengis.net/gml/srs/epsg.xml#3857")
];
function fs(i, t, e, n) {
const s = i.length;
e = e > 1 ? e : 2, n = n ?? e, t === void 0 && (e > 2 ? t = i.slice() : t = new Array(s));
for (let r = 0; r < s; r += n) {
t[r] = Ft * i[r] / 180;
let o = Vt * Math.log(Math.tan(Math.PI * (+i[r + 1] + 90) / 360));
o > te ? o = te : o < -te && (o = -te), t[r + 1] = o;
}
return t;
}
function gs(i, t, e, n) {
const s = i.length;
e = e > 1 ? e : 2, n = n ?? e, t === void 0 && (e > 2 ? t = i.slice() : t = new Array(s));
for (let r = 0; r < s; r += n)
t[r] = 180 * i[r] / Ft, t[r + 1] = 360 * Math.atan(Math.exp(i[r + 1] / Vt)) / Math.PI - 90;
return t;
}
const _s = 6378137, xn = [-180, -90, 180, 90], ms = Math.PI * _s / 180;
class Rt extends ke {
/**
* @param {string} code Code.
* @param {string} [axisOrientation] Axis orientation.
*/
constructor(t, e) {
super({
code: t,
units: "degrees",
extent: xn,
axisOrientation: e,
global: !0,
metersPerUnit: ms,
worldExtent: xn
});
}
}
const Cn = [
new Rt("CRS:84"),
new Rt("EPSG:4326", "neu"),
new Rt("urn:ogc:def:crs:OGC:1.3:CRS84"),
new Rt("urn:ogc:def:crs:OGC:2:84"),
new Rt("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),
new Rt("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"),
new Rt("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")
];
let De = {};
function Rs(i) {
return De[i] || De[i.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/, "EPSG:$3")] || null;
}
function ps(i, t) {
De[i] = t;
}
function ii(i) {
for (const t in i)
delete i[t];
}
function ys(i) {
let t;
for (t in i)
return !1;
return !t;
}
let Xt = {};
function Ut(i, t, e) {
const n = i.getCode(), s = t.getCode();
n in Xt || (Xt[n] = {}), Xt[n][s] = e;
}
function Ce(i, t) {
return i in Xt && t in Xt[i] ? Xt[i][t] : null;
}
const ae = 0.9996, k = 669438e-8, pe = k * k, ye = pe * k, pt = k / (1 - k), Mn = Math.sqrt(1 - k), Dt = (1 - Mn) / (1 + Mn), si = Dt * Dt, Ve = si * Dt, Be = Ve * Dt, ri = Be * Dt, oi = 1 - k / 4 - 3 * pe / 64 - 5 * ye / 256, Es = 3 * k / 8 + 3 * pe / 32 + 45 * ye / 1024, Ts = 15 * pe / 256 + 45 * ye / 1024, xs = 35 * ye / 3072, Cs = 3 / 2 * Dt - 27 / 32 * Ve + 269 / 512 * ri, Ms = 21 / 16 * si - 55 / 32 * Be, Is = 151 / 96 * Ve - 417 / 128 * ri, ws = 1097 / 512 * Be, le = 6378137;
function Ss(i, t, e) {
const n = i - 5e5, o = (e.north ? t : t - 1e7) / ae / (le * oi), a = o + Cs * Math.sin(2 * o) + Ms * Math.sin(4 * o) + Is * Math.sin(6 * o) + ws * Math.sin(8 * o), l = Math.sin(a), c = l * l, h = Math.cos(a), u = l / h, d = u * u, g = d * d, f = 1 - k * c, _ = Math.sqrt(1 - k * c), m = le / _, y = (1 - k) / f, R = pt * h ** 2, T = R * R, E = n / (m * ae), p = E * E, S = p * E, w = S * E, I = w * E, P = I * E, b = a - u / y * (p / 2 - w / 24 * (5 + 3 * d + 10 * R - 4 * T - 9 * pt)) + P / 720 * (61 + 90 * d + 298 * R + 45 * g - 252 * pt - 3 * T);
let X = (E - S / 6 * (1 + 2 * d + R) + I / 120 * (5 - 2 * R + 28 * d - 3 * T + 8 * pt + 24 * g)) / h;
return X = Ge(
X + dt(ai(e.number)),
-Math.PI,
Math.PI
), [En(X), En(b)];
}
const In = -80, wn = 84, vs = -180, Ps = 180;
function As(i, t, e) {
i = Ge(i, vs, Ps), t < In ? t = In : t > wn && (t = wn);
const n = dt(t), s = Math.sin(n), r = Math.cos(n), o = s / r, a = o * o, l = a * a, c = dt(i), h = ai(e.number), u = dt(h), d = le / Math.sqrt(1 - k * s ** 2), g = pt * r ** 2, f = r * Ge(c - u, -Math.PI, Math.PI), _ = f * f, m = _ * f, y = m * f, R = y * f, T = R * f, E = le * (oi * n - Es * Math.sin(2 * n) + Ts * Math.sin(4 * n) - xs * Math.sin(6 * n)), p = ae * d * (f + m / 6 * (1 - a + g) + R / 120 * (5 - 18 * a + l + 72 * g - 58 * pt)) + 5e5;
let S = ae * (E + d * o * (_ / 2 + y / 24 * (5 - a + 9 * g + 4 * g ** 2) + T / 720 * (61 - 58 * a + l + 600 * g - 330 * pt)));
return e.north || (S += 1e7), [p, S];
}
function ai(i) {
return (i - 1) * 6 - 180 + 3;
}
const Fs = [
/^EPSG:(\d+)$/,
/^urn:ogc:def:crs:EPSG::(\d+)$/,
/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/
];
function li(i) {
let t = 0;
for (const s of Fs) {
const r = i.match(s);
if (r) {
t = parseInt(r[1]);
break;
}
}
if (!t)
return null;
let e = 0, n = !1;
return t > 32700 && t < 32761 ? e = t - 32700 : t > 32600 && t < 32661 && (n = !0, e = t - 32600), e ? { number: e, north: n } : null;
}
function Sn(i, t) {
return function(e, n, s, r) {
const o = e.length;
s = s > 1 ? s : 2, r = r ?? s, n || (s > 2 ? n = e.slice() : n = new Array(o));
for (let a = 0; a < o; a += r) {
const l = e[a], c = e[a + 1], h = i(l, c, t);
n[a] = h[0], n[a + 1] = h[1];
}
return n;
};
}
function Os(i) {
return li(i) ? new ke({ code: i, units: "m" }) : null;
}
function Ls(i) {
const t = li(i.getCode());
return t ? {
forward: Sn(As, t),
inverse: Sn(Ss, t)
} : null;
}
const bs = 63710088e-1;
function vn(i, t, e) {
e = e || bs;
const n = dt(i[1]), s = dt(t[1]), r = (s - n) / 2, o = dt(t[0] - i[0]) / 2, a = Math.sin(r) * Math.sin(r) + Math.sin(o) * Math.sin(o) * Math.cos(n) * Math.cos(s);
return 2 * e * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
}
const Xs = [Ls], Ns = [Os];
let ze = !0;
function Gs(i) {
ze = !1;
}
function $e(i, t) {
if (t !== void 0) {
for (let e = 0, n = i.length; e < n; ++e)
t[e] = i[e];
t = t;
} else
t = i.slice();
return t;
}
function Ze(i) {
ps(i.getCode(), i), Ut(i, i, $e);
}
function Ds(i) {
i.forEach(Ze);
}
function Y(i) {
if (typeof i != "string")
return i;
const t = Rs(i);
if (t)
return t;
for (const e of Ns) {
const n = e(i);
if (n)
return n;
}
return null;
}
function Pn(i, t, e, n) {
i = Y(i);
let s;
const r = i.getPointResolutionFunc();
if (r)
s = r(t, e);
else {
const o = i.getUnits();
if (o == "degrees" && !n || n == "degrees")
s = t;
else {
const a = He(
i,
Y("EPSG:4326")
);
if (!a && o !== "degrees")
s = t * i.getMetersPerUnit();
else {
let c = [
e[0] - t / 2,
e[1],
e[0] + t / 2,
e[1],
e[0],
e[1] - t / 2,
e[0],
e[1] + t / 2
];
c = a(c, c, 2);
const h = vn(c.slice(0, 2), c.slice(2, 4)), u = vn(c.slice(4, 6), c.slice(6, 8));
s = (h + u) / 2;
}
const l = i.getMetersPerUnit();
l !== void 0 && (s /= l);
}
}
return s;
}
function An(i) {
Ds(i), i.forEach(function(t) {
i.forEach(function(e) {
t !== e && Ut(t, e, $e);
});
});
}
function zs(i, t, e, n) {
i.forEach(function(s) {
t.forEach(function(r) {
Ut(s, r, e), Ut(r, s, n);
});
});
}
function qe(i, t) {
return i ? typeof i == "string" ? Y(i) : (
/** @type {Projection} */
i
) : Y(t);
}
function Zs(i) {
return (
/**
* @param {Array<number>} input Input.
* @param {Array<number>} [output] Output.
* @param {number} [dimension] Dimensions that should be transformed.
* @param {number} [stride] Stride.
* @return {Array<number>} Output.
*/
function(t, e, n, s) {
const r = t.length;
n = n !== void 0 ? n : 2, s = s ?? n, e = e !== void 0 ? e : new Array(r);
for (let o = 0; o < r; o += s) {
const a = i(t.slice(o, o + n)), l = a.length;
for (let c = 0, h = s; c < h; ++c)
e[o + c] = c >= l ? t[o + c] : a[c];
}
return e;
}
);
}
function Me(i, t) {
if (i === t)
return !0;
const e = i.getUnits() === t.getUnits();
return (i.getCode() === t.getCode() || He(i, t) === $e) && e;
}
function He(i, t) {
const e = i.getCode(), n = t.getCode();
let s = Ce(e, n);
if (s)
return s;
let r = null, o = null;
for (const l of Xs)
r || (r = l(i)), o || (o = l(t));
if (!r && !o)
return null;
const a = "EPSG:4326";
if (o)
if (r)
s = Ie(
r.inverse,
o.forward
);
else {
const l = Ce(e, a);
l && (s = Ie(
l,
o.forward
));
}
else {
const l = Ce(a, n);
l && (s = Ie(
r.inverse,
l
));
}
return s && (Ze(i), Ze(t), Ut(i, t, s)), s;
}
function Ie(i, t) {
return function(e, n, s, r) {
return n = i(e, n, s, r), t(n, n, s, r);
};
}
function Kt(i, t) {
const e = Y(i), n = Y(t);
return He(e, n);
}
function ci(i, t, e) {
const n = Kt(t, e);
if (!n) {
const s = Y(t).getCode(), r = Y(e).getCode();
throw new Error(
`No transform available between ${s} and ${r}`
);
}
return n(i, void 0, i.length);
}
function js(i, t, e, n) {
const s = Kt(t, e);
return es(i, s, void 0);
}
function Fn(i, t) {
return i;
}
function lt(i, t) {
return ze && !oe(i, [0, 0]) && i[0] >= -180 && i[0] <= 180 && i[1] >= -90 && i[1] <= 90 && (ze = !1, rs(
"Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates."
)), i;
}
function Ys(i, t) {
return i;
}
function yt(i, t) {
return i;
}
function Us() {
An(Tn), An(Cn), zs(
Cn,
Tn,
fs,
gs
);
}
Us();
function ce(i, t, e, n) {
return n !== void 0 ? (n[0] = i, n[1] = t, n[2] = e, n) : [i, t, e];
}
function Ks(i, t, e) {
return i + "/" + t + "/" + e;
}
function Ws(i) {
return ks(i[0], i[1], i[2]);
}
function ks(i, t, e) {
return (t << i) + e;
}
function Vs(i, t) {
const e = i[0], n = i[1], s = i[2];
if (t.getMinZoom() > e || e > t.getMaxZoom())
return !1;
const r = t.getFullTileRange(e);
return r ? r.containsXY(n, s) : !0;
}
function Bs(i, t, e) {
return e === void 0 && (e = [0, 0]), e[0] = i[0] * t + 0.5 | 0, e[1] = i[1] * t + 0.5 | 0, e;
}
function ut(i, t) {
return Array.isArray(i) ? i : (t === void 0 ? t = [i, i] : (t[0] = i, t[1] = i), t);
}
class Qe {
/**
* @param {number} minX Minimum X.
* @param {number} maxX Maximum X.
* @param {number} minY Minimum Y.
* @param {number} maxY Maximum Y.
*/
constructor(t, e, n, s) {
this.minX = t, this.maxX = e, this.minY = n, this.maxY = s;
}
/**
* @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @return {boolean} Contains tile coordinate.
*/
contains(t) {
return this.containsXY(t[1], t[2]);
}
/**
* @param {TileRange} tileRange Tile range.
* @return {boolean} Contains.
*/
containsTileRange(t) {
return this.minX <= t.minX && t.maxX <= this.maxX && this.minY <= t.minY && t.maxY <= this.maxY;
}
/**
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @return {boolean} Contains coordinate.
*/
containsXY(t, e) {
return this.minX <= t && t <= this.maxX && this.minY <= e && e <= this.maxY;
}
/**
* @param {TileRange} tileRange Tile range.
* @return {boolean} Equals.
*/
equals(t) {
return this.minX == t.minX && this.minY == t.minY && this.maxX == t.maxX && this.maxY == t.maxY;
}
/**
* @param {TileRange} tileRange Tile range.
*/
extend(t) {
t.minX < this.minX && (this.minX = t.minX), t.maxX > this.maxX && (this.maxX = t.maxX), t.minY < this.minY && (this.minY = t.minY), t.maxY > this.maxY && (this.maxY = t.maxY);
}
/**
* @return {number} Height.
*/
getHeight() {
return this.maxY - this.minY + 1;
}
/**
* @return {import("./size.js").Size} Size.
*/
getSize() {
return [this.getWidth(), this.getHeight()];
}
/**
* @return {number} Width.
*/
getWidth() {
return this.maxX - this.minX + 1;
}
/**
* @param {TileRange} tileRange Tile range.
* @return {boolean} Intersects.
*/
intersects(t) {
return this.minX <= t.maxX && this.maxX >= t.minX && this.minY <= t.maxY && this.maxY >= t.minY;
}
}
function wt(i, t, e, n, s) {
return s !== void 0 ? (s.minX = i, s.maxX = t, s.minY = e, s.maxY = n, s) : new Qe(i, t, e, n);
}
function Je(i, t) {
return i > t ? 1 : i < t ? -1 : 0;
}
function tn(i, t, e) {
if (i[0] <= t)
return 0;
const n = i.length;
if (t <= i[n - 1])
return n - 1;
if (typeof e == "function") {
for (let s = 1; s < n; ++s) {
const r = i[s];
if (r === t)
return s;
if (r < t)
return e(t, i[s - 1], r) > 0 ? s - 1 : s;
}
return n - 1;
}
if (e > 0) {
for (let s = 1; s < n; ++s)
if (i[s] < t)
return s - 1;
return n - 1;
}
if (e < 0) {
for (let s = 1; s < n; ++s)
if (i[s] <= t)
return s;
return n - 1;
}
for (let s = 1; s < n; ++s) {
if (i[s] == t)
return s;
if (i[s] < t)
return i[s - 1] - t < t - i[s] ? s - 1 : s;
}
return n - 1;
}
function $s(i, t) {
const e = Array.isArray(t) ? t : [t], n = e.length;
for (let s = 0; s < n; s++)
i[i.length] = e[s];
}
function hi(i, t) {
const e = i.length;
if (e !== t.length)
return !1;
for (let n = 0; n < e; n++)
if (i[n] !== t[n])
return !1;
return !0;
}
function qs(i, t, e) {
const n = t || Je;
return i.every(function(s, r) {
if (r === 0)
return !0;
const o = n(i[r - 1], s);
return !(o > 0 || o === 0);
});
}
function Hs(i, t, e, n, s) {
return !ti(
s,
/**
* @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
* @return {boolean} Contains (x, y).
*/
function(o) {
return !Et(
i,
t,
e,
n,
o[0],
o[1]
);
}
);
}
function Et(i, t, e, n, s, r) {
let o = 0, a = i[e - n], l = i[e - n + 1];
for (; t < e; t += n) {
const c = i[t], h = i[t + 1];
l <= r ? h > r && (c - a) * (r - l) - (s - a) * (h - l) > 0 && o++ : h <= r && (c - a) * (r - l) - (s - a) * (h - l) < 0 && o--, a = c, l = h;
}
return o !== 0;
}
function ui(i, t, e, n, s, r) {
if (e.length === 0 || !Et(i, t, e[0], n, s, r))
return !1;
for (let o = 1, a = e.length; o < a; ++o)
if (Et(i, e[o - 1], e[o], n, s, r))
return !1;
return !0;
}
function Qs(i, t, e, n, s) {
let r;
for (t += n; t < e; t += n)
if (r = s(
i.slice(t - n, t),
i.slice(t, t + n)
), r)
return r;
return !1;
}
function di(i, t, e, n, s, r) {
return r = r ?? Jn(Ct(), i, t, e, n), kt(s, r) ? r[0] >= s[0] && r[2] <= s[2] || r[1] >= s[1] && r[3] <= s[3] ? !0 : Qs(
i,
t,
e,
n,
/**
* @param {import("../../coordinate.js").Coordinate} point1 Start point.
* @param {import("../../coordinate.js").Coordinate} point2 End point.
* @return {boolean} `true` if the segment and the extent intersect,
* `false` otherwise.
*/
function(o, a) {
return ts(s, o, a);
}
) : !1;
}
function fi(i, t, e, n, s) {
return !!(di(i, t, e, n, s) || Et(
i,
t,
e,
n,
s[0],
s[1]
) || Et(
i,
t,
e,
n,
s[0],
s[3]
) || Et(
i,
t,
e,
n,
s[2],
s[1]
) || Et(
i,
t,
e,
n,
s[2],
s[3]
));
}
function Js(i, t, e, n, s) {
if (!fi(i, t, e[0], n, s))
return !1;
if (e.length === 1)
return !0;
for (let r = 1, o = e.length; r < o; ++r)
if (Hs(
i,
e[r - 1],
e[r],
n,
s
) && !di(
i,
e[r - 1],
e[r],
n,
s
))
return !1;
return !0;
}
const tr = 42, en = 256, St = [0, 0, 0], ct = 5;
class gi {
/**
* @param {Options} options Tile grid options.
*/
constructor(t) {
this.minZoom = t.minZoom !== void 0 ? t.minZoom : 0, this.resolutions_ = t.resolutions, D(
qs(
this.resolutions_,
/**
* @param {number} a First resolution
* @param {number} b Second resolution
* @return {number} Comparison result
*/
(s, r) => r - s
),
"`resolutions` must be sorted in descending order"
);
let e;
if (!t.origins) {
for (let s = 0, r = this.resolutions_.length - 1; s < r; ++s)
if (!e)
e = this.resolutions_[s] / this.resolutions_[s + 1];
else if (this.resolutions_[s] / this.resolutions_[s + 1] !== e) {
e = void 0;
break;
}
}
this.zoomFactor_ = e, this.maxZoom = this.resolutions_.length - 1, this.origin_ = t.origin !== void 0 ? t.origin : null, this.origins_ = null, t.origins !== void 0 && (this.origins_ = t.origins, D(
this.origins_.length == this.resolutions_.length,
"Number of `origins` and `resolutions` must be equal"
));
const n = t.extent;
n !== void 0 && !this.origin_ && !this.origins_ && (this.origin_ = Mt(n)), D(
!this.origin_ && this.origins_ || this.origin_ && !this.origins_,
"Either `origin` or `origins` must be configured, never both"
), this.tileSizes_ = null, t.tileSizes !== void 0 && (this.tileSizes_ = t.tileSizes, D(
this.tileSizes_.length == this.resolutions_.length,
"Number of `tileSizes` and `resolutions` must be equal"
)), this.tileSize_ = t.tileSize !== void 0 ? t.tileSize : this.tileSizes_ ? null : en, D(
!this.tileSize_ && this.tileSizes_ || this.tileSize_ && !this.tileSizes_,
"Either `tileSize` or `tileSizes` must be configured, never both"
), this.extent_ = n !== void 0 ? n : null, this.fullTileRanges_ = null, this.tmpSize_ = [0, 0], this.tmpExtent_ = [0, 0, 0, 0], t.sizes !== void 0 ? this.fullTileRanges_ = t.sizes.map((s, r) => {
const o = new Qe(
Math.min(0, s[0]),
Math.max(s[0] - 1, -1),
Math.min(0, s[1]),
Math.max(s[1] - 1, -1)
);
if (n) {
const a = this.getTileRangeForExtentAndZ(n, r);
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);
}
return o;
}) : n && this.calculateTileRanges_(n);
}
/**
* Call a function with each tile coordinate for a given extent and zoom level.
*
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} zoom Integer zoom level.
* @param {function(import("../tilecoord.js").TileCoord): void} callback Function called with each tile coordinate.
* @api
*/
forEachTileCoord(t, e, n) {
const s = this.getTileRangeForExtentAndZ(t, e);
for (let r = s.minX, o = s.maxX; r <= o; ++r)
for (let a = s.minY, l = s.maxY; a <= l; ++a)
n([e, r, a]);
}
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {function(number, import("../TileRange.js").default): boolean} callback Callback.
* @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
* @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object.
* @return {boolean} Callback succeeded.
*/
forEachTileCoordParentTileRange(t, e, n, s) {
let r, o, a, l = null, c = t[0] - 1;
for (this.zoomFactor_ === 2 ? (o = t[1], a = t[2]) : l = this.getTileCoordExtent(t, s); c >= this.minZoom; ) {
if (o !== void 0 && a !== void 0 ? (o = Math.floor(o / 2), a = Math.floor(a / 2), r = wt(o, o, a, a, n)) : r = this.getTileRangeForExtentAndZ(
l,
c,
n
), e(c, r))
return !0;
--c;
}
return !1;
}
/**
* Get the extent for this tile grid, if it was configured.
* @return {import("../extent.js").Extent} Extent.
* @api
*/
getExtent() {
return this.extent_;
}
/**
* Get the maximum zoom level for the grid.
* @return {number} Max zoom.
* @api
*/
getMaxZoom() {
return this.maxZoom;
}
/**
* Get the minimum zoom level for the grid.
* @return {number} Min zoom.
* @api
*/
getMinZoom() {
return this.minZoom;
}
/**
* Get the origin for the grid at the given zoom level.
* @param {number} z Integer zoom level.
* @return {import("../coordinate.js").Coordinate} Origin.
* @api
*/
getOrigin(t) {
return this.origin_ ? this.origin_ : this.origins_[t];
}
/**
* Get the resolution for the given zoom level.
* @param {number} z Integer zoom level.
* @return {number} Resolution.
* @api
*/
getResolution(t) {
return this.resolutions_[t];
}
/**
* Get the list of resolutions for the tile grid.
* @return {Array<number>} Resolutions.
* @api
*/
getResolutions() {
return this.resolutions_;
}
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
* @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object.
* @return {import("../TileRange.js").default|null} Tile range.
*/
getTileCoordChildTileRange(t, e, n) {
if (t[0] < this.maxZoom) {
if (this.zoomFactor_ === 2) {
const r = t[1] * 2, o = t[2] * 2;
return wt(
r,
r + 1,
o,
o + 1,
e
);
}
const s = this.getTileCoordExtent(
t,
n || this.tmpExtent_
);
return this.getTileRangeForExtentAndZ(
s,
t[0] + 1,
e
);
}
return null;
}
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {number} z Integer zoom level.
* @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
* @return {import("../TileRange.js").default|null} Tile range.
*/
getTileRangeForTileCoordAndZ(t, e, n) {
if (e > this.maxZoom || e < this.minZoom)
return null;
const s = t[0], r = t[1], o = t[2];
if (e === s)
return wt(
r,
o,
r,
o,
n
);
if (this.zoomFactor_) {
const l = Math.pow(this.zoomFactor_, e - s), c = Math.floor(r * l), h = Math.floor(o * l);
if (e < s)
return wt(c, c, h, h, n);
const u = Math.floor(l * (r + 1)) - 1, d = Math.floor(l * (o + 1)) - 1;
return wt(c, u, h, d, n);
}
const a = this.getTileCoordExtent(t, this.tmpExtent_);
return this.getTileRangeForExtentAndZ(a, e, n);
}
/**
* Get a tile range for the given extent and integer zoom level.
* @param {import("../extent.js").Extent} extent Extent.
* @param {number} z Integer zoom level.
* @param {import("../TileRange.js").default} [tempTileRange] Temporary tile range object.
* @return {import("../TileRange.js").default} Tile range.
*/
getTileRangeForExtentAndZ(t, e, n) {
this.getTileCoordForXYAndZ_(t[0], t[3], e, !1, St);
const s = St[1], r = St[2];
this.getTileCoordForXYAndZ_(t[2], t[1], e, !0, St);
const o = St[1], a = St[2];
return wt(s, o, r, a, n);
}
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @return {import("../coordinate.js").Coordinate} Tile center.
*/
getTileCoordCenter(t) {
const e = this.getOrigin(t[0]), n = this.getResolution(t[0]), s = ut(this.getTileSize(t[0]), this.tmpSize_);
return [
e[0] + (t[1] + 0.5) * s[0] * n,
e[1] - (t[2] + 0.5) * s[1] * n
];
}
/**
* Get the extent of a tile coordinate.
*
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("../extent.js").Extent} [tempExtent] Temporary extent object.
* @return {import("../extent.js").Extent} Extent.
* @api
*/
getTileCoordExtent(t, e) {
const n = this.getOrigin(t[0]), s = this.getResolution(t[0]), r = ut(this.getTileSize(t[0]), this.tmpSize_), o = n[0] + t[1] * r[0] * s, a = n[1] - (t[2] + 1) * r[1] * s, l = o + r[0] * s, c = a + r[1] * s;
return zt(o, a, l, c, e);
}
/**
* Get the tile coordinate for the given map coordinate and resolution. This
* method considers that coordinates that intersect tile boundaries should be
* assigned the higher tile coordinate.
*
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @param {number} resolution Resolution.
* @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
* @return {import("../tilecoord.js").TileCoord} Tile coordinate.
* @api
*/
getTileCoordForCoordAndResolution(t, e, n) {
return this.getTileCoordForXYAndResolution_(
t[0],
t[1],
e,
!1,
n
);
}
/**
* Note that this method should not be called for resolutions that correspond
* to an integer zoom level. Instead call the `getTileCoordForXYAndZ_` method.
* @param {number} x X.
* @param {number} y Y.
* @param {number} resolution Resolution (for a non-integer zoom level).
* @param {boolean} reverseIntersectionPolicy Instead of letting edge
* intersections go to the higher tile coordinate, let edge intersections
* go to the lower tile coordinate.
* @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
* @return {import("../tilecoord.js").TileCoord} Tile coordinate.
* @private
*/
getTileCoordForXYAndResolution_(t, e, n, s, r) {
const o = this.getZForResolution(n), a = n / this.getResolution(o), l = this.getOrigin(o), c = ut(this.getTileSize(o), this.tmpSize_);
let h = a * (t - l[0]) / n / c[0], u = a * (l[1] - e) / n / c[1];
return s ? (h = Jt(h, ct) - 1, u = Jt(u, ct) - 1) : (h = Qt(h, ct), u = Qt(u, ct)), ce(o, h, u, r);
}
/**
* Although there is repetition between this method and `getTileCoordForXYAndResolution_`,
* they should have separate implementations. This method is for integer zoom
* levels. The other method should only be called for resolutions corresponding
* to non-integer zoom levels.
* @param {number} x Map x coordinate.
* @param {number} y Map y coordinate.
* @param {number} z Integer zoom level.
* @param {boolean} reverseIntersectionPolicy Instead of letting edge
* intersections go to the higher tile coordinate, let edge intersections
* go to the lower tile coordinate.
* @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
* @return {import("../tilecoord.js").TileCoord} Tile coordinate.
* @private
*/
getTileCoordForXYAndZ_(t, e, n, s, r) {
const o = this.getOrigin(n), a = this.getResolution(n), l = ut(this.getTileSize(n), this.tmpSize_);
let c = (t - o[0]) / a / l[0], h = (o[1] - e) / a / l[1];
return s ? (c = Jt(c, ct) - 1, h = Jt(h, ct) - 1) : (c = Qt(c, ct), h = Qt(h, ct)), ce(n, c, h, r);
}
/**
* Get a tile coordinate given a map coordinate and zoom level.
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @param {number} z Integer zoom level, e.g. the result of a `getZForResolution()` method call
* @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
* @return {import("../tilecoord.js").TileCoord} Tile coordinate.
* @api
*/
getTileCoordForCoordAndZ(t, e, n) {
return this.getTileCoordForXYAndZ_(
t[0],
t[1],
e,
!1,
n
);
}
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @return {number} Tile resolution.
*/
getTileCoordResolution(t) {
return this.resolutions_[t[0]];
}
/**
* Get the tile size for a zoom level. The type of the return value matches the
* `tileSize` or `tileSizes` that the tile grid was configured with. To always
* get an {@link import("../size.js").Size}, run the result through {@link module:ol/size.toSize}.
* @param {number} z Z.
* @return {number|import("../size.js").Size} Tile size.
* @api
*/
getTileSize(t) {
return this.tileSize_ ? this.tileSize_ : this.tileSizes_[t];
}
/**
* @param {number} z Zoom level.
* @return {import("../TileRange.js").default|null} Extent tile range for the specified zoom level.
*/
getFullTileRange(t) {
return this.fullTileRanges_ ? this.fullTileRanges_[t] : this.extent_ ? this.getTileRangeForExtentAndZ(this.extent_, t) : null;
}
/**
* @param {number} resolution Resolution.
* @param {number|import("../array.js").NearestDirectionFunction} [opt_direction]
* If 0, the nearest resolution will be used.
* If 1, the nearest higher resolution (lower Z) will be used. If -1, the
* nearest lower resolution (higher Z) will be used. Default is 0.
* Use a {@link module:ol/array~NearestDirectionFunction} for more precise control.
*
* For example to change tile Z at the midpoint of zoom levels
* ```js
* function(value, high, low) {
* return value - low * Math.sqrt(high / low);
* }
* ```
* @return {number} Z.
* @api
*/
getZForResolution(t, e) {
const n = tn(
this.resolutions_,
t,
e || 0
);
return z(n, this.minZoom, this.maxZoom);
}
/**
* The tile with the provided tile coordinate intersects the given viewport.
* @param {import('../tilecoord.js').TileCoord} tileCoord Tile coordinate.
* @param {Array<number>} viewport Viewport as returned from {@link module:ol/extent.getRotatedViewport}.
* @return {boolean} The tile with the provided tile coordinate intersects the given viewport.
*/
tileCoordIntersectsViewport(t, e) {
return fi(
e,
0,
e.length,
2,
this.getTileCoordExtent(t)
);
}
/**
* @param {!import("../extent.js").Extent} extent Extent for this tile grid.
* @private
*/
calculateTileRanges_(t) {
const e = this.resolutions_.length, n = new Array(e);
for (let s = this.minZoom; s < e; ++s)
n[s] = this.getTileRangeForExtentAndZ(t, s);
this.fullTileRanges_ = n;
}
}
function _i(i) {
let t = i.getDefaultTileGrid();
return t || (t = sr(i), i.setDefaultTileGrid(t)), t;
}
function er(i, t, e) {
const n = t[0], s = i.getTileCoordCenter(t), r = nn(e);
if (!Ue(r, s)) {
const o = v(r), a = Math.ceil(
(r[0] - s[0]) / o
);
return s[0] += o * a, i.getTileCoordForCoordAndZ(s, n);
}
return t;
}
function nr(i, t, e, n) {
n = n !== void 0 ? n : "top-left";
const s = mi(i, t, e);
return new gi({
extent: i,
origin: Hi(i, n),
resolutions: s,
tileSize: e
});
}
function ir(i) {
const t = i || {}, e = t.extent || Y("EPSG:3857").getExtent(), n = {
extent: e,
minZoom: t.minZoom,
tileSize: t.tileSize,
resolutions: mi(
e,
t.maxZoom,
t.tileSize,
t.maxResolution
)
};
return new gi(n);
}
function mi(i, t, e, n) {
t = t !== void 0 ? t : tr, e = ut(e !== void 0 ? e : en);
const s = W(i), r = v(i);
n = n > 0 ? n : Math.max(r / e[0], s / e[1]);
const o = t + 1, a = new Array(o);
for (let l = 0; l < o; ++l)
a[l] = n / Math.pow(2, l);
return a;
}
function sr(i, t, e, n) {
const s = nn(i);
return nr(s, t, e, n);
}
function nn(i) {
i = Y(i);
let t = i.getExtent();
if (!t) {
const e = 180 * We.degrees / i.getMetersPerUnit();
t = zt(-e, -e, e, e);
}
return t;
}
const rr = /\{z\}/g, or = /\{x\}/g, ar = /\{y\}/g, lr = /\{-y\}/g;
function cr(i, t, e, n, s) {
return i.replace(rr, t.toString()).replace(or, e.toString()).replace(ar, n.toString()).replace(lr, function() {
if (s === void 0)
throw new Error(
"If the URL template has a {-y} placeholder, the grid extent must be known"
);
return (s - n).toString();
});
}
function hr(i) {
const t = [];
let e = /\{([a-z])-([a-z])\}/.exec(i);
if (e) {
const n = e[1].charCodeAt(0), s = e[2].charCodeAt(0);
let r;
for (r = n; r <= s; ++r)
t.push(i.replace(e[0], String.fromCharCode(r)));
return t;
}
if (e = /\{(\d+)-(\d+)\}/.exec(i), e) {
const n = parseInt(e[2], 10);
for (let s = parseInt(e[1], 10); s <= n; s++)
t.push(i.replace(e[0], s.toString()));
return t;
}
return t.push(i), t;
}
function ur(i, t) {
return (
/**
* @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {import("./proj/Projection.js").default} projection Projection.
* @return {string|undefined} Tile URL.
*/
function(e, n, s) {
if (!e)
return;
let r;
const o = e[0];
if (t) {
const a = t.getFullTileRange(o);
a && (r = a.getHeight() - 1);
}
return cr(i, o, e[1], e[2], r);
}
);
}
function dr(i, t) {
const e = i.length, n = new Array(e);
for (let s = 0; s < e; ++s)
n[s] = ur(i[s], t);
return fr(n);
}
function fr(i) {
return i.length === 1 ? i[0] : (
/**
* @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {import("./proj/Projection.js").default} projection Projection.
* @return {string|undefined} Tile URL.
*/
function(t, e, n) {
if (!t)
return;
const s = Ws(t), r = bt(s, i.length);
return i[r](t, e, n);
}
);
}
const vt = {
IDLE: 0,
LOADED: 2,
ERROR: 3
}, nt = {
/**
* Generic change event. Triggered when the revision counter is increased.
* @event module:ol/events/Event~BaseEvent#change
* @api
*/
CHANGE: "change",
/**
* Generic error event. Triggered when an error occurs.
* @event module:ol/events/Event~BaseEvent#error
* @api
*/
ERROR: "error",
LOAD: "load"
};
function je() {
}
function gr(i) {
let t, e, n;
return function() {
const s = Array.prototype.slice.call(arguments);
return (!e || this !== n || !hi(s, e)) && (n = this, e = s, t = i.apply(this, arguments)), t;
};
}
class Ee {
/**
* @param {string} type Type.
*/
constructor(t) {
this.propagationStopped, this.defaultPrevented, this.type = t, this.target = null;
}
/**
* Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events
* will be fired.
* @api
*/
preventDefault() {
this.defaultPrevented = !0;
}
/**
* Stop event propagation.
* @api
*/
stopPropagation() {
this.propagationStopped = !0;
}
}
class Ri extends ni {
/**
* @param {*} [target] Default event target for dispatched events.
*/
constructor(t) {
super(), this.eventTarget_ = t, this.pendingRemovals_ = null, this.dispatching_ = null, this.listeners_ = null;
}
/**
* @param {string} type Type.
* @param {import("../events.js").Listener} listener Listener.
*/
addEventListener(t, e) {
if (!t || !e)
return;
const n = this.listeners_ || (this.listeners_ = {}), s = n[t] || (n[t] = []);
s.includes(e) || s.push(e);
}
/**
* Dispatches an event and calls all listeners listening for events
* of this type. The event parameter can either be a string or an
* Object with a `type` property.
*
* @param {import("./Event.js").default|string} event Event object.
* @return {boolean|undefined} `false` if anyone called preventDefault on the
* event object or if any of the listeners returned false.
* @api
*/
dispatchEvent(t) {
const e = typeof t == "string", n = e ? t : t.type, s = this.listeners_ && this.listeners_[n];
if (!s)
return;
const r = e ? new Ee(t) : (
/** @type {Event} */
t
);
r.target || (r.target = this.eventTarget_ || this);
const o = this.dispatching_ || (this.dispatching_ = {}), a = this.pendingRemovals_ || (this.pendingRemovals_ = {});
n in o || (o[n] = 0, a[n] = 0), ++o[n];
let l;
for (let c = 0, h = s.length; c < h; ++c)
if ("handleEvent" in s[c] ? l = /** @type {import("../events.js").ListenerObject} */
s[c].handleEvent(r) : l = /** @type {import("../events.js").ListenerFunction} */
s[c].call(this, r), l === !1 || r.propagationStopped) {
l = !1;
break;
}
if (--o[n] === 0) {
let c = a[n];
for (delete a[n]; c--; )
this.removeEventListener(n, je);
delete o[n];
}
return l;
}
/**
* Clean up.
* @override
*/
disposeInternal() {
this.listeners_ && ii(this.listeners_);
}
/**
* Get the listeners for a specified event type. Listeners are returned in the
* order that they will be called in.
*
* @param {string} type Type.
* @return {Array<import("../events.js").Listener>|undefined} Listeners.
*/
getListeners(t) {
return this.listeners_ && this.listeners_[t] || void 0;
}
/**
* @param {string} [type] Type. If not provided,
* `true` will be returned if this event target has any listeners.
* @return {boolean} Has listeners.
*/
hasListener(t) {
return this.listeners_ ? t ? t in this.listeners_ : Object.keys(this.listeners_).length > 0 : !1;
}
/**
* @param {string} type Type.
* @param {import("../events.js").Listener} listener Listener.
*/
removeEventListener(t, e) {
if (!this.listeners_)
return;
const n = this.listeners_[t];
if (!n)
return;
const s = n.indexOf(e);
s !== -1 && (this.pendingRemovals_ && t in this.pendingRemovals_ ? (n[s] = je, ++this.pendingRemovals_[t]) : (n.splice(s, 1), n.length === 0 && delete this.listeners_[t]));
}
}
function Tt(i, t, e, n, s) {
if (s) {
const o = e;
e = function(a) {
return i.removeEventListener(t, e), o.call(n ?? this, a);
};
} else n && n !== i && (e = e.bind(n));
const r = {
target: i,
type: t,
listener: e
};
return i.addEventListener(t, e), r;
}
function he(i, t, e, n) {
return Tt(i, t, e, n, !0);
}
function ft(i) {
i && i.target && (i.target.removeEventListener(i.type, i.listener), ii(i));
}
const xt = typeof navigator < "u" && typeof navigator.userAgent < "u" ? navigator.userAgent.toLowerCase() : "", _r = xt.includes("safari") && !xt.includes("chrom");
_r && (xt.includes("version/15.4") || /cpu (os|iphone os) 15_4 like mac os x/.test(xt));
xt.includes("webkit") && xt.includes("edge");
xt.includes("macintosh");
const mr = typeof WorkerGlobalScope < "u" && typeof OffscreenCanvas < "u" && self instanceof WorkerGlobalScope, Rr = typeof Image < "u" && Image.prototype.decode;
(function() {
let i = !1;
try {
const t = Object.defineProperty({}, "passive", {
get: function() {
i = !0;
}
});
window.addEventListener("_", null, t), window.removeEventListener("_", null, t);
} catch {
}
return i;
})();
function pr(i, t, e) {
const n = (
/** @type {HTMLImageElement} */
i
);
let s = !0, r = !1, o = !1;
const a = [
he(n, nt.LOAD, function() {
o = !0, r || t();
})
];
return n.src && Rr ? (r = !0, n.decode().then(function() {
s && t();
}).catch(function(l) {
s && (o ? t() : e());
})) : a.push(he(n, nt.ERROR, e)), function() {
s = !1, a.forEach(ft);
};
}
const x = {
IDLE: 0,
LOADING: 1,
LOADED: 2,
/**
* Indicates that tile loading failed
* @type {number}
*/
ERROR: 3,
EMPTY: 4
};
function pi(i) {
return Math.pow(i, 3);
}
function yr(i) {
return 1 - pi(1 - i);
}
function Er(i) {
return 3 * i * i - 2 * i * i * i;
}
function O() {
throw new Error("Unimplemented abstract method.");
}
let Tr = 0;
function $(i) {
return i.ol_uid || (i.ol_uid = String(++Tr));
}
class sn extends Ri {
/**
* @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("./TileState.js").default} state State.
* @param {Options} [options] Tile options.
*/
constructor(t, e, n) {
super(), n = n || {}, this.tileCoord = t, this.state = e, this.key = "", this.transition_ = n.transition === void 0 ? 250 : n.transition, this.transitionStarts_ = {}, this.interpolate = !!n.interpolate;
}
/**
* @protected
*/
changed() {
this.dispatchEvent(nt.CHANGE);
}
/**
* Called by the tile cache when the tile is removed from the cache due to expiry
*/
release() {
this.setState(x.EMPTY);
}
/**
* @return {string} Key.
*/
getKey() {
return this.key + "/" + this.tileCoord;
}
/**
* Get the tile coordinate for this tile.
* @return {import("./tilecoord.js").TileCoord} The tile coordinate.
* @api
*/
getTileCoord() {
return this.tileCoord;
}
/**
* @return {import("./TileState.js").default} State.
*/
getState() {
return this.state;
}
/**
* Sets the state of this tile. If you write your own {@link module:ol/Tile~LoadFunction tileLoadFunction} ,
* it is important to set the state correctly to {@link module:ol/TileState~ERROR}
* when the tile cannot be loaded. Otherwise the tile cannot be removed from
* the tile queue and will block other requests.
* @param {import("./TileState.js").default} state State.
* @api
*/
setState(t) {
if (this.state !== x.EMPTY) {
if (this.state !== x.ERROR && this.state > t)
throw new Error("Tile load sequence violation");
this.state = t, this.changed();
}
}
/**
* Load the image or retry if loading previously failed.
* Loading is taken care of by the tile queue, and calling this method is
* only needed for preloading or for reloading in case of an error.
* @abstract
* @api
*/
load() {
O();
}
/**
* Get the alpha value for rendering.
* @param {string} id An id for the renderer.
* @param {number} time The render frame time.
* @return {number} A number between 0 and 1.
*/
getAlpha(t, e) {
if (!this.transition_)
return 1;
let n = this.transitionStarts_[t];
if (!n)
n = e, this.transitionStarts_[t] = n;
else if (n === -1)
return 1;
const s = e - n + 1e3 / 60;
return s >= this.transition_ ? 1 : pi(s / this.transition_);
}
/**
* Determine if a tile is in an alpha transition. A tile is considered in
* transition if tile.getAlpha() has not yet been called or has been called
* and returned 1.
* @param {string} id An id for the renderer.
* @return {boolean} The tile is in transition.
*/
inTransition(t) {
return this.transition_ ? this.transitionStarts_[t] !== -1 : !1;
}
/**
* Mark a transition as complete.
* @param {string} id An id for the renderer.
*/
endTransition(t) {
this.transition_ && (this.transitionStarts_[t] = -1);
}
/**
* @override
*/
disposeInternal() {
this.release(), super.disposeInternal();
}
}
function gt(i, t, e, n) {
let s;
return e && e.length ? s = /** @type {HTMLCanvasElement} */
e.shift() : mr ? s = new OffscreenCanvas(i || 300, t || 300) : s = document.createElement("canvas"), i && (s.width = i), t && (s.height = t), /** @type {CanvasRenderingContext2D} */
s.getContext("2d", n);
}
let we;
function On() {
return we || (we = gt(1, 1)), we;
}
function rn(i) {
const t = i.canvas;
t.width = 1, t.height = 1, i.clearRect(0, 0, 1, 1);
}
class yi extends sn {
/**
* @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("./TileState.js").default} state State.
* @param {string} src Image source URI.
* @param {?string} crossOrigin Cross origin.
* @param {import("./Tile.js").LoadFunction} tileLoadFunction Tile load function.
* @param {import("./Tile.js").Options} [options] Tile options.
*/
constructor(t, e, n, s, r, o) {
super(t, e, o), this.crossOrigin_ = s, this.src_ = n, this.key = n, this.image_ = new Image(), s !== null && (this.image_.crossOrigin = s), this.unlisten_ = null, this.tileLoadFunction_ = r;
}
/**
* Get the HTML image element for this tile (may be a Canvas, Image, or Video).
* @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
* @api
*/
getImage() {
return this.image_;
}
/**
* Sets an HTML image element for this tile (may be a Canvas or preloaded Image).
* @param {HTMLCanvasElement|HTMLImageElement} element Element.
*/
setImage(t) {
this.image_ = t, this.state = x.LOADED, this.unlistenImage_(), this.changed();
}
/**
* Tracks loading or read errors.
*
* @private
*/
handleImageError_() {
this.state = x.ERROR, this.unlistenImage_(), this.image_ = xr(), this.changed();
}
/**
* Tracks successful image load.
*
* @private
*/
handleImageLoad_() {
const t = (
/** @type {HTMLImageElement} */
this.image_
);
t.naturalWidth && t.naturalHeight ? this.state = x.LOADED : this.state = x.EMPTY, this.unlistenImage_(), this.changed();
}
/**
* Load the image or retry if loading previously failed.
* Loading is taken care of by the tile queue, and calling this method is
* only needed for preloading or for reloading in case of an error.
*
* To retry loading tiles on failed requests, use a custom `tileLoadFunction`
* that checks for error status codes and reloads only when the status code is
* 408, 429, 500, 502, 503 and 504, and only when not too many retries have been
* made already:
*
* ```js
* const retryCodes = [408, 429, 500, 502, 503, 504];
* const retries = {};
* source.setTileLoadFunction((tile, src) => {
* const image = tile.getImage();
* fetch(src)
* .then((response) => {
* if (retryCodes.includes(response.status)) {
* retries[src] = (retries[src] || 0) + 1;
* if (retries[src] <= 3) {
* setTimeout(() => tile.load(), retries[src] * 1000);
* }
* return Promise.reject();
* }
* return response.blob();
* })
* .then((blob) => {
* const imageUrl = URL.createObjectURL(blob);
* image.src = imageUrl;
* setTimeout(() => URL.revokeObjectURL(imageUrl), 5000);
* })
* .catch(() => tile.setState(3)); // error
* });
* ```
* @api
* @override
*/
load() {
this.state == x.ERROR && (this.state = x.IDLE, this.image_ = new Image(), this.crossOrigin_ !== null && (this.image_.crossOrigin = this.crossOrigin_)), this.state == x.IDLE && (this.state = x.LOADING, this.changed(), this.tileLoadFunction_(this, this.src_), this.unlisten_ = pr(
this.image_,
this.handleImageLoad_.bind(this),
this.handleImageError_.bind(this)
));
}
/**
* Discards event handlers which listen for load completion or errors.
*
* @private
*/
unlistenImage_() {
this.unlisten_ && (this.unlisten_(), this.unlisten_ = null);
}
/**
* @override
*/
disposeInternal() {
this.unlistenImage_(), this.image_ = null, super.disposeInternal();
}
}
function xr() {
const i = gt(1, 1);
return i.fillStyle = "rgba(0,0,0,0)", i.fillRect(0, 0, 1, 1), i.canvas;
}
let Se;
const Nt = [];
function Ln(i, t, e, n, s) {
i.beginPath(), i.moveTo(0, 0), i.lineTo(t, e), i.lineTo(n, s), i.closePath(), i.save(), i.clip(), i.fillRect(0, 0, Math.max(t, n) + 1, Math.max(e, s)), i.restore();
}
function ve(i, t) {
return Math.abs(i[t * 4] - 210) > 2 || Math.abs(i[t * 4 + 3] - 0.75 * 255) > 2;
}
function Cr() {
if (Se === void 0) {
const i = gt(6, 6, Nt);
i.globalCompositeOperation = "lighter", i.fillStyle = "rgba(210, 0, 0, 0.75)", Ln(i, 4, 5, 4, 0), Ln(i, 4, 5, 0, 5);
const t = i.getImageData(0, 0, 3, 3).data;
Se = ve(t, 0) || ve(t, 4) || ve(t, 8), rn(i), Nt.push(i.canvas);
}
return Se;
}
function bn(i, t, e, n) {
const s = ci(e, t, i);
let r = Pn(
t,
n,
e
);
const o = t.getMetersPerUnit();
o !== void 0 && (r *= o);
const a = i.getMetersPerUnit();
a !== void 0 && (r /= a);
const l = i.getExtent();
if (!l || Ue(l, s)) {
const c = Pn(i, r, s) / r;
isFinite(c) && c > 0 && (r /= c);
}
return r;
}
function Mr(i, t, e, n) {
const s = Gt(e);
let r = bn(
i,
t,
s,
n
);
return (!isFinite(r) || r <= 0) && ti(e, function(o) {
return r = bn(
i,
t,
o,
n
), isFinite(r) && r > 0;
}), r;
}
function Ir(i, t, e, n, s, r, o, a, l, c, h, u, d, g) {
const f = gt(
Math.round(e * i),
Math.round(e * t),
Nt
);
if (u || (f.imageSmoothingEnabled = !1), l.length === 0)
return f.canvas;
f.scale(e, e);
function _(p) {
return Math.round(p * e) / e;
}
f.globalCompositeOperation = "lighter";
const m = Ct();
l.forEach(function(p, S, w) {
$i(m, p.extent);
});
let y;
const R = e / n, T = (u ? 1 : 1 + Math.pow(2, -24)) / R;
y = gt(
Math.round(v(m) * R),
Math.round(W(m) * R),
Nt
), u || (y.imageSmoothingEnabled = !1), l.forEach(function(p, S, w) {
if (p.image.width > 0 && p.image.height > 0) {
if (p.clipExtent) {
y.save();
const L = (p.clipExtent[0] - m[0]) * R, C = -(p.clipExtent[3] - m[3]) * R, Z = v(p.clipExtent) * R, N = W(p.clipExtent) * R;
y.rect(
u ? L : Math.round(L),
u ? C : Math.round(C),
u ? Z : Math.round(L + Z) - Math.round(L),
u ? N : Math.round(C + N) - Math.round(C)
), y.clip();
}
const I = (p.extent[0] - m[0]) * R, P = -(p.extent[3] - m[3]) * R, b = v(p.extent) * R, X = W(p.extent) * R;
y.drawImage(
p.image,
c,
c,
p.image.width - 2 * c,
p.image.height - 2 * c,
u ? I : Math.round(I),
u ? P : Math.round(P),
u ? b : Math.round(I + b) - Math.round(I),
u ? X : Math.round(P + X) - Math.round(P)
), p.clipExtent && y.restore();
}
});
const E = Mt(o);
return a.getTriangles().forEach(function(p, S, w) {
const I = p.source, P = p.target;
let b = I[0][0], X = I[0][1], L = I[1][0], C = I[1][1], Z = I[2][0], N = I[2][1];
const tt = _((P[0][0] - E[0]) / r), it = _(
-(P[0][1] - E[1]) / r
), A = _((P[1][0] - E[0]) / r), F = _(
-(P[1][1] - E[1]) / r
), U = _((P[2][0] - E[0]) / r), _t = _(
-(P[2][1] - E[1]) / r
), q = b, H = X;
b = 0, X = 0, L -= q, C -= H, Z -= q, N -= H;
const et = [
[L, C, 0, 0, A - tt],
[Z, N, 0, 0, U - tt],
[0, 0, L, C, F - it],
[0, 0, Z, N, _t - it]
], Q = as(et);
if (!Q)
return;
if (f.save(), f.beginPath(), Cr() || !u) {
f.moveTo(A, F);
const j = 4, mt = tt - A, rt = it - F;
for (let J = 0; J < j; J++)
f.lineTo(
A + _((J + 1) * mt / j),
F + _(J * rt / (j - 1))
), J != j - 1 && f.lineTo(
A + _((J + 1) * mt / j),
F + _((J + 1) * rt / (j - 1))
);
f.lineTo(U, _t);
} else
f.moveTo(A, F), f.lineTo(tt, it), f.lineTo(U, _t);
f.clip(), f.transform(
Q[0],
Q[2],
Q[1],
Q[3],
tt,
it
), f.translate(
m[0] - q,
m[3] - H
);
let st;
if (y)
st = y.canvas, f.scale(T, -T);
else {
const j = l[0], mt = j.extent;
st = j.image, f.scale(
v(mt) / st.width,
-W(mt) / st.height
);
}
f.drawImage(st, 0, 0), f.restore();
}), y && (rn(y), Nt.push(y.canvas)), h && (f.save(), f.globalCompositeOperation = "source-over", f.strokeStyle = "black", f.lineWidth = 1, a.getTriangles().forEach(function(p, S, w) {
const I = p.target, P = (I[0][0] - E[0]) / r, b = -(I[0][1] - E[1]) / r, X = (I[1][0] - E[0]) / r, L = -(I[1][1] - E[1]) / r, C = (I[2][0] - E[0]) / r, Z = -(I[2][1] - E[1]) / r;
f.beginPath(), f.moveTo(X, L), f.lineTo(P, b), f.lineTo(C, Z), f.closePath(), f.stroke();
}), f.restore()), f.canvas;
}
new Array(6);
function re() {
return [1, 0, 0, 1, 0, 0];
}
function B(i, t) {
const e = t[0], n = t[1];
return t[0] = i[0] * e + i[2] * n + i[4], t[1] = i[1] * e + i[3] * n + i[5], t;
}
function ue(i, t, e, n, s, r, o, a) {
const l = Math.sin(r), c = Math.cos(r);
return i[0] = n * c, i[1] = s * l, i[2] = -n * l, i[3] = s * c, i[4] = o * n * c - a * n * l + t, i[5] = o * s * l + a * s * c + e, i;
}
function wr(i, t) {
const e = Sr(t);
D(e !== 0, "Transformation matrix cannot be inverted");
const n = t[0], s = t[1], r = t[2], o = t[3], a = t[4], l = t[5];
return i[0] = o / e, i[1] = -s / e, i[2] = -r / e, i[3] = n / e, i[4] = (r * l - o * a) / e, i[5] = -(n * l - s * a) / e, i;
}
function Sr(i) {
return i[0] * i[3] - i[1] * i[2];
}
const vr = [1e5, 1e5, 1e5, 1e5, 2, 2];
function Pr(i) {
return "matrix(" + i.join(", ") + ")";
}
function Xn(i) {
return i.substring(7, i.length - 1).split(",").map(parseFloat);
}
function Ar(i, t) {
const e = Xn(i), n = Xn(t);
for (let s = 0; s < 6; ++s)
if (Math.round((e[s] - n[s]) * vr[s]) !== 0)
return !1;
return !0;
}
const Fr = 10, Nn = 0.25;
class Or {
/**
* @param {import("../proj/Projection.js").default} sourceProj Source projection.
* @param {import("../proj/Projection.js").default} targetProj Target projection.
* @param {import("../extent.js").Extent} targetExtent Target extent to triangulate.
* @param {import("../extent.js").Extent} maxSourceExtent Maximal source extent that can be used.
* @param {number} errorThreshold Acceptable error (in source units).
* @param {?number} destinationResolution The (optional) resolution of the destination.
* @param {import("../transform.js").Transform} [sourceMatrix] Source transform matrix.
*/
constructor(t, e, n, s, r, o, a) {
this.sourceProj_ = t, this.targetProj_ = e;
let l = {};
const c = a ? Zs(
(T) => B(
a,
ci(T, this.targetProj_, this.sourceProj_)
)
) : Kt(this.targetProj_, this.sourceProj_);
this.transformInv_ = function(T) {
const E = T[0] + "/" + T[1];
return l[E] || (l[E] = c(T)), l[E];
}, this.maxSourceExtent_ = s, this.errorThresholdSquared_ = r * r, this.triangles_ = [], this.wrapsXInSource_ = !1, this.canWrapXInSource_ = this.sourceProj_.canWrapX() && !!s && !!this.sourceProj_.getExtent() && v(s) >= v(this.sourceProj_.getExtent()), this.sourceWorldWidth_ = this.sourceProj_.getExtent() ? v(this.sourceProj_.getExtent()) : null, this.targetWorldWidth_ = this.targetProj_.getExtent() ? v(this.targetProj_.getExtent()) : null;
const h = Mt(n), u = me(n), d = _e(n), g = ge(n), f = this.transformInv_(h), _ = this.transformInv_(u), m = this.transformInv_(d), y = this.transformInv_(g), R = Fr + (o ? Math.max(
0,
Math.ceil(
Math.log2(
Ne(n) / (o * o * 256 * 256)
)
)
) : 0);
if (this.addQuad_(
h,
u,
d,
g,
f,
_,
m,
y,
R
), this.wrapsXInSource_) {
let T = 1 / 0;
this.triangles_.forEach(function(E, p, S) {
T = Math.min(
T,
E.source[0][0],
E.source[1][0],
E.source[2][0]
);
}), this.triangles_.forEach((E) => {
if (Math.max(
E.source[0][0],
E.source[1][0],
E.source[2][0]
) - T > this.sourceWorldWidth_ / 2) {
const p = [
[E.source[0][0], E.source[0][1]],
[E.source[1][0], E.source[1][1]],
[E.source[2][0], E.source[2][1]]
];
p[0][0] - T > this.sourceWorldWidth_ / 2 && (p[0][0] -= this.sourceWorldWidth_), p[1][0] - T > this.sourceWorldWidth_ / 2 && (p[1][0] -= this.sourceWorldWidth_), p[2][0] - T > this.sourceWorldWidth_ / 2 && (p[2][0] -= this.sourceWorldWidth_);
const S = Math.min(
p[0][0],
p[1][0],
p[2][0]
);
Math.max(
p[0][0],
p[1][0],
p[2][0]
) - S < this.sourceWorldWidth_ / 2 && (E.source = p);
}
});
}
l = {};
}
/**
* Adds triangle to the triangulation.
* @param {import("../coordinate.js").Coordinate} a The target a coordinate.
* @param {import("../coordinate.js").Coordinate} b The target b coordinate.
* @param {import("../coordinate.js").Coordinate} c The target c coordinate.
* @param {import("../coordinate.js").Coordinate} aSrc The source a coordinate.
* @param {import("../coordinate.js").Coordinate} bSrc The source b coordinate.
* @param {import("../coordinate.js").Coordinate} cSrc The source c coordinate.
* @private
*/
addTriangle_(t, e, n, s, r, o) {
this.triangles_.push({
source: [s, r, o],
target: [t, e, n]
});
}
/**
* Adds quad (points in clock-wise order) to the triangulation
* (and reprojects the vertices) if valid.
* Performs quad subdivision if needed to increase precision.
*
* @param {import("../coordinate.js").Coordinate} a The target a coordinate.
* @param {import("../coordinate.js").Coordinate} b The target b coordinate.
* @param {import("../coordinate.js").Coordinate} c The target c coordinate.
* @param {import("../coordinate.js").Coordinate} d The target d coordinate.
* @param {import("../coordinate.js").Coordinate} aSrc The source a coordinate.
* @param {import("../coordinate.js").Coordinate} bSrc The source b coordinate.
* @param {import("../coordinate.js").Coordinate} cSrc The source c coordinate.
* @param {import("../coordinate.js").Coordinate} dSrc The source d coordinate.
* @param {number} maxSubdivision Maximal allowed subdivision of the quad.
* @private
*/
addQuad_(t, e, n, s, r, o, a, l, c) {
const h = pn([r, o, a, l]), u = this.sourceWorldWidth_ ? v(h) / this.sourceWorldWidth_ : null, d = (
/** @type {number} */
this.sourceWorldWidth_
), g = this.sourceProj_.canWrapX() && u > 0.5 && u < 1;
let f = !1;
if (c > 0) {
if (this.targetProj_.isGlobal() && this.targetWorldWidth_) {
const m = pn([t, e, n, s]);
f = v(m) / this.targetWorldWidth_ > Nn || f;
}
!g && this.sourceProj_.isGlobal() && u && (f = u > Nn || f);
}
if (!f && this.maxSourceExtent_ && isFinite(h[0]) && isFinite(h[1]) && isFinite(h[2]) && isFinite(h[3]) && !kt(h, this.maxSourceExtent_))
return;
let _ = 0;
if (!f && (!isFinite(r[0]) || !isFinite(r[1]) || !isFinite(o[0]) || !isFinite(o[1]) || !isFinite(a[0]) || !isFinite(a[1]) || !isFinite(l[0]) || !isFinite(l[1]))) {
if (c > 0)
f = !0;
else if (_ = (!isFinite(r[0]) || !isFinite(r[1]) ? 8 : 0) + (!isFinite(o[0]) || !isFinite(o[1]) ? 4 : 0) + (!isFinite(a[0]) || !isFinite(a[1]) ? 2 : 0) + (!isFinite(l[0]) || !isFinite(l[1]) ? 1 : 0), _ != 1 && _ != 2 && _ != 4 && _ != 8)
return;
}
if (c > 0) {
if (!f) {
const m = [(t[0] + n[0]) / 2, (t[1] + n[1]) / 2], y = this.transformInv_(m);
let R;
g ? R = (bt(r[0], d) + bt(a[0], d)) / 2 - bt(y[0], d) : R = (r[0] + a[0]) / 2 - y[0];
const T = (r[1] + a[1]) / 2 - y[1];
f = R * R + T * T > this.errorThresholdSquared_;
}
if (f) {
if (Math.abs(t[0] - n[0]) <= Math.abs(t[1] - n[1])) {
const m = [(e[0] + n[0]) / 2, (e[1] + n[1]) / 2], y = this.transformInv_(m), R = [(s[0] + t[0]) / 2, (s[1] + t[1]) / 2], T = this.transformInv_(R);
this.addQuad_(
t,
e,
m,
R,
r,
o,
y,
T,
c - 1
), this.addQuad_(
R,
m,
n,
s,
T,
y,
a,
l,
c - 1
);
} else {
const m = [(t[0] + e[0]) / 2, (t[1] + e[1]) / 2], y = this.transformInv_(m), R = [(n[0] + s[0]) / 2, (n[1] + s[1]) / 2], T = this.transformInv_(R);
this.addQuad_(
t,
m,
R,
s,
r,
y,
T,
l,
c - 1
), this.addQuad_(
m,
e,
n,
R,
y,
o,
a,
T,
c - 1
);
}
return;
}
}
if (g) {
if (!this.canWrapXInSource_)
return;
this.wrapsXInSource_ = !0;
}
(_ & 11) == 0 && this.addTriangle_(t, n, s, r, a, l), (_ & 14) == 0 && this.addTriangle_(t, n, e, r, a, o), _ && ((_ & 13) == 0 && this.addTriangle_(e, s, t, o, l, r), (_ & 7) == 0 && this.addTriangle_(e, s, n, o, l, a));
}
/**
* Calculates extent of the `source` coordinates from all the triangles.
*
* @return {import("../extent.js").Extent} Calculated extent.
*/
calculateSourceExtent() {
const t = Ct();
return this.triangles_.forEach(function(e, n, s) {
const r = e.source;
se(t, r[0]), se(t, r[1]), se(t, r[2]);
}), t;
}
/**
* @return {Array<Triangle>} Array of the calculated triangles.
*/
getTriangles() {
return this.triangles_;
}
}
const Lr = 0.5;
class Ei extends sn {
/**
* @param {import("../proj/Projection.js").default} sourceProj Source projection.
* @param {import("../tilegrid/TileGrid.js").default} sourceTileGrid Source tile grid.
* @param {import("../proj/Projection.js").default} targetProj Target projection.
* @param {import("../tilegrid/TileGrid.js").default} targetTileGrid Target tile grid.
* @param {import("../tilecoord.js").TileCoord} tileCoord Coordinate of the tile.
* @param {import("../tilecoord.js").TileCoord} wrappedTileCoord Coordinate of the tile wrapped in X.
* @param {number} pixelRatio Pixel ratio.
* @param {number} gutter Gutter of the source tiles.
* @param {FunctionType} getTileFunction
* Function returning source tiles (z, x, y, pixelRatio).
* @param {number} [errorThreshold] Acceptable reprojection error (in px).
* @param {boolean} [renderEdges] Render reprojection edges.
* @param {import("../Tile.js").Options} [options] Tile options.
*/
constructor(t, e, n, s, r, o, a, l, c, h, u, d) {
super(r, x.IDLE, d), this.renderEdges_ = u !== void 0 ? u : !1, this.pixelRatio_ = a, this.gutter_ = l, this.canvas_ = null, this.sourceTileGrid_ = e, this.targetTileGrid_ = s, this.wrappedTileCoord_ = o || r, this.sourceTiles_ = [], this.sourcesListenerKeys_ = null, this.sourceZ_ = 0, this.clipExtent_ = t.canWrapX() ? t.getExtent() : void 0;
const g = s.getTileCoordExtent(
this.wrappedTileCoord_
), f = this.targetTileGrid_.getExtent();
let _ = this.sourceTileGrid_.getExtent();
const m = f ? Ot(g, f) : g;
if (Ne(m) === 0) {
this.state = x.EMPTY;
return;
}
const y = t.getExtent();
y && (_ ? _ = Ot(_, y) : _ = y);
const R = s.getResolution(
this.wrappedTileCoord_[0]
), T = Mr(
t,
n,
m,
R
);
if (!isFinite(T) || T <= 0) {
this.state = x.EMPTY;
return;
}
const E = h !== void 0 ? h : Lr;
if (this.triangulation_ = new Or(
t,
n,
m,
_,
T * E,
R
), this.triangulation_.getTriangles().length === 0) {
this.state = x.EMPTY;
return;
}
this.sourceZ_ = e.getZForResolution(T);
let p = this.triangulation_.calculateSourceExtent();
if (_ && (t.canWrapX() ? (p[1] = z(
p[1],
_[1],
_[3]
), p[3] = z(
p[3],
_[1],
_[3]
)) : p = Ot(p, _)), !Ne(p))
this.state = x.EMPTY;
else {
let S = 0, w = 0;
t.canWrapX() && (S = v(y), w = Math.floor(
(p[0] - y[0]) / S
)), is(
p.slice(),
t
).forEach((P) => {
const b = e.getTileRangeForExtentAndZ(
P,
this.sourceZ_
);
for (let X = b.minX; X <= b.maxX; X++)
for (let L = b.minY; L <= b.maxY; L++) {
const C = c(this.sourceZ_, X, L, a);
if (C) {
const Z = w * S;
this.sourceTiles_.push({ tile: C, offset: Z });
}
}
++w;
}), this.sourceTiles_.length === 0 && (this.state = x.EMPTY);
}
}
/**
* Get the HTML Canvas element for this tile.
* @return {HTMLCanvasElement} Canvas.
*/
getImage() {
return this.canvas_;
}
/**
* @private
*/
reproject_() {
const t = [];
if (this.sourceTiles_.forEach((e) => {
var s;
const n = e.tile;
if (n && n.getState() == x.LOADED) {
const r = this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);
r[0] += e.offset, r[2] += e.offset;
const o = (s = this.clipExtent_) == null ? void 0 : s.slice();
o && (o[0] += e.offset, o[2] += e.offset), t.push({
extent: r,
clipExtent: o,
image: n.getImage()
});
}
}), this.sourceTiles_.length = 0, t.length === 0)
this.state = x.ERROR;
else {
const e = this.wrappedTileCoord_[0], n = this.targetTileGrid_.getTileSize(e), s = typeof n == "number" ? n : n[0], r = typeof n == "number" ? n : n[1], o = this.targetTileGrid_.getResolution(e), a = this.sourceTileGrid_.getResolution(
this.sourceZ_
), l = this.targetTileGrid_.getTileCoordExtent(
this.wrappedTileCoord_
);
this.canvas_ = Ir(
s,
r,
this.pixelRatio_,
a,
this.sourceTileGrid_.getExtent(),
o,
l,
this.triangulation_,
t,
this.gutter_,
this.renderEdges_,
this.interpolate
), this.state = x.LOADED;
}
this.changed();
}
/**
* Load not yet loaded URI.
* @override
*/
load() {
if (this.state == x.IDLE) {
this.state = x.LOADING, this.changed();
let t = 0;
this.sourcesListenerKeys_ = [], this.sourceTiles_.forEach(({ tile: e }) => {
const n = e.getState();
if (n == x.IDLE || n == x.LOADING) {
t++;
const s = Tt(e, nt.CHANGE, (r) => {
const o = e.getState();
(o == x.LOADED || o == x.ERROR || o == x.EMPTY) && (ft(s), t--, t === 0 && (this.unlistenSources_(), this.reproject_()));
});
this.sourcesListenerKeys_.push(s);
}
}), t === 0 ? setTimeout(this.reproject_.bind(this), 0) : this.sourceTiles_.forEach(function({ tile: e }, n, s) {
e.getState() == x.IDLE && e.load();
});
}
}
/**
* @private
*/
unlistenSources_() {
this.sourcesListenerKeys_.forEach(ft), this.sourcesListenerKeys_ = null;
}
/**
* Remove from the cache due to expiry
* @override
*/
release() {
this.canvas_ && (rn(this.canvas_.getContext("2d")), Nt.push(this.canvas_), this.canvas_ = null), super.release();
}
}
const br = {
/**
* Triggered when a property is changed.
* @event module:ol/Object.ObjectEvent#propertychange
* @api
*/
PROPERTYCHANGE: "propertychange"
};
class Bt extends Ri {
constructor() {
super(), this.on = /** @type {ObservableOnSignature<import("./events").EventsKey>} */
this.onInternal, this.once = /** @type {ObservableOnSignature<import("./events").EventsKey>} */
this.onceInternal, this.un = /** @type {ObservableOnSignature<void>} */
this.unInternal, this.revision_ = 0;
}
/**
* Increases the revision counter and dispatches a 'change' event.
* @api
*/
changed() {
++this.revision_, this.dispatchEvent(nt.CHANGE);
}
/**
* Get the version number for this object. Each time the object is modified,
* its version number will be incremented.
* @return {number} Revision.
* @api
*/
getRevision() {
return this.revision_;
}
/**
* @param {string|Array<string>} type Type.
* @param {function((Event|import("./events/Event").default)): ?} listener Listener.
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
* @protected
*/
onInternal(t, e) {
if (Array.isArray(t)) {
const n = t.length, s = new Array(n);
for (let r = 0; r < n; ++r)
s[r] = Tt(this, t[r], e);
return s;
}
return Tt(
this,
/** @type {string} */
t,
e
);
}
/**
* @param {string|Array<string>} type Type.
* @param {function((Event|import("./events/Event").default)): ?} listener Listener.
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
* @protected
*/
onceInternal(t, e) {
let n;
if (Array.isArray(t)) {
const s = t.length;
n = new Array(s);
for (let r = 0; r < s; ++r)
n[r] = he(this, t[r], e);
} else
n = he(
this,
/** @type {string} */
t,
e
);
return e.ol_key = n, n;
}
/**
* Unlisten for a certain type of event.
* @param {string|Array<string>} type Type.
* @param {function((Event|import("./events/Event").default)): ?} listener Listener.
* @protected
*/
unInternal(t, e) {
const n = (
/** @type {Object} */
e.ol_key
);
if (n)
Xr(n);
else if (Array.isArray(t))
for (let s = 0, r = t.length; s < r; ++s)
this.removeEventListener(t[s], e);
else
this.removeEventListener(t, e);
}
}
Bt.prototype.on;
Bt.prototype.once;
Bt.prototype.un;
function Xr(i) {
if (Array.isArray(i))
for (let t = 0, e = i.length; t < e; ++t)
ft(i[t]);
else
ft(
/** @type {import("./events.js").EventsKey} */
i
);
}
class Gn extends Ee {
/**
* @param {string} type The event type.
* @param {string} key The property name.
* @param {*} oldValue The old value for `key`.
*/
constructor(t, e, n) {
super(t), this.key = e, this.oldValue = n;
}
}
class Te extends Bt {
/**
* @param {Object<string, *>} [values] An object with key-value pairs.
*/
constructor(t) {
super(), this.on, this.once, this.un, $(this), this.values_ = null, t !== void 0 && this.setProperties(t);
}
/**
* Gets a value.
* @param {string} key Key name.
* @return {*} Value.
* @api
*/
get(t) {
let e;
return this.values_ && this.values_.hasOwnProperty(t) && (e = this.values_[t]), e;
}
/**
* Get a list of object property names.
* @return {Array<string>} List of property names.
* @api
*/
getKeys() {
return this.values_ && Object.keys(this.values_) || [];
}
/**
* Get an object of all property names and values.
* @return {Object<string, *>} Object.
* @api
*/
getProperties() {
return this.values_ && Object.assign({}, this.values_) || {};
}
/**
* Get an object of all property names and values.
* @return {Object<string, *>?} Object.
*/
getPropertiesInternal() {
return this.values_;
}
/**
* @return {boolean} The object has properties.
*/
hasProperties() {
return !!this.values_;
}
/**
* @param {string} key Key name.
* @param {*} oldValue Old value.
*/
notify(t, e) {
let n;
n = `change:${t}`, this.hasListener(n) && this.dispatchEvent(new Gn(n, t, e)), n = br.PROPERTYCHANGE, this.hasListener(n) && this.dispatchEvent(new Gn(n, t, e));
}
/**
* @param {string} key Key name.
* @param {import("./events.js").Listener} listener Listener.
*/
addChangeListener(t, e) {
this.addEventListener(`change:${t}`, e);
}
/**
* @param {string} key Key name.
* @param {import("./events.js").Listener} listener Listener.
*/
removeChangeListener(t, e) {
this.removeEventListener(`change:${t}`, e);
}
/**
* Sets a value.
* @param {string} key Key name.
* @param {*} value Value.
* @param {boolean} [silent] Update without triggering an event.
* @api
*/
set(t, e, n) {
const s = this.values_ || (this.values_ = {});
if (n)
s[t] = e;
else {
const r = s[t];
s[t] = e, r !== e && this.notify(t, r);
}
}
/**
* Sets a collection of key-value pairs. Note that this changes any existing
* properties and adds new ones (it does not remove any existing properties).
* @param {Object<string, *>} values Values.
* @param {boolean} [silent] Update without triggering an event.
* @api
*/
setProperties(t, e) {
for (const n in t)
this.set(n, t[n], e);
}
/**
* Apply any properties from another object without triggering events.
* @param {BaseObject} source The source object.
* @protected
*/
applyProperties(t) {
t.values_ && Object.assign(this.values_ || (this.values_ = {}), t.values_);
}
/**
* Unsets a property.
* @param {string} key Key name.
* @param {boolean} [silent] Unset without triggering an event.
* @api
*/
unset(t, e) {
if (this.values_ && t in this.values_) {
const n = this.values_[t];
delete this.values_[t], ys(this.values_) && (this.values_ = null), e || this.notify(t, n);
}
}
}
class Nr extends Te {
/**
* @param {Options} options Source options.
*/
constructor(t) {
super(), this.projection = Y(t.projection), this.attributions_ = Dn(t.attributions), this.attributionsCollapsible_ = t.attributionsCollapsible ?? !0, this.loading = !1, this.state_ = t.state !== void 0 ? t.state : "ready", this.wrapX_ = t.wrapX !== void 0 ? t.wrapX : !1, this.interpolate_ = !!t.interpolate, this.viewResolver = null, this.viewRejector = null;
const e = this;
this.viewPromise_ = new Promise(function(n, s) {
e.viewResolver = n, e.viewRejector = s;
});
}
/**
* Get the attribution function for the source.
* @return {?Attribution} Attribution function.
* @api
*/
getAttributions() {
return this.attributions_;
}
/**
* @return {boolean} Attributions are collapsible.
* @api
*/
getAttributionsCollapsible() {
return this.attributionsCollapsible_;
}
/**
* Get the projection of the source.
* @return {import("../proj/Projection.js").default|null} Projection.
* @api
*/
getProjection() {
return this.projection;
}
/**
* @param {import("../proj/Projection").default} [projection] Projection.
* @return {Array<number>|null} Resolutions.
*/
getResolutions(t) {
return null;
}
/**
* @return {Promise<import("../View.js").ViewOptions>} A promise for view-related properties.
*/
getView() {
return this.viewPromise_;
}
/**
* Get the state of the source, see {@link import("./Source.js").State} for possible states.
* @return {import("./Source.js").State} State.
* @api
*/
getState() {
return this.state_;
}
/**
* @return {boolean|undefined} Wrap X.
*/
getWrapX() {
return this.wrapX_;
}
/**
* @return {boolean} Use linear interpolation when resampling.
*/
getInterpolate() {
return this.interpolate_;
}
/**
* Refreshes the source. The source will be cleared, and data from the server will be reloaded.
* @api
*/
refresh() {
this.changed();
}
/**
* Set the attributions of the source.
* @param {AttributionLike|undefined} attributions Attributions.
* Can be passed as `string`, `Array<string>`, {@link module:ol/source/Source~Attribution},
* or `undefined`.
* @api
*/
setAttributions(t) {
this.attributions_ = Dn(t), this.changed();
}
/**
* Set the state of the source.
* @param {import("./Source.js").State} state State.
*/
setState(t) {
this.state_ = t, this.changed();
}
}
function Dn(i) {
return i ? typeof i == "function" ? i : (Array.isArray(i) || (i = [i]), (t) => i) : null;
}
class Gr extends Nr {
/**
* @param {Options} options SourceTile source options.
*/
constructor(t) {
super({
attributions: t.attributions,
attributionsCollapsible: t.attributionsCollapsible,
projection: t.projection,
state: t.state,
wrapX: t.wrapX,
interpolate: t.interpolate
}), this.on, this.once, this.un, this.tilePixelRatio_ = t.tilePixelRatio !== void 0 ? t.tilePixelRatio : 1, this.tileGrid = t.tileGrid !== void 0 ? t.tileGrid : null;
const e = [256, 256];
this.tileGrid && ut(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()), e), this.tmpSize = [0, 0], this.key_ = t.key || $(this), this.tileOptions = {
transition: t.transition,
interpolate: t.interpolate
}, this.zDirection = t.zDirection ? t.zDirection : 0;
}
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {number} Gutter.
*/
getGutterForProjection(t) {
return 0;
}
/**
* Return the key to be used for all tiles in the source.
* @return {string} The key for all tiles.
*/
getKey() {
return this.key_;
}
/**
* Set the value to be used as the key for all tiles in the source.
* @param {string} key The key for tiles.
* @protected
*/
setKey(t) {
this.key_ !== t && (this.key_ = t, this.changed());
}
/**
* @param {import("../proj/Projection").default} [projection] Projection.
* @return {Array<number>|null} Resolutions.
* @override
*/
getResolutions(t) {
const e = t ? this.getTileGridForProjection(t) : this.tileGrid;
return e ? e.getResolutions() : null;
}
/**
* @abstract
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {TileType|null} Tile.
*/
getTile(t, e, n, s, r) {
return O();
}
/**
* Return the tile grid of the tile source.
* @return {import("../tilegrid/TileGrid.js").default|null} Tile grid.
* @api
*/
getTileGrid() {
return this.tileGrid;
}
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
*/
getTileGridForProjection(t) {
return this.tileGrid ? this.tileGrid : _i(t);
}
/**
* Get the tile pixel ratio for this source. Subclasses may override this
* method, which is meant to return a supported pixel ratio that matches the
* provided `pixelRatio` as close as possible.
* @param {number} pixelRatio Pixel ratio.
* @return {number} Tile pixel ratio.
*/
getTilePixelRatio(t) {
return this.tilePixelRatio_;
}
/**
* @param {number} z Z.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {import("../size.js").Size} Tile size.
*/
getTilePixelSize(t, e, n) {
const s = this.getTileGridForProjection(n), r = this.getTilePixelRatio(e), o = ut(s.getTileSize(t), this.tmpSize);
return r == 1 ? o : Bs(o, r, this.tmpSize);
}
/**
* Returns a tile coordinate wrapped around the x-axis. When the tile coordinate
* is outside the resolution and extent range of the tile grid, `null` will be
* returned.
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {import("../proj/Projection.js").default} [projection] Projection.
* @return {import("../tilecoord.js").TileCoord} Tile coordinate to be passed to the tileUrlFunction or
* null if no tile URL should be created for the passed `tileCoord`.
*/
getTileCoordForTileUrlFunction(t, e) {
const n = e !== void 0 ? e : this.getProjection(), s = e !== void 0 ? this.getTileGridForProjection(n) : this.tileGrid || this.getTileGridForProjection(n);
return this.getWrapX() && n.isGlobal() && (t = er(s, t, n)), Vs(t, s) ? t : null;
}
/**
* Remove all cached reprojected tiles from the source. The next render cycle will create new tiles.
* @api
*/
clear() {
}
/**
* @override
*/
refresh() {
this.clear(), super.refresh();
}
}
class Dr extends Ee {
/**
* @param {string} type Type.
* @param {import("../Tile.js").default} tile The tile.
*/
constructor(t, e) {
super(t), this.tile = e;
}
}
const Pe = {
/**
* Triggered when a tile starts loading.
* @event module:ol/source/Tile.TileSourceEvent#tileloadstart
* @api
*/
TILELOADSTART: "tileloadstart",
/**
* Triggered when a tile finishes loading, either when its data is loaded,
* or when loading was aborted because the tile is no longer needed.
* @event module:ol/source/Tile.TileSourceEvent#tileloadend
* @api
*/
TILELOADEND: "tileloadend",
/**
* Triggered if tile loading results in an error. Note that this is not the
* right place to re-fetch tiles. See {@link module:ol/ImageTile~ImageTile#load}
* for details.
* @event module:ol/source/Tile.TileSourceEvent#tileloaderror
* @api
*/
TILELOADERROR: "tileloaderror"
};
class on extends Gr {
/**
* @param {Options} options Image tile options.
*/
constructor(t) {
super({
attributions: t.attributions,
cacheSize: t.cacheSize,
projection: t.projection,
state: t.state,
tileGrid: t.tileGrid,
tilePixelRatio: t.tilePixelRatio,
wrapX: t.wrapX,
transition: t.transition,
interpolate: t.interpolate,
key: t.key,
attributionsCollapsible: t.attributionsCollapsible,
zDirection: t.zDirection
}), this.generateTileUrlFunction_ = this.tileUrlFunction === on.prototype.tileUrlFunction, this.tileLoadFunction = t.tileLoadFunction, t.tileUrlFunction && (this.tileUrlFunction = t.tileUrlFunction), this.urls = null, t.urls ? this.setUrls(t.urls) : t.url && this.setUrl(t.url), this.tileLoadingKeys_ = {};
}
/**
* Deprecated. Use an ImageTile source instead.
* Return the tile load function of the source.
* @return {import("../Tile.js").LoadFunction} TileLoadFunction
* @api
*/
getTileLoadFunction() {
return this.tileLoadFunction;
}
/**
* Deprecated. Use an ImageTile source instead.
* Return the tile URL function of the source.
* @return {import("../Tile.js").UrlFunction} TileUrlFunction
* @api
*/
getTileUrlFunction() {
return Object.getPrototypeOf(this).tileUrlFunction === this.tileUrlFunction ? this.tileUrlFunction.bind(this) : this.tileUrlFunction;
}
/**
* Deprecated. Use an ImageTile source instead.
* Return the URLs used for this source.
* When a tileUrlFunction is used instead of url or urls,
* null will be returned.
* @return {!Array<string>|null} URLs.
* @api
*/
getUrls() {
return this.urls;
}
/**
* Handle tile change events.
* @param {import("../events/Event.js").default} event Event.
* @protected
*/
handleTileChange(t) {
const e = (
/** @type {import("../Tile.js").default} */
t.target
), n = $(e), s = e.getState();
let r;
s == x.LOADING ? (this.tileLoadingKeys_[n] = !0, r = Pe.TILELOADSTART) : n in this.tileLoadingKeys_ && (delete this.tileLoadingKeys_[n], r = s == x.ERROR ? Pe.TILELOADERROR : s == x.LOADED ? Pe.TILELOADEND : void 0), r != null && this.dispatchEvent(new Dr(r, e));
}
/**
* Deprecated. Use an ImageTile source instead.
* Set the tile load function of the source.
* @param {import("../Tile.js").LoadFunction} tileLoadFunction Tile load function.
* @api
*/
setTileLoadFunction(t) {
this.tileLoadFunction = t, this.changed();
}
/**
* Deprecated. Use an ImageTile source instead.
* Set the tile URL function of the source.
* @param {import("../Tile.js").UrlFunction} tileUrlFunction Tile URL function.
* @param {string} [key] Optional new tile key for the source.
* @api
*/
setTileUrlFunction(t, e) {
this.tileUrlFunction = t, typeof e < "u" ? this.setKey(e) : this.changed();
}
/**
* Set the URL to use for requests.
* @param {string} url URL.
* @api
*/
setUrl(t) {
const e = hr(t);
this.urls = e, this.setUrls(e);
}
/**
* Deprecated. Use an ImageTile source instead.
* Set the URLs to use for requests.
* @param {Array<string>} urls URLs.
* @api
*/
setUrls(t) {
this.urls = t;
const e = t.join(`
`);
this.generateTileUrlFunction_ ? this.setTileUrlFunction(dr(t, this.tileGrid), e) : this.setKey(e);
}
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {string|undefined} Tile URL.
*/
tileUrlFunction(t, e, n) {
}
}
class zr extends on {
/**
* @param {!Options} options Image tile options.
*/
constructor(t) {
super({
attributions: t.attributions,
cacheSize: t.cacheSize,
projection: t.projection,
state: t.state,
tileGrid: t.tileGrid,
tileLoadFunction: t.tileLoadFunction ? t.tileLoadFunction : Zr,
tilePixelRatio: t.tilePixelRatio,
tileUrlFunction: t.tileUrlFunction,
url: t.url,
urls: t.urls,
wrapX: t.wrapX,
transition: t.transition,
interpolate: t.interpolate !== void 0 ? t.interpolate : !0,
key: t.key,
attributionsCollapsible: t.attributionsCollapsible,
zDirection: t.zDirection
}), this.crossOrigin = t.crossOrigin !== void 0 ? t.crossOrigin : null, this.tileClass = t.tileClass !== void 0 ? t.tileClass : yi, this.tileGridForProjection = {}, this.reprojectionErrorThreshold_ = t.reprojectionErrorThreshold, this.renderReprojectionEdges_ = !1;
}
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {number} Gutter.
* @override
*/
getGutterForProjection(t) {
return this.getProjection() && t && !Me(this.getProjection(), t) ? 0 : this.getGutter();
}
/**
* @return {number} Gutter.
*/
getGutter() {
return 0;
}
/**
* Return the key to be used for all tiles in the source.
* @return {string} The key for all tiles.
* @override
*/
getKey() {
let t = super.getKey();
return this.getInterpolate() || (t += ":disable-interpolation"), t;
}
/**
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
* @override
*/
getTileGridForProjection(t) {
const e = this.getProjection();
if (this.tileGrid && (!e || Me(e, t)))
return this.tileGrid;
const n = $(t);
return n in this.tileGridForProjection || (this.tileGridForProjection[n] = _i(t)), this.tileGridForProjection[n];
}
/**
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @param {string} key The key set on the tile.
* @return {!ImageTile} Tile.
* @private
*/
createTile_(t, e, n, s, r, o) {
const a = [t, e, n], l = this.getTileCoordForTileUrlFunction(
a,
r
), c = l ? this.tileUrlFunction(l, s, r) : void 0, h = new this.tileClass(
a,
c !== void 0 ? x.IDLE : x.EMPTY,
c !== void 0 ? c : "",
this.crossOrigin,
this.tileLoadFunction,
this.tileOptions
);
return h.key = o, h.addEventListener(nt.CHANGE, this.handleTileChange.bind(this)), h;
}
/**
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {import("../proj/Projection.js").default} projection Projection.
* @return {!(ImageTile|ReprojTile)} Tile.
* @override
*/
getTile(t, e, n, s, r) {
const o = this.getProjection();
if (!o || !r || Me(o, r))
return this.getTileInternal(
t,
e,
n,
s,
o || r
);
const a = [t, e, n], l = this.getKey(), c = this.getTileGridForProjection(o), h = this.getTileGridForProjection(r), u = this.getTileCoordForTileUrlFunction(
a,
r
), d = new Ei(
o,
c,
r,
h,
a,
u,
this.getTilePixelRatio(s),
this.getGutter(),
(g, f, _, m) => this.getTileInternal(g, f, _, m, o),
this.reprojectionErrorThreshold_,
this.renderReprojectionEdges_,
this.tileOptions
);
return d.key = l, d;
}
/**
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {number} pixelRatio Pixel ratio.
* @param {!import("../proj/Projection.js").default} projection Projection.
* @return {!ImageTile} Tile.
* @protected
*/
getTileInternal(t, e, n, s, r) {
const o = this.getKey();
return this.createTile_(t, e, n, s, r, o);
}
/**
* Sets whether to render reprojection edges or not (usually for debugging).
* @param {boolean} render Render the edges.
* @api
*/
setRenderReprojectionEdges(t) {
this.renderReprojectionEdges_ != t && (this.renderReprojectionEdges_ = t, this.changed());
}
/**
* Sets the tile grid to use when reprojecting the tiles to the given
* projection instead of the default tile grid for the projection.
*
* This can be useful when the default tile grid cannot be created
* (e.g. projection has no extent defined) or
* for optimization reasons (custom tile size, resolutions, ...).
*
* @param {import("../proj.js").ProjectionLike} projection Projection.
* @param {import("../tilegrid/TileGrid.js").default} tilegrid Tile grid to use for the projection.
* @api
*/
setTileGridForProjection(t, e) {
const n = Y(t);
if (n) {
const s = $(n);
s in this.tileGridForProjection || (this.tileGridForProjection[s] = e);
}
}
}
function Zr(i, t) {
i.getImage().src = t;
}
class jr extends zr {
/**
* @param {Options} [options] XYZ options.
*/
constructor(t) {
t = t || {};
const e = t.projection !== void 0 ? t.projection : "EPSG:3857", n = t.tileGrid !== void 0 ? t.tileGrid : ir({
extent: nn(e),
maxResolution: t.maxResolution,
maxZoom: t.maxZoom,
minZoom: t.minZoom,
tileSize: t.tileSize
});
super({
attributions: t.attributions,
cacheSize: t.cacheSize,
crossOrigin: t.crossOrigin,
interpolate: t.interpolate,
projection: e,
reprojectionErrorThreshold: t.reprojectionErrorThreshold,
tileGrid: n,
tileLoadFunction: t.tileLoadFunction,
tilePixelRatio: t.tilePixelRatio,
tileUrlFunction: t.tileUrlFunction,
url: t.url,
urls: t.urls,
wrapX: t.wrapX !== void 0 ? t.wrapX : !0,
transition: t.transition,
attributionsCollapsible: t.attributionsCollapsible,
zDirection: t.zDirection
}), this.gutter_ = t.gutter !== void 0 ? t.gutter : 0;
}
/**
* @return {number} Gutter.
* @override
*/
getGutter() {
return this.gutter_;
}
}
function Yr(i, t, e, n, s, r, o) {
r = r || [], o = o || 2;
let a = 0;
for (let l = t; l < e; l += n) {
const c = i[l], h = i[l + 1];
r[a++] = s[0] * c + s[2] * h + s[4], r[a++] = s[1] * c + s[3] * h + s[5];
for (let u = 2; u < o; u++)
r[a++] = i[l + u];
}
return r && r.length != a && (r.length = a), r;
}
function Ur(i, t, e, n, s, r, o) {
o = o || [];
const a = Math.cos(s), l = Math.sin(s), c = r[0], h = r[1];
let u = 0;
for (let d = t; d < e; d += n) {
const g = i[d] - c, f = i[d + 1] - h;
o[u++] = c + g * a - f * l, o[u++] = h + g * l + f * a;
for (let _ = d + 2; _ < d + n; ++_)
o[u++] = i[_];
}
return o && o.length != u && (o.length = u), o;
}
function Kr(i, t, e, n, s, r, o, a) {
a = a || [];
const l = o[0], c = o[1];
let h = 0;
for (let u = t; u < e; u += n) {
const d = i[u] - l, g = i[u + 1] - c;
a[h++] = l + s * d, a[h++] = c + r * g;
for (let f = u + 2; f < u + n; ++f)
a[h++] = i[f];
}
return a && a.length != h && (a.length = h), a;
}
function Wr(i, t, e, n, s, r, o) {
o = o || [];
let a = 0;
for (let l = t; l < e; l += n) {
o[a++] = i[l] + s, o[a++] = i[l + 1] + r;
for (let c = l + 2; c < l + n; ++c)
o[a++] = i[c];
}
return o && o.length != a && (o.length = a), o;
}
const zn = re(), kr = [NaN, NaN];
class Vr extends Te {
constructor() {
super(), this.extent_ = Ct(), this.extentRevision_ = -1, this.simplifiedGeometryMaxMinSquaredTolerance = 0, this.simplifiedGeometryRevision = 0, this.simplifyTransformedInternal = gr(
(t, e, n) => {
if (!n)
return this.getSimplifiedGeometry(e);
const s = this.clone();
return s.applyTransform(n), s.getSimplifiedGeometry(e);
}
);
}
/**
* Get a transformed and simplified version of the geometry.
* @abstract
* @param {number} squaredTolerance Squared tolerance.
* @param {import("../proj.js").TransformFunction} [transform] Optional transform function.
* @return {Geometry} Simplified geometry.
*/
simplifyTransformed(t, e) {
return this.simplifyTransformedInternal(
this.getRevision(),
t,
e
);
}
/**
* Make a complete copy of the geometry.
* @abstract
* @return {!Geometry} Clone.
*/
clone() {
return O();
}
/**
* @abstract
* @param {number} x X.
* @param {number} y Y.
* @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
* @param {number} minSquaredDistance Minimum squared distance.
* @return {number} Minimum squared distance.
*/
closestPointXY(t, e, n, s) {
return O();
}
/**
* @param {number} x X.
* @param {number} y Y.
* @return {boolean} Contains (x, y).
*/
containsXY(t, e) {
return this.closestPointXY(t, e, kr, Number.MIN_VALUE) === 0;
}
/**
* Return the closest point of the geometry to the passed point as
* {@link module:ol/coordinate~Coordinate coordinate}.
* @param {import("../coordinate.js").Coordinate} point Point.
* @param {import("../coordinate.js").Coordinate} [closestPoint] Closest point.
* @return {import("../coordinate.js").Coordinate} Closest point.
* @api
*/
getClosestPoint(t, e) {
return e = e || [NaN, NaN], this.closestPointXY(t[0], t[1], e, 1 / 0), e;
}
/**
* Returns true if this geometry includes the specified coordinate. If the
* coordinate is on the boundary of the geometry, returns false.
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @return {boolean} Contains coordinate.
* @api
*/
intersectsCoordinate(t) {
return this.containsXY(t[0], t[1]);
}
/**
* @abstract
* @param {import("../extent.js").Extent} extent Extent.
* @protected
* @return {import("../extent.js").Extent} extent Extent.
*/
computeExtent(t) {
return O();
}
/**
* Get the extent of the geometry.
* @param {import("../extent.js").Extent} [extent] Extent.
* @return {import("../extent.js").Extent} extent Extent.
* @api
*/
getExtent(t) {
if (this.extentRevision_ != this.getRevision()) {
const e = this.computeExtent(this.extent_);
(isNaN(e[0]) || isNaN(e[1])) && fe(e), this.extentRevision_ = this.getRevision();
}
return Ji(this.extent_, t);
}
/**
* Rotate the geometry around a given coordinate. This modifies the geometry
* coordinates in place.
* @abstract
* @param {number} angle Rotation angle in radians.
* @param {import("../coordinate.js").Coordinate} anchor The rotation center.
* @api
*/
rotate(t, e) {
O();
}
/**
* Scale the geometry (with an optional origin). This modifies the geometry
* coordinates in place.
* @abstract
* @param {number} sx The scaling factor in the x-direction.
* @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
* @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
* of the geometry extent).
* @api
*/
scale(t, e, n) {
O();
}
/**
* Create a simplified version of this geometry. For linestrings, this uses
* the [Douglas Peucker](https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm)
* algorithm. For polygons, a quantization-based
* simplification is used to preserve topology.
* @param {number} tolerance The tolerance distance for simplification.
* @return {Geometry} A new, simplified version of the original geometry.
* @api
*/
simplify(t) {
return this.getSimplifiedGeometry(t * t);
}
/**
* Create a simplified version of this geometry using the Douglas Peucker
* algorithm.
* See https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm.
* @abstract
* @param {number} squaredTolerance Squared tolerance.
* @return {Geometry} Simplified geometry.
*/
getSimplifiedGeometry(t) {
return O();
}
/**
* Get the type of this geometry.
* @abstract
* @return {Type} Geometry type.
*/
getType() {
return O();
}
/**
* Apply a transform function to the coordinates of the geometry.
* The geometry is modified in place.
* If you do not want the geometry modified in place, first `clone()` it and
* then use this function on the clone.
* @abstract
* @param {import("../proj.js").TransformFunction} transformFn Transform function.
* Called with a flat array of geometry coordinates.
*/
applyTransform(t) {
O();
}
/**
* Test if the geometry and the passed extent intersect.
* @abstract
* @param {import("../extent.js").Extent} extent Extent.
* @return {boolean} `true` if the geometry and the extent intersect.
*/
intersectsExtent(t) {
return O();
}
/**
* Translate the geometry. This modifies the geometry coordinates in place. If
* instead you want a new geometry, first `clone()` this geometry.
* @abstract
* @param {number} deltaX Delta X.
* @param {number} deltaY Delta Y.
* @api
*/
translate(t, e) {
O();
}
/**
* Transform each coordinate of the geometry from one coordinate reference
* system to another. The geometry is modified in place.
* For example, a line will be transformed to a line and a circle to a circle.
* If you do not want the geometry modified in place, first `clone()` it and
* then use this function on the clone.
*
* @param {import("../proj.js").ProjectionLike} source The current projection. Can be a
* string identifier or a {@link module:ol/proj/Projection~Projection} object.
* @param {import("../proj.js").ProjectionLike} destination The desired projection. Can be a
* string identifier or a {@link module:ol/proj/Projection~Projection} object.
* @return {this} This geometry. Note that original geometry is
* modified in place.
* @api
*/
transform(t, e) {
const n = Y(t), s = n.getUnits() == "tile-pixels" ? function(r, o, a) {
const l = n.getExtent(), c = n.getWorldExtent(), h = W(c) / W(l);
ue(
zn,
c[0],
c[3],
h,
-h,
0,
0,
0
);
const u = Yr(
r,
0,
r.length,
a,
zn,
o
), d = Kt(n, e);
return d ? d(u, u, a) : u;
} : Kt(n, e);
return this.applyTransform(s), this;
}
}
class an extends Vr {
constructor() {
super(), this.layout = "XY", this.stride = 2, this.flatCoordinates;
}
/**
* @param {import("../extent.js").Extent} extent Extent.
* @protected
* @return {import("../extent.js").Extent} extent Extent.
* @override
*/
computeExtent(t) {
return Vi(
this.flatCoordinates,
0,
this.flatCoordinates.length,
this.stride,
t
);
}
/**
* @abstract
* @return {Array<*> | null} Coordinates.
*/
getCoordinates() {
return O();
}
/**
* Return the first coordinate of the geometry.
* @return {import("../coordinate.js").Coordinate} First coordinate.
* @api
*/
getFirstCoordinate() {
return this.flatCoordinates.slice(0, this.stride);
}
/**
* @return {Array<number>} Flat coordinates.
*/
getFlatCoordinates() {
return this.flatCoordinates;
}
/**
* Return the last coordinate of the geometry.
* @return {import("../coordinate.js").Coordinate} Last point.
* @api
*/
getLastCoordinate() {
return this.flatCoordinates.slice(
this.flatCoordinates.length - this.stride
);
}
/**
* Return the {@link import("./Geometry.js").GeometryLayout layout} of the geometry.
* @return {import("./Geometry.js").GeometryLayout} Layout.
* @api
*/
getLayout() {
return this.layout;
}
/**
* Create a simplified version of this geometry using the Douglas Peucker algorithm.
* @param {number} squaredTolerance Squared tolerance.
* @return {SimpleGeometry} Simplified geometry.
* @override
*/
getSimplifiedGeometry(t) {
if (this.simplifiedGeometryRevision !== this.getRevision() && (this.simplifiedGeometryMaxMinSquaredTolerance = 0, this.simplifiedGeometryRevision = this.getRevision()), t < 0 || this.simplifiedGeometryMaxMinSquaredTolerance !== 0 && t <= this.simplifiedGeometryMaxMinSquaredTolerance)
return this;
const e = this.getSimplifiedGeometryInternal(t);
return e.getFlatCoordinates().length < this.flatCoordinates.length ? e : (this.simplifiedGeometryMaxMinSquaredTolerance = t, this);
}
/**
* @param {number} squaredTolerance Squared tolerance.
* @return {SimpleGeometry} Simplified geometry.
* @protected
*/
getSimplifiedGeometryInternal(t) {
return this;
}
/**
* @return {number} Stride.
*/
getStride() {
return this.stride;
}
/**
* @param {import("./Geometry.js").GeometryLayout} layout Layout.
* @param {Array<number>} flatCoordinates Flat coordinates.
*/
setFlatCoordinates(t, e) {
this.stride = Zn(t), this.layout = t, this.flatCoordinates = e;
}
/**
* @abstract
* @param {!Array<*>} coordinates Coordinates.
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
*/
setCoordinates(t, e) {
O();
}
/**
* @param {import("./Geometry.js").GeometryLayout|undefined} layout Layout.
* @param {Array<*>} coordinates Coordinates.
* @param {number} nesting Nesting.
* @protected
*/
setLayout(t, e, n) {
let s;
if (t)
s = Zn(t);
else {
for (let r = 0; r < n; ++r) {
if (e.length === 0) {
this.layout = "XY", this.stride = 2;
return;
}
e = /** @type {Array<unknown>} */
e[0];
}
s = e.length, t = Br(s);
}
this.layout = t, this.stride = s;
}
/**
* Apply a transform function to the coordinates of the geometry.
* The geometry is modified in place.
* If you do not want the geometry modified in place, first `clone()` it and
* then use this function on the clone.
* @param {import("../proj.js").TransformFunction} transformFn Transform function.
* Called with a flat array of geometry coordinates.
* @api
* @override
*/
applyTransform(t) {
this.flatCoordinates && (t(
this.flatCoordinates,
this.flatCoordinates,
this.layout.startsWith("XYZ") ? 3 : 2,
this.stride
), this.changed());
}
/**
* Rotate the geometry around a given coordinate. This modifies the geometry
* coordinates in place.
* @param {number} angle Rotation angle in counter-clockwise radians.
* @param {import("../coordinate.js").Coordinate} anchor The rotation center.
* @api
* @override
*/
rotate(t, e) {
const n = this.getFlatCoordinates();
if (n) {
const s = this.getStride();
Ur(
n,
0,
n.length,
s,
t,
e,
n
), this.changed();
}
}
/**
* Scale the geometry (with an optional origin). This modifies the geometry
* coordinates in place.
* @param {number} sx The scaling factor in the x-direction.
* @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
* @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
* of the geometry extent).
* @api
* @override
*/
scale(t, e, n) {
e === void 0 && (e = t), n || (n = Gt(this.getExtent()));
const s = this.getFlatCoordinates();
if (s) {
const r = this.getStride();
Kr(
s,
0,
s.length,
r,
t,
e,
n,
s
), this.changed();
}
}
/**
* Translate the geometry. This modifies the geometry coordinates in place. If
* instead you want a new geometry, first `clone()` this geometry.
* @param {number} deltaX Delta X.
* @param {number} deltaY Delta Y.
* @api
* @override
*/
translate(t, e) {
const n = this.getFlatCoordinates();
if (n) {
const s = this.getStride();
Wr(
n,
0,
n.length,
s,
t,
e,
n
), this.changed();
}
}
}
function Br(i) {
let t;
return i == 2 ? t = "XY" : i == 3 ? t = "XYZ" : i == 4 && (t = "XYZM"), /** @type {import("./Geometry.js").GeometryLayout} */
t;
}
function Zn(i) {
let t;
return i == "XY" ? t = 2 : i == "XYZ" || i == "XYM" ? t = 3 : i == "XYZM" && (t = 4), /** @type {number} */
t;
}
function $r(i, t, e, n) {
for (let s = 0, r = e.length; s < r; ++s)
i[t++] = e[s];
return t;
}
function Ti(i, t, e, n) {
for (let s = 0, r = e.length; s < r; ++s) {
const o = e[s];
for (let a = 0; a < n; ++a)
i[t++] = o[a];
}
return t;
}
function qr(i, t, e, n, s) {
s = s || [];
let r = 0;
for (let o = 0, a = e.length; o < a; ++o) {
const l = Ti(
i,
t,
e[o],
n
);
s[r++] = l, t = l;
}
return s.length = r, s;
}
class ln extends an {
/**
* @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
*/
constructor(t, e) {
super(), this.setCoordinates(t, e);
}
/**
* Make a complete copy of the geometry.
* @return {!Point} Clone.
* @api
* @override
*/
clone() {
const t = new ln(this.flatCoordinates.slice(), this.layout);
return t.applyProperties(this), t;
}
/**
* @param {number} x X.
* @param {number} y Y.
* @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
* @param {number} minSquaredDistance Minimum squared distance.
* @return {number} Minimum squared distance.
* @override
*/
closestPointXY(t, e, n, s) {
const r = this.flatCoordinates, o = Lt(
t,
e,
r[0],
r[1]
);
if (o < s) {
const a = this.stride;
for (let l = 0; l < a; ++l)
n[l] = r[l];
return n.length = a, o;
}
return s;
}
/**
* Return the coordinate of the point.
* @return {import("../coordinate.js").Coordinate} Coordinates.
* @api
* @override
*/
getCoordinates() {
return this.flatCoordinates.slice();
}
/**
* @param {import("../extent.js").Extent} extent Extent.
* @protected
* @return {import("../extent.js").Extent} extent Extent.
* @override
*/
computeExtent(t) {
return ki(this.flatCoordinates, t);
}
/**
* Get the type of this geometry.
* @return {import("./Geometry.js").Type} Geometry type.
* @api
* @override
*/
getType() {
return "Point";
}
/**
* Test if the geometry and the passed extent intersect.
* @param {import("../extent.js").Extent} extent Extent.
* @return {boolean} `true` if the geometry and the extent intersect.
* @api
* @override
*/
intersectsExtent(t) {
return Qn(t, this.flatCoordinates[0], this.flatCoordinates[1]);
}
/**
* @param {!Array<*>} coordinates Coordinates.
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
* @api
* @override
*/
setCoordinates(t, e) {
this.setLayout(e, t, 0), this.flatCoordinates || (this.flatCoordinates = []), this.flatCoordinates.length = $r(
this.flatCoordinates,
0,
t,
this.stride
), this.changed();
}
}
function Hr(i, t, e, n, s, r, o) {
let a, l, c, h, u, d, g;
const f = s[r + 1], _ = [];
for (let R = 0, T = e.length; R < T; ++R) {
const E = e[R];
for (h = i[E - n], d = i[E - n + 1], a = t; a < E; a += n)
u = i[a], g = i[a + 1], (f <= d && g <= f || d <= f && f <= g) && (c = (f - d) / (g - d) * (u - h) + h, _.push(c)), h = u, d = g;
}
let m = NaN, y = -1 / 0;
for (_.sort(Je), h = _[0], a = 1, l = _.length; a < l; ++a) {
u = _[a];
const R = Math.abs(u - h);
R > y && (c = (h + u) / 2, ui(i, t, e, n, c, f) && (m = c, y = R)), h = u;
}
return isNaN(m) && (m = s[r]), [m, f, y];
}
function Qr(i, t, e, n) {
for (; t < e - n; ) {
for (let s = 0; s < n; ++s) {
const r = i[t + s];
i[t + s] = i[e - n + s], i[e - n + s] = r;
}
t += n, e -= n;
}
}
function xi(i, t, e, n) {
let s = 0, r = i[e - n], o = i[e - n + 1];
for (; t < e; t += n) {
const a = i[t], l = i[t + 1];
s += (a - r) * (l + o), r = a, o = l;
}
return s === 0 ? void 0 : s > 0;
}
function Jr(i, t, e, n, s) {
s = s !== void 0 ? s : !1;
for (let r = 0, o = e.length; r < o; ++r) {
const a = e[r], l = xi(
i,
t,
a,
n
);
if (r === 0) {
if (s && l || !s && !l)
return !1;
} else if (s && !l || !s && l)
return !1;
t = a;
}
return !0;
}
function jn(i, t, e, n, s) {
s = s !== void 0 ? s : !1;
for (let r = 0, o = e.length; r < o; ++r) {
const a = e[r], l = xi(
i,
t,
a,
n
);
(r === 0 ? s && l || !s && !l : s && !l || !s && l) && Qr(i, t, a, n), t = a;
}
return t;
}
function to(i, t, e, n, s, r, o) {
const a = (e - t) / n;
if (a < 3) {
for (; t < e; t += n)
r[o++] = i[t], r[o++] = i[t + 1];
return o;
}
const l = new Array(a);
l[0] = 1, l[a - 1] = 1;
const c = [t, e - n];
let h = 0;
for (; c.length > 0; ) {
const u = c.pop(), d = c.pop();
let g = 0;
const f = i[d], _ = i[d + 1], m = i[u], y = i[u + 1];
for (let R = d + n; R < u; R += n) {
const T = i[R], E = i[R + 1], p = os(T, E, f, _, m, y);
p > g && (h = R, g = p);
}
g > s && (l[(h - t) / n] = 1, d + n < h && c.push(d, h), h + n < u && c.push(h, u));
}
for (let u = 0; u < a; ++u)
l[u] && (r[o++] = i[t + u * n], r[o++] = i[t + u * n + 1]);
return o;
}
function Pt(i, t) {
return t * Math.round(i / t);
}
function eo(i, t, e, n, s, r, o) {
if (t == e)
return o;
let a = Pt(i[t], s), l = Pt(i[t + 1], s);
t += n, r[o++] = a, r[o++] = l;
let c, h;
do
if (c = Pt(i[t], s), h = Pt(i[t + 1], s), t += n, t == e)
return r[o++] = c, r[o++] = h, o;
while (c == a && h == l);
for (; t < e; ) {
const u = Pt(i[t], s), d = Pt(i[t + 1], s);
if (t += n, u == c && d == h)
continue;
const g = c - a, f = h - l, _ = u - a, m = d - l;
if (g * m == f * _ && (g < 0 && _ < g || g == _ || g > 0 && _ > g) && (f < 0 && m < f || f == m || f > 0 && m > f)) {
c = u, h = d;
continue;
}
r[o++] = c, r[o++] = h, a = c, l = h, c = u, h = d;
}
return r[o++] = c, r[o++] = h, o;
}
function no(i, t, e, n, s, r, o, a) {
for (let l = 0, c = e.length; l < c; ++l) {
const h = e[l];
o = eo(
i,
t,
h,
n,
s,
r,
o
), a.push(o), t = h;
}
return o;
}
function Ci(i, t, e, n) {
let s = 0;
const r = i[e - n], o = i[e - n + 1];
let a = 0, l = 0;
for (; t < e; t += n) {
const c = i[t] - r, h = i[t + 1] - o;
s += l * c - a * h, a = c, l = h;
}
return s / 2;
}
function io(i, t, e, n) {
let s = 0;
for (let r = 0, o = e.length; r < o; ++r) {
const a = e[r];
s += Ci(i, t, a, n), t = a;
}
return s;
}
function Yn(i, t, e, n, s, r, o) {
const a = i[t], l = i[t + 1], c = i[e] - a, h = i[e + 1] - l;
let u;
if (c === 0 && h === 0)
u = t;
else {
const d = ((s - a) * c + (r - l) * h) / (c * c + h * h);
if (d > 1)
u = e;
else if (d > 0) {
for (let g = 0; g < n; ++g)
o[g] = ls(
i[t + g],
i[e + g],
d
);
o.length = n;
return;
} else
u = t;
}
for (let d = 0; d < n; ++d)
o[d] = i[u + d];
o.length = n;
}
function Mi(i, t, e, n, s) {
let r = i[t], o = i[t + 1];
for (t += n; t < e; t += n) {
const a = i[t], l = i[t + 1], c = Lt(r, o, a, l);
c > s && (s = c), r = a, o = l;
}
return s;
}
function so(i, t, e, n, s) {
for (let r = 0, o = e.length; r < o; ++r) {
const a = e[r];
s = Mi(i, t, a, n, s), t = a;
}
return s;
}
function Ii(i, t, e, n, s, r, o, a, l, c, h) {
if (t == e)
return c;
let u, d;
if (s === 0) {
if (d = Lt(
o,
a,
i[t],
i[t + 1]
), d < c) {
for (u = 0; u < n; ++u)
l[u] = i[t + u];
return l.length = n, d;
}
return c;
}
h = h || [NaN, NaN];
let g = t + n;
for (; g < e; )
if (Yn(
i,
g - n,
g,
n,
o,
a,
h
), d = Lt(o, a, h[0], h[1]), d < c) {
for (c = d, u = 0; u < n; ++u)
l[u] = h[u];
l.length = n, g += n;
} else
g += n * Math.max(
(Math.sqrt(d) - Math.sqrt(c)) / s | 0,
1
);
if (Yn(
i,
e - n,
t,
n,
o,
a,
h
), d = Lt(o, a, h[0], h[1]), d < c) {
for (c = d, u = 0; u < n; ++u)
l[u] = h[u];
l.length = n;
}
return c;
}
function ro(i, t, e, n, s, r, o, a, l, c, h) {
h = h || [NaN, NaN];
for (let u = 0, d = e.length; u < d; ++u) {
const g = e[u];
c = Ii(
i,
t,
g,
n,
s,
r,
o,
a,
l,
c,
h
), t = g;
}
return c;
}
function wi(i, t, e, n, s) {
s = s !== void 0 ? s : [];
let r = 0;
for (let o = t; o < e; o += n)
s[r++] = i.slice(o, o + n);
return s.length = r, s;
}
function oo(i, t, e, n, s) {
s = s !== void 0 ? s : [];
let r = 0;
for (let o = 0, a = e.length; o < a; ++o) {
const l = e[o];
s[r++] = wi(
i,
t,
l,
n,
s[r]
), t = l;
}
return s.length = r, s;
}
class Wt extends an {
/**
* @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
* For internal use, flat coordinates in combination with `layout` are also accepted.
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
*/
constructor(t, e) {
super(), this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, e !== void 0 && !Array.isArray(t[0]) ? this.setFlatCoordinates(
e,
/** @type {Array<number>} */
t
) : this.setCoordinates(
/** @type {Array<import("../coordinate.js").Coordinate>} */
t,
e
);
}
/**
* Make a complete copy of the geometry.
* @return {!LinearRing} Clone.
* @api
* @override
*/
clone() {
return new Wt(this.flatCoordinates.slice(), this.layout);
}
/**
* @param {number} x X.
* @param {number} y Y.
* @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
* @param {number} minSquaredDistance Minimum squared distance.
* @return {number} Minimum squared distance.
* @override
*/
closestPointXY(t, e, n, s) {
return s < Hn(this.getExtent(), t, e) ? s : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt(
Mi(
this.flatCoordinates,
0,
this.flatCoordinates.length,
this.stride,
0
)
), this.maxDeltaRevision_ = this.getRevision()), Ii(
this.flatCoordinates,
0,
this.flatCoordinates.length,
this.stride,
this.maxDelta_,
!0,
t,
e,
n,
s
));
}
/**
* Return the area of the linear ring on projected plane.
* @return {number} Area (on projected plane).
* @api
*/
getArea() {
return Ci(
this.flatCoordinates,
0,
this.flatCoordinates.length,
this.stride
);
}
/**
* Return the coordinates of the linear ring.
* @return {Array<import("../coordinate.js").Coordinate>} Coordinates.
* @api
* @override
*/
getCoordinates() {
return wi(
this.flatCoordinates,
0,
this.flatCoordinates.length,
this.stride
);
}
/**
* @param {number} squaredTolerance Squared tolerance.
* @return {LinearRing} Simplified LinearRing.
* @protected
* @override
*/
getSimplifiedGeometryInternal(t) {
const e = [];
return e.length = to(
this.flatCoordinates,
0,
this.flatCoordinates.length,
this.stride,
t,
e,
0
), new Wt(e, "XY");
}
/**
* Get the type of this geometry.
* @return {import("./Geometry.js").Type} Geometry type.
* @api
* @override
*/
getType() {
return "LinearRing";
}
/**
* Test if the geometry and the passed extent intersect.
* @param {import("../extent.js").Extent} extent Extent.
* @return {boolean} `true` if the geometry and the extent intersect.
* @api
* @override
*/
intersectsExtent(t) {
return !1;
}
/**
* Set the coordinates of the linear ring.
* @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
* @api
* @override
*/
setCoordinates(t, e) {
this.setLayout(e, t, 1), this.flatCoordinates || (this.flatCoordinates = []), this.flatCoordinates.length = Ti(
this.flatCoordinates,
0,
t,
this.stride
), this.changed();
}
}
class de extends an {
/**
* @param {!Array<Array<import("../coordinate.js").Coordinate>>|!Array<number>} coordinates
* Array of linear rings that define the polygon. The first linear ring of the
* array defines the outer-boundary or surface of the polygon. Each subsequent
* linear ring defines a hole in the surface of the polygon. A linear ring is
* an array of vertices' coordinates where the first coordinate and the last are
* equivalent. (For internal use, flat coordinates in combination with
* `layout` and `ends` are also accepted.)
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
* @param {Array<number>} [ends] Ends (for internal use with flat coordinates).
*/
constructor(t, e, n) {
super(), this.ends_ = [], this.flatInteriorPointRevision_ = -1, this.flatInteriorPoint_ = null, this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, this.orientedRevision_ = -1, this.orientedFlatCoordinates_ = null, e !== void 0 && n ? (this.setFlatCoordinates(
e,
/** @type {Array<number>} */
t
), this.ends_ = n) : this.setCoordinates(
/** @type {Array<Array<import("../coordinate.js").Coordinate>>} */
t,
e
);
}
/**
* Append the passed linear ring to this polygon.
* @param {LinearRing} linearRing Linear ring.
* @api
*/
appendLinearRing(t) {
this.flatCoordinates ? $s(this.flatCoordinates, t.getFlatCoordinates()) : this.flatCoordinates = t.getFlatCoordinates().slice(), this.ends_.push(this.flatCoordinates.length), this.changed();
}
/**
* Make a complete copy of the geometry.
* @return {!Polygon} Clone.
* @api
* @override
*/
clone() {
const t = new de(
this.flatCoordinates.slice(),
this.layout,
this.ends_.slice()
);
return t.applyProperties(this), t;
}
/**
* @param {number} x X.
* @param {number} y Y.
* @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
* @param {number} minSquaredDistance Minimum squared distance.
* @return {number} Minimum squared distance.
* @override
*/
closestPointXY(t, e, n, s) {
return s < Hn(this.getExtent(), t, e) ? s : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt(
so(
this.flatCoordinates,
0,
this.ends_,
this.stride,
0
)
), this.maxDeltaRevision_ = this.getRevision()), ro(
this.flatCoordinates,
0,
this.ends_,
this.stride,
this.maxDelta_,
!0,
t,
e,
n,
s
));
}
/**
* @param {number} x X.
* @param {number} y Y.
* @return {boolean} Contains (x, y).
* @override
*/
containsXY(t, e) {
return ui(
this.getOrientedFlatCoordinates(),
0,
this.ends_,
this.stride,
t,
e
);
}
/**
* Return the area of the polygon on projected plane.
* @return {number} Area (on projected plane).
* @api
*/
getArea() {
return io(
this.getOrientedFlatCoordinates(),
0,
this.ends_,
this.stride
);
}
/**
* Get the coordinate array for this geometry. This array has the structure
* of a GeoJSON coordinate array for polygons.
*
* @param {boolean} [right] Orient coordinates according to the right-hand
* rule (counter-clockwise for exterior and clockwise for interior rings).
* If `false`, coordinates will be oriented according to the left-hand rule
* (clockwise for exterior and counter-clockwise for interior rings).
* By default, coordinate orientation will depend on how the geometry was
* constructed.
* @return {Array<Array<import("../coordinate.js").Coordinate>>} Coordinates.
* @api
* @override
*/
getCoordinates(t) {
let e;
return t !== void 0 ? (e = this.getOrientedFlatCoordinates().slice(), jn(e, 0, this.ends_, this.stride, t)) : e = this.flatCoordinates, oo(e, 0, this.ends_, this.stride);
}
/**
* @return {Array<number>} Ends.
*/
getEnds() {
return this.ends_;
}
/**
* @return {Array<number>} Interior point.
*/
getFlatInteriorPoint() {
if (this.flatInteriorPointRevision_ != this.getRevision()) {
const t = Gt(this.getExtent());
this.flatInteriorPoint_ = Hr(
this.getOrientedFlatCoordinates(),
0,
this.ends_,
this.stride,
t,
0
), this.flatInteriorPointRevision_ = this.getRevision();
}
return (
/** @type {import("../coordinate.js").Coordinate} */
this.flatInteriorPoint_
);
}
/**
* Return an interior point of the polygon.
* @return {Point} Interior point as XYM coordinate, where M is the
* length of the horizontal intersection that the point belongs to.
* @api
*/
getInteriorPoint() {
return new ln(this.getFlatInteriorPoint(), "XYM");
}
/**
* Return the number of rings of the polygon, this includes the exterior
* ring and any interior rings.
*
* @return {number} Number of rings.
* @api
*/
getLinearRingCount() {
return this.ends_.length;
}
/**
* Return the Nth linear ring of the polygon geometry. Return `null` if the
* given index is out of range.
* The exterior linear ring is available at index `0` and the interior rings
* at index `1` and beyond.
*
* @param {number} index Index.
* @return {LinearRing|null} Linear ring.
* @api
*/
getLinearRing(t) {
return t < 0 || this.ends_.length <= t ? null : new Wt(
this.flatCoordinates.slice(
t === 0 ? 0 : this.ends_[t - 1],
this.ends_[t]
),
this.layout
);
}
/**
* Return the linear rings of the polygon.
* @return {Array<LinearRing>} Linear rings.
* @api
*/
getLinearRings() {
const t = this.layout, e = this.flatCoordinates, n = this.ends_, s = [];
let r = 0;
for (let o = 0, a = n.length; o < a; ++o) {
const l = n[o], c = new Wt(
e.slice(r, l),
t
);
s.push(c), r = l;
}
return s;
}
/**
* @return {Array<number>} Oriented flat coordinates.
*/
getOrientedFlatCoordinates() {
if (this.orientedRevision_ != this.getRevision()) {
const t = this.flatCoordinates;
Jr(t, 0, this.ends_, this.stride) ? this.orientedFlatCoordinates_ = t : (this.orientedFlatCoordinates_ = t.slice(), this.orientedFlatCoordinates_.length = jn(
this.orientedFlatCoordinates_,
0,
this.ends_,
this.stride
)), this.orientedRevision_ = this.getRevision();
}
return (
/** @type {Array<number>} */
this.orientedFlatCoordinates_
);
}
/**
* @param {number} squaredTolerance Squared tolerance.
* @return {Polygon} Simplified Polygon.
* @protected
* @override
*/
getSimplifiedGeometryInternal(t) {
const e = [], n = [];
return e.length = no(
this.flatCoordinates,
0,
this.ends_,
this.stride,
Math.sqrt(t),
e,
0,
n
), new de(e, "XY", n);
}
/**
* Get the type of this geometry.
* @return {import("./Geometry.js").Type} Geometry type.
* @api
* @override
*/
getType() {
return "Polygon";
}
/**
* Test if the geometry and the passed extent intersect.
* @param {import("../extent.js").Extent} extent Extent.
* @return {boolean} `true` if the geometry and the extent intersect.
* @api
* @override
*/
intersectsExtent(t) {
return Js(
this.getOrientedFlatCoordinates(),
0,
this.ends_,
this.stride,
t
);
}
/**
* Set the coordinates of the polygon.
* @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates.
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
* @api
* @override
*/
setCoordinates(t, e) {
this.setLayout(e, t, 2), this.flatCoordinates || (this.flatCoordinates = []);
const n = qr(
this.flatCoordinates,
0,
t,
this.stride,
this.ends_
);
this.flatCoordinates.length = n.length === 0 ? 0 : n[n.length - 1], this.changed();
}
}
function Un(i) {
if (Re(i))
throw new Error("Cannot create polygon from empty extent");
const t = i[0], e = i[1], n = i[2], s = i[3], r = [
t,
e,
t,
s,
n,
s,
n,
e,
t,
e
];
return new de(r, "XY", [r.length]);
}
function Ye(i) {
return i instanceof Image || i instanceof HTMLCanvasElement || i instanceof HTMLVideoElement || i instanceof ImageBitmap ? i : null;
}
const ao = new Error("disposed"), lo = [256, 256];
class Kn extends sn {
/**
* @param {Options} options Tile options.
*/
constructor(t) {
const e = x.IDLE;
super(t.tileCoord, e, {
transition: t.transition,
interpolate: t.interpolate
}), this.loader_ = t.loader, this.data_ = null, this.error_ = null, this.size_ = t.size || null, this.controller_ = t.controller || null;
}
/**
* Get the tile size.
* @return {import('./size.js').Size} Tile size.
*/
getSize() {
if (this.size_)
return this.size_;
const t = Ye(this.data_);
return t ? [t.width, t.height] : lo;
}
/**
* Get the data for the tile.
* @return {Data} Tile data.
* @api
*/
getData() {
return this.data_;
}
/**
* Get any loading error.
* @return {Error} Loading error.
* @api
*/
getError() {
return this.error_;
}
/**
* Load the tile data.
* @api
* @override
*/
load() {
if (this.state !== x.IDLE && this.state !== x.ERROR)
return;
this.state = x.LOADING, this.changed();
const t = this;
this.loader_().then(function(e) {
t.data_ = e, t.state = x.LOADED, t.changed();
}).catch(function(e) {
t.error_ = e, t.state = x.ERROR, t.changed();
});
}
/**
* Clean up.
* @override
*/
disposeInternal() {
this.controller_ && (this.controller_.abort(ao), this.controller_ = null), super.disposeInternal();
}
}
const ht = {
ANIMATING: 0,
INTERACTING: 1
}, co = [NaN, NaN, NaN, 0];
let Ae;
function ho() {
return Ae || (Ae = gt(1, 1, void 0, {
willReadFrequently: !0,
desynchronized: !0
})), Ae;
}
const uo = /^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i, fo = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i, go = /^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i, _o = /^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;
function ee(i, t) {
return i.endsWith("%") ? Number(i.substring(0, i.length - 1)) / t : Number(i);
}
function Yt(i) {
throw new Error('failed to parse "' + i + '" as color');
}
function Si(i) {
if (i.toLowerCase().startsWith("rgb")) {
const r = i.match(fo) || i.match(uo) || i.match(go);
if (r) {
const o = r[4], a = 100 / 255;
return [
z(ee(r[1], a) + 0.5 | 0, 0, 255),
z(ee(r[2], a) + 0.5 | 0, 0, 255),
z(ee(r[3], a) + 0.5 | 0, 0, 255),
o !== void 0 ? z(ee(o, 100), 0, 1) : 1
];
}
Yt(i);
}
if (i.startsWith("#")) {
if (_o.test(i)) {
const r = i.substring(1), o = r.length <= 4 ? 1 : 2, a = [0, 0, 0, 255];
for (let l = 0, c = r.length; l < c; l += o) {
let h = parseInt(r.substring(l, l + o), 16);
o === 1 && (h += h << 4), a[l / o] = h;
}
return a[3] = a[3] / 255, a;
}
Yt(i);
}
const t = ho();
t.fillStyle = "#abcdef";
let e = t.fillStyle;
t.fillStyle = i, t.fillStyle === e && (t.fillStyle = "#fedcba", e = t.fillStyle, t.fillStyle = i, t.fillStyle === e && Yt(i));
const n = t.fillStyle;
if (n.startsWith("#") || n.startsWith("rgba"))
return Si(n);
t.clearRect(0, 0, 1, 1), t.fillRect(0, 0, 1, 1);
const s = Array.from(t.getImageData(0, 0, 1, 1).data);
return s[3] = Ke(s[3] / 255, 3), s;
}
const mo = 1024, Zt = {};
let Fe = 0;
function Ro(i) {
if (i === "none")
return co;
if (Zt.hasOwnProperty(i))
return Zt[i];
if (Fe >= mo) {
let e = 0;
for (const n in Zt)
(e++ & 3) === 0 && (delete Zt[n], --Fe);
}
const t = Si(i);
t.length !== 4 && Yt(i);
for (const e of t)
isNaN(e) && Yt(i);
return Zt[i] = t, ++Fe, t;
}
function Wn(i) {
return Array.isArray(i) ? i : Ro(i);
}
class po extends Ee {
/**
* @param {import("./EventType.js").default} type Type.
* @param {import("../transform.js").Transform} [inversePixelTransform] Transform for
* CSS pixels to rendered pixels.
* @param {import("../Map.js").FrameState} [frameState] Frame state.
* @param {?(CanvasRenderingContext2D|WebGLRenderingContext)} [context] Context.
*/
constructor(t, e, n, s) {
super(t), this.inversePixelTransform = e, this.frameState = n, this.context = s;
}
}
const jt = {
/**
* Triggered before a layer is rendered.
* @event module:ol/render/Event~RenderEvent#prerender
* @api
*/
PRERENDER: "prerender",
/**
* Triggered after a layer is rendered.
* @event module:ol/render/Event~RenderEvent#postrender
* @api
*/
POSTRENDER: "postrender",
/**
* Triggered before layers are composed. When dispatched by the map, the event object will not have
* a `context` set. When dispatched by a layer, the event object will have a `context` set. Only
* WebGL layers currently dispatch this event.
* @event module:ol/render/Event~RenderEvent#precompose
* @api
*/
PRECOMPOSE: "precompose"
};
class yo {
constructor() {
/**
* @private
* @param {...*} args Args.
* @return {ZIndexContext} This.
*/
gn(this, "pushMethodArgs_", (...t) => (this.push_(t), this));
this.instructions_ = [], this.zIndex = 0, this.offset_ = 0, this.context_ = /** @type {ZIndexContextProxy} */
new Proxy(On(), {
get: (t, e) => {
if (typeof /** @type {*} */
On()[e] == "function")
return this.push_(e), this.pushMethodArgs_;
},
set: (t, e, n) => (this.push_(e, n), !0)
});
}
/**
* @param {...*} args Arguments to push to the instructions array.
* @private
*/
push_(...t) {
const e = this.instructions_, n = this.zIndex + this.offset_;
e[n] || (e[n] = []), e[n].push(...t);
}
/**
* Push a function that renders to the context directly.
* @param {function(CanvasRenderingContext2D): void} render Function.
*/
pushFunction(t) {
this.push_(t);
}
/**
* Get a proxy for CanvasRenderingContext2D which does not support getting state
* (e.g. `context.globalAlpha`, which will return `undefined`). To set state, if it relies on a
* previous state (e.g. `context.globalAlpha = context.globalAlpha / 2`), set a function,
* e.g. `context.globalAlpha = (context) => context.globalAlpha / 2`.
* @return {ZIndexContextProxy} Context.
*/
getContext() {
return this.context_;
}
/**
* @param {CanvasRenderingContext2D} context Context.
*/
draw(t) {
this.instructions_.forEach((e) => {
for (let n = 0, s = e.length; n < s; ++n) {
const r = e[n];
if (typeof r == "function") {
r(t);
continue;
}
const o = e[++n];
if (typeof /** @type {*} */
t[r] == "function")
t[r](...o);
else {
if (typeof o == "function") {
t[r] = o(t);
continue;
}
t[r] = o;
}
}
});
}
clear() {
this.instructions_.length = 0, this.zIndex = 0, this.offset_ = 0;
}
/**
* Offsets the zIndex by the highest current zIndex. Useful for rendering multiple worlds or tiles, to
* avoid conflicting context.clip() or context.save()/restore() calls.
*/
offset() {
this.offset_ = this.instructions_.length, this.zIndex = 0;
}
}
const Eo = 5;
class To extends Bt {
/**
* @param {LayerType} layer Layer.
*/
constructor(t) {
super(), this.ready = !0, this.boundHandleImageChange_ = this.handleImageChange_.bind(this), this.layer_ = t, this.staleKeys_ = new Array(), this.maxStaleKeys = Eo;
}
/**
* @return {Array<string>} Get the list of stale keys.
*/
getStaleKeys() {
return this.staleKeys_;
}
/**
* @param {string} key The new stale key.
*/
prependStaleKey(t) {
this.staleKeys_.unshift(t), this.staleKeys_.length > this.maxStaleKeys && (this.staleKeys_.length = this.maxStaleKeys);
}
/**
* Asynchronous layer level hit detection.
* @param {import("../pixel.js").Pixel} pixel Pixel.
* @return {Promise<Array<import("../Feature").FeatureLike>>} Promise that resolves with
* an array of features.
*/
getFeatures(t) {
return O();
}
/**
* @param {import("../pixel.js").Pixel} pixel Pixel.
* @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data.
*/
getData(t) {
return null;
}
/**
* Determine whether render should be called.
* @abstract
* @param {import("../Map.js").FrameState} frameState Frame state.
* @return {boolean} Layer is ready to be rendered.
*/
prepareFrame(t) {
return O();
}
/**
* Render the layer.
* @abstract
* @param {import("../Map.js").FrameState} frameState Frame state.
* @param {HTMLElement|null} target Target that may be used to render content to.
* @return {HTMLElement} The rendered element.
*/
renderFrame(t, e) {
return O();
}
/**
* @abstract
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @param {import("../Map.js").FrameState} frameState Frame state.
* @param {number} hitTolerance Hit tolerance in pixels.
* @param {import("./vector.js").FeatureCallback<T>} callback Feature callback.
* @param {Array<import("./Map.js").HitMatch<T>>} matches The hit detected matches with tolerance.
* @return {T|undefined} Callback result.
* @template T
*/
forEachFeatureAtCoordinate(t, e, n, s, r) {
}
/**
* @return {LayerType} Layer.
*/
getLayer() {
return this.layer_;
}
/**
* Perform action necessary to get the layer rendered after new fonts have loaded
* @abstract
*/
handleFontsChanged() {
}
/**
* Handle changes in image state.
* @param {import("../events/Event.js").default} event Image change event.
* @private
*/
handleImageChange_(t) {
const e = (
/** @type {import("../Image.js").default} */
t.target
);
(e.getState() === vt.LOADED || e.getState() === vt.ERROR) && this.renderIfReadyAndVisible();
}
/**
* Load the image if not already loaded, and register the image change
* listener if needed.
* @param {import("../Image.js").default} image Image.
* @return {boolean} `true` if the image is already loaded, `false` otherwise.
* @protected
*/
loadImage(t) {
let e = t.getState();
return e != vt.LOADED && e != vt.ERROR && t.addEventListener(nt.CHANGE, this.boundHandleImageChange_), e == vt.IDLE && (t.load(), e = t.getState()), e == vt.LOADED;
}
/**
* @protected
*/
renderIfReadyAndVisible() {
const t = this.getLayer();
t && t.getVisible() && t.getSourceState() === "ready" && t.changed();
}
/**
* @param {import("../Map.js").FrameState} frameState Frame state.
*/
renderDeferred(t) {
}
/**
* Clean up.
* @override
*/
disposeInternal() {
delete this.layer_, super.disposeInternal();
}
}
let At = null;
function xo() {
At = gt(1, 1, void 0, {
willReadFrequently: !0
});
}
class Co extends To {
/**
* @param {LayerType} layer Layer.
*/
constructor(t) {
super(t), this.container = null, this.renderedResolution, this.tempTransform = re(), this.pixelTransform = re(), this.inversePixelTransform = re(), this.context = null, this.deferredContext_ = null, this.containerReused = !1, this.frameState = null;
}
/**
* @param {import('../../DataTile.js').ImageLike} image Image.
* @param {number} col The column index.
* @param {number} row The row index.
* @return {Uint8ClampedArray|null} The image data.
*/
getImageData(t, e, n) {
At || xo(), At.clearRect(0, 0, 1, 1);
let s;
try {
At.drawImage(t, e, n, 1, 1, 0, 0, 1, 1), s = At.getImageData(0, 0, 1, 1).data;
} catch {
return At = null, null;
}
return s;
}
/**
* @param {import('../../Map.js').FrameState} frameState Frame state.
* @return {string} Background color.
*/
getBackground(t) {
let n = this.getLayer().getBackground();
return typeof n == "function" && (n = n(t.viewState.resolution)), n || void 0;
}
/**
* Get a rendering container from an existing target, if compatible.
* @param {HTMLElement} target Potential render target.
* @param {string} transform CSS transform matrix.
* @param {string} [backgroundColor] Background color.
*/
useContainer(t, e, n) {
const s = this.getLayer().getClassName();
let r, o;
if (t && t.className === s && (!n || t && t.style.backgroundColor && hi(
Wn(t.style.backgroundColor),
Wn(n)
))) {
const a = t.firstElementChild;
a instanceof HTMLCanvasElement && (o = a.getContext("2d"));
}
if (o && Ar(o.canvas.style.transform, e) ? (this.container = t, this.context = o, this.containerReused = !0) : this.containerReused ? (this.container = null, this.context = null, this.containerReused = !1) : this.container && (this.container.style.backgroundColor = null), !this.container) {
r = document.createElement("div"), r.className = s;
let a = r.style;
a.position = "absolute", a.width = "100%", a.height = "100%", o = gt();
const l = o.canvas;
r.appendChild(l), a = l.style, a.position = "absolute", a.left = "0", a.transformOrigin = "top left", this.container = r, this.context = o;
}
!this.containerReused && n && !this.container.style.backgroundColor && (this.container.style.backgroundColor = n);
}
/**
* @param {CanvasRenderingContext2D} context Context.
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @param {import("../../extent.js").Extent} extent Clip extent.
* @protected
*/
clipUnrotated(t, e, n) {
const s = Mt(n), r = me(n), o = _e(n), a = ge(n);
B(e.coordinateToPixelTransform, s), B(e.coordinateToPixelTransform, r), B(e.coordinateToPixelTransform, o), B(e.coordinateToPixelTransform, a);
const l = this.inversePixelTransform;
B(l, s), B(l, r), B(l, o), B(l, a), t.save(), t.beginPath(), t.moveTo(Math.round(s[0]), Math.round(s[1])), t.lineTo(Math.round(r[0]), Math.round(r[1])), t.lineTo(Math.round(o[0]), Math.round(o[1])), t.lineTo(Math.round(a[0]), Math.round(a[1])), t.clip();
}
/**
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @param {HTMLElement} target Target that may be used to render content to.
* @protected
*/
prepareContainer(t, e) {
const n = t.extent, s = t.viewState.resolution, r = t.viewState.rotation, o = t.pixelRatio, a = Math.round(v(n) / s * o), l = Math.round(W(n) / s * o);
ue(
this.pixelTransform,
t.size[0] / 2,
t.size[1] / 2,
1 / o,
1 / o,
r,
-a / 2,
-l / 2
), wr(this.inversePixelTransform, this.pixelTransform);
const c = Pr(this.pixelTransform);
if (this.useContainer(e, c, this.getBackground(t)), !this.containerReused) {
const h = this.context.canvas;
h.width != a || h.height != l ? (h.width = a, h.height = l) : this.context.clearRect(0, 0, a, l), c !== h.style.transform && (h.style.transform = c);
}
}
/**
* @param {import("../../render/EventType.js").default} type Event type.
* @param {CanvasRenderingContext2D} context Context.
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @private
*/
dispatchRenderEvent_(t, e, n) {
const s = this.getLayer();
if (s.hasListener(t)) {
const r = new po(
t,
this.inversePixelTransform,
n,
e
);
s.dispatchEvent(r);
}
}
/**
* @param {CanvasRenderingContext2D} context Context.
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @protected
*/
preRender(t, e) {
this.frameState = e, !e.declutter && this.dispatchRenderEvent_(jt.PRERENDER, t, e);
}
/**
* @param {CanvasRenderingContext2D} context Context.
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @protected
*/
postRender(t, e) {
e.declutter || this.dispatchRenderEvent_(jt.POSTRENDER, t, e);
}
/**
* @param {import("../../Map.js").FrameState} frameState Frame state.
*/
renderDeferredInternal(t) {
}
/**
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @return {import('../../render/canvas/ZIndexContext.js').ZIndexContextProxy} Context.
*/
getRenderContext(t) {
return t.declutter && !this.deferredContext_ && (this.deferredContext_ = new yo()), t.declutter ? this.deferredContext_.getContext() : this.context;
}
/**
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @override
*/
renderDeferred(t) {
t.declutter && (this.dispatchRenderEvent_(
jt.PRERENDER,
this.context,
t
), t.declutter && this.deferredContext_ && (this.deferredContext_.draw(this.context), this.deferredContext_.clear()), this.renderDeferredInternal(t), this.dispatchRenderEvent_(
jt.POSTRENDER,
this.context,
t
));
}
/**
* Creates a transform for rendering to an element that will be rotated after rendering.
* @param {import("../../coordinate.js").Coordinate} center Center.
* @param {number} resolution Resolution.
* @param {number} rotation Rotation.
* @param {number} pixelRatio Pixel ratio.
* @param {number} width Width of the rendered element (in pixels).
* @param {number} height Height of the rendered element (in pixels).
* @param {number} offsetX Offset on the x-axis in view coordinates.
* @protected
* @return {!import("../../transform.js").Transform} Transform.
*/
getRenderTransform(t, e, n, s, r, o, a) {
const l = r / 2, c = o / 2, h = s / e, u = -h, d = -t[0] + a, g = -t[1];
return ue(
this.tempTransform,
l,
c,
h,
u,
-n,
d,
g
);
}
/**
* Clean up.
* @override
*/
disposeInternal() {
delete this.frameState, super.disposeInternal();
}
}
const V = {
CENTER: "center",
RESOLUTION: "resolution",
ROTATION: "rotation"
};
function kn(i, t, e) {
return (
/**
* @param {import("./coordinate.js").Coordinate|undefined} center Center.
* @param {number|undefined} resolution Resolution.
* @param {import("./size.js").Size} size Viewport size; unused if `onlyCenter` was specified.
* @param {boolean} [isMoving] True if an interaction or animation is in progress.
* @param {Array<number>} [centerShift] Shift between map center and viewport center.
* @return {import("./coordinate.js").Coordinate|undefined} Center.
*/
function(n, s, r, o, a) {
if (!n)
return;
if (!s && !t)
return n;
const l = t ? 0 : r[0] * s, c = t ? 0 : r[1] * s, h = a ? a[0] : 0, u = a ? a[1] : 0;
let d = i[0] + l / 2 + h, g = i[2] - l / 2 + h, f = i[1] + c / 2 + u, _ = i[3] - c / 2 + u;
d > g && (d = (g + d) / 2, g = d), f > _ && (f = (_ + f) / 2, _ = f);
let m = z(n[0], d, g), y = z(n[1], f, _);
if (o && e && s) {
const R = 30 * s;
m += -R * Math.log(1 + Math.max(0, d - n[0]) / R) + R * Math.log(1 + Math.max(0, n[0] - g) / R), y += -R * Math.log(1 + Math.max(0, f - n[1]) / R) + R * Math.log(1 + Math.max(0, n[1] - _) / R);
}
return [m, y];
}
);
}
function Mo(i) {
return i;
}
function cn(i, t, e, n) {
const s = v(t) / e[0], r = W(t) / e[1];
return n ? Math.min(i, Math.max(s, r)) : Math.min(i, Math.min(s, r));
}
function hn(i, t, e) {
let n = Math.min(i, t);
const s = 50;
return n *= Math.log(1 + s * Math.max(0, i / t - 1)) / s + 1, e && (n = Math.max(n, e), n /= Math.log(1 + s * Math.max(0, e / i - 1)) / s + 1), z(n, e / 2, t * 2);
}
function Io(i, t, e, n) {
return t = t !== void 0 ? t : !0, /**
* @param {number|undefined} resolution Resolution.
* @param {number} direction Direction.
* @param {import("./size.js").Size} size Viewport size.
* @param {boolean} [isMoving] True if an interaction or animation is in progress.
* @return {number|undefined} Resolution.
*/
function(s, r, o, a) {
if (s !== void 0) {
const l = i[0], c = i[i.length - 1], h = e ? cn(
l,
e,
o,
n
) : l;
if (a)
return t ? hn(
s,
h,
c
) : z(s, c, h);
const u = Math.min(h, s), d = Math.floor(tn(i, u, r));
return i[d] > h && d < i.length - 1 ? i[d + 1] : i[d];
}
};
}
function wo(i, t, e, n, s, r) {
return n = n !== void 0 ? n : !0, e = e !== void 0 ? e : 0, /**
* @param {number|undefined} resolution Resolution.
* @param {number} direction Direction.
* @param {import("./size.js").Size} size Viewport size.
* @param {boolean} [isMoving] True if an interaction or animation is in progress.
* @return {number|undefined} Resolution.
*/
function(o, a, l, c) {
if (o !== void 0) {
const h = s ? cn(
t,
s,
l,
r
) : t;
if (c)
return n ? hn(
o,
h,
e
) : z(o, e, h);
const u = 1e-9, d = Math.ceil(
Math.log(t / h) / Math.log(i) - u
), g = -a * (0.5 - u) + 0.5, f = Math.min(h, o), _ = Math.floor(
Math.log(t / f) / Math.log(i) + g
), m = Math.max(d, _), y = t / Math.pow(i, m);
return z(y, e, h);
}
};
}
function Vn(i, t, e, n, s) {
return e = e !== void 0 ? e : !0, /**
* @param {number|undefined} resolution Resolution.
* @param {number} direction Direction.
* @param {import("./size.js").Size} size Viewport size.
* @param {boolean} [isMoving] True if an interaction or animation is in progress.
* @return {number|undefined} Resolution.
*/
function(r, o, a, l) {
if (r !== void 0) {
const c = n ? cn(
i,
n,
a,
s
) : i;
return !e || !l ? z(r, t, c) : hn(
r,
c,
t
);
}
};
}
function So(i) {
if (i !== void 0)
return 0;
}
function Bn(i) {
if (i !== void 0)
return i;
}
function vo(i) {
const t = 2 * Math.PI / i;
return (
/**
* @param {number|undefined} rotation Rotation.
* @param {boolean} [isMoving] True if an interaction or animation is in progress.
* @return {number|undefined} Rotation.
*/
function(e, n) {
if (n)
return e;
if (e !== void 0)
return e = Math.floor(e / t + 0.5) * t, e;
}
);
}
function Po(i) {
const t = dt(5);
return (
/**
* @param {number|undefined} rotation Rotation.
* @param {boolean} [isMoving] True if an interaction or animation is in progress.
* @return {number|undefined} Rotation.
*/
function(e, n) {
return n || e === void 0 ? e : Math.abs(e) <= t ? 0 : e;
}
);
}
const Oe = 0;
class $n extends Te {
/**
* @param {ViewOptions} [options] View options.
*/
constructor(t) {
super(), this.on, this.once, this.un, t = Object.assign({}, t), this.hints_ = [0, 0], this.animations_ = [], this.updateAnimationKey_, this.projection_ = qe(t.projection, "EPSG:3857"), this.viewportSize_ = [100, 100], this.targetCenter_ = null, this.targetResolution_, this.targetRotation_, this.nextCenter_ = null, this.nextResolution_, this.nextRotation_, this.cancelAnchor_ = void 0, t.projection && Gs(), t.center && (t.center = lt(t.center, this.projection_)), t.extent && (t.extent = yt(t.extent, this.projection_)), this.applyOptions_(t);
}
/**
* Set up the view with the given options.
* @param {ViewOptions} options View options.
*/
applyOptions_(t) {
const e = Object.assign({}, t);
for (const a in V)
delete e[a];
this.setProperties(e, !0);
const n = Fo(t);
this.maxResolution_ = n.maxResolution, this.minResolution_ = n.minResolution, this.zoomFactor_ = n.zoomFactor, this.resolutions_ = t.resolutions, this.padding_ = t.padding, this.minZoom_ = n.minZoom;
const s = Ao(t), r = n.constraint, o = Oo(t);
this.constraints_ = {
center: s,
resolution: r,
rotation: o
}, this.setRotation(t.rotation !== void 0 ? t.rotation : 0), this.setCenterInternal(
t.center !== void 0 ? t.center : null
), t.resolution !== void 0 ? this.setResolution(t.resolution) : t.zoom !== void 0 && this.setZoom(t.zoom);
}
/**
* Padding (in css pixels).
* If the map viewport is partially covered with other content (overlays) along
* its edges, this setting allows to shift the center of the viewport away from that
* content. The order of the values in the array is top, right, bottom, left.
* The default is no padding, which is equivalent to `[0, 0, 0, 0]`.
* @type {Array<number>|undefined}
* @api
*/
get padding() {
return this.padding_;
}
set padding(t) {
let e = this.padding_;
this.padding_ = t;
const n = this.getCenterInternal();
if (n) {
const s = t || [0, 0, 0, 0];
e = e || [0, 0, 0, 0];
const r = this.getResolution(), o = r / 2 * (s[3] - e[3] + e[1] - s[1]), a = r / 2 * (s[0] - e[0] + e[2] - s[2]);
this.setCenterInternal([n[0] + o, n[1] - a]);
}
}
/**
* Get an updated version of the view options used to construct the view. The
* current resolution (or zoom), center, and rotation are applied to any stored
* options. The provided options can be used to apply new min/max zoom or
* resolution limits.
* @param {ViewOptions} newOptions New options to be applied.
* @return {ViewOptions} New options updated with the current view state.
*/
getUpdatedOptions_(t) {
const e = this.getProperties();
return e.resolution !== void 0 ? e.resolution = this.getResolution() : e.zoom = this.getZoom(), e.center = this.getCenterInternal(), e.rotation = this.getRotation(), Object.assign({}, e, t);
}
/**
* Animate the view. The view's center, zoom (or resolution), and rotation
* can be animated for smooth transitions between view states. For example,
* to animate the view to a new zoom level:
*
* view.animate({zoom: view.getZoom() + 1});
*
* By default, the animation lasts one second and uses in-and-out easing. You
* can customize this behavior by including `duration` (in milliseconds) and
* `easing` options (see {@link module:ol/easing}).
*
* To chain together multiple animations, call the method with multiple
* animation objects. For example, to first zoom and then pan:
*
* view.animate({zoom: 10}, {center: [0, 0]});
*
* If you provide a function as the last argument to the animate method, it
* will get called at the end of an animation series. The callback will be
* called with `true` if the animation series completed on its own or `false`
* if it was cancelled.
*
* Animations are cancelled by user interactions (e.g. dragging the map) or by
* calling `view.setCenter()`, `view.setResolution()`, or `view.setRotation()`
* (or another method that calls one of these).
*
* @param {...(AnimationOptions|function(boolean): void)} var_args Animation
* options. Multiple animations can be run in series by passing multiple
* options objects. To run multiple animations in parallel, call the method
* multiple times. An optional callback can be provided as a final
* argument. The callback will be called with a boolean indicating whether
* the animation completed without being cancelled.
* @api
*/
animate(t) {
this.isDef() && !this.getAnimating() && this.resolveConstraints(0);
const e = new Array(arguments.length);
for (let n = 0; n < e.length; ++n) {
let s = arguments[n];
s.center && (s = Object.assign({}, s), s.center = lt(
s.center,
this.getProjection()
)), s.anchor && (s = Object.assign({}, s), s.anchor = lt(
s.anchor,
this.getProjection()
)), e[n] = s;
}
this.animateInternal.apply(this, e);
}
/**
* @param {...(AnimationOptions|function(boolean): void)} var_args Animation options.
*/
animateInternal(t) {
let e = arguments.length, n;
e > 1 && typeof arguments[e - 1] == "function" && (n = arguments[e - 1], --e);
let s = 0;
for (; s < e && !this.isDef(); ++s) {
const h = arguments[s];
h.center && this.setCenterInternal(h.center), h.zoom !== void 0 ? this.setZoom(h.zoom) : h.resolution && this.setResolution(h.resolution), h.rotation !== void 0 && this.setRotation(h.rotation);
}
if (s === e) {
n && ne(n, !0);
return;
}
let r = Date.now(), o = this.targetCenter_.slice(), a = this.targetResolution_, l = this.targetRotation_;
const c = [];
for (; s < e; ++s) {
const h = (
/** @type {AnimationOptions} */
arguments[s]
), u = {
start: r,
complete: !1,
anchor: h.anchor,
duration: h.duration !== void 0 ? h.duration : 1e3,
easing: h.easing || Er,
callback: n
};
if (h.center && (u.sourceCenter = o, u.targetCenter = h.center.slice(), o = u.targetCenter), h.zoom !== void 0 ? (u.sourceResolution = a, u.targetResolution = this.getResolutionForZoom(h.zoom), a = u.targetResolution) : h.resolution && (u.sourceResolution = a, u.targetResolution = h.resolution, a = u.targetResolution), h.rotation !== void 0) {
u.sourceRotation = l;
const d = bt(h.rotation - l + Math.PI, 2 * Math.PI) - Math.PI;
u.targetRotation = l + d, l = u.targetRotation;
}
Lo(u) ? u.complete = !0 : r += u.duration, c.push(u);
}
this.animations_.push(c), this.setHint(ht.ANIMATING, 1), this.updateAnimations_();
}
/**
* Determine if the view is being animated.
* @return {boolean} The view is being animated.
* @api
*/
getAnimating() {
return this.hints_[ht.ANIMATING] > 0;
}
/**
* Determine if the user is interacting with the view, such as panning or zooming.
* @return {boolean} The view is being interacted with.
* @api
*/
getInteracting() {
return this.hints_[ht.INTERACTING] > 0;
}
/**
* Cancel any ongoing animations.
* @api
*/
cancelAnimations() {
this.setHint(ht.ANIMATING, -this.hints_[ht.ANIMATING]);
let t;
for (let e = 0, n = this.animations_.length; e < n; ++e) {
const s = this.animations_[e];
if (s[0].callback && ne(s[0].callback, !1), !t)
for (let r = 0, o = s.length; r < o; ++r) {
const a = s[r];
if (!a.complete) {
t = a.anchor;
break;
}
}
}
this.animations_.length = 0, this.cancelAnchor_ = t, this.nextCenter_ = null, this.nextResolution_ = NaN, this.nextRotation_ = NaN;
}
/**
* Update all animations.
*/
updateAnimations_() {
if (this.updateAnimationKey_ !== void 0 && (cancelAnimationFrame(this.updateAnimationKey_), this.updateAnimationKey_ = void 0), !this.getAnimating())
return;
const t = Date.now();
let e = !1;
for (let n = this.animations_.length - 1; n >= 0; --n) {
const s = this.animations_[n];
let r = !0;
for (let o = 0, a = s.length; o < a; ++o) {
const l = s[o];
if (l.complete)
continue;
const c = t - l.start;
let h = l.duration > 0 ? c / l.duration : 1;
h >= 1 ? (l.complete = !0, h = 1) : r = !1;
const u = l.easing(h);
if (l.sourceCenter) {
const d = l.sourceCenter[0], g = l.sourceCenter[1], f = l.targetCenter[0], _ = l.targetCenter[1];
this.nextCenter_ = l.targetCenter;
const m = d + u * (f - d), y = g + u * (_ - g);
this.targetCenter_ = [m, y];
}
if (l.sourceResolution && l.targetResolution) {
const d = u === 1 ? l.targetResolution : l.sourceResolution + u * (l.targetResolution - l.sourceResolution);
if (l.anchor) {
const g = this.getViewportSize_(this.getRotation()), f = this.constraints_.resolution(
d,
0,
g,
!0
);
this.targetCenter_ = this.calculateCenterZoom(
f,
l.anchor
);
}
this.nextResolution_ = l.targetResolution, this.targetResolution_ = d, this.applyTargetState_(!0);
}
if (l.sourceRotation !== void 0 && l.targetRotation !== void 0) {
const d = u === 1 ? bt(l.targetRotation + Math.PI, 2 * Math.PI) - Math.PI : l.sourceRotation + u * (l.targetRotation - l.sourceRotation);
if (l.anchor) {
const g = this.constraints_.rotation(
d,
!0
);
this.targetCenter_ = this.calculateCenterRotate(
g,
l.anchor
);
}
this.nextRotation_ = l.targetRotation, this.targetRotation_ = d;
}
if (this.applyTargetState_(!0), e = !0, !l.complete)
break;
}
if (r) {
this.animations_[n] = null, this.setHint(ht.ANIMATING, -1), this.nextCenter_ = null, this.nextResolution_ = NaN, this.nextRotation_ = NaN;
const o = s[0].callback;
o && ne(o, !0);
}
}
this.animations_ = this.animations_.filter(Boolean), e && this.updateAnimationKey_ === void 0 && (this.updateAnimationKey_ = requestAnimationFrame(
this.updateAnimations_.bind(this)
));
}
/**
* @param {number} rotation Target rotation.
* @param {import("./coordinate.js").Coordinate} anchor Rotation anchor.
* @return {import("./coordinate.js").Coordinate|undefined} Center for rotation and anchor.
*/
calculateCenterRotate(t, e) {
let n;
const s = this.getCenterInternal();
return s !== void 0 && (n = [s[0] - e[0], s[1] - e[1]], hs(n, t - this.getRotation()), cs(n, e)), n;
}
/**
* @param {number} resolution Target resolution.
* @param {import("./coordinate.js").Coordinate} anchor Zoom anchor.
* @return {import("./coordinate.js").Coordinate|undefined} Center for resolution and anchor.
*/
calculateCenterZoom(t, e) {
let n;
const s = this.getCenterInternal(), r = this.getResolution();
if (s !== void 0 && r !== void 0) {
const o = e[0] - t * (e[0] - s[0]) / r, a = e[1] - t * (e[1] - s[1]) / r;
n = [o, a];
}
return n;
}
/**
* Returns the current viewport size.
* @private
* @param {number} [rotation] Take into account the rotation of the viewport when giving the size
* @return {import("./size.js").Size} Viewport size or `[100, 100]` when no viewport is found.
*/
getViewportSize_(t) {
const e = this.viewportSize_;
if (t) {
const n = e[0], s = e[1];
return [
Math.abs(n * Math.cos(t)) + Math.abs(s * Math.sin(t)),
Math.abs(n * Math.sin(t)) + Math.abs(s * Math.cos(t))
];
}
return e;
}
/**
* Stores the viewport size on the view. The viewport size is not read every time from the DOM
* to avoid performance hit and layout reflow.
* This should be done on map size change.
* Note: the constraints are not resolved during an animation to avoid stopping it
* @param {import("./size.js").Size} [size] Viewport size; if undefined, [100, 100] is assumed
*/
setViewportSize(t) {
this.viewportSize_ = Array.isArray(t) ? t.slice() : [100, 100], this.getAnimating() || this.resolveConstraints(0);
}
/**
* Get the view center.
* @return {import("./coordinate.js").Coordinate|undefined} The center of the view.
* @observable
* @api
*/
getCenter() {
const t = this.getCenterInternal();
return t && Fn(t, this.getProjection());
}
/**
* Get the view center without transforming to user projection.
* @return {import("./coordinate.js").Coordinate|undefined} The center of the view.
*/
getCenterInternal() {
return (
/** @type {import("./coordinate.js").Coordinate|undefined} */
this.get(V.CENTER)
);
}
/**
* @return {Constraints} Constraints.
*/
getConstraints() {
return this.constraints_;
}
/**
* @return {boolean} Resolution constraint is set
*/
getConstrainResolution() {
return this.get("constrainResolution");
}
/**
* @param {Array<number>} [hints] Destination array.
* @return {Array<number>} Hint.
*/
getHints(t) {
return t !== void 0 ? (t[0] = this.hints_[0], t[1] = this.hints_[1], t) : this.hints_.slice();
}
/**
* Calculate the extent for the current view state and the passed box size.
* @param {import("./size.js").Size} [size] The pixel dimensions of the box
* into which the calculated extent should fit. Defaults to the size of the
* map the view is associated with.
* If no map or multiple maps are connected to the view, provide the desired
* box size (e.g. `map.getSize()`).
* @return {import("./extent.js").Extent} Extent.
* @api
*/
calculateExtent(t) {
const e = this.calculateExtentInternal(t);
return Ys(e, this.getProjection());
}
/**
* @param {import("./size.js").Size} [size] Box pixel size. If not provided,
* the map's last known viewport size will be used.
* @return {import("./extent.js").Extent} Extent.
*/
calculateExtentInternal(t) {
t = t || this.getViewportSizeMinusPadding_();
const e = (
/** @type {!import("./coordinate.js").Coordinate} */
this.getCenterInternal()
);
D(e, "The view center is not defined");
const n = (
/** @type {!number} */
this.getResolution()
);
D(n !== void 0, "The view resolution is not defined");
const s = (
/** @type {!number} */
this.getRotation()
);
return D(s !== void 0, "The view rotation is not defined"), Qi(e, n, s, t);
}
/**
* Get the maximum resolution of the view.
* @return {number} The maximum resolution of the view.
* @api
*/
getMaxResolution() {
return this.maxResolution_;
}
/**
* Get the minimum resolution of the view.
* @return {number} The minimum resolution of the view.
* @api
*/
getMinResolution() {
return this.minResolution_;
}
/**
* Get the maximum zoom level for the view.
* @return {number} The maximum zoom level.
* @api
*/
getMaxZoom() {
return (
/** @type {number} */
this.getZoomForResolution(this.minResolution_)
);
}
/**
* Set a new maximum zoom level for the view.
* @param {number} zoom The maximum zoom level.
* @api
*/
setMaxZoom(t) {
this.applyOptions_(this.getUpdatedOptions_({ maxZoom: t }));
}
/**
* Get the minimum zoom level for the view.
* @return {number} The minimum zoom level.
* @api
*/
getMinZoom() {
return (
/** @type {number} */
this.getZoomForResolution(this.maxResolution_)
);
}
/**
* Set a new minimum zoom level for the view.
* @param {number} zoom The minimum zoom level.
* @api
*/
setMinZoom(t) {
this.applyOptions_(this.getUpdatedOptions_({ minZoom: t }));
}
/**
* Set whether the view should allow intermediary zoom levels.
* @param {boolean} enabled Whether the resolution is constrained.
* @api
*/
setConstrainResolution(t) {
this.applyOptions_(this.getUpdatedOptions_({ constrainResolution: t }));
}
/**
* Get the view projection.
* @return {import("./proj/Projection.js").default} The projection of the view.
* @api
*/
getProjection() {
return this.projection_;
}
/**
* Get the view resolution.
* @return {number|undefined} The resolution of the view.
* @observable
* @api
*/
getResolution() {
return (
/** @type {number|undefined} */
this.get(V.RESOLUTION)
);
}
/**
* Get the resolutions for the view. This returns the array of resolutions
* passed to the constructor of the View, or undefined if none were given.
* @return {Array<number>|undefined} The resolutions of the view.
* @api
*/
getResolutions() {
return this.resolutions_;
}
/**
* Get the resolution for a provided extent (in map units) and size (in pixels).
* @param {import("./extent.js").Extent} extent Extent.
* @param {import("./size.js").Size} [size] Box pixel size.
* @return {number} The resolution at which the provided extent will render at
* the given size.
* @api
*/
getResolutionForExtent(t, e) {
return this.getResolutionForExtentInternal(
yt(t, this.getProjection()),
e
);
}
/**
* Get the resolution for a provided extent (in map units) and size (in pixels).
* @param {import("./extent.js").Extent} extent Extent.
* @param {import("./size.js").Size} [size] Box pixel size.
* @return {number} The resolution at which the provided extent will render at
* the given size.
*/
getResolutionForExtentInternal(t, e) {
e = e || this.getViewportSizeMinusPadding_();
const n = v(t) / e[0], s = W(t) / e[1];
return Math.max(n, s);
}
/**
* Return a function that returns a value between 0 and 1 for a
* resolution. Exponential scaling is assumed.
* @param {number} [power] Power.
* @return {function(number): number} Resolution for value function.
*/
getResolutionForValueFunction(t) {
t = t || 2;
const e = this.getConstrainedResolution(this.maxResolution_), n = this.minResolution_, s = Math.log(e / n) / Math.log(t);
return (
/**
* @param {number} value Value.
* @return {number} Resolution.
*/
function(r) {
return e / Math.pow(t, r * s);
}
);
}
/**
* Get the view rotation.
* @return {number} The rotation of the view in radians.
* @observable
* @api
*/
getRotation() {
return (
/** @type {number} */
this.get(V.ROTATION)
);
}
/**
* Return a function that returns a resolution for a value between
* 0 and 1. Exponential scaling is assumed.
* @param {number} [power] Power.
* @return {function(number): number} Value for resolution function.
*/
getValueForResolutionFunction(t) {
const e = Math.log(t || 2), n = this.getConstrainedResolution(this.maxResolution_), s = this.minResolution_, r = Math.log(n / s) / e;
return (
/**
* @param {number} resolution Resolution.
* @return {number} Value.
*/
function(o) {
return Math.log(n / o) / e / r;
}
);
}
/**
* Returns the size of the viewport minus padding.
* @private
* @param {number} [rotation] Take into account the rotation of the viewport when giving the size
* @return {import("./size.js").Size} Viewport size reduced by the padding.
*/
getViewportSizeMinusPadding_(t) {
let e = this.getViewportSize_(t);
const n = this.padding_;
return n && (e = [
e[0] - n[1] - n[3],
e[1] - n[0] - n[2]
]), e;
}
/**
* @return {State} View state.
*/
getState() {
const t = this.getProjection(), e = this.getResolution(), n = this.getRotation();
let s = (
/** @type {import("./coordinate.js").Coordinate} */
this.getCenterInternal()
);
const r = this.padding_;
if (r) {
const o = this.getViewportSizeMinusPadding_();
s = Le(
s,
this.getViewportSize_(),
[o[0] / 2 + r[3], o[1] / 2 + r[0]],
e,
n
);
}
return {
center: s.slice(0),
projection: t !== void 0 ? t : null,
resolution: e,
nextCenter: this.nextCenter_,
nextResolution: this.nextResolution_,
nextRotation: this.nextRotation_,
rotation: n,
zoom: this.getZoom()
};
}
/**
* @return {ViewStateLayerStateExtent} Like `FrameState`, but just `viewState` and `extent`.
*/
getViewStateAndExtent() {
return {
viewState: this.getState(),
extent: this.calculateExtent()
};
}
/**
* Get the current zoom level. This method may return non-integer zoom levels
* if the view does not constrain the resolution, or if an interaction or
* animation is underway.
* @return {number|undefined} Zoom.
* @api
*/
getZoom() {
let t;
const e = this.getResolution();
return e !== void 0 && (t = this.getZoomForResolution(e)), t;
}
/**
* Get the zoom level for a resolution.
* @param {number} resolution The resolution.
* @return {number|undefined} The zoom level for the provided resolution.
* @api
*/
getZoomForResolution(t) {
let e = this.minZoom_ || 0, n, s;
if (this.resolutions_) {
const r = tn(this.resolutions_, t, 1);
e = r, n = this.resolutions_[r], r == this.resolutions_.length - 1 ? s = 2 : s = n / this.resolutions_[r + 1];
} else
n = this.maxResolution_, s = this.zoomFactor_;
return e + Math.log(n / t) / Math.log(s);
}
/**
* Get the resolution for a zoom level.
* @param {number} zoom Zoom level.
* @return {number} The view resolution for the provided zoom level.
* @api
*/
getResolutionForZoom(t) {
var e;
if ((e = this.resolutions_) != null && e.length) {
if (this.resolutions_.length === 1)
return this.resolutions_[0];
const n = z(
Math.floor(t),
0,
this.resolutions_.length - 2
), s = this.resolutions_[n] / this.resolutions_[n + 1];
return this.resolutions_[n] / Math.pow(s, z(t - n, 0, 1));
}
return this.maxResolution_ / Math.pow(this.zoomFactor_, t - this.minZoom_);
}
/**
* Fit the given geometry or extent based on the given map size and border.
* The size is pixel dimensions of the box to fit the extent into.
* In most cases you will want to use the map size, that is `map.getSize()`.
* Takes care of the map angle.
* @param {import("./geom/SimpleGeometry.js").default|import("./extent.js").Extent} geometryOrExtent The geometry or
* extent to fit the view to.
* @param {FitOptions} [options] Options.
* @api
*/
fit(t, e) {
let n;
if (D(
Array.isArray(t) || typeof /** @type {?} */
t.getSimplifiedGeometry == "function",
"Invalid extent or geometry provided as `geometry`"
), Array.isArray(t)) {
D(
!Re(t),
"Cannot fit empty extent provided as `geometry`"
);
const s = yt(t, this.getProjection());
n = Un(s);
} else if (t.getType() === "Circle") {
const s = yt(
t.getExtent(),
this.getProjection()
);
n = Un(s), n.rotate(this.getRotation(), Gt(s));
} else
n = t;
this.fitInternal(n, e);
}
/**
* Calculate rotated extent
* @param {import("./geom/SimpleGeometry.js").default} geometry The geometry.
* @return {import("./extent").Extent} The rotated extent for the geometry.
*/
rotatedExtentForGeometry(t) {
const e = this.getRotation(), n = Math.cos(e), s = Math.sin(-e), r = t.getFlatCoordinates(), o = t.getStride();
let a = 1 / 0, l = 1 / 0, c = -1 / 0, h = -1 / 0;
for (let u = 0, d = r.length; u < d; u += o) {
const g = r[u] * n - r[u + 1] * s, f = r[u] * s + r[u + 1] * n;
a = Math.min(a, g), l = Math.min(l, f), c = Math.max(c, g), h = Math.max(h, f);
}
return [a, l, c, h];
}
/**
* @param {import("./geom/SimpleGeometry.js").default} geometry The geometry.
* @param {FitOptions} [options] Options.
*/
fitInternal(t, e) {
e = e || {};
let n = e.size;
n || (n = this.getViewportSizeMinusPadding_());
const s = e.padding !== void 0 ? e.padding : [0, 0, 0, 0], r = e.nearest !== void 0 ? e.nearest : !1;
let o;
e.minResolution !== void 0 ? o = e.minResolution : e.maxZoom !== void 0 ? o = this.getResolutionForZoom(e.maxZoom) : o = 0;
const a = this.rotatedExtentForGeometry(t);
let l = this.getResolutionForExtentInternal(a, [
n[0] - s[1] - s[3],
n[1] - s[0] - s[2]
]);
l = isNaN(l) ? o : Math.max(l, o), l = this.getConstrainedResolution(l, r ? 0 : 1);
const c = this.getRotation(), h = Math.sin(c), u = Math.cos(c), d = Gt(a);
d[0] += (s[1] - s[3]) / 2 * l, d[1] += (s[0] - s[2]) / 2 * l;
const g = d[0] * u - d[1] * h, f = d[1] * u + d[0] * h, _ = this.getConstrainedCenter([g, f], l), m = e.callback ? e.callback : je;
e.duration !== void 0 ? this.animateInternal(
{
resolution: l,
center: _,
duration: e.duration,
easing: e.easing
},
m
) : (this.targetResolution_ = l, this.targetCenter_ = _, this.applyTargetState_(!1, !0), ne(m, !0));
}
/**
* Center on coordinate and view position.
* @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
* @param {import("./size.js").Size} size Box pixel size.
* @param {import("./pixel.js").Pixel} position Position on the view to center on.
* @api
*/
centerOn(t, e, n) {
this.centerOnInternal(
lt(t, this.getProjection()),
e,
n
);
}
/**
* @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
* @param {import("./size.js").Size} size Box pixel size.
* @param {import("./pixel.js").Pixel} position Position on the view to center on.
*/
centerOnInternal(t, e, n) {
this.setCenterInternal(
Le(
t,
e,
n,
this.getResolution(),
this.getRotation()
)
);
}
/**
* Calculates the shift between map and viewport center.
* @param {import("./coordinate.js").Coordinate} center Center.
* @param {number} resolution Resolution.
* @param {number} rotation Rotation.
* @param {import("./size.js").Size} size Size.
* @return {Array<number>|undefined} Center shift.
*/
calculateCenterShift(t, e, n, s) {
let r;
const o = this.padding_;
if (o && t) {
const a = this.getViewportSizeMinusPadding_(-n), l = Le(
t,
s,
[a[0] / 2 + o[3], a[1] / 2 + o[0]],
e,
n
);
r = [
t[0] - l[0],
t[1] - l[1]
];
}
return r;
}
/**
* @return {boolean} Is defined.
*/
isDef() {
return !!this.getCenterInternal() && this.getResolution() !== void 0;
}
/**
* Adds relative coordinates to the center of the view. Any extent constraint will apply.
* @param {import("./coordinate.js").Coordinate} deltaCoordinates Relative value to add.
* @api
*/
adjustCenter(t) {
const e = Fn(this.targetCenter_, this.getProjection());
this.setCenter([
e[0] + t[0],
e[1] + t[1]
]);
}
/**
* Adds relative coordinates to the center of the view. Any extent constraint will apply.
* @param {import("./coordinate.js").Coordinate} deltaCoordinates Relative value to add.
*/
adjustCenterInternal(t) {
const e = this.targetCenter_;
this.setCenterInternal([
e[0] + t[0],
e[1] + t[1]
]);
}
/**
* Multiply the view resolution by a ratio, optionally using an anchor. Any resolution
* constraint will apply.
* @param {number} ratio The ratio to apply on the view resolution.
* @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
* @api
*/
adjustResolution(t, e) {
e = e && lt(e, this.getProjection()), this.adjustResolutionInternal(t, e);
}
/**
* Multiply the view resolution by a ratio, optionally using an anchor. Any resolution
* constraint will apply.
* @param {number} ratio The ratio to apply on the view resolution.
* @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
*/
adjustResolutionInternal(t, e) {
const n = this.getAnimating() || this.getInteracting(), s = this.getViewportSize_(this.getRotation()), r = this.constraints_.resolution(
this.targetResolution_ * t,
0,
s,
n
);
e && (this.targetCenter_ = this.calculateCenterZoom(r, e)), this.targetResolution_ *= t, this.applyTargetState_();
}
/**
* Adds a value to the view zoom level, optionally using an anchor. Any resolution
* constraint will apply.
* @param {number} delta Relative value to add to the zoom level.
* @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
* @api
*/
adjustZoom(t, e) {
this.adjustResolution(Math.pow(this.zoomFactor_, -t), e);
}
/**
* Adds a value to the view rotation, optionally using an anchor. Any rotation
* constraint will apply.
* @param {number} delta Relative value to add to the zoom rotation, in radians.
* @param {import("./coordinate.js").Coordinate} [anchor] The rotation center.
* @api
*/
adjustRotation(t, e) {
e && (e = lt(e, this.getProjection())), this.adjustRotationInternal(t, e);
}
/**
* @param {number} delta Relative value to add to the zoom rotation, in radians.
* @param {import("./coordinate.js").Coordinate} [anchor] The rotation center.
*/
adjustRotationInternal(t, e) {
const n = this.getAnimating() || this.getInteracting(), s = this.constraints_.rotation(
this.targetRotation_ + t,
n
);
e && (this.targetCenter_ = this.calculateCenterRotate(s, e)), this.targetRotation_ += t, this.applyTargetState_();
}
/**
* Set the center of the current view. Any extent constraint will apply.
* @param {import("./coordinate.js").Coordinate|undefined} center The center of the view.
* @observable
* @api
*/
setCenter(t) {
this.setCenterInternal(
t && lt(t, this.getProjection())
);
}
/**
* Set the center using the view projection (not the user projection).
* @param {import("./coordinate.js").Coordinate|undefined} center The center of the view.
*/
setCenterInternal(t) {
this.targetCenter_ = t, this.applyTargetState_();
}
/**
* @param {import("./ViewHint.js").default} hint Hint.
* @param {number} delta Delta.
* @return {number} New value.
*/
setHint(t, e) {
return this.hints_[t] += e, this.changed(), this.hints_[t];
}
/**
* Set the resolution for this view. Any resolution constraint will apply.
* @param {number|undefined} resolution The resolution of the view.
* @observable
* @api
*/
setResolution(t) {
this.targetResolution_ = t, this.applyTargetState_();
}
/**
* Set the rotation for this view. Any rotation constraint will apply.
* @param {number} rotation The rotation of the view in radians.
* @observable
* @api
*/
setRotation(t) {
this.targetRotation_ = t, this.applyTargetState_();
}
/**
* Zoom to a specific zoom level. Any resolution constrain will apply.
* @param {number} zoom Zoom level.
* @api
*/
setZoom(t) {
this.setResolution(this.getResolutionForZoom(t));
}
/**
* Recompute rotation/resolution/center based on target values.
* Note: we have to compute rotation first, then resolution and center considering that
* parameters can influence one another in case a view extent constraint is present.
* @param {boolean} [doNotCancelAnims] Do not cancel animations.
* @param {boolean} [forceMoving] Apply constraints as if the view is moving.
* @private
*/
applyTargetState_(t, e) {
const n = this.getAnimating() || this.getInteracting() || e, s = this.constraints_.rotation(
this.targetRotation_,
n
), r = this.getViewportSize_(s), o = this.constraints_.resolution(
this.targetResolution_,
0,
r,
n
), a = this.constraints_.center(
this.targetCenter_,
o,
r,
n,
this.calculateCenterShift(
this.targetCenter_,
o,
s,
r
)
);
this.get(V.ROTATION) !== s && this.set(V.ROTATION, s), this.get(V.RESOLUTION) !== o && (this.set(V.RESOLUTION, o), this.set("zoom", this.getZoom(), !0)), (!a || !this.get(V.CENTER) || !oe(this.get(V.CENTER), a)) && this.set(V.CENTER, a), this.getAnimating() && !t && this.cancelAnimations(), this.cancelAnchor_ = void 0;
}
/**
* If any constraints need to be applied, an animation will be triggered.
* This is typically done on interaction end.
* Note: calling this with a duration of 0 will apply the constrained values straight away,
* without animation.
* @param {number} [duration] The animation duration in ms.
* @param {number} [resolutionDirection] Which direction to zoom.
* @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
*/
resolveConstraints(t, e, n) {
t = t !== void 0 ? t : 200;
const s = e || 0, r = this.constraints_.rotation(this.targetRotation_), o = this.getViewportSize_(r), a = this.constraints_.resolution(
this.targetResolution_,
s,
o
), l = this.constraints_.center(
this.targetCenter_,
a,
o,
!1,
this.calculateCenterShift(
this.targetCenter_,
a,
r,
o
)
);
if (t === 0 && !this.cancelAnchor_) {
this.targetResolution_ = a, this.targetRotation_ = r, this.targetCenter_ = l, this.applyTargetState_();
return;
}
n = n || (t === 0 ? this.cancelAnchor_ : void 0), this.cancelAnchor_ = void 0, (this.getResolution() !== a || this.getRotation() !== r || !this.getCenterInternal() || !oe(this.getCenterInternal(), l)) && (this.getAnimating() && this.cancelAnimations(), this.animateInternal({
rotation: r,
center: l,
resolution: a,
duration: t,
easing: yr,
anchor: n
}));
}
/**
* Notify the View that an interaction has started.
* The view state will be resolved to a stable one if needed
* (depending on its constraints).
* @api
*/
beginInteraction() {
this.resolveConstraints(0), this.setHint(ht.INTERACTING, 1);
}
/**
* Notify the View that an interaction has ended. The view state will be resolved
* to a stable one if needed (depending on its constraints).
* @param {number} [duration] Animation duration in ms.
* @param {number} [resolutionDirection] Which direction to zoom.
* @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
* @api
*/
endInteraction(t, e, n) {
n = n && lt(n, this.getProjection()), this.endInteractionInternal(t, e, n);
}
/**
* Notify the View that an interaction has ended. The view state will be resolved
* to a stable one if needed (depending on its constraints).
* @param {number} [duration] Animation duration in ms.
* @param {number} [resolutionDirection] Which direction to zoom.
* @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
*/
endInteractionInternal(t, e, n) {
this.getInteracting() && (this.setHint(ht.INTERACTING, -1), this.resolveConstraints(t, e, n));
}
/**
* Get a valid position for the view center according to the current constraints.
* @param {import("./coordinate.js").Coordinate|undefined} targetCenter Target center position.
* @param {number} [targetResolution] Target resolution. If not supplied, the current one will be used.
* This is useful to guess a valid center position at a different zoom level.
* @return {import("./coordinate.js").Coordinate|undefined} Valid center position.
*/
getConstrainedCenter(t, e) {
const n = this.getViewportSize_(this.getRotation());
return this.constraints_.center(
t,
e || this.getResolution(),
n
);
}
/**
* Get a valid zoom level according to the current view constraints.
* @param {number|undefined} targetZoom Target zoom.
* @param {number} [direction] Indicate which resolution should be used
* by a renderer if the view resolution does not match any resolution of the tile source.
* If 0, the nearest resolution will be used. If 1, the nearest lower resolution
* will be used. If -1, the nearest higher resolution will be used.
* @return {number|undefined} Valid zoom level.
*/
getConstrainedZoom(t, e) {
const n = this.getResolutionForZoom(t);
return this.getZoomForResolution(
this.getConstrainedResolution(n, e)
);
}
/**
* Get a valid resolution according to the current view constraints.
* @param {number|undefined} targetResolution Target resolution.
* @param {number} [direction] Indicate which resolution should be used
* by a renderer if the view resolution does not match any resolution of the tile source.
* If 0, the nearest resolution will be used. If 1, the nearest lower resolution
* will be used. If -1, the nearest higher resolution will be used.
* @return {number|undefined} Valid resolution.
*/
getConstrainedResolution(t, e) {
e = e || 0;
const n = this.getViewportSize_(this.getRotation());
return this.constraints_.resolution(t, e, n);
}
}
function ne(i, t) {
setTimeout(function() {
i(t);
}, 0);
}
function Ao(i) {
if (i.extent !== void 0) {
const e = i.smoothExtentConstraint !== void 0 ? i.smoothExtentConstraint : !0;
return kn(i.extent, i.constrainOnlyCenter, e);
}
const t = qe(i.projection, "EPSG:3857");
if (i.multiWorld !== !0 && t.isGlobal()) {
const e = t.getExtent().slice();
return e[0] = -1 / 0, e[2] = 1 / 0, kn(e, !1, !1);
}
return Mo;
}
function Fo(i) {
let t, e, n, o = i.minZoom !== void 0 ? i.minZoom : Oe, a = i.maxZoom !== void 0 ? i.maxZoom : 28;
const l = i.zoomFactor !== void 0 ? i.zoomFactor : 2, c = i.multiWorld !== void 0 ? i.multiWorld : !1, h = i.smoothResolutionConstraint !== void 0 ? i.smoothResolutionConstraint : !0, u = i.showFullExtent !== void 0 ? i.showFullExtent : !1, d = qe(i.projection, "EPSG:3857"), g = d.getExtent();
let f = i.constrainOnlyCenter, _ = i.extent;
if (!c && !_ && d.isGlobal() && (f = !1, _ = g), i.resolutions !== void 0) {
const m = i.resolutions;
e = m[o], n = m[a] !== void 0 ? m[a] : m[m.length - 1], i.constrainResolution ? t = Io(
m,
h,
!f && _,
u
) : t = Vn(
e,
n,
h,
!f && _,
u
);
} else {
const y = (g ? Math.max(v(g), W(g)) : (
// use an extent that can fit the whole world if need be
360 * We.degrees / d.getMetersPerUnit()
)) / en / Math.pow(2, Oe), R = y / Math.pow(2, 28 - Oe);
e = i.maxResolution, e !== void 0 ? o = 0 : e = y / Math.pow(l, o), n = i.minResolution, n === void 0 && (i.maxZoom !== void 0 ? i.maxResolution !== void 0 ? n = e / Math.pow(l, a) : n = y / Math.pow(l, a) : n = R), a = o + Math.floor(
Math.log(e / n) / Math.log(l)
), n = e / Math.pow(l, a - o), i.constrainResolution ? t = wo(
l,
e,
n,
h,
!f && _,
u
) : t = Vn(
e,
n,
h,
!f && _,
u
);
}
return {
constraint: t,
maxResolution: e,
minResolution: n,
minZoom: o,
zoomFactor: l
};
}
function Oo(i) {
if (i.enableRotation !== void 0 ? i.enableRotation : !0) {
const e = i.constrainRotation;
return e === void 0 || e === !0 ? Po() : e === !1 ? Bn : typeof e == "number" ? vo(e) : Bn;
}
return So;
}
function Lo(i) {
return !(i.sourceCenter && i.targetCenter && !oe(i.sourceCenter, i.targetCenter) || i.sourceResolution !== i.targetResolution || i.sourceRotation !== i.targetRotation);
}
function Le(i, t, e, n, s) {
const r = Math.cos(-s);
let o = Math.sin(-s), a = i[0] * r - i[1] * o, l = i[1] * r + i[0] * o;
a += (t[0] / 2 - e[0]) * n, l += (e[1] - t[1] / 2) * n, o = -o;
const c = a * r - l * o, h = l * r + a * o;
return [c, h];
}
const M = {
OPACITY: "opacity",
VISIBLE: "visible",
EXTENT: "extent",
Z_INDEX: "zIndex",
MAX_RESOLUTION: "maxResolution",
MIN_RESOLUTION: "minResolution",
MAX_ZOOM: "maxZoom",
MIN_ZOOM: "minZoom",
SOURCE: "source",
MAP: "map"
};
class bo extends Te {
/**
* @param {Options} options Layer options.
*/
constructor(t) {
super(), this.on, this.once, this.un, this.background_ = t.background;
const e = Object.assign({}, t);
typeof t.properties == "object" && (delete e.properties, Object.assign(e, t.properties)), e[M.OPACITY] = t.opacity !== void 0 ? t.opacity : 1, D(
typeof e[M.OPACITY] == "number",
"Layer opacity must be a number"
), e[M.VISIBLE] = t.visible !== void 0 ? t.visible : !0, e[M.Z_INDEX] = t.zIndex, e[M.MAX_RESOLUTION] = t.maxResolution !== void 0 ? t.maxResolution : 1 / 0, e[M.MIN_RESOLUTION] = t.minResolution !== void 0 ? t.minResolution : 0, e[M.MIN_ZOOM] = t.minZoom !== void 0 ? t.minZoom : -1 / 0, e[M.MAX_ZOOM] = t.maxZoom !== void 0 ? t.maxZoom : 1 / 0, this.className_ = e.className !== void 0 ? e.className : "ol-layer", delete e.className, this.setProperties(e), this.state_ = null;
}
/**
* Get the background for this layer.
* @return {BackgroundColor|false} Layer background.
*/
getBackground() {
return this.background_;
}
/**
* @return {string} CSS class name.
*/
getClassName() {
return this.className_;
}
/**
* This method is not meant to be called by layers or layer renderers because the state
* is incorrect if the layer is included in a layer group.
*
* @param {boolean} [managed] Layer is managed.
* @return {import("./Layer.js").State} Layer state.
*/
getLayerState(t) {
const e = this.state_ || /** @type {?} */
{
layer: this,
managed: t === void 0 ? !0 : t
}, n = this.getZIndex();
return e.opacity = z(Math.round(this.getOpacity() * 100) / 100, 0, 1), e.visible = this.getVisible(), e.extent = this.getExtent(), e.zIndex = n === void 0 && !e.managed ? 1 / 0 : n, e.maxResolution = this.getMaxResolution(), e.minResolution = Math.max(this.getMinResolution(), 0), e.minZoom = this.getMinZoom(), e.maxZoom = this.getMaxZoom(), this.state_ = e, e;
}
/**
* @abstract
* @param {Array<import("./Layer.js").default>} [array] Array of layers (to be
* modified in place).
* @return {Array<import("./Layer.js").default>} Array of layers.
*/
getLayersArray(t) {
return O();
}
/**
* @abstract
* @param {Array<import("./Layer.js").State>} [states] Optional list of layer
* states (to be modified in place).
* @return {Array<import("./Layer.js").State>} List of layer states.
*/
getLayerStatesArray(t) {
return O();
}
/**
* Return the {@link module:ol/extent~Extent extent} of the layer or `undefined` if it
* will be visible regardless of extent.
* @return {import("../extent.js").Extent|undefined} The layer extent.
* @observable
* @api
*/
getExtent() {
return (
/** @type {import("../extent.js").Extent|undefined} */
this.get(M.EXTENT)
);
}
/**
* Return the maximum resolution of the layer. Returns Infinity if
* the layer has no maximum resolution set.
* @return {number} The maximum resolution of the layer.
* @observable
* @api
*/
getMaxResolution() {
return (
/** @type {number} */
this.get(M.MAX_RESOLUTION)
);
}
/**
* Return the minimum resolution of the layer. Returns 0 if
* the layer has no minimum resolution set.
* @return {number} The minimum resolution of the layer.
* @observable
* @api
*/
getMinResolution() {
return (
/** @type {number} */
this.get(M.MIN_RESOLUTION)
);
}
/**
* Return the minimum zoom level of the layer. Returns -Infinity if
* the layer has no minimum zoom set.
* @return {number} The minimum zoom level of the layer.
* @observable
* @api
*/
getMinZoom() {
return (
/** @type {number} */
this.get(M.MIN_ZOOM)
);
}
/**
* Return the maximum zoom level of the layer. Returns Infinity if
* the layer has no maximum zoom set.
* @return {number} The maximum zoom level of the layer.
* @observable
* @api
*/
getMaxZoom() {
return (
/** @type {number} */
this.get(M.MAX_ZOOM)
);
}
/**
* Return the opacity of the layer (between 0 and 1).
* @return {number} The opacity of the layer.
* @observable
* @api
*/
getOpacity() {
return (
/** @type {number} */
this.get(M.OPACITY)
);
}
/**
* @abstract
* @return {import("../source/Source.js").State} Source state.
*/
getSourceState() {
return O();
}
/**
* Return the value of this layer's `visible` property. To find out whether the layer
* is visible on a map, use `isVisible()` instead.
* @return {boolean} The value of the `visible` property of the layer.
* @observable
* @api
*/
getVisible() {
return (
/** @type {boolean} */
this.get(M.VISIBLE)
);
}
/**
* Return the Z-index of the layer, which is used to order layers before
* rendering. Returns undefined if the layer is unmanaged.
* @return {number|undefined} The Z-index of the layer.
* @observable
* @api
*/
getZIndex() {
return (
/** @type {number|undefined} */
this.get(M.Z_INDEX)
);
}
/**
* Sets the background color.
* @param {BackgroundColor} [background] Background color.
*/
setBackground(t) {
this.background_ = t, this.changed();
}
/**
* Set the extent at which the layer is visible. If `undefined`, the layer
* will be visible at all extents.
* @param {import("../extent.js").Extent|undefined} extent The extent of the layer.
* @observable
* @api
*/
setExtent(t) {
this.set(M.EXTENT, t);
}
/**
* Set the maximum resolution at which the layer is visible.
* @param {number} maxResolution The maximum resolution of the layer.
* @observable
* @api
*/
setMaxResolution(t) {
this.set(M.MAX_RESOLUTION, t);
}
/**
* Set the minimum resolution at which the layer is visible.
* @param {number} minResolution The minimum resolution of the layer.
* @observable
* @api
*/
setMinResolution(t) {
this.set(M.MIN_RESOLUTION, t);
}
/**
* Set the maximum zoom (exclusive) at which the layer is visible.
* Note that the zoom levels for layer visibility are based on the
* view zoom level, which may be different from a tile source zoom level.
* @param {number} maxZoom The maximum zoom of the layer.
* @observable
* @api
*/
setMaxZoom(t) {
this.set(M.MAX_ZOOM, t);
}
/**
* Set the minimum zoom (inclusive) at which the layer is visible.
* Note that the zoom levels for layer visibility are based on the
* view zoom level, which may be different from a tile source zoom level.
* @param {number} minZoom The minimum zoom of the layer.
* @observable
* @api
*/
setMinZoom(t) {
this.set(M.MIN_ZOOM, t);
}
/**
* Set the opacity of the layer, allowed values range from 0 to 1.
* @param {number} opacity The opacity of the layer.
* @observable
* @api
*/
setOpacity(t) {
D(typeof t == "number", "Layer opacity must be a number"), this.set(M.OPACITY, t);
}
/**
* Set the visibility of the layer (`true` or `false`).
* @param {boolean} visible The visibility of the layer.
* @observable
* @api
*/
setVisible(t) {
this.set(M.VISIBLE, t);
}
/**
* Set Z-index of the layer, which is used to order layers before rendering.
* The default Z-index is 0.
* @param {number} zindex The z-index of the layer.
* @observable
* @api
*/
setZIndex(t) {
this.set(M.Z_INDEX, t);
}
/**
* Clean up.
* @override
*/
disposeInternal() {
this.state_ && (this.state_.layer = null, this.state_ = null), super.disposeInternal();
}
}
class Xo extends bo {
/**
* @param {Options<SourceType>} options Layer options.
*/
constructor(t) {
const e = Object.assign({}, t);
delete e.source, super(e), this.on, this.once, this.un, this.mapPrecomposeKey_ = null, this.mapRenderKey_ = null, this.sourceChangeKey_ = null, this.renderer_ = null, this.sourceReady_ = !1, this.rendered = !1, t.render && (this.render = t.render), t.map && this.setMap(t.map), this.addChangeListener(
M.SOURCE,
this.handleSourcePropertyChange_
);
const n = t.source ? (
/** @type {SourceType} */
t.source
) : null;
this.setSource(n);
}
/**
* @param {Array<import("./Layer.js").default>} [array] Array of layers (to be modified in place).
* @return {Array<import("./Layer.js").default>} Array of layers.
* @override
*/
getLayersArray(t) {
return t = t || [], t.push(this), t;
}
/**
* @param {Array<import("./Layer.js").State>} [states] Optional list of layer states (to be modified in place).
* @return {Array<import("./Layer.js").State>} List of layer states.
* @override
*/
getLayerStatesArray(t) {
return t = t || [], t.push(this.getLayerState()), t;
}
/**
* Get the layer source.
* @return {SourceType|null} The layer source (or `null` if not yet set).
* @observable
* @api
*/
getSource() {
return (
/** @type {SourceType} */
this.get(M.SOURCE) || null
);
}
/**
* @return {SourceType|null} The source being rendered.
*/
getRenderSource() {
return this.getSource();
}
/**
* @return {import("../source/Source.js").State} Source state.
* @override
*/
getSourceState() {
const t = this.getSource();
return t ? t.getState() : "undefined";
}
/**
* @private
*/
handleSourceChange_() {
this.changed(), !(this.sourceReady_ || this.getSource().getState() !== "ready") && (this.sourceReady_ = !0, this.dispatchEvent("sourceready"));
}
/**
* @private
*/
handleSourcePropertyChange_() {
this.sourceChangeKey_ && (ft(this.sourceChangeKey_), this.sourceChangeKey_ = null), this.sourceReady_ = !1;
const t = this.getSource();
t && (this.sourceChangeKey_ = Tt(
t,
nt.CHANGE,
this.handleSourceChange_,
this
), t.getState() === "ready" && (this.sourceReady_ = !0, setTimeout(() => {
this.dispatchEvent("sourceready");
}, 0)), this.clearRenderer()), this.changed();
}
/**
* @param {import("../pixel").Pixel} pixel Pixel.
* @return {Promise<Array<import("../Feature").FeatureLike>>} Promise that resolves with
* an array of features.
*/
getFeatures(t) {
return this.renderer_ ? this.renderer_.getFeatures(t) : Promise.resolve([]);
}
/**
* @param {import("../pixel").Pixel} pixel Pixel.
* @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data.
*/
getData(t) {
return !this.renderer_ || !this.rendered ? null : this.renderer_.getData(t);
}
/**
* The layer is visible on the map view, i.e. within its min/max resolution or zoom and
* extent, not set to `visible: false`, and not inside a layer group that is set
* to `visible: false`.
* @param {View|import("../View.js").ViewStateLayerStateExtent} [view] View or {@link import("../Map.js").FrameState}.
* Only required when the layer is not added to a map.
* @return {boolean} The layer is visible in the map view.
* @api
*/
isVisible(t) {
let e;
const n = this.getMapInternal();
!t && n && (t = n.getView()), t instanceof $n ? e = {
viewState: t.getState(),
extent: t.calculateExtent()
} : e = t, !e.layerStatesArray && n && (e.layerStatesArray = n.getLayerGroup().getLayerStatesArray());
let s;
if (e.layerStatesArray) {
if (s = e.layerStatesArray.find(
(o) => o.layer === this
), !s)
return !1;
} else
s = this.getLayerState();
const r = this.getExtent();
return No(s, e.viewState) && (!r || kt(r, e.extent));
}
/**
* Get the attributions of the source of this layer for the given view.
* @param {View|import("../View.js").ViewStateLayerStateExtent} [view] View or {@link import("../Map.js").FrameState}.
* Only required when the layer is not added to a map.
* @return {Array<string>} Attributions for this layer at the given view.
* @api
*/
getAttributions(t) {
var r;
if (!this.isVisible(t))
return [];
const e = (r = this.getSource()) == null ? void 0 : r.getAttributions();
if (!e)
return [];
const n = t instanceof $n ? t.getViewStateAndExtent() : t;
let s = e(n);
return Array.isArray(s) || (s = [s]), s;
}
/**
* In charge to manage the rendering of the layer. One layer type is
* bounded with one layer renderer.
* @param {?import("../Map.js").FrameState} frameState Frame state.
* @param {HTMLElement} target Target which the renderer may (but need not) use
* for rendering its content.
* @return {HTMLElement|null} The rendered element.
*/
render(t, e) {
const n = this.getRenderer();
return n.prepareFrame(t) ? (this.rendered = !0, n.renderFrame(t, e)) : null;
}
/**
* Called when a layer is not visible during a map render.
*/
unrender() {
this.rendered = !1;
}
/** @return {string} Declutter */
getDeclutter() {
}
/**
* @param {import("../Map.js").FrameState} frameState Frame state.
* @param {import("../layer/Layer.js").State} layerState Layer state.
*/
renderDeclutter(t, e) {
}
/**
* When the renderer follows a layout -> render approach, do the final rendering here.
* @param {import('../Map.js').FrameState} frameState Frame state
*/
renderDeferred(t) {
const e = this.getRenderer();
e && e.renderDeferred(t);
}
/**
* For use inside the library only.
* @param {import("../Map.js").default|null} map Map.
*/
setMapInternal(t) {
t || this.unrender(), this.set(M.MAP, t);
}
/**
* For use inside the library only.
* @return {import("../Map.js").default|null} Map.
*/
getMapInternal() {
return this.get(M.MAP);
}
/**
* Sets the layer to be rendered on top of other layers on a map. The map will
* not manage this layer in its layers collection. This
* is useful for temporary layers. To remove an unmanaged layer from the map,
* use `#setMap(null)`.
*
* To add the layer to a map and have it managed by the map, use
* {@link module:ol/Map~Map#addLayer} instead.
* @param {import("../Map.js").default|null} map Map.
* @api
*/
setMap(t) {
this.mapPrecomposeKey_ && (ft(this.mapPrecomposeKey_), this.mapPrecomposeKey_ = null), t || this.changed(), this.mapRenderKey_ && (ft(this.mapRenderKey_), this.mapRenderKey_ = null), t && (this.mapPrecomposeKey_ = Tt(
t,
jt.PRECOMPOSE,
this.handlePrecompose_,
this
), this.mapRenderKey_ = Tt(this, nt.CHANGE, t.render, t), this.changed());
}
/**
* @param {import("../events/Event.js").default} renderEvent Render event
* @private
*/
handlePrecompose_(t) {
const e = (
/** @type {import("../render/Event.js").default} */
t.frameState.layerStatesArray
), n = this.getLayerState(!1);
D(
!e.some(
(s) => s.layer === n.layer
),
"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."
), e.push(n);
}
/**
* Set the layer source.
* @param {SourceType|null} source The layer source.
* @observable
* @api
*/
setSource(t) {
this.set(M.SOURCE, t);
}
/**
* Get the renderer for this layer.
* @return {RendererType|null} The layer renderer.
*/
getRenderer() {
return this.renderer_ || (this.renderer_ = this.createRenderer()), this.renderer_;
}
/**
* @return {boolean} The layer has a renderer.
*/
hasRenderer() {
return !!this.renderer_;
}
/**
* Create a renderer for this layer.
* @return {RendererType} A layer renderer.
* @protected
*/
createRenderer() {
return null;
}
/**
* This will clear the renderer so that a new one can be created next time it is needed
*/
clearRenderer() {
this.renderer_ && (this.renderer_.dispose(), delete this.renderer_);
}
/**
* Clean up.
* @override
*/
disposeInternal() {
this.clearRenderer(), this.setSource(null), super.disposeInternal();
}
}
function No(i, t) {
if (!i.visible)
return !1;
const e = t.resolution;
if (e < i.minResolution || e >= i.maxResolution)
return !1;
const n = t.zoom;
return n > i.minZoom && n <= i.maxZoom;
}
function be(i, t, e, n) {
return `${i},${Ks(t, e, n)}`;
}
function Xe(i, t, e) {
if (!(e in i))
return i[e] = /* @__PURE__ */ new Set([t]), !0;
const n = i[e], s = n.has(t);
return s || n.add(t), !s;
}
function Go(i, t, e) {
const n = i[e];
return n ? n.delete(t) : !1;
}
function qn(i, t) {
const e = i.layerStatesArray[i.layerIndex];
e.extent && (t = Ot(
t,
yt(e.extent, i.viewState.projection)
));
const n = (
/** @type {import("../../source/Tile.js").default} */
e.layer.getRenderSource()
);
if (!n.getWrapX()) {
const s = n.getTileGridForProjection(i.viewState.projection).getExtent();
s && (t = Ot(t, s));
}
return t;
}
class Do extends Co {
/**
* @param {LayerType} tileLayer Tile layer.
* @param {Options} [options] Options.
*/
constructor(t, e) {
super(t), e = e || {}, this.extentChanged = !0, this.renderComplete = !1, this.renderedExtent_ = null, this.renderedPixelRatio, this.renderedProjection = null, this.renderedRevision_, this.renderedTiles = [], this.renderedSourceKey_, this.renderedSourceRevision_, this.tempExtent = Ct(), this.tempTileRange_ = new Qe(0, 0, 0, 0), this.tempTileCoord_ = ce(0, 0, 0);
const n = e.cacheSize !== void 0 ? e.cacheSize : 512;
this.tileCache_ = new ss(n), this.maxStaleKeys = n * 0.5;
}
/**
* @return {LRUCache} Tile cache.
*/
getTileCache() {
return this.tileCache_;
}
/**
* Get a tile from the cache or create one if needed.
*
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @return {import("../../Tile.js").default|null} Tile (or null if outside source extent).
* @protected
*/
getOrCreateTile(t, e, n, s) {
const r = this.tileCache_, a = this.getLayer().getSource(), l = be(a.getKey(), t, e, n);
let c;
if (r.containsKey(l))
c = r.get(l);
else {
if (c = a.getTile(
t,
e,
n,
s.pixelRatio,
s.viewState.projection
), !c)
return null;
r.set(l, c);
}
return c;
}
/**
* @param {number} z Tile coordinate z.
* @param {number} x Tile coordinate x.
* @param {number} y Tile coordinate y.
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @return {import("../../Tile.js").default|null} Tile (or null if outside source extent).
* @protected
*/
getTile(t, e, n, s) {
const r = this.getOrCreateTile(t, e, n, s);
return r || null;
}
/**
* @param {import("../../pixel.js").Pixel} pixel Pixel.
* @return {Uint8ClampedArray} Data at the pixel location.
* @override
*/
getData(t) {
const e = this.frameState;
if (!e)
return null;
const n = this.getLayer(), s = B(
e.pixelToCoordinateTransform,
t.slice()
), r = n.getExtent();
if (r && !Ue(r, s))
return null;
const o = e.viewState, a = n.getRenderSource(), l = a.getTileGridForProjection(o.projection), c = a.getTilePixelRatio(e.pixelRatio);
for (let h = l.getZForResolution(o.resolution); h >= l.getMinZoom(); --h) {
const u = l.getTileCoordForCoordAndZ(s, h), d = this.getTile(h, u[1], u[2], e);
if (!d || d.getState() !== x.LOADED)
continue;
const g = l.getOrigin(h), f = ut(l.getTileSize(h)), _ = l.getResolution(h);
let m;
if (d instanceof yi || d instanceof Ei)
m = d.getImage();
else if (d instanceof Kn) {
if (m = Ye(d.getData()), !m)
continue;
} else
continue;
const y = Math.floor(
c * ((s[0] - g[0]) / _ - u[1] * f[0])
), R = Math.floor(
c * ((g[1] - s[1]) / _ - u[2] * f[1])
), T = Math.round(
c * a.getGutterForProjection(o.projection)
);
return this.getImageData(m, y + T, R + T);
}
return null;
}
/**
* Determine whether render should be called.
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @return {boolean} Layer is ready to be rendered.
* @override
*/
prepareFrame(t) {
this.renderedProjection ? t.viewState.projection !== this.renderedProjection && (this.tileCache_.clear(), this.renderedProjection = t.viewState.projection) : this.renderedProjection = t.viewState.projection;
const e = this.getLayer().getSource();
if (!e)
return !1;
const n = e.getRevision();
return this.renderedRevision_ ? this.renderedRevision_ !== n && (this.renderedRevision_ = n, this.renderedSourceKey_ === e.getKey() && this.tileCache_.clear()) : this.renderedRevision_ = n, !0;
}
/**
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @param {import("../../extent.js").Extent} extent The extent to be rendered.
* @param {number} initialZ The zoom level.
* @param {TileLookup} tilesByZ Lookup of tiles by zoom level.
* @param {number} preload Number of additional levels to load.
*/
enqueueTiles(t, e, n, s, r) {
const o = t.viewState, a = this.getLayer(), l = a.getRenderSource(), c = l.getTileGridForProjection(o.projection), h = $(l);
h in t.wantedTiles || (t.wantedTiles[h] = {});
const u = t.wantedTiles[h], d = a.getMapInternal(), g = Math.max(
n - r,
c.getMinZoom(),
c.getZForResolution(
Math.min(
a.getMaxResolution(),
d ? d.getView().getResolutionForZoom(Math.max(a.getMinZoom(), 0)) : c.getResolution(0)
),
l.zDirection
)
), f = o.rotation, _ = f ? ei(
o.center,
o.resolution,
f,
t.size
) : void 0;
for (let m = n; m >= g; --m) {
const y = c.getTileRangeForExtentAndZ(
e,
m,
this.tempTileRange_
), R = c.getResolution(m);
for (let T = y.minX; T <= y.maxX; ++T)
for (let E = y.minY; E <= y.maxY; ++E) {
if (f && !c.tileCoordIntersectsViewport([m, T, E], _))
continue;
const p = this.getTile(m, T, E, t);
if (!p || !Xe(s, p, m))
continue;
const w = p.getKey();
if (u[w] = !0, p.getState() === x.IDLE && !t.tileQueue.isKeyQueued(w)) {
const I = ce(m, T, E, this.tempTileCoord_);
t.tileQueue.enqueue([
p,
h,
c.getTileCoordCenter(I),
R
]);
}
}
}
}
/**
* Look for tiles covering the provided tile coordinate at an alternate
* zoom level. Loaded tiles will be added to the provided tile texture lookup.
* @param {import("../../tilecoord.js").TileCoord} tileCoord The target tile coordinate.
* @param {TileLookup} tilesByZ Lookup of tiles by zoom level.
* @return {boolean} The tile coordinate is covered by loaded tiles at the alternate zoom level.
* @private
*/
findStaleTile_(t, e) {
const n = this.tileCache_, s = t[0], r = t[1], o = t[2], a = this.getStaleKeys();
for (let l = 0; l < a.length; ++l) {
const c = be(a[l], s, r, o);
if (n.containsKey(c)) {
const h = n.peek(c);
if (h.getState() === x.LOADED)
return h.endTransition($(this)), Xe(e, h, s), !0;
}
}
return !1;
}
/**
* Look for tiles covering the provided tile coordinate at an alternate
* zoom level. Loaded tiles will be added to the provided tile texture lookup.
* @param {import("../../tilegrid/TileGrid.js").default} tileGrid The tile grid.
* @param {import("../../tilecoord.js").TileCoord} tileCoord The target tile coordinate.
* @param {number} altZ The alternate zoom level.
* @param {TileLookup} tilesByZ Lookup of tiles by zoom level.
* @return {boolean} The tile coordinate is covered by loaded tiles at the alternate zoom level.
* @private
*/
findAltTiles_(t, e, n, s) {
const r = t.getTileRangeForTileCoordAndZ(
e,
n,
this.tempTileRange_
);
if (!r)
return !1;
let o = !0;
const a = this.tileCache_, c = this.getLayer().getRenderSource().getKey();
for (let h = r.minX; h <= r.maxX; ++h)
for (let u = r.minY; u <= r.maxY; ++u) {
const d = be(c, n, h, u);
let g = !1;
if (a.containsKey(d)) {
const f = a.peek(d);
f.getState() === x.LOADED && (Xe(s, f, n), g = !0);
}
g || (o = !1);
}
return o;
}
/**
* Render the layer.
*
* The frame rendering logic has three parts:
*
* 1. Enqueue tiles
* 2. Find alt tiles for those that are not yet loaded
* 3. Render loaded tiles
*
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @param {HTMLElement} target Target that may be used to render content to.
* @return {HTMLElement} The rendered element.
* @override
*/
renderFrame(t, e) {
this.renderComplete = !0;
const n = t.layerStatesArray[t.layerIndex], s = t.viewState, r = s.projection, o = s.resolution, a = s.center, l = t.pixelRatio, c = this.getLayer(), h = c.getSource(), u = h.getTileGridForProjection(r), d = u.getZForResolution(o, h.zDirection), g = u.getResolution(d), f = h.getKey();
this.renderedSourceKey_ ? this.renderedSourceKey_ !== f && (this.prependStaleKey(this.renderedSourceKey_), this.renderedSourceKey_ = f) : this.renderedSourceKey_ = f;
let _ = t.extent;
const m = h.getTilePixelRatio(l);
this.prepareContainer(t, e);
const y = this.context.canvas.width, R = this.context.canvas.height, T = n.extent && yt(n.extent);
T && (_ = Ot(
_,
yt(n.extent)
));
const E = g * y / 2 / m, p = g * R / 2 / m, S = [
a[0] - E,
a[1] - p,
a[0] + E,
a[1] + p
], w = {};
this.renderedTiles.length = 0;
const I = c.getPreload();
if (t.nextExtent) {
const A = u.getZForResolution(
s.nextResolution,
h.zDirection
), F = qn(t, t.nextExtent);
this.enqueueTiles(t, F, A, w, I);
}
const P = qn(t, _);
if (this.enqueueTiles(t, P, d, w, 0), I > 0 && setTimeout(() => {
this.enqueueTiles(
t,
P,
d - 1,
w,
I - 1
);
}, 0), !(d in w))
return this.container;
const b = $(this), X = t.time;
for (const A of w[d]) {
const F = A.getState();
if (F === x.EMPTY)
continue;
const U = A.tileCoord;
if (F === x.LOADED && A.getAlpha(b, X) === 1) {
A.endTransition(b);
continue;
}
if (F !== x.ERROR && (this.renderComplete = !1), this.findStaleTile_(U, w)) {
Go(w, A, d), t.animate = !0;
continue;
}
if (this.findAltTiles_(
u,
U,
d + 1,
w
))
continue;
const H = u.getMinZoom();
for (let et = d - 1; et >= H && !this.findAltTiles_(
u,
U,
et,
w
); --et)
;
}
const L = g / o * l / m, C = this.getRenderContext(t);
ue(
this.tempTransform,
y / 2,
R / 2,
L,
L,
0,
-y / 2,
-R / 2
), n.extent && this.clipUnrotated(C, t, T), h.getInterpolate() || (C.imageSmoothingEnabled = !1), this.preRender(C, t);
const Z = Object.keys(w).map(Number);
Z.sort(Je);
let N;
const tt = [], it = [];
for (let A = Z.length - 1; A >= 0; --A) {
const F = Z[A], U = h.getTilePixelSize(
F,
l,
r
), q = u.getResolution(F) / g, H = U[0] * q * L, et = U[1] * q * L, Q = u.getTileCoordForCoordAndZ(
Mt(S),
F
), st = u.getTileCoordExtent(Q), j = B(this.tempTransform, [
m * (st[0] - S[0]) / g,
m * (S[3] - st[3]) / g
]), mt = m * h.getGutterForProjection(r);
for (const rt of w[F]) {
if (rt.getState() !== x.LOADED)
continue;
const J = rt.tileCoord, un = Q[1] - J[1], vi = Math.round(j[0] - (un - 1) * H), dn = Q[2] - J[2], Pi = Math.round(j[1] - (dn - 1) * et), ot = Math.round(j[0] - un * H), at = Math.round(j[1] - dn * et), $t = vi - ot, qt = Pi - at, fn = Z.length === 1;
let xe = !1;
N = [ot, at, ot + $t, at, ot + $t, at + qt, ot, at + qt];
for (let Ht = 0, Ai = tt.length; Ht < Ai; ++Ht)
if (!fn && F < it[Ht]) {
const K = tt[Ht];
kt(
[ot, at, ot + $t, at + qt],
[K[0], K[3], K[4], K[7]]
) && (xe || (C.save(), xe = !0), C.beginPath(), C.moveTo(N[0], N[1]), C.lineTo(N[2], N[3]), C.lineTo(N[4], N[5]), C.lineTo(N[6], N[7]), C.moveTo(K[6], K[7]), C.lineTo(K[4], K[5]), C.lineTo(K[2], K[3]), C.lineTo(K[0], K[1]), C.clip());
}
tt.push(N), it.push(F), this.drawTile(rt, t, ot, at, $t, qt, mt, fn), xe && C.restore(), this.renderedTiles.unshift(rt), this.updateUsedTiles(t.usedTiles, h, rt);
}
}
if (this.renderedResolution = g, this.extentChanged = !this.renderedExtent_ || !Bi(this.renderedExtent_, S), this.renderedExtent_ = S, this.renderedPixelRatio = l, this.postRender(this.context, t), n.extent && C.restore(), C.imageSmoothingEnabled = !0, this.renderComplete) {
const A = (F, U) => {
const _t = $(h), q = U.wantedTiles[_t], H = q ? Object.keys(q).length : 0;
this.updateCacheSize(H), this.tileCache_.expireCache();
};
t.postRenderFunctions.push(A);
}
return this.container;
}
/**
* Increases the cache size if needed
* @param {number} tileCount Minimum number of tiles needed.
*/
updateCacheSize(t) {
this.tileCache_.highWaterMark = Math.max(
this.tileCache_.highWaterMark,
t * 2
);
}
/**
* @param {import("../../Tile.js").default} tile Tile.
* @param {import("../../Map.js").FrameState} frameState Frame state.
* @param {number} x Left of the tile.
* @param {number} y Top of the tile.
* @param {number} w Width of the tile.
* @param {number} h Height of the tile.
* @param {number} gutter Tile gutter.
* @param {boolean} transition Apply an alpha transition.
* @protected
*/
drawTile(t, e, n, s, r, o, a, l) {
let c;
if (t instanceof Kn) {
if (c = Ye(t.getData()), !c)
throw new Error("Rendering array data is not yet supported");
} else
c = this.getTileImage(
/** @type {import("../../ImageTile.js").default} */
t
);
if (!c)
return;
const h = this.getRenderContext(e), u = $(this), d = e.layerStatesArray[e.layerIndex], g = d.opacity * (l ? t.getAlpha(u, e.time) : 1), f = g !== h.globalAlpha;
f && (h.save(), h.globalAlpha = g), h.drawImage(
c,
a,
a,
c.width - 2 * a,
c.height - 2 * a,
n,
s,
r,
o
), f && h.restore(), g !== d.opacity ? e.animate = !0 : l && t.endTransition(u);
}
/**
* @return {HTMLCanvasElement} Image
*/
getImage() {
const t = this.context;
return t ? t.canvas : null;
}
/**
* Get the image from a tile.
* @param {import("../../ImageTile.js").default} tile Tile.
* @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
* @protected
*/
getTileImage(t) {
return t.getImage();
}
/**
* @param {!Object<string, !Object<string, boolean>>} usedTiles Used tiles.
* @param {import("../../source/Tile.js").default} tileSource Tile source.
* @param {import('../../Tile.js').default} tile Tile.
* @protected
*/
updateUsedTiles(t, e, n) {
const s = $(e);
s in t || (t[s] = {}), t[s][n.getKey()] = !0;
}
}
const ie = {
PRELOAD: "preload",
USE_INTERIM_TILES_ON_ERROR: "useInterimTilesOnError"
};
class zo extends Xo {
/**
* @param {Options<TileSourceType>} [options] Tile layer options.
*/
constructor(t) {
t = t || {};
const e = Object.assign({}, t), n = t.cacheSize;
delete t.cacheSize, delete e.preload, delete e.useInterimTilesOnError, super(e), this.on, this.once, this.un, this.cacheSize_ = n, this.setPreload(t.preload !== void 0 ? t.preload : 0), this.setUseInterimTilesOnError(
t.useInterimTilesOnError !== void 0 ? t.useInterimTilesOnError : !0
);
}
/**
* @return {number|undefined} The suggested cache size
* @protected
*/
getCacheSize() {
return this.cacheSize_;
}
/**
* Return the level as number to which we will preload tiles up to.
* @return {number} The level to preload tiles up to.
* @observable
* @api
*/
getPreload() {
return (
/** @type {number} */
this.get(ie.PRELOAD)
);
}
/**
* Set the level as number to which we will preload tiles up to.
* @param {number} preload The level to preload tiles up to.
* @observable
* @api
*/
setPreload(t) {
this.set(ie.PRELOAD, t);
}
/**
* Deprecated. Whether we use interim tiles on error.
* @return {boolean} Use interim tiles on error.
* @observable
* @api
*/
getUseInterimTilesOnError() {
return (
/** @type {boolean} */
this.get(ie.USE_INTERIM_TILES_ON_ERROR)
);
}
/**
* Deprecated. Set whether we use interim tiles on error.
* @param {boolean} useInterimTilesOnError Use interim tiles on error.
* @observable
* @api
*/
setUseInterimTilesOnError(t) {
this.set(ie.USE_INTERIM_TILES_ON_ERROR, t);
}
/**
* Get data for a pixel location. The return type depends on the source data. For image tiles,
* a four element RGBA array will be returned. For data tiles, the array length will match the
* number of bands in the dataset. For requests outside the layer extent, `null` will be returned.
* Data for a image tiles can only be retrieved if the source's `crossOrigin` property is set.
*
* ```js
* // display layer data on every pointer move
* map.on('pointermove', (event) => {
* console.log(layer.getData(event.pixel));
* });
* ```
* @param {import("../pixel").Pixel} pixel Pixel.
* @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data.
* @api
* @override
*/
getData(t) {
return super.getData(t);
}
}
class Zo extends zo {
/**
* @param {import("./BaseTile.js").Options<TileSourceType>} [options] Tile layer options.
*/
constructor(t) {
super(t);
}
/**
* @override
*/
createRenderer() {
return new Do(this, {
cacheSize: this.getCacheSize()
});
}
}
const jo = (i) => new Yi({
target: i,
// 目标容器的 ID
layers: [
new Zo({
source: new jr({
url: "https://webst01.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}"
})
})
],
view: new Ui({
center: [0, 0],
// 初始中心点
zoom: 2
// 初始缩放级别
})
}), Yo = (i, t) => {
const e = new t({ map: i }), n = e.getCesiumScene(), s = new Ki.UrlTemplateImageryProvider({
url: "https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}"
});
return n.imageryLayers.removeAll(), n.imageryLayers.addImageryProvider(s), n.globe.maximumScreenSpaceError = 3, n.globe.enableLighting = !0, n.fog.enabled = !1, n.skyAtmosphere.show = !0, e.setEnabled(!1), e;
}, Uo = { id: "map-container" }, Ko = /* @__PURE__ */ Li({
__name: "index",
setup(i) {
const t = _n(!1), e = _n("3D");
let n = null, s = null;
const r = () => {
t.value = !t.value, t.value ? (e.value = "2D", s == null || s.setEnabled(!0)) : (e.value = "3D", s == null || s.setEnabled(!1));
}, o = () => {
const l = js([73.4977, 18.1631, 135.0953, 53.5623], "EPSG:4326", "EPSG:3857");
n == null || n.getView().fit(l, {
padding: [20, 20, 20, 20],
duration: 1e3
});
};
return bi(() => {
n = jo("map-container");
const a = Xi();
a != null && a.proxy.$OLCesium && (s = Yo(n, a.proxy.$OLCesium)), o(), mn("map", n), mn("ol3d", s);
}), (a, l) => {
const c = Ni("el-button");
return Di(), Gi("div", Uo, [
Rn(c, {
class: "ol-switch",
onClick: l[0] || (l[0] = (h) => r())
}, {
default: zi(() => [
Zi(ji(e.value), 1)
]),
_: 1
}),
Rn(c, {
class: "ol-location",
onClick: o,
icon: "Position"
})
]);
};
}
}), Wo = (i, t) => {
const e = i.__vccOpts || i;
for (const [n, s] of t)
e[n] = s;
return e;
}, ko = /* @__PURE__ */ Wo(Ko, [["__scopeId", "data-v-454a3460"]]), Vo = (i) => {
i.component("GlobeView", ko);
}, Ho = {
install: Vo
};
export {
ko as GlobeView,
Ho as default,
Vo as install
};