1function qg(e) { 2 e("EPSG:4326", "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"), e("EPSG:4269", "+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"), e("EPSG:3857", "+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"), e.WGS84 = e["EPSG:4326"], e["EPSG:3785"] = e["EPSG:3857"], e.GOOGLE = e["EPSG:3857"], e["EPSG:900913"] = e["EPSG:3857"], e["EPSG:102113"] = e["EPSG:3857"]; 3} 4var xs = 1, vs = 2, Js = 3, Hg = 4, Qa = 5, oc = 6378137, Zg = 6356752314e-3, ac = 0.0066943799901413165, $n = 484813681109536e-20, A = Math.PI / 2, Jg = 0.16666666666666666, Qg = 0.04722222222222222, t_ = 0.022156084656084655, G = 1e-10, Vt = 0.017453292519943295, ki = 57.29577951308232, yt = Math.PI / 4, Jn = Math.PI * 2, Nt = 3.14159265359, Me = {}; 5Me.greenwich = 0; 6Me.lisbon = -9.131906111111; 7Me.paris = 2.337229166667; 8Me.bogota = -74.080916666667; 9Me.madrid = -3.687938888889; 10Me.rome = 12.452333333333; 11Me.bern = 7.439583333333; 12Me.jakarta = 106.807719444444; 13Me.ferro = -17.666666666667; 14Me.brussels = 4.367975; 15Me.stockholm = 18.058277777778; 16Me.athens = 23.7163375; 17Me.oslo = 10.722916666667; 18const e_ = { 19 ft: { to_meter: 0.3048 }, 20 "us-ft": { to_meter: 1200 / 3937 } 21}; 22var lc = /[\s_\-\/\(\)]/g; 23function qi(e, t) { 24 if (e[t]) 25 return e[t]; 26 for (var i = Object.keys(e), s = t.toLowerCase().replace(lc, ""), n = -1, r, o; ++n < i.length; ) 27 if (r = i[n], o = r.toLowerCase().replace(lc, ""), o === s) 28 return e[r]; 29} 30function tl(e) { 31 var t = {}, i = e.split("+").map(function(a) { 32 return a.trim(); 33 }).filter(function(a) { 34 return a; 35 }).reduce(function(a, l) { 36 var h = l.split("="); 37 return h.push(!0), a[h[0].toLowerCase()] = h[1], a; 38 }, {}), s, n, r, o = { 39 proj: "projName", 40 datum: "datumCode", 41 rf: function(a) { 42 t.rf = parseFloat(a); 43 }, 44 lat_0: function(a) { 45 t.lat0 = a * Vt; 46 }, 47 lat_1: function(a) { 48 t.lat1 = a * Vt; 49 }, 50 lat_2: function(a) { 51 t.lat2 = a * Vt; 52 }, 53 lat_ts: function(a) { 54 t.lat_ts = a * Vt; 55 }, 56 lon_0: function(a) { 57 t.long0 = a * Vt; 58 }, 59 lon_1: function(a) { 60 t.long1 = a * Vt; 61 }, 62 lon_2: function(a) { 63 t.long2 = a * Vt; 64 }, 65 alpha: function(a) { 66 t.alpha = parseFloat(a) * Vt; 67 }, 68 gamma: function(a) { 69 t.rectified_grid_angle = parseFloat(a); 70 }, 71 lonc: function(a) { 72 t.longc = a * Vt; 73 }, 74 x_0: function(a) { 75 t.x0 = parseFloat(a); 76 }, 77 y_0: function(a) { 78 t.y0 = parseFloat(a); 79 }, 80 k_0: function(a) { 81 t.k0 = parseFloat(a); 82 }, 83 k: function(a) { 84 t.k0 = parseFloat(a); 85 }, 86 a: function(a) { 87 t.a = parseFloat(a); 88 }, 89 b: function(a) { 90 t.b = parseFloat(a); 91 }, 92 r_a: function() { 93 t.R_A = !0; 94 }, 95 zone: function(a) { 96 t.zone = parseInt(a, 10); 97 }, 98 south: function() { 99 t.utmSouth = !0; 100 }, 101 towgs84: function(a) { 102 t.datum_params = a.split(",").map(function(l) { 103 return parseFloat(l); 104 }); 105 }, 106 to_meter: function(a) { 107 t.to_meter = parseFloat(a); 108 }, 109 units: function(a) { 110 t.units = a; 111 var l = qi(e_, a); 112 l && (t.to_meter = l.to_meter); 113 }, 114 from_greenwich: function(a) { 115 t.from_greenwich = a * Vt; 116 }, 117 pm: function(a) { 118 var l = qi(Me, a); 119 t.from_greenwich = (l || parseFloat(a)) * Vt; 120 }, 121 nadgrids: function(a) { 122 a === "@null" ? t.datumCode = "none" : t.nadgrids = a; 123 }, 124 axis: function(a) { 125 var l = "ewnsud"; 126 a.length === 3 && l.indexOf(a.substr(0, 1)) !== -1 && l.indexOf(a.substr(1, 1)) !== -1 && l.indexOf(a.substr(2, 1)) !== -1 && (t.axis = a); 127 }, 128 approx: function() { 129 t.approx = !0; 130 } 131 }; 132 for (s in i) 133 n = i[s], s in o ? (r = o[s], typeof r == "function" ? r(n) : t[r] = n) : t[s] = n; 134 return typeof t.datumCode == "string" && t.datumCode !== "WGS84" && (t.datumCode = t.datumCode.toLowerCase()), t; 135}
136var Qn = 1, sd = 2, nd = 3, yo = 4, rd = 5, kl = -1, i_ = /\s/, s_ = /[A-Za-z]/, n_ = /[A-Za-z84_]/, Yo = /[,\]]/, od = /[\d\.E\-\+]/; 137function Mi(e) { 138 if (typeof e != "string") 139 throw new Error("not a string"); 140 this.text = e.trim(), this.level = 0, this.place = 0, this.root = null, this.stack = [], this.currentObject = null, this.state = Qn; 141} 142Mi.prototype.readCharicter = function() { 143 var e = this.text[this.place++]; 144 if (this.state !== yo) 145 for (; i_.test(e); ) { 146 if (this.place >= this.text.length) 147 return; 148 e = this.text[this.place++]; 149 } 150 switch (this.state) { 151 case Qn: 152 return this.neutral(e); 153 case sd: 154 return this.keyword(e); 155 case yo: 156 return this.quoted(e); 157 case rd: 158 return this.afterquote(e); 159 case nd: 160 return this.number(e); 161 case kl: 162 return; 163 } 164}; 165Mi.prototype.afterquote = function(e) { 166 if (e === '"') { 167 this.word += '"', this.state = yo; 168 return; 169 } 170 if (Yo.test(e)) { 171 this.word = this.word.trim(), this.afterItem(e); 172 return; 173 } 174 throw new Error(`havn't handled "` + e + '" in afterquote yet, index ' + this.place); 175}; 176Mi.prototype.afterItem = function(e) { 177 if (e === ",") { 178 this.word !== null && this.currentObject.push(this.word), this.word = null, this.state = Qn; 179 return; 180 } 181 if (e === "]") { 182 this.level--, this.word !== null && (this.currentObject.push(this.word), this.word = null), this.state = Qn, this.currentObject = this.stack.pop(), this.currentObject || (this.state = kl); 183 return; 184 } 185}; 186Mi.prototype.number = function(e) { 187 if (od.test(e)) { 188 this.word += e; 189 return; 190 } 191 if (Yo.test(e)) { 192 this.word = parseFloat(this.word), this.afterItem(e); 193 return; 194 } 195 throw new Error(`havn't handled "` + e + '" in number yet, index ' + this.place); 196}; 197Mi.prototype.quoted = function(e) { 198 if (e === '"') { 199 this.state = rd; 200 return; 201 } 202 this.word += e; 203}; 204Mi.prototype.keyword = function(e) { 205 if (n_.test(e)) { 206 this.word += e; 207 return; 208 } 209 if (e === "[") { 210 var t = []; 211 t.push(this.word), this.level++, this.root === null ? this.root = t : this.currentObject.push(t), this.stack.push(this.currentObject), this.currentObject = t, this.state = Qn; 212 return; 213 } 214 if (Yo.test(e)) { 215 this.afterItem(e); 216 return; 217 } 218 throw new Error(`havn't handled "` + e + '" in keyword yet, index ' + this.place); 219}; 220Mi.prototype.neutral = function(e) { 221 if (s_.test(e)) { 222 this.word = e, this.state = sd; 223 return; 224 } 225 if (e === '"') { 226 this.word = "", this.state = yo; 227 return; 228 } 229 if (od.test(e)) { 230 this.word = e, this.state = nd; 231 return; 232 } 233 if (Yo.test(e)) { 234 this.afterItem(e); 235 return; 236 } 237 throw new Error(`havn't handled "` + e + '" in neutral yet, index ' + this.place); 238}; 239Mi.prototype.output = function() { 240 for (; this.place < this.text.length; ) 241 this.readCharicter(); 242 if (this.state === kl) 243 return this.root; 244 throw new Error('unable to parse string "' + this.text + '". State is ' + this.state); 245}; 246function r_(e) { 247 var t = new Mi(e); 248 return t.output(); 249} 250function hc(e, t, i) { 251 Array.isArray(t) && (i.unshift(t), t = null); 252 var s = t ? {} : e, n = i.reduce(function(r, o) { 253 return Us(o, r), r; 254 }, s); 255 t && (e[t] = n); 256} 257function Us(e, t) { 258 if (!Array.isArray(e)) { 259 t[e] = !0; 260 return; 261 } 262 var i = e.shift(); 263 if (i === "PARAMETER" && (i = e.shift()), e.length === 1) { 264 if (Array.isArray(e[0])) { 265 t[i] = {}, Us(e[0], t[i]); 266 return; 267 } 268 t[i] = e[0]; 269 return; 270 } 271 if (!e.length) { 272 t[i] = !0; 273 return; 274 } 275 if (i === "TOWGS84") { 276 t[i] = e; 277 return; 278 } 279 if (i === "AXIS") { 280 i in t || (t[i] = []), t[i].push(e); 281 return; 282 } 283 Array.isArray(i) || (t[i] = {}); 284 var s; 285 switch (i) { 286 case "UNIT": 287 case "PRIMEM": 288 case "VERT_DATUM": 289 t[i] = { 290 name: e[0].toLowerCase(), 291 convert: e[1] 292 }, e.length === 3 && Us(e[2], t[i]); 293 return; 294 case "SPHEROID": 295 case "ELLIPSOID": 296 t[i] = { 297 name: e[0], 298 a: e[1], 299 rf: e[2] 300 }, e.length === 4 && Us(e[3], t[i]); 301 return;
302 case "PROJECTEDCRS": 303 case "PROJCRS": 304 case "GEOGCS": 305 case "GEOCCS": 306 case "PROJCS": 307 case "LOCAL_CS": 308 case "GEODCRS": 309 case "GEODETICCRS": 310 case "GEODETICDATUM": 311 case "EDATUM": 312 case "ENGINEERINGDATUM": 313 case "VERT_CS": 314 case "VERTCRS": 315 case "VERTICALCRS": 316 case "COMPD_CS": 317 case "COMPOUNDCRS": 318 case "ENGINEERINGCRS": 319 case "ENGCRS": 320 case "FITTED_CS": 321 case "LOCAL_DATUM": 322 case "DATUM": 323 e[0] = ["name", e[0]], hc(t, i, e); 324 return; 325 default: 326 for (s = -1; ++s < e.length; ) 327 if (!Array.isArray(e[s])) 328 return Us(e, t[i]); 329 return hc(t, i, e); 330 } 331} 332var o_ = 0.017453292519943295; 333function a_(e, t) { 334 var i = t[0], s = t[1]; 335 !(i in e) && s in e && (e[i] = e[s], t.length === 3 && (e[i] = t[2](e[i]))); 336} 337function Xe(e) { 338 return e * o_; 339} 340function l_(e) { 341 if (e.type === "GEOGCS" ? e.projName = "longlat" : e.type === "LOCAL_CS" ? (e.projName = "identity", e.local = !0) : typeof e.PROJECTION == "object" ? e.projName = Object.keys(e.PROJECTION)[0] : e.projName = e.PROJECTION, e.AXIS) { 342 for (var t = "", i = 0, s = e.AXIS.length; i < s; ++i) { 343 var n = [e.AXIS[i][0].toLowerCase(), e.AXIS[i][1].toLowerCase()]; 344 n[0].indexOf("north") !== -1 || (n[0] === "y" || n[0] === "lat") && n[1] === "north" ? t += "n" : n[0].indexOf("south") !== -1 || (n[0] === "y" || n[0] === "lat") && n[1] === "south" ? t += "s" : n[0].indexOf("east") !== -1 || (n[0] === "x" || n[0] === "lon") && n[1] === "east" ? t += "e" : (n[0].indexOf("west") !== -1 || (n[0] === "x" || n[0] === "lon") && n[1] === "west") && (t += "w"); 345 } 346 t.length === 2 && (t += "u"), t.length === 3 && (e.axis = t); 347 } 348 e.UNIT && (e.units = e.UNIT.name.toLowerCase(), e.units === "metre" && (e.units = "meter"), e.UNIT.convert && (e.type === "GEOGCS" ? e.DATUM && e.DATUM.SPHEROID && (e.to_meter = e.UNIT.convert * e.DATUM.SPHEROID.a) : e.to_meter = e.UNIT.convert)); 349 var r = e.GEOGCS; 350 e.type === "GEOGCS" && (r = e), r && (r.DATUM ? e.datumCode = r.DATUM.name.toLowerCase() : e.datumCode = r.name.toLowerCase(), e.datumCode.slice(0, 2) === "d_" && (e.datumCode = e.datumCode.slice(2)), (e.datumCode === "new_zealand_geodetic_datum_1949" || e.datumCode === "new_zealand_1949") && (e.datumCode = "nzgd49"), (e.datumCode === "wgs_1984" || e.datumCode === "world_geodetic_system_1984") && (e.PROJECTION === "Mercator_Auxiliary_Sphere" && (e.sphere = !0), e.datumCode = "wgs84"), e.datumCode.slice(-6) === "_ferro" && (e.datumCode = e.datumCode.slice(0, -6)), e.datumCode.slice(-8) === "_jakarta" && (e.datumCode = e.datumCode.slice(0, -8)), ~e.datumCode.indexOf("belge") && (e.datumCode = "rnb72"), r.DATUM && r.DATUM.SPHEROID && (e.ellps = r.DATUM.SPHEROID.name.replace("_19", "").replace(/[Cc]larke\_18/, "clrk"), e.ellps.toLowerCase().slice(0, 13) === "international" && (e.ellps = "intl"), e.a = r.DATUM.SPHEROID.a, e.rf = parseFloat(r.DATUM.SPHEROID.rf, 10)), r.DATUM && r.DATUM.TOWGS84 && (e.datum_params = r.DATUM.TOWGS84), ~e.datumCode.indexOf("osgb_1936") && (e.datumCode = "osgb36"), ~e.datumCode.indexOf("osni_1952") && (e.datumCode = "osni52"), (~e.datumCode.indexOf("tm65") || ~e.datumCode.indexOf("geodetic_datum_of_1965")) && (e.datumCode = "ire65"), e.datumCode === "ch1903+" && (e.datumCode = "ch1903"), ~e.datumCode.indexOf("israel") && (e.datumCode = "isr93")), e.b && !isFinite(e.b) && (e.b = e.a); 351 function o(h) { 352 var c = e.to_meter || 1; 353 return h * c; 354 } 355 var a = function(h) { 356 return a_(e, h); 357 }, l = [ 358 ["standard_parallel_1", "Standard_Parallel_1"], 359 ["standard_parallel_1", "Latitude of 1st standard parallel"], 360 ["standard_parallel_2", "Standard_Parallel_2"], 361 ["standard_parallel_2", "Latitude of 2nd standard parallel"], 362 ["false_easting", "False_Easting"], 363 ["false_easting", "False easting"], 364 ["false-easting", "Easting at false origin"], 365 ["false_northing", "False_Northing"], 366 ["false_northing", "False northing"], 367 ["false_northing", "Northing at false origin"], 368 ["central_meridian", "Central_Meridian"], 369 ["central_meridian", "Longitude of natural origin"], 370 ["central_meridian", "Longitude of false origin"], 371 ["latitude_of_origin", "Latitude_Of_Origin"], 372 ["latitude_of_origin", "Central_Parallel"], 373 ["latitude_of_origin", "Latitude of natural origin"], 374 ["latitude_of_origin", "Latitude of false origin"], 375 ["scale_factor", "Scale_Factor"], 376 ["k0", "scale_factor"], 377 ["latitude_of_center", "Latitude_Of_Center"], 378 ["latitude_of_center", "Latitude_of_center"], 379 ["lat0", "latitude_of_center", Xe], 380 ["longitude_of_center", "Longitude_Of_Center"], 381 ["longitude_of_center", "Longitude_of_center"], 382 ["longc", "longitude_of_center", Xe], 383 ["x0", "false_easting", o], 384 ["y0", "false_northing", o], 385 ["long0", "central_meridian", Xe],
386 ["lat0", "latitude_of_origin", Xe], 387 ["lat0", "standard_parallel_1", Xe], 388 ["lat1", "standard_parallel_1", Xe], 389 ["lat2", "standard_parallel_2", Xe], 390 ["azimuth", "Azimuth"], 391 ["alpha", "azimuth", Xe], 392 ["srsCode", "name"] 393 ]; 394 l.forEach(a), !e.long0 && e.longc && (e.projName === "Albers_Conic_Equal_Area" || e.projName === "Lambert_Azimuthal_Equal_Area") && (e.long0 = e.longc), !e.lat_ts && e.lat1 && (e.projName === "Stereographic_South_Pole" || e.projName === "Polar Stereographic (variant B)") ? (e.lat0 = Xe(e.lat1 > 0 ? 90 : -90), e.lat_ts = e.lat1) : !e.lat_ts && e.lat0 && e.projName === "Polar_Stereographic" && (e.lat_ts = e.lat0, e.lat0 = Xe(e.lat0 > 0 ? 90 : -90)); 395} 396function ad(e) { 397 var t = r_(e), i = t.shift(), s = t.shift(); 398 t.unshift(["name", s]), t.unshift(["type", i]); 399 var n = {}; 400 return Us(t, n), l_(n), n; 401} 402function he(e) { 403 var t = this; 404 if (arguments.length === 2) { 405 var i = arguments[1]; 406 typeof i == "string" ? i.charAt(0) === "+" ? he[e] = tl(arguments[1]) : he[e] = ad(arguments[1]) : he[e] = i; 407 } else if (arguments.length === 1) { 408 if (Array.isArray(e)) 409 return e.map(function(s) { 410 Array.isArray(s) ? he.apply(t, s) : he(s); 411 }); 412 if (typeof e == "string") { 413 if (e in he) 414 return he[e]; 415 } else 416 "EPSG" in e ? he["EPSG:" + e.EPSG] = e : "ESRI" in e ? he["ESRI:" + e.ESRI] = e : "IAU2000" in e && (he["IAU2000:" + e.IAU2000] = e); 417 return; 418 } 419} 420qg(he); 421function h_(e) { 422 return typeof e == "string"; 423} 424function c_(e) { 425 return e in he; 426} 427var u_ = ["PROJECTEDCRS", "PROJCRS", "GEOGCS", "GEOCCS", "PROJCS", "LOCAL_CS", "GEODCRS", "GEODETICCRS", "GEODETICDATUM", "ENGCRS", "ENGINEERINGCRS"]; 428function d_(e) { 429 return u_.some(function(t) { 430 return e.indexOf(t) > -1; 431 }); 432} 433var f_ = ["3857", "900913", "3785", "102113"]; 434function g_(e) { 435 var t = qi(e, "authority"); 436 if (t) { 437 var i = qi(t, "epsg"); 438 return i && f_.indexOf(i) > -1; 439 } 440} 441function __(e) { 442 var t = qi(e, "extension"); 443 if (t) 444 return qi(t, "proj4"); 445} 446function m_(e) { 447 return e[0] === "+"; 448} 449function p_(e) { 450 if (h_(e)) { 451 if (c_(e)) 452 return he[e]; 453 if (d_(e)) { 454 var t = ad(e); 455 if (g_(t)) 456 return he["EPSG:3857"]; 457 var i = __(t); 458 return i ? tl(i) : t; 459 } 460 if (m_(e)) 461 return tl(e); 462 } else 463 return e; 464} 465function cc(e, t) { 466 e = e || {}; 467 var i, s; 468 if (!t) 469 return e; 470 for (s in t) 471 i = t[s], i !== void 0 && (e[s] = i); 472 return e; 473} 474function ti(e, t, i) { 475 var s = e * t; 476 return i / Math.sqrt(1 - s * s); 477} 478function xr(e) { 479 return e < 0 ? -1 : 1; 480} 481function U(e) { 482 return Math.abs(e) <= Nt ? e : e - xr(e) * Jn; 483} 484function ze(e, t, i) { 485 var s = e * i, n = 0.5 * e; 486 return s = Math.pow((1 - s) / (1 + s), n), Math.tan(0.5 * (A - t)) / s; 487} 488function tr(e, t) { 489 for (var i = 0.5 * e, s, n, r = A - 2 * Math.atan(t), o = 0; o <= 15; o++) 490 if (s = e * Math.sin(r), n = A - 2 * Math.atan(t * Math.pow((1 - s) / (1 + s), i)) - r, r += n, Math.abs(n) <= 1e-10) 491 return r; 492 return -9999; 493} 494function y_() { 495 var e = this.b / this.a; 496 this.es = 1 - e * e, "x0" in this || (this.x0 = 0), "y0" in this || (this.y0 = 0), this.e = Math.sqrt(this.es), this.lat_ts ? this.sphere ? this.k0 = Math.cos(this.lat_ts) : this.k0 = ti(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)) : this.k0 || (this.k ? this.k0 = this.k : this.k0 = 1); 497} 498function x_(e) { 499 var t = e.x, i = e.y; 500 if (i * ki > 90 && i * ki < -90 && t * ki > 180 && t * ki < -180) 501 return null; 502 var s, n; 503 if (Math.abs(Math.abs(i) - A) <= G) 504 return null; 505 if (this.sphere) 506 s = this.x0 + this.a * this.k0 * U(t - this.long0), n = this.y0 + this.a * this.k0 * Math.log(Math.tan(yt + 0.5 * i)); 507 else { 508 var r = Math.sin(i), o = ze(this.e, i, r); 509 s = this.x0 + this.a * this.k0 * U(t - this.long0), n = this.y0 - this.a * this.k0 * Math.log(o); 510 } 511 return e.x = s, e.y = n, e; 512} 513function v_(e) { 514 var t = e.x - this.x0, i = e.y - this.y0, s, n; 515 if (this.sphere) 516 n = A - 2 * Math.atan(Math.exp(-i / (this.a * this.k0))); 517 else { 518 var r = Math.exp(-i / (this.a * this.k0)); 519 if (n = tr(this.e, r), n === -9999) 520 return null; 521 } 522 return s = U(this.long0 + t / (this.a * this.k0)), e.x = s, e.y = n, e; 523} 524var E_ = ["Mercator", "Popular Visualisation Pseudo Mercator", "Mercator_1SP", "Mercator_Auxiliary_Sphere", "merc"]; 525const M_ = { 526 init: y_, 527 forward: x_, 528 inverse: v_, 529 names: E_ 530}; 531function C_() { 532} 533function uc(e) { 534 return e; 535} 536var b_ = ["longlat", "identity"]; 537const S_ = { 538 init: C_, 539 forward: uc, 540 inverse: uc, 541 names: b_ 542}; 543var w_ = [M_, S_], lo = {}, xo = []; 544function ld(e, t) { 545 var i = xo.length;
546 return e.names ? (xo[i] = e, e.names.forEach(function(s) { 547 lo[s.toLowerCase()] = i; 548 }), this) : !0; 549} 550function T_(e) { 551 if (!e) 552 return !1; 553 var t = e.toLowerCase(); 554 if (typeof lo[t] < "u" && xo[lo[t]]) 555 return xo[lo[t]]; 556} 557function R_() { 558 w_.forEach(ld); 559} 560const I_ = { 561 start: R_, 562 add: ld, 563 get: T_ 564}; 565var st = {}; 566st.MERIT = { 567 a: 6378137, 568 rf: 298.257, 569 ellipseName: "MERIT 1983" 570}; 571st.SGS85 = { 572 a: 6378136, 573 rf: 298.257, 574 ellipseName: "Soviet Geodetic System 85" 575}; 576st.GRS80 = { 577 a: 6378137, 578 rf: 298.257222101, 579 ellipseName: "GRS 1980(IUGG, 1980)" 580}; 581st.IAU76 = { 582 a: 6378140, 583 rf: 298.257, 584 ellipseName: "IAU 1976" 585}; 586st.airy = { 587 a: 6377563396e-3, 588 b: 635625691e-2, 589 ellipseName: "Airy 1830" 590}; 591st.APL4 = { 592 a: 6378137, 593 rf: 298.25, 594 ellipseName: "Appl. Physics. 1965" 595}; 596st.NWL9D = { 597 a: 6378145, 598 rf: 298.25, 599 ellipseName: "Naval Weapons Lab., 1965" 600}; 601st.mod_airy = { 602 a: 6377340189e-3, 603 b: 6356034446e-3, 604 ellipseName: "Modified Airy" 605}; 606st.andrae = { 607 a: 637710443e-2, 608 rf: 300, 609 ellipseName: "Andrae 1876 (Den., Iclnd.)" 610}; 611st.aust_SA = { 612 a: 6378160, 613 rf: 298.25, 614 ellipseName: "Australian Natl & S. Amer. 1969" 615}; 616st.GRS67 = { 617 a: 6378160, 618 rf: 298.247167427, 619 ellipseName: "GRS 67(IUGG 1967)" 620}; 621st.bessel = { 622 a: 6377397155e-3, 623 rf: 299.1528128, 624 ellipseName: "Bessel 1841" 625}; 626st.bess_nam = { 627 a: 6377483865e-3, 628 rf: 299.1528128, 629 ellipseName: "Bessel 1841 (Namibia)" 630}; 631st.clrk66 = { 632 a: 63782064e-1, 633 b: 63565838e-1, 634 ellipseName: "Clarke 1866" 635}; 636st.clrk80 = { 637 a: 6378249145e-3, 638 rf: 293.4663, 639 ellipseName: "Clarke 1880 mod." 640}; 641st.clrk80ign = { 642 a: 63782492e-1, 643 b: 6356515, 644 rf: 293.4660213, 645 ellipseName: "Clarke 1880 (IGN)" 646}; 647st.clrk58 = { 648 a: 6378293645208759e-9, 649 rf: 294.2606763692654, 650 ellipseName: "Clarke 1858" 651}; 652st.CPM = { 653 a: 63757387e-1, 654 rf: 334.29, 655 ellipseName: "Comm. des Poids et Mesures 1799" 656}; 657st.delmbr = { 658 a: 6376428, 659 rf: 311.5, 660 ellipseName: "Delambre 1810 (Belgium)" 661}; 662st.engelis = { 663 a: 637813605e-2, 664 rf: 298.2566, 665 ellipseName: "Engelis 1985" 666}; 667st.evrst30 = { 668 a: 6377276345e-3, 669 rf: 300.8017, 670 ellipseName: "Everest 1830" 671}; 672st.evrst48 = { 673 a: 6377304063e-3, 674 rf: 300.8017, 675 ellipseName: "Everest 1948" 676}; 677st.evrst56 = { 678 a: 6377301243e-3, 679 rf: 300.8017, 680 ellipseName: "Everest 1956" 681}; 682st.evrst69 = { 683 a: 6377295664e-3, 684 rf: 300.8017, 685 ellipseName: "Everest 1969" 686}; 687st.evrstSS = { 688 a: 6377298556e-3, 689 rf: 300.8017, 690 ellipseName: "Everest (Sabah & Sarawak)" 691}; 692st.fschr60 = { 693 a: 6378166, 694 rf: 298.3, 695 ellipseName: "Fischer (Mercury Datum) 1960" 696}; 697st.fschr60m = { 698 a: 6378155, 699 rf: 298.3, 700 ellipseName: "Fischer 1960" 701}; 702st.fschr68 = { 703 a: 6378150, 704 rf: 298.3, 705 ellipseName: "Fischer 1968" 706}; 707st.helmert = { 708 a: 6378200, 709 rf: 298.3, 710 ellipseName: "Helmert 1906" 711}; 712st.hough = { 713 a: 6378270, 714 rf: 297, 715 ellipseName: "Hough" 716}; 717st.intl = { 718 a: 6378388, 719 rf: 297, 720 ellipseName: "International 1909 (Hayford)" 721}; 722st.kaula = { 723 a: 6378163, 724 rf: 298.24, 725 ellipseName: "Kaula 1961" 726}; 727st.lerch = { 728 a: 6378139, 729 rf: 298.257, 730 ellipseName: "Lerch 1979" 731}; 732st.mprts = { 733 a: 6397300, 734 rf: 191, 735 ellipseName: "Maupertius 1738" 736}; 737st.new_intl = { 738 a: 63781575e-1, 739 b: 63567722e-1, 740 ellipseName: "New International 1967" 741}; 742st.plessis = { 743 a: 6376523, 744 rf: 6355863, 745 ellipseName: "Plessis 1817 (France)" 746}; 747st.krass = { 748 a: 6378245, 749 rf: 298.3, 750 ellipseName: "Krassovsky, 1942" 751}; 752st.SEasia = { 753 a: 6378155, 754 b: 63567733205e-4, 755 ellipseName: "Southeast Asia" 756}; 757st.walbeck = { 758 a: 6376896, 759 b: 63558348467e-4, 760 ellipseName: "Walbeck" 761}; 762st.WGS60 = { 763 a: 6378165, 764 rf: 298.3, 765 ellipseName: "WGS 60" 766}; 767st.WGS66 = { 768 a: 6378145, 769 rf: 298.25, 770 ellipseName: "WGS 66" 771}; 772st.WGS7 = { 773 a: 6378135, 774 rf: 298.26, 775 ellipseName: "WGS 72" 776}; 777var P_ = st.WGS84 = { 778 a: 6378137, 779 rf: 298.257223563, 780 ellipseName: "WGS 84" 781}; 782st.sphere = { 783 a: 6370997, 784 b: 6370997, 785 ellipseName: "Normal Sphere (r=6370997)" 786}; 787function A_(e, t, i, s) { 788 var n = e * e, r = t * t, o = (n - r) / n, a = 0; 789 s ? (e *= 1 - o * (Jg + o * (Qg + o * t_)), n = e * e, o = 0) : a = Math.sqrt(o); 790 var l = (n - r) / r; 791 return { 792 es: o, 793 e: a, 794 ep2: l 795 }; 796} 797function L_(e, t, i, s, n) { 798 if (!e) { 799 var r = qi(st, s); 800 r || (r = P_), e = r.a, t = r.b, i = r.rf; 801 } 802 return i && !t && (t = (1 - 1 / i) * e), (i === 0 || Math.abs(e - t) < G) && (n = !0, t = e), { 803 a: e, 804 b: t, 805 rf: i, 806 sphere: n 807 }; 808} 809var Kt = {}; 810Kt.wgs84 = { 811 towgs84: "0,0,0", 812 ellipse: "WGS84", 813 datumName: "WGS84" 814}; 815Kt.ch1903 = { 816 towgs84: "674.374,15.056,405.346", 817 ellipse: "bessel", 818 datumName: "swiss" 819}; 820Kt.ggrs87 = { 821 towgs84: "-199.87,74.79,246.62", 822 ellipse: "GRS80", 823 datumName: "Greek_Geodetic_Reference_System_1987" 824}; 825Kt.nad83 = { 826 towgs84: "0,0,0", 827 ellipse: "GRS80", 828 datumName: "North_American_Datum_1983" 829}; 830Kt.nad27 = { 831 nadgrids: "@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat", 832 ellipse: "clrk66", 833 datumName: "North_American_Datum_1927" 834};
835Kt.potsdam = { 836 towgs84: "598.1,73.7,418.2,0.202,0.045,-2.455,6.7", 837 ellipse: "bessel", 838 datumName: "Potsdam Rauenberg 1950 DHDN" 839}; 840Kt.carthage = { 841 towgs84: "-263.0,6.0,431.0", 842 ellipse: "clark80", 843 datumName: "Carthage 1934 Tunisia" 844}; 845Kt.hermannskogel = { 846 towgs84: "577.326,90.129,463.919,5.137,1.474,5.297,2.4232", 847 ellipse: "bessel", 848 datumName: "Hermannskogel" 849}; 850Kt.osni52 = { 851 towgs84: "482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15", 852 ellipse: "airy", 853 datumName: "Irish National" 854}; 855Kt.ire65 = { 856 towgs84: "482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15", 857 ellipse: "mod_airy", 858 datumName: "Ireland 1965" 859}; 860Kt.rassadiran = { 861 towgs84: "-133.63,-157.5,-158.62", 862 ellipse: "intl", 863 datumName: "Rassadiran" 864}; 865Kt.nzgd49 = { 866 towgs84: "59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993", 867 ellipse: "intl", 868 datumName: "New Zealand Geodetic Datum 1949" 869}; 870Kt.osgb36 = { 871 towgs84: "446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894", 872 ellipse: "airy", 873 datumName: "Airy 1830" 874}; 875Kt.s_jtsk = { 876 towgs84: "589,76,480", 877 ellipse: "bessel", 878 datumName: "S-JTSK (Ferro)" 879}; 880Kt.beduaram = { 881 towgs84: "-106,-87,188", 882 ellipse: "clrk80", 883 datumName: "Beduaram" 884}; 885Kt.gunung_segara = { 886 towgs84: "-403,684,41", 887 ellipse: "bessel", 888 datumName: "Gunung Segara Jakarta" 889}; 890Kt.rnb72 = { 891 towgs84: "106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1", 892 ellipse: "intl", 893 datumName: "Reseau National Belge 1972" 894}; 895function O_(e, t, i, s, n, r, o) { 896 var a = {}; 897 return e === void 0 || e === "none" ? a.datum_type = Qa : a.datum_type = Hg, t && (a.datum_params = t.map(parseFloat), (a.datum_params[0] !== 0 || a.datum_params[1] !== 0 || a.datum_params[2] !== 0) && (a.datum_type = xs), a.datum_params.length > 3 && (a.datum_params[3] !== 0 || a.datum_params[4] !== 0 || a.datum_params[5] !== 0 || a.datum_params[6] !== 0) && (a.datum_type = vs, a.datum_params[3] *= $n, a.datum_params[4] *= $n, a.datum_params[5] *= $n, a.datum_params[6] = a.datum_params[6] / 1e6 + 1)), o && (a.datum_type = Js, a.grids = o), a.a = i, a.b = s, a.es = n, a.ep2 = r, a; 898} 899var hd = {}; 900function F_(e, t) { 901 var i = new DataView(t), s = k_(i), n = G_(i, s); 902 n.nSubgrids > 1; 903 var r = z_(i, n, s), o = { header: n, subgrids: r }; 904 return hd[e] = o, o; 905} 906function D_(e) { 907 if (e === void 0) 908 return null; 909 var t = e.split(","); 910 return t.map(N_); 911} 912function N_(e) { 913 if (e.length === 0) 914 return null; 915 var t = e[0] === "@"; 916 return t && (e = e.slice(1)), e === "null" ? { name: "null", mandatory: !t, grid: null, isNull: !0 } : { 917 name: e, 918 mandatory: !t, 919 grid: hd[e] || null, 920 isNull: !1 921 }; 922} 923function Xs(e) { 924 return e / 3600 * Math.PI / 180; 925} 926function k_(e) { 927 var t = e.getInt32(8, !1); 928 return t === 11 ? !1 : (t = e.getInt32(8, !0), !0); 929} 930function G_(e, t) { 931 return { 932 nFields: e.getInt32(8, t), 933 nSubgridFields: e.getInt32(24, t), 934 nSubgrids: e.getInt32(40, t), 935 shiftType: el(e, 56, 56 + 8).trim(), 936 fromSemiMajorAxis: e.getFloat64(120, t), 937 fromSemiMinorAxis: e.getFloat64(136, t), 938 toSemiMajorAxis: e.getFloat64(152, t), 939 toSemiMinorAxis: e.getFloat64(168, t) 940 }; 941} 942function el(e, t, i) { 943 return String.fromCharCode.apply(null, new Uint8Array(e.buffer.slice(t, i))); 944} 945function z_(e, t, i) { 946 for (var s = 176, n = [], r = 0; r < t.nSubgrids; r++) { 947 var o = W_(e, s, i), a = B_(e, s, o, i), l = Math.round( 948 1 + (o.upperLongitude - o.lowerLongitude) / o.longitudeInterval 949 ), h = Math.round( 950 1 + (o.upperLatitude - o.lowerLatitude) / o.latitudeInterval 951 ); 952 n.push({ 953 ll: [Xs(o.lowerLongitude), Xs(o.lowerLatitude)], 954 del: [Xs(o.longitudeInterval), Xs(o.latitudeInterval)], 955 lim: [l, h], 956 count: o.gridNodeCount, 957 cvs: j_(a) 958 }); 959 } 960 return n; 961} 962function j_(e) { 963 return e.map(function(t) { 964 return [Xs(t.longitudeShift), Xs(t.latitudeShift)]; 965 }); 966} 967function W_(e, t, i) { 968 return { 969 name: el(e, t + 8, t + 16).trim(), 970 parent: el(e, t + 24, t + 24 + 8).trim(), 971 lowerLatitude: e.getFloat64(t + 72, i), 972 upperLatitude: e.getFloat64(t + 88, i), 973 lowerLongitude: e.getFloat64(t + 104, i), 974 upperLongitude: e.getFloat64(t + 120, i), 975 latitudeInterval: e.getFloat64(t + 136, i), 976 longitudeInterval: e.getFloat64(t + 152, i), 977 gridNodeCount: e.getInt32(t + 168, i) 978 }; 979} 980function B_(e, t, i, s) { 981 for (var n = t + 176, r = 16, o = [], a = 0; a < i.gridNodeCount; a++) { 982 var l = { 983 latitudeShift: e.getFloat32(n + a * r, s), 984 longitudeShift: e.getFloat32(n + a * r + 4, s), 985 latitudeAccuracy: e.getFloat32(n + a * r + 8, s), 986 longitudeAccuracy: e.getFloat32(n + a * r + 12, s) 987 }; 988 o.push(l); 989 } 990 return o; 991} 992function Je(e, t) { 993 if (!(this instanceof Je)) 994 return new Je(e); 995 t = t || function(h) { 996 if (h) 997 throw h; 998 }; 999 var i = p_(e); 1000 if (typeof i != "object") { 1001 t(e); 1002 return; 1003 } 1004 var s = Je.projections.get(i.projName); 1005 if (!s) { 1006 t(e); 1007 return; 1008 } 1009 if (i.datumCode && i.datumCode !== "none") { 1010 var n = qi(Kt, i.datumCode); 1011 n && (i.datum_params = i.datum_params || (n.towgs84 ? n.towgs84.split(",") : null), i.ellps = n.ellipse, i.datumName = n.datumName ? n.datumName : i.datumCode); 1012 }
1013 i.k0 = i.k0 || 1, i.axis = i.axis || "enu", i.ellps = i.ellps || "wgs84", i.lat1 = i.lat1 || i.lat0; 1014 var r = L_(i.a, i.b, i.rf, i.ellps, i.sphere), o = A_(r.a, r.b, r.rf, i.R_A), a = D_(i.nadgrids), l = i.datum || O_( 1015 i.datumCode, 1016 i.datum_params, 1017 r.a, 1018 r.b, 1019 o.es, 1020 o.ep2, 1021 a 1022 ); 1023 cc(this, i), cc(this, s), this.a = r.a, this.b = r.b, this.rf = r.rf, this.sphere = r.sphere, this.es = o.es, this.e = o.e, this.ep2 = o.ep2, this.datum = l, this.init(), t(null, this); 1024} 1025Je.projections = I_; 1026Je.projections.start(); 1027function U_(e, t) { 1028 return e.datum_type !== t.datum_type || e.a !== t.a || Math.abs(e.es - t.es) > 5e-11 ? !1 : e.datum_type === xs ? e.datum_params[0] === t.datum_params[0] && e.datum_params[1] === t.datum_params[1] && e.datum_params[2] === t.datum_params[2] : e.datum_type === vs ? e.datum_params[0] === t.datum_params[0] && e.datum_params[1] === t.datum_params[1] && e.datum_params[2] === t.datum_params[2] && e.datum_params[3] === t.datum_params[3] && e.datum_params[4] === t.datum_params[4] && e.datum_params[5] === t.datum_params[5] && e.datum_params[6] === t.datum_params[6] : !0; 1029} 1030function cd(e, t, i) { 1031 var s = e.x, n = e.y, r = e.z ? e.z : 0, o, a, l, h; 1032 if (n < -A && n > -1.001 * A) 1033 n = -A; 1034 else if (n > A && n < 1.001 * A) 1035 n = A; 1036 else { 1037 if (n < -A) 1038 return { x: -1 / 0, y: -1 / 0, z: e.z }; 1039 if (n > A) 1040 return { x: 1 / 0, y: 1 / 0, z: e.z }; 1041 } 1042 return s > Math.PI && (s -= 2 * Math.PI), a = Math.sin(n), h = Math.cos(n), l = a * a, o = i / Math.sqrt(1 - t * l), { 1043 x: (o + r) * h * Math.cos(s), 1044 y: (o + r) * h * Math.sin(s), 1045 z: (o * (1 - t) + r) * a 1046 }; 1047} 1048function ud(e, t, i, s) { 1049 var n = 1e-12, r = n * n, o = 30, a, l, h, c, u, d, f, g, _, m, p, y, v, E = e.x, C = e.y, S = e.z ? e.z : 0, O, R, j; 1050 if (a = Math.sqrt(E * E + C * C), l = Math.sqrt(E * E + C * C + S * S), a / i < n) { 1051 if (O = 0, l / i < n) 1052 return R = A, j = -s, { 1053 x: e.x, 1054 y: e.y, 1055 z: e.z 1056 }; 1057 } else 1058 O = Math.atan2(C, E); 1059 h = S / l, c = a / l, u = 1 / Math.sqrt(1 - t * (2 - t) * c * c), g = c * (1 - t) * u, _ = h * u, v = 0; 1060 do 1061 v++, f = i / Math.sqrt(1 - t * _ * _), j = a * g + S * _ - f * (1 - t * _ * _), d = t * f / (f + j), u = 1 / Math.sqrt(1 - d * (2 - d) * c * c), m = c * (1 - d) * u, p = h * u, y = p * g - m * _, g = m, _ = p; 1062 while (y * y > r && v < o); 1063 return R = Math.atan(p / Math.abs(m)), { 1064 x: O, 1065 y: R, 1066 z: j 1067 }; 1068} 1069function X_(e, t, i) { 1070 if (t === xs) 1071 return { 1072 x: e.x + i[0], 1073 y: e.y + i[1], 1074 z: e.z + i[2] 1075 }; 1076 if (t === vs) { 1077 var s = i[0], n = i[1], r = i[2], o = i[3], a = i[4], l = i[5], h = i[6]; 1078 return { 1079 x: h * (e.x - l * e.y + a * e.z) + s, 1080 y: h * (l * e.x + e.y - o * e.z) + n, 1081 z: h * (-a * e.x + o * e.y + e.z) + r 1082 }; 1083 } 1084} 1085function $_(e, t, i) { 1086 if (t === xs) 1087 return { 1088 x: e.x - i[0], 1089 y: e.y - i[1], 1090 z: e.z - i[2] 1091 }; 1092 if (t === vs) { 1093 var s = i[0], n = i[1], r = i[2], o = i[3], a = i[4], l = i[5], h = i[6], c = (e.x - s) / h, u = (e.y - n) / h, d = (e.z - r) / h; 1094 return { 1095 x: c + l * u - a * d, 1096 y: -l * c + u + o * d, 1097 z: a * c - o * u + d 1098 }; 1099 } 1100} 1101function Gr(e) { 1102 return e === xs || e === vs; 1103} 1104function Y_(e, t, i) { 1105 if (U_(e, t) || e.datum_type === Qa || t.datum_type === Qa) 1106 return i; 1107 var s = e.a, n = e.es; 1108 if (e.datum_type === Js) { 1109 var r = dc(e, !1, i); 1110 if (r !== 0) 1111 return; 1112 s = oc, n = ac; 1113 } 1114 var o = t.a, a = t.b, l = t.es; 1115 if (t.datum_type === Js && (o = oc, a = Zg, l = ac), n === l && s === o && !Gr(e.datum_type) && !Gr(t.datum_type)) 1116 return i; 1117 if (i = cd(i, n, s), Gr(e.datum_type) && (i = X_(i, e.datum_type, e.datum_params)), Gr(t.datum_type) && (i = $_(i, t.datum_type, t.datum_params)), i = ud(i, l, o, a), t.datum_type === Js) { 1118 var h = dc(t, !0, i); 1119 if (h !== 0) 1120 return; 1121 } 1122 return i; 1123} 1124function dc(e, t, i) { 1125 if (e.grids === null || e.grids.length === 0) 1126 return -1; 1127 for (var s = { x: -i.x, y: i.y }, n = { x: Number.NaN, y: Number.NaN }, r = [], o = 0; o < e.grids.length; o++) { 1128 var a = e.grids[o]; 1129 if (r.push(a.name), a.isNull) { 1130 n = s; 1131 break; 1132 } 1133 if (a.mandatory, a.grid === null) { 1134 if (a.mandatory) 1135 return -1; 1136 continue; 1137 } 1138 var l = a.grid.subgrids[0], h = (Math.abs(l.del[1]) + Math.abs(l.del[0])) / 1e4, c = l.ll[0] - h, u = l.ll[1] - h, d = l.ll[0] + (l.lim[0] - 1) * l.del[0] + h, f = l.ll[1] + (l.lim[1] - 1) * l.del[1] + h; 1139 if (!(u > s.y || c > s.x || f < s.y || d < s.x) && (n = K_(s, t, l), !isNaN(n.x))) 1140 break; 1141 } 1142 return isNaN(n.x) ? -1 : (i.x = -n.x, i.y = n.y, 0); 1143} 1144function K_(e, t, i) { 1145 var s = { x: Number.NaN, y: Number.NaN }; 1146 if (isNaN(e.x)) 1147 return s; 1148 var n = { x: e.x, y: e.y }; 1149 n.x -= i.ll[0], n.y -= i.ll[1], n.x = U(n.x - Math.PI) + Math.PI; 1150 var r = fc(n, i); 1151 if (t) { 1152 if (isNaN(r.x)) 1153 return s; 1154 r.x = n.x - r.x, r.y = n.y - r.y; 1155 var o = 9, a = 1e-12, l, h; 1156 do { 1157 if (h = fc(r, i), isNaN(h.x)) 1158 break; 1159 l = { x: n.x - (h.x + r.x), y: n.y - (h.y + r.y) }, r.x += l.x, r.y += l.y; 1160 } while (o-- && Math.abs(l.x) >
1160 a && Math.abs(l.y) > a); 1161 if (o < 0) 1162 return s; 1163 s.x = U(r.x + i.ll[0]), s.y = r.y + i.ll[1]; 1164 } else 1165 isNaN(r.x) || (s.x = e.x + r.x, s.y = e.y + r.y); 1166 return s; 1167} 1168function fc(e, t) { 1169 var i = { x: e.x / t.del[0], y: e.y / t.del[1] }, s = { x: Math.floor(i.x), y: Math.floor(i.y) }, n = { x: i.x - 1 * s.x, y: i.y - 1 * s.y }, r = { x: Number.NaN, y: Number.NaN }, o; 1170 if (s.x < 0 || s.x >= t.lim[0] || s.y < 0 || s.y >= t.lim[1]) 1171 return r; 1172 o = s.y * t.lim[0] + s.x; 1173 var a = { x: t.cvs[o][0], y: t.cvs[o][1] }; 1174 o++; 1175 var l = { x: t.cvs[o][0], y: t.cvs[o][1] }; 1176 o += t.lim[0]; 1177 var h = { x: t.cvs[o][0], y: t.cvs[o][1] }; 1178 o--; 1179 var c = { x: t.cvs[o][0], y: t.cvs[o][1] }, u = n.x * n.y, d = n.x * (1 - n.y), f = (1 - n.x) * (1 - n.y), g = (1 - n.x) * n.y; 1180 return r.x = f * a.x + d * l.x + g * c.x + u * h.x, r.y = f * a.y + d * l.y + g * c.y + u * h.y, r; 1181} 1182function gc(e, t, i) { 1183 var s = i.x, n = i.y, r = i.z || 0, o, a, l, h = {}; 1184 for (l = 0; l < 3; l++) 1185 if (!(t && l === 2 && i.z === void 0)) 1186 switch (l === 0 ? (o = s, "ew".indexOf(e.axis[l]) !== -1 ? a = "x" : a = "y") : l === 1 ? (o = n, "ns".indexOf(e.axis[l]) !== -1 ? a = "y" : a = "x") : (o = r, a = "z"), e.axis[l]) { 1187 case "e": 1188 h[a] = o; 1189 break; 1190 case "w": 1191 h[a] = -o; 1192 break; 1193 case "n": 1194 h[a] = o; 1195 break; 1196 case "s": 1197 h[a] = -o; 1198 break; 1199 case "u": 1200 i[a] !== void 0 && (h.z = o); 1201 break; 1202 case "d": 1203 i[a] !== void 0 && (h.z = -o); 1204 break; 1205 default: 1206 return null; 1207 } 1208 return h; 1209} 1210function dd(e) { 1211 var t = { 1212 x: e[0], 1213 y: e[1] 1214 }; 1215 return e.length > 2 && (t.z = e[2]), e.length > 3 && (t.m = e[3]), t; 1216} 1217function V_(e) { 1218 _c(e.x), _c(e.y); 1219} 1220function _c(e) { 1221 if (typeof Number.isFinite == "function") { 1222 if (Number.isFinite(e)) 1223 return; 1224 throw new TypeError("coordinates must be finite numbers"); 1225 } 1226 if (typeof e != "number" || e !== e || !isFinite(e)) 1227 throw new TypeError("coordinates must be finite numbers"); 1228} 1229function q_(e, t) { 1230 return (e.datum.datum_type === xs || e.datum.datum_type === vs || e.datum.datum_type === Js) && t.datumCode !== "WGS84" || (t.datum.datum_type === xs || t.datum.datum_type === vs || t.datum.datum_type === Js) && e.datumCode !== "WGS84"; 1231} 1232function vo(e, t, i, s) { 1233 var n; 1234 Array.isArray(i) ? i = dd(i) : i = { 1235 x: i.x, 1236 y: i.y, 1237 z: i.z, 1238 m: i.m 1239 }; 1240 var r = i.z !== void 0; 1241 if (V_(i), e.datum && t.datum && q_(e, t) && (n = new Je("WGS84"), i = vo(e, n, i, s), e = n), s && e.axis !== "enu" && (i = gc(e, !1, i)), e.projName === "longlat") 1242 i = { 1243 x: i.x * Vt, 1244 y: i.y * Vt, 1245 z: i.z || 0 1246 }; 1247 else if (e.to_meter && (i = { 1248 x: i.x * e.to_meter, 1249 y: i.y * e.to_meter, 1250 z: i.z || 0 1251 }), i = e.inverse(i), !i) 1252 return; 1253 if (e.from_greenwich && (i.x += e.from_greenwich), i = Y_(e.datum, t.datum, i), !!i) 1254 return t.from_greenwich && (i = { 1255 x: i.x - t.from_greenwich, 1256 y: i.y, 1257 z: i.z || 0 1258 }), t.projName === "longlat" ? i = { 1259 x: i.x * ki, 1260 y: i.y * ki, 1261 z: i.z || 0 1262 } : (i = t.forward(i), t.to_meter && (i = { 1263 x: i.x / t.to_meter, 1264 y: i.y / t.to_meter, 1265 z: i.z || 0 1266 })), s && t.axis !== "enu" ? gc(t, !0, i) : (r || delete i.z, i); 1267} 1268var mc = Je("WGS84"); 1269function Ma(e, t, i, s) { 1270 var n, r, o; 1271 return Array.isArray(i) ? (n = vo(e, t, i, s) || { x: NaN, y: NaN }, i.length > 2 ? typeof e.name < "u" && e.name === "geocent" || typeof t.name < "u" && t.name === "geocent" ? typeof n.z == "number" ? [n.x, n.y, n.z].concat(i.splice(3)) : [n.x, n.y, i[2]].concat(i.splice(3)) : [n.x, n.y].concat(i.splice(2)) : [n.x, n.y]) : (r = vo(e, t, i, s), o = Object.keys(i), o.length === 2 || o.forEach(function(a) { 1272 if (typeof e.name < "u" && e.name === "geocent" || typeof t.name < "u" && t.name === "geocent") { 1273 if (a === "x" || a === "y" || a === "z") 1274 return; 1275 } else if (a === "x" || a === "y") 1276 return; 1277 r[a] = i[a]; 1278 }), r); 1279} 1280function pc(e) { 1281 return e instanceof Je ? e : e.oProj ? e.oProj : Je(e); 1282} 1283function xe(e, t, i) { 1284 e = pc(e); 1285 var s = !1, n; 1286 return typeof t > "u" ? (t = e, e = mc, s = !0) : (typeof t.x < "u" || Array.isArray(t)) && (i = t, t = e, e = mc, s = !0), t = pc(t), i ? Ma(e, t, i) : (n = { 1287 forward: function(r, o) { 1288 return Ma(e, t, r, o); 1289 }, 1290 inverse: function(r, o) { 1291 return Ma(t, e, r, o); 1292 } 1293 }, s && (n.oProj = t), n); 1294} 1295var yc = 6, fd = "AJSAJS", gd = "AFAFAF", $s = 65, ge = 73, Ie = 79, Gn = 86, zn = 90; 1296const H_ = { 1297 forward: _d, 1298 inverse: Z_, 1299 toPoint: md 1300}; 1301function _d(e, t) { 1302 return t = t || 5, t0(J_({ 1303 lat: e[1], 1304 lon: e[0] 1305 }), t); 1306} 1307function Z_(e) { 1308 var t = Gl(yd(e.toUpperCase())); 1309 return t.lat && t.lon ? [t.lon, t.lat, t.lon, t.lat] : [t.left, t.bottom, t.right, t.top]; 1310} 1311function md(e) { 1312 var t = Gl(yd(e.toUpperCase())); 1313 return t.lat && t.lon ? [t.lon, t.lat] : [(t.left + t.right) / 2, (t.top + t.bottom) / 2]; 1314} 1315function Ca(e) { 1316 return e * (Math.PI / 180); 1317} 1318function xc(e) { 1319 return 180 * (e / Math.PI); 1320} 1321function J_(e) { 1322 var t = e.lat, i = e.lon, s = 6378137, n = 669438e-8, r = 0.9996, o, a, l, h, c, u, d, f = Ca(t), g = Ca(i), _, m; 1323 m = Math.floor((i + 180) / 6) + 1, i === 180 && (m = 60), t >= 56 && t < 64 && i >= 3 && i < 12 && (m = 32), t >= 72 && t < 84 && (i >= 0 && i < 9 ? m = 31 : i >= 9 && i < 21 ? m = 33 : i >= 21 && i < 33 ? m = 35 : i >= 33 && i < 42 && (m = 37)), o = (m - 1) * 6 - 180 + 3, _ = Ca(o), a = n / (1 - n), l = s / Math.sqrt(1 - n * Math.sin(f) * Math.sin(f)), h = Math.tan(f) * Math.tan(f), c = a * Math.cos(f) * Math.cos(f), u = Math.
1323cos(f) * (g - _), d = s * ((1 - n / 4 - 3 * n * n / 64 - 5 * n * n * n / 256) * f - (3 * n / 8 + 3 * n * n / 32 + 45 * n * n * n / 1024) * Math.sin(2 * f) + (15 * n * n / 256 + 45 * n * n * n / 1024) * Math.sin(4 * f) - 35 * n * n * n / 3072 * Math.sin(6 * f)); 1324 var p = r * l * (u + (1 - h + c) * u * u * u / 6 + (5 - 18 * h + h * h + 72 * c - 58 * a) * u * u * u * u * u / 120) + 5e5, y = r * (d + l * Math.tan(f) * (u * u / 2 + (5 - h + 9 * c + 4 * c * c) * u * u * u * u / 24 + (61 - 58 * h + h * h + 600 * c - 330 * a) * u * u * u * u * u * u / 720)); 1325 return t < 0 && (y += 1e7), { 1326 northing: Math.round(y), 1327 easting: Math.round(p), 1328 zoneNumber: m, 1329 zoneLetter: Q_(t) 1330 }; 1331} 1332function Gl(e) { 1333 var t = e.northing, i = e.easting, s = e.zoneLetter, n = e.zoneNumber; 1334 if (n < 0 || n > 60) 1335 return null; 1336 var r = 0.9996, o = 6378137, a = 669438e-8, l, h = (1 - Math.sqrt(1 - a)) / (1 + Math.sqrt(1 - a)), c, u, d, f, g, _, m, p, y, v = i - 5e5, E = t; 1337 s < "N" && (E -= 1e7), m = (n - 1) * 6 - 180 + 3, l = a / (1 - a), _ = E / r, p = _ / (o * (1 - a / 4 - 3 * a * a / 64 - 5 * a * a * a / 256)), y = p + (3 * h / 2 - 27 * h * h * h / 32) * Math.sin(2 * p) + (21 * h * h / 16 - 55 * h * h * h * h / 32) * Math.sin(4 * p) + 151 * h * h * h / 96 * Math.sin(6 * p), c = o / Math.sqrt(1 - a * Math.sin(y) * Math.sin(y)), u = Math.tan(y) * Math.tan(y), d = l * Math.cos(y) * Math.cos(y), f = o * (1 - a) / Math.pow(1 - a * Math.sin(y) * Math.sin(y), 1.5), g = v / (c * r); 1338 var C = y - c * Math.tan(y) / f * (g * g / 2 - (5 + 3 * u + 10 * d - 4 * d * d - 9 * l) * g * g * g * g / 24 + (61 + 90 * u + 298 * d + 45 * u * u - 252 * l - 3 * d * d) * g * g * g * g * g * g / 720); 1339 C = xc(C); 1340 var S = (g - (1 + 2 * u + d) * g * g * g / 6 + (5 - 2 * d + 28 * u - 3 * d * d + 8 * l + 24 * u * u) * g * g * g * g * g / 120) / Math.cos(y); 1341 S = m + xc(S); 1342 var O; 1343 if (e.accuracy) { 1344 var R = Gl({ 1345 northing: e.northing + e.accuracy, 1346 easting: e.easting + e.accuracy, 1347 zoneLetter: e.zoneLetter, 1348 zoneNumber: e.zoneNumber 1349 }); 1350 O = { 1351 top: R.lat, 1352 right: R.lon, 1353 bottom: C, 1354 left: S 1355 }; 1356 } else 1357 O = { 1358 lat: C, 1359 lon: S 1360 }; 1361 return O; 1362} 1363function Q_(e) { 1364 var t = "Z"; 1365 return 84 >= e && e >= 72 ? t = "X" : 72 > e && e >= 64 ? t = "W" : 64 > e && e >= 56 ? t = "V" : 56 > e && e >= 48 ? t = "U" : 48 > e && e >= 40 ? t = "T" : 40 > e && e >= 32 ? t = "S" : 32 > e && e >= 24 ? t = "R" : 24 > e && e >= 16 ? t = "Q" : 16 > e && e >= 8 ? t = "P" : 8 > e && e >= 0 ? t = "N" : 0 > e && e >= -8 ? t = "M" : -8 > e && e >= -16 ? t = "L" : -16 > e && e >= -24 ? t = "K" : -24 > e && e >= -32 ? t = "J" : -32 > e && e >= -40 ? t = "H" : -40 > e && e >= -48 ? t = "G" : -48 > e && e >= -56 ? t = "F" : -56 > e && e >= -64 ? t = "E" : -64 > e && e >= -72 ? t = "D" : -72 > e && e >= -80 && (t = "C"), t; 1366} 1367function t0(e, t) { 1368 var i = "00000" + e.easting, s = "00000" + e.northing; 1369 return e.zoneNumber + e.zoneLetter + e0(e.easting, e.northing, e.zoneNumber) + i.substr(i.length - 5, t) + s.substr(s.length - 5, t); 1370} 1371function e0(e, t, i) { 1372 var s = pd(i), n = Math.floor(e / 1e5), r = Math.floor(t / 1e5) % 20; 1373 return i0(n, r, s); 1374} 1375function pd(e) { 1376 var t = e % yc; 1377 return t === 0 && (t = yc), t; 1378} 1379function i0(e, t, i) { 1380 var s = i - 1, n = fd.charCodeAt(s), r = gd.charCodeAt(s), o = n + e - 1, a = r + t, l = !1; 1381 o > zn && (o = o - zn + $s - 1, l = !0), (o === ge || n < ge && o > ge || (o > ge || n < ge) && l) && o++, (o === Ie || n < Ie && o > Ie || (o > Ie || n < Ie) && l) && (o++, o === ge && o++), o > zn && (o = o - zn + $s - 1), a > Gn ? (a = a - Gn + $s - 1, l = !0) : l = !1, (a === ge || r < ge && a > ge || (a > ge || r < ge) && l) && a++, (a === Ie || r < Ie && a > Ie || (a > Ie || r < Ie) && l) && (a++, a === ge && a++), a > Gn && (a = a - Gn + $s - 1); 1382 var h = String.fromCharCode(o) + String.fromCharCode(a); 1383 return h; 1384} 1385function yd(e) { 1386 if (e && e.length === 0) 1387 throw "MGRSPoint coverting from nothing"; 1388 for (var t = e.length, i = null, s = "", n, r = 0; !/[A-Z]/.test(n = e.charAt(r)); ) { 1389 if (r >= 2) 1390 throw "MGRSPoint bad conversion from: " + e; 1391 s += n, r++; 1392 } 1393 var o = parseInt(s, 10); 1394 if (r === 0 || r + 3 > t) 1395 throw "MGRSPoint bad conversion from: " + e; 1396 var a = e.charAt(r++); 1397 if (a <= "A" || a === "B" || a === "Y" || a >= "Z" || a === "I" || a === "O") 1398 throw "MGRSPoint zone letter " + a + " not handled: " + e; 1399 i = e.substring(r, r += 2);
1400 for (var l = pd(o), h = s0(i.charAt(0), l), c = n0(i.charAt(1), l); c < r0(a); ) 1401 c += 2e6; 1402 var u = t - r; 1403 if (u % 2 !== 0) 1404 throw `MGRSPoint has to have an even number 1405of digits after the zone letter and two 100km letters - front 1406half for easting meters, second half for 1407northing meters` + e; 1408 var d = u / 2, f = 0, g = 0, _, m, p, y, v; 1409 return d > 0 && (_ = 1e5 / Math.pow(10, d), m = e.substring(r, r + d), f = parseFloat(m) * _, p = e.substring(r + d), g = parseFloat(p) * _), y = f + h, v = g + c, { 1410 easting: y, 1411 northing: v, 1412 zoneLetter: a, 1413 zoneNumber: o, 1414 accuracy: _ 1415 }; 1416} 1417function s0(e, t) { 1418 for (var i = fd.charCodeAt(t - 1), s = 1e5, n = !1; i !== e.charCodeAt(0); ) { 1419 if (i++, i === ge && i++, i === Ie && i++, i > zn) { 1420 if (n) 1421 throw "Bad character: " + e; 1422 i = $s, n = !0; 1423 } 1424 s += 1e5; 1425 } 1426 return s; 1427} 1428function n0(e, t) { 1429 if (e > "V") 1430 throw "MGRSPoint given invalid Northing " + e; 1431 for (var i = gd.charCodeAt(t - 1), s = 0, n = !1; i !== e.charCodeAt(0); ) { 1432 if (i++, i === ge && i++, i === Ie && i++, i > Gn) { 1433 if (n) 1434 throw "Bad character: " + e; 1435 i = $s, n = !0; 1436 } 1437 s += 1e5; 1438 } 1439 return s; 1440} 1441function r0(e) { 1442 var t; 1443 switch (e) { 1444 case "C": 1445 t = 11e5; 1446 break; 1447 case "D": 1448 t = 2e6; 1449 break; 1450 case "E": 1451 t = 28e5; 1452 break; 1453 case "F": 1454 t = 37e5; 1455 break; 1456 case "G": 1457 t = 46e5; 1458 break; 1459 case "H": 1460 t = 55e5; 1461 break; 1462 case "J": 1463 t = 64e5; 1464 break; 1465 case "K": 1466 t = 73e5; 1467 break; 1468 case "L": 1469 t = 82e5; 1470 break; 1471 case "M": 1472 t = 91e5; 1473 break; 1474 case "N": 1475 t = 0; 1476 break; 1477 case "P": 1478 t = 8e5; 1479 break; 1480 case "Q": 1481 t = 17e5; 1482 break; 1483 case "R": 1484 t = 26e5; 1485 break; 1486 case "S": 1487 t = 35e5; 1488 break; 1489 case "T": 1490 t = 44e5; 1491 break; 1492 case "U": 1493 t = 53e5; 1494 break; 1495 case "V": 1496 t = 62e5; 1497 break; 1498 case "W": 1499 t = 7e6; 1500 break; 1501 case "X": 1502 t = 79e5; 1503 break; 1504 default: 1505 t = -1; 1506 } 1507 if (t >= 0) 1508 return t; 1509 throw "Invalid zone letter: " + e; 1510} 1511function hn(e, t, i) { 1512 if (!(this instanceof hn)) 1513 return new hn(e, t, i); 1514 if (Array.isArray(e)) 1515 this.x = e[0], this.y = e[1], this.z = e[2] || 0; 1516 else if (typeof e == "object") 1517 this.x = e.x, this.y = e.y, this.z = e.z || 0; 1518 else if (typeof e == "string" && typeof t > "u") { 1519 var s = e.split(","); 1520 this.x = parseFloat(s[0], 10), this.y = parseFloat(s[1], 10), this.z = parseFloat(s[2], 10) || 0; 1521 } else 1522 this.x = e, this.y = t, this.z = i || 0; 1523} 1524hn.fromMGRS = function(e) { 1525 return new hn(md(e)); 1526}; 1527hn.prototype.toMGRS = function(e) { 1528 return _d([this.x, this.y], e); 1529}; 1530var o0 = 1, a0 = 0.25, vc = 0.046875, Ec = 0.01953125, Mc = 0.01068115234375, l0 = 0.75, h0 = 0.46875, c0 = 0.013020833333333334, u0 = 0.007120768229166667, d0 = 0.3645833333333333, f0 = 0.005696614583333333, g0 = 0.3076171875; 1531function xd(e) { 1532 var t = []; 1533 t[0] = o0 - e * (a0 + e * (vc + e * (Ec + e * Mc))), t[1] = e * (l0 - e * (vc + e * (Ec + e * Mc))); 1534 var i = e * e; 1535 return t[2] = i * (h0 - e * (c0 + e * u0)), i *= e, t[3] = i * (d0 - e * f0), t[4] = i * e * g0, t; 1536} 1537function Ko(e, t, i, s) { 1538 return i *= t, t *= t, s[0] * e - i * (s[1] + t * (s[2] + t * (s[3] + t * s[4]))); 1539} 1540var _0 = 20; 1541function vd(e, t, i) { 1542 for (var s = 1 / (1 - t), n = e, r = _0; r; --r) { 1543 var o = Math.sin(n), a = 1 - t * o * o; 1544 if (a = (Ko(n, o, Math.cos(n), i) - e) * (a * Math.sqrt(a)) * s, n -= a, Math.abs(a) < G) 1545 return n; 1546 } 1547 return n; 1548} 1549function m0() { 1550 this.x0 = this.x0 !== void 0 ? this.x0 : 0, this.y0 = this.y0 !== void 0 ? this.y0 : 0, this.long0 = this.long0 !== void 0 ? this.long0 : 0, this.lat0 = this.lat0 !== void 0 ? this.lat0 : 0, this.es && (this.en = xd(this.es), this.ml0 = Ko(this.lat0, Math.sin(this.lat0), Math.cos(this.lat0), this.en)); 1551} 1552function p0(e) { 1553 var t = e.x, i = e.y, s = U(t - this.long0), n, r, o, a = Math.sin(i), l = Math.
1553cos(i); 1554 if (this.es) { 1555 var c = l * s, u = Math.pow(c, 2), d = this.ep2 * Math.pow(l, 2), f = Math.pow(d, 2), g = Math.abs(l) > G ? Math.tan(i) : 0, _ = Math.pow(g, 2), m = Math.pow(_, 2); 1556 n = 1 - this.es * Math.pow(a, 2), c = c / Math.sqrt(n); 1557 var p = Ko(i, a, l, this.en); 1558 r = this.a * (this.k0 * c * (1 + u / 6 * (1 - _ + d + u / 20 * (5 - 18 * _ + m + 14 * d - 58 * _ * d + u / 42 * (61 + 179 * m - m * _ - 479 * _))))) + this.x0, o = this.a * (this.k0 * (p - this.ml0 + a * s * c / 2 * (1 + u / 12 * (5 - _ + 9 * d + 4 * f + u / 30 * (61 + m - 58 * _ + 270 * d - 330 * _ * d + u / 56 * (1385 + 543 * m - m * _ - 3111 * _)))))) + this.y0; 1559 } else { 1560 var h = l * Math.sin(s); 1561 if (Math.abs(Math.abs(h) - 1) < G) 1562 return 93; 1563 if (r = 0.5 * this.a * this.k0 * Math.log((1 + h) / (1 - h)) + this.x0, o = l * Math.cos(s) / Math.sqrt(1 - Math.pow(h, 2)), h = Math.abs(o), h >= 1) { 1564 if (h - 1 > G) 1565 return 93; 1566 o = 0; 1567 } else 1568 o = Math.acos(o); 1569 i < 0 && (o = -o), o = this.a * this.k0 * (o - this.lat0) + this.y0; 1570 } 1571 return e.x = r, e.y = o, e; 1572} 1573function y0(e) { 1574 var t, i, s, n, r = (e.x - this.x0) * (1 / this.a), o = (e.y - this.y0) * (1 / this.a); 1575 if (this.es) 1576 if (t = this.ml0 + o / this.k0, i = vd(t, this.es, this.en), Math.abs(i) < A) { 1577 var u = Math.sin(i), d = Math.cos(i), f = Math.abs(d) > G ? Math.tan(i) : 0, g = this.ep2 * Math.pow(d, 2), _ = Math.pow(g, 2), m = Math.pow(f, 2), p = Math.pow(m, 2); 1578 t = 1 - this.es * Math.pow(u, 2); 1579 var y = r * Math.sqrt(t) / this.k0, v = Math.pow(y, 2); 1580 t = t * f, s = i - t * v / (1 - this.es) * 0.5 * (1 - v / 12 * (5 + 3 * m - 9 * g * m + g - 4 * _ - v / 30 * (61 + 90 * m - 252 * g * m + 45 * p + 46 * g - v / 56 * (1385 + 3633 * m + 4095 * p + 1574 * p * m)))), n = U(this.long0 + y * (1 - v / 6 * (1 + 2 * m + g - v / 20 * (5 + 28 * m + 24 * p + 8 * g * m + 6 * g - v / 42 * (61 + 662 * m + 1320 * p + 720 * p * m)))) / d); 1581 } else 1582 s = A * xr(o), n = 0; 1583 else { 1584 var a = Math.exp(r / this.k0), l = 0.5 * (a - 1 / a), h = this.lat0 + o / this.k0, c = Math.cos(h); 1585 t = Math.sqrt((1 - Math.pow(c, 2)) / (1 + Math.pow(l, 2))), s = Math.asin(t), o < 0 && (s = -s), l === 0 && c === 0 ? n = 0 : n = U(Math.atan2(l, c) + this.long0); 1586 } 1587 return e.x = n, e.y = s, e; 1588} 1589var x0 = ["Fast_Transverse_Mercator", "Fast Transverse Mercator"]; 1590const ho = { 1591 init: m0, 1592 forward: p0, 1593 inverse: y0, 1594 names: x0 1595}; 1596function Ed(e) { 1597 var t = Math.exp(e); 1598 return t = (t - 1 / t) / 2, t; 1599} 1600function De(e, t) { 1601 e = Math.abs(e), t = Math.abs(t); 1602 var i = Math.max(e, t), s = Math.min(e, t) / (i || 1); 1603 return i * Math.sqrt(1 + Math.pow(s, 2)); 1604} 1605function v0(e) { 1606 var t = 1 + e, i = t - 1; 1607 return i === 0 ? e : e * Math.log(t) / i; 1608} 1609function E0(e) { 1610 var t = Math.abs(e); 1611 return t = v0(t * (1 + t / (De(1, t) + 1))), e < 0 ? -t : t; 1612} 1613function zl(e, t) { 1614 for (var i = 2 * Math.cos(2 * t), s = e.length - 1, n = e[s], r = 0, o; --s >= 0; ) 1615 o = -r + i * n + e[s], r = n, n = o; 1616 return t + o * Math.sin(2 * t); 1617} 1618function M0(e, t) { 1619 for (var i = 2 * Math.cos(t), s = e.length - 1, n = e[s], r = 0, o; --s >= 0; ) 1620 o = -r + i * n + e[s], r = n, n = o; 1621 return Math.sin(t) * o; 1622} 1623function C0(e) { 1624 var t = Math.exp(e); 1625 return t = (t + 1 / t) / 2, t; 1626} 1627function Md(e, t, i) { 1628 for (var s = Math.sin(t), n = Math.cos(t), r = Ed(i), o = C0(i), a = 2 * n * o, l = -2 * s * r, h = e.length - 1, c = e[h], u = 0, d = 0, f = 0, g, _; --h >= 0; ) 1629 g = d, _ = u, d = c, u = f, c = -g + a * d - l * u + e[h], f = -_ + l * d + a * u; 1630 return a = s * o, l = n * r, [a * c - l * f, a * f + l * c]; 1631} 1632function b0() { 1633 if (!this.approx && (isNaN(this.es) || this.es <= 0)) 1634 throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.'); 1635 this.approx && (ho.init.apply(this), this.forward = ho.forward, this.inverse = ho.inverse), this.x0 = this.x0 !== void 0 ? this.x0 : 0, this.y0 = this.y0 !== void 0 ? this.y0 : 0, this.long0 = this.long0 !== void 0 ? this.long0 : 0, this.lat0 = this.lat0 !== void 0 ? this.lat0 : 0, this.cgb = [], this.cbg = [], this.utg = [], this.gtu = []; 1636 var e = this.es / (1 + Math.sqrt(1 - this.es)), t = e / (2 - e), i = t; 1637 this.cgb[0] = t * (2 + t * (-2 / 3 + t * (-2 + t * (116 / 45 + t * (26 / 45 + t * (-2854 / 675)))))), this.cbg[0] = t * (-2 + t * (2 / 3 + t * (4 / 3 + t * (-82 / 45 + t * (32 / 45 + t * (4642 / 4725)))))), i = i * t, this.cgb[1] = i * (7 / 3 + t * (-8 / 5 + t * (-227 / 45 + t * (2704 / 315 + t * (2323 / 945))))), this.cbg[1] = i * (5 / 3 + t * (-16 / 15 + t * (-13 / 9 + t * (904 / 315 + t * (-1522 / 945))))), i = i * t, this.cgb[2] = i * (56 / 15 + t * (-136 / 35 + t * (-1262 / 105 + t * (73814 / 2835)))), this.cbg[2] = i * (-26 / 15 + t * (34 / 21 + t * (8 / 5 + t * (-12686 / 2835)))), i = i * t, this.cgb[3] = i * (4279 / 630 + t * (-332 / 35 + t * (-399572 / 14175))), this.cbg[3] = i * (1237 / 630 + t * (-12 / 5 + t * (-24832 / 14175))), i = i * t, this.cgb[4] = i * (4174 / 315 + t * (-144838 / 6237)), this.cbg[4] = i * (-734 / 315 + t * (109598 / 31185)), i = i * t, this.cgb[5] = i * (601676 / 22275), this.cbg[5] = i * (444337 / 155925), i = Math.pow(t, 2), this.Qn = this.k0 / (1 + t) * (1 + i * (1 / 4 + i * (1 / 64 + i / 256))), this.utg[0] = t * (-0.5 + t * (2 / 3 + t * (-37 / 96 + t * (1 / 360 + t * (81 / 512 + t * (-96199 / 604800)))))), this.gtu[0] = t * (0.5 + t * (-2 / 3 + t * (5 / 16 + t * (41 / 180 + t * (-127 / 288 + t * (7891 / 37800)))))), this.utg[1] = i * (-1 / 48 + t * (-1 / 15 + t * (437 / 1440 + t * (-46 / 105 + t * (1118711 / 3870720))))), this.gtu[1] = i * (13 / 48 + t * (-3 / 5 + t * (557 / 1440 + t * (281 / 630 + t * (-1983433 / 1935360))))), i = i * t, this.utg[2] = i * (-17 / 480 + t * (37 / 840 + t * (209 / 4480 + t * (-5569 / 90720)))), this.gtu[2] = i * (61 / 240 + t * (-103 / 140 + t * (15061 / 26880 + t * (167603 / 181440)))), i = i * t, this.utg[3] = i * (-4397 / 161280 + t * (11 / 504 + t * (830251 / 7257600))), this.gtu[3] = i * (49561 / 161280 + t * (-179 / 168 + t * (6601661 / 7257600))), i = i * t, this.utg[4] = i * (-4583 / 161280 + t * (108847 / 3991680)), this.gtu[4] = i * (34729 / 80640 + t * (-3418889 / 1995840)), i = i * t, this.utg[5] = i * (-20648693 / 638668800), this.gtu[5] = i * (212378941 / 319334400); 1638 var s = zl(this.cbg, this.lat0); 1639 this.Zb = -this.Qn * (s + M0(this.gtu, 2 * s)); 1640} 1641function S0(e) { 1642 var t = U(e.x - this.long0), i = e.y; 1643 i = zl(this.cbg, i); 1644 var s = Math.sin(i), n = Math.cos(i), r = Math.sin(t), o = Math.cos(t); 1645 i = Math.atan2(s, o * n), t = Math.atan2(r * n, De(s, n * o)), t = E0(Math.tan(t)); 1646 var a = Md(this.gtu, 2 * i, 2 * t); 1647 i = i + a[0], t = t + a[1]; 1648 var l, h; 1649 return Math.abs(t) <= 2.623395162778 ? (l = this.a * (this.Qn * t) + this.x0, h = this.a * (this.Qn * i + this.Zb) + this.y0) : (l = 1 / 0, h = 1 / 0), e.x = l, e.y = h, e; 1650} 1651function w0(e) { 1652 var t = (e.x - this.x0) * (1 / this.a), i = (e.y - this.y0) * (1 / this.a); 1653 i = (i - this.Zb) / this.Qn, t = t / this.Qn; 1654 var s, n; 1655 if (Math.abs(t) <= 2.623395162778) { 1656 var r = Md(this.utg, 2 * i, 2 * t); 1657 i = i + r[0], t = t + r[1], t = Math.atan(Ed(t)); 1658 var o = Math.sin(i), a = Math.cos(i), l = Math.sin(t), h = Math.cos(t); 1659 i = Math.atan2(o * h, De(l, h * a)), t = Math.atan2(l, h * a), s = U(t + this.long0), n = zl(this.cgb, i); 1660 } else 1661 s = 1 / 0, n = 1 / 0; 1662 return e.x = s, e.y = n, e; 1663} 1664var T0 = ["Extended_Transverse_Mercator", "Extended Transverse Mercator", "etmerc", "Transverse_Mercator", "Transverse Mercator", "tmerc"]; 1665const co = { 1666 init: b0, 1667 forward: S0, 1668 inverse: w0, 1669 names: T0 1670}; 1671function R0(e, t) { 1672 if (e === void 0) { 1673 if (e = Math.floor((U(t) + Math.PI) * 30 / Math.PI) + 1, e < 0) 1674 return 0; 1675 if (e > 60) 1676 return 60; 1677 } 1678 return e; 1679} 1680var I0 = "etmerc"; 1681function P0() { 1682 var e = R0(this.zone, this.long0); 1683 if (e === void 0) 1684 throw new Error("unknown utm zone"); 1685 this.lat0 = 0, this.long0 = (6 * Math.abs(e) - 183) * Vt, this.x0 = 5e5, this.y0 = this.utmSouth ? 1e7 : 0, this.k0 = 0.9996, co.init.apply(this), this.forward = co.forward, this.inverse = co.inverse; 1686} 1687var A0 = ["Universal Transverse Mercator System", "utm"]; 1688const L0 = { 1689 init: P0, 1690 names: A0, 1691 dependsOn: I0 1692}
1692; 1693function jl(e, t) { 1694 return Math.pow((1 - e) / (1 + e), t); 1695} 1696var O0 = 20; 1697function F0() { 1698 var e = Math.sin(this.lat0), t = Math.cos(this.lat0); 1699 t *= t, this.rc = Math.sqrt(1 - this.es) / (1 - this.es * e * e), this.C = Math.sqrt(1 + this.es * t * t / (1 - this.es)), this.phic0 = Math.asin(e / this.C), this.ratexp = 0.5 * this.C * this.e, this.K = Math.tan(0.5 * this.phic0 + yt) / (Math.pow(Math.tan(0.5 * this.lat0 + yt), this.C) * jl(this.e * e, this.ratexp)); 1700} 1701function D0(e) { 1702 var t = e.x, i = e.y; 1703 return e.y = 2 * Math.atan(this.K * Math.pow(Math.tan(0.5 * i + yt), this.C) * jl(this.e * Math.sin(i), this.ratexp)) - A, e.x = this.C * t, e; 1704} 1705function N0(e) { 1706 for (var t = 1e-14, i = e.x / this.C, s = e.y, n = Math.pow(Math.tan(0.5 * s + yt) / this.K, 1 / this.C), r = O0; r > 0 && (s = 2 * Math.atan(n * jl(this.e * Math.sin(e.y), -0.5 * this.e)) - A, !(Math.abs(s - e.y) < t)); --r) 1707 e.y = s; 1708 return r ? (e.x = i, e.y = s, e) : null; 1709} 1710var k0 = ["gauss"]; 1711const Wl = { 1712 init: F0, 1713 forward: D0, 1714 inverse: N0, 1715 names: k0 1716}; 1717function G0() { 1718 Wl.init.apply(this), this.rc && (this.sinc0 = Math.sin(this.phic0), this.cosc0 = Math.cos(this.phic0), this.R2 = 2 * this.rc, this.title || (this.title = "Oblique Stereographic Alternative")); 1719} 1720function z0(e) { 1721 var t, i, s, n; 1722 return e.x = U(e.x - this.long0), Wl.forward.apply(this, [e]), t = Math.sin(e.y), i = Math.cos(e.y), s = Math.cos(e.x), n = this.k0 * this.R2 / (1 + this.sinc0 * t + this.cosc0 * i * s), e.x = n * i * Math.sin(e.x), e.y = n * (this.cosc0 * t - this.sinc0 * i * s), e.x = this.a * e.x + this.x0, e.y = this.a * e.y + this.y0, e; 1723} 1724function j0(e) { 1725 var t, i, s, n, r; 1726 if (e.x = (e.x - this.x0) / this.a, e.y = (e.y - this.y0) / this.a, e.x /= this.k0, e.y /= this.k0, r = Math.sqrt(e.x * e.x + e.y * e.y)) { 1727 var o = 2 * Math.atan2(r, this.R2); 1728 t = Math.sin(o), i = Math.cos(o), n = Math.asin(i * this.sinc0 + e.y * t * this.cosc0 / r), s = Math.atan2(e.x * t, r * this.cosc0 * i - e.y * this.sinc0 * t); 1729 } else 1730 n = this.phic0, s = 0; 1731 return e.x = s, e.y = n, Wl.inverse.apply(this, [e]), e.x = U(e.x + this.long0), e; 1732} 1733var W0 = ["Stereographic_North_Pole", "Oblique_Stereographic", "Polar_Stereographic", "sterea", "Oblique Stereographic Alternative", "Double_Stereographic"]; 1734const B0 = { 1735 init: G0, 1736 forward: z0, 1737 inverse: j0, 1738 names: W0 1739}; 1740function U0(e, t, i) { 1741 return t *= i, Math.tan(0.5 * (A + e)) * Math.pow((1 - t) / (1 + t), 0.5 * i); 1742} 1743function X0() { 1744 this.coslat0 = Math.cos(this.lat0), this.sinlat0 = Math.sin(this.lat0), this.sphere ? this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= G && (this.k0 = 0.5 * (1 + xr(this.lat0) * Math.sin(this.lat_ts))) : (Math.abs(this.coslat0) <= G && (this.lat0 > 0 ? this.con = 1 : this.con = -1), this.cons = Math.sqrt(Math.pow(1 + this.e, 1 + this.e) * Math.pow(1 - this.e, 1 - this.e)), this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= G && (this.k0 = 0.5 * this.cons * ti(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)) / ze(this.e, this.con * this.lat_ts, this.con * Math.sin(this.lat_ts))), this.ms1 = ti(this.e, this.sinlat0, this.coslat0), this.X0 = 2 * Math.atan(this.ssfn_(this.lat0, this.sinlat0, this.e)) - A, this.cosX0 = Math.cos(this.X0), this.sinX0 = Math.sin(this.X0)); 1745} 1746function $0(e) { 1747 var t = e.x, i = e.y, s = Math.sin(i), n = Math.cos(i), r, o, a, l, h, c, u = U(t - this.long0); 1748 return Math.abs(Math.abs(t - this.long0) - Math.PI) <= G && Math.abs(i + this.lat0) <= G ? (e.x = NaN, e.y = NaN, e) : this.sphere ? (r = 2 * this.k0 / (1 + this.sinlat0 * s + this.coslat0 * n * Math.cos(u)), e.x = this.a * r * n * Math.sin(u) + this.x0, e.y = this.a * r * (this.coslat0 * s - this.sinlat0 * n * Math.cos(u)) + this.y0, e) : (o = 2 * Math.atan(this.ssfn_(i, s, this.e)) - A, l = Math.cos(o), a = Math.sin(o), Math.abs(this.coslat0) <= G ? (h = ze(this.e, i * this.con, this.con * s), c = 2 * this.a * this.k0 * h / this.cons, e.x = this.x0 + c * Math.sin(t - this.long0), e.y = this.y0 - this.con * c * Math.cos(t - this.long0), e) : (Math.abs(this.sinlat0) < G ? (r = 2 * this.a * this.k0 / (1 + l * Math.cos(u)), e.y = r * a) : (r = 2 * this.a * this.k0 * this.ms1 / (this.cosX0 * (1 + this.sinX0 * a + this.cosX0 * l * Math.cos(u))), e.y = r * (this.cosX0 * a - this.sinX0 * l * Math.cos(u)) + this.y0), e.x = r * l * Math.sin(u) + this.x0, e)); 1749} 1750function Y0(e) { 1751 e.x -= this.x0, e.y -= this.y0; 1752 var t, i, s, n, r, o = Math.sqrt(e.x * e.x + e.y * e.y); 1753 if (this.sphere) { 1754 var a = 2 * Math.atan(o / (2 * this.a * this.k0)); 1755 return t = this.long0, i = this.lat0, o <= G ? (e.x = t, e.y = i, e) : (i = Math.asin(Math.cos(a) * this.sinlat0 + e.y * Math.sin(a) * this.coslat0 / o), Math.abs(this.coslat0) < G ? this.lat0 > 0 ? t = U(this.long0 + Math.atan2(e.x, -1 * e.y)) : t = U(this.long0 + Math.atan2(e.x, e.y)) : t = U(this.long0 + Math.atan2(e.x * Math.sin(a), o * this.coslat0 * Math.cos(a) - e.y * this.sinlat0 * Math.sin(a))), e.x = t, e.y = i, e); 1756 } else if (Math.abs(this.coslat0) <= G) { 1757 if (o <= G) 1758 return i = this.lat0, t = this.long0, e.x = t, e.y = i, e; 1759 e.x *= this.con, e.y *= this.con, s = o * this.cons / (2 * this.a * this.k0), i = this.con * tr(this.e, s), t = this.con * U(this.con * this.long0 + Math.atan2(e.x, -1 * e.y)); 1760 } else 1761 n = 2 * Math.atan(o * this.cosX0 / (2 * this.a * this.k0 * this.ms1)), t = this.long0, o <= G ? r = this.X0
1761: (r = Math.asin(Math.cos(n) * this.sinX0 + e.y * Math.sin(n) * this.cosX0 / o), t = U(this.long0 + Math.atan2(e.x * Math.sin(n), o * this.cosX0 * Math.cos(n) - e.y * this.sinX0 * Math.sin(n)))), i = -1 * tr(this.e, Math.tan(0.5 * (A + r))); 1762 return e.x = t, e.y = i, e; 1763} 1764var K0 = ["stere", "Stereographic_South_Pole", "Polar Stereographic (variant B)"]; 1765const V0 = { 1766 init: X0, 1767 forward: $0, 1768 inverse: Y0, 1769 names: K0, 1770 ssfn_: U0 1771}; 1772function q0() { 1773 var e = this.lat0; 1774 this.lambda0 = this.long0; 1775 var t = Math.sin(e), i = this.a, s = this.rf, n = 1 / s, r = 2 * n - Math.pow(n, 2), o = this.e = Math.sqrt(r); 1776 this.R = this.k0 * i * Math.sqrt(1 - r) / (1 - r * Math.pow(t, 2)), this.alpha = Math.sqrt(1 + r / (1 - r) * Math.pow(Math.cos(e), 4)), this.b0 = Math.asin(t / this.alpha); 1777 var a = Math.log(Math.tan(Math.PI / 4 + this.b0 / 2)), l = Math.log(Math.tan(Math.PI / 4 + e / 2)), h = Math.log((1 + o * t) / (1 - o * t)); 1778 this.K = a - this.alpha * l + this.alpha * o / 2 * h; 1779} 1780function H0(e) { 1781 var t = Math.log(Math.tan(Math.PI / 4 - e.y / 2)), i = this.e / 2 * Math.log((1 + this.e * Math.sin(e.y)) / (1 - this.e * Math.sin(e.y))), s = -this.alpha * (t + i) + this.K, n = 2 * (Math.atan(Math.exp(s)) - Math.PI / 4), r = this.alpha * (e.x - this.lambda0), o = Math.atan(Math.sin(r) / (Math.sin(this.b0) * Math.tan(n) + Math.cos(this.b0) * Math.cos(r))), a = Math.asin(Math.cos(this.b0) * Math.sin(n) - Math.sin(this.b0) * Math.cos(n) * Math.cos(r)); 1782 return e.y = this.R / 2 * Math.log((1 + Math.sin(a)) / (1 - Math.sin(a))) + this.y0, e.x = this.R * o + this.x0, e; 1783} 1784function Z0(e) { 1785 for (var t = e.x - this.x0, i = e.y - this.y0, s = t / this.R, n = 2 * (Math.atan(Math.exp(i / this.R)) - Math.PI / 4), r = Math.asin(Math.cos(this.b0) * Math.sin(n) + Math.sin(this.b0) * Math.cos(n) * Math.cos(s)), o = Math.atan(Math.sin(s) / (Math.cos(this.b0) * Math.cos(s) - Math.sin(this.b0) * Math.tan(n))), a = this.lambda0 + o / this.alpha, l = 0, h = r, c = -1e3, u = 0; Math.abs(h - c) > 1e-7; ) { 1786 if (++u > 20) 1787 return; 1788 l = 1 / this.alpha * (Math.log(Math.tan(Math.PI / 4 + r / 2)) - this.K) + this.e * Math.log(Math.tan(Math.PI / 4 + Math.asin(this.e * Math.sin(h)) / 2)), c = h, h = 2 * Math.atan(Math.exp(l)) - Math.PI / 2; 1789 } 1790 return e.x = a, e.y = h, e; 1791} 1792var J0 = ["somerc"]; 1793const Q0 = { 1794 init: q0, 1795 forward: H0, 1796 inverse: Z0, 1797 names: J0 1798}; 1799var Gs = 1e-7; 1800function tm(e) { 1801 var t = ["Hotine_Oblique_Mercator", "Hotine_Oblique_Mercator_Azimuth_Natural_Origin"], i = typeof e.PROJECTION == "object" ? Object.keys(e.PROJECTION)[0] : e.PROJECTION; 1802 return "no_uoff" in e || "no_off" in e || t.indexOf(i) !== -1; 1803} 1804function em() { 1805 var e, t, i, s, n, r, o, a, l, h, c = 0, u, d = 0, f = 0, g = 0, _ = 0, m = 0, p = 0; 1806 this.no_off = tm(this), this.no_rot = "no_rot" in this; 1807 var y = !1; 1808 "alpha" in this && (y = !0); 1809 var v = !1; 1810 if ("rectified_grid_angle" in this && (v = !0), y && (p = this.alpha), v && (c = this.rectified_grid_angle * Vt), y || v) 1811 d = this.longc; 1812 else if (f = this.long1, _ = this.lat1, g = this.long2, m = this.lat2, Math.abs(_ - m) <= Gs || (e = Math.abs(_)) <= Gs || Math.abs(e - A) <= Gs || Math.abs(Math.abs(this.lat0) - A) <= Gs || Math.abs(Math.abs(m) - A) <= Gs) 1813 throw new Error(); 1814 var E = 1 - this.es; 1815 t = Math.sqrt(E), Math.abs(this.lat0) > G ? (a = Math.sin(this.lat0), i = Math.cos(this.lat0), e = 1 - this.es * a * a, this.B = i * i, this.B = Math.sqrt(1 + this.es * this.B * this.B / E), this.A = this.B * this.k0 * t / e, s = this.B * t / (i * Math.sqrt(e)), n = s * s - 1, n <= 0 ? n = 0 : (n = Math.sqrt(n), this.lat0 < 0 && (n = -n)), this.E = n += s, this.E *= Math.pow(ze(this.e, this.lat0, a), this.B)) : (this.B = 1 / t, this.A = this.k0, this.E = s = n = 1), y || v ? (y ? (u = Math.asin(Math.sin(p) / s), v || (c = p)) : (u = c, p = Math.asin(s * Math.sin(u))), this.lam0 = d - Math.asin(0.5 * (n - 1 / n) * Math.tan(u)) / this.B) : (r = Math.pow(ze(this.e, _, Math.sin(_)), this.B), o = Math.pow(ze(this.e, m, Math.sin(m)), this.B), n = this.E / r, l = (o - r) / (o + r), h = this.E * this.E, h = (h - o * r) / (h + o * r), e = f - g, e < -Math.pi ? g -= Jn : e > Math.pi && (g += Jn), this.lam0 = U(0.5 * (f + g) - Math.atan(h * Math.tan(0.5 * this.B * (f - g)) / l) / this.B), u = Math.atan(2 * Math.sin(this.B * U(f - this.lam0)) / (n - 1 / n)), c = p = Math.asin(s * Math.sin(u))), this.singam = Math.sin(u), this.cosgam = Math.
1815cos(u), this.sinrot = Math.sin(c), this.cosrot = Math.cos(c), this.rB = 1 / this.B, this.ArB = this.A * this.rB, this.BrA = 1 / this.ArB, this.A * this.B, this.no_off ? this.u_0 = 0 : (this.u_0 = Math.abs(this.ArB * Math.atan(Math.sqrt(s * s - 1) / Math.cos(p))), this.lat0 < 0 && (this.u_0 = -this.u_0)), n = 0.5 * u, this.v_pole_n = this.ArB * Math.log(Math.tan(yt - n)), this.v_pole_s = this.ArB * Math.log(Math.tan(yt + n)); 1816} 1817function im(e) { 1818 var t = {}, i, s, n, r, o, a, l, h; 1819 if (e.x = e.x - this.lam0, Math.abs(Math.abs(e.y) - A) > G) { 1820 if (o = this.E / Math.pow(ze(this.e, e.y, Math.sin(e.y)), this.B), a = 1 / o, i = 0.5 * (o - a), s = 0.5 * (o + a), r = Math.sin(this.B * e.x), n = (i * this.singam - r * this.cosgam) / s, Math.abs(Math.abs(n) - 1) < G) 1821 throw new Error(); 1822 h = 0.5 * this.ArB * Math.log((1 - n) / (1 + n)), a = Math.cos(this.B * e.x), Math.abs(a) < Gs ? l = this.A * e.x : l = this.ArB * Math.atan2(i * this.cosgam + r * this.singam, a); 1823 } else 1824 h = e.y > 0 ? this.v_pole_n : this.v_pole_s, l = this.ArB * e.y; 1825 return this.no_rot ? (t.x = l, t.y = h) : (l -= this.u_0, t.x = h * this.cosrot + l * this.sinrot, t.y = l * this.cosrot - h * this.sinrot), t.x = this.a * t.x + this.x0, t.y = this.a * t.y + this.y0, t; 1826} 1827function sm(e) { 1828 var t, i, s, n, r, o, a, l = {}; 1829 if (e.x = (e.x - this.x0) * (1 / this.a), e.y = (e.y - this.y0) * (1 / this.a), this.no_rot ? (i = e.y, t = e.x) : (i = e.x * this.cosrot - e.y * this.sinrot, t = e.y * this.cosrot + e.x * this.sinrot + this.u_0), s = Math.exp(-this.BrA * i), n = 0.5 * (s - 1 / s), r = 0.5 * (s + 1 / s), o = Math.sin(this.BrA * t), a = (o * this.cosgam + n * this.singam) / r, Math.abs(Math.abs(a) - 1) < G) 1830 l.x = 0, l.y = a < 0 ? -A : A; 1831 else { 1832 if (l.y = this.E / Math.sqrt((1 + a) / (1 - a)), l.y = tr(this.e, Math.pow(l.y, 1 / this.B)), l.y === 1 / 0) 1833 throw new Error(); 1834 l.x = -this.rB * Math.atan2(n * this.cosgam - o * this.singam, Math.cos(this.BrA * t)); 1835 } 1836 return l.x += this.lam0, l; 1837} 1838var nm = ["Hotine_Oblique_Mercator", "Hotine Oblique Mercator", "Hotine_Oblique_Mercator_Azimuth_Natural_Origin", "Hotine_Oblique_Mercator_Two_Point_Natural_Origin", "Hotine_Oblique_Mercator_Azimuth_Center", "Oblique_Mercator", "omerc"]; 1839const rm = { 1840 init: em, 1841 forward: im, 1842 inverse: sm, 1843 names: nm 1844}; 1845function om() { 1846 if (this.lat2 || (this.lat2 = this.lat1), this.k0 || (this.k0 = 1), this.x0 = this.x0 || 0, this.y0 = this.y0 || 0, !(Math.abs(this.lat1 + this.lat2) < G)) { 1847 var e = this.b / this.a; 1848 this.e = Math.sqrt(1 - e * e); 1849 var t = Math.sin(this.lat1), i = Math.cos(this.lat1), s = ti(this.e, t, i), n = ze(this.e, this.lat1, t), r = Math.sin(this.lat2), o = Math.cos(this.lat2), a = ti(this.e, r, o), l = ze(this.e, this.lat2, r), h = ze(this.e, this.lat0, Math.sin(this.lat0)); 1850 Math.abs(this.lat1 - this.lat2) > G ? this.ns = Math.log(s / a) / Math.log(n / l) : this.ns = t, isNaN(this.ns) && (this.ns = t), this.f0 = s / (this.ns * Math.pow(n, this.ns)), this.rh = this.a * this.f0 * Math.pow(h, this.ns), this.title || (this.title = "Lambert Conformal Conic"); 1851 } 1852} 1853function am(e) { 1854 var t = e.x, i = e.y; 1855 Math.abs(2 * Math.abs(i) - Math.PI) <= G && (i = xr(i) * (A - 2 * G)); 1856 var s = Math.abs(Math.abs(i) - A), n, r; 1857 if (s > G) 1858 n = ze(this.e, i, Math.sin(i)), r = this.a * this.f0 * Math.pow(n, this.ns); 1859 else { 1860 if (s = i * this.ns, s <= 0) 1861 return null; 1862 r = 0; 1863 } 1864 var o = this.ns * U(t - this.long0); 1865 return e.x = this.k0 * (r * Math.sin(o)) + this.x0, e.y = this.k0 * (this.rh - r * Math.cos(o)) + this.y0, e; 1866} 1867function lm(e) { 1868 var t, i, s, n, r, o = (e.x - this.x0) / this.k0, a = this.rh - (e.y - this.y0) / this.k0; 1869 this.ns > 0 ? (t = Math.sqrt(o * o + a * a), i = 1) : (t = -Math.sqrt(o * o + a * a), i = -1); 1870 var l = 0; 1871 if (t !== 0 && (l = Math.atan2(i * o, i * a)), t !== 0 || this.ns > 0) { 1872 if (i = 1 / this.ns, s = Math.pow(t / (this.a * this.f0), i), n = tr(this.e, s), n === -9999) 1873 return null; 1874 } else 1875 n = -A; 1876 return r = U(l / this.ns + this.long0), e.x = r, e.y = n, e; 1877} 1878var hm = [ 1879 "Lambert Tangential Conformal Conic Projection",
1880 "Lambert_Conformal_Conic", 1881 "Lambert_Conformal_Conic_1SP", 1882 "Lambert_Conformal_Conic_2SP", 1883 "lcc", 1884 "Lambert Conic Conformal (1SP)", 1885 "Lambert Conic Conformal (2SP)" 1886]; 1887const cm = { 1888 init: om, 1889 forward: am, 1890 inverse: lm, 1891 names: hm 1892}; 1893function um() { 1894 this.a = 6377397155e-3, this.es = 0.006674372230614, this.e = Math.sqrt(this.es), this.lat0 || (this.lat0 = 0.863937979737193), this.long0 || (this.long0 = 0.7417649320975901 - 0.308341501185665), this.k0 || (this.k0 = 0.9999), this.s45 = 0.785398163397448, this.s90 = 2 * this.s45, this.fi0 = this.lat0, this.e2 = this.es, this.e = Math.sqrt(this.e2), this.alfa = Math.sqrt(1 + this.e2 * Math.pow(Math.cos(this.fi0), 4) / (1 - this.e2)), this.uq = 1.04216856380474, this.u0 = Math.asin(Math.sin(this.fi0) / this.alfa), this.g = Math.pow((1 + this.e * Math.sin(this.fi0)) / (1 - this.e * Math.sin(this.fi0)), this.alfa * this.e / 2), this.k = Math.tan(this.u0 / 2 + this.s45) / Math.pow(Math.tan(this.fi0 / 2 + this.s45), this.alfa) * this.g, this.k1 = this.k0, this.n0 = this.a * Math.sqrt(1 - this.e2) / (1 - this.e2 * Math.pow(Math.sin(this.fi0), 2)), this.s0 = 1.37008346281555, this.n = Math.sin(this.s0), this.ro0 = this.k1 * this.n0 / Math.tan(this.s0), this.ad = this.s90 - this.uq; 1895} 1896function dm(e) { 1897 var t, i, s, n, r, o, a, l = e.x, h = e.y, c = U(l - this.long0); 1898 return t = Math.pow((1 + this.e * Math.sin(h)) / (1 - this.e * Math.sin(h)), this.alfa * this.e / 2), i = 2 * (Math.atan(this.k * Math.pow(Math.tan(h / 2 + this.s45), this.alfa) / t) - this.s45), s = -c * this.alfa, n = Math.asin(Math.cos(this.ad) * Math.sin(i) + Math.sin(this.ad) * Math.cos(i) * Math.cos(s)), r = Math.asin(Math.cos(i) * Math.sin(s) / Math.cos(n)), o = this.n * r, a = this.ro0 * Math.pow(Math.tan(this.s0 / 2 + this.s45), this.n) / Math.pow(Math.tan(n / 2 + this.s45), this.n), e.y = a * Math.cos(o) / 1, e.x = a * Math.sin(o) / 1, this.czech || (e.y *= -1, e.x *= -1), e; 1899} 1900function fm(e) { 1901 var t, i, s, n, r, o, a, l, h = e.x; 1902 e.x = e.y, e.y = h, this.czech || (e.y *= -1, e.x *= -1), o = Math.sqrt(e.x * e.x + e.y * e.y), r = Math.atan2(e.y, e.x), n = r / Math.sin(this.s0), s = 2 * (Math.atan(Math.pow(this.ro0 / o, 1 / this.n) * Math.tan(this.s0 / 2 + this.s45)) - this.s45), t = Math.asin(Math.cos(this.ad) * Math.sin(s) - Math.sin(this.ad) * Math.cos(s) * Math.cos(n)), i = Math.asin(Math.cos(s) * Math.sin(n) / Math.cos(t)), e.x = this.long0 - i / this.alfa, a = t, l = 0; 1903 var c = 0; 1904 do 1905 e.y = 2 * (Math.atan(Math.pow(this.k, -1 / this.alfa) * Math.pow(Math.tan(t / 2 + this.s45), 1 / this.alfa) * Math.pow((1 + this.e * Math.sin(a)) / (1 - this.e * Math.sin(a)), this.e / 2)) - this.s45), Math.abs(a - e.y) < 1e-10 && (l = 1), a = e.y, c += 1; 1906 while (l === 0 && c < 15); 1907 return c >= 15 ? null : e; 1908} 1909var gm = ["Krovak", "krovak"]; 1910const _m = { 1911 init: um, 1912 forward: dm, 1913 inverse: fm, 1914 names: gm 1915}; 1916function ue(e, t, i, s, n) { 1917 return e * n - t * Math.sin(2 * n) + i * Math.sin(4 * n) - s * Math.sin(6 * n); 1918} 1919function vr(e) { 1920 return 1 - 0.25 * e * (1 + e / 16 * (3 + 1.25 * e)); 1921} 1922function Er(e) { 1923 return 0.375 * e * (1 + 0.25 * e * (1 + 0.46875 * e)); 1924} 1925function Mr(e) { 1926 return 0.05859375 * e * e * (1 + 0.75 * e); 1927} 1928function Cr(e) { 1929 return e * e * e * (35 / 3072); 1930} 1931function cn(e, t, i) { 1932 var s = t * i; 1933 return e / Math.sqrt(1 - s * s); 1934} 1935function Cn(e) { 1936 return Math.abs(e) < A ? e : e - xr(e) * Math.PI; 1937} 1938function Eo(e, t, i, s, n) { 1939 var r, o; 1940 r = e / t; 1941 for (var a = 0; a < 15; a++) 1942 if (o = (e - (t * r - i * Math.sin(2 * r) + s * Math.sin(4 * r) - n * Math.sin(6 * r))) / (t - 2 * i * Math.cos(2 * r) + 4 * s * Math.cos(4 * r) - 6 * n * Math.cos(6 * r)), r += o, Math.abs(o) <= 1e-10) 1943 return r; 1944 return NaN; 1945} 1946function mm() { 1947 this.sphere || (this.e0 = vr(this.es), this.e1 = Er(this.es), this.e2 = Mr(this.es), this.e3 = Cr(this.es), this.ml0 = this.a * ue(this.e0, this.e1, this.e2, this.e3, this.lat0)); 1948} 1949function pm(e) { 1950 var t, i, s = e.x, n = e.y; 1951 if (s = U(s - this.long0), this.sphere) 1952 t = this.a * Math.asin(Math.cos(n) * Math.sin(s)), i = this.a * (Math.atan2(Math.tan(n), Math.cos(s)) - this.lat0); 1953 else { 1954 var r = Math.sin(n), o = Math.cos(n), a = cn(this.a, this.e, r), l = Math.tan(n) * Math.tan(n), h = s * Math.cos(n), c = h * h, u = this.es * o * o / (1 - this.es), d = this.a * ue(this.e0, this.e1, this.e2, this.e3, n); 1955 t = a * h * (1 - c * l * (1 / 6 - (8 - l + 8 * u) * c / 120)), i = d - this.ml0 + a * r / o * c * (0.5 + (5 - l + 6 * u) * c / 24); 1956 } 1957 return e.x = t + this.x0, e.y = i + this.y0, e; 1958} 1959function ym(e) { 1960 e.x -= this.x0, e.y -= this.y0; 1961 var t = e.x / this.a, i = e.y / this.a, s, n; 1962 if (this.sphere) { 1963 var r = i + this.lat0; 1964 s = Math.asin(Math.sin(r) * Math.cos(t)), n = Math.atan2(Math.tan(t), Math.cos(r)); 1965 } else { 1966 var o = this.ml0 / this.a + i, a = Eo(o, this.e0, this.e1, this.e2, this.e3); 1967 if (Math.abs(Math.abs(a) - A) <= G) 1968 return e.x = this.long0, e.y = A, i < 0 && (e.y *= -1), e; 1969 var l = cn(this.a, this.e, Math.sin(a)), h = l * l * l / this.a / this.a * (1 - this.es), c = Math.pow(Math.tan(a), 2), u = t * this.a / l, d = u * u; 1970 s = a - l * Math.tan(a) / h * u * u * (0.5 - (1 + 3 * c) * u * u / 24), n = u * (1 - d * (c / 3 + (1 + 3 * c) * c * d / 15)) / Math.cos(a); 1971 }
1972 return e.x = U(n + this.long0), e.y = Cn(s), e; 1973} 1974var xm = ["Cassini", "Cassini_Soldner", "cass"]; 1975const vm = { 1976 init: mm, 1977 forward: pm, 1978 inverse: ym, 1979 names: xm 1980}; 1981function Xi(e, t) { 1982 var i; 1983 return e > 1e-7 ? (i = e * t, (1 - e * e) * (t / (1 - i * i) - 0.5 / e * Math.log((1 - i) / (1 + i)))) : 2 * t; 1984} 1985var Em = 1, Mm = 2, Cm = 3, bm = 4; 1986function Sm() { 1987 var e = Math.abs(this.lat0); 1988 if (Math.abs(e - A) < G ? this.mode = this.lat0 < 0 ? this.S_POLE : this.N_POLE : Math.abs(e) < G ? this.mode = this.EQUIT : this.mode = this.OBLIQ, this.es > 0) { 1989 var t; 1990 switch (this.qp = Xi(this.e, 1), this.mmf = 0.5 / (1 - this.es), this.apa = Fm(this.es), this.mode) { 1991 case this.N_POLE: 1992 this.dd = 1; 1993 break; 1994 case this.S_POLE: 1995 this.dd = 1; 1996 break; 1997 case this.EQUIT: 1998 this.rq = Math.sqrt(0.5 * this.qp), this.dd = 1 / this.rq, this.xmf = 1, this.ymf = 0.5 * this.qp; 1999 break; 2000 case this.OBLIQ: 2001 this.rq = Math.sqrt(0.5 * this.qp), t = Math.sin(this.lat0), this.sinb1 = Xi(this.e, t) / this.qp, this.cosb1 = Math.sqrt(1 - this.sinb1 * this.sinb1), this.dd = Math.cos(this.lat0) / (Math.sqrt(1 - this.es * t * t) * this.rq * this.cosb1), this.ymf = (this.xmf = this.rq) / this.dd, this.xmf *= this.dd; 2002 break; 2003 } 2004 } else 2005 this.mode === this.OBLIQ && (this.sinph0 = Math.sin(this.lat0), this.cosph0 = Math.cos(this.lat0)); 2006} 2007function wm(e) { 2008 var t, i, s, n, r, o, a, l, h, c, u = e.x, d = e.y; 2009 if (u = U(u - this.long0), this.sphere) { 2010 if (r = Math.sin(d), c = Math.cos(d), s = Math.cos(u), this.mode === this.OBLIQ || this.mode === this.EQUIT) { 2011 if (i = this.mode === this.EQUIT ? 1 + c * s : 1 + this.sinph0 * r + this.cosph0 * c * s, i <= G) 2012 return null; 2013 i = Math.sqrt(2 / i), t = i * c * Math.sin(u), i *= this.mode === this.EQUIT ? r : this.cosph0 * r - this.sinph0 * c * s; 2014 } else if (this.mode === this.N_POLE || this.mode === this.S_POLE) { 2015 if (this.mode === this.N_POLE && (s = -s), Math.abs(d + this.lat0) < G) 2016 return null; 2017 i = yt - d * 0.5, i = 2 * (this.mode === this.S_POLE ? Math.cos(i) : Math.sin(i)), t = i * Math.sin(u), i *= s; 2018 } 2019 } else { 2020 switch (a = 0, l = 0, h = 0, s = Math.cos(u), n = Math.sin(u), r = Math.sin(d), o = Xi(this.e, r), (this.mode === this.OBLIQ || this.mode === this.EQUIT) && (a = o / this.qp, l = Math.sqrt(1 - a * a)), this.mode) { 2021 case this.OBLIQ: 2022 h = 1 + this.sinb1 * a + this.cosb1 * l * s; 2023 break; 2024 case this.EQUIT: 2025 h = 1 + l * s; 2026 break; 2027 case this.N_POLE: 2028 h = A + d, o = this.qp - o; 2029 break; 2030 case this.S_POLE: 2031 h = d - A, o = this.qp + o; 2032 break; 2033 } 2034 if (Math.abs(h) < G) 2035 return null; 2036 switch (this.mode) { 2037 case this.OBLIQ: 2038 case this.EQUIT: 2039 h = Math.sqrt(2 / h), this.mode === this.OBLIQ ? i = this.ymf * h * (this.cosb1 * a - this.sinb1 * l * s) : i = (h = Math.sqrt(2 / (1 + l * s))) * a * this.ymf, t = this.xmf * h * l * n; 2040 break; 2041 case this.N_POLE: 2042 case this.S_POLE: 2043 o >= 0 ? (t = (h = Math.sqrt(o)) * n, i = s * (this.mode === this.S_POLE ? h : -h)) : t = i = 0; 2044 break; 2045 } 2046 } 2047 return e.x = this.a * t + this.x0, e.y = this.a * i + this.y0, e; 2048} 2049function Tm(e) { 2050 e.x -= this.x0, e.y -= this.y0; 2051 var t = e.x / this.a, i = e.y / this.a, s, n, r, o, a, l, h; 2052 if (this.sphere) { 2053 var c = 0, u, d = 0; 2054 if (u = Math.sqrt(t * t + i * i), n = u * 0.5, n > 1) 2055 return null; 2056 switch (n = 2 * Math.asin(n), (this.mode === this.OBLIQ || this.mode === this.EQUIT) && (d = Math.sin(n), c = Math.cos(n)), this.mode) { 2057 case this.EQUIT: 2058 n = Math.abs(u) <= G ? 0 : Math.asin(i * d / u), t *= d, i = c * u; 2059 break; 2060 case this.OBLIQ: 2061 n = Math.abs(u) <= G ? this.lat0 : Math.asin(c * this.sinph0 + i * d * this.cosph0 / u), t *= d * this.cosph0, i = (c - Math.sin(n) * this.sinph0) * u; 2062 break; 2063 case this.N_POLE: 2064 i = -i, n = A - n; 2065 break; 2066 case this.S_POLE: 2067 n -= A; 2068 break; 2069 } 2070 s = i === 0 && (this.mode === this.EQUIT || this.mode === this.OBLIQ) ? 0 : Math.atan2(t, i); 2071 } else { 2072 if (h = 0, this.mode === this.OBLIQ || this.mode === this.EQUIT) { 2073 if (t /= this.dd, i *= this.dd, l = Math.sqrt(t * t + i * i), l < G) 2074 return e.x = this.long0, e.y = this.lat0, e;
2075 o = 2 * Math.asin(0.5 * l / this.rq), r = Math.cos(o), t *= o = Math.sin(o), this.mode === this.OBLIQ ? (h = r * this.sinb1 + i * o * this.cosb1 / l, a = this.qp * h, i = l * this.cosb1 * r - i * this.sinb1 * o) : (h = i * o / l, a = this.qp * h, i = l * r); 2076 } else if (this.mode === this.N_POLE || this.mode === this.S_POLE) { 2077 if (this.mode === this.N_POLE && (i = -i), a = t * t + i * i, !a) 2078 return e.x = this.long0, e.y = this.lat0, e; 2079 h = 1 - a / this.qp, this.mode === this.S_POLE && (h = -h); 2080 } 2081 s = Math.atan2(t, i), n = Dm(Math.asin(h), this.apa); 2082 } 2083 return e.x = U(this.long0 + s), e.y = n, e; 2084} 2085var Rm = 0.3333333333333333, Im = 0.17222222222222222, Pm = 0.10257936507936508, Am = 0.06388888888888888, Lm = 0.0664021164021164, Om = 0.016415012942191543; 2086function Fm(e) { 2087 var t, i = []; 2088 return i[0] = e * Rm, t = e * e, i[0] += t * Im, i[1] = t * Am, t *= e, i[0] += t * Pm, i[1] += t * Lm, i[2] = t * Om, i; 2089} 2090function Dm(e, t) { 2091 var i = e + e; 2092 return e + t[0] * Math.sin(i) + t[1] * Math.sin(i + i) + t[2] * Math.sin(i + i + i); 2093} 2094var Nm = ["Lambert Azimuthal Equal Area", "Lambert_Azimuthal_Equal_Area", "laea"]; 2095const km = { 2096 init: Sm, 2097 forward: wm, 2098 inverse: Tm, 2099 names: Nm, 2100 S_POLE: Em, 2101 N_POLE: Mm, 2102 EQUIT: Cm, 2103 OBLIQ: bm 2104}; 2105function Hi(e) { 2106 return Math.abs(e) > 1 && (e = e > 1 ? 1 : -1), Math.asin(e); 2107} 2108function Gm() { 2109 Math.abs(this.lat1 + this.lat2) < G || (this.temp = this.b / this.a, this.es = 1 - Math.pow(this.temp, 2), this.e3 = Math.sqrt(this.es), this.sin_po = Math.sin(this.lat1), this.cos_po = Math.cos(this.lat1), this.t1 = this.sin_po, this.con = this.sin_po, this.ms1 = ti(this.e3, this.sin_po, this.cos_po), this.qs1 = Xi(this.e3, this.sin_po), this.sin_po = Math.sin(this.lat2), this.cos_po = Math.cos(this.lat2), this.t2 = this.sin_po, this.ms2 = ti(this.e3, this.sin_po, this.cos_po), this.qs2 = Xi(this.e3, this.sin_po), this.sin_po = Math.sin(this.lat0), this.cos_po = Math.cos(this.lat0), this.t3 = this.sin_po, this.qs0 = Xi(this.e3, this.sin_po), Math.abs(this.lat1 - this.lat2) > G ? this.ns0 = (this.ms1 * this.ms1 - this.ms2 * this.ms2) / (this.qs2 - this.qs1) : this.ns0 = this.con, this.c = this.ms1 * this.ms1 + this.ns0 * this.qs1, this.rh = this.a * Math.sqrt(this.c - this.ns0 * this.qs0) / this.ns0); 2110} 2111function zm(e) { 2112 var t = e.x, i = e.y; 2113 this.sin_phi = Math.sin(i), this.cos_phi = Math.cos(i); 2114 var s = Xi(this.e3, this.sin_phi), n = this.a * Math.sqrt(this.c - this.ns0 * s) / this.ns0, r = this.ns0 * U(t - this.long0), o = n * Math.sin(r) + this.x0, a = this.rh - n * Math.cos(r) + this.y0; 2115 return e.x = o, e.y = a, e; 2116} 2117function jm(e) { 2118 var t, i, s, n, r, o; 2119 return e.x -= this.x0, e.y = this.rh - e.y + this.y0, this.ns0 >= 0 ? (t = Math.sqrt(e.x * e.x + e.y * e.y), s = 1) : (t = -Math.sqrt(e.x * e.x + e.y * e.y), s = -1), n = 0, t !== 0 && (n = Math.atan2(s * e.x, s * e.y)), s = t * this.ns0 / this.a, this.sphere ? o = Math.asin((this.c - s * s) / (2 * this.ns0)) : (i = (this.c - s * s) / this.ns0, o = this.phi1z(this.e3, i)), r = U(n / this.ns0 + this.long0), e.x = r, e.y = o, e; 2120} 2121function Wm(e, t) { 2122 var i, s, n, r, o, a = Hi(0.5 * t); 2123 if (e < G) 2124 return a; 2125 for (var l = e * e, h = 1; h <= 25; h++) 2126 if (i = Math.sin(a), s = Math.cos(a), n = e * i, r = 1 - n * n, o = 0.5 * r * r / s * (t / (1 - l) - i / r + 0.5 / e * Math.log((1 - n) / (1 + n))), a = a + o, Math.abs(o) <= 1e-7) 2127 return a; 2128 return null; 2129} 2130var Bm = ["Albers_Conic_Equal_Area", "Albers", "aea"]; 2131const Um = { 2132 init: Gm, 2133 forward: zm, 2134 inverse: jm, 2135 names: Bm, 2136 phi1z: Wm 2137}; 2138function Xm() { 2139 this.sin_p14 = Math.sin(this.lat0), this.cos_p14 = Math.cos(this.lat0), this.infinity_dist = 1e3 * this.a, this.rc = 1; 2140} 2141function $m(e) { 2142 var t, i, s, n, r, o, a, l, h = e.x, c = e.y; 2143 return s = U(h - this.long0), t = Math.sin(c), i = Math.cos(c), n = Math.cos(s), o = this.sin_p14 * t + this.cos_p14 * i * n, r = 1, o > 0 || Math.abs(o) <= G ? (a = this.x0 + this.a * r * i * Math.sin(s) / o, l = this.y0 + this.a * r * (this.cos_p14 * t - this.sin_p14 * i * n) / o) : (a = this.x0 + this.infinity_dist * i * Math.sin(s), l = this.y0 + this.infinity_dist * (this.cos_p14 * t - this.sin_p14 * i * n)), e.x = a, e.y = l, e; 2144} 2145function Ym(e) { 2146 var t, i, s, n, r, o; 2147 return e.x = (e.x - this.x0) / this.a, e.y = (e.y - this.y0) / this.a, e.x /= this.k0, e.y /= this.k0, (t = Math.sqrt(e.x * e.x + e.y * e.y)) ? (n = Math.atan2(t, this.rc), i = Math.sin(n), s = Math.cos(n), o = Hi(s * this.sin_p14 + e.y * i * this.cos_p14 / t), r = Math.atan2(e.x * i, t * this.cos_p14 * s - e.y * this.sin_p14 * i), r = U(this.long0 + r)) : (o = this.phic0, r = 0), e.x = r, e.y = o, e; 2148} 2149var Km = ["gnom"]; 2150const Vm = { 2151 init: Xm, 2152 forward: $m, 2153 inverse: Ym, 2154 names: Km 2155}; 2156function qm(e, t) { 2157 var i = 1 - (1 - e * e) / (2 * e) * Math.log((1 - e) / (1 + e)); 2158 if (Math.abs(Math.abs(t) - i) < 1e-6) 2159 return t < 0 ? -1 * A : A; 2160 for (var s = Math.asin(0.5 * t), n, r, o, a, l = 0; l < 30; l++) 2161 if (r = Math.sin(s), o = Math.cos(s), a = e * r, n = Math.pow(1 - a * a, 2) / (2 * o) * (t / (1 - e * e) - r / (1 - a * a) + 0.5 / e * Math.log((1 - a) / (1 + a))), s += n, Math.abs(n) <= 1e-10) 2162 return s; 2163 return NaN; 2164} 2165function Hm() { 2166 this.sphere || (this.k0 = ti(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts))); 2167} 2168function Zm(e) { 2169 var t = e.x, i = e.y, s, n, r = U(t - this.long0); 2170 if (this.sphere) 2171 s = this.x0 + this.a * r * Math.cos(this.lat_ts), n = this.y0 + this.a * Math.sin(i) / Math.cos(this.lat_ts); 2172 else { 2173 var o = Xi(this.e, Math.sin(i)); 2174 s = this.x0 + this.a * this.k0 * r, n = this.y0 + this.a * o * 0.5 / this.k0; 2175 } 2176 return e.x = s, e.y = n, e; 2177} 2178function Jm(e) { 2179 e.x -= this.x0, e.y -= this.y0; 2180 var t, i; 2181 return this.sphere ? (t = U(this.long0 + e.x / this.a / Math.cos(this.lat_ts)), i = Math.asin(e.y / this.a * Math.cos(this.lat_ts))) : (i = qm(this.e, 2 * e.y * this.k0 / this.a), t = U(this.long0 + e.x / (this.a * this.k0))), e.x = t, e.y = i, e; 2182} 2183var Qm = ["cea"]; 2184const tp = { 2185 init: Hm, 2186 forward: Zm, 2187 inverse: Jm, 2188 names: Qm 2189}; 2190function ep() { 2191 this.x0 = this.x0 || 0, this.y0 = this.y0 || 0, this.lat0 = this.lat0 || 0, this.long0 = this.long0 || 0, this.lat_ts = this.lat_ts || 0, this.title = this.title || "Equidistant Cylindrical (Plate Carre)", this.rc = Math.cos(this.lat_ts); 2192} 2193function ip(e) { 2194 var t = e.x, i = e.y, s = U(t - this.long0), n = Cn(i - this.lat0); 2195 return e.x = this.x0 + this.a * s * this.rc, e.y = this.y0 + this.a * n, e; 2196} 2197function sp(e) { 2198 var t = e.x, i = e.y;
2199 return e.x = U(this.long0 + (t - this.x0) / (this.a * this.rc)), e.y = Cn(this.lat0 + (i - this.y0) / this.a), e; 2200} 2201var np = ["Equirectangular", "Equidistant_Cylindrical", "eqc"]; 2202const rp = { 2203 init: ep, 2204 forward: ip, 2205 inverse: sp, 2206 names: np 2207}; 2208var Cc = 20; 2209function op() { 2210 this.temp = this.b / this.a, this.es = 1 - Math.pow(this.temp, 2), this.e = Math.sqrt(this.es), this.e0 = vr(this.es), this.e1 = Er(this.es), this.e2 = Mr(this.es), this.e3 = Cr(this.es), this.ml0 = this.a * ue(this.e0, this.e1, this.e2, this.e3, this.lat0); 2211} 2212function ap(e) { 2213 var t = e.x, i = e.y, s, n, r, o = U(t - this.long0); 2214 if (r = o * Math.sin(i), this.sphere) 2215 Math.abs(i) <= G ? (s = this.a * o, n = -1 * this.a * this.lat0) : (s = this.a * Math.sin(r) / Math.tan(i), n = this.a * (Cn(i - this.lat0) + (1 - Math.cos(r)) / Math.tan(i))); 2216 else if (Math.abs(i) <= G) 2217 s = this.a * o, n = -1 * this.ml0; 2218 else { 2219 var a = cn(this.a, this.e, Math.sin(i)) / Math.tan(i); 2220 s = a * Math.sin(r), n = this.a * ue(this.e0, this.e1, this.e2, this.e3, i) - this.ml0 + a * (1 - Math.cos(r)); 2221 } 2222 return e.x = s + this.x0, e.y = n + this.y0, e; 2223} 2224function lp(e) { 2225 var t, i, s, n, r, o, a, l, h; 2226 if (s = e.x - this.x0, n = e.y - this.y0, this.sphere) 2227 if (Math.abs(n + this.a * this.lat0) <= G) 2228 t = U(s / this.a + this.long0), i = 0; 2229 else { 2230 o = this.lat0 + n / this.a, a = s * s / this.a / this.a + o * o, l = o; 2231 var c; 2232 for (r = Cc; r; --r) 2233 if (c = Math.tan(l), h = -1 * (o * (l * c + 1) - l - 0.5 * (l * l + a) * c) / ((l - o) / c - 1), l += h, Math.abs(h) <= G) { 2234 i = l; 2235 break; 2236 } 2237 t = U(this.long0 + Math.asin(s * Math.tan(l) / this.a) / Math.sin(i)); 2238 } 2239 else if (Math.abs(n + this.ml0) <= G) 2240 i = 0, t = U(this.long0 + s / this.a); 2241 else { 2242 o = (this.ml0 + n) / this.a, a = s * s / this.a / this.a + o * o, l = o; 2243 var u, d, f, g, _; 2244 for (r = Cc; r; --r) 2245 if (_ = this.e * Math.sin(l), u = Math.sqrt(1 - _ * _) * Math.tan(l), d = this.a * ue(this.e0, this.e1, this.e2, this.e3, l), f = this.e0 - 2 * this.e1 * Math.cos(2 * l) + 4 * this.e2 * Math.cos(4 * l) - 6 * this.e3 * Math.cos(6 * l), g = d / this.a, h = (o * (u * g + 1) - g - 0.5 * u * (g * g + a)) / (this.es * Math.sin(2 * l) * (g * g + a - 2 * o * g) / (4 * u) + (o - g) * (u * f - 2 / Math.sin(2 * l)) - f), l -= h, Math.abs(h) <= G) { 2246 i = l; 2247 break; 2248 } 2249 u = Math.sqrt(1 - this.es * Math.pow(Math.sin(i), 2)) * Math.tan(i), t = U(this.long0 + Math.asin(s * u / this.a) / Math.sin(i)); 2250 } 2251 return e.x = t, e.y = i, e; 2252} 2253var hp = ["Polyconic", "poly"]; 2254const cp = { 2255 init: op, 2256 forward: ap, 2257 inverse: lp, 2258 names: hp 2259}; 2260function up() { 2261 this.A = [], this.A[1] = 0.6399175073, this.A[2] = -0.1358797613, this.A[3] = 0.063294409, this.A[4] = -0.02526853, this.A[5] = 0.0117879, this.A[6] = -55161e-7, this.A[7] = 26906e-7, this.A[8] = -1333e-6, this.A[9] = 67e-5, this.A[10] = -34e-5, this.B_re = [], this.B_im = [], this.B_re[1] = 0.7557853228, this.B_im[1] = 0, this.B_re[2] = 0.249204646, this.B_im[2] = 3371507e-9, this.B_re[3] = -1541739e-9, this.B_im[3] = 0.04105856, this.B_re[4] = -0.10162907, this.B_im[4] = 0.01727609, this.B_re[5] = -0.26623489, this.B_im[5] = -0.36249218, this.B_re[6] = -0.6870983, this.B_im[6] = -1.1651967, this.C_re = [], this.C_im = [], this.C_re[1] = 1.3231270439, this.C_im[1] = 0, this.C_re[2] = -0.577245789, this.C_im[2] = -7809598e-9, this.C_re[3] = 0.508307513, this.C_im[3] = -0.112208952, this.C_re[4] = -0.15094762, this.C_im[4] = 0.18200602, this.C_re[5] = 1.01418179, this.C_im[5] = 1.64497696, this.C_re[6] = 1.9660549, this.C_im[6] = 2.5127645, this.D = [], this.D[1] = 1.5627014243, this.D[2] = 0.5185406398, this.D[3] = -0.03333098, this.D[4] = -0.1052906, this.D[5] = -0.0368594, this.D[6] = 7317e-6, this.D[7] = 0.0122, this.D[8] = 394e-5, this.D[9] = -13e-4; 2262} 2263function dp(e) { 2264 var t, i = e.x, s = e.y, n = s - this.lat0, r = i - this.long0, o = n / $n * 1e-5, a = r, l = 1, h = 0; 2265 for (t = 1; t <= 10; t++) 2266 l = l * o, h = h + this.A[t] * l; 2267 var c = h, u = a, d = 1, f = 0, g, _, m = 0, p = 0; 2268 for (t = 1; t <= 6; t++) 2269 g = d * c - f * u, _ = f * c + d * u, d = g, f = _, m = m + this.B_re[t] * d - this.B_im[t] * f, p = p + this.B_im[t] * d + this.B_re[t] * f; 2270 return e.x = p * this.a + this.x0, e.y = m * this.a + this.y0, e; 2271} 2272function fp(e) {
2273 var t, i = e.x, s = e.y, n = i - this.x0, r = s - this.y0, o = r / this.a, a = n / this.a, l = 1, h = 0, c, u, d = 0, f = 0; 2274 for (t = 1; t <= 6; t++) 2275 c = l * o - h * a, u = h * o + l * a, l = c, h = u, d = d + this.C_re[t] * l - this.C_im[t] * h, f = f + this.C_im[t] * l + this.C_re[t] * h; 2276 for (var g = 0; g < this.iterations; g++) { 2277 var _ = d, m = f, p, y, v = o, E = a; 2278 for (t = 2; t <= 6; t++) 2279 p = _ * d - m * f, y = m * d + _ * f, _ = p, m = y, v = v + (t - 1) * (this.B_re[t] * _ - this.B_im[t] * m), E = E + (t - 1) * (this.B_im[t] * _ + this.B_re[t] * m); 2280 _ = 1, m = 0; 2281 var C = this.B_re[1], S = this.B_im[1]; 2282 for (t = 2; t <= 6; t++) 2283 p = _ * d - m * f, y = m * d + _ * f, _ = p, m = y, C = C + t * (this.B_re[t] * _ - this.B_im[t] * m), S = S + t * (this.B_im[t] * _ + this.B_re[t] * m); 2284 var O = C * C + S * S; 2285 d = (v * C + E * S) / O, f = (E * C - v * S) / O; 2286 } 2287 var R = d, j = f, $ = 1, q = 0; 2288 for (t = 1; t <= 9; t++) 2289 $ = $ * R, q = q + this.D[t] * $; 2290 var tt = this.lat0 + q * $n * 1e5, J = this.long0 + j; 2291 return e.x = J, e.y = tt, e; 2292} 2293var gp = ["New_Zealand_Map_Grid", "nzmg"]; 2294const _p = { 2295 init: up, 2296 forward: dp, 2297 inverse: fp, 2298 names: gp 2299}; 2300function mp() { 2301} 2302function pp(e) { 2303 var t = e.x, i = e.y, s = U(t - this.long0), n = this.x0 + this.a * s, r = this.y0 + this.a * Math.log(Math.tan(Math.PI / 4 + i / 2.5)) * 1.25; 2304 return e.x = n, e.y = r, e; 2305} 2306function yp(e) { 2307 e.x -= this.x0, e.y -= this.y0; 2308 var t = U(this.long0 + e.x / this.a), i = 2.5 * (Math.atan(Math.exp(0.8 * e.y / this.a)) - Math.PI / 4); 2309 return e.x = t, e.y = i, e; 2310} 2311var xp = ["Miller_Cylindrical", "mill"]; 2312const vp = { 2313 init: mp, 2314 forward: pp, 2315 inverse: yp, 2316 names: xp 2317}; 2318var Ep = 20; 2319function Mp() { 2320 this.sphere ? (this.n = 1, this.m = 0, this.es = 0, this.C_y = Math.sqrt((this.m + 1) / this.n), this.C_x = this.C_y / (this.m + 1)) : this.en = xd(this.es); 2321} 2322function Cp(e) { 2323 var t, i, s = e.x, n = e.y; 2324 if (s = U(s - this.long0), this.sphere) { 2325 if (!this.m) 2326 n = this.n !== 1 ? Math.asin(this.n * Math.sin(n)) : n; 2327 else 2328 for (var r = this.n * Math.sin(n), o = Ep; o; --o) { 2329 var a = (this.m * n + Math.sin(n) - r) / (this.m + Math.cos(n)); 2330 if (n -= a, Math.abs(a) < G) 2331 break; 2332 } 2333 t = this.a * this.C_x * s * (this.m + Math.cos(n)), i = this.a * this.C_y * n; 2334 } else { 2335 var l = Math.sin(n), h = Math.cos(n); 2336 i = this.a * Ko(n, l, h, this.en), t = this.a * s * h / Math.sqrt(1 - this.es * l * l); 2337 } 2338 return e.x = t, e.y = i, e; 2339} 2340function bp(e) { 2341 var t, i, s, n; 2342 return e.x -= this.x0, s = e.x / this.a, e.y -= this.y0, t = e.y / this.a, this.sphere ? (t /= this.C_y, s = s / (this.C_x * (this.m + Math.cos(t))), this.m ? t = Hi((this.m * t + Math.sin(t)) / this.n) : this.n !== 1 && (t = Hi(Math.sin(t) / this.n)), s = U(s + this.long0), t = Cn(t)) : (t = vd(e.y / this.a, this.es, this.en), n = Math.abs(t), n < A ? (n = Math.sin(t), i = this.long0 + e.x * Math.sqrt(1 - this.es * n * n) / (this.a * Math.cos(t)), s = U(i)) : n - G < A && (s = this.long0)), e.x = s, e.y = t, e; 2343} 2344var Sp = ["Sinusoidal", "sinu"]; 2345const wp = { 2346 init: Mp, 2347 forward: Cp, 2348 inverse: bp, 2349 names: Sp 2350}; 2351function Tp() { 2352} 2353function Rp(e) { 2354 for (var t = e.x, i = e.y, s = U(t - this.long0), n = i, r = Math.PI * Math.sin(i); ; ) { 2355 var o = -(n + Math.sin(n) - r) / (1 + Math.cos(n)); 2356 if (n += o, Math.abs(o) < G) 2357 break; 2358 } 2359 n /= 2, Math.PI / 2 - Math.abs(i) < G && (s = 0); 2360 var a = 0.900316316158 * this.a * s * Math.cos(n) + this.x0, l = 1.4142135623731 * this.a * Math.sin(n) + this.y0; 2361 return e.x = a, e.y = l, e; 2362} 2363function Ip(e) { 2364 var t, i; 2365 e.x -= this.x0, e.y -= this.y0, i = e.y / (1.4142135623731 * this.a), Math.abs(i) > 0.999999999999 && (i = 0.999999999999), t = Math.asin(i); 2366 var s = U(this.long0 + e.x / (0.900316316158 * this.a * Math.cos(t))); 2367 s < -Math.PI && (s = -Math.PI), s > Math.PI && (s = Math.PI), i = (2 * t + Math.sin(2 * t)) / Math.PI, Math.abs(i) > 1 && (i = 1); 2368 var n = Math.asin(i); 2369 return e.x = s, e.y = n, e; 2370} 2371var Pp = ["Mollweide", "moll"]; 2372const Ap = { 2373 init: Tp, 2374 forward: Rp, 2375 inverse: Ip, 2376 names: Pp 2377}; 2378function Lp() { 2379 Math.abs(this.lat1 + this.lat2) < G || (this.lat2 = this.lat2 || this.lat1, this.temp = this.b / this.a, this.es = 1 - Math.pow(this.temp, 2), this.e = Math.sqrt(this.es), this.e0 = vr(this.es), this.e1 = Er(this.es), this.e2 = Mr(this.es), this.e3 = Cr(this.es), this.sinphi = Math.sin(this.lat1), this.cosphi = Math.cos(this.lat1), this.ms1 = ti(this.e, this.sinphi, this.cosphi), this.ml1 = ue(this.e0, this.e1, this.e2, this.e3, this.lat1), Math.abs(this.lat1 - this.lat2) < G ? this.ns = this.sinphi : (this.sinphi = Math.sin(this.lat2), this.cosphi = Math.cos(this.lat2), this.ms2 = ti(this.e, this.sinphi, this.cosphi), this.ml2 = ue(this.e0, this.e1, this.e2, this.e3, this.lat2), this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1)), this.g = this.ml1 + this.ms1 / this.ns, this.ml0 = ue(this.e0, this.e1, this.e2, this.e3, this.lat0), this.rh = this.a * (this.g - this.ml0)); 2380} 2381function Op(e) { 2382 var t = e.x, i = e.y, s; 2383 if (this.sphere) 2384 s = this.a * (this.g - i); 2385 else { 2386 var n = ue(this.e0, this.e1, this.e2, this.e3, i); 2387 s = this.a * (this.g - n); 2388 } 2389 var r = this.ns * U(t - this.long0), o = this.x0 + s * Math.sin(r), a = this.y0 + this.rh - s * Math.cos(r); 2390 return e.x = o, e.y = a, e; 2391} 2392function Fp(e) { 2393 e.x -= this.x0, e.y = this.rh - e.y + this.y0; 2394 var t, i, s, n; 2395 this.ns >= 0 ? (i = Math.sqrt(e.x * e.x + e.y * e.y), t = 1) : (i = -Math.sqrt(e.x * e.x + e.y * e.y), t = -1); 2396 var r = 0; 2397 if (i !== 0 && (r = Math.atan2(t * e.x, t * e.y)), this.sphere) 2398 return n = U(this.long0 + r / this.ns), s = Cn(this.g - i / this.a), e.x = n, e.y = s, e; 2399 var o = this.g - i / this.a; 2400 return s = Eo(o, this.e0, this.e1, this.e2, this.e3), n = U(this.long0 + r / this.ns), e.x = n, e.y = s, e; 2401} 2402var Dp = ["Equidistant_Conic", "eqdc"]; 2403const Np = { 2404 init: Lp, 2405 forward: Op, 2406 inverse: Fp, 2407 names: Dp 2408}; 2409function kp() { 2410 this.R = this.a; 2411} 2412function Gp(e) { 2413 var t = e.x, i = e.y, s = U(t - this.long0), n, r; 2414 Math.abs(i) <= G && (n = this.x0 + this.R * s, r = this.y0); 2415 var o = Hi(2 * Math.abs(i / Math.PI)); 2416 (Math.abs(s) <= G || Math.abs(Math.abs(i) - A) <= G) && (n = this.x0, i >= 0 ? r = this.y0 + Math.PI * this.R * Math.tan(0.5 * o) : r = this.y0 + Math.PI * this.R * -Math.tan(0.5 * o)); 2417 var a = 0.5 * Math.abs(Math.PI / s - s / Math.PI), l = a * a, h = Math.sin(o), c = Math.cos(o), u = c / (h + c - 1), d = u * u, f = u * (2 / h - 1), g = f * f, _ = Math.PI * this.R * (a * (u - g) + Math.sqrt(l * (u - g) * (u - g) - (g + l) * (d - g))) / (g + l); 2418 s < 0 && (_ = -_), n = this.x0 + _; 2419 var m = l + u; 2420 return _ = Math.PI * this.R * (f * m - a * Math.sqrt((g + l) * (l + 1) - m * m)) / (g + l), i >= 0 ? r = this.y0 + _ : r = this.y0 - _, e.x = n, e.y = r, e; 2421} 2422function zp(e) { 2423 var t, i, s, n, r, o, a, l, h, c, u, d, f; 2424 return e.x -= this.x0, e.y -= this.y0, u = Math.PI * this.R, s = e.x / u, n = e.y / u, r = s * s + n * n, o = -Math.abs(n) * (1 + r), a = o - 2 * n *
2424n + s * s, l = -2 * o + 1 + 2 * n * n + r * r, f = n * n / l + (2 * a * a * a / l / l / l - 9 * o * a / l / l) / 27, h = (o - a * a / 3 / l) / l, c = 2 * Math.sqrt(-h / 3), u = 3 * f / h / c, Math.abs(u) > 1 && (u >= 0 ? u = 1 : u = -1), d = Math.acos(u) / 3, e.y >= 0 ? i = (-c * Math.cos(d + Math.PI / 3) - a / 3 / l) * Math.PI : i = -(-c * Math.cos(d + Math.PI / 3) - a / 3 / l) * Math.PI, Math.abs(s) < G ? t = this.long0 : t = U(this.long0 + Math.PI * (r - 1 + Math.sqrt(1 + 2 * (s * s - n * n) + r * r)) / 2 / s), e.x = t, e.y = i, e; 2425} 2426var jp = ["Van_der_Grinten_I", "VanDerGrinten", "vandg"]; 2427const Wp = { 2428 init: kp, 2429 forward: Gp, 2430 inverse: zp, 2431 names: jp 2432}; 2433function Bp() { 2434 this.sin_p12 = Math.sin(this.lat0), this.cos_p12 = Math.cos(this.lat0); 2435} 2436function Up(e) { 2437 var t = e.x, i = e.y, s = Math.sin(e.y), n = Math.cos(e.y), r = U(t - this.long0), o, a, l, h, c, u, d, f, g, _, m, p, y, v, E, C, S, O, R, j, $, q, tt; 2438 return this.sphere ? Math.abs(this.sin_p12 - 1) <= G ? (e.x = this.x0 + this.a * (A - i) * Math.sin(r), e.y = this.y0 - this.a * (A - i) * Math.cos(r), e) : Math.abs(this.sin_p12 + 1) <= G ? (e.x = this.x0 + this.a * (A + i) * Math.sin(r), e.y = this.y0 + this.a * (A + i) * Math.cos(r), e) : (O = this.sin_p12 * s + this.cos_p12 * n * Math.cos(r), C = Math.acos(O), S = C ? C / Math.sin(C) : 1, e.x = this.x0 + this.a * S * n * Math.sin(r), e.y = this.y0 + this.a * S * (this.cos_p12 * s - this.sin_p12 * n * Math.cos(r)), e) : (o = vr(this.es), a = Er(this.es), l = Mr(this.es), h = Cr(this.es), Math.abs(this.sin_p12 - 1) <= G ? (c = this.a * ue(o, a, l, h, A), u = this.a * ue(o, a, l, h, i), e.x = this.x0 + (c - u) * Math.sin(r), e.y = this.y0 - (c - u) * Math.cos(r), e) : Math.abs(this.sin_p12 + 1) <= G ? (c = this.a * ue(o, a, l, h, A), u = this.a * ue(o, a, l, h, i), e.x = this.x0 + (c + u) * Math.sin(r), e.y = this.y0 + (c + u) * Math.cos(r), e) : (d = s / n, f = cn(this.a, this.e, this.sin_p12), g = cn(this.a, this.e, s), _ = Math.atan((1 - this.es) * d + this.es * f * this.sin_p12 / (g * n)), m = Math.atan2(Math.sin(r), this.cos_p12 * Math.tan(_) - this.sin_p12 * Math.cos(r)), m === 0 ? R = Math.asin(this.cos_p12 * Math.sin(_) - this.sin_p12 * Math.cos(_)) : Math.abs(Math.abs(m) - Math.PI) <= G ? R = -Math.asin(this.cos_p12 * Math.sin(_) - this.sin_p12 * Math.cos(_)) : R = Math.asin(Math.sin(r) * Math.cos(_) / Math.sin(m)), p = this.e * this.sin_p12 / Math.sqrt(1 - this.es), y = this.e * this.cos_p12 * Math.cos(m) / Math.sqrt(1 - this.es), v = p * y, E = y * y, j = R * R, $ = j * R, q = $ * R, tt = q * R, C = f * R * (1 - j * E * (1 - E) / 6 + $ / 8 * v * (1 - 2 * E) + q / 120 * (E * (4 - 7 * E) - 3 * p * p * (1 - 7 * E)) - tt / 48 * v), e.x = this.x0 + C * Math.sin(m), e.y = this.y0 + C * Math.cos(m), e)); 2439} 2440function Xp(e) { 2441 e.x -= this.x0, e.y -= this.y0; 2442 var t, i, s, n, r, o, a, l, h, c, u, d, f, g, _, m, p, y, v, E, C, S, O, R; 2443 return this.sphere ? (t = Math.sqrt(e.x * e.x + e.y * e.y), t > 2 * A * this.a ? void 0 : (i = t / this.a, s = Math.sin(i), n = Math.cos(i), r = this.long0, Math.abs(t) <= G ? o = this.lat0 : (o = Hi(n * this.sin_p12 + e.y * s * this.cos_p12 / t), a = Math.abs(this.lat0) - A, Math.abs(a) <= G ? this.lat0 >= 0 ? r = U(this.long0 + Math.atan2(e.x, -e.y)) : r = U(this.long0 - Math.atan2(-e.x, e.y)) : r = U(this.long0 + Math.atan2(e.x * s, t * this.cos_p12 * n - e.y * this.sin_p12 * s))), e.x = r, e.y = o, e)) : (l = vr(this.es), h = Er(this.es), c = Mr(this.es), u = Cr(this.es), Math.abs(this.sin_p12 - 1) <= G ? (d = this.a * ue(l, h, c, u, A), t = Math.sqrt(e.x * e.x + e.y * e.y), f = d - t, o = Eo(f / this.a, l, h, c, u), r = U(this.long0 + Math.atan2(e.x, -1 * e.y)), e.x = r, e.y = o, e) : Math.abs(this.sin_p12 + 1) <= G ? (d = this.a * ue(l, h, c, u, A), t = Math.sqrt(e.x * e.x + e.y * e.y), f = t - d, o = Eo(f / this.a, l, h, c, u), r = U(this.long0 + Math.atan2(e.x, e.y)), e.x = r, e.y = o, e) : (t = Math.sqrt(e.x * e.x + e.y * e.y), m = Math.atan2(e.x, e.y), g = cn(this.a, this.e, this.sin_p12), p = Math.cos(m), y = this.e * this.cos_p12 * p, v = -y * y / (1 - this.es), E = 3 * this.es * (1 - v) * this.sin_p12 * this.cos_p12 * p / (1 - this.es), C = t / g, S = C - v * (1 + v) * Math.pow(C, 3) / 6 - E * (1 + 3 * v) * Math.pow(C, 4) / 24, O = 1 - v * S * S / 2 - C * S * S * S / 6, _ = Math.asin(this.sin_p12 * Math.cos(S) + this.cos_p12 * Math.sin(S) * p), r = U(this.long0 + Math.asin(Math.sin(m) * Math.sin(S) / Math.cos(_))), R = Math.sin(_), o = Math.atan2((R - this.es * O * this.sin_p12) * Math.tan(_), R * (1 - this.es)), e.x = r, e.y = o, e)); 2444} 2445var $p = ["Azimuthal_Equidistant", "aeqd"]; 2446const Yp = { 2447 init: Bp, 2448 forward: Up, 2449 inverse: Xp, 2450 names: $p 2451}; 2452function Kp() {
2453 this.sin_p14 = Math.sin(this.lat0), this.cos_p14 = Math.cos(this.lat0); 2454} 2455function Vp(e) { 2456 var t, i, s, n, r, o, a, l, h = e.x, c = e.y; 2457 return s = U(h - this.long0), t = Math.sin(c), i = Math.cos(c), n = Math.cos(s), o = this.sin_p14 * t + this.cos_p14 * i * n, r = 1, (o > 0 || Math.abs(o) <= G) && (a = this.a * r * i * Math.sin(s), l = this.y0 + this.a * r * (this.cos_p14 * t - this.sin_p14 * i * n)), e.x = a, e.y = l, e; 2458} 2459function qp(e) { 2460 var t, i, s, n, r, o, a; 2461 return e.x -= this.x0, e.y -= this.y0, t = Math.sqrt(e.x * e.x + e.y * e.y), i = Hi(t / this.a), s = Math.sin(i), n = Math.cos(i), o = this.long0, Math.abs(t) <= G ? (a = this.lat0, e.x = o, e.y = a, e) : (a = Hi(n * this.sin_p14 + e.y * s * this.cos_p14 / t), r = Math.abs(this.lat0) - A, Math.abs(r) <= G ? (this.lat0 >= 0 ? o = U(this.long0 + Math.atan2(e.x, -e.y)) : o = U(this.long0 - Math.atan2(-e.x, e.y)), e.x = o, e.y = a, e) : (o = U(this.long0 + Math.atan2(e.x * s, t * this.cos_p14 * n - e.y * this.sin_p14 * s)), e.x = o, e.y = a, e)); 2462} 2463var Hp = ["ortho"]; 2464const Zp = { 2465 init: Kp, 2466 forward: Vp, 2467 inverse: qp, 2468 names: Hp 2469}; 2470var Lt = { 2471 FRONT: 1, 2472 RIGHT: 2, 2473 BACK: 3, 2474 LEFT: 4, 2475 TOP: 5, 2476 BOTTOM: 6 2477}, xt = { 2478 AREA_0: 1, 2479 AREA_1: 2, 2480 AREA_2: 3, 2481 AREA_3: 4 2482}; 2483function Jp() { 2484 this.x0 = this.x0 || 0, this.y0 = this.y0 || 0, this.lat0 = this.lat0 || 0, this.long0 = this.long0 || 0, this.lat_ts = this.lat_ts || 0, this.title = this.title || "Quadrilateralized Spherical Cube", this.lat0 >= A - yt / 2 ? this.face = Lt.TOP : this.lat0 <= -(A - yt / 2) ? this.face = Lt.BOTTOM : Math.abs(this.long0) <= yt ? this.face = Lt.FRONT : Math.abs(this.long0) <= A + yt ? this.face = this.long0 > 0 ? Lt.RIGHT : Lt.LEFT : this.face = Lt.BACK, this.es !== 0 && (this.one_minus_f = 1 - (this.a - this.b) / this.a, this.one_minus_f_squared = this.one_minus_f * this.one_minus_f); 2485} 2486function Qp(e) { 2487 var t = { x: 0, y: 0 }, i, s, n, r, o, a, l = { value: 0 }; 2488 if (e.x -= this.long0, this.es !== 0 ? i = Math.atan(this.one_minus_f_squared * Math.tan(e.y)) : i = e.y, s = e.x, this.face === Lt.TOP) 2489 r = A - i, s >= yt && s <= A + yt ? (l.value = xt.AREA_0, n = s - A) : s > A + yt || s <= -(A + yt) ? (l.value = xt.AREA_1, n = s > 0 ? s - Nt : s + Nt) : s > -(A + yt) && s <= -yt ? (l.value = xt.AREA_2, n = s + A) : (l.value = xt.AREA_3, n = s); 2490 else if (this.face === Lt.BOTTOM) 2491 r = A + i, s >= yt && s <= A + yt ? (l.value = xt.AREA_0, n = -s + A) : s < yt && s >= -yt ? (l.value = xt.AREA_1, n = -s) : s < -yt && s >= -(A + yt) ? (l.value = xt.AREA_2, n = -s - A) : (l.value = xt.AREA_3, n = s > 0 ? -s + Nt : -s - Nt); 2492 else { 2493 var h, c, u, d, f, g, _; 2494 this.face === Lt.RIGHT ? s = Qs(s, +A) : this.face === Lt.BACK ? s = Qs(s, +Nt) : this.face === Lt.LEFT && (s = Qs(s, -A)), d = Math.sin(i), f = Math.cos(i), g = Math.sin(s), _ = Math.cos(s), h = f * _, c = f * g, u = d, this.face === Lt.FRONT ? (r = Math.acos(h), n = zr(r, u, c, l)) : this.face === Lt.RIGHT ? (r = Math.acos(c), n = zr(r, u, -h, l)) : this.face === Lt.BACK ? (r = Math.acos(-h), n = zr(r, u, -c, l)) : this.face === Lt.LEFT ? (r = Math.acos(-c), n = zr(r, u, h, l)) : (r = n = 0, l.value = xt.AREA_0); 2495 } 2496 return a = Math.atan(12 / Nt * (n + Math.acos(Math.sin(n) * Math.cos(yt)) - A)), o = Math.sqrt((1 - Math.cos(r)) / (Math.cos(a) * Math.cos(a)) / (1 - Math.cos(Math.atan(1 / Math.cos(n))))), l.value === xt.AREA_1 ? a += A : l.value === xt.AREA_2 ? a += Nt : l.value === xt.AREA_3 && (a += 1.5 * Nt), t.x = o * Math.cos(a), t.y = o * Math.sin(a), t.x = t.x * this.a + this.x0, t.y = t.y * this.a + this.y0, e.x = t.x, e.y = t.y, e; 2497} 2498function ty(e) { 2499 var t = { lam: 0, phi: 0 }, i, s, n, r, o, a, l, h, c, u = { value: 0 }; 2500 if (e.x = (e.x - this.x0) / this.a, e.y = (e.y - this.y0) / this.a, s = Math.atan(Math.sqrt(e.x * e.x + e.y * e.y)), i = Math.atan2(e.y, e.x), e.x >= 0 && e.x >= Math.abs(e.y) ? u.value = xt.AREA_0 : e.y >= 0 && e.y >= Math.abs(e.x) ? (u.value = xt.AREA_1, i -= A) : e.x < 0 && -e.x >= Math.abs(e.y) ? (u.value = xt.AREA_2, i = i < 0 ? i + Nt : i - Nt) : (u.value = xt.AREA_3, i += A), c = Nt / 12 * Math.tan(i), o = Math.sin(c) / (Math.cos(c) - 1 / Math.sqrt(2)), a = Math.atan(o), n = Math.cos(i), r = Math.tan(s), l = 1 - n * n * r * r * (1 - Math.cos(Math.atan(1 / Math.cos(a)))), l < -1 ? l = -1 : l > 1 && (l = 1), this.face === Lt.TOP) 2501 h = Math.acos(l), t.phi = A - h, u.value === xt.AREA_0 ? t.lam = a + A : u.value === xt.AREA_1 ? t.lam = a < 0 ? a + Nt : a -
2501Nt : u.value === xt.AREA_2 ? t.lam = a - A : t.lam = a; 2502 else if (this.face === Lt.BOTTOM) 2503 h = Math.acos(l), t.phi = h - A, u.value === xt.AREA_0 ? t.lam = -a + A : u.value === xt.AREA_1 ? t.lam = -a : u.value === xt.AREA_2 ? t.lam = -a - A : t.lam = a < 0 ? -a - Nt : -a + Nt; 2504 else { 2505 var d, f, g; 2506 d = l, c = d * d, c >= 1 ? g = 0 : g = Math.sqrt(1 - c) * Math.sin(a), c += g * g, c >= 1 ? f = 0 : f = Math.sqrt(1 - c), u.value === xt.AREA_1 ? (c = f, f = -g, g = c) : u.value === xt.AREA_2 ? (f = -f, g = -g) : u.value === xt.AREA_3 && (c = f, f = g, g = -c), this.face === Lt.RIGHT ? (c = d, d = -f, f = c) : this.face === Lt.BACK ? (d = -d, f = -f) : this.face === Lt.LEFT && (c = d, d = f, f = -c), t.phi = Math.acos(-g) - A, t.lam = Math.atan2(f, d), this.face === Lt.RIGHT ? t.lam = Qs(t.lam, -A) : this.face === Lt.BACK ? t.lam = Qs(t.lam, -Nt) : this.face === Lt.LEFT && (t.lam = Qs(t.lam, +A)); 2507 } 2508 if (this.es !== 0) { 2509 var _, m, p; 2510 _ = t.phi < 0 ? 1 : 0, m = Math.tan(t.phi), p = this.b / Math.sqrt(m * m + this.one_minus_f_squared), t.phi = Math.atan(Math.sqrt(this.a * this.a - p * p) / (this.one_minus_f * p)), _ && (t.phi = -t.phi); 2511 } 2512 return t.lam += this.long0, e.x = t.lam, e.y = t.phi, e; 2513} 2514function zr(e, t, i, s) { 2515 var n; 2516 return e < G ? (s.value = xt.AREA_0, n = 0) : (n = Math.atan2(t, i), Math.abs(n) <= yt ? s.value = xt.AREA_0 : n > yt && n <= A + yt ? (s.value = xt.AREA_1, n -= A) : n > A + yt || n <= -(A + yt) ? (s.value = xt.AREA_2, n = n >= 0 ? n - Nt : n + Nt) : (s.value = xt.AREA_3, n += A)), n; 2517} 2518function Qs(e, t) { 2519 var i = e + t; 2520 return i < -Nt ? i += Jn : i > +Nt && (i -= Jn), i; 2521} 2522var ey = ["Quadrilateralized Spherical Cube", "Quadrilateralized_Spherical_Cube", "qsc"]; 2523const iy = { 2524 init: Jp, 2525 forward: Qp, 2526 inverse: ty, 2527 names: ey 2528}; 2529var il = [ 2530 [1, 22199e-21, -715515e-10, 31103e-10], 2531 [0.9986, -482243e-9, -24897e-9, -13309e-10], 2532 [0.9954, -83103e-8, -448605e-10, -986701e-12], 2533 [0.99, -135364e-8, -59661e-9, 36777e-10], 2534 [0.9822, -167442e-8, -449547e-11, -572411e-11], 2535 [0.973, -214868e-8, -903571e-10, 18736e-12], 2536 [0.96, -305085e-8, -900761e-10, 164917e-11], 2537 [0.9427, -382792e-8, -653386e-10, -26154e-10], 2538 [0.9216, -467746e-8, -10457e-8, 481243e-11], 2539 [0.8962, -536223e-8, -323831e-10, -543432e-11], 2540 [0.8679, -609363e-8, -113898e-9, 332484e-11], 2541 [0.835, -698325e-8, -640253e-10, 934959e-12], 2542 [0.7986, -755338e-8, -500009e-10, 935324e-12], 2543 [0.7597, -798324e-8, -35971e-9, -227626e-11], 2544 [0.7186, -851367e-8, -701149e-10, -86303e-10], 2545 [0.6732, -986209e-8, -199569e-9, 191974e-10], 2546 [0.6213, -0.010418, 883923e-10, 624051e-11], 2547 [0.5722, -906601e-8, 182e-6, 624051e-11], 2548 [0.5322, -677797e-8, 275608e-9, 624051e-11] 2549], jn = [ 2550 [-520417e-23, 0.0124, 121431e-23, -845284e-16], 2551 [0.062, 0.0124, -126793e-14, 422642e-15], 2552 [0.124, 0.0124, 507171e-14, -160604e-14], 2553 [0.186, 0.0123999, -190189e-13, 600152e-14], 2554 [0.248, 0.0124002, 710039e-13, -224e-10], 2555 [0.31, 0.0123992, -264997e-12, 835986e-13], 2556 [0.372, 0.0124029, 988983e-12, -311994e-12], 2557 [0.434, 0.0123893, -369093e-11, -435621e-12], 2558 [0.4958, 0.0123198, -102252e-10, -345523e-12], 2559 [0.5571, 0.0121916, -154081e-10, -582288e-12], 2560 [0.6176, 0.0119938, -241424e-10, -525327e-12], 2561 [0.6769, 0.011713, -320223e-10, -516405e-12], 2562 [0.7346, 0.0113541, -397684e-10, -609052e-12], 2563 [0.7903, 0.0109107, -489042e-10, -104739e-11], 2564 [0.8435, 0.0103431, -64615e-9, -140374e-14], 2565 [0.8936, 969686e-8, -64636e-9, -8547e-9], 2566 [0.9394, 840947e-8, -192841e-9, -42106e-10], 2567 [0.9761, 616527e-8, -256e-6, -42106e-10], 2568 [1, 328947e-8, -319159e-9, -42106e-10] 2569], Cd = 0.8487, bd = 1.3523, Sd = ki / 5, sy = 1 / Sd, Ys = 18, Mo = function(e, t) { 2570 return e[0] + t * (e[1] + t * (e[2] + t * e[3])); 2571}, ny = function(e, t) { 2572 return e[1] + t * (2 * e[2] + t * 3 * e[3]); 2573}; 2574function ry(e, t, i, s) { 2575 for (var n = t; s; --s) { 2576 var r = e(n); 2577 if (n -= r, Math.abs(r) < i) 2578 break; 2579 } 2580 return n; 2581} 2582function oy() { 2583 this.x0 = this.x0 || 0, this.y0 = this.y0 || 0, this.long0 = this.long0 || 0, this.es = 0, this.title = this.title || "Robinson"; 2584} 2585function ay(e) { 2586 var t = U(e.x - this.long0), i = Math.abs(e.y), s = Math.floor(i * Sd); 2587 s < 0 ? s = 0 : s >= Ys && (s = Ys - 1), i = ki * (i - sy * s); 2588 var n = { 2589 x: Mo(il[s], i) * t, 2590 y: Mo(jn[s], i) 2591 }; 2592 return e.y < 0 && (n.y = -n.y), n.x = n.x * this.a * Cd + this.x0, n.y = n.y * this.a * bd + this.y0, n; 2593} 2594function ly(e) { 2595 var t = { 2596 x: (e.x - this.x0) / (this.a * Cd), 2597 y: Math.abs(e.y - this.y0) / (this.a * bd) 2598 }; 2599 if (t.y >= 1) 2600 t.x /= il[Ys][0], t.y = e.y < 0 ? -A : A; 2601 else { 2602 var i = Math.floor(t.y * Ys); 2603 for (i < 0 ? i = 0 : i >= Ys && (i = Ys - 1); ; ) 2604 if (jn[i][0] > t.y) 2605 --i; 2606 else if (jn[i + 1][0] <= t.y) 2607 ++i; 2608 else 2609 break; 2610 var s = jn[i], n = 5 * (t.y - s[0]) / (jn[i + 1][0] - s[0]); 2611 n = ry(function(r) { 2612 return (Mo(s, r) - t.y) / ny(s, r); 2613 }, n, G, 100), t.x /= Mo(il[i], n), t.y = (5 * i + n) * Vt, e.y < 0 && (t.y = -t.y); 2614 } 2615 return t.x = U(t.x + this.long0), t; 2616} 2617var hy = ["Robinson", "robin"]; 2618const cy = { 2619 init: oy, 2620 forward: ay, 2621 inverse: ly, 2622 names: hy 2623}; 2624function uy() { 2625 this.name = "geocent"; 2626} 2627function dy(e) { 2628 var t = cd(e, this.es, this.a); 2629 return t; 2630} 2631function fy(e) { 2632 var t = ud(e, this.es, this.a, this.b); 2633 return t; 2634} 2635var gy = ["Geocentric", "geocentric", "geocent", "Geocent"]; 2636const _y = { 2637 init: uy, 2638 forward: dy, 2639 inverse: fy, 2640 names: gy 2641}; 2642var te = { 2643 N_POLE: 0, 2644 S_POLE: 1, 2645 EQUIT: 2, 2646 OBLIQ: 3 2647}, On = { 2648 h: { def: 1e5, num: !0 },
2649 // default is Karman line, no default in PROJ.7 2650 azi: { def: 0, num: !0, degrees: !0 }, 2651 // default is North 2652 tilt: { def: 0, num: !0, degrees: !0 }, 2653 // default is Nadir 2654 long0: { def: 0, num: !0 }, 2655 // default is Greenwich, conversion to rad is automatic 2656 lat0: { def: 0, num: !0 } 2657 // default is Equator, conversion to rad is automatic 2658}; 2659function my() { 2660 if (Object.keys(On).forEach((function(i) { 2661 if (typeof this[i] > "u") 2662 this[i] = On[i].def; 2663 else { 2664 if (On[i].num && isNaN(this[i])) 2665 throw new Error("Invalid parameter value, must be numeric " + i + " = " + this[i]); 2666 On[i].num && (this[i] = parseFloat(this[i])); 2667 } 2668 On[i].degrees && (this[i] = this[i] * Vt); 2669 }).bind(this)), Math.abs(Math.abs(this.lat0) - A) < G ? this.mode = this.lat0 < 0 ? te.S_POLE : te.N_POLE : Math.abs(this.lat0) < G ? this.mode = te.EQUIT : (this.mode = te.OBLIQ, this.sinph0 = Math.sin(this.lat0), this.cosph0 = Math.cos(this.lat0)), this.pn1 = this.h / this.a, this.pn1 <= 0 || this.pn1 > 1e10) 2670 throw new Error("Invalid height"); 2671 this.p = 1 + this.pn1, this.rp = 1 / this.p, this.h1 = 1 / this.pn1, this.pfact = (this.p + 1) * this.h1, this.es = 0; 2672 var e = this.tilt, t = this.azi; 2673 this.cg = Math.cos(t), this.sg = Math.sin(t), this.cw = Math.cos(e), this.sw = Math.sin(e); 2674} 2675function py(e) { 2676 e.x -= this.long0; 2677 var t = Math.sin(e.y), i = Math.cos(e.y), s = Math.cos(e.x), n, r; 2678 switch (this.mode) { 2679 case te.OBLIQ: 2680 r = this.sinph0 * t + this.cosph0 * i * s; 2681 break; 2682 case te.EQUIT: 2683 r = i * s; 2684 break; 2685 case te.S_POLE: 2686 r = -t; 2687 break; 2688 case te.N_POLE: 2689 r = t; 2690 break; 2691 } 2692 switch (r = this.pn1 / (this.p - r), n = r * i * Math.sin(e.x), this.mode) { 2693 case te.OBLIQ: 2694 r *= this.cosph0 * t - this.sinph0 * i * s; 2695 break; 2696 case te.EQUIT: 2697 r *= t; 2698 break; 2699 case te.N_POLE: 2700 r *= -(i * s); 2701 break; 2702 case te.S_POLE: 2703 r *= i * s; 2704 break; 2705 } 2706 var o, a; 2707 return o = r * this.cg + n * this.sg, a = 1 / (o * this.sw * this.h1 + this.cw), n = (n * this.cg - r * this.sg) * this.cw * a, r = o * a, e.x = n * this.a, e.y = r * this.a, e; 2708} 2709function yy(e) { 2710 e.x /= this.a, e.y /= this.a; 2711 var t = { x: e.x, y: e.y }, i, s, n; 2712 n = 1 / (this.pn1 - e.y * this.sw), i = this.pn1 * e.x * n, s = this.pn1 * e.y * this.cw * n, e.x = i * this.cg + s * this.sg, e.y = s * this.cg - i * this.sg; 2713 var r = De(e.x, e.y); 2714 if (Math.abs(r) < G) 2715 t.x = 0, t.y = e.y; 2716 else { 2717 var o, a; 2718 switch (a = 1 - r * r * this.pfact, a = (this.p - Math.sqrt(a)) / (this.pn1 / r + r / this.pn1), o = Math.sqrt(1 - a * a), this.mode) { 2719 case te.OBLIQ: 2720 t.y = Math.asin(o * this.sinph0 + e.y * a * this.cosph0 / r), e.y = (o - this.sinph0 * Math.sin(t.y)) * r, e.x *= a * this.cosph0; 2721 break; 2722 case te.EQUIT: 2723 t.y = Math.asin(e.y * a / r), e.y = o * r, e.x *= a; 2724 break; 2725 case te.N_POLE: 2726 t.y = Math.asin(o), e.y = -e.y; 2727 break; 2728 case te.S_POLE: 2729 t.y = -Math.asin(o); 2730 break; 2731 } 2732 t.x = Math.atan2(e.x, e.y); 2733 } 2734 return e.x = t.x + this.long0, e.y = t.y, e; 2735} 2736var xy = ["Tilted_Perspective", "tpers"]; 2737const vy = { 2738 init: my, 2739 forward: py, 2740 inverse: yy, 2741 names: xy 2742}; 2743function Ey() { 2744 if (this.flip_axis = this.sweep === "x" ? 1 : 0, this.h = Number(this.h), this.radius_g_1 = this.h / this.a, this.radius_g_1 <= 0 || this.radius_g_1 > 1e10) 2745 throw new Error(); 2746 if (this.radius_g = 1 + this.radius_g_1, this.C = this.radius_g * this.radius_g - 1, this.es !== 0) { 2747 var e = 1 - this.es, t = 1 / e; 2748 this.radius_p = Math.sqrt(e), this.radius_p2 = e, this.radius_p_inv2 = t, this.shape = "ellipse"; 2749 } else 2750 this.radius_p = 1, this.radius_p2 = 1, this.radius_p_inv2 = 1, this.shape = "sphere"; 2751 this.title || (this.title = "Geostationary Satellite View"); 2752} 2753function My(e) { 2754 var t = e.x, i = e.y, s, n, r, o; 2755 if (t = t - this.long0, this.shape === "ellipse") { 2756 i = Math.atan(this.radius_p2 * Math.tan(i)); 2757 var a = this.radius_p / De(this.radius_p * Math.cos(i), Math.sin(i)); 2758 if (n = a * Math.cos(t) * Math.cos(i), r = a * Math.sin(t) * Math.cos(i), o = a * Math.sin(i), (this.radius_g - n) * n - r * r - o * o * this.radius_p_inv2 < 0) 2759 return e.x = Number.NaN, e.y = Number.NaN, e; 2760 s = this.radius_g - n, this.flip_axis ? (e.x = this.radius_g_1 * Math.atan(r / De(o, s)), e.y = this.radius_g_1 * Math.atan(o / s)) : (e.x = this.radius_g_1 * Math.atan(r / s), e.y = this.radius_g_1 * Math.atan(o / De(r, s))); 2761 } else 2762 this.shape === "sphere" && (s = Math.cos(i), n = Math.cos(t) * s, r = Math.sin(t) * s, o = Math.sin(i), s = this.radius_g - n, this.flip_axis ? (e.x = this.radius_g_1 * Math.atan(r / De(o, s)), e.y = this.radius_g_1 * Math.atan(o / s)) : (e.x = this.radius_g_1 * Math.atan(r / s), e.y = this.radius_g_1 * Math.atan(o / De(r, s)))); 2763 return e.x = e.x * this.a, e.y = e.y * this.a, e; 2764} 2765function Cy(e) { 2766 var t = -1, i = 0, s = 0, n, r, o, a; 2767 if (e.x = e.x / this.a, e.y = e.y / this.a, this.shape === "ellipse") { 2768 this.flip_axis ? (s = Math.tan(e.y / this.radius_g_1), i = Math.tan(e.x / this.radius_g_1) * De(1, s)) : (i = Math.tan(e.x / this.radius_g_1), s = Math.tan(e.y / this.radius_g_1) * De(1, i)
2768); 2769 var l = s / this.radius_p; 2770 if (n = i * i + l * l + t * t, r = 2 * this.radius_g * t, o = r * r - 4 * n * this.C, o < 0) 2771 return e.x = Number.NaN, e.y = Number.NaN, e; 2772 a = (-r - Math.sqrt(o)) / (2 * n), t = this.radius_g + a * t, i *= a, s *= a, e.x = Math.atan2(i, t), e.y = Math.atan(s * Math.cos(e.x) / t), e.y = Math.atan(this.radius_p_inv2 * Math.tan(e.y)); 2773 } else if (this.shape === "sphere") { 2774 if (this.flip_axis ? (s = Math.tan(e.y / this.radius_g_1), i = Math.tan(e.x / this.radius_g_1) * Math.sqrt(1 + s * s)) : (i = Math.tan(e.x / this.radius_g_1), s = Math.tan(e.y / this.radius_g_1) * Math.sqrt(1 + i * i)), n = i * i + s * s + t * t, r = 2 * this.radius_g * t, o = r * r - 4 * n * this.C, o < 0) 2775 return e.x = Number.NaN, e.y = Number.NaN, e; 2776 a = (-r - Math.sqrt(o)) / (2 * n), t = this.radius_g + a * t, i *= a, s *= a, e.x = Math.atan2(i, t), e.y = Math.atan(s * Math.cos(e.x) / t); 2777 } 2778 return e.x = e.x + this.long0, e; 2779} 2780var by = ["Geostationary Satellite View", "Geostationary_Satellite", "geos"]; 2781const Sy = { 2782 init: Ey, 2783 forward: My, 2784 inverse: Cy, 2785 names: by 2786}; 2787function wy(e) { 2788 e.Proj.projections.add(ho), e.Proj.projections.add(co), e.Proj.projections.add(L0), e.Proj.projections.add(B0), e.Proj.projections.add(V0), e.Proj.projections.add(Q0), e.Proj.projections.add(rm), e.Proj.projections.add(cm), e.Proj.projections.add(_m), e.Proj.projections.add(vm), e.Proj.projections.add(km), e.Proj.projections.add(Um), e.Proj.projections.add(Vm), e.Proj.projections.add(tp), e.Proj.projections.add(rp), e.Proj.projections.add(cp), e.Proj.projections.add(_p), e.Proj.projections.add(vp), e.Proj.projections.add(wp), e.Proj.projections.add(Ap), e.Proj.projections.add(Np), e.Proj.projections.add(Wp), e.Proj.projections.add(Yp), e.Proj.projections.add(Zp), e.Proj.projections.add(iy), e.Proj.projections.add(cy), e.Proj.projections.add(_y), e.Proj.projections.add(vy), e.Proj.projections.add(Sy); 2789} 2790xe.defaultDatum = "WGS84"; 2791xe.Proj = Je; 2792xe.WGS84 = new xe.Proj("WGS84"); 2793xe.Point = hn; 2794xe.toPoint = dd; 2795xe.defs = he; 2796xe.nadgrid = F_; 2797xe.transform = vo; 2798xe.mgrs = H_; 2799xe.version = "__VERSION__"; 2800wy(xe); 2801const er = { 2802 // use the radius of the Normal sphere 2803 radians: 6370997 / (2 * Math.PI), 2804 degrees: 2 * Math.PI * 6370997 / 360, 2805 ft: 0.3048, 2806 m: 1, 2807 "us-ft": 1200 / 3937 2808}; 2809class Ty { 2810 /** 2811 * @param {Options} options Projection options. 2812 */ 2813 constructor(t) { 2814 this.code_ = t.code, this.units_ = /** @type {import("./Units.js").Units} */ 2815 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; 2816 } 2817 /** 2818 * @return {boolean} The projection is suitable for wrapping the x-axis 2819 */ 2820 canWrapX() { 2821 return this.canWrapX_; 2822 } 2823 /** 2824 * Get the code for this projection, e.g. 'EPSG:4326'. 2825 * @return {string} Code. 2826 * @api 2827 */ 2828 getCode() { 2829 return this.code_; 2830 } 2831 /** 2832 * Get the validity extent for this projection. 2833 * @return {import("../extent.js").Extent} Extent. 2834 * @api 2835 */ 2836 getExtent() { 2837 return this.extent_; 2838 } 2839 /** 2840 * Get the units of this projection. 2841 * @return {import("./Units.js").Units} Units. 2842 * @api 2843 */ 2844 getUnits() { 2845 return this.units_; 2846 } 2847 /** 2848 * Get the amount of meters per unit of this projection. If the projection is 2849 * not configured with `metersPerUnit` or a units identifier, the return is 2850 * `undefined`. 2851 * @return {number|undefined} Meters. 2852 * @api 2853 */ 2854 getMetersPerUnit() { 2855 return this.metersPerUnit_ || er[this.units_]; 2856 } 2857 /** 2858 * Get the world extent for this projection. 2859 * @return {import("../extent.js").Extent} Extent. 2860 * @api 2861 */ 2862 getWorldExtent() { 2863 return this.worldExtent_; 2864 } 2865 /** 2866 * Get the axis orientation of this projection. 2867 * Example values are: 2868 * enu - the default easting, northing, elevation. 2869 * neu - northing, easting, up - useful for "lat/long" geographic coordinates, 2870 * or south orientated transverse mercator. 2871 * wnu - westing, northing, up - some planetary coordinate systems have 2872 * "west positive" coordinate systems 2873 * @return {string} Axis orientation. 2874 * @api 2875 */ 2876 getAxisOrientation() { 2877 return this.axisOrientation_; 2878 } 2879 /** 2880 * Is this projection a global projection which spans the whole world? 2881 * @return {boolean} Whether the projection is global. 2882 * @api 2883 */ 2884 isGlobal() { 2885 return this.global_; 2886 } 2887 /** 2888 * Set if the projection is a global projection which spans the whole world 2889 * @param {boolean} global Whether the projection is global. 2890 * @api 2891 */ 2892 setGlobal(t) { 2893 this.global_ = t, this.canWrapX_ = !!(t && this.extent_); 2894 } 2895 /** 2896 * @return {import("../tilegrid/TileGrid.js").default} The default tile grid. 2897 */ 2898 getDefaultTileGrid() { 2899 return this.defaultTileGrid_; 2900 } 2901 /** 2902 * @param {import("../tilegrid/TileGrid.js").default} tileGrid The default tile grid. 2903 */ 2904 setDefaultTileGrid(t) { 2905 this.defaultTileGrid_ = t; 2906 } 2907 /** 2908 * Set the validity extent for this projection. 2909 * @param {import("../extent.js").Extent} extent Extent. 2910 * @api 2911 */ 2912 setExtent(t) { 2913 this.extent_ = t, this.canWrapX_ = !!(this.global_ && t); 2914 } 2915 /** 2916 * Set the world extent for this projection. 2917 * @param {import("../extent.js").Extent} worldExtent World extent 2918 * [minlon, minlat, maxlon, maxlat]. 2919 * @api 2920 */ 2921 setWorldExtent(t) { 2922 this.worldExtent_ = t; 2923 } 2924 /** 2925 * Set the getPointResolution function (see {@link module:ol/proj.getPointResolution} 2926 * for this projection. 2927 * @param {function(number, import("../coordinate.js").Coordinate):number}
2927 func Function 2928 * @api 2929 */ 2930 setGetPointResolution(t) { 2931 this.getPointResolutionFunc_ = t; 2932 } 2933 /** 2934 * Get the custom point resolution function for this projection (if set). 2935 * @return {function(number, import("../coordinate.js").Coordinate):number|undefined} The custom point 2936 * resolution function (if set). 2937 */ 2938 getPointResolutionFunc() { 2939 return this.getPointResolutionFunc_; 2940 } 2941} 2942const Bl = Ty, br = 6378137, Ks = Math.PI * br, Ry = [-Ks, -Ks, Ks, Ks], Iy = [-180, -85, 180, 85], jr = br * Math.log(Math.tan(Math.PI / 2)); 2943class Ls extends Bl { 2944 /** 2945 * @param {string} code Code. 2946 */ 2947 constructor(t) { 2948 super({ 2949 code: t, 2950 units: "m", 2951 extent: Ry, 2952 global: !0, 2953 worldExtent: Iy, 2954 getPointResolution: function(i, s) { 2955 return i / Math.cosh(s[1] / br); 2956 } 2957 }); 2958 } 2959} 2960const bc = [ 2961 new Ls("EPSG:3857"), 2962 new Ls("EPSG:102100"), 2963 new Ls("EPSG:102113"), 2964 new Ls("EPSG:900913"), 2965 new Ls("http://www.opengis.net/def/crs/EPSG/0/3857"), 2966 new Ls("http://www.opengis.net/gml/srs/epsg.xml#3857") 2967]; 2968function Py(e, t, i) { 2969 const s = e.length; 2970 i = i > 1 ? i : 2, t === void 0 && (i > 2 ? t = e.slice() : t = new Array(s)); 2971 for (let n = 0; n < s; n += i) { 2972 t[n] = Ks * e[n] / 180; 2973 let r = br * Math.log(Math.tan(Math.PI * (+e[n + 1] + 90) / 360)); 2974 r > jr ? r = jr : r < -jr && (r = -jr), t[n + 1] = r; 2975 } 2976 return t; 2977} 2978function Ay(e, t, i) { 2979 const s = e.length; 2980 i = i > 1 ? i : 2, t === void 0 && (i > 2 ? t = e.slice() : t = new Array(s)); 2981 for (let n = 0; n < s; n += i) 2982 t[n] = 180 * e[n] / Ks, t[n + 1] = 360 * Math.atan(Math.exp(e[n + 1] / br)) / Math.PI - 90; 2983 return t; 2984} 2985const Ly = 6378137, Sc = [-180, -90, 180, 90], Oy = Math.PI * Ly / 180; 2986class ss extends Bl { 2987 /** 2988 * @param {string} code Code. 2989 * @param {string} [axisOrientation] Axis orientation. 2990 */ 2991 constructor(t, i) { 2992 super({ 2993 code: t, 2994 units: "degrees", 2995 extent: Sc, 2996 axisOrientation: i, 2997 global: !0, 2998 metersPerUnit: Oy, 2999 worldExtent: Sc 3000 }); 3001 } 3002} 3003const wc = [ 3004 new ss("CRS:84"), 3005 new ss("EPSG:4326", "neu"), 3006 new ss("urn:ogc:def:crs:OGC:1.3:CRS84"), 3007 new ss("urn:ogc:def:crs:OGC:2:84"), 3008 new ss("http://www.opengis.net/def/crs/OGC/1.3/CRS84"), 3009 new ss("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"), 3010 new ss("http://www.opengis.net/def/crs/EPSG/0/4326", "neu") 3011]; 3012let sl = {}; 3013function Fy(e) { 3014 return sl[e] || sl[e.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/, "EPSG:$3")] || null; 3015} 3016function Dy(e, t) { 3017 sl[e] = t; 3018} 3019function Sr(e) { 3020 for (const t in e) 3021 delete e[t]; 3022} 3023function un(e) { 3024 let t; 3025 for (t in e) 3026 return !1; 3027 return !t; 3028} 3029let tn = {}; 3030function dn(e, t, i) { 3031 const s = e.getCode(), n = t.getCode(); 3032 s in tn || (tn[s] = {}), tn[s][n] = i; 3033} 3034function wd(e, t) { 3035 let i; 3036 return e in tn && t in tn[e] && (i = tn[e][t]), i; 3037} 3038const Ut = { 3039 UNKNOWN: 0, 3040 INTERSECTING: 1, 3041 ABOVE: 2, 3042 RIGHT: 4, 3043 BELOW: 8, 3044 LEFT: 16 3045}, Ny = { 3046 1: "The view center is not defined", 3047 2: "The view resolution is not defined", 3048 3: "The view rotation is not defined", 3049 4: "`image` and `src` cannot be provided at the same time", 3050 5: "`imgSize` must be set when `image` is provided", 3051 7: "`format` must be set when `url` is set", 3052 8: "Unknown `serverType` configured", 3053 9: "`url` must be configured or set using `#setUrl()`", 3054 10: "The default `geometryFunction` can only handle `Point` geometries", 3055 11: "`options.featureTypes` must be an Array", 3056 12: "`options.geometryName` must also be provided when `options.bbox` is set", 3057 13: "Invalid corner", 3058 14: "Invalid color", 3059 15: "Tried to get a value for a key that does not exist in the cache", 3060 16: "Tried to set a value for a key that is used already", 3061 17: "`resolutions` must be sorted in descending order", 3062 18: "Either `origin` or `origins` must be configured, never both", 3063 19: "Number of `tileSizes` and `resolutions` must be equal", 3064 20: "Number of `origins` and `resolutions` must be equal", 3065 22: "Either `tileSize` or `tileSizes` must be configured, never both", 3066 24: "Invalid extent or geometry provided as `geometry`", 3067 25: "Cannot fit empty extent provided as `geometry`", 3068 26: "Features must have an id set", 3069 27: "Features must have an id set", 3070 28: '`renderMode` must be `"hybrid"` or `"vector"`', 3071 30: "The passed `feature` was already added to the source", 3072 31: "Tried to enqueue an `element` that was already added to the queue", 3073 32: "Transformation matrix cannot be inverted", 3074 33: "Invalid units", 3075 34: "Invalid geometry layout", 3076 36: "Unknown SRS type", 3077 37: "Unknown geometry type found", 3078 38: "`styleMapValue` has an unknown type", 3079 39: "Unknown geometry type", 3080 40: "Expected `feature` to have a geometry", 3081 41: "Expected an `ol/style/Style` or an array of `ol/style/Style.js`", 3082 42: "Question unknown, the answer is 42", 3083 43: "Expected `layers` to be an array or a `Collection`", 3084 47: "Expected `controls` to be an array or an `ol/Collection`", 3085 48: "Expected `interactions` to be an array or an `ol/Collection`", 3086 49: "Expected `overlays` to be an array or an `ol/Collection`", 3087 50: "`options.featureTypes` should be an Array", 3088 51: "Either `url` or `tileJSON` options must be provided", 3089 52: "Unknown `serverType` configured", 3090 53: "Unknown `tierSizeCalculation` configured", 3091 55: "The {-y} placeholder requires a tile grid with extent", 3092 56: "mapBrowserEvent must originate from a pointer event", 3093 57: "At least 2 conditions are required", 3094 59: "Invalid command found in the PBF", 3095 60: "Missing or invalid `size`", 3096 61: "Cannot determine IIIF Image API version from provided image information JSON", 3097 62: "A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`", 3098 64: "Layer opacity must be a number", 3099 66: "`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has not been enabled. This is done by providing adequate shaders using the `hitVertexShader` and `hitFragmentShader` properties of `WebGLPointsLayerRenderer`", 3100 67: "A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both", 3101 68: "A VectorTile source can only be rendered if it has a projection compatible with the view projection", 3102 69: "`width` or `height` cannot be provided together with `scale`" 3103};
3104class ky extends Error { 3105 /** 3106 * @param {number} code Error code. 3107 */ 3108 constructor(t) { 3109 const i = Ny[t]; 3110 super(i), this.code = t, this.name = "AssertionError", this.message = i; 3111 } 3112} 3113const Td = ky; 3114function at(e, t) { 3115 if (!e) 3116 throw new Td(t); 3117} 3118function ce(e) { 3119 const t = ve(); 3120 for (let i = 0, s = e.length; i < s; ++i) 3121 Yn(t, e[i]); 3122 return t; 3123} 3124function Gy(e, t, i) { 3125 const s = Math.min.apply(null, e), n = Math.min.apply(null, t), r = Math.max.apply(null, e), o = Math.max.apply(null, t); 3126 return ei(s, n, r, o, i); 3127} 3128function Es(e, t, i) { 3129 return i ? (i[0] = e[0] - t, i[1] = e[1] - t, i[2] = e[2] + t, i[3] = e[3] + t, i) : [ 3130 e[0] - t, 3131 e[1] - t, 3132 e[2] + t, 3133 e[3] + t 3134 ]; 3135} 3136function Rd(e, t) { 3137 return t ? (t[0] = e[0], t[1] = e[1], t[2] = e[2], t[3] = e[3], t) : e.slice(); 3138} 3139function Ss(e, t, i) { 3140 let s, n; 3141 return t < e[0] ? s = e[0] - t : e[2] < t ? s = t - e[2] : s = 0, i < e[1] ? n = e[1] - i : e[3] < i ? n = i - e[3] : n = 0, s * s + n * n; 3142} 3143function wr(e, t) { 3144 return Ul(e, t[0], t[1]); 3145} 3146function Gi(e, t) { 3147 return e[0] <= t[0] && t[2] <= e[2] && e[1] <= t[1] && t[3] <= e[3]; 3148} 3149function Ul(e, t, i) { 3150 return e[0] <= t && t <= e[2] && e[1] <= i && i <= e[3]; 3151} 3152function nl(e, t) { 3153 const i = e[0], s = e[1], n = e[2], r = e[3], o = t[0], a = t[1]; 3154 let l = Ut.UNKNOWN; 3155 return o < i ? l = l | Ut.LEFT : o > n && (l = l | Ut.RIGHT), a < s ? l = l | Ut.BELOW : a > r && (l = l | Ut.ABOVE), l === Ut.UNKNOWN && (l = Ut.INTERSECTING), l; 3156} 3157function ve() { 3158 return [1 / 0, 1 / 0, -1 / 0, -1 / 0]; 3159} 3160function ei(e, t, i, s, n) { 3161 return n ? (n[0] = e, n[1] = t, n[2] = i, n[3] = s, n) : [e, t, i, s]; 3162} 3163function bn(e) { 3164 return ei(1 / 0, 1 / 0, -1 / 0, -1 / 0, e); 3165} 3166function uo(e, t) { 3167 const i = e[0], s = e[1]; 3168 return ei(i, s, i, s, t); 3169} 3170function Id(e, t, i, s, n) { 3171 const r = bn(n); 3172 return Ad(r, e, t, i, s); 3173} 3174function fn(e, t) { 3175 return e[0] == t[0] && e[2] == t[2] && e[1] == t[1] && e[3] == t[3]; 3176} 3177function Pd(e, t) { 3178 return t[0] < e[0] && (e[0] = t[0]), t[2] > e[2] && (e[2] = t[2]), t[1] < e[1] && (e[1] = t[1]), t[3] > e[3] && (e[3] = t[3]), e; 3179} 3180function Yn(e, t) { 3181 t[0] < e[0] && (e[0] = t[0]), t[0] > e[2] && (e[2] = t[0]), t[1] < e[1] && (e[1] = t[1]), t[1] > e[3] && (e[3] = t[1]); 3182} 3183function Ad(e, t, i, s, n) { 3184 for (; i < s; i += n) 3185 zy(e, t[i], t[i + 1]); 3186 return e; 3187} 3188function zy(e, t, i) { 3189 e[0] = Math.min(e[0], t), e[1] = Math.min(e[1], i), e[2] = Math.max(e[2], t), e[3] = Math.max(e[3], i); 3190} 3191function Xl(e, t) { 3192 let i; 3193 return i = t(Vo(e)), i || (i = t(qo(e)), i) || (i = t(Ho(e)), i) || (i = t(ws(e)), i) ? i : !1; 3194} 3195function rl(e) { 3196 let t = 0; 3197 return Ts(e) || (t = mt(e) * Yt(e)), t; 3198} 3199function Vo(e) { 3200 return [e[0], e[1]]; 3201} 3202function qo(e) { 3203 return [e[2], e[1]]; 3204} 3205function ii(e) { 3206 return [(e[0] + e[2]) / 2, (e[1] + e[3]) / 2]; 3207} 3208function jy(e, t) { 3209 let i; 3210 return t === "bottom-left" ? i = Vo(e) : t === "bottom-right" ? i = qo(e) : t === "top-left" ? i = ws(e) : t === "top-right" ? i = Ho(e) : at(!1, 13), i; 3211} 3212function en(e, t, i, s, n) { 3213 const [r, o, a, l, h, c, u, d] = ol( 3214 e, 3215 t, 3216 i, 3217 s 3218 ); 3219 return ei( 3220 Math.min(r, a, h, u), 3221 Math.min(o, l, c, d), 3222 Math.max(r, a, h, u), 3223 Math.max(o, l, c, d), 3224 n 3225 ); 3226} 3227function ol(e, t, i, s) { 3228 const n = t * s[0] / 2, r = t * s[1] / 2, o = Math.cos(i), a = Math.sin(i), l = n * o, h = n * a, c = r * o, u = r * a, d = e[0], f = e[1]; 3229 return [ 3230 d - l + u, 3231 f - h - c, 3232 d - l - u, 3233 f - h + c, 3234 d + l - u, 3235 f + h + c, 3236 d + l + u, 3237 f + h - c, 3238 d - l + u, 3239 f - h - c 3240 ]; 3241} 3242function Yt(e) { 3243 return e[3] - e[1]; 3244} 3245function fs(e, t, i) { 3246 const s = i || ve(); 3247 return ee(e, t) ? (e[0] > t[0] ? s[0] = e[0] : s[0] = t[0], e[1] > t[1] ? s[1] = e[1] : s[1] = t[1], e[2] < t[2] ? s[2] = e[2] : s[2] = t[2], e[3] < t[3] ? s[3] = e[3] : s[3] = t[3]) : bn(s), s; 3248} 3249function ws(e) { 3250 return [e[0], e[3]]; 3251} 3252function Ho(e) { 3253 return [e[2], e[3]]; 3254} 3255function mt(e) { 3256 return e[2] - e[0]; 3257} 3258function ee(e, t) { 3259 return e[0] <= t[2] && e[2] >= t[0] && e[1] <= t[3] && e[3] >= t[1]; 3260} 3261function Ts(e) { 3262 return e[2] < e[0] || e[3] < e[1]; 3263} 3264function Wy(e, t) { 3265 return t ? (t[0] = e[0], t[1] = e[1], t[2] = e[2], t[3] = e[3], t) : e; 3266} 3267function By(e, t, i) { 3268 let s = !1; 3269 const n = nl(e, t), r = nl(e, i); 3270 if (n === Ut.INTERSECTING || r === Ut.INTERSECTING) 3271 s = !0; 3272 else { 3273 const o = e[0], a = e[1], l = e[2], h = e[3], c = t[0], u = t[1], d = i[0], f = i[1], g = (f - u) / (d - c); 3274 let _, m; 3275 r & Ut.ABOVE && !(n & Ut.ABOVE) && (_ = d - (f - h) / g, s = _ >= o && _ <= l), !s && r & Ut.RIGHT && !(n & Ut.RIGHT) && (m = f - (d - l) * g, s = m >= a && m <= h), !s && r & Ut.BELOW && !(n & Ut.BELOW) && (_ = d - (f - a) / g, s = _ >= o && _ <= l), !s && r & Ut.LEFT && !(n & Ut.LEFT) && (m = f - (d - o) * g, s = m >= a && m <= h); 3276 } 3277 return s; 3278} 3279function Uy(e, t, i, s) { 3280 if (Ts(e)) 3281 return bn(i); 3282 let n = []; 3283 if (s > 1) { 3284 const a = e[2] - e[0], l = e[3] - e[1]; 3285 for (let h = 0; h < s; ++h) 3286 n.push( 3287 e[0] + a * h / s, 3288 e[1], 3289 e[2], 3290 e[1] + l * h / s, 3291 e[2] - a * h / s, 3292 e[3], 3293 e[0], 3294 e[3] - l * h / s 3295 ); 3296 } else 3297 n = [ 3298 e[0], 3299 e[1], 3300 e[2], 3301 e[1], 3302 e[2], 3303 e[3], 3304 e[0], 3305 e[3] 3306 ]; 3307 t(n, n, 2); 3308 const r = [], o = []; 3309 for (let a = 0, l = n.length; a < l; a += 2) 3310 r.push(n[a]), o.push(n[a + 1]); 3311 return Gy(r, o, i); 3312} 3313function Ld(e, t) { 3314 const i = t.getExtent(), s = ii(e); 3315 if (t.canWrapX() && (s[0] < i[0] || s[0] >= i[2])) { 3316 const n = mt(i), o = Math.floor( 3317 (s[0] - i[0]) / n 3318 ) * n; 3319 e[0] -= o, e[2] -= o; 3320 } 3321 return e; 3322} 3323function Xy(e, t) { 3324 if (t.canWrapX()) { 3325 const i = t.getExtent(); 3326 if (!isFinite(e[0]) || !isFinite(e[2])) 3327 return [[i[0], e[1], i[2], e[3]]]; 3328 Ld(e, t); 3329 const s = mt(i); 3330 if (mt(e) > s) 3331 return [[i[0], e[1], i[2], e[3]]]; 3332 if (e[0] < i[0]) 3333 return [ 3334 [e[0] + s, e[1], i[2], e[3]], 3335 [i[0], e[1], e[2], e[3]] 3336 ]; 3337 if (e[2] > i[2]) 3338 return [ 3339 [e[0], e[1], i[2], e[3]], 3340 [i[0], e[1], e[2] - s, e[3]] 3341 ]; 3342 } 3343 return [e]; 3344} 3345function Ot(e, t, i) { 3346 return Math.min(Math.max(e, t), i); 3347} 3348function $y(e, t, i, s, n, r) { 3349 const o = n - i, a = r - s; 3350 if (o !== 0 || a !== 0) { 3351 const l = ((e - i) * o + (t - s) * a) / (o * o + a * a); 3352 l > 1 ? (i = n, s = r) : l > 0 && (i += o * l, s += a * l); 3353 } 3354 return fi(e, t, i, s); 3355} 3356function fi(e, t, i, s) {
3357 const n = i - e, r = s - t; 3358 return n * n + r * r; 3359} 3360function Yy(e) { 3361 const t = e.length; 3362 for (let s = 0; s < t; s++) { 3363 let n = s, r = Math.abs(e[s][s]); 3364 for (let a = s + 1; a < t; a++) { 3365 const l = Math.abs(e[a][s]); 3366 l > r && (r = l, n = a); 3367 } 3368 if (r === 0) 3369 return null; 3370 const o = e[n]; 3371 e[n] = e[s], e[s] = o; 3372 for (let a = s + 1; a < t; a++) { 3373 const l = -e[a][s] / e[s][s]; 3374 for (let h = s; h < t + 1; h++) 3375 s == h ? e[a][h] = 0 : e[a][h] += l * e[s][h]; 3376 } 3377 } 3378 const i = new Array(t); 3379 for (let s = t - 1; s >= 0; s--) { 3380 i[s] = e[s][t] / e[s][s]; 3381 for (let n = s - 1; n >= 0; n--) 3382 e[n][t] -= e[n][s] * i[s]; 3383 } 3384 return i; 3385} 3386function fo(e) { 3387 return e * Math.PI / 180; 3388} 3389function $i(e, t) { 3390 const i = e % t; 3391 return i * t < 0 ? i + t : i; 3392} 3393function we(e, t, i) { 3394 return e + i * (t - e); 3395} 3396function Tr(e, t) { 3397 const i = Math.pow(10, t); 3398 return Math.round(e * i) / i; 3399} 3400function Tc(e, t) { 3401 return Math.round(Tr(e, t)); 3402} 3403function Vs(e, t) { 3404 return Math.floor(Tr(e, t)); 3405} 3406function zi(e, t) { 3407 return Math.ceil(Tr(e, t)); 3408} 3409function Od(e, t) { 3410 const i = ("" + e).split("."), s = ("" + t).split("."); 3411 for (let n = 0; n < Math.max(i.length, s.length); n++) { 3412 const r = parseInt(i[n] || "0", 10), o = parseInt(s[n] || "0", 10); 3413 if (r > o) 3414 return 1; 3415 if (o > r) 3416 return -1; 3417 } 3418 return 0; 3419} 3420function Ky(e, t) { 3421 return e[0] += +t[0], e[1] += +t[1], e; 3422} 3423function Vy(e, t) { 3424 const i = t.getRadius(), s = t.getCenter(), n = s[0], r = s[1], o = e[0], a = e[1]; 3425 let l = o - n; 3426 const h = a - r; 3427 l === 0 && h === 0 && (l = 1); 3428 const c = Math.sqrt(l * l + h * h), u = n + i * l / c, d = r + i * h / c; 3429 return [u, d]; 3430} 3431function $l(e, t) { 3432 const i = e[0], s = e[1], n = t[0], r = t[1], o = n[0], a = n[1], l = r[0], h = r[1], c = l - o, u = h - a, d = c === 0 && u === 0 ? 0 : (c * (i - o) + u * (s - a)) / (c * c + u * u || 0); 3433 let f, g; 3434 return d <= 0 ? (f = o, g = a) : d >= 1 ? (f = l, g = h) : (f = o + d * c, g = a + d * u), [f, g]; 3435} 3436function Fe(e, t) { 3437 let i = !0; 3438 for (let s = e.length - 1; s >= 0; --s) 3439 if (e[s] != t[s]) { 3440 i = !1; 3441 break; 3442 } 3443 return i; 3444} 3445function Yl(e, t) { 3446 const i = Math.cos(t), s = Math.sin(t), n = e[0] * i - e[1] * s, r = e[1] * i + e[0] * s; 3447 return e[0] = n, e[1] = r, e; 3448} 3449function qy(e, t) { 3450 return e[0] *= t, e[1] *= t, e; 3451} 3452function gi(e, t) { 3453 const i = e[0] - t[0], s = e[1] - t[1]; 3454 return i * i + s * s; 3455} 3456function Co(e, t) { 3457 return Math.sqrt(gi(e, t)); 3458} 3459function Hy(e, t) { 3460 return gi(e, $l(e, t)); 3461} 3462function Fd(e, t) { 3463 if (t.canWrapX()) { 3464 const i = mt(t.getExtent()), s = Dd(e, t, i); 3465 s && (e[0] -= s * i); 3466 } 3467 return e; 3468} 3469function Dd(e, t, i) { 3470 const s = t.getExtent(); 3471 let n = 0; 3472 return t.canWrapX() && (e[0] < s[0] || e[0] > s[2]) && (i = i || mt(s), n = Math.floor( 3473 (e[0] - s[0]) / i 3474 )), n; 3475} 3476const Zy = 63710088e-1; 3477function Rc(e, t, i) { 3478 i = i || Zy; 3479 const s = fo(e[1]), n = fo(t[1]), r = (n - s) / 2, o = fo(t[0] - e[0]) / 2, a = Math.sin(r) * Math.sin(r) + Math.sin(o) * Math.sin(o) * Math.cos(s) * Math.cos(n); 3480 return 2 * i * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); 3481} 3482const Nd = { 3483 info: 1, 3484 warn: 2, 3485 error: 3, 3486 none: 4 3487}; 3488let Jy = Nd.info; 3489function kd(...e) { 3490 Jy > Nd.warn; 3491} 3492let al = !0; 3493function Qy(e) { 3494 al = !(e === void 0 ? !0 : e); 3495} 3496function Kl(e, t) { 3497 if (t !== void 0) { 3498 for (let i = 0, s = e.length; i < s; ++i) 3499 t[i] = e[i]; 3500 t = t; 3501 } else 3502 t = e.slice(); 3503 return t; 3504} 3505function Gd(e, t) { 3506 if (t !== void 0 && e !== t) { 3507 for (let i = 0, s = e.length; i < s; ++i) 3508 t[i] = e[i]; 3509 e = t; 3510 } 3511 return e; 3512} 3513function zd(e) { 3514 Dy(e.getCode(), e), dn(e, e, Kl); 3515} 3516function t1(e) { 3517 e.forEach(zd); 3518} 3519function Rt(e) { 3520 return typeof e == "string" ? Fy( 3521 /** @type {string} */ 3522 e 3523 ) : ( 3524 /** @type {Projection} */ 3525 e || null 3526 ); 3527} 3528function Ic(e, t, i, s) { 3529 e = Rt(e); 3530 let n; 3531 const r = e.getPointResolutionFunc(); 3532 if (r) { 3533 if (n = r(t, i), s && s !== e.getUnits()) { 3534 const o = e.getMetersPerUnit(); 3535 o && (n = n * o / er[s]); 3536 } 3537 } else { 3538 const o = e.getUnits(); 3539 if (o == "degrees" && !s || s == "degrees") 3540 n = t; 3541 else { 3542 const a = ql( 3543 e, 3544 Rt("EPSG:4326") 3545 ); 3546 if (a === Gd && o !== "degrees") 3547 n = t * e.getMetersPerUnit(); 3548 else { 3549 let h = [ 3550 i[0] - t / 2, 3551 i[1], 3552 i[0] + t / 2, 3553 i[1], 3554 i[0], 3555 i[1] - t / 2, 3556 i[0], 3557 i[1] + t / 2 3558 ]; 3559 h = a(h, h, 2); 3560 const c = Rc(h.slice(0, 2), h.slice(2, 4)), u = Rc(h.slice(4, 6), h.slice(6, 8)); 3561 n = (c + u) / 2; 3562 } 3563 const l = s ? er[s] : e.getMetersPerUnit(); 3564 l !== void 0 && (n /= l); 3565 } 3566 } 3567 return n; 3568} 3569function ll(e) { 3570 t1(e), e.forEach(function(t) { 3571 e.forEach(function(i) { 3572 t !== i && dn(t, i, Kl); 3573 }); 3574 }); 3575} 3576function e1(e, t, i, s) { 3577 e.forEach(function(n) { 3578 t.forEach(function(r) { 3579 dn(n, r, i), dn(r, n, s); 3580 }); 3581 }); 3582} 3583function Vl(e, t) { 3584 return e ? typeof e == "string" ? Rt(e) : ( 3585 /** @type {Projection} */ 3586 e 3587 ) : Rt(t); 3588} 3589function Pc(e) { 3590 return ( 3591 /** 3592 * @param {Array<number>} input Input. 3593 * @param {Array<number>} [output] Output. 3594 * @param {number} [dimension] Dimension. 3595 * @return {Array<number>} Output. 3596 */ 3597 function(t, i, s) { 3598 const n = t.length; 3599 s = s !== void 0 ? s : 2, i = i !== void 0 ? i : new Array(n); 3600 for (let r = 0; r < n; r += s) { 3601 const o = e(t.slice(r, r + s)), a = o.length; 3602 for (let l = 0, h = s; l < h; ++l) 3603 i[r + l] = l >= a ? t[r + l] : o[l]; 3604 } 3605 return i; 3606 } 3607 ); 3608} 3609function i1(e, t, i, s) { 3610 const n = Rt(e), r = Rt(t); 3611 dn( 3612 n, 3613 r, 3614 Pc(i) 3615 ), dn( 3616 r, 3617 n, 3618 Pc(s) 3619 ); 3620} 3621function di(e, t) { 3622 if (e === t) 3623 return !0; 3624 const i = e.getUnits() === t.getUnits(); 3625 return (e.getCode() === t.getCode() || ql(e, t) === Kl) && i; 3626} 3627function ql(e, t) { 3628 const i = e.getCode(), s = t.getCode(); 3629 let n = wd(i, s); 3630 return n || (n = Gd), n; 3631} 3632function ir(e, t) { 3633 const i = Rt(e), s = Rt(t); 3634 return ql(i, s); 3635} 3636function Hl(e, t, i) { 3637 return ir(t, i)(e, void 0, e.length); 3638} 3639function s1(e, t, i, s) { 3640 const n = ir(t, i); 3641 return Uy(e, n, void 0, s); 3642} 3643function Ms(e, t) { 3644 return e; 3645} 3646function It(e, t) { 3647 return al && !Fe(e, [0, 0]) && e[0] >= -180 && e[0] <= 180 && e[1] >= -90 && e[1] <= 90 && (al = !1, kd( 3648 "Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates." 3649 )), e; 3650} 3651function Zo(e, t) { 3652 return e; 3653} 3654function He(e, t) { 3655 return e; 3656} 3657function Ac(e, t, i) { 3658 return function(s) { 3659 let n, r; 3660 if (e.canWrapX()) { 3661 const o = e.getExtent(), a = mt(o); 3662 s = s.slice(0), r = Dd(s, e, a), r && (s[0] = s[0] - r * a), s[0] = Ot(s[0], o[0], o[2]), s[1] = Ot(s[1], o[1], o[3]), n = i(s); 3663 } else 3664 n = i(s); 3665 return r && t.canWrapX() && (n[0] += r * mt(t.getExtent())), n; 3666 }; 3667} 3668function n1() { 3669 ll(bc), ll(wc), e1( 3670 wc, 3671 bc, 3672 Py, 3673 Ay 3674 ); 3675} 3676n1(); 3677let r1 = null; 3678function o1(e) { 3679 r1 = e; 3680 const t = Object.keys(e.defs), i = t.length; 3681 let s, n; 3682 for (s = 0; s < i; ++s) { 3683 const r = t[s]; 3684 if (!Rt(r)) { 3685 const o = e.defs(r); 3686 let a = ( 3687 /** @type {import("./Units.js").Units} */ 3688 o.units 3689 ); 3690 !a && o.projName === "longlat" && (a = "degrees"), zd( 3691 new Bl({ 3692 code: r, 3693 axisOrientation: o.axis, 3694 metersPerUnit: o.to_meter, 3695 units: a 3696 }) 3697 ); 3698 } 3699 } 3700 for (s = 0; s < i; ++s) { 3701 const r = t[s], o = Rt(r); 3702 for (n = 0; n < i; ++n) { 3703 const a = t[n], l = Rt(a); 3704 if (!wd(r, a)) 3705 if (e.defs[r] === e.defs[a]) 3706 ll([o, l]); 3707 else { 3708 const h = e(r, a); 3709 i1( 3710 o, 3711 l, 3712 Ac(o, l, h.forward), 3713 Ac(l, o, h.inverse) 3714 ); 3715 } 3716 } 3717 } 3718} 3719function Zl(e, t) { 3720 const i = /* @__PURE__ */ Object.create(null), s = e.split(","); 3721 for (let n = 0; n < s.length; n++) 3722 i[s[n]] = !0; 3723 return t ? (n) => !!i[n.toLowerCase()] : (n) => !!i[n]; 3724} 3725const At = {}, sn = [], je = () => { 3726}, a1 = () => !1, l1 = /^on[^a-z]/, Jo = (e) => l1.test(e), Jl = (e) => e.startsWith("onUpdate:"), jt = Object.assign, Ql = (e, t) => { 3727 const i = e.indexOf(t); 3728 i > -1 && e.splice(i, 1); 3729}, h1 = Object.prototype.hasOwnProperty, _t = (e, t) => h1.call(e, t), it = Array.isArray, nn = (e) => Qo(e) === "[object Map]", jd = (e) => Qo(e) === "[object Set]", ht = (e) => typeof e == "function", Wt = (e) => typeof e == "string", th = (e) => typeof e == "symbol", Ft = (e) => e !== null && typeof e == "object", Wd = (e) => Ft(e) && ht(e.then) && ht(e.catch), Bd = Object.prototype.toString, Qo = (e) => Bd.call(e), c1 = (e) => Qo(e).slice(8, -1), Ud = (e) => Qo(e) === "[object Object]", eh = (e) => Wt(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, go = /* @__PURE__ */ Zl( 3730 // the leading comma is intentional so empty string "" is also included 3731 ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted" 3732), ta = (e) => { 3733 const t = /* @__PURE__ */ Object.create(null); 3734 return (i) => t[i] || (t[i] = e(i)); 3735}, u1 = /-(\w)/g, _i = ta((e) => e.replace(u1, (t, i) => i ? i.toUpperCase() : "")), d1 = /\B([A-Z])/g, Ne = ta( 3736 (e) => e.replace(d1, "-$1").toLowerCase() 3737), Xd = ta( 3738 (e) => e.charAt(0).toUpperCase() + e.slice(1) 3739), ba = ta( 3740 (e) => e ? `on${Xd(e)}` : "" 3741), bo = (e, t) => !Object.is(e, t), Sa = (e, t) => { 3742 for (let i = 0; i < e.length; i++) 3743 e[i](t); 3744}, So = (e, t, i) => { 3745 Object.defineProperty(e, t, { 3746 configurable: !0, 3747 enumerable: !1, 3748 value: i 3749 }); 3750}, f1 = (e) => { 3751 const t = parseFloat(e); 3752 return isNaN(t) ? e : t; 3753}, Lc = (e) => { 3754 const t = Wt(e) ? Number(e) : NaN; 3755 return isNaN(t) ? e : t; 3756}; 3757let Oc; 3758const hl = () => Oc || (Oc = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {}); 3759function Rr(e) { 3760 if (it(e)) { 3761 const t = {}; 3762 for (let i = 0; i < e.length; i++) { 3763 const s = e[i], n = Wt(s) ? p1(s) : Rr(s); 3764 if (n) 3765 for (const r in n) 3766 t[r] = n[r]; 3767 } 3768 return t; 3769 } else { 3770 if (Wt(e)) 3771 return e; 3772 if (Ft(e)) 3773 return e; 3774 } 3775} 3776const g1 = /;(?![^(]*\))/g, _1 = /:([^]+)/, m1 = /\/\*[^]*?\*\//g; 3777function p1(e) { 3778 const t = {};
3779 return e.replace(m1, "").split(g1).forEach((i) => { 3780 if (i) { 3781 const s = i.split(_1); 3782 s.length > 1 && (t[s[0].trim()] = s[1].trim()); 3783 } 3784 }), t; 3785} 3786function gn(e) { 3787 let t = ""; 3788 if (Wt(e)) 3789 t = e; 3790 else if (it(e)) 3791 for (let i = 0; i < e.length; i++) { 3792 const s = gn(e[i]); 3793 s && (t += s + " "); 3794 } 3795 else if (Ft(e)) 3796 for (const i in e) 3797 e[i] && (t += i + " "); 3798 return t.trim(); 3799} 3800const y1 = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly", x1 = /* @__PURE__ */ Zl(y1); 3801function $d(e) { 3802 return !!e || e === ""; 3803} 3804const Di = (e) => Wt(e) ? e : e == null ? "" : it(e) || Ft(e) && (e.toString === Bd || !ht(e.toString)) ? JSON.stringify(e, Yd, 2) : String(e), Yd = (e, t) => t && t.__v_isRef ? Yd(e, t.value) : nn(t) ? { 3805 [`Map(${t.size})`]: [...t.entries()].reduce((i, [s, n]) => (i[`${s} =>`] = n, i), {}) 3806} : jd(t) ? { 3807 [`Set(${t.size})`]: [...t.values()] 3808} : Ft(t) && !it(t) && !Ud(t) ? String(t) : t; 3809let Oe; 3810class v1 { 3811 constructor(t = !1) { 3812 this.detached = t, this._active = !0, this.effects = [], this.cleanups = [], this.parent = Oe, !t && Oe && (this.index = (Oe.scopes || (Oe.scopes = [])).push( 3813 this 3814 ) - 1); 3815 } 3816 get active() { 3817 return this._active; 3818 } 3819 run(t) { 3820 if (this._active) { 3821 const i = Oe; 3822 try { 3823 return Oe = this, t(); 3824 } finally { 3825 Oe = i; 3826 } 3827 } 3828 } 3829 /** 3830 * This should only be called on non-detached scopes 3831 * @internal 3832 */ 3833 on() { 3834 Oe = this; 3835 } 3836 /** 3837 * This should only be called on non-detached scopes 3838 * @internal 3839 */ 3840 off() { 3841 Oe = this.parent; 3842 } 3843 stop(t) { 3844 if (this._active) { 3845 let i, s; 3846 for (i = 0, s = this.effects.length; i < s; i++) 3847 this.effects[i].stop(); 3848 for (i = 0, s = this.cleanups.length; i < s; i++) 3849 this.cleanups[i](); 3850 if (this.scopes) 3851 for (i = 0, s = this.scopes.length; i < s; i++) 3852 this.scopes[i].stop(!0); 3853 if (!this.detached && this.parent && !t) { 3854 const n = this.parent.scopes.pop(); 3855 n && n !== this && (this.parent.scopes[this.index] = n, n.index = this.index); 3856 } 3857 this.parent = void 0, this._active = !1; 3858 } 3859 } 3860} 3861function E1(e, t = Oe) { 3862 t && t.active && t.effects.push(e); 3863} 3864function M1() { 3865 return Oe; 3866} 3867const ih = (e) => { 3868 const t = new Set(e); 3869 return t.w = 0, t.n = 0, t; 3870}, Kd = (e) => (e.w & Zi) > 0, Vd = (e) => (e.n & Zi) > 0, C1 = ({ deps: e }) => { 3871 if (e.length) 3872 for (let t = 0; t < e.length; t++) 3873 e[t].w |= Zi; 3874}, b1 = (e) => { 3875 const { deps: t } = e; 3876 if (t.length) { 3877 let i = 0; 3878 for (let s = 0; s < t.length; s++) { 3879 const n = t[s]; 3880 Kd(n) && !Vd(n) ? n.delete(e) : t[i++] = n, n.w &= ~Zi, n.n &= ~Zi; 3881 } 3882 t.length = i; 3883 } 3884}, cl = /* @__PURE__ */ new WeakMap(); 3885let Wn = 0, Zi = 1; 3886const ul = 30; 3887let ke; 3888const gs = Symbol(""), dl = Symbol(""); 3889class sh { 3890 constructor(t, i = null, s) { 3891 this.fn = t, this.scheduler = i, this.active = !0, this.deps = [], this.parent = void 0, E1(this, s); 3892 } 3893 run() { 3894 if (!this.active) 3895 return this.fn(); 3896 let t = ke, i = Yi; 3897 for (; t; ) { 3898 if (t === this) 3899 return; 3900 t = t.parent; 3901 } 3902 try { 3903 return this.parent = ke, ke = this, Yi = !0, Zi = 1 << ++Wn, Wn <= ul ? C1(this) : Fc(this), this.fn(); 3904 } finally { 3905 Wn <= ul && b1(this), Zi = 1 << --Wn, ke = this.parent, Yi = i, this.parent = void 0, this.deferStop && this.stop(); 3906 } 3907 } 3908 stop() { 3909 ke === this ? this.deferStop = !0 : this.active && (Fc(this), this.onStop && this.onStop(), this.active = !1); 3910 } 3911} 3912function Fc(e) { 3913 const { deps: t } = e; 3914 if (t.length) { 3915 for (let i = 0; i < t.length; i++) 3916 t[i].delete(e); 3917 t.length = 0; 3918 } 3919} 3920let Yi = !0; 3921const qd = []; 3922function Sn() { 3923 qd.push(Yi), Yi = !1; 3924} 3925function wn() { 3926 const e = qd.pop(); 3927 Yi = e === void 0 ? !0 : e; 3928} 3929function Ee(e, t, i) { 3930 if (Yi && ke) { 3931 let s = cl.get(e); 3932 s || cl.set(e, s = /* @__PURE__ */ new Map()); 3933 let n = s.get(i); 3934 n || s.set(i, n = ih()), Hd(n); 3935 } 3936} 3937function Hd(e, t) { 3938 let i = !1; 3939 Wn <= ul ? Vd(e) || (e.n |= Zi, i = !Kd(e)) : i = !e.has(ke), i && (e.add(ke), ke.deps.push(e)); 3940} 3941function vi(e, t, i, s, n, r) { 3942 const o = cl.get(e); 3943 if (!o) 3944 return; 3945 let a = []; 3946 if (t === "clear") 3947 a = [...o.values()]; 3948 else if (i === "length" && it(e)) { 3949 const l = Number(s); 3950 o.forEach((h, c) => { 3951 (c === "length" || c >= l) && a.push(h); 3952 }); 3953 } else 3954 switch (i !== void 0 && a.push(o.get(i)), t) { 3955 case "add": 3956 it(e) ? eh(i) && a.push(o.get("length")) : (a.push(o.get(gs)), nn(e) && a.push(o.get(dl))); 3957 break; 3958 case "delete": 3959 it(e) || (a.push(o.get(gs)), nn(e) && a.push(o.get(dl))); 3960 break; 3961 case "set": 3962 nn(e) && a.push(o.get(gs)); 3963 break; 3964 } 3965 if (a.length === 1) 3966 a[0] && fl(a[0]); 3967 else { 3968 const l = []; 3969 for (const h of a) 3970 h && l.push(...h); 3971 fl(ih(l)); 3972 } 3973} 3974function fl(e, t) { 3975 const i = it(e) ? e : [...e]; 3976 for (const s of i) 3977 s.computed && Dc(s); 3978 for (const s of i) 3979 s.computed || Dc(s); 3980} 3981function Dc(e, t) { 3982 (e !== ke || e.allowRecurse) && (e.scheduler ? e.scheduler() : e.run()); 3983} 3984const S1 = /* @__PURE__ */ Zl("__proto__,__v_isRef,__isVue"), Zd = new Set(
3985 /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((e) => e !== "arguments" && e !== "caller").map((e) => Symbol[e]).filter(th) 3986), w1 = /* @__PURE__ */ nh(), T1 = /* @__PURE__ */ nh(!1, !0), R1 = /* @__PURE__ */ nh(!0), Nc = /* @__PURE__ */ I1(); 3987function I1() { 3988 const e = {}; 3989 return ["includes", "indexOf", "lastIndexOf"].forEach((t) => { 3990 e[t] = function(...i) { 3991 const s = Ct(this); 3992 for (let r = 0, o = this.length; r < o; r++) 3993 Ee(s, "get", r + ""); 3994 const n = s[t](...i); 3995 return n === -1 || n === !1 ? s[t](...i.map(Ct)) : n; 3996 }; 3997 }), ["push", "pop", "shift", "unshift", "splice"].forEach((t) => { 3998 e[t] = function(...i) { 3999 Sn(); 4000 const s = Ct(this)[t].apply(this, i); 4001 return wn(), s; 4002 }; 4003 }), e; 4004} 4005function P1(e) { 4006 const t = Ct(this); 4007 return Ee(t, "has", e), t.hasOwnProperty(e); 4008} 4009function nh(e = !1, t = !1) { 4010 return function(s, n, r) { 4011 if (n === "__v_isReactive") 4012 return !e; 4013 if (n === "__v_isReadonly") 4014 return e; 4015 if (n === "__v_isShallow") 4016 return t; 4017 if (n === "__v_raw" && r === (e ? t ? Y1 : sf : t ? ef : tf).get(s)) 4018 return s; 4019 const o = it(s); 4020 if (!e) { 4021 if (o && _t(Nc, n)) 4022 return Reflect.get(Nc, n, r); 4023 if (n === "hasOwnProperty") 4024 return P1; 4025 } 4026 const a = Reflect.get(s, n, r); 4027 return (th(n) ? Zd.has(n) : S1(n)) || (e || Ee(s, "get", n), t) ? a : de(a) ? o && eh(n) ? a : a.value : Ft(a) ? e ? nf(a) : ia(a) : a; 4028 }; 4029} 4030const A1 = /* @__PURE__ */ Jd(), L1 = /* @__PURE__ */ Jd(!0); 4031function Jd(e = !1) { 4032 return function(i, s, n, r) { 4033 let o = i[s]; 4034 if (sr(o) && de(o) && !de(n)) 4035 return !1; 4036 if (!e && (!gl(n) && !sr(n) && (o = Ct(o), n = Ct(n)), !it(i) && de(o) && !de(n))) 4037 return o.value = n, !0; 4038 const a = it(i) && eh(s) ? Number(s) < i.length : _t(i, s), l = Reflect.set(i, s, n, r); 4039 return i === Ct(r) && (a ? bo(n, o) && vi(i, "set", s, n) : vi(i, "add", s, n)), l; 4040 }; 4041} 4042function O1(e, t) { 4043 const i = _t(e, t); 4044 e[t]; 4045 const s = Reflect.deleteProperty(e, t); 4046 return s && i && vi(e, "delete", t, void 0), s; 4047} 4048function F1(e, t) { 4049 const i = Reflect.has(e, t); 4050 return (!th(t) || !Zd.has(t)) && Ee(e, "has", t), i; 4051} 4052function D1(e) { 4053 return Ee(e, "iterate", it(e) ? "length" : gs), Reflect.ownKeys(e); 4054} 4055const Qd = { 4056 get: w1, 4057 set: A1, 4058 deleteProperty: O1, 4059 has: F1, 4060 ownKeys: D1 4061}, N1 = { 4062 get: R1, 4063 set(e, t) { 4064 return !0; 4065 }, 4066 deleteProperty(e, t) { 4067 return !0; 4068 } 4069}, k1 = /* @__PURE__ */ jt( 4070 {}, 4071 Qd, 4072 { 4073 get: T1, 4074 set: L1 4075 } 4076), rh = (e) => e, ea = (e) => Reflect.getPrototypeOf(e); 4077function Wr(e, t, i = !1, s = !1) { 4078 e = e.__v_raw; 4079 const n = Ct(e), r = Ct(t); 4080 i || (t !== r && Ee(n, "get", t), Ee(n, "get", r)); 4081 const { has: o } = ea(n), a = s ? rh : i ? hh : lh; 4082 if (o.call(n, t)) 4083 return a(e.get(t)); 4084 if (o.call(n, r)) 4085 return a(e.get(r)); 4086 e !== n && e.get(t); 4087} 4088function Br(e, t = !1) { 4089 const i = this.__v_raw, s = Ct(i), n = Ct(e); 4090 return t || (e !== n && Ee(s, "has", e), Ee(s, "has", n)), e === n ? i.has(e) : i.has(e) || i.has(n); 4091} 4092function Ur(e, t = !1) { 4093 return e = e.__v_raw, !t && Ee(Ct(e), "iterate", gs), Reflect.get(e, "size", e); 4094} 4095function kc(e) { 4096 e = Ct(e); 4097 const t = Ct(this); 4098 return ea(t).has.call(t, e) || (t.add(e), vi(t, "add", e, e)), this; 4099} 4100function Gc(e, t) { 4101 t = Ct(t); 4102 const i = Ct(this), { has: s, get: n } = ea(i); 4103 let r = s.call(i, e); 4104 r || (e = Ct(e), r = s.call(i, e)); 4105 const o = n.call(i, e); 4106 return i.set(e, t), r ? bo(t, o) && vi(i, "set", e, t) : vi(i, "add", e, t), this; 4107} 4108function zc(e) { 4109 const t = Ct(this), { has: i, get: s } = ea(t); 4110 let n = i.call(t, e); 4111 n || (e = Ct(e), n = i.call(t, e)), s && s.call(t, e); 4112 const r = t.delete(e); 4113 return n && vi(t, "delete", e, void 0), r; 4114} 4115function jc() { 4116 const e = Ct(this), t = e.size !== 0, i = e.clear(); 4117 return t && vi(e, "clear", void 0, void 0), i; 4118} 4119function Xr(e, t) { 4120 return function(s, n) { 4121 const r = this, o = r.__v_raw, a = Ct(o), l = t ? rh : e ? hh : lh; 4122 return !e && Ee(a, "iterate", gs), o.forEach((h, c) => s.call(n, l(h), l(c), r)); 4123 }; 4124} 4125function $r(e, t, i) { 4126 return function(...s) { 4127 const n = this.__v_raw, r = Ct(n), o = nn(r), a = e === "entries" || e === Symbol.iterator && o, l = e === "keys" && o, h = n[e](...s), c = i ? rh : t ? hh : lh; 4128 return !t && Ee( 4129 r, 4130 "iterate", 4131 l ? dl : gs 4132 ), { 4133 // iterator protocol 4134 next() { 4135 const { value: u, done: d } = h.next(); 4136 return d ? { value: u, done: d } : { 4137 value: a ? [c(u[0]), c(u[1])] : c(u), 4138 done: d 4139 }; 4140 }, 4141 // iterable protocol 4142 [Symbol.iterator]() { 4143 return this; 4144 } 4145 }; 4146 }; 4147} 4148function wi(e) { 4149 return function(...t) { 4150 return e === "delete" ? !1 : this; 4151 }; 4152} 4153function G1() { 4154 const e = { 4155 get(r) { 4156 return Wr(this, r); 4157 }, 4158 get size() { 4159 return Ur(this); 4160 }, 4161 has: Br, 4162 add: kc, 4163 set: Gc, 4164 delete: zc, 4165 clear: jc,
4166 forEach: Xr(!1, !1) 4167 }, t = { 4168 get(r) { 4169 return Wr(this, r, !1, !0); 4170 }, 4171 get size() { 4172 return Ur(this); 4173 }, 4174 has: Br, 4175 add: kc, 4176 set: Gc, 4177 delete: zc, 4178 clear: jc, 4179 forEach: Xr(!1, !0) 4180 }, i = { 4181 get(r) { 4182 return Wr(this, r, !0); 4183 }, 4184 get size() { 4185 return Ur(this, !0); 4186 }, 4187 has(r) { 4188 return Br.call(this, r, !0); 4189 }, 4190 add: wi("add"), 4191 set: wi("set"), 4192 delete: wi("delete"), 4193 clear: wi("clear"), 4194 forEach: Xr(!0, !1) 4195 }, s = { 4196 get(r) { 4197 return Wr(this, r, !0, !0); 4198 }, 4199 get size() { 4200 return Ur(this, !0); 4201 }, 4202 has(r) { 4203 return Br.call(this, r, !0); 4204 }, 4205 add: wi("add"), 4206 set: wi("set"), 4207 delete: wi("delete"), 4208 clear: wi("clear"), 4209 forEach: Xr(!0, !0) 4210 }; 4211 return ["keys", "values", "entries", Symbol.iterator].forEach((r) => { 4212 e[r] = $r( 4213 r, 4214 !1, 4215 !1 4216 ), i[r] = $r( 4217 r, 4218 !0, 4219 !1 4220 ), t[r] = $r( 4221 r, 4222 !1, 4223 !0 4224 ), s[r] = $r( 4225 r, 4226 !0, 4227 !0 4228 ); 4229 }), [ 4230 e, 4231 i, 4232 t, 4233 s 4234 ]; 4235} 4236const [ 4237 z1, 4238 j1, 4239 W1, 4240 B1 4241] = /* @__PURE__ */ G1(); 4242function oh(e, t) { 4243 const i = t ? e ? B1 : W1 : e ? j1 : z1; 4244 return (s, n, r) => n === "__v_isReactive" ? !e : n === "__v_isReadonly" ? e : n === "__v_raw" ? s : Reflect.get( 4245 _t(i, n) && n in s ? i : s, 4246 n, 4247 r 4248 ); 4249} 4250const U1 = { 4251 get: /* @__PURE__ */ oh(!1, !1) 4252}, X1 = { 4253 get: /* @__PURE__ */ oh(!1, !0) 4254}, $1 = { 4255 get: /* @__PURE__ */ oh(!0, !1) 4256}, tf = /* @__PURE__ */ new WeakMap(), ef = /* @__PURE__ */ new WeakMap(), sf = /* @__PURE__ */ new WeakMap(), Y1 = /* @__PURE__ */ new WeakMap(); 4257function K1(e) { 4258 switch (e) { 4259 case "Object": 4260 case "Array": 4261 return 1; 4262 case "Map": 4263 case "Set": 4264 case "WeakMap": 4265 case "WeakSet": 4266 return 2; 4267 default: 4268 return 0; 4269 } 4270} 4271function V1(e) { 4272 return e.__v_skip || !Object.isExtensible(e) ? 0 : K1(c1(e)); 4273} 4274function ia(e) { 4275 return sr(e) ? e : ah( 4276 e, 4277 !1, 4278 Qd, 4279 U1, 4280 tf 4281 ); 4282} 4283function q1(e) { 4284 return ah( 4285 e, 4286 !1, 4287 k1, 4288 X1, 4289 ef 4290 ); 4291} 4292function nf(e) { 4293 return ah( 4294 e, 4295 !0, 4296 N1, 4297 $1, 4298 sf 4299 ); 4300} 4301function ah(e, t, i, s, n) { 4302 if (!Ft(e) || e.__v_raw && !(t && e.__v_isReactive)) 4303 return e; 4304 const r = n.get(e); 4305 if (r) 4306 return r; 4307 const o = V1(e); 4308 if (o === 0) 4309 return e; 4310 const a = new Proxy( 4311 e, 4312 o === 2 ? s : i 4313 ); 4314 return n.set(e, a), a; 4315} 4316function rn(e) { 4317 return sr(e) ? rn(e.__v_raw) : !!(e && e.__v_isReactive); 4318} 4319function sr(e) { 4320 return !!(e && e.__v_isReadonly); 4321} 4322function gl(e) { 4323 return !!(e && e.__v_isShallow); 4324} 4325function rf(e) { 4326 return rn(e) || sr(e); 4327} 4328function Ct(e) { 4329 const t = e && e.__v_raw; 4330 return t ? Ct(t) : e; 4331} 4332function _n(e) { 4333 return So(e, "__v_skip", !0), e; 4334} 4335const lh = (e) => Ft(e) ? ia(e) : e, hh = (e) => Ft(e) ? nf(e) : e; 4336function H1(e) { 4337 Yi && ke && (e = Ct(e), Hd(e.dep || (e.dep = ih()))); 4338} 4339function Z1(e, t) { 4340 e = Ct(e); 4341 const i = e.dep; 4342 i && fl(i); 4343} 4344function de(e) { 4345 return !!(e && e.__v_isRef === !0); 4346} 4347function J1(e) { 4348 return de(e) ? e.value : e; 4349} 4350const Q1 = { 4351 get: (e, t, i) => J1(Reflect.get(e, t, i)), 4352 set: (e, t, i, s) => { 4353 const n = e[t]; 4354 return de(n) && !de(i) ? (n.value = i, !0) : Reflect.set(e, t, i, s); 4355 } 4356}; 4357function of(e) { 4358 return rn(e) ? e : new Proxy(e, Q1); 4359} 4360class tx { 4361 constructor(t, i, s, n) { 4362 this._setter = i, this.dep = void 0, this.__v_isRef = !0, this.__v_isReadonly = !1, this._dirty = !0, this.effect = new sh(t, () => { 4363 this._dirty || (this._dirty = !0, Z1(this)); 4364 }), this.effect.computed = this, this.effect.active = this._cacheable = !n, this.__v_isReadonly = s; 4365 } 4366 get value() { 4367 const t = Ct(this); 4368 return H1(t), (t._dirty || !t._cacheable) && (t._dirty = !1, t._value = t.effect.run()), t._value; 4369 } 4370 set value(t) { 4371 this._setter(t); 4372 } 4373} 4374function ex(e, t, i = !1) { 4375 let s, n; 4376 const r = ht(e); 4377 return r ? (s = e, n = je) : (s = e.get, n = e.set), new tx(s, n, r || !n, i); 4378} 4379function Ki(e, t, i, s) { 4380 let n; 4381 try { 4382 n = s ? e(...s) : e(); 4383 } catch (r) { 4384 sa(r, t, i); 4385 } 4386 return n; 4387} 4388function We(e, t, i, s) { 4389 if (ht(e)) { 4390 const r = Ki(e, t, i, s); 4391 return r && Wd(r) && r.catch((o) => { 4392 sa(o, t, i); 4393 }), r; 4394 } 4395 const n = []; 4396 for (let r = 0; r < e.length; r++) 4397 n.push(We(e[r], t, i, s)); 4398 return n; 4399} 4400function sa(e, t, i, s = !0) { 4401 const n = t ? t.vnode : null; 4402 if (t) { 4403 let r = t.parent; 4404 const o = t.proxy, a = i; 4405 for (; r; ) { 4406 const h = r.ec; 4407 if (h) { 4408 for (let c = 0; c < h.length; c++) 4409 if (h[c](e, o, a) === !1) 4410 return; 4411 } 4412 r = r.parent; 4413 } 4414 const l = t.appContext.config.errorHandler; 4415 if (l) { 4416 Ki( 4417 l, 4418 null, 4419 10, 4420 [e, o, a] 4421 ); 4422 return; 4423 } 4424 } 4425} 4426let nr = !1, _l = !1; 4427const ie = []; 4428let Ke = 0; 4429const on = []; 4430let ci = null, ls = 0; 4431const af = /* @__PURE__ */ Promise.resolve(); 4432let ch = null; 4433function lf(e) { 4434 const t = ch || af; 4435 return e ? t.then(this ? e.bind(this) : e) : t; 4436} 4437function ix(e) { 4438 let t = Ke + 1, i = ie.length; 4439 for (; t < i; ) { 4440 const s = t + i >>> 1; 4441 rr(ie[s]) < e ? t = s + 1 : i = s; 4442 } 4443 return t; 4444} 4445function uh(e) { 4446 (!ie.length || !ie.includes( 4447 e, 4448 nr && e.allowRecurse ? Ke + 1 : Ke 4449 )) && (e.id == null ? ie.push(e) : ie.splice(ix(e.id), 0, e), hf()); 4450} 4451function hf() { 4452 !nr && !_l && (_l = !0, ch = af.then(uf)); 4453} 4454function sx(e) { 4455 const t = ie.indexOf(e); 4456 t > Ke && ie.splice(t, 1); 4457} 4458function nx(e) { 4459 it(e) ? on.push(...e) : (!ci || !ci.includes( 4460 e, 4461 e.allowRecurse ? ls + 1 : ls 4462 )) && on.push(e), hf(); 4463} 4464function Wc(e, t = nr ? Ke + 1 : 0) { 4465 for (; t < ie.length; t++) { 4466 const i = ie[t]; 4467 i && i.pre && (ie.splice(t, 1), t--, i()); 4468 } 4469} 4470function cf(e) { 4471 if (on.length) { 4472 const t = [...new Set(on)]; 4473 if (on.length = 0, ci) { 4474 ci.push(...t); 4475 return; 4476 } 4477 for (ci = t, ci.sort((i, s) => rr(i) - rr(s)), ls = 0; ls < ci.length; ls++) 4478 ci[ls](); 4479 ci = null, ls = 0; 4480 } 4481} 4482const rr = (e) => e.id == null ? 1 / 0 : e.id, rx = (e, t) => { 4483 const i = rr(e) - rr(t); 4484 if (i === 0) { 4485 if (e.pre && !t.pre) 4486 return -1; 4487 if (t.pre && !e.pre) 4488 return 1; 4489 } 4490 return i; 4491}; 4492function uf(e) { 4493 _l = !1, nr = !0, ie.sort(rx); 4494 const t = je; 4495 try { 4496 for (Ke = 0; Ke < ie.length; Ke++) { 4497 const i = ie[Ke]; 4498 i && i.active !== !1 && Ki(i, null, 14); 4499 } 4500 } finally { 4501 Ke = 0, ie.length = 0, cf(), nr = !1, ch = null, (ie.length || on.length) && uf(); 4502 } 4503} 4504function ox(e, t, ...i) { 4505 if (e.isUnmounted) 4506 return; 4507 const s = e.vnode.props || At; 4508 let n = i; 4509 const r = t.startsWith("update:"), o = r && t.slice(7); 4510 if (o && o in s) { 4511 const c = `${o === "modelValue" ? "model" : o}Modifiers`, { number: u, trim: d } = s[c] || At; 4512 d && (n = i.map((f) => Wt(f) ? f.trim() : f)), u && (n = i.map(f1)); 4513 } 4514 let a, l = s[a = ba(t)] || // also try camelCase event handler (#2249)
vendor: 2,853 bytes, lines 4515-4647
4515 s[a = ba(_i(t))]; 4516 !l && r && (l = s[a = ba(Ne(t))]), l && We( 4517 l, 4518 e, 4519 6, 4520 n 4521 ); 4522 const h = s[a + "Once"]; 4523 if (h) { 4524 if (!e.emitted) 4525 e.emitted = {}; 4526 else if (e.emitted[a]) 4527 return; 4528 e.emitted[a] = !0, We( 4529 h, 4530 e, 4531 6, 4532 n 4533 ); 4534 } 4535} 4536function df(e, t, i = !1) { 4537 const s = t.emitsCache, n = s.get(e); 4538 if (n !== void 0) 4539 return n; 4540 const r = e.emits; 4541 let o = {}, a = !1; 4542 if (!ht(e)) { 4543 const l = (h) => { 4544 const c = df(h, t, !0); 4545 c && (a = !0, jt(o, c)); 4546 }; 4547 !i && t.mixins.length && t.mixins.forEach(l), e.extends && l(e.extends), e.mixins && e.mixins.forEach(l); 4548 } 4549 return !r && !a ? (Ft(e) && s.set(e, null), null) : (it(r) ? r.forEach((l) => o[l] = null) : jt(o, r), Ft(e) && s.set(e, o), o); 4550} 4551function na(e, t) { 4552 return !e || !Jo(t) ? !1 : (t = t.slice(2).replace(/Once$/, ""), _t(e, t[0].toLowerCase() + t.slice(1)) || _t(e, Ne(t)) || _t(e, t)); 4553} 4554let pe = null, ff = null; 4555function wo(e) { 4556 const t = pe; 4557 return pe = e, ff = e && e.type.__scopeId || null, t; 4558} 4559function ax(e, t = pe, i) { 4560 if (!t || e._n) 4561 return e; 4562 const s = (...n) => { 4563 s._d && Zc(-1); 4564 const r = wo(t); 4565 let o; 4566 try { 4567 o = e(...n); 4568 } finally { 4569 wo(r), s._d && Zc(1); 4570 } 4571 return o; 4572 }; 4573 return s._n = !0, s._c = !0, s._d = !0, s; 4574} 4575function wa(e) { 4576 const { 4577 type: t, 4578 vnode: i, 4579 proxy: s, 4580 withProxy: n, 4581 props: r, 4582 propsOptions: [o], 4583 slots: a, 4584 attrs: l, 4585 emit: h, 4586 render: c, 4587 renderCache: u, 4588 data: d, 4589 setupState: f, 4590 ctx: g, 4591 inheritAttrs: _ 4592 } = e; 4593 let m, p; 4594 const y = wo(e); 4595 try { 4596 if (i.shapeFlag & 4) { 4597 const E = n || s; 4598 m = Ye( 4599 c.call( 4600 E, 4601 E, 4602 u, 4603 r, 4604 f, 4605 d, 4606 g 4607 ) 4608 ), p = l; 4609 } else { 4610 const E = t; 4611 m = Ye( 4612 E.length > 1 ? E( 4613 r, 4614 { attrs: l, slots: a, emit: h } 4615 ) : E( 4616 r, 4617 null 4618 /* we know it doesn't need it */ 4619 ) 4620 ), p = t.props ? l : lx(l); 4621 } 4622 } catch (E) { 4623 qn.length = 0, sa(E, e, 1), m = Be(Ji); 4624 } 4625 let v = m; 4626 if (p && _ !== !1) { 4627 const E = Object.keys(p), { shapeFlag: C } = v; 4628 E.length && C & 7 && (o && E.some(Jl) && (p = hx( 4629 p, 4630 o 4631 )), v = mn(v, p)); 4632 } 4633 return i.dirs && (v = mn(v), v.dirs = v.dirs ? v.dirs.concat(i.dirs) : i.dirs), i.transition && (v.transition = i.transition), m = v, wo(y), m; 4634} 4635const lx = (e) => { 4636 let t; 4637 for (const i in e) 4638 (i === "class" || i === "style" || Jo(i)) && ((t || (t = {}))[i] = e[i]); 4639 return t; 4640}, hx = (e, t) => { 4641 const i = {}; 4642 for (const s in e) 4643 (!Jl(s) || !(s.slice(9) in t)) && (i[s] = e[s]); 4644 return i; 4645}; 4646function cx(e, t, i) { 4647 const { props: s, children: n, component: r }
4647 = e, { props: o, children: a, patchFlag: l } = t, h = r.emitsOptions; 4648 if (t.dirs || t.transition) 4649 return !0; 4650 if (i && l >= 0) { 4651 if (l & 1024) 4652 return !0; 4653 if (l & 16) 4654 return s ? Bc(s, o, h) : !!o; 4655 if (l & 8) { 4656 const c = t.dynamicProps; 4657 for (let u = 0; u < c.length; u++) { 4658 const d = c[u]; 4659 if (o[d] !== s[d] && !na(h, d)) 4660 return !0; 4661 } 4662 } 4663 } else 4664 return (n || a) && (!a || !a.$stable) ? !0 : s === o ? !1 : s ? o ? Bc(s, o, h) : !0 : !!o; 4665 return !1; 4666} 4667function Bc(e, t, i) { 4668 const s = Object.keys(t); 4669 if (s.length !== Object.keys(e).length) 4670 return !0; 4671 for (let n = 0; n < s.length; n++) { 4672 const r = s[n]; 4673 if (t[r] !== e[r] && !na(i, r)) 4674 return !0; 4675 } 4676 return !1; 4677} 4678function ux({ vnode: e, parent: t }, i) { 4679 for (; t && t.subTree === e; ) 4680 (e = t.vnode).el = i, t = t.parent; 4681} 4682const dx = (e) => e.__isSuspense; 4683function fx(e, t) { 4684 t && t.pendingBranch ? it(e) ? t.effects.push(...e) : t.effects.push(e) : nx(e); 4685} 4686const Yr = {}; 4687function Ta(e, t, i) { 4688 return gf(e, t, i); 4689} 4690function gf(e, t, { immediate: i, deep: s, flush: n, onTrack: r, onTrigger: o } = At) { 4691 var a; 4692 const l = M1() === ((a = se) == null ? void 0 : a.scope) ? se : null; 4693 let h, c = !1, u = !1; 4694 if (de(e) ? (h = () => e.value, c = gl(e)) : rn(e) ? (h = () => e, s = !0) : it(e) ? (u = !0, c = e.some((E) => rn(E) || gl(E)), h = () => e.map((E) => { 4695 if (de(E)) 4696 return E.value; 4697 if (rn(E)) 4698 return qs(E); 4699 if (ht(E)) 4700 return Ki(E, l, 2); 4701 })) : ht(e) ? t ? h = () => Ki(e, l, 2) : h = () => { 4702 if (!(l && l.isUnmounted)) 4703 return d && d(), We( 4704 e, 4705 l, 4706 3, 4707 [f] 4708 ); 4709 } : h = je, t && s) { 4710 const E = h; 4711 h = () => qs(E()); 4712 } 4713 let d, f = (E) => { 4714 d = y.onStop = () => { 4715 Ki(E, l, 4); 4716 }; 4717 }, g; 4718 if (ar) 4719 if (f = je, t ? i && We(t, l, 3, [ 4720 h(), 4721 u ? [] : void 0, 4722 f 4723 ]) : h(), n === "sync") { 4724 const E = av(); 4725 g = E.__watcherHandles || (E.__watcherHandles = []); 4726 } else 4727 return je; 4728 let _ = u ? new Array(e.length).fill(Yr) : Yr; 4729 const m = () => { 4730 if (y.active) 4731 if (t) { 4732 const E = y.run(); 4733 (s || c || (u ? E.some( 4734 (C, S) => bo(C, _[S]) 4735 ) : bo(E, _))) && (d && d(), We(t, l, 3, [ 4736 E, 4737 // pass undefined as the old value when it's changed for the first time 4738 _ === Yr ? void 0 : u && _[0] === Yr ? [] : _, 4739 f 4740 ]), _ = E); 4741 } else 4742 y.run(); 4743 }; 4744 m.allowRecurse = !!t; 4745 let p; 4746 n === "sync" ? p = m : n === "post" ? p = () => _e(m, l && l.suspense) : (m.pre = !0, l && (m.id = l.uid), p = () => uh(m)); 4747 const y = new sh(h, p); 4748 t ? i ? m() : _ = y.run() : n === "post" ? _e( 4749 y.run.bind(y), 4750 l && l.suspense 4751 ) : y.run(); 4752 const v = () => { 4753 y.stop(), l && l.scope && Ql(l.scope.effects, y); 4754 }; 4755 return g && g.push(v), v; 4756} 4757function gx(e, t, i) { 4758 const s = this.proxy, n = Wt(e) ? e.includes(".") ? _f(s, e) : () => s[e] : e.bind(s, s); 4759 let r; 4760 ht(t) ? r = t : (r = t.handler, i = t); 4761 const o = se; 4762 pn(this); 4763 const a = gf(n, r.bind(s), i); 4764 return o ? pn(o) : ms(), a; 4765} 4766function _f(e, t) { 4767 const i = t.split("."); 4768 return () => { 4769 let s = e; 4770 for (let n = 0; n < i.length && s; n++) 4771 s = s[i[n]]; 4772 return s; 4773 }; 4774} 4775function qs(e, t) { 4776 if (!Ft(e) || e.__v_skip || (t = t || /* @__PURE__ */ new Set(), t.has(e))) 4777 return e; 4778 if (t.add(e), de(e)) 4779 qs(e.value, t); 4780 else if (it(e)) 4781 for (let i = 0; i < e.length; i++) 4782 qs(e[i], t); 4783 else if (jd(e) || nn(e)) 4784 e.forEach((i) => { 4785 qs(i, t); 4786 }); 4787 else if (Ud(e)) 4788 for (const i in e) 4789 qs(e[i], t); 4790 return e; 4791} 4792function ns(e, t, i, s) { 4793 const n = e.dirs, r = t && t.dirs; 4794 for (let o = 0; o < n.length; o++) { 4795 const a = n[o]; 4796 r && (a.oldValue = r[o].value); 4797 let l = a.dir[s]; 4798 l && (Sn(), We(l, i, 8, [ 4799 e.el, 4800 a, 4801 e, 4802 t 4803 ]), wn()); 4804 } 4805} 4806function _x(e, t) { 4807 return ht(e) ? ( 4808 // #8326: extend call and options.name access are considered side-effects 4809 // by Rollup, so we have to wrap it in a pure-annotated IIFE.
4810 /* @__PURE__ */ (() => jt({ name: e.name }, t, { setup: e }))() 4811 ) : e; 4812} 4813const Kn = (e) => !!e.type.__asyncLoader, mf = (e) => e.type.__isKeepAlive; 4814function mx(e, t) { 4815 pf(e, "a", t); 4816} 4817function px(e, t) { 4818 pf(e, "da", t); 4819} 4820function pf(e, t, i = se) { 4821 const s = e.__wdc || (e.__wdc = () => { 4822 let n = i; 4823 for (; n; ) { 4824 if (n.isDeactivated) 4825 return; 4826 n = n.parent; 4827 } 4828 return e(); 4829 }); 4830 if (ra(t, s, i), i) { 4831 let n = i.parent; 4832 for (; n && n.parent; ) 4833 mf(n.parent.vnode) && yx(s, t, i, n), n = n.parent; 4834 } 4835} 4836function yx(e, t, i, s) { 4837 const n = ra( 4838 t, 4839 e, 4840 s, 4841 !0 4842 /* prepend */ 4843 ); 4844 yf(() => { 4845 Ql(s[t], n); 4846 }, i); 4847} 4848function ra(e, t, i = se, s = !1) { 4849 if (i) { 4850 const n = i[e] || (i[e] = []), r = t.__weh || (t.__weh = (...o) => { 4851 if (i.isUnmounted) 4852 return; 4853 Sn(), pn(i); 4854 const a = We(t, i, e, o); 4855 return ms(), wn(), a; 4856 }); 4857 return s ? n.unshift(r) : n.push(r), r; 4858 } 4859} 4860const Ci = (e) => (t, i = se) => ( 4861 // post-create lifecycle registrations are noops during SSR (except for serverPrefetch) 4862 (!ar || e === "sp") && ra(e, (...s) => t(...s), i) 4863), xx = Ci("bm"), vx = Ci("m"), Ex = Ci("bu"), Mx = Ci("u"), Cx = Ci("bum"), yf = Ci("um"), bx = Ci("sp"), Sx = Ci( 4864 "rtg" 4865), wx = Ci( 4866 "rtc" 4867); 4868function Tx(e, t = se) { 4869 ra("ec", e, t); 4870} 4871const Rx = Symbol.for("v-ndc"); 4872function ml(e, t, i, s) { 4873 let n; 4874 const r = i && i[s]; 4875 if (it(e) || Wt(e)) { 4876 n = new Array(e.length); 4877 for (let o = 0, a = e.length; o < a; o++) 4878 n[o] = t(e[o], o, void 0, r && r[o]); 4879 } else if (typeof e == "number") { 4880 n = new Array(e); 4881 for (let o = 0; o < e; o++) 4882 n[o] = t(o + 1, o, void 0, r && r[o]); 4883 } else if (Ft(e)) 4884 if (e[Symbol.iterator]) 4885 n = Array.from( 4886 e, 4887 (o, a) => t(o, a, void 0, r && r[a]) 4888 ); 4889 else { 4890 const o = Object.keys(e); 4891 n = new Array(o.length); 4892 for (let a = 0, l = o.length; a < l; a++) { 4893 const h = o[a]; 4894 n[a] = t(e[h], h, a, r && r[a]); 4895 } 4896 } 4897 else 4898 n = []; 4899 return i && (i[s] = n), n; 4900} 4901function xf(e, t, i = {}, s, n) { 4902 if (pe.isCE || pe.parent && Kn(pe.parent) && pe.parent.isCE) 4903 return t !== "default" && (i.name = t), Be("slot", i, s && s()); 4904 let r = e[t]; 4905 r && r._c && (r._d = !1), Tt(); 4906 const o = r && vf(r(i)), a = Pf( 4907 me, 4908 { 4909 key: i.key || // slot content array of a dynamic conditional slot may have a branch 4910 // key attached in the `createSlots` helper, respect that 4911 o && o.key || `_${t}` 4912 }, 4913 o || (s ? s() : []), 4914 o && e._ === 1 ? 64 : -2 4915 ); 4916 return !n && a.scopeId && (a.slotScopeIds = [a.scopeId + "-s"]), r && r._c && (r._d = !0), a; 4917} 4918function vf(e) { 4919 return e.some((t) => Af(t) ? !(t.type === Ji || t.type === me && !vf(t.children)) : !0) ? e : null; 4920} 4921const pl = (e) => e ? Ff(e) ? mh(e) || e.proxy : pl(e.parent) : null, Vn = ( 4922 // Move PURE marker to new line to workaround compiler discarding it 4923 // due to type annotation 4924 /* @__PURE__ */ jt(/* @__PURE__ */ Object.create(null), { 4925 $: (e) => e, 4926 $el: (e) => e.vnode.el, 4927 $data: (e) => e.data, 4928 $props: (e) => e.props, 4929 $attrs: (e) => e.attrs, 4930 $slots: (e) => e.slots, 4931 $refs: (e) => e.refs, 4932 $parent: (e) => pl(e.parent), 4933 $root: (e) => pl(e.root), 4934 $emit: (e) => e.emit, 4935 $options: (e) => dh(e), 4936 $forceUpdate: (e) => e.f || (e.f = () => uh(e.update)), 4937 $nextTick: (e) => e.n || (e.n = lf.bind(e.proxy)), 4938 $watch: (e) => gx.bind(e) 4939 }) 4940), Ra = (e, t) => e !== At && !e.__isScriptSetup && _t(e, t), Ix = { 4941 get({ _: e }, t) { 4942 const { ctx: i, setupState: s, data: n, props: r, accessCache: o, type: a, appContext: l } = e; 4943 let h; 4944 if (t[0] !== "$") { 4945 const f = o[t]; 4946 if (f !== void 0) 4947 switch (f) { 4948 case 1: 4949 return s[t]; 4950 case 2: 4951 return n[t]; 4952 case 4: 4953 return i[t]; 4954 case 3: 4955 return r[t]; 4956 } 4957 else { 4958 if (Ra(s, t)) 4959 return o[t] = 1, s[t]; 4960 if (n !== At && _t(n, t)) 4961 return o[t] = 2, n[t]; 4962 if ( 4963 // only cache other properties when instance has declared (thus stable) 4964 // props 4965 (h = e.propsOptions[0]) && _t(h, t) 4966 ) 4967 return o[t] = 3, r[t]; 4968 if (i !== At && _t(i, t)) 4969 return o[t] = 4, i[t]; 4970 yl && (o[t] = 0); 4971 } 4972 } 4973 const c = Vn[t]; 4974 let u, d; 4975 if (c) 4976 return t === "$attrs" && Ee(e, "get", t), c(e); 4977 if ( 4978 // css module (injected by vue-loader) 4979 (u = a.__cssModules) && (u = u[t]) 4980 ) 4981 return u; 4982 if (i !== At && _t(i, t)) 4983 return o[t] = 4, i[t]; 4984 if ( 4985 // global properties 4986 d = l.config.globalProperties, _t(d, t) 4987 ) 4988 return d[t]; 4989 }, 4990 set({ _: e }, t, i) { 4991 const { data: s, setupState: n, ctx: r } = e; 4992 return Ra(n, t) ? (n[t] = i, !0) : s !== At && _t(s, t) ? (s[t] = i, !0) : _t(e.props, t) || t[0] === "$" && t.slice(1) in e ? !1 : (r[t] = i, !0); 4993 }, 4994 has({ 4995 _: { data: e, setupState: t, accessCache: i, ctx: s, appContext: n, propsOptions: r } 4996 }, o) { 4997 let a; 4998 return !!i[o] || e !== At && _t(e, o) || Ra(t, o) || (a = r[0]) && _t(a, o) || _t(s, o) || _t(Vn, o) || _t(n.config.globalProperties, o); 4999 }, 5000 defineProperty(e, t, i) { 5001 return i.get != null ? e._.accessCache[t] = 0 : _t(i, "value") && this.set(e, t, i.value, null), Reflect.defineProperty(e, t, i); 5002 } 5003}; 5004function Uc(e) { 5005 return it(e) ? e.reduce( 5006 (t, i) => (t[i] = null, t), 5007 {} 5008 ) : e; 5009} 5010let yl = !0; 5011function Px(e) { 5012 const t = dh(e), i = e.proxy, s = e.ctx; 5013 yl = !1, t.beforeCreate && Xc(t.beforeCreate, e, "bc"); 5014 const { 5015 // state 5016 data: n, 5017 computed: r, 5018 methods: o, 5019 watch: a, 5020 provide: l, 5021 inject: h, 5022 // lifecycle 5023 created: c, 5024 beforeMount: u, 5025 mounted: d, 5026 beforeUpdate: f, 5027 updated: g, 5028 activated: _, 5029 deactivated: m, 5030 beforeDestroy: p, 5031 beforeUnmount: y, 5032 destroyed: v, 5033 unmounted: E, 5034 render: C, 5035 renderTracked: S, 5036 renderTriggered: O, 5037 errorCaptured: R, 5038 serverPrefetch: j, 5039 // public API 5040 expose: $, 5041 inheritAttrs: q, 5042 // assets 5043 components: tt, 5044 directives: J, 5045 filters: St 5046 } = t; 5047 if (h && Ax(h, s, null), o) 5048 for (const L in o) { 5049 const W = o[L]; 5050 ht(W) && (s[L] = W.bind(i)); 5051 } 5052 if (n) { 5053 const L = n.call(i, i); 5054 Ft(L) && (e.data = ia(L)); 5055 } 5056 if (yl = !0, r) 5057 for (const L in r) { 5058 const W = r[L], ut = ht(W) ? W.bind(i, i) : ht(W.get) ? W.get.bind(i, i) : je, ft = !ht(W) && ht(W.
vendor: 5,586 bytes, lines 5058-5290
5058set) ? W.set.bind(i) : je, wt = rv({ 5059 get: ut, 5060 set: ft 5061 }); 5062 Object.defineProperty(s, L, { 5063 enumerable: !0, 5064 configurable: !0, 5065 get: () => wt.value, 5066 set: (I) => wt.value = I 5067 }); 5068 } 5069 if (a) 5070 for (const L in a) 5071 Ef(a[L], s, i, L); 5072 if (l) { 5073 const L = ht(l) ? l.call(i) : l; 5074 Reflect.ownKeys(L).forEach((W) => { 5075 kx(W, L[W]); 5076 }); 5077 } 5078 c && Xc(c, e, "c"); 5079 function Y(L, W) { 5080 it(W) ? W.forEach((ut) => L(ut.bind(i))) : W && L(W.bind(i)); 5081 } 5082 if (Y(xx, u), Y(vx, d), Y(Ex, f), Y(Mx, g), Y(mx, _), Y(px, m), Y(Tx, R), Y(wx, S), Y(Sx, O), Y(Cx, y), Y(yf, E), Y(bx, j), it($)) 5083 if ($.length) { 5084 const L = e.exposed || (e.exposed = {}); 5085 $.forEach((W) => { 5086 Object.defineProperty(L, W, { 5087 get: () => i[W], 5088 set: (ut) => i[W] = ut 5089 }); 5090 }); 5091 } else 5092 e.exposed || (e.exposed = {}); 5093 C && e.render === je && (e.render = C), q != null && (e.inheritAttrs = q), tt && (e.components = tt), J && (e.directives = J); 5094} 5095function Ax(e, t, i = je) { 5096 it(e) && (e = xl(e)); 5097 for (const s in e) { 5098 const n = e[s]; 5099 let r; 5100 Ft(n) ? "default" in n ? r = _o( 5101 n.from || s, 5102 n.default, 5103 !0 5104 /* treat default function as factory */ 5105 ) : r = _o(n.from || s) : r = _o(n), de(r) ? Object.defineProperty(t, s, { 5106 enumerable: !0, 5107 configurable: !0, 5108 get: () => r.value, 5109 set: (o) => r.value = o 5110 }) : t[s] = r; 5111 } 5112} 5113function Xc(e, t, i) { 5114 We( 5115 it(e) ? e.map((s) => s.bind(t.proxy)) : e.bind(t.proxy), 5116 t, 5117 i 5118 ); 5119} 5120function Ef(e, t, i, s) { 5121 const n = s.includes(".") ? _f(i, s) : () => i[s]; 5122 if (Wt(e)) { 5123 const r = t[e]; 5124 ht(r) && Ta(n, r); 5125 } else if (ht(e)) 5126 Ta(n, e.bind(i)); 5127 else if (Ft(e)) 5128 if (it(e)) 5129 e.forEach((r) => Ef(r, t, i, s)); 5130 else { 5131 const r = ht(e.handler) ? e.handler.bind(i) : t[e.handler]; 5132 ht(r) && Ta(n, r, e); 5133 } 5134} 5135function dh(e) { 5136 const t = e.type, { mixins: i, extends: s } = t, { 5137 mixins: n, 5138 optionsCache: r, 5139 config: { optionMergeStrategies: o } 5140 } = e.appContext, a = r.get(t); 5141 let l; 5142 return a ? l = a : !n.length && !i && !s ? l = t : (l = {}, n.length && n.forEach( 5143 (h) => To(l, h, o, !0) 5144 ), To(l, t, o)), Ft(t) && r.set(t, l), l; 5145} 5146function To(e, t, i, s = !1) { 5147 const { mixins: n, extends: r } = t; 5148 r && To(e, r, i, !0), n && n.forEach( 5149 (o) => To(e, o, i, !0) 5150 ); 5151 for (const o in t) 5152 if (!(s && o === "expose")) { 5153 const a = Lx[o] || i && i[o]; 5154 e[o] = a ? a(e[o], t[o]) : t[o]; 5155 } 5156 return e; 5157} 5158const Lx = { 5159 data: $c, 5160 props: Yc, 5161 emits: Yc, 5162 // objects 5163 methods: Bn, 5164 computed: Bn, 5165 // lifecycle 5166 beforeCreate: ae, 5167 created: ae, 5168 beforeMount: ae, 5169 mounted: ae, 5170 beforeUpdate: ae, 5171 updated: ae, 5172 beforeDestroy: ae, 5173 beforeUnmount: ae, 5174 destroyed: ae, 5175 unmounted: ae, 5176 activated: ae, 5177 deactivated: ae, 5178 errorCaptured: ae, 5179 serverPrefetch: ae, 5180 // assets 5181 components: Bn, 5182 directives: Bn, 5183 // watch 5184 watch: Fx, 5185 // provide / inject 5186 provide: $c, 5187 inject: Ox 5188}; 5189function $c(e, t) { 5190 return t ? e ? function() { 5191 return jt( 5192 ht(e) ? e.call(this, this) : e, 5193 ht(t) ? t.call(this, this) : t 5194 ); 5195 } : t : e; 5196} 5197function Ox(e, t) { 5198 return Bn(xl(e), xl(t)); 5199} 5200function xl(e) { 5201 if (it(e)) { 5202 const t = {}; 5203 for (let i = 0; i < e.length; i++) 5204 t[e[i]] = e[i]; 5205 return t; 5206 } 5207 return e; 5208} 5209function ae(e, t) { 5210 return e ? [...new Set([].concat(e, t))] : t; 5211} 5212function Bn(e, t) { 5213 return e ? jt(/* @__PURE__ */ Object.create(null), e, t) : t; 5214} 5215function Yc(e, t) { 5216 return e ? it(e) && it(t) ? [.../* @__PURE__ */ new Set([...e, ...t])] : jt( 5217 /* @__PURE__ */ Object.create(null), 5218 Uc(e), 5219 Uc(t ?? {}) 5220 ) : t; 5221} 5222function Fx(e, t) { 5223 if (!e) 5224 return t; 5225 if (!t) 5226 return e; 5227 const i = jt(/* @__PURE__ */ Object.create(null), e); 5228 for (const s in t) 5229 i[s] = ae(e[s], t[s]); 5230 return i; 5231} 5232function Mf() { 5233 return { 5234 app: null, 5235 config: { 5236 isNativeTag: a1, 5237 performance: !1, 5238 globalProperties: {}, 5239 optionMergeStrategies: {}, 5240 errorHandler: void 0, 5241 warnHandler: void 0, 5242 compilerOptions: {} 5243 }, 5244 mixins: [], 5245 components: {}, 5246 directives: {}, 5247 provides: /* @__PURE__ */ Object.create(null), 5248 optionsCache: /* @__PURE__ */ new WeakMap(), 5249 propsCache: /* @__PURE__ */ new WeakMap(), 5250 emitsCache: /* @__PURE__ */ new WeakMap() 5251 }; 5252} 5253let Dx = 0; 5254function Nx(e, t) { 5255 return function(s, n = null) { 5256 ht(s) || (s = jt({}, s)), n != null && !Ft(n) && (n = null); 5257 const r = Mf(), o = /* @__PURE__ */ new Set(); 5258 let a = !1; 5259 const l = r.app = { 5260 _uid: Dx++, 5261 _component: s, 5262 _props: n, 5263 _container: null, 5264 _context: r, 5265 _instance: null, 5266 version: lv, 5267 get config() { 5268 return r.config; 5269 }, 5270 set config(h) { 5271 }, 5272 use(h, ...c) { 5273 return o.has(h) || (h && ht(h.install) ? (o.add(h), h.install(l, ...c)) : ht(h) && (o.add(h), h(l, ...c))), l; 5274 }, 5275 mixin(h) { 5276 return r.mixins.includes(h) || r.mixins.push(h), l; 5277 }, 5278 component(h, c) { 5279 return c ? (r.components[h] = c, l) : r.components[h]; 5280 }, 5281 directive(h, c) { 5282 return c ? (r.directives[h] = c, l) : r.directives[h]; 5283 }, 5284 mount(h, c, u) { 5285 if (!a) { 5286 const d = Be( 5287 s, 5288 n 5289 ); 5290 return d.appContext = r, c && t ? t(d, h) : e(d, h, u), a = !0, l._container = h, h.__vue_app__ = l, mh(d.c
5290omponent) || d.component.proxy; 5291 } 5292 }, 5293 unmount() { 5294 a && (e(null, l._container), delete l._container.__vue_app__); 5295 }, 5296 provide(h, c) { 5297 return r.provides[h] = c, l; 5298 }, 5299 runWithContext(h) { 5300 Ro = l; 5301 try { 5302 return h(); 5303 } finally { 5304 Ro = null; 5305 } 5306 } 5307 }; 5308 return l; 5309 }; 5310} 5311let Ro = null; 5312function kx(e, t) { 5313 if (se) { 5314 let i = se.provides; 5315 const s = se.parent && se.parent.provides; 5316 s === i && (i = se.provides = Object.create(s)), i[e] = t; 5317 } 5318} 5319function _o(e, t, i = !1) { 5320 const s = se || pe; 5321 if (s || Ro) { 5322 const n = s ? s.parent == null ? s.vnode.appContext && s.vnode.appContext.provides : s.parent.provides : Ro._context.provides; 5323 if (n && e in n) 5324 return n[e]; 5325 if (arguments.length > 1) 5326 return i && ht(t) ? t.call(s && s.proxy) : t; 5327 } 5328} 5329function Gx(e, t, i, s = !1) { 5330 const n = {}, r = {}; 5331 So(r, aa, 1), e.propsDefaults = /* @__PURE__ */ Object.create(null), Cf(e, t, n, r); 5332 for (const o in e.propsOptions[0]) 5333 o in n || (n[o] = void 0); 5334 i ? e.props = s ? n : q1(n) : e.type.props ? e.props = n : e.props = r, e.attrs = r; 5335} 5336function zx(e, t, i, s) { 5337 const { 5338 props: n, 5339 attrs: r, 5340 vnode: { patchFlag: o } 5341 } = e, a = Ct(n), [l] = e.propsOptions; 5342 let h = !1; 5343 if ( 5344 // always force full diff in dev 5345 // - #1942 if hmr is enabled with sfc component 5346 // - vite#872 non-sfc component used by sfc component 5347 (s || o > 0) && !(o & 16) 5348 ) { 5349 if (o & 8) { 5350 const c = e.vnode.dynamicProps; 5351 for (let u = 0; u < c.length; u++) { 5352 let d = c[u]; 5353 if (na(e.emitsOptions, d)) 5354 continue; 5355 const f = t[d]; 5356 if (l) 5357 if (_t(r, d)) 5358 f !== r[d] && (r[d] = f, h = !0); 5359 else { 5360 const g = _i(d); 5361 n[g] = vl( 5362 l, 5363 a, 5364 g, 5365 f, 5366 e, 5367 !1 5368 /* isAbsent */ 5369 ); 5370 } 5371 else 5372 f !== r[d] && (r[d] = f, h = !0); 5373 } 5374 } 5375 } else { 5376 Cf(e, t, n, r) && (h = !0); 5377 let c; 5378 for (const u in a) 5379 (!t || // for camelCase 5380 !_t(t, u) && // it's possible the original props was passed in as kebab-case 5381 // and converted to camelCase (#955) 5382 ((c = Ne(u)) === u || !_t(t, c))) && (l ? i && // for camelCase 5383 (i[u] !== void 0 || // for kebab-case 5384 i[c] !== void 0) && (n[u] = vl( 5385 l, 5386 a, 5387 u, 5388 void 0, 5389 e, 5390 !0 5391 /* isAbsent */ 5392 )) : delete n[u]); 5393 if (r !== a) 5394 for (const u in r) 5395 (!t || !_t(t, u)) && (delete r[u], h = !0); 5396 } 5397 h && vi(e, "set", "$attrs"); 5398} 5399function Cf(e, t, i, s) { 5400 const [n, r] = e.propsOptions; 5401 let o = !1, a; 5402 if (t) 5403 for (let l in t) { 5404 if (go(l)) 5405 continue; 5406 const h = t[l]; 5407 let c; 5408 n && _t(n, c = _i(l)) ? !r || !r.includes(c) ? i[c] = h : (a || (a = {}))[c] = h : na(e.emitsOptions, l) || (!(l in s) || h !== s[l]) && (s[l] = h, o = !0); 5409 } 5410 if (r) { 5411 const l = Ct(i), h = a || At; 5412 for (let c = 0; c < r.length; c++) { 5413 const u = r[c]; 5414 i[u] = vl( 5415 n, 5416 l, 5417 u, 5418 h[u], 5419 e, 5420 !_t(h, u) 5421 ); 5422 } 5423 } 5424 return o; 5425} 5426function vl(e, t, i, s, n, r) { 5427 const o = e[i]; 5428 if (o != null) { 5429 const a = _t(o, "default"); 5430 if (a && s === void 0) { 5431 const l = o.default; 5432 if (o.type !== Function && !o.skipFactory && ht(l)) { 5433 const { propsDefaults: h } = n; 5434 i in h ? s = h[i] : (pn(n), s = h[i] = l.call( 5435 null, 5436 t 5437 ), ms()); 5438 } else 5439 s = l; 5440 } 5441 o[ 5442 0 5443 /* shouldCast */ 5444 ] && (r && !a ? s = !1 : o[ 5445 1 5446 /* shouldCastTrue */ 5447 ] && (s === "" || s === Ne(i)) && (s = !0)); 5448 } 5449 return s; 5450} 5451function bf(e, t, i = !1) { 5452 const s = t.propsCache, n = s.get(e); 5453 if (n) 5454 return n; 5455 const r = e.props, o = {}, a = []; 5456 let l = !1; 5457 if (!ht(e)) { 5458 const c = (u) => { 5459 l = !0; 5460 const [d, f] = bf(u, t, !0); 5461 jt(o, d), f && a.push(...f); 5462 }; 5463 !i && t.mixins.length && t.mixins.forEach(c), e.extends && c(e.extends), e.mixins && e.mixins.forEach(c); 5464 } 5465 if (!r && !l) 5466 return Ft(e) && s.set(e, sn), sn; 5467 if (it(r)) 5468 for (let c = 0; c < r.length; c++) { 5469 const u = _i(r[c]); 5470 Kc(u) && (o[u] = At); 5471 } 5472 else if (r) 5473 for (const c in r) { 5474 const u = _i(c); 5475 if (Kc(u)) { 5476 const d = r[c], f = o[u] = it(d) || ht(d) ? { type: d } : jt({}, d); 5477 if (f) { 5478 const g = Hc(Boolean, f.type), _ = Hc(String, f.type); 5479 f[ 5480 0 5481 /* shouldCast */ 5482 ] = g > -1, f[ 5483 1 5484 /* shouldCastTrue */ 5485 ] = _ < 0 || g < _, (g > -1 || _t(f, "default")) && a.push(u); 5486 } 5487 } 5488 } 5489 const h = [o, a]; 5490 return Ft(e) && s.set(e, h), h; 5491} 5492function Kc(e) { 5493 return e[0] !== "$"; 5494} 5495function Vc(e) { 5496 const t = e && e.toString().match(/^\s*(function|class) (\w+)/); 5497 return t ? t[2] : e === null ? "null" : ""; 5498} 5499function qc(e, t) { 5500 return Vc(e) === Vc(t); 5501} 5502function Hc(e, t) { 5503 return it(t) ? t.findIndex((i) => qc(i, e)) : ht(t) && qc(t, e) ? 0 : -1; 5504} 5505const Sf = (e) => e[0] === "_" || e === "$stable", fh = (e) => it(e) ? e.map(Ye) : [Ye(e)], jx = (e, t, i) => { 5506 if (t._n) 5507 return t;
5508 const s = ax((...n) => fh(t(...n)), i); 5509 return s._c = !1, s; 5510}, wf = (e, t, i) => { 5511 const s = e._ctx; 5512 for (const n in e) { 5513 if (Sf(n)) 5514 continue; 5515 const r = e[n]; 5516 if (ht(r)) 5517 t[n] = jx(n, r, s); 5518 else if (r != null) { 5519 const o = fh(r); 5520 t[n] = () => o; 5521 } 5522 } 5523}, Tf = (e, t) => { 5524 const i = fh(t); 5525 e.slots.default = () => i; 5526}, Wx = (e, t) => { 5527 if (e.vnode.shapeFlag & 32) { 5528 const i = t._; 5529 i ? (e.slots = Ct(t), So(t, "_", i)) : wf( 5530 t, 5531 e.slots = {} 5532 ); 5533 } else 5534 e.slots = {}, t && Tf(e, t); 5535 So(e.slots, aa, 1); 5536}, Bx = (e, t, i) => { 5537 const { vnode: s, slots: n } = e; 5538 let r = !0, o = At; 5539 if (s.shapeFlag & 32) { 5540 const a = t._; 5541 a ? i && a === 1 ? r = !1 : (jt(n, t), !i && a === 1 && delete n._) : (r = !t.$stable, wf(t, n)), o = t; 5542 } else 5543 t && (Tf(e, t), o = { default: 1 }); 5544 if (r) 5545 for (const a in n) 5546 !Sf(a) && !(a in o) && delete n[a]; 5547}; 5548function El(e, t, i, s, n = !1) { 5549 if (it(e)) { 5550 e.forEach( 5551 (d, f) => El( 5552 d, 5553 t && (it(t) ? t[f] : t), 5554 i, 5555 s, 5556 n 5557 ) 5558 ); 5559 return; 5560 } 5561 if (Kn(s) && !n) 5562 return; 5563 const r = s.shapeFlag & 4 ? mh(s.component) || s.component.proxy : s.el, o = n ? null : r, { i: a, r: l } = e, h = t && t.r, c = a.refs === At ? a.refs = {} : a.refs, u = a.setupState; 5564 if (h != null && h !== l && (Wt(h) ? (c[h] = null, _t(u, h) && (u[h] = null)) : de(h) && (h.value = null)), ht(l)) 5565 Ki(l, a, 12, [o, c]); 5566 else { 5567 const d = Wt(l), f = de(l); 5568 if (d || f) { 5569 const g = () => { 5570 if (e.f) { 5571 const _ = d ? _t(u, l) ? u[l] : c[l] : l.value; 5572 n ? it(_) && Ql(_, r) : it(_) ? _.includes(r) || _.push(r) : d ? (c[l] = [r], _t(u, l) && (u[l] = c[l])) : (l.value = [r], e.k && (c[e.k] = l.value)); 5573 } else 5574 d ? (c[l] = o, _t(u, l) && (u[l] = o)) : f && (l.value = o, e.k && (c[e.k] = o)); 5575 }; 5576 o ? (g.id = -1, _e(g, i)) : g(); 5577 } 5578 } 5579} 5580const _e = fx; 5581function Ux(e) { 5582 return Xx(e); 5583} 5584function Xx(e, t) { 5585 const i = hl(); 5586 i.__VUE__ = !0; 5587 const { 5588 insert: s, 5589 remove: n, 5590 patchProp: r, 5591 createElement: o, 5592 createText: a, 5593 createComment: l, 5594 setText: h, 5595 setElementText: c, 5596 parentNode: u, 5597 nextSibling: d, 5598 setScopeId: f = je, 5599 insertStaticContent: g 5600 } = e, _ = (x, M, b, T = null, w = null, D = null, k = !1, F = null, N = !!M.dynamicChildren) => { 5601 if (x === M) 5602 return; 5603 x && !Fn(x, M) && (T = oe(x), I(x, w, D, !0), x = null), M.patchFlag === -2 && (N = !1, M.dynamicChildren = null); 5604 const { type: P, ref: B, shapeFlag: z } = M; 5605 switch (P) { 5606 case oa: 5607 m(x, M, b, T); 5608 break; 5609 case Ji: 5610 p(x, M, b, T); 5611 break; 5612 case Ia: 5613 x == null && y(M, b, T, k); 5614 break; 5615 case me: 5616 tt( 5617 x, 5618 M, 5619 b, 5620 T, 5621 w, 5622 D, 5623 k, 5624 F, 5625 N 5626 ); 5627 break; 5628 default: 5629 z & 1 ? C( 5630 x, 5631 M, 5632 b, 5633 T, 5634 w, 5635 D, 5636 k, 5637 F, 5638 N 5639 ) : z & 6 ? J( 5640 x, 5641 M, 5642 b, 5643 T, 5644 w, 5645 D, 5646 k, 5647 F, 5648 N 5649 ) : (z & 64 || z & 128) && P.process( 5650 x, 5651 M, 5652 b, 5653 T, 5654 w, 5655 D, 5656 k, 5657 F, 5658 N, 5659 Ht 5660 ); 5661 } 5662 B != null && w && El(B, x && x.ref, D, M || x, !M); 5663 }, m = (x, M, b, T) => { 5664 if (x == null) 5665 s( 5666 M.el = a(M.children), 5667 b, 5668 T 5669 ); 5670 else { 5671 const w = M.el = x.el; 5672 M.children !== x.children && h(w, M.children); 5673 } 5674 }, p = (x, M, b, T) => { 5675 x == null ? s( 5676 M.el = l(M.children || ""), 5677 b, 5678 T 5679 ) : M.el = x.el; 5680 }, y = (x, M, b, T) => { 5681 [x.el, x.anchor] = g( 5682 x.children, 5683 M, 5684 b, 5685 T, 5686 x.el, 5687 x.anchor 5688 ); 5689 }, v = ({ el: x, anchor: M }, b, T) => { 5690 let w; 5691 for (; x && x !== M; ) 5692 w = d(x), s(x, b, T), x = w; 5693 s(M, b, T); 5694 }, E = ({ el: x, anchor: M }) => { 5695 let b; 5696 for (; x && x !== M; ) 5697 b = d(x), n(x), x = b; 5698 n(M); 5699 }, C = (x, M, b, T, w, D, k, F, N) => { 5700 k = k || M.type === "svg", x == null ? S( 5701 M, 5702 b, 5703 T, 5704 w, 5705 D, 5706 k, 5707 F, 5708 N 5709 ) : j( 5710 x, 5711 M, 5712 w, 5713 D, 5714 k, 5715 F, 5716 N 5717 ); 5718 }, S = (x, M, b, T, w, D, k, F) => { 5719 let N, P; 5720 const { type: B, props: z, shapeFlag: X, transition: V, dirs: nt } = x; 5721 if (N = x.el = o( 5722 x.type, 5723 D, 5724 z && z.is, 5725 z 5726 ), X & 8 ? c(N, x.children) : X & 16 && R( 5727 x.children, 5728 N, 5729 null, 5730 T, 5731 w, 5732 D && B !== "foreignObject", 5733 k, 5734 F 5735 ), nt && ns(x, null, T, "created"), O(N, x, x.scopeId, k, T), z) { 5736 for (const ct in z) 5737 ct !== "value" && !go(ct) && r( 5738 N, 5739 ct, 5740 null, 5741 z[ct], 5742 D, 5743 x.children, 5744 T, 5745 w, 5746 Bt 5747 ); 5748 "value" in z && r(N, "value", null, z.value), (P = z.onVnodeBeforeMount) && $e(P, T, x); 5749 } 5750 nt && ns(x, null, T, "beforeMount"); 5751 const gt = (!w || w && !w.pendingBranch) && V && !V.persisted; 5752 gt && V.beforeEnter(N), s(N, M, b), ((P = z && z.onVnodeMounted) || gt || nt) && _e(() => { 5753 P && $e(P, T, x), gt && V.enter(N), nt && ns(x, null, T, "mounted"); 5754 }, w); 5755 }, O = (x, M, b, T, w) => { 5756 if (b && f(x, b), T) 5757 for (let D = 0; D < T.length; D++) 5758 f(x, T[D]); 5759 if (w) { 5760 let D = w.subTree; 5761 if (M === D) {
5762 const k = w.vnode; 5763 O( 5764 x, 5765 k, 5766 k.scopeId, 5767 k.slotScopeIds, 5768 w.parent 5769 ); 5770 } 5771 } 5772 }, R = (x, M, b, T, w, D, k, F, N = 0) => { 5773 for (let P = N; P < x.length; P++) { 5774 const B = x[P] = F ? Oi(x[P]) : Ye(x[P]); 5775 _( 5776 null, 5777 B, 5778 M, 5779 b, 5780 T, 5781 w, 5782 D, 5783 k, 5784 F 5785 ); 5786 } 5787 }, j = (x, M, b, T, w, D, k) => { 5788 const F = M.el = x.el; 5789 let { patchFlag: N, dynamicChildren: P, dirs: B } = M; 5790 N |= x.patchFlag & 16; 5791 const z = x.props || At, X = M.props || At; 5792 let V; 5793 b && rs(b, !1), (V = X.onVnodeBeforeUpdate) && $e(V, b, M, x), B && ns(M, x, b, "beforeUpdate"), b && rs(b, !0); 5794 const nt = w && M.type !== "foreignObject"; 5795 if (P ? $( 5796 x.dynamicChildren, 5797 P, 5798 F, 5799 b, 5800 T, 5801 nt, 5802 D 5803 ) : k || W( 5804 x, 5805 M, 5806 F, 5807 null, 5808 b, 5809 T, 5810 nt, 5811 D, 5812 !1 5813 ), N > 0) { 5814 if (N & 16) 5815 q( 5816 F, 5817 M, 5818 z, 5819 X, 5820 b, 5821 T, 5822 w 5823 ); 5824 else if (N & 2 && z.class !== X.class && r(F, "class", null, X.class, w), N & 4 && r(F, "style", z.style, X.style, w), N & 8) { 5825 const gt = M.dynamicProps; 5826 for (let ct = 0; ct < gt.length; ct++) { 5827 const bt = gt[ct], Zt = z[bt], Dt = X[bt]; 5828 (Dt !== Zt || bt === "value") && r( 5829 F, 5830 bt, 5831 Zt, 5832 Dt, 5833 w, 5834 x.children, 5835 b, 5836 T, 5837 Bt 5838 ); 5839 } 5840 } 5841 N & 1 && x.children !== M.children && c(F, M.children); 5842 } else 5843 !k && P == null && q( 5844 F, 5845 M, 5846 z, 5847 X, 5848 b, 5849 T, 5850 w 5851 ); 5852 ((V = X.onVnodeUpdated) || B) && _e(() => { 5853 V && $e(V, b, M, x), B && ns(M, x, b, "updated"); 5854 }, T); 5855 }, $ = (x, M, b, T, w, D, k) => { 5856 for (let F = 0; F < M.length; F++) { 5857 const N = x[F], P = M[F], B = ( 5858 // oldVNode may be an errored async setup() component inside Suspense 5859 // which will not have a mounted element 5860 N.el && // - In the case of a Fragment, we need to provide the actual parent 5861 // of the Fragment itself so it can move its children. 5862 (N.type === me || // - In the case of different nodes, there is going to be a replacement 5863 // which also requires the correct parent container 5864 !Fn(N, P) || // - In the case of a component, it could contain anything. 5865 N.shapeFlag & 70) ? u(N.el) : ( 5866 // In other cases, the parent container is not actually used so we 5867 // just pass the block element here to avoid a DOM parentNode call. 5868 b 5869 ) 5870 ); 5871 _( 5872 N, 5873 P, 5874 B, 5875 null, 5876 T, 5877 w, 5878 D, 5879 k, 5880 !0 5881 ); 5882 } 5883 }, q = (x, M, b, T, w, D, k) => { 5884 if (b !== T) { 5885 if (b !== At) 5886 for (const F in b) 5887 !go(F) && !(F in T) && r( 5888 x, 5889 F, 5890 b[F], 5891 null, 5892 k, 5893 M.children, 5894 w, 5895 D, 5896 Bt 5897 ); 5898 for (const F in T) { 5899 if (go(F)) 5900 continue; 5901 const N = T[F], P = b[F]; 5902 N !== P && F !== "value" && r( 5903 x, 5904 F, 5905 P, 5906 N, 5907 k, 5908 M.children, 5909 w, 5910 D, 5911 Bt 5912 ); 5913 } 5914 "value" in T && r(x, "value", b.value, T.value); 5915 } 5916 }, tt = (x, M, b, T, w, D, k, F, N) => { 5917 const P = M.el = x ? x.el : a(""), B = M.anchor = x ? x.anchor : a(""); 5918 let { patchFlag: z, dynamicChildren: X, slotScopeIds: V } = M; 5919 V && (F = F ? F.concat(V) : V), x == null ? (s(P, b, T), s(B, b, T), R( 5920 M.children, 5921 b, 5922 B, 5923 w, 5924 D, 5925 k, 5926 F, 5927 N 5928 )) : z > 0 && z & 64 && X && // #2715 the previous fragment could've been a BAILed one as a result 5929 // of renderSlot() with no valid children 5930 x.dynamicChildren ? ($( 5931 x.dynamicChildren, 5932 X, 5933 b, 5934 w, 5935 D, 5936 k, 5937 F 5938 ), // #2080 if the stable fragment has a key, it's a <template v-for> that may 5939 // get moved around. Make sure all root level vnodes inherit el.
5940 // #2134 or if it's a component root, it may also get moved around 5941 // as the component is being moved. 5942 (M.key != null || w && M === w.subTree) && Rf( 5943 x, 5944 M, 5945 !0 5946 /* shallow */ 5947 )) : W( 5948 x, 5949 M, 5950 b, 5951 B, 5952 w, 5953 D, 5954 k, 5955 F, 5956 N 5957 ); 5958 }, J = (x, M, b, T, w, D, k, F, N) => { 5959 M.slotScopeIds = F, x == null ? M.shapeFlag & 512 ? w.ctx.activate( 5960 M, 5961 b, 5962 T, 5963 k, 5964 N 5965 ) : St( 5966 M, 5967 b, 5968 T, 5969 w, 5970 D, 5971 k, 5972 N 5973 ) : K(x, M, N); 5974 }, St = (x, M, b, T, w, D, k) => { 5975 const F = x.component = Qx( 5976 x, 5977 T, 5978 w 5979 ); 5980 if (mf(x) && (F.ctx.renderer = Ht), tv(F), F.asyncDep) { 5981 if (w && w.registerDep(F, Y), !x.el) { 5982 const N = F.subTree = Be(Ji); 5983 p(null, N, M, b); 5984 } 5985 return; 5986 } 5987 Y( 5988 F, 5989 x, 5990 M, 5991 b, 5992 w, 5993 D, 5994 k 5995 ); 5996 }, K = (x, M, b) => { 5997 const T = M.component = x.component; 5998 if (cx(x, M, b)) 5999 if (T.asyncDep && !T.asyncResolved) { 6000 L(T, M, b); 6001 return; 6002 } else 6003 T.next = M, sx(T.update), T.update(); 6004 else 6005 M.el = x.el, T.vnode = M; 6006 }, Y = (x, M, b, T, w, D, k) => { 6007 const F = () => { 6008 if (x.isMounted) { 6009 let { next: B, bu: z, u: X, parent: V, vnode: nt } = x, gt = B, ct; 6010 rs(x, !1), B ? (B.el = nt.el, L(x, B, k)) : B = nt, z && Sa(z), (ct = B.props && B.props.onVnodeBeforeUpdate) && $e(ct, V, B, nt), rs(x, !0); 6011 const bt = wa(x), Zt = x.subTree; 6012 x.subTree = bt, _( 6013 Zt, 6014 bt, 6015 // parent may have changed if it's in a teleport 6016 u(Zt.el), 6017 // anchor may have changed if it's in a fragment 6018 oe(Zt), 6019 x, 6020 w, 6021 D 6022 ), B.el = bt.el, gt === null && ux(x, bt.el), X && _e(X, w), (ct = B.props && B.props.onVnodeUpdated) && _e( 6023 () => $e(ct, V, B, nt), 6024 w 6025 ); 6026 } else { 6027 let B; 6028 const { el: z, props: X } = M, { bm: V, m: nt, parent: gt } = x, ct = Kn(M); 6029 if (rs(x, !1), V && Sa(V), !ct && (B = X && X.onVnodeBeforeMount) && $e(B, gt, M), rs(x, !0), z && Si) { 6030 const bt = () => { 6031 x.subTree = wa(x), Si( 6032 z, 6033 x.subTree, 6034 x, 6035 w, 6036 null 6037 ); 6038 }; 6039 ct ? M.type.__asyncLoader().then( 6040 // note: we are moving the render call into an async callback, 6041 // which means it won't track dependencies - but it's ok because 6042 // a server-rendered async wrapper is already in resolved state 6043 // and it will never need to change. 6044 () => !x.isUnmounted && bt() 6045 ) : bt(); 6046 } else { 6047 const bt = x.subTree = wa(x); 6048 _( 6049 null, 6050 bt, 6051 b, 6052 T, 6053 x, 6054 w, 6055 D 6056 ), M.el = bt.el; 6057 } 6058 if (nt && _e(nt, w), !ct && (B = X && X.onVnodeMounted)) { 6059 const bt = M; 6060 _e( 6061 () => $e(B, gt, bt), 6062 w 6063 ); 6064 } 6065 (M.shapeFlag & 256 || gt && Kn(gt.vnode) && gt.vnode.shapeFlag & 256) && x.a && _e(x.a, w), x.isMounted = !0, M = b = T = null; 6066 } 6067 }, N = x.effect = new sh( 6068 F, 6069 () => uh(P), 6070 x.scope 6071 // track it in component's effect scope 6072 ), P = x.update = () => N.run(); 6073 P.id = x.uid, rs(x, !0), P(); 6074 }, L = (x, M, b) => { 6075 M.component = x; 6076 const T = x.vnode.props; 6077 x.vnode = M, x.next = null, zx(x, M.props, T, b), Bx(x, M.children, b), Sn(), Wc(), wn(); 6078 }, W = (x, M, b, T, w, D, k, F, N = !1) => { 6079 const P = x && x.children, B = x ? x.shapeFlag : 0, z = M.children, { patchFlag: X, shapeFlag: V } = M; 6080 if (X > 0) { 6081 if (X & 128) { 6082 ft( 6083 P, 6084 z, 6085 b, 6086 T, 6087 w, 6088 D, 6089 k, 6090 F, 6091 N 6092 ); 6093 return; 6094 } else if (X & 256) { 6095 ut( 6096 P, 6097 z, 6098 b, 6099 T, 6100 w, 6101 D, 6102 k, 6103 F, 6104 N 6105 ); 6106 return; 6107 } 6108 } 6109 V & 8 ? (B & 16 && Bt(P, w, D), z !== P && c(b, z)) : B & 16 ? V & 16 ? ft( 6110 P, 6111 z, 6112 b, 6113 T, 6114 w, 6115 D, 6116 k, 6117 F, 6118 N 6119 ) : Bt(P, w, D, !0) : (B & 8 && c(b, ""), V & 16 && R( 6120 z, 6121 b, 6122 T, 6123 w, 6124 D, 6125 k, 6126 F, 6127 N 6128 )); 6129 }, ut = (x, M, b, T, w, D, k, F, N) => { 6130 x = x || sn, M = M || sn; 6131 const P = x.length, B = M.length, z = Math.min(P, B); 6132 let X; 6133 for (X = 0; X < z; X++) { 6134 const V = M[X] = N ? Oi(M[X]) : Ye(M[X]); 6135 _( 6136 x[X], 6137 V, 6138 b, 6139 null, 6140 w, 6141 D, 6142 k, 6143 F, 6144 N 6145 ); 6146 } 6147 P > B ? Bt( 6148 x, 6149 w, 6150 D, 6151 !0, 6152 !1, 6153 z 6154 ) : R( 6155 M, 6156 b, 6157 T, 6158 w, 6159 D, 6160 k, 6161 F, 6162 N, 6163 z 6164 ); 6165 }, ft = (x, M, b, T, w, D, k, F, N) => { 6166 let P = 0; 6167 const B = M.length; 6168 let z = x.length - 1, X = B - 1; 6169 for (; P <= z && P <= X; ) { 6170 const V = x[P], nt = M[P] = N ? Oi(M[P]) : Ye(M[P]); 6171 if (Fn(V, nt)) 6172 _( 6173 V, 6174 nt, 6175 b, 6176 null, 6177 w, 6178 D, 6179 k, 6180 F, 6181 N 6182 ); 6183 else 6184 break; 6185 P++; 6186 } 6187 for (; P <= z && P <= X; ) { 6188 const V = x[z], nt = M[X] = N ? Oi(M[X]) : Ye(M[X]); 6189 if (Fn(V, nt)) 6190 _( 6191 V, 6192 nt, 6193 b, 6194 null, 6195 w, 6196 D, 6197 k, 6198 F, 6199 N 6200 ); 6201 else 6202 break; 6203 z--, X--; 6204 } 6205 if (P > z) { 6206 if (P <= X) { 6207 const V = X + 1, nt = V < B ? M[V].el : T; 6208 for (; P <= X; ) 6209 _( 6210 null, 6211 M[P] = N ? Oi(M[P]) : Ye(M[P]), 6212 b, 6213 nt, 6214 w, 6215 D, 6216 k, 6217 F, 6218 N 6219 ), P++; 6220 } 6221 } else if (P > X) 6222 for (; P <= z; ) 6223 I(x[P], w, D, !0), P++; 6224 else { 6225 const V = P, nt = P, gt = /* @__PURE__ */ new Map(); 6226 for (P = nt; P <= X; P++) { 6227 const Jt = M[P] = N ? Oi(M[P]) : Ye(M[P]); 6228 Jt.key != null && gt.set(Jt.key, P); 6229 } 6230 let ct, bt = 0; 6231 const Zt = X - nt + 1; 6232 let Dt = !1, Is = 0; 6233 const is = new Array(Zt); 6234 for (P = 0; P < Zt; P++) 6235 is[P] = 0; 6236 for (P = V; P <= z; P++) { 6237 const Jt = x[P]; 6238 if (bt >= Zt) { 6239 I(Jt, w, D, !0); 6240 continue; 6241 } 6242 let Ce; 6243 if (Jt.key != null) 6244 Ce = gt.get(Jt.key); 6245 else 6246 for (ct = nt; ct <= X; ct++) 6247 if (is[ct - nt] === 0 && Fn(Jt, M[ct])) { 6248 Ce = ct; 6249 break; 6250 } 6251 Ce === void 0 ? I(Jt, w, D, !0) : (is[Ce - nt] = P + 1, Ce >= Is ? Is = Ce : Dt = !0, _( 6252 Jt, 6253 M[Ce],
6254 b, 6255 null, 6256 w, 6257 D, 6258 k, 6259 F, 6260 N 6261 ), bt++); 6262 } 6263 const Dr = Dt ? $x(is) : sn; 6264 for (ct = Dr.length - 1, P = Zt - 1; P >= 0; P--) { 6265 const Jt = nt + P, Ce = M[Jt], Ps = Jt + 1 < B ? M[Jt + 1].el : T; 6266 is[P] === 0 ? _( 6267 null, 6268 Ce, 6269 b, 6270 Ps, 6271 w, 6272 D, 6273 k, 6274 F, 6275 N 6276 ) : Dt && (ct < 0 || P !== Dr[ct] ? wt(Ce, b, Ps, 2) : ct--); 6277 } 6278 } 6279 }, wt = (x, M, b, T, w = null) => { 6280 const { el: D, type: k, transition: F, children: N, shapeFlag: P } = x; 6281 if (P & 6) { 6282 wt(x.component.subTree, M, b, T); 6283 return; 6284 } 6285 if (P & 128) { 6286 x.suspense.move(M, b, T); 6287 return; 6288 } 6289 if (P & 64) { 6290 k.move(x, M, b, Ht); 6291 return; 6292 } 6293 if (k === me) { 6294 s(D, M, b); 6295 for (let z = 0; z < N.length; z++) 6296 wt(N[z], M, b, T); 6297 s(x.anchor, M, b); 6298 return; 6299 } 6300 if (k === Ia) { 6301 v(x, M, b); 6302 return; 6303 } 6304 if (T !== 2 && P & 1 && F) 6305 if (T === 0) 6306 F.beforeEnter(D), s(D, M, b), _e(() => F.enter(D), w); 6307 else { 6308 const { leave: z, delayLeave: X, afterLeave: V } = F, nt = () => s(D, M, b), gt = () => { 6309 z(D, () => { 6310 nt(), V && V(); 6311 }); 6312 }; 6313 X ? X(D, nt, gt) : gt(); 6314 } 6315 else 6316 s(D, M, b); 6317 }, I = (x, M, b, T = !1, w = !1) => { 6318 const { 6319 type: D, 6320 props: k, 6321 ref: F, 6322 children: N, 6323 dynamicChildren: P, 6324 shapeFlag: B, 6325 patchFlag: z, 6326 dirs: X 6327 } = x; 6328 if (F != null && El(F, null, b, x, !0), B & 256) { 6329 M.ctx.deactivate(x); 6330 return; 6331 } 6332 const V = B & 1 && X, nt = !Kn(x); 6333 let gt; 6334 if (nt && (gt = k && k.onVnodeBeforeUnmount) && $e(gt, M, x), B & 6) 6335 vt(x.component, b, T); 6336 else { 6337 if (B & 128) { 6338 x.suspense.unmount(b, T); 6339 return; 6340 } 6341 V && ns(x, null, M, "beforeUnmount"), B & 64 ? x.type.remove( 6342 x, 6343 M, 6344 b, 6345 w, 6346 Ht, 6347 T 6348 ) : P && // #1153: fast path should not be taken for non-stable (v-for) fragments 6349 (D !== me || z > 0 && z & 64) ? Bt( 6350 P, 6351 M, 6352 b, 6353 !1, 6354 !0 6355 ) : (D === me && z & 384 || !w && B & 16) && Bt(N, M, b), T && qt(x); 6356 } 6357 (nt && (gt = k && k.onVnodeUnmounted) || V) && _e(() => { 6358 gt && $e(gt, M, x), V && ns(x, null, M, "unmounted"); 6359 }, b); 6360 }, qt = (x) => { 6361 const { type: M, el: b, anchor: T, transition: w } = x; 6362 if (M === me) { 6363 pt(b, T); 6364 return; 6365 } 6366 if (M === Ia) { 6367 E(x); 6368 return; 6369 } 6370 const D = () => { 6371 n(b), w && !w.persisted && w.afterLeave && w.afterLeave(); 6372 }; 6373 if (x.shapeFlag & 1 && w && !w.persisted) { 6374 const { leave: k, delayLeave: F } = w, N = () => k(b, D); 6375 F ? F(x.el, D, N) : N(); 6376 } else 6377 D(); 6378 }, pt = (x, M) => { 6379 let b; 6380 for (; x !== M; ) 6381 b = d(x), n(x), x = b; 6382 n(M); 6383 }, vt = (x, M, b) => { 6384 const { bum: T, scope: w, update: D, subTree: k, um: F } = x; 6385 T && Sa(T), w.stop(), D && (D.active = !1, I(k, x, M, b)), F && _e(F, M), _e(() => { 6386 x.isUnmounted = !0; 6387 }, M), M && M.pendingBranch && !M.isUnmounted && x.asyncDep && !x.asyncResolved && x.suspenseId === M.pendingId && (M.deps--, M.deps === 0 && M.resolve()); 6388 }, Bt = (x, M, b, T = !1, w = !1, D = 0) => { 6389 for (let k = D; k < x.length; k++) 6390 I(x[k], M, b, T, w); 6391 }, oe = (x) => x.shapeFlag & 6 ? oe(x.component.subTree) : x.shapeFlag & 128 ? x.suspense.next() : d(x.anchor || x.el), Gt = (x, M, b) => { 6392 x == null ? M._vnode && I(M._vnode, null, null, !0) : _(M._vnode || null, x, M, null, null, null, b), Wc(), cf(), M._vnode = x; 6393 }, Ht = { 6394 p: _, 6395 um: I, 6396 m: wt, 6397 r: qt, 6398 mt: St, 6399 mc: R, 6400 pc: W, 6401 pbc: $, 6402 n: oe, 6403 o: e 6404 }; 6405 let Ue, Si; 6406 return t && ([Ue, Si] = t( 6407 Ht 6408 )), { 6409 render: Gt, 6410 hydrate: Ue, 6411 createApp: Nx(Gt, Ue) 6412 }; 6413} 6414function rs({ effect: e, update: t }, i) { 6415 e.allowRecurse = t.allowRecurse = i; 6416} 6417function Rf(e, t, i = !1) { 6418 const s = e.children, n = t.children; 6419 if (it(s) && it(n)) 6420 for (let r = 0; r < s.length; r++) { 6421 const o = s[r]; 6422 let a = n[r]; 6423 a.shapeFlag & 1 && !a.dynamicChildren && ((a.patchFlag <= 0 || a.patchFlag === 32) && (a = n[r] = Oi(n[r]), a.el = o.el), i || Rf(o, a)), a.type === oa && (a.el = o.el); 6424 } 6425} 6426function $x(e) { 6427 const t = e.slice(), i = [0]; 6428 let s, n, r, o, a; 6429 const l = e.length; 6430 for (s = 0; s < l; s++) { 6431 const h = e[s]; 6432 if (h !== 0) { 6433 if (n = i[i.length - 1], e[n] < h) { 6434 t[s] = n, i.push(s); 6435 continue; 6436 } 6437 for (r = 0, o = i.length - 1; r < o; ) 6438 a = r + o >> 1, e[i[a]] < h ? r = a + 1 : o = a; 6439 h < e[i[r]] && (r > 0 && (t[s] = i[r - 1]), i[r] = s); 6440 } 6441 } 6442 for (r = i.length, o = i[r - 1]; r-- > 0; ) 6443 i[r] = o, o = t[o]; 6444 return i; 6445} 6446const Yx = (e) => e.__isTeleport, me = Symbol.for("v-fgt"), oa = Symbol.for("v-txt"), Ji = Symbol.for("v-cmt"), Ia = Symbol.for("v-stc"), qn = []; 6447let Ge = null; 6448function Tt(e = !1) { 6449 qn.push(Ge = e ? null : []); 6450} 6451function Kx() { 6452 qn.pop(), Ge = qn[qn.length - 1] || null; 6453} 6454let or = 1; 6455function Zc(e) { 6456 or += e; 6457} 6458function If(e) { 6459 return e.dynamicChildren = or > 0 ? Ge || sn : null, Kx(), or > 0 && Ge && Ge.push(e), e; 6460} 6461function Pt(e, t, i, s, n, r) { 6462 return If( 6463 kt( 6464 e, 6465 t, 6466 i, 6467 s, 6468 n, 6469 r, 6470 !0 6471 /* isBlock */ 6472 ) 6473 ); 6474} 6475function Pf(e, t, i, s, n) { 6476 return If( 6477 Be( 6478 e, 6479 t, 6480 i, 6481 s, 6482 n, 6483 !0 6484 /* isBlock: prevent a block from tracking itself */ 6485 ) 6486 ); 6487} 6488function Af(e) { 6489 return e ? e.__v_isVNode === !0 : !1; 6490} 6491function Fn(e, t) { 6492 return e.type === t.type && e.key === t.key; 6493} 6494const aa = "__vInternal", Lf = ({ key: e }) => e ?? null, mo = ({ 6495 ref: e, 6496 ref_key: t, 6497 ref_for: i 6498}) => (typeof e == "number" && (e = "" + e), e != null ? Wt(e) || de(e) || ht(e) ? { i: pe, r: e, k: t, f: !!i } : e : null); 6499function kt(e, t = null, i = null, s = 0, n = null, r = e === me ? 0 : 1, o = !1, a = !1) { 6500 const l = { 6501 __v_isVNode: !0, 6502 __v_skip: !0, 6503 type: e, 6504 props: t,
vendor: 7,161 bytes, lines 6505-6758
6505 key: t && Lf(t), 6506 ref: t && mo(t), 6507 scopeId: ff, 6508 slotScopeIds: null, 6509 children: i, 6510 component: null, 6511 suspense: null, 6512 ssContent: null, 6513 ssFallback: null, 6514 dirs: null, 6515 transition: null, 6516 el: null, 6517 anchor: null, 6518 target: null, 6519 targetAnchor: null, 6520 staticCount: 0, 6521 shapeFlag: r, 6522 patchFlag: s, 6523 dynamicProps: n, 6524 dynamicChildren: null, 6525 appContext: null, 6526 ctx: pe 6527 }; 6528 return a ? (gh(l, i), r & 128 && e.normalize(l)) : i && (l.shapeFlag |= Wt(i) ? 8 : 16), or > 0 && // avoid a block node from tracking itself 6529 !o && // has current parent block 6530 Ge && // presence of a patch flag indicates this node needs patching on updates. 6531 // component nodes also should always be patched, because even if the 6532 // component doesn't need to update, it needs to persist the instance on to 6533 // the next vnode so that it can be properly unmounted later. 6534 (l.patchFlag > 0 || r & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the 6535 // vnode should not be considered dynamic due to handler caching. 6536 l.patchFlag !== 32 && Ge.push(l), l; 6537} 6538const Be = Vx; 6539function Vx(e, t = null, i = null, s = 0, n = null, r = !1) { 6540 if ((!e || e === Rx) && (e = Ji), Af(e)) { 6541 const a = mn( 6542 e, 6543 t, 6544 !0 6545 /* mergeRef: true */ 6546 ); 6547 return i && gh(a, i), or > 0 && !r && Ge && (a.shapeFlag & 6 ? Ge[Ge.indexOf(e)] = a : Ge.push(a)), a.patchFlag |= -2, a; 6548 } 6549 if (nv(e) && (e = e.__vccOpts), t) { 6550 t = qx(t); 6551 let { class: a, style: l } = t; 6552 a && !Wt(a) && (t.class = gn(a)), Ft(l) && (rf(l) && !it(l) && (l = jt({}, l)), t.style = Rr(l)); 6553 } 6554 const o = Wt(e) ? 1 : dx(e) ? 128 : Yx(e) ? 64 : Ft(e) ? 4 : ht(e) ? 2 : 0; 6555 return kt( 6556 e, 6557 t, 6558 i, 6559 s, 6560 n, 6561 o, 6562 r, 6563 !0 6564 ); 6565} 6566function qx(e) { 6567 return e ? rf(e) || aa in e ? jt({}, e) : e : null; 6568} 6569function mn(e, t, i = !1) { 6570 const { props: s, ref: n, patchFlag: r, children: o } = e, a = t ? Hx(s || {}, t) : s; 6571 return { 6572 __v_isVNode: !0, 6573 __v_skip: !0, 6574 type: e.type, 6575 props: a, 6576 key: a && Lf(a), 6577 ref: t && t.ref ? ( 6578 // #2078 in the case of <component :is="vnode" ref="extra"/> 6579 // if the vnode itself already has a ref, cloneVNode will need to merge 6580 // the refs so the single vnode can be set on multiple refs 6581 i && n ? it(n) ? n.concat(mo(t)) : [n, mo(t)] : mo(t) 6582 ) : n, 6583 scopeId: e.scopeId, 6584 slotScopeIds: e.slotScopeIds, 6585 children: o, 6586 target: e.target, 6587 targetAnchor: e.targetAnchor, 6588 staticCount: e.staticCount, 6589 shapeFlag: e.shapeFlag, 6590 // if the vnode is cloned with extra props, we can no longer assume its 6591 // existing patch flag to be reliable and need to add the FULL_PROPS flag. 6592 // note: preserve flag for fragments since they use the flag for children 6593 // fast paths only. 6594 patchFlag: t && e.type !== me ? r === -1 ? 16 : r | 16 : r, 6595 dynamicProps: e.dynamicProps, 6596 dynamicChildren: e.dynamicChildren, 6597 appContext: e.appContext, 6598 dirs: e.dirs, 6599 transition: e.transition, 6600 // These should technically only be non-null on mounted VNodes. However, 6601 // they *should* be copied for kept-alive vnodes. So we just always copy 6602 // them since them being non-null during a mount doesn't affect the logic as 6603 // they will simply be overwritten. 6604 component: e.component, 6605 suspense: e.suspense, 6606 ssContent: e.ssContent && mn(e.ssContent), 6607 ssFallback: e.ssFallback && mn(e.ssFallback), 6608 el: e.el, 6609 anchor: e.anchor, 6610 ctx: e.ctx, 6611 ce: e.ce 6612 }; 6613} 6614function Of(e = " ", t = 0) { 6615 return Be(oa, null, e, t); 6616} 6617function _s(e = "", t = !1) { 6618 return t ? (Tt(), Pf(Ji, null, e)) : Be(Ji, null, e); 6619} 6620function Ye(e) { 6621 return e == null || typeof e == "boolean" ? Be(Ji) : it(e) ? Be( 6622 me, 6623 null, 6624 // #3666, avoid reference pollution when reusing vnode 6625 e.slice() 6626 ) : typeof e == "object" ? Oi(e) : Be(oa, null, String(e)); 6627} 6628function Oi(e) { 6629 return e.el === null && e.patchFlag !== -1 || e.memo ? e : mn(e); 6630} 6631function gh(e, t) { 6632 let i = 0; 6633 const { shapeFlag: s } = e; 6634 if (t == null) 6635 t = null; 6636 else if (it(t)) 6637 i = 16; 6638 else if (typeof t == "object") 6639 if (s & 65) { 6640 const n = t.default; 6641 n && (n._c && (n._d = !1), gh(e, n()), n._c && (n._d = !0)); 6642 return; 6643 } else { 6644 i = 32; 6645 const n = t._; 6646 !n && !(aa in t) ? t._ctx = pe : n === 3 && pe && (pe.slots._ === 1 ? t._ = 1 : (t._ = 2, e.patchFlag |= 1024)); 6647 } 6648 else 6649 ht(t) ? (t = { default: t, _ctx: pe }, i = 32) : (t = String(t), s & 64 ? (i = 16, t = [Of(t)]) : i = 8); 6650 e.children = t, e.shapeFlag |= i; 6651} 6652function Hx(...e) { 6653 const t = {}; 6654 for (let i = 0; i < e.length; i++) { 6655 const s = e[i]; 6656 for (const n in s) 6657 if (n === "class") 6658 t.class !== s.class && (t.class = gn([t.class, s.class])); 6659 else if (n === "style") 6660 t.style = Rr([t.style, s.style]); 6661 else if (Jo(n)) { 6662 const r = t[n], o = s[n]; 6663 o && r !== o && !(it(r) && r.includes(o)) && (t[n] = r ? [].concat(r, o) : o); 6664 } else 6665 n !== "" && (t[n] = s[n]); 6666 } 6667 return t; 6668} 6669function $e(e, t, i, s = null) { 6670 We(e, t, 7, [ 6671 i, 6672 s 6673 ]); 6674} 6675const Zx = Mf(); 6676let Jx = 0; 6677function Qx(e, t, i) { 6678 const s = e.type, n = (t ? t.appContext : e.appContext) || Zx, r = { 6679 uid: Jx++, 6680 vnode: e, 6681 type: s, 6682 parent: t, 6683 appContext: n, 6684 root: null, 6685 // to be immediately set 6686 next: null, 6687 subTree: null, 6688 // will be set synchronously right after creation 6689 effect: null, 6690 update: null, 6691 // will be set synchronously right after creation 6692 scope: new v1( 6693 !0 6694 /* detached */ 6695 ), 6696 render: null, 6697 proxy: null, 6698 exposed: null, 6699 exposeProxy: null, 6700 withProxy: null, 6701 provides: t ? t.provides : Object.create(n.provides), 6702 accessCache: null, 6703 renderCache: [], 6704 // local resolved assets 6705 components: null, 6706 directives: null, 6707 // resolved props and emits options 6708 propsOptions: bf(s, n), 6709 emitsOptions: df(s, n), 6710 // emit 6711 emit: null, 6712 // to be set immediately 6713 emitted: null, 6714 // props default value 6715 propsDefaults: At, 6716 // inheritAttrs 6717 inheritAttrs: s.inheritAttrs, 6718 // state 6719 ctx: At, 6720 data: At, 6721 props: At, 6722 attrs: At, 6723 slots: At, 6724 refs: At, 6725 setupState: At, 6726 setupContext: null, 6727 attrsProxy: null, 6728 slotsProxy: null, 6729 // suspense related 6730 suspense: i, 6731 suspenseId: i ? i.pendingId : 0, 6732 asyncDep: null, 6733 asyncResolved: !1, 6734 // lifecycle hooks 6735 // not using enums here because it results in computed properties 6736 isMounted: !1, 6737 isUnmounted: !1, 6738 isDeactivated: !1, 6739 bc: null, 6740 c: null, 6741 bm: null, 6742 m: null, 6743 bu: null, 6744 u: null, 6745 um: null, 6746 bum: null, 6747 da: null, 6748 a: null, 6749 rtg: null, 6750 rtc: null, 6751 ec: null, 6752 sp: null 6753 }; 6754 return r.ctx = { _: r }, r.root = t ? t.root : r, r.emit = ox.bind(null, r), e.ce && e.ce(r), r; 6755} 6756let se = null, _h, Os, Jc = "__VUE_INSTANCE_SETTERS__"; 6757(Os = hl()[Jc]) || (Os = hl()[Jc] = []), Os.push((e) => se = e), _h = (e) => { 6758 Os.length >
6758 1 ? Os.forEach((t) => t(e)) : Os[0](e); 6759}; 6760const pn = (e) => { 6761 _h(e), e.scope.on(); 6762}, ms = () => { 6763 se && se.scope.off(), _h(null); 6764}; 6765function Ff(e) { 6766 return e.vnode.shapeFlag & 4; 6767} 6768let ar = !1; 6769function tv(e, t = !1) { 6770 ar = t; 6771 const { props: i, children: s } = e.vnode, n = Ff(e); 6772 Gx(e, i, n, t), Wx(e, s); 6773 const r = n ? ev(e, t) : void 0; 6774 return ar = !1, r; 6775} 6776function ev(e, t) { 6777 const i = e.type; 6778 e.accessCache = /* @__PURE__ */ Object.create(null), e.proxy = _n(new Proxy(e.ctx, Ix)); 6779 const { setup: s } = i; 6780 if (s) { 6781 const n = e.setupContext = s.length > 1 ? sv(e) : null; 6782 pn(e), Sn(); 6783 const r = Ki( 6784 s, 6785 e, 6786 0, 6787 [e.props, n] 6788 ); 6789 if (wn(), ms(), Wd(r)) { 6790 if (r.then(ms, ms), t) 6791 return r.then((o) => { 6792 Qc(e, o, t); 6793 }).catch((o) => { 6794 sa(o, e, 0); 6795 }); 6796 e.asyncDep = r; 6797 } else 6798 Qc(e, r, t); 6799 } else 6800 Df(e, t); 6801} 6802function Qc(e, t, i) { 6803 ht(t) ? e.type.__ssrInlineRender ? e.ssrRender = t : e.render = t : Ft(t) && (e.setupState = of(t)), Df(e, i); 6804} 6805let tu; 6806function Df(e, t, i) { 6807 const s = e.type; 6808 if (!e.render) { 6809 if (!t && tu && !s.render) { 6810 const n = s.template || dh(e).template; 6811 if (n) { 6812 const { isCustomElement: r, compilerOptions: o } = e.appContext.config, { delimiters: a, compilerOptions: l } = s, h = jt( 6813 jt( 6814 { 6815 isCustomElement: r, 6816 delimiters: a 6817 }, 6818 o 6819 ), 6820 l 6821 ); 6822 s.render = tu(n, h); 6823 } 6824 } 6825 e.render = s.render || je; 6826 } 6827 pn(e), Sn(), Px(e), wn(), ms(); 6828} 6829function iv(e) { 6830 return e.attrsProxy || (e.attrsProxy = new Proxy( 6831 e.attrs, 6832 { 6833 get(t, i) { 6834 return Ee(e, "get", "$attrs"), t[i]; 6835 } 6836 } 6837 )); 6838} 6839function sv(e) { 6840 const t = (i) => { 6841 e.exposed = i || {}; 6842 }; 6843 return { 6844 get attrs() { 6845 return iv(e); 6846 }, 6847 slots: e.slots, 6848 emit: e.emit, 6849 expose: t 6850 }; 6851} 6852function mh(e) { 6853 if (e.exposed) 6854 return e.exposeProxy || (e.exposeProxy = new Proxy(of(_n(e.exposed)), { 6855 get(t, i) { 6856 if (i in t) 6857 return t[i]; 6858 if (i in Vn) 6859 return Vn[i](e); 6860 }, 6861 has(t, i) { 6862 return i in t || i in Vn; 6863 } 6864 })); 6865} 6866function nv(e) { 6867 return ht(e) && "__vccOpts" in e; 6868} 6869const rv = (e, t) => ex(e, t, ar), ov = Symbol.for("v-scx"), av = () => _o(ov), lv = "3.3.4", hv = "http://www.w3.org/2000/svg", hs = typeof document < "u" ? document : null, eu = hs && /* @__P
6869URE__ */ hs.createElement("template"), cv = { 6870 insert: (e, t, i) => { 6871 t.insertBefore(e, i || null); 6872 }, 6873 remove: (e) => { 6874 const t = e.parentNode; 6875 t && t.removeChild(e); 6876 }, 6877 createElement: (e, t, i, s) => { 6878 const n = t ? hs.createElementNS(hv, e) : hs.createElement(e, i ? { is: i } : void 0); 6879 return e === "select" && s && s.multiple != null && n.setAttribute("multiple", s.multiple), n; 6880 }, 6881 createText: (e) => hs.createTextNode(e), 6882 createComment: (e) => hs.createComment(e), 6883 setText: (e, t) => { 6884 e.nodeValue = t; 6885 }, 6886 setElementText: (e, t) => { 6887 e.textContent = t; 6888 }, 6889 parentNode: (e) => e.parentNode, 6890 nextSibling: (e) => e.nextSibling, 6891 querySelector: (e) => hs.querySelector(e), 6892 setScopeId(e, t) { 6893 e.setAttribute(t, ""); 6894 }, 6895 // __UNSAFE__ 6896 // Reason: innerHTML. 6897 // Static content here can only come from compiled templates. 6898 // As long as the user only uses trusted templates, this is safe. 6899 insertStaticContent(e, t, i, s, n, r) { 6900 const o = i ? i.previousSibling : t.lastChild; 6901 if (n && (n === r || n.nextSibling)) 6902 for (; t.insertBefore(n.cloneNode(!0), i), !(n === r || !(n = n.nextSibling)); ) 6903 ; 6904 else { 6905 eu.innerHTML = s ? `<svg>${e}</svg>` : e; 6906 const a = eu.content; 6907 if (s) { 6908 const l = a.firstChild; 6909 for (; l.firstChild; ) 6910 a.appendChild(l.firstChild); 6911 a.removeChild(l); 6912 } 6913 t.insertBefore(a, i); 6914 } 6915 return [ 6916 // first 6917 o ? o.nextSibling : t.firstChild, 6918 // last 6919 i ? i.previousSibling : t.lastChild 6920 ]; 6921 } 6922}; 6923function uv(e, t, i) { 6924 const s = e._vtc; 6925 s && (t = (t ? [t, ...s] : [...s]).join(" ")), t == null ? e.removeAttribute("class") : i ? e.setAttribute("class", t) : e.className = t; 6926} 6927function dv(e, t, i) { 6928 const s = e.style, n = Wt(i); 6929 if (i && !n) { 6930 if (t && !Wt(t)) 6931 for (const r in t) 6932 i[r] == null && Ml(s, r, ""); 6933 for (const r in i) 6934 Ml(s, r, i[r]); 6935 } else { 6936 const r = s.display; 6937 n ? t !== i && (s.cssText = i) : t && e.removeAttribute("style"), "_vod" in e && (s.display = r); 6938 } 6939} 6940const iu = /\s*!important$/; 6941function Ml(e, t, i) { 6942 if (it(i)) 6943 i.forEach((s) => Ml(e, t, s)); 6944 else if (i == null && (i = ""), t.startsWith("--")) 6945 e.setProperty(t, i); 6946 else { 6947 const s = fv(e, t); 6948 iu.test(i) ? e.setProperty( 6949 Ne(s), 6950 i.replace(iu, ""), 6951 "important" 6952 ) : e[s] = i; 6953 } 6954} 6955const su = ["Webkit", "Moz", "ms"], Pa = {}; 6956function fv(e, t) { 6957 const i = Pa[t]; 6958 if (i) 6959 return i; 6960 let s = _i(t); 6961 if (s !== "filter" && s in e) 6962 return Pa[t] = s; 6963 s = Xd(s); 6964 for (let n = 0; n < su.length; n++) { 6965 const r = su[n] + s; 6966 if (r in e) 6967 return Pa[t] = r; 6968 } 6969 return t; 6970} 6971const nu = "http://www.w3.org/1999/xlink"; 6972function gv(e, t, i, s, n) { 6973 if (s && t.startsWith("xlink:")) 6974 i == null ? e.removeAttributeNS(nu, t.slice(6, t.length)) : e.setAttributeNS(nu, t, i); 6975 else { 6976 const r = x1(t); 6977 i == null || r && !$d(i) ? e.removeAttribute(t) : e.setAttribute(t, r ? "" : i); 6978 } 6979} 6980function _v(e, t, i, s, n, r, o) { 6981 if (t === "innerHTML" || t === "textContent") { 6982 s && o(s, n, r), e[t] = i ?? ""; 6983 return; 6984 } 6985 const a = e.tagName; 6986 if (t === "value" && a !== "PROGRESS" && // custom elements may use _value internally 6987 !a.includes("-")) { 6988 e._value = i; 6989 const h = a === "OPTION" ? e.getAttribute("value") : e.value, c = i ?? ""; 6990 h !== c && (e.value = c), i == null && e.removeAttribute(t); 6991 return; 6992 } 6993 let l = !1; 6994 if (i === "" || i == null) { 6995 const h = typeof e[t]; 6996 h === "boolean" ? i = $d(i) : i == null && h === "string" ? (i = "", l = !0) : h === "number" && (i = 0, l = !0); 6997 } 6998 try { 6999 e[t] = i; 7000 } catch { 7001 } 7002 l && e.removeAttribute(t); 7003} 7004function mv(e, t, i, s) { 7005 e.addEventListener(t, i, s); 7006} 7007function pv(e, t, i, s) { 7008 e.removeEventListener(t, i, s); 7009} 7010function yv(e, t, i, s, n = null) { 7011 const r = e._vei || (e._vei = {}), o = r[t]; 7012 if (s && o) 7013 o.value = s; 7014 else { 7015 const [a, l] = xv(t); 7016 if (s) { 7017 const h = r[t] = Mv(s, n); 7018 mv(e, a, h, l); 7019 } else 7020 o && (pv(e, a, o, l), r[t] = void 0); 7021 } 7022} 7023const ru = /(?:Once|Passive|Capture)$/; 7024function xv(e) { 7025 let t; 7026 if (ru.test(e)) { 7027 t = {}; 7028 let s; 7029 for (; s = e.match(ru); ) 7030 e = e.slice(0, e.length - s[0].length), t[s[0].toLowerCase()] = !0; 7031 } 7032 return [e[2] === ":" ? e.slice(3) : Ne(e.slice(2)), t]; 7033} 7034let Aa = 0; 7035const vv = /* @__PURE__ */ Promise.resolve(), Ev = () => Aa || (vv.then(() => Aa = 0), Aa = Date.now()); 7036function Mv(e, t) { 7037 const i = (s) => { 7038 if (!s._vts) 7039 s._vts = Date.now(); 7040 else if (s._vts <= i.attached) 7041 return; 7042 We( 7043 Cv(s, i.value), 7044 t, 7045 5, 7046 [s] 7047 ); 7048 }; 7049 return i.value = e, i.attached = Ev(), i; 7050} 7051function Cv(e, t) { 7052 if (it(t)) { 7053 const i = e.stopImmediatePropagation; 7054 return e.stopImmediatePropagation = () => { 7055 i.call(e), e._stopped = !0; 7056 }, t.map((s) => (n) => !n._stopped && s && s(n)); 7057 } else 7058 return t; 7059} 7060const ou = /^on[a-z]/, bv = (e, t, i, s, n = !1, r, o, a, l) => { 7061 t === "class" ? uv(e, s, n) : t === "style" ? dv(e, i, s) : Jo(t) ? Jl(t) || yv(e, t, i, s, o) : (t[0] === "." ? (t = t.slice(1), !0) : t[0] === "^" ? (t = t.slice(1), !1) : Sv(e, t, s, n)) ? _v( 7062 e, 7063 t, 7064 s, 7065 r, 7066 o, 7067 a, 7068 l
7069 ) : (t === "true-value" ? e._trueValue = s : t === "false-value" && (e._falseValue = s), gv(e, t, s, n)); 7070}; 7071function Sv(e, t, i, s) { 7072 return s ? !!(t === "innerHTML" || t === "textContent" || t in e && ou.test(t) && ht(i)) : t === "spellcheck" || t === "draggable" || t === "translate" || t === "form" || t === "list" && e.tagName === "INPUT" || t === "type" && e.tagName === "TEXTAREA" || ou.test(t) && Wt(i) ? !1 : t in e; 7073} 7074function Tn(e, t) { 7075 const i = _x(e); 7076 class s extends ph { 7077 constructor(r) { 7078 super(i, r, t); 7079 } 7080 } 7081 return s.def = i, s; 7082} 7083const wv = typeof HTMLElement < "u" ? HTMLElement : class { 7084}; 7085class ph extends wv { 7086 constructor(t, i = {}, s) { 7087 super(), this._def = t, this._props = i, this._instance = null, this._connected = !1, this._resolved = !1, this._numberProps = null, this.shadowRoot && s ? s(this._createVNode(), this.shadowRoot) : (this.attachShadow({ mode: "open" }), this._def.__asyncLoader || this._resolveProps(this._def)); 7088 } 7089 connectedCallback() { 7090 this._connected = !0, this._instance || (this._resolved ? this._update() : this._resolveDef()); 7091 } 7092 disconnectedCallback() { 7093 this._connected = !1, lf(() => { 7094 this._connected || (lu(null, this.shadowRoot), this._instance = null); 7095 }); 7096 } 7097 /** 7098 * resolve inner component definition (handle possible async component) 7099 */ 7100 _resolveDef() { 7101 this._resolved = !0; 7102 for (let s = 0; s < this.attributes.length; s++) 7103 this._setAttr(this.attributes[s].name); 7104 new MutationObserver((s) => { 7105 for (const n of s) 7106 this._setAttr(n.attributeName); 7107 }).observe(this, { attributes: !0 }); 7108 const t = (s, n = !1) => { 7109 const { props: r, styles: o } = s; 7110 let a; 7111 if (r && !it(r)) 7112 for (const l in r) { 7113 const h = r[l]; 7114 (h === Number || h && h.type === Number) && (l in this._props && (this._props[l] = Lc(this._props[l])), (a || (a = /* @__PURE__ */ Object.create(null)))[_i(l)] = !0); 7115 } 7116 this._numberProps = a, n && this._resolveProps(s), this._applyStyles(o), this._update(); 7117 }, i = this._def.__asyncLoader; 7118 i ? i().then((s) => t(s, !0)) : t(this._def); 7119 } 7120 _resolveProps(t) { 7121 const { props: i } = t, s = it(i) ? i : Object.keys(i || {}); 7122 for (const n of Object.keys(this)) 7123 n[0] !== "_" && s.includes(n) && this._setProp(n, this[n], !0, !1); 7124 for (const n of s.map(_i)) 7125 Object.defineProperty(this, n, { 7126 get() { 7127 return this._getProp(n); 7128 }, 7129 set(r) { 7130 this._setProp(n, r); 7131 } 7132 }); 7133 } 7134 _setAttr(t) { 7135 let i = this.getAttribute(t); 7136 const s = _i(t); 7137 this._numberProps && this._numberProps[s] && (i = Lc(i)), this._setProp(s, i, !1); 7138 } 7139 /** 7140 * @internal 7141 */ 7142 _getProp(t) { 7143 return this._props[t]; 7144 } 7145 /** 7146 * @internal 7147 */ 7148 _setProp(t, i, s = !0, n = !0) { 7149 i !== this._props[t] && (this._props[t] = i, n && this._instance && this._update(), s && (i === !0 ? this.setAttribute(Ne(t), "") : typeof i == "string" || typeof i == "number" ? this.setAttribute(Ne(t), i + "") : i || this.removeAttribute(Ne(t)))); 7150 } 7151 _update() { 7152 lu(this._createVNode(), this.shadowRoot); 7153 } 7154 _createVNode() { 7155 const t = Be(this._def, jt({}, this._props)); 7156 return this._instance || (t.ce = (i) => { 7157 this._instance = i, i.isCE = !0; 7158 const s = (r, o) => { 7159 this.dispatchEvent( 7160 new CustomEvent(r, { 7161 detail: o 7162 }) 7163 ); 7164 }; 7165 i.emit = (r, ...o) => { 7166 s(r, o), Ne(r) !== r && s(Ne(r), o); 7167 }; 7168 let n = this; 7169 for (; n = n && (n.parentNode || n.host); ) 7170 if (n instanceof ph) { 7171 i.parent = n._instance, i.provides = n._instance.provides; 7172 break; 7173 } 7174 }), t; 7175 } 7176 _applyStyles(t) { 7177 t && t.forEach((i) => { 7178 const s = document.createElement("style"); 7179 s.textContent = i, this.shadowRoot.appendChild(s); 7180 }); 7181 } 7182} 7183const Tv = ["ctrl", "shift", "alt", "meta"], Rv = { 7184 stop: (e) => e.stopPropagation(), 7185 prevent: (e) => e.preventDefault(), 7186 self: (e) => e.target !== e.currentTarget, 7187 ctrl: (e) => !e.ctrlKey, 7188 shift: (e) => !e.shiftKey, 7189 alt: (e) => !e.altKey, 7190 meta: (e) => !e.metaKey, 7191 left: (e) => "button" in e && e.button !== 0, 7192 middle: (e) => "button" in e && e.button !== 1, 7193 right: (e) => "button" in e && e.button !== 2, 7194 exact: (e, t) => Tv.some((i) => e[`${i}Key`] && !t.includes(i)) 7195}, Nf = (e, t) =>
7195 (i, ...s) => { 7196 for (let n = 0; n < t.length; n++) { 7197 const r = Rv[t[n]]; 7198 if (r && r(i, t)) 7199 return; 7200 } 7201 return e(i, ...s); 7202}, Iv = /* @__PURE__ */ jt({ patchProp: bv }, cv); 7203let au; 7204function Pv() { 7205 return au || (au = Ux(Iv)); 7206} 7207const lu = (...e) => { 7208 Pv().render(...e); 7209}; 7210function La(e) { 7211 return parseInt(e, 16) || e; 7212} 7213function Oa(e) { 7214 return La(e) / 255 <= 0.03928 ? La(e) / 255 / 12.92 : Math.pow((La(e) / 255 + 0.055) / 1.055, 2.4); 7215} 7216function hu(e) { 7217 return 0.2126 * Oa(e.substr(1, 2)) + 0.7152 * Oa(e.substr(3, 2)) + 0.0722 * Oa(e.substr(-2)); 7218} 7219function Io(e, t) { 7220 const i = hu(e), s = hu(t); 7221 return (Math.max(i, s) + 0.05) / (Math.min(i, s) + 0.05); 7222} 7223function Av(e) { 7224 const t = Io(e, "#ffffff"), i = Io(e, "#000000"); 7225 return t > i ? "#ffffff" : "#000000"; 7226} 7227function Lv(e) { 7228 const t = Io(e, "#ffffff"), i = Io(e, "#000000"); 7229 return t > i; 7230} 7231const Ov = `.xmap{height:100%;display:flex;flex-flow:column;font-family:Roboto,sans-serif!important;border:1px solid black}.xmap-main{height:calc(100% - 25px)}.xmap-web-map-footer{width:100%;height:25px;min-height:25px;background-color:var(--xmap-primary);font-size:.8em}.xmap-web-map-footer div{float:right;padding-right:5px;height:100%;line-height:25px}.xmap-web-map-footer div span{color:var(--xmap-footer-text);opacity:.9;height:100%;line-height:25px;padding-right:5px}.xmap-web-map-footer div a,.xmap-web-map-footer div a:hover,.xmap-web-map-footer div a:focus,.xmap-web-map-footer div a:active{text-decoration:none;color:var(--xmap-footer-text);float:right} 7232`, la = (e, t) => { 7233 const i = e.__vccOpts || e; 7234 for (const [s, n] of t) 7235 i[s] = n; 7236 return i; 7237}, Fv = { 7238 name: "Xmap", 7239 mounted() { 7240 }, 7241 data: () => ({ 7242 allowedVariants: ["xmap", "parishonline"] 7243 }), 7244 computed: { 7245 footerTextColor() { 7246 return Av(this.primaryColor); 7247 }, 7248 logoType() { 7249 let e = Lv(this.primaryColor) ? "light" : "dark"; 7250 return `https://embed.xmap.cloud/${this.appVariant}-${e}.png`; 7251 }, 7252 // Theme colours as named CSS custom properties, set through the normal :style 7253 // render path. Not v-bind() in <style>: Vue's useCssVars writes those from a 7254 // post-flush job that never lands in the Power Apps canvas player (XMP-2224). 7255 themeVars() { 7256 return { 7257 "--xmap-primary": this.primaryColor, 7258 "--xmap-secondary": this.secondaryColor, 7259 "--xmap-footer-text": this.footerTextColor 7260 }; 7261 }, 7262 appVariant() { 7263 return this.allowedVariants.includes(this.variant) ? this.variant : this.allowedVariants[0]; 7264 } 7265 }, 7266 provide() { 7267 return { 7268 primaryColor: this.primaryColor, 7269 secondaryColor: this.secondaryColor, 7270 variant: this.appVariant 7271 }; 7272 }, 7273 methods: { 7274 handleUpdate(e) { 7275 } 7276 }, 7277 watch: { 7278 primaryColor(e) { 7279 } 7280 }, 7281 props: { 7282 variant: { 7283 type: String, 7284 default: "xmap" 7285 }, 7286 primaryColor: { 7287 type: String, 7288 default: "#263746" 7289 }, 7290 secondaryColor: { 7291 type: String, 7292 default: "#a1d0ca" 7293 } 7294 } 7295}, Dv = { 7296 ref: "xmapMain", 7297 class: "xmap-main" 7298}, Nv = { 7299 ref: "footer", 7300 class: "xmap-web-map-footer" 7301}, kv = /* @__PURE__ */ kt("span", null, "Powered by ", -1), Gv = { 7302 target: "_blank", 7303 href: "https://parish-online.co.uk" 7304}, zv = ["src"]; 7305function jv(e, t, i, s, n, r) { 7306 return Tt(), Pt("div", { 7307 class: "xmap", 7308 style: Rr(r.themeVars) 7309 }, [ 7310 kt("div", Dv, [ 7311 xf(e.$slots, "default", { 7312 "onUpdate:x": t[0] || (t[0] = (...o) => r.handleUpdate && r.handleUpdate(...o)) 7313 }) 7314 ], 512), 7315 kt("div", Nv, [ 7316 kt("div", null, [ 7317 kv, 7318 kt("a", Gv, [ 7319 kt("img", { 7320 style: { height: "20px", "margin-top": "2.5px" }, 7321 alt: "A Logo", 7322 src: `${r.logoType}` 7323 }, null, 8, zv) 7324 ]) 7325 ]) 7326 ], 512) 7327 ], 4); 7328} 7329const Wv = /* @__PURE__ */ la(Fv, [["render", jv], ["styles", [Ov]]]); 7330class Bv { 7331 /** 7332 * @param {string} type Type. 7333 */ 7334 constructor(t) { 7335 this.propagationStopped, this.defaultPrevented, this.type = t, this.target = null; 7336 } 7337 /** 7338 * Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events 7339 * will be fired. 7340 * @api 7341 */ 7342 preventDefault() { 7343 this.defaultPrevented = !0; 7344 } 7345 /** 7346 * Stop event propagation. 7347 * @api 7348 */ 7349 stopPropagation() {
7350 this.propagationStopped = !0; 7351 } 7352} 7353const Ae = Bv, yn = { 7354 /** 7355 * Triggered when a property is changed. 7356 * @event module:ol/Object.ObjectEvent#propertychange 7357 * @api 7358 */ 7359 PROPERTYCHANGE: "propertychange" 7360}; 7361class Uv { 7362 constructor() { 7363 this.disposed = !1; 7364 } 7365 /** 7366 * Clean up. 7367 */ 7368 dispose() { 7369 this.disposed || (this.disposed = !0, this.disposeInternal()); 7370 } 7371 /** 7372 * Extension point for disposable objects. 7373 * @protected 7374 */ 7375 disposeInternal() { 7376 } 7377} 7378const yh = Uv; 7379function Xv(e, t, i) { 7380 let s, n; 7381 i = i || Cs; 7382 let r = 0, o = e.length, a = !1; 7383 for (; r < o; ) 7384 s = r + (o - r >> 1), n = +i(e[s], t), n < 0 ? r = s + 1 : (o = s, a = !n); 7385 return a ? r : ~r; 7386} 7387function Cs(e, t) { 7388 return e > t ? 1 : e < t ? -1 : 0; 7389} 7390function ha(e, t, i) { 7391 if (e[0] <= t) 7392 return 0; 7393 const s = e.length; 7394 if (t <= e[s - 1]) 7395 return s - 1; 7396 if (typeof i == "function") { 7397 for (let n = 1; n < s; ++n) { 7398 const r = e[n]; 7399 if (r === t) 7400 return n; 7401 if (r < t) 7402 return i(t, e[n - 1], r) > 0 ? n - 1 : n; 7403 } 7404 return s - 1; 7405 } 7406 if (i > 0) { 7407 for (let n = 1; n < s; ++n) 7408 if (e[n] < t) 7409 return n - 1; 7410 return s - 1; 7411 } 7412 if (i < 0) { 7413 for (let n = 1; n < s; ++n) 7414 if (e[n] <= t) 7415 return n; 7416 return s - 1; 7417 } 7418 for (let n = 1; n < s; ++n) { 7419 if (e[n] == t) 7420 return n; 7421 if (e[n] < t) 7422 return e[n - 1] - t < t - e[n] ? n - 1 : n; 7423 } 7424 return s - 1; 7425} 7426function $v(e, t, i) { 7427 for (; t < i; ) { 7428 const s = e[t]; 7429 e[t] = e[i], e[i] = s, ++t, --i; 7430 } 7431} 7432function mi(e, t) { 7433 const i = Array.isArray(t) ? t : [t], s = i.length; 7434 for (let n = 0; n < s; n++) 7435 e[e.length] = i[n]; 7436} 7437function bi(e, t) { 7438 const i = e.length; 7439 if (i !== t.length) 7440 return !1; 7441 for (let s = 0; s < i; s++) 7442 if (e[s] !== t[s]) 7443 return !1; 7444 return !0; 7445} 7446function Yv(e, t, i) { 7447 const s = t || Cs; 7448 return e.every(function(n, r) { 7449 if (r === 0) 7450 return !0; 7451 const o = s(e[r - 1], n); 7452 return !(o > 0 || i && o === 0); 7453 }); 7454} 7455function bs() { 7456 return !0; 7457} 7458function Rs() { 7459 return !1; 7460} 7461function xn() { 7462} 7463function Kv(e) { 7464 let t = !1, i, s, n; 7465 return function() { 7466 const r = Array.prototype.slice.call(arguments); 7467 return (!t || this !== n || !bi(r, s)) && (t = !0, n = this, s = r, i = e.apply(this, arguments)), i; 7468 }; 7469} 7470class Vv extends yh { 7471 /** 7472 * @param {*} [target] Default event target for dispatched events. 7473 */ 7474 constructor(t) { 7475 super(), this.eventTarget_ = t, this.pendingRemovals_ = null, this.dispatching_ = null, this.listeners_ = null; 7476 } 7477 /** 7478 * @param {string} type Type. 7479 * @param {import("../events.js").Listener} listener Listener. 7480 */ 7481 addEventListener(t, i) { 7482 if (!t || !i) 7483 return; 7484 const s = this.listeners_ || (this.listeners_ = {}), n = s[t] || (s[t] = []); 7485 n.includes(i) || n.push(i); 7486 } 7487 /** 7488 * Dispatches an event and calls all listeners listening for events 7489 * of this type. The event parameter can either be a string or an 7490 * Object with a `type` property. 7491 * 7492 * @param {import("./Event.js").default|string} event Event object. 7493 * @return {boolean|undefined} `false` if anyone called preventDefault on the 7494 * event object or if any of the listeners returned false. 7495 * @api 7496 */ 7497 dispatchEvent(t) { 7498 const i = typeof t == "string", s = i ? t : t.type, n = this.listeners_ && this.listeners_[s]; 7499 if (!n) 7500 return; 7501 const r = i ? new Ae(t) : ( 7502 /** @type {Event} */ 7503 t 7504 ); 7505 r.target || (r.target = this.eventTarget_ || this); 7506 const o = this.dispatching_ || (this.dispatching_ = {}), a = this.pendingRemovals_ || (this.pendingRemovals_ = {}); 7507 s in o || (o[s] = 0, a[s] = 0), ++o[s]; 7508 let l; 7509 for (let h = 0, c = n.length; h < c; ++h) 7510 if ("handleEvent" in n[h] ? l = /** @type {import("../events.js").ListenerObject} */ 7511 n[h].handleEvent(r) : l = /** @type {import("../events.js").ListenerFunction} */ 7512 n[h].call(this, r), l === !1 || r.propagationStopped) { 7513 l = !1; 7514 break; 7515 } 7516 if (--o[s] === 0) { 7517 let h = a[s]; 7518 for (delete a[s]; h--; ) 7519 this.removeEventListener(s, xn); 7520 delete o[s]; 7521 } 7522 return l; 7523 } 7524 /** 7525 * Clean up. 7526 */ 7527 disposeInternal() { 7528 this.listeners_ && Sr(this.listeners_); 7529 } 7530 /** 7531 * Get the listeners for a specified event type. Listeners are returned in the 7532 * order that they will be called in. 7533 * 7534 * @param {string} type Type. 7535 * @return {Array<import("../events.js").Listener>|undefined} Listeners. 7536 */ 7537 getListeners(t) { 7538 return this.listeners_ && this.listeners_[t] || void 0; 7539 } 7540 /** 7541 * @param {string} [type] Type. If not provided, 7542 * `true` will be returned if this event target has any listeners. 7543 * @return {boolean} Has listeners. 7544 */ 7545 hasListener(t) { 7546 return this.listeners_ ? t ? t in this.listeners_ : Object.keys(this.listeners_).length > 0 : !1; 7547 } 7548 /** 7549 * @param {string} type Type. 7550 * @param {import("../events.js").Listener} listener Listener. 7551 */ 7552 removeEventListener(t, i) { 7553 const s = this.listeners_ && this.listeners_[t]; 7554 if (s) { 7555 const n = s.indexOf(i); 7556 n !== -1 && (this.pendingRemovals_ && t in this.pendingRemovals_ ? (s[n] = xn, ++this.pendingRemovals_[t]) : (s.splice(n, 1), s.length === 0 && delete this.listeners_[t])); 7557 } 7558 } 7559} 7560const Ir = Vv, et = { 7561 /** 7562 * Generic change event. Triggered when the revision counter is increased. 7563 * @event module:ol/events/Event~BaseEvent#change 7564 * @api 7565 */ 7566 CHANGE: "change", 7567 /** 7568 * Generic error event. Triggered when an error occurs. 7569 * @event module:ol/events/Event~BaseEvent#error 7570 * @api 7571 */ 7572 ERROR: "error", 7573 BLUR: "blur", 7574 CLEAR: "clear", 7575 CONTEXTMENU: "contextmenu", 7576 CLICK: "click", 7577 DBLCLICK: "dblclick", 7578 DRAGENTER: "dragenter", 7579 DRAGOVER: "dragover", 7580 DROP: "drop", 7581 FOCUS: "focus", 7582 KEYDOWN: "keydown", 7583 KEYPRESS: "keypress", 7584 LOAD: "load", 7585 RESIZE: "resize", 7586 TOUCHMOVE: "touchmove", 7587 WHEEL: "wheel" 7588}; 7589function lt(e, t, i, s, n) { 7590 if (s && s !== e && (i = i.bind(s)), n) { 7591 const o = i; 7592 i = function() { 7593 e.removeEventListener(t, i), o.apply(this, arguments); 7594 }; 7595 } 7596 const r = { 7597 target: e, 7598 type: t, 7599 listener: i 7600 }; 7601 return e.addEventListener(t, i), r; 7602} 7603function Po(e, t, i, s) { 7604 return lt(e, t, i, s, !0); 7605} 7606function Mt(e) { 7607 e && e.target && (e.target.removeEventListener(e.type, e.listener), Sr(e)); 7608} 7609class ca extends Ir {
7610 constructor() { 7611 super(), this.on = /** @type {ObservableOnSignature<import("./events").EventsKey>} */ 7612 this.onInternal, this.once = /** @type {ObservableOnSignature<import("./events").EventsKey>} */ 7613 this.onceInternal, this.un = /** @type {ObservableOnSignature<void>} */ 7614 this.unInternal, this.revision_ = 0; 7615 } 7616 /** 7617 * Increases the revision counter and dispatches a 'change' event. 7618 * @api 7619 */ 7620 changed() { 7621 ++this.revision_, this.dispatchEvent(et.CHANGE); 7622 } 7623 /** 7624 * Get the version number for this object. Each time the object is modified, 7625 * its version number will be incremented. 7626 * @return {number} Revision. 7627 * @api 7628 */ 7629 getRevision() { 7630 return this.revision_; 7631 } 7632 /** 7633 * @param {string|Array<string>} type Type. 7634 * @param {function((Event|import("./events/Event").default)): ?} listener Listener. 7635 * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key. 7636 * @protected 7637 */ 7638 onInternal(t, i) { 7639 if (Array.isArray(t)) { 7640 const s = t.length, n = new Array(s); 7641 for (let r = 0; r < s; ++r) 7642 n[r] = lt(this, t[r], i); 7643 return n; 7644 } 7645 return lt( 7646 this, 7647 /** @type {string} */ 7648 t, 7649 i 7650 ); 7651 } 7652 /** 7653 * @param {string|Array<string>} type Type. 7654 * @param {function((Event|import("./events/Event").default)): ?} listener Listener. 7655 * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key. 7656 * @protected 7657 */ 7658 onceInternal(t, i) { 7659 let s; 7660 if (Array.isArray(t)) { 7661 const n = t.length; 7662 s = new Array(n); 7663 for (let r = 0; r < n; ++r) 7664 s[r] = Po(this, t[r], i); 7665 } else 7666 s = Po( 7667 this, 7668 /** @type {string} */ 7669 t, 7670 i 7671 ); 7672 return i.ol_key = s, s; 7673 } 7674 /** 7675 * Unlisten for a certain type of event. 7676 * @param {string|Array<string>} type Type. 7677 * @param {function((Event|import("./events/Event").default)): ?} listener Listener. 7678 * @protected 7679 */ 7680 unInternal(t, i) { 7681 const s = ( 7682 /** @type {Object} */ 7683 i.ol_key 7684 ); 7685 if (s) 7686 qv(s); 7687 else if (Array.isArray(t)) 7688 for (let n = 0, r = t.length; n < r; ++n) 7689 this.removeEventListener(t[n], i); 7690 else 7691 this.removeEventListener(t, i); 7692 } 7693} 7694ca.prototype.on; 7695ca.prototype.once; 7696ca.prototype.un; 7697function qv(e) { 7698 if (Array.isArray(e)) 7699 for (let t = 0, i = e.length; t < i; ++t) 7700 Mt(e[t]); 7701 else 7702 Mt( 7703 /** @type {import("./events.js").EventsKey} */ 7704 e 7705 ); 7706} 7707const kf = ca; 7708function Z() { 7709 throw new Error("Unimplemented abstract method."); 7710} 7711let Hv = 0; 7712function ot(e) { 7713 return e.ol_uid || (e.ol_uid = String(++Hv)); 7714} 7715class cu extends Ae { 7716 /** 7717 * @param {string} type The event type. 7718 * @param {string} key The property name. 7719 * @param {*} oldValue The old value for `key`. 7720 */ 7721 constructor(t, i, s) { 7722 super(t), this.key = i, this.oldValue = s; 7723 } 7724} 7725class Zv extends kf { 7726 /** 7727 * @param {Object<string, *>} [values] An object with key-value pairs. 7728 */ 7729 constructor(t) { 7730 super(), this.on, this.once, this.un, ot(this), this.values_ = null, t !== void 0 && this.setProperties(t); 7731 } 7732 /** 7733 * Gets a value. 7734 * @param {string} key Key name. 7735 * @return {*} Value. 7736 * @api 7737 */ 7738 get(t) { 7739 let i; 7740 return this.values_ && this.values_.hasOwnProperty(t) && (i = this.values_[t]), i; 7741 } 7742 /** 7743 * Get a list of object property names. 7744 * @return {Array<string>} List of property names. 7745 * @api 7746 */ 7747 getKeys() { 7748 return this.values_ && Object.keys(this.values_) || []; 7749 } 7750 /** 7751 * Get an object of all property names and values. 7752 * @return {Object<string, *>} Object. 7753 * @api 7754 */ 7755 getProperties() { 7756 return this.values_ && Object.assign({}, this.values_) || {}; 7757 } 7758 /** 7759 * @return {boolean} The object has properties. 7760 */ 7761 hasProperties() { 7762 return !!this.values_; 7763 } 7764 /** 7765 * @param {string} key Key name. 7766 * @param {*} oldValue Old value. 7767 */ 7768 notify(t, i) { 7769 let s; 7770 s = `change:${t}`, this.hasListener(s) && this.dispatchEvent(new cu(s, t, i)), s = yn.PROPERTYCHANGE, this.hasListener(s) && this.dispatchEvent(new cu(s, t, i)); 7771 } 7772 /** 7773 * @param {string} key Key name. 7774 * @param {import("./events.js").Listener} listener Listener. 7775 */ 7776 addChangeListener(t, i) { 7777 this.addEventListener(`change:${t}`, i); 7778 } 7779 /** 7780 * @param {string} key Key name. 7781 * @param {import("./events.js").Listener} listener Listener. 7782 */ 7783 removeChangeListener(t, i) { 7784 this.removeEventListener(`change:${t}`, i); 7785 } 7786 /** 7787 * Sets a value. 7788 * @param {string} key Key name. 7789 * @param {*} value Value. 7790 * @param {boolean} [silent] Update without triggering an event. 7791 * @api 7792 */ 7793 set(t, i, s) { 7794 const n = this.values_ || (this.values_ = {}); 7795 if (s) 7796 n[t] = i; 7797 else { 7798 const r = n[t]; 7799 n[t] = i, r !== i && this.notify(t, r); 7800 } 7801 } 7802 /** 7803 * Sets a collection of key-value pairs. Note that this changes any existing 7804 * properties and adds new ones (it does not remove any existing properties). 7805 * @param {Object<string, *>} values Values. 7806 * @param {boolean} [silent] Update without triggering an event. 7807 * @api 7808 */ 7809 setProperties(t, i) { 7810 for (const s in t) 7811 this.set(s, t[s], i); 7812 } 7813 /** 7814 * Apply any properties from another object without triggering events. 7815 * @param {BaseObject} source The source object. 7816 * @protected 7817 */ 7818 applyProperties(t) { 7819 t.values_ && Object.assign(this.values_ || (this.values_ = {}), t.values_); 7820 } 7821 /** 7822 * Unsets a property. 7823 * @param {string} key Key name. 7824 * @param {boolean} [silent] Unset without triggering an event. 7825 * @api 7826 */ 7827 unset(t, i) { 7828 if (this.values_ && t in this.values_) { 7829 const s = this.values_[t]; 7830 delete this.values_[t], un(this.values_) && (this.values_ = null), i || this.notify(t, s); 7831 } 7832 } 7833} 7834const ni = Zv, $t = { 7835 /** 7836 * Triggered when an item is added to the collection. 7837 * @event module:ol/Collection.CollectionEvent#add 7838 * @api 7839 */ 7840 ADD: "add", 7841 /** 7842 * Triggered when an item is removed from the collection. 7843 * @event module:ol/Collection.CollectionEvent#remove 7844 * @api 7845 */ 7846 REMOVE: "remove" 7847}, uu = { 7848 LENGTH: "length" 7849}; 7850class Kr extends Ae { 7851 /** 7852 * @param {import("./CollectionEventType.js").default} type Type. 7853 * @param {T} element Element. 7854 * @param {number} index The index of the added or removed element. 7855 */ 7856 constructor(t, i, s) { 7857 super(t), this.element = i, this.index = s; 7858 } 7859} 7860class Jv extends ni { 7861 /** 7862 * @param {Array<T>} [array] Array. 7863 * @param {Options} [options] Collection options. 7864 */ 7865 constructor(t, i) { 7866 if (super(), this.on, this.once, this.un, i = i || {}, this.unique_ = !!i.unique, this.array_ = t || [], this.unique_) 7867 for (let s = 0, n = this.array_.length; s < n; ++s) 7868 this.assertUnique_(this.array_[s], s); 7869 this.updateLength_(); 7870 } 7871 /** 7872 * Remove all elements from the collection. 7873 * @api 7874 */ 7875 clear() { 7876 for (; this.getLength() > 0; ) 7877 this.pop(); 7878 } 7879 /** 7880 * Add elements to the collection. This pushes each item in the provided array 7881 * to the end of the collection. 7882 * @param {!Array<T>} arr Array. 7883 * @return {Collection<T>} This collection. 7884 * @api 7885 */ 7886 extend(t) { 7887 for (let i = 0, s = t.length; i < s; ++i) 7888 this.push(t[i]); 7889 return this; 7890 } 7891 /** 7892 * Iterate over each element, calling the provided callback. 7893 * @param {function(T, number, Array<T>): *} f The function to call 7894 * for every element. This function takes 3 arguments (the element, the 7895 * index and the array). The return value is ignored. 7896 * @api 7897 */ 7898 forEach(t) { 7899 const i = this.array_; 7900 for (let s = 0, n = i.length; s < n; ++s) 7901 t(i[s], s, i); 7902 } 7903 /** 7904 * Get a reference to the underlying Array object. Warning: if the array 7905 * is mutated, no events will be dispatched by the collection, and the
7906 * collection's "length" property won't be in sync with the actual length 7907 * of the array. 7908 * @return {!Array<T>} Array. 7909 * @api 7910 */ 7911 getArray() { 7912 return this.array_; 7913 } 7914 /** 7915 * Get the element at the provided index. 7916 * @param {number} index Index. 7917 * @return {T} Element. 7918 * @api 7919 */ 7920 item(t) { 7921 return this.array_[t]; 7922 } 7923 /** 7924 * Get the length of this collection. 7925 * @return {number} The length of the array. 7926 * @observable 7927 * @api 7928 */ 7929 getLength() { 7930 return this.get(uu.LENGTH); 7931 } 7932 /** 7933 * Insert an element at the provided index. 7934 * @param {number} index Index. 7935 * @param {T} elem Element. 7936 * @api 7937 */ 7938 insertAt(t, i) { 7939 if (t < 0 || t > this.getLength()) 7940 throw new Error("Index out of bounds: " + t); 7941 this.unique_ && this.assertUnique_(i), this.array_.splice(t, 0, i), this.updateLength_(), this.dispatchEvent( 7942 new Kr($t.ADD, i, t) 7943 ); 7944 } 7945 /** 7946 * Remove the last element of the collection and return it. 7947 * Return `undefined` if the collection is empty. 7948 * @return {T|undefined} Element. 7949 * @api 7950 */ 7951 pop() { 7952 return this.removeAt(this.getLength() - 1); 7953 } 7954 /** 7955 * Insert the provided element at the end of the collection. 7956 * @param {T} elem Element. 7957 * @return {number} New length of the collection. 7958 * @api 7959 */ 7960 push(t) { 7961 this.unique_ && this.assertUnique_(t); 7962 const i = this.getLength(); 7963 return this.insertAt(i, t), this.getLength(); 7964 } 7965 /** 7966 * Remove the first occurrence of an element from the collection. 7967 * @param {T} elem Element. 7968 * @return {T|undefined} The removed element or undefined if none found. 7969 * @api 7970 */ 7971 remove(t) { 7972 const i = this.array_; 7973 for (let s = 0, n = i.length; s < n; ++s) 7974 if (i[s] === t) 7975 return this.removeAt(s); 7976 } 7977 /** 7978 * Remove the element at the provided index and return it. 7979 * Return `undefined` if the collection does not contain this index. 7980 * @param {number} index Index. 7981 * @return {T|undefined} Value. 7982 * @api 7983 */ 7984 removeAt(t) { 7985 if (t < 0 || t >= this.getLength()) 7986 return; 7987 const i = this.array_[t]; 7988 return this.array_.splice(t, 1), this.updateLength_(), this.dispatchEvent( 7989 /** @type {CollectionEvent<T>} */ 7990 new Kr($t.REMOVE, i, t) 7991 ), i; 7992 } 7993 /** 7994 * Set the element at the provided index. 7995 * @param {number} index Index. 7996 * @param {T} elem Element. 7997 * @api 7998 */ 7999 setAt(t, i) { 8000 const s = this.getLength(); 8001 if (t >= s) { 8002 this.insertAt(t, i); 8003 return; 8004 } 8005 if (t < 0) 8006 throw new Error("Index out of bounds: " + t); 8007 this.unique_ && this.assertUnique_(i, t); 8008 const n = this.array_[t]; 8009 this.array_[t] = i, this.dispatchEvent( 8010 /** @type {CollectionEvent<T>} */ 8011 new Kr($t.REMOVE, n, t) 8012 ), this.dispatchEvent( 8013 /** @type {CollectionEvent<T>} */ 8014 new Kr($t.ADD, i, t) 8015 ); 8016 } 8017 /** 8018 * @private 8019 */ 8020 updateLength_() { 8021 this.set(uu.LENGTH, this.array_.length); 8022 } 8023 /** 8024 * @private 8025 * @param {T} elem Element. 8026 * @param {number} [except] Optional index to ignore. 8027 */ 8028 assertUnique_(t, i) { 8029 for (let s = 0, n = this.array_.length; s < n; ++s) 8030 if (this.array_[s] === t && s !== i) 8031 throw new Td(58); 8032 } 8033} 8034const Pe = Jv, Qi = typeof navigator < "u" && typeof navigator.userAgent < "u" ? navigator.userAgent.toLowerCase() : "", Qv = Qi.includes("firefox"), tE = Qi.includes("safari") && !Qi.includes("chrom"); 8035tE && (Qi.includes("version/15.4") || /cpu (os|iphone os) 15_4 like mac os x/.test(Qi)); 8036const eE = Qi.includes("webkit") && !Qi.includes("edge"), iE = Qi.includes("macintosh"), Gf = typeof devicePixelRatio < "u" ? devicePixelRatio : 1, xh = typeof WorkerGlobalScope < "u" && typeof OffscreenCanvas < "u" && self instanceof WorkerGlobalScope, sE = typeof Image < "u" && Image.prototype.decode, zf = function() { 8037 let e = !1; 8038 try { 8039 const t = Object.defineProperty({}, "passive", { 8040 get: function() { 8041 e = !0; 8042 } 8043 }); 8044 window.addEventListener("_", null, t), window.removeEventListener("_", null, t); 8045 } catch { 8046 } 8047 return e; 8048}();
8049new Array(6); 8050function Qe() { 8051 return [1, 0, 0, 1, 0, 0]; 8052} 8053function nE(e, t, i, s, n, r, o) { 8054 return e[0] = t, e[1] = i, e[2] = s, e[3] = n, e[4] = r, e[5] = o, e; 8055} 8056function rE(e, t) { 8057 return e[0] = t[0], e[1] = t[1], e[2] = t[2], e[3] = t[3], e[4] = t[4], e[5] = t[5], e; 8058} 8059function zt(e, t) { 8060 const i = t[0], s = t[1]; 8061 return t[0] = e[0] * i + e[2] * s + e[4], t[1] = e[1] * i + e[3] * s + e[5], t; 8062} 8063function oE(e, t, i) { 8064 return nE(e, t, 0, 0, i, 0, 0); 8065} 8066function si(e, t, i, s, n, r, o, a) { 8067 const l = Math.sin(r), h = Math.cos(r); 8068 return e[0] = s * h, e[1] = n * l, e[2] = -s * l, e[3] = n * h, e[4] = o * s * h - a * s * l + t, e[5] = o * n * l + a * n * h + i, e; 8069} 8070function ua(e, t) { 8071 const i = aE(t); 8072 at(i !== 0, 32); 8073 const s = t[0], n = t[1], r = t[2], o = t[3], a = t[4], l = t[5]; 8074 return e[0] = o / i, e[1] = -n / i, e[2] = -r / i, e[3] = s / i, e[4] = (r * l - o * a) / i, e[5] = -(s * l - n * a) / i, e; 8075} 8076function aE(e) { 8077 return e[0] * e[3] - e[1] * e[2]; 8078} 8079let du; 8080function vh(e) { 8081 const t = "matrix(" + e.join(", ") + ")"; 8082 if (xh) 8083 return t; 8084 const i = du || (du = document.createElement("div")); 8085 return i.style.transform = t, i.style.transform; 8086} 8087const lE = /^#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})$/i, hE = /^([a-z]*)$|^hsla?\(.*\)$/i; 8088function jf(e) { 8089 return typeof e == "string" ? e : Wf(e); 8090} 8091function cE(e) { 8092 const t = document.createElement("div"); 8093 if (t.style.color = e, t.style.color !== "") { 8094 document.body.appendChild(t); 8095 const i = getComputedStyle(t).color; 8096 return document.body.removeChild(t), i; 8097 } 8098 return ""; 8099} 8100const uE = function() { 8101 const t = {}; 8102 let i = 0; 8103 return ( 8104 /** 8105 * @param {string} s String. 8106 * @return {Color} Color. 8107 */ 8108 function(s) { 8109 let n; 8110 if (t.hasOwnProperty(s)) 8111 n = t[s]; 8112 else { 8113 if (i >= 1024) { 8114 let r = 0; 8115 for (const o in t) 8116 r++ & 3 || (delete t[o], --i); 8117 } 8118 n = dE(s), t[s] = n, ++i; 8119 } 8120 return n; 8121 } 8122 ); 8123}(); 8124function Ao(e) { 8125 return Array.isArray(e) ? e : uE(e); 8126} 8127function dE(e) { 8128 let t, i, s, n, r; 8129 if (hE.exec(e) && (e = cE(e)), lE.exec(e)) { 8130 const o = e.length - 1; 8131 let a; 8132 o <= 4 ? a = 1 : a = 2; 8133 const l = o === 4 || o === 8; 8134 t = parseInt(e.substr(1 + 0 * a, a), 16), i = parseInt(e.substr(1 + 1 * a, a), 16), s = parseInt(e.substr(1 + 2 * a, a), 16), l ? n = parseInt(e.substr(1 + 3 * a, a), 16) : n = 255, a == 1 && (t = (t << 4) + t, i = (i << 4) + i, s = (s << 4) + s, l && (n = (n << 4) + n)), r = [t, i, s, n / 255]; 8135 } else 8136 e.startsWith("rgba(") ? (r = e.slice(5, -1).split(",").map(Number), fu(r)) : e.startsWith("rgb(") ? (r = e.slice(4, -1).split(",").map(Number), r.push(1), fu(r)) : at(!1, 14); 8137 return r; 8138} 8139function fu(e) { 8140 return e[0] = Ot(e[0] + 0.5 | 0, 0, 255), e[1] = Ot(e[1] + 0.5 | 0, 0, 255), e[2] = Ot(e[2] + 0.5 | 0, 0, 255), e[3] = Ot(e[3], 0, 1), e; 8141} 8142function Wf(e) { 8143 let t = e[0]; 8144 t != (t | 0) && (t = t + 0.5 | 0); 8145 let i = e[1]; 8146 i != (i | 0) && (i = i + 0.5 | 0); 8147 let s = e[2]; 8148 s != (s | 0) && (s = s + 0.5 | 0); 8149 const n = e[3] === void 0 ? 1 : Math.round(e[3] * 100) / 100; 8150 return "rgba(" + t + "," + i + "," + s + "," + n + ")"; 8151} 8152class fE { 8153 constructor() { 8154 this.cache_ = {}, this.cacheSize_ = 0, this.maxCacheSize_ = 32; 8155 } 8156 /** 8157 * FIXME empty description for jsdoc 8158 */ 8159 clear() { 8160 this.cache_ = {}, this.cacheSize_ = 0; 8161 } 8162 /** 8163 * @return {boolean} Can expire cache. 8164 */ 8165 canExpireCache() { 8166 return this.cacheSize_ > this.maxCacheSize_; 8167 } 8168 /** 8169 * FIXME empty description for jsdoc 8170 */ 8171 expire() { 8172 if (this.canExpireCache()) { 8173 let t = 0; 8174 for (const i in this.cache_) { 8175 const s = this.cache_[i]; 8176 !(t++ & 3) && !s.hasListener() && (delete this.cache_[i], --this.cacheSize_); 8177 } 8178 } 8179 } 8180 /** 8181 * @param {string} src Src. 8182 * @param {?string} crossOrigin Cross origin. 8183 * @param {import("../color.js").Color} color Color. 8184 * @return {import("./IconImage.js").default} Icon image. 8185 */ 8186 get(t, i, s) { 8187 const n = gu(t, i, s); 8188 return n in this.cache_ ? this.cache_[n] : null; 8189 } 8190 /** 8191 * @param {string} src Src. 8192 * @param {?string} crossOrigin Cross origin. 8193 * @param {import("../color.js").Color} color Color. 8194 * @param {import("./IconImage.js").default} iconImage Icon image. 8195 */ 8196 set(t, i, s, n) { 8197 const r = gu(t, i, s); 8198 this.cache_[r] = n, ++this.cacheSize_; 8199 } 8200 /** 8201 * Set the cache size of the icon cache. Default is `32`. Change this value when 8202 * your map uses more than 32 different icon images and you are not caching icon 8203 * styles on the application level. 8204 * @param {number} maxCacheSize Cache max size. 8205 * @api 8206 */ 8207 setSize(t) { 8208 this.maxCacheSize_ = t, this.expire(); 8209 } 8210} 8211function gu(e, t, i) { 8212 const s = i ? jf(i) : "null"; 8213 return t + ":" + e + ":" + s; 8214} 8215const Lo = new fE(), Et = { 8216 OPACITY: "opacity", 8217 VISIBLE: "visible", 8218 EXTENT: "extent", 8219 Z_INDEX: "zIndex", 8220 MAX_RESOLUTION: "maxResolution", 8221 MIN_RESOLUTION: "minResolution", 8222 MAX_ZOOM: "maxZoom", 8223 MIN_ZOOM: "minZoom", 8224 SOURCE: "source", 8225 MAP: "map" 8226}; 8227class gE extends ni { 8228 /** 8229 * @param {Options} options Layer options. 8230 */ 8231 constructor(t) { 8232 super(), this.on, this.once, this.un, this.background_ = t.background; 8233 const i = Object.assign({}, t); 8234 typeof t.properties == "object" && (delete i.properties, Object.assign(i, t.properties)), i[Et.OPACITY] = t.opacity !== void 0 ? t.opacity : 1, at(typeof i[Et.OPACITY] == "number", 64), i[Et.VISIBLE] = t.visible !== void 0 ? t.visible : !0, i[Et.Z_INDEX] = t.zIndex, i[Et.MAX_RESOLUTION] = t.maxResolution !== void 0 ? t.maxResolution : 1 / 0, i[Et.MIN_RESOLUTION] = t.minResolution !== void 0 ? t.minResolution : 0, i[Et.MIN_ZOOM] = t.minZoom !== void 0 ? t.minZoom : -1 / 0, i[Et.MAX_ZOOM] = t.maxZoom !== void 0 ? t.maxZoom : 1 / 0, this.className_ = i.className !== void 0 ? i.className : "ol-layer", delete i.className, this.setProperties(i), this.state_ = null; 8235 } 8236 /** 8237 * Get the background for this layer.
8238 * @return {BackgroundColor|false} Layer background. 8239 */ 8240 getBackground() { 8241 return this.background_; 8242 } 8243 /** 8244 * @return {string} CSS class name. 8245 */ 8246 getClassName() { 8247 return this.className_; 8248 } 8249 /** 8250 * This method is not meant to be called by layers or layer renderers because the state 8251 * is incorrect if the layer is included in a layer group. 8252 * 8253 * @param {boolean} [managed] Layer is managed. 8254 * @return {import("./Layer.js").State} Layer state. 8255 */ 8256 getLayerState(t) { 8257 const i = this.state_ || /** @type {?} */ 8258 { 8259 layer: this, 8260 managed: t === void 0 ? !0 : t 8261 }, s = this.getZIndex(); 8262 return i.opacity = Ot(Math.round(this.getOpacity() * 100) / 100, 0, 1), i.visible = this.getVisible(), i.extent = this.getExtent(), i.zIndex = s === void 0 && !i.managed ? 1 / 0 : s, i.maxResolution = this.getMaxResolution(), i.minResolution = Math.max(this.getMinResolution(), 0), i.minZoom = this.getMinZoom(), i.maxZoom = this.getMaxZoom(), this.state_ = i, i; 8263 } 8264 /** 8265 * @abstract 8266 * @param {Array<import("./Layer.js").default>} [array] Array of layers (to be 8267 * modified in place). 8268 * @return {Array<import("./Layer.js").default>} Array of layers. 8269 */ 8270 getLayersArray(t) { 8271 return Z(); 8272 } 8273 /** 8274 * @abstract 8275 * @param {Array<import("./Layer.js").State>} [states] Optional list of layer 8276 * states (to be modified in place). 8277 * @return {Array<import("./Layer.js").State>} List of layer states. 8278 */ 8279 getLayerStatesArray(t) { 8280 return Z(); 8281 } 8282 /** 8283 * Return the {@link module:ol/extent~Extent extent} of the layer or `undefined` if it 8284 * will be visible regardless of extent. 8285 * @return {import("../extent.js").Extent|undefined} The layer extent. 8286 * @observable 8287 * @api 8288 */ 8289 getExtent() { 8290 return ( 8291 /** @type {import("../extent.js").Extent|undefined} */ 8292 this.get(Et.EXTENT) 8293 ); 8294 } 8295 /** 8296 * Return the maximum resolution of the layer. 8297 * @return {number} The maximum resolution of the layer. 8298 * @observable 8299 * @api 8300 */ 8301 getMaxResolution() { 8302 return ( 8303 /** @type {number} */ 8304 this.get(Et.MAX_RESOLUTION) 8305 ); 8306 } 8307 /** 8308 * Return the minimum resolution of the layer. 8309 * @return {number} The minimum resolution of the layer. 8310 * @observable 8311 * @api 8312 */ 8313 getMinResolution() { 8314 return ( 8315 /** @type {number} */ 8316 this.get(Et.MIN_RESOLUTION) 8317 ); 8318 } 8319 /** 8320 * Return the minimum zoom level of the layer. 8321 * @return {number} The minimum zoom level of the layer. 8322 * @observable 8323 * @api 8324 */ 8325 getMinZoom() { 8326 return ( 8327 /** @type {number} */ 8328 this.get(Et.MIN_ZOOM) 8329 ); 8330 } 8331 /** 8332 * Return the maximum zoom level of the layer. 8333 * @return {number} The maximum zoom level of the layer. 8334 * @observable 8335 * @api 8336 */ 8337 getMaxZoom() { 8338 return ( 8339 /** @type {number} */ 8340 this.get(Et.MAX_ZOOM) 8341 ); 8342 } 8343 /** 8344 * Return the opacity of the layer (between 0 and 1). 8345 * @return {number} The opacity of the layer. 8346 * @observable 8347 * @api 8348 */ 8349 getOpacity() { 8350 return ( 8351 /** @type {number} */ 8352 this.get(Et.OPACITY) 8353 ); 8354 } 8355 /** 8356 * @abstract 8357 * @return {import("../source/Source.js").State} Source state. 8358 */ 8359 getSourceState() { 8360 return Z(); 8361 } 8362 /** 8363 * Return the value of this layer's `visible` property. To find out whether the layer 8364 * is visible on a map, use `isVisible()` instead. 8365 * @return {boolean} The value of the `visible` property of the layer. 8366 * @observable 8367 * @api 8368 */ 8369 getVisible() { 8370 return ( 8371 /** @type {boolean} */ 8372 this.get(Et.VISIBLE) 8373 ); 8374 } 8375 /** 8376 * Return the Z-index of the layer, which is used to order layers before 8377 * rendering. The default Z-index is 0. 8378 * @return {number} The Z-index of the layer. 8379 * @observable 8380 * @api 8381 */ 8382 getZIndex() { 8383 return ( 8384 /** @type {number} */ 8385 this.get(Et.Z_INDEX) 8386 ); 8387 } 8388 /** 8389 * Sets the background color. 8390 * @param {BackgroundColor} [background] Background color. 8391 */ 8392 setBackground(t) { 8393 this.background_ = t, this.changed(); 8394 } 8395 /** 8396 * Set the extent at which the layer is visible. If `undefined`, the layer 8397 * will be visible at all extents. 8398 * @param {import("../extent.js").Extent|undefined} extent The extent of the layer. 8399 * @observable 8400 * @api 8401 */ 8402 setExtent(t) { 8403 this.set(Et.EXTENT, t); 8404 } 8405 /** 8406 * Set the maximum resolution at which the layer is visible. 8407 * @param {number} maxResolution The maximum resolution of the layer. 8408 * @observable 8409 * @api 8410 */ 8411 setMaxResolution(t) { 8412 this.set(Et.MAX_RESOLUTION, t); 8413 } 8414 /** 8415 * Set the minimum resolution at which the layer is visible. 8416 * @param {number} minResolution The minimum resolution of the layer. 8417 * @observable 8418 * @api 8419 */ 8420 setMinResolution(t) { 8421 this.set(Et.MIN_RESOLUTION, t); 8422 } 8423 /** 8424 * Set the maximum zoom (exclusive) at which the layer is visible. 8425 * Note that the zoom levels for layer visibility are based on the 8426 * view zoom level, which may be different from a tile source zoom level. 8427 * @param {number} maxZoom The maximum zoom of the layer. 8428 * @observable 8429 * @api 8430 */ 8431 setMaxZoom(t) { 8432 this.set(Et.MAX_ZOOM, t); 8433 } 8434 /** 8435 * Set the minimum zoom (inclusive) at which the layer is visible. 8436 * Note that the zoom levels for layer visibility are based on the 8437 * view zoom level, which may be different from a tile source zoom level. 8438 * @param {number} minZoom The minimum zoom of the layer. 8439 * @observable 8440 * @api 8441 */ 8442 setMinZoom(t) { 8443 this.set(Et.MIN_ZOOM, t); 8444 } 8445 /** 8446 * Set the opacity of the layer, allowed values range from 0 to 1. 8447 * @param {number} opacity The opacity of the layer. 8448 * @observable 8449 * @api 8450 */ 8451 setOpacity(t) { 8452 at(typeof t == "number", 64), this.set(Et.OPACITY, t); 8453 } 8454 /** 8455 * Set the visibility of the layer (`true` or `false`). 8456 * @param {boolean} visible The visibility of the layer. 8457 * @observable 8458 * @api 8459 */ 8460 setVisible(t) { 8461 this.set(Et.VISIBLE, t); 8462 } 8463 /** 8464 * Set Z-index of the layer, which is used to order layers before rendering. 8465 * The default Z-index is 0. 8466 * @param {number} zindex The z-index of the layer. 8467 * @observable 8468 * @api 8469 */ 8470 setZIndex(t) { 8471 this.set(Et.Z_INDEX, t); 8472 } 8473 /** 8474 * Clean up. 8475 */ 8476 disposeInternal() { 8477 this.state_ && (this.state_.layer = null, this.state_ = null), super.disposeInternal(); 8478 } 8479} 8480const Bf = gE, Vi = { 8481 /** 8482 * Triggered before a layer is rendered. 8483 * @event module:ol/render/Event~RenderEvent#prerender 8484 * @api 8485 */ 8486 PRERENDER: "prerender", 8487 /** 8488 * Triggered after a layer is rendered. 8489 * @event module:ol/render/Event~RenderEvent#postrender 8490 * @api 8491 */ 8492 POSTRENDER: "postrender", 8493 /**
8494 * Triggered before layers are composed. When dispatched by the map, the event object will not have 8495 * a `context` set. When dispatched by a layer, the event object will have a `context` set. Only 8496 * WebGL layers currently dispatch this event. 8497 * @event module:ol/render/Event~RenderEvent#precompose 8498 * @api 8499 */ 8500 PRECOMPOSE: "precompose", 8501 /** 8502 * Triggered after layers are composed. When dispatched by the map, the event object will not have 8503 * a `context` set. When dispatched by a layer, the event object will have a `context` set. Only 8504 * WebGL layers currently dispatch this event. 8505 * @event module:ol/render/Event~RenderEvent#postcompose 8506 * @api 8507 */ 8508 POSTCOMPOSE: "postcompose", 8509 /** 8510 * Triggered when rendering is complete, i.e. all sources and tiles have 8511 * finished loading for the current viewport, and all tiles are faded in. 8512 * The event object will not have a `context` set. 8513 * @event module:ol/render/Event~RenderEvent#rendercomplete 8514 * @api 8515 */ 8516 RENDERCOMPLETE: "rendercomplete" 8517}, Xt = { 8518 ANIMATING: 0, 8519 INTERACTING: 1 8520}, Le = { 8521 CENTER: "center", 8522 RESOLUTION: "resolution", 8523 ROTATION: "rotation" 8524}, _E = 42, Eh = 256; 8525function _u(e, t, i) { 8526 return ( 8527 /** 8528 * @param {import("./coordinate.js").Coordinate|undefined} center Center. 8529 * @param {number|undefined} resolution Resolution. 8530 * @param {import("./size.js").Size} size Viewport size; unused if `onlyCenter` was specified. 8531 * @param {boolean} [isMoving] True if an interaction or animation is in progress. 8532 * @param {Array<number>} [centerShift] Shift between map center and viewport center. 8533 * @return {import("./coordinate.js").Coordinate|undefined} Center. 8534 */ 8535 function(s, n, r, o, a) { 8536 if (!s) 8537 return; 8538 if (!n && !t) 8539 return s; 8540 const l = t ? 0 : r[0] * n, h = t ? 0 : r[1] * n, c = a ? a[0] : 0, u = a ? a[1] : 0; 8541 let d = e[0] + l / 2 + c, f = e[2] - l / 2 + c, g = e[1] + h / 2 + u, _ = e[3] - h / 2 + u; 8542 d > f && (d = (f + d) / 2, f = d), g > _ && (g = (_ + g) / 2, _ = g); 8543 let m = Ot(s[0], d, f), p = Ot(s[1], g, _); 8544 if (o && i && n) { 8545 const y = 30 * n; 8546 m += -y * Math.log(1 + Math.max(0, d - s[0]) / y) + y * Math.log(1 + Math.max(0, s[0] - f) / y), p += -y * Math.log(1 + Math.max(0, g - s[1]) / y) + y * Math.log(1 + Math.max(0, s[1] - _) / y); 8547 } 8548 return [m, p]; 8549 } 8550 ); 8551} 8552function mE(e) { 8553 return e; 8554} 8555function Mh(e, t, i, s) { 8556 const n = mt(t) / i[0], r = Yt(t) / i[1]; 8557 return s ? Math.min(e, Math.max(n, r)) : Math.min(e, Math.min(n, r)); 8558} 8559function Ch(e, t, i) { 8560 let s = Math.min(e, t); 8561 const n = 50; 8562 return s *= Math.log(1 + n * Math.max(0, e / t - 1)) / n + 1, i && (s = Math.max(s, i), s /= Math.log(1 + n * Math.max(0, i / e - 1)) / n + 1), Ot(s, i / 2, t * 2); 8563} 8564function pE(e, t, i, s) { 8565 return t = t !== void 0 ? t : !0, /** 8566 * @param {number|undefined} resolution Resolution. 8567 * @param {number} direction Direction. 8568 * @param {import("./size.js").Size} size Viewport size. 8569 * @param {boolean} [isMoving] True if an interaction or animation is in progress. 8570 * @return {number|undefined} Resolution. 8571 */ 8572 function(n, r, o, a) { 8573 if (n !== void 0) { 8574 const l = e[0], h = e[e.length - 1], c = i ? Mh( 8575 l, 8576 i, 8577 o, 8578 s 8579 ) : l; 8580 if (a) 8581 return t ? Ch( 8582 n, 8583 c, 8584 h 8585 ) : Ot(n, h, c); 8586 const u = Math.min(c, n), d = Math.floor(ha(e, u, r)); 8587 return e[d] > c && d < e.length - 1 ? e[d + 1] : e[d]; 8588 } 8589 }; 8590} 8591function yE(e, t, i, s, n, r) { 8592 return s = s !== void 0 ? s : !0, i = i !== void 0 ? i : 0, /** 8593 * @param {number|undefined} resolution Resolution. 8594 * @param {number} direction Direction. 8595 * @param {import("./size.js").Size} size Viewport size. 8596 * @param {boolean} [isMoving] True if an interaction or animation is in progress. 8597 * @return {number|undefined} Resolution. 8598 */ 8599 function(o, a, l, h) { 8600 if (o !== void 0) { 8601 const c = n ? Mh( 8602 t, 8603 n, 8604 l, 8605 r 8606 ) : t; 8607 if (h) 8608 return s ? Ch( 8609 o, 8610 c, 8611 i 8612 ) : Ot(o, i, c); 8613 const u = 1e-9, d = Math.ceil( 8614 Math.log(t / c) / Math.log(e) - u 8615 ), f = -a * (0.5 - u) + 0.5, g = Math.min(c, o), _ = Math.floor( 8616 Math.log(t / g) / Math.log(e) + f 8617 ), m = Math.max(d, _), p = t / Math.pow(e, m); 8618 return Ot(p, i, c); 8619 } 8620 }; 8621} 8622function mu(e, t, i, s, n) { 8623 return i = i !== void 0 ? i : !0, /** 8624 * @param {number|undefined} resolution Resolution. 8625 * @param {number} direction Direction. 8626 * @param {import("./size.js").Size} size Viewport size. 8627 * @param {boolean} [isMoving] True if an interaction or animation is in progress. 8628 * @return {number|undefined} Resolution. 8629 */ 8630 function(r, o, a, l) { 8631 if (r !== void 0) { 8632 const h = s ? Mh( 8633 e, 8634 s, 8635 a, 8636 n 8637 ) : e; 8638 return !i || !l ? Ot(r, t, h) : Ch( 8639 r, 8640 h, 8641 t 8642 ); 8643 } 8644 }; 8645} 8646function bh(e) { 8647 if (e !== void 0) 8648 return 0; 8649} 8650function pu(e) { 8651 if (e !== void 0) 8652 return e; 8653} 8654function xE(e) { 8655 const t = 2 * Math.PI / e; 8656 return ( 8657 /** 8658 * @param {number|undefined} rotation Rotation. 8659 * @param {boolean} [isMoving] True if an interaction or animation is in progress. 8660 * @return {number|undefined} Rotation. 8661 */ 8662 function(i, s) { 8663 if (s) 8664 return i; 8665 if (i !== void 0) 8666 return i = Math.floor(i / t + 0.5) * t, i; 8667 } 8668 ); 8669} 8670function vE(e) { 8671 return e = e || fo(5), /** 8672 * @param {number|undefined} rotation Rotation. 8673 * @param {boolean} [isMoving] True if an interaction or animation is in progress. 8674 * @return {number|undefined} Rotation. 8675 */ 8676 function(t, i) { 8677 if (i) 8678 return t; 8679 if (t !== void 0) 8680 return Math.abs(t) <= e ? 0 : t; 8681 }; 8682} 8683function Uf(e) { 8684 return Math.pow(e, 3); 8685} 8686function Rn(e) { 8687 return 1 - Uf(1 - e); 8688} 8689function EE(e) { 8690 return 3 * e * e - 2 * e * e * e; 8691} 8692function ME(e) { 8693 return e; 8694} 8695function ps(e, t, i, s, n, r) { 8696 r = r || []; 8697 let o = 0; 8698 for (let a = t; a < i; a += s) { 8699 const l = e[a], h = e[a + 1]; 8700 r[o++] = n[0] * l + n[2] * h + n[4], r[o++] = n[1] * l + n[3] * h + n[5]; 8701 } 8702 return r && r.length != o && (r.length = o), r; 8703} 8704function Sh(e, t, i, s, n, r, o) { 8705 o = o || []; 8706 const a = Math.cos(n), l = Math.sin(n), h = r[0], c = r[1]; 8707 let u = 0; 8708 for (let d = t; d < i; d += s) { 8709 const f = e[d] - h, g = e[d + 1] - c; 8710 o[u++] = h + f * a - g * l, o[u++] = c + f * l + g * a; 8711 for (let _ = d + 2; _ < d + s; ++_) 8712 o[u++] = e[_]; 8713 } 8714 return o && o.length != u && (o.length = u), o; 8715} 8716function CE(e, t, i, s, n, r, o, a) { 8717 a = a || []; 8718 const l = o[0], h = o[1]; 8719 let c = 0; 8720 for (let u = t; u < i; u += s) { 8721 const d = e[u] - l, f = e[u + 1] - h; 8722 a[c++] = l + n * d, a[c++] = h + r * f; 8723 for (let g = u + 2; g < u + s; ++g) 8724 a[c++] = e[g]; 8725 } 8726 return a && a.length != c && (a.length = c), a; 8727} 8728function bE(e, t, i, s, n, r, o) { 8729 o = o || []; 8730 let a = 0; 8731 for (let l = t; l < i; l += s) { 8732 o[a++] = e[l] + n, o[a++] = e[l + 1] + r; 8733 for (let h = l + 2; h < l + s; ++h) 8734 o[a++] = e[h]; 8735 } 8736 return o && o.length != a && (o.length = a), o; 8737} 8738const yu = Qe(); 8739class SE extends ni { 8740 constructor() { 8741 super(), this.extent_ = ve(), this.extentRevision_ = -1, this.simplifiedGeometryMaxMinSquaredTolerance = 0, this.simplifiedGeometryRevision = 0, this.simplifyTransformedInternal = Kv(function(t, i, s) { 8742 if (!s)
8743 return this.getSimplifiedGeometry(i); 8744 const n = this.clone(); 8745 return n.applyTransform(s), n.getSimplifiedGeometry(i); 8746 }); 8747 } 8748 /** 8749 * Get a transformed and simplified version of the geometry. 8750 * @abstract 8751 * @param {number} squaredTolerance Squared tolerance. 8752 * @param {import("../proj.js").TransformFunction} [transform] Optional transform function. 8753 * @return {Geometry} Simplified geometry. 8754 */ 8755 simplifyTransformed(t, i) { 8756 return this.simplifyTransformedInternal( 8757 this.getRevision(), 8758 t, 8759 i 8760 ); 8761 } 8762 /** 8763 * Make a complete copy of the geometry. 8764 * @abstract 8765 * @return {!Geometry} Clone. 8766 */ 8767 clone() { 8768 return Z(); 8769 } 8770 /** 8771 * @abstract 8772 * @param {number} x X. 8773 * @param {number} y Y. 8774 * @param {import("../coordinate.js").Coordinate} closestPoint Closest point. 8775 * @param {number} minSquaredDistance Minimum squared distance. 8776 * @return {number} Minimum squared distance. 8777 */ 8778 closestPointXY(t, i, s, n) { 8779 return Z(); 8780 } 8781 /** 8782 * @param {number} x X. 8783 * @param {number} y Y. 8784 * @return {boolean} Contains (x, y). 8785 */ 8786 containsXY(t, i) { 8787 const s = this.getClosestPoint([t, i]); 8788 return s[0] === t && s[1] === i; 8789 } 8790 /** 8791 * Return the closest point of the geometry to the passed point as 8792 * {@link module:ol/coordinate~Coordinate coordinate}. 8793 * @param {import("../coordinate.js").Coordinate} point Point. 8794 * @param {import("../coordinate.js").Coordinate} [closestPoint] Closest point. 8795 * @return {import("../coordinate.js").Coordinate} Closest point. 8796 * @api 8797 */ 8798 getClosestPoint(t, i) { 8799 return i = i || [NaN, NaN], this.closestPointXY(t[0], t[1], i, 1 / 0), i; 8800 } 8801 /** 8802 * Returns true if this geometry includes the specified coordinate. If the 8803 * coordinate is on the boundary of the geometry, returns false. 8804 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 8805 * @return {boolean} Contains coordinate. 8806 * @api 8807 */ 8808 intersectsCoordinate(t) { 8809 return this.containsXY(t[0], t[1]); 8810 } 8811 /** 8812 * @abstract 8813 * @param {import("../extent.js").Extent} extent Extent. 8814 * @protected 8815 * @return {import("../extent.js").Extent} extent Extent. 8816 */ 8817 computeExtent(t) { 8818 return Z(); 8819 } 8820 /** 8821 * Get the extent of the geometry. 8822 * @param {import("../extent.js").Extent} [extent] Extent. 8823 * @return {import("../extent.js").Extent} extent Extent. 8824 * @api 8825 */ 8826 getExtent(t) { 8827 if (this.extentRevision_ != this.getRevision()) { 8828 const i = this.computeExtent(this.extent_); 8829 (isNaN(i[0]) || isNaN(i[1])) && bn(i), this.extentRevision_ = this.getRevision(); 8830 } 8831 return Wy(this.extent_, t); 8832 } 8833 /** 8834 * Rotate the geometry around a given coordinate. This modifies the geometry 8835 * coordinates in place. 8836 * @abstract 8837 * @param {number} angle Rotation angle in radians. 8838 * @param {import("../coordinate.js").Coordinate} anchor The rotation center. 8839 * @api 8840 */ 8841 rotate(t, i) { 8842 Z(); 8843 } 8844 /** 8845 * Scale the geometry (with an optional origin). This modifies the geometry 8846 * coordinates in place. 8847 * @abstract 8848 * @param {number} sx The scaling factor in the x-direction. 8849 * @param {number} [sy] The scaling factor in the y-direction (defaults to sx). 8850 * @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center 8851 * of the geometry extent). 8852 * @api 8853 */ 8854 scale(t, i, s) { 8855 Z(); 8856 } 8857 /** 8858 * Create a simplified version of this geometry. For linestrings, this uses 8859 * the [Douglas Peucker](https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm) 8860 * algorithm. For polygons, a quantization-based 8861 * simplification is used to preserve topology. 8862 * @param {number} tolerance The tolerance distance for simplification. 8863 * @return {Geometry} A new, simplified version of the original geometry. 8864 * @api 8865 */ 8866 simplify(t) { 8867 return this.getSimplifiedGeometry(t * t); 8868 } 8869 /** 8870 * Create a simplified version of this geometry using the Douglas Peucker 8871 * algorithm. 8872 * See https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm. 8873 * @abstract 8874 * @param {number} squaredTolerance Squared tolerance. 8875 * @return {Geometry} Simplified geometry. 8876 */ 8877 getSimplifiedGeometry(t) { 8878 return Z(); 8879 } 8880 /** 8881 * Get the type of this geometry. 8882 * @abstract 8883 * @return {Type} Geometry type. 8884 */ 8885 getType() { 8886 return Z(); 8887 } 8888 /** 8889 * Apply a transform function to the coordinates of the geometry. 8890 * The geometry is modified in place. 8891 * If you do not want the geometry modified in place, first `clone()` it and 8892 * then use this function on the clone. 8893 * @abstract 8894 * @param {import("../proj.js").TransformFunction} transformFn Transform function. 8895 * Called with a flat array of geometry coordinates. 8896 */ 8897 applyTransform(t) { 8898 Z(); 8899 } 8900 /** 8901 * Test if the geometry and the passed extent intersect. 8902 * @abstract 8903 * @param {import("../extent.js").Extent} extent Extent. 8904 * @return {boolean} `true` if the geometry and the extent intersect. 8905 */ 8906 intersectsExtent(t) { 8907 return Z(); 8908 } 8909 /** 8910 * Translate the geometry. This modifies the geometry coordinates in place. If 8911 * instead you want a new geometry, first `clone()` this geometry. 8912 * @abstract 8913 * @param {number} deltaX Delta X. 8914 * @param {number} deltaY Delta Y. 8915 * @api 8916 */ 8917 translate(t, i) { 8918 Z(); 8919 } 8920 /** 8921 * Transform each coordinate of the geometry from one coordinate reference 8922 * system to another. The geometry is modified in place. 8923 * For example, a line will be transformed to a line and a circle to a circle. 8924 * If you do not want the geometry modified in place, first `clone()` it and 8925 * then use this function on the clone. 8926 * 8927 * @param {import("../proj.js").ProjectionLike} source The current projection. Can be a 8928 * string identifier or a {@link module:ol/proj/Projection~Projection} object. 8929 * @param {import("../proj.js").ProjectionLike} destination The desired projection. Can be a 8930 * string identifier or a {@link module:ol/proj/Projection~Projection} object. 8931 * @return {Geometry} This geometry. Note that original geometry is 8932 * modified in place. 8933 * @api 8934 */ 8935 transform(t, i) { 8936 const s = Rt(t), n = s.getUnits() == "tile-pixels" ? function(r, o, a) { 8937 const l = s.getExtent(), h = s.getWorldExtent(), c = Yt(h) / Yt(l); 8938 return si( 8939 yu, 8940 h[0], 8941 h[3], 8942 c, 8943 -c, 8944 0, 8945 0, 8946 0 8947 ), ps( 8948 r, 8949 0, 8950 r.length, 8951 a, 8952 yu, 8953 o 8954 ), ir(s, i)( 8955 r, 8956 o, 8957 a 8958 ); 8959 } : ir(s, i); 8960 return this.applyTransform(n), this; 8961 } 8962} 8963const Xf = SE; 8964class ts extends Xf { 8965 constructor() { 8966 super(), this.layout = "XY", this.stride = 2, this.flatCoordinates = null; 8967 } 8968 /** 8969 * @param {import("../extent.js").Extent} extent Extent. 8970 * @protected 8971 * @return {import("../extent.js").Extent} extent Extent. 8972 */ 8973 computeExtent(t) { 8974 return Id( 8975 this.flatCoordinates, 8976 0, 8977 this.flatCoordinates.length, 8978 this.stride, 8979 t 8980 ); 8981 } 8982 /** 8983 * @abstract 8984 * @return {Array<*> | null} Coordinates. 8985 */ 8986 getCoordinates() { 8987 return Z(); 8988 } 8989 /** 8990 * Return the first coordinate of the geometry. 8991 * @return {import("../coordinate.js").Coordinate} First coordinate. 8992 * @api 8993 */ 8994 getFirstCoordinate() { 8995 return this.flatCoordinates.slice(0, this.stride); 8996 } 8997 /** 8998 * @return {Array<number>} Flat coordinates. 8999 */ 9000 getFlatCoordinates() { 9001 return this.flatCoordinates; 9002 } 9003 /** 9004 * Return the last coordinate of the geometry. 9005 * @return {import("../coordinate.js").Coordinate} Last point. 9006 * @api 9007 */ 9008 getLastCoordinate() { 9009 return this.flatCoordinates.slice( 9010 this.flatCoordinates.length - this.stride 9011 ); 9012 } 9013 /** 9014 * Return the {@link import("./Geometry.js").GeometryLayout layout} of the geometry. 9015 * @return {import("./Geometry.js").GeometryLayout} Layout. 9016 * @api 9017 */ 9018 getLayout() { 9019 return this.layout; 9020 } 9021 /** 9022 * Create a simplified version of this geometry using the Douglas Peucker algorithm. 9023 * @param {number} squaredTolerance Squared tolerance. 9024 * @return {SimpleGeometry} Simplified geometry. 9025 */ 9026 getSimplifiedGeometry(t) { 9027 if (this.simplifiedGeometryRevision !== this.getRevision() && (this.simplifiedGeometryMaxMinSquaredTolerance = 0, this.simplifiedGeometryRevision = this.getRevision()), t
9027< 0 || this.simplifiedGeometryMaxMinSquaredTolerance !== 0 && t <= this.simplifiedGeometryMaxMinSquaredTolerance) 9028 return this; 9029 const i = this.getSimplifiedGeometryInternal(t); 9030 return i.getFlatCoordinates().length < this.flatCoordinates.length ? i : (this.simplifiedGeometryMaxMinSquaredTolerance = t, this); 9031 } 9032 /** 9033 * @param {number} squaredTolerance Squared tolerance. 9034 * @return {SimpleGeometry} Simplified geometry. 9035 * @protected 9036 */ 9037 getSimplifiedGeometryInternal(t) { 9038 return this; 9039 } 9040 /** 9041 * @return {number} Stride. 9042 */ 9043 getStride() { 9044 return this.stride; 9045 } 9046 /** 9047 * @param {import("./Geometry.js").GeometryLayout} layout Layout. 9048 * @param {Array<number>} flatCoordinates Flat coordinates. 9049 */ 9050 setFlatCoordinates(t, i) { 9051 this.stride = Oo(t), this.layout = t, this.flatCoordinates = i; 9052 } 9053 /** 9054 * @abstract 9055 * @param {!Array<*>} coordinates Coordinates. 9056 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 9057 */ 9058 setCoordinates(t, i) { 9059 Z(); 9060 } 9061 /** 9062 * @param {import("./Geometry.js").GeometryLayout|undefined} layout Layout. 9063 * @param {Array<*>} coordinates Coordinates. 9064 * @param {number} nesting Nesting. 9065 * @protected 9066 */ 9067 setLayout(t, i, s) { 9068 let n; 9069 if (t) 9070 n = Oo(t); 9071 else { 9072 for (let r = 0; r < s; ++r) { 9073 if (i.length === 0) { 9074 this.layout = "XY", this.stride = 2; 9075 return; 9076 } 9077 i = /** @type {Array} */ 9078 i[0]; 9079 } 9080 n = i.length, t = wE(n); 9081 } 9082 this.layout = t, this.stride = n; 9083 } 9084 /** 9085 * Apply a transform function to the coordinates of the geometry. 9086 * The geometry is modified in place. 9087 * If you do not want the geometry modified in place, first `clone()` it and 9088 * then use this function on the clone. 9089 * @param {import("../proj.js").TransformFunction} transformFn Transform function. 9090 * Called with a flat array of geometry coordinates. 9091 * @api 9092 */ 9093 applyTransform(t) { 9094 this.flatCoordinates && (t(this.flatCoordinates, this.flatCoordinates, this.stride), this.changed()); 9095 } 9096 /** 9097 * Rotate the geometry around a given coordinate. This modifies the geometry 9098 * coordinates in place. 9099 * @param {number} angle Rotation angle in counter-clockwise radians. 9100 * @param {import("../coordinate.js").Coordinate} anchor The rotation center. 9101 * @api 9102 */ 9103 rotate(t, i) { 9104 const s = this.getFlatCoordinates(); 9105 if (s) { 9106 const n = this.getStride(); 9107 Sh( 9108 s, 9109 0, 9110 s.length, 9111 n, 9112 t, 9113 i, 9114 s 9115 ), this.changed(); 9116 } 9117 } 9118 /** 9119 * Scale the geometry (with an optional origin). This modifies the geometry 9120 * coordinates in place. 9121 * @param {number} sx The scaling factor in the x-direction. 9122 * @param {number} [sy] The scaling factor in the y-direction (defaults to sx). 9123 * @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center 9124 * of the geometry extent). 9125 * @api 9126 */ 9127 scale(t, i, s) { 9128 i === void 0 && (i = t), s || (s = ii(this.getExtent())); 9129 const n = this.getFlatCoordinates(); 9130 if (n) { 9131 const r = this.getStride(); 9132 CE( 9133 n, 9134 0, 9135 n.length, 9136 r, 9137 t, 9138 i, 9139 s, 9140 n 9141 ), this.changed(); 9142 } 9143 } 9144 /** 9145 * Translate the geometry. This modifies the geometry coordinates in place. If 9146 * instead you want a new geometry, first `clone()` this geometry. 9147 * @param {number} deltaX Delta X. 9148 * @param {number} deltaY Delta Y. 9149 * @api 9150 */ 9151 translate(t, i) { 9152 const s = this.getFlatCoordinates(); 9153 if (s) { 9154 const n = this.getStride(); 9155 bE( 9156 s, 9157 0, 9158 s.length, 9159 n, 9160 t, 9161 i, 9162 s 9163 ), this.changed(); 9164 } 9165 } 9166} 9167function wE(e) { 9168 let t; 9169 return e == 2 ? t = "XY" : e == 3 ? t = "XYZ" : e == 4 && (t = "XYZM"), /** @type {import("./Geometry.js").GeometryLayout} */ 9170 t; 9171} 9172function Oo(e) { 9173 let t; 9174 return e == "XY" ? t = 2 : e == "XYZ" || e == "XYM" ? t = 3 : e == "XYZM" && (t = 4), /** @type {number} */ 9175 t; 9176} 9177function TE(e, t, i) { 9178 const s = e.getFlatCoordinates(); 9179 if (!s) 9180 return null; 9181 const n = e.getStride(); 9182 return ps( 9183 s, 9184 0, 9185 s.length, 9186 n, 9187 t, 9188 i 9189 ); 9190} 9191function xu(e, t, i, s, n, r, o) { 9192 const a = e[t], l = e[t + 1], h = e[i] - a, c = e[i + 1] - l; 9193 let u; 9194 if (h === 0 && c === 0) 9195 u = t; 9196 else { 9197 const d = ((n - a) * h + (r - l) * c) / (h * h + c * c); 9198 if (d > 1) 9199 u = i; 9200 else if (d > 0) { 9201 for (let f = 0; f < s; ++f) 9202 o[f] = we( 9203 e[t + f], 9204 e[i + f], 9205 d 9206 ); 9207 o.length = s; 9208 return; 9209 } else 9210 u = t; 9211 } 9212 for (let d = 0; d < s; ++d) 9213 o[d] = e[u + d]; 9214 o.length = s; 9215} 9216function wh(e, t, i, s, n) { 9217 let r = e[t], o = e[t + 1]; 9218 for (t += s; t < i; t += s) { 9219 const a = e[t], l = e[t + 1], h = fi(r, o, a, l); 9220 h > n && (n = h), r = a, o = l; 9221 } 9222 return n; 9223} 9224function Th(e, t, i, s, n) { 9225 for (let r = 0, o = i.length; r < o; ++r) { 9226 const a = i[r]; 9227 n = wh(e, t, a, s, n), t = a; 9228 } 9229 return n; 9230} 9231function RE(e, t, i, s, n) { 9232 for (let r = 0, o = i.length; r < o; ++r) { 9233 const a = i[r]; 9234 n = Th(e, t, a, s, n), t = a[a.length - 1]; 9235 } 9236 return n; 9237} 9238function Rh(e, t, i, s, n, r, o, a, l, h, c) { 9239 if (t == i) 9240 return h; 9241 let u, d; 9242 if (n === 0) { 9243 if (d = fi( 9244 o, 9245 a, 9246 e[t], 9247 e[t + 1] 9248 ), d < h) { 9249 for (u = 0; u < s; ++u) 9250 l[u] = e[t + u]; 9251 return l.length = s, d; 9252 } 9253 return h; 9254 } 9255 c = c || [NaN, NaN]; 9256 let f = t + s; 9257 for (; f < i; ) 9258 if (xu( 9259 e, 9260 f - s, 9261 f, 9262 s, 9263 o, 9264 a, 9265 c 9266 ), d = fi(o, a, c[0], c[1]), d < h) { 9267 for (h = d, u = 0; u < s; ++u) 9268 l[u] = c[u]; 9269 l.length = s, f += s; 9270 } else 9271 f += s * Math.max( 9272 (Math.sqrt(d) - Math.sqrt(h)) / n | 0, 9273 1 9274 ); 9275 if (r && (xu( 9276 e, 9277 i - s, 9278 t, 9279 s, 9280 o, 9281 a, 9282 c 9283 ), d = fi(o, a, c[0], c[1]), d < h)) { 9284 for (h = d, u = 0; u < s; ++u) 9285 l[u] = c[u]; 9286 l.length = s; 9287 } 9288 return h; 9289} 9290function Ih(e, t, i, s, n, r, o, a, l, h, c) { 9291 c = c || [NaN, NaN]; 9292 for (let u = 0, d = i.length; u < d; ++u) { 9293 const f = i[u]; 9294 h = Rh( 9295 e, 9296 t, 9297 f, 9298 s, 9299 n, 9300 r, 9301 o, 9302 a, 9303 l, 9304 h, 9305 c 9306 ), t = f; 9307 } 9308 return h; 9309} 9310function IE(e, t, i, s, n, r, o, a, l, h, c) { 9311 c = c || [NaN, NaN]; 9312 for (let u = 0, d = i.length; u < d; ++u) { 9313 const f = i[u]; 9314 h = Ih( 9315 e, 9316 t, 9317 f, 9318 s, 9319 n, 9320 r, 9321 o, 9322 a, 9323 l, 9324 h, 9325 c 9326 ), t = f[f.length - 1]; 9327 } 9328 return h; 9329} 9330function $f(e, t, i, s) { 9331 for (let n = 0, r = i.length; n < r; ++n) 9332 e[t++] = i[n]; 9333 return t; 9334} 9335function da(e, t, i, s) { 9336 for (let n = 0, r = i.length; n < r; ++n) { 9337 const o = i[n]; 9338 for (let a = 0; a < s; ++a) 9339 e[t++] = o[a]; 9340 } 9341 return t; 9342} 9343function Ph(e, t, i, s, n) { 9344 n = n || []; 9345 let r = 0; 9346 for (let o = 0, a = i.length; o < a; ++o) { 9347 const l = da( 9348 e, 9349 t, 9350 i[o], 9351 s 9352 ); 9353 n[r++] = l, t = l; 9354 } 9355 return n.length = r, n; 9356} 9357function PE(e, t, i, s, n) { 9358 n = n || []; 9359 let r = 0; 9360 for (let o = 0, a = i.length; o < a; ++o) { 9361 const l = Ph( 9362 e, 9363 t, 9364 i[o], 9365 s, 9366 n[r] 9367 ); 9368 l.length === 0 && (l[0] = t), n[r++] = l, t = l[l.length - 1]; 9369 } 9370 return n.length = r, n; 9371} 9372function Ah(e, t, i, s, n, r, o) { 9373 const a = (i - t) / s; 9374 if (a < 3) { 9375 for (; t < i; t += s) 9376 r[o++] = e[t], r[o++] = e[t + 1]; 9377 return o; 9378 } 9379 const l = new Array(a); 9380 l[0] = 1, l[a - 1] = 1; 9381 const h = [t, i - s]; 9382 let c = 0; 9383 for (; h.length > 0; ) { 9384 const u = h.pop(), d = h.pop(); 9385 let f = 0; 9386 const g = e[d], _ = e[d + 1], m = e[u], p = e[u + 1]; 9387 for (let y = d + s; y < u; y += s) { 9388 const v = e[y], E = e[y + 1], C = $y(v, E, g, _, m, p); 9389 C > f && (c = y, f = C); 9390 } 9391 f > n && (l[(c - t) / s] = 1, d + s < c && h.push(d, c), c + s < u && h.push(c, u)); 9392 } 9393 for (let u = 0; u < a; ++u) 9394 l[u] && (r[o++] = e[t + u * s], r[o++] = e[t + u * s + 1]); 9395 return o; 9396} 9397function AE(e, t, i, s, n, r, o, a) { 9398 for (let l = 0, h = i.length; l < h; ++l) { 9399 const c = i[l]; 9400 o = Ah( 9401 e, 9402 t, 9403 c, 9404 s, 9405 n, 9406 r, 9407 o 9408 ), a.push(o), t = c; 9409 } 9410 return o; 9411} 9412function as(e, t) { 9413 return t * Math.round(e / t); 9414} 9415function LE(e, t, i, s, n, r, o) { 9416 if (t == i) 9417 return o; 9418 let a = as(e[t], n), l = as(e[t + 1], n); 9419 t += s, r[o++] = a, r[o++] = l; 9420 let h, c; 9421 do 9422 if (h = as(e[t], n), c = as(e[t + 1], n), t += s, t == i) 9423 return r[o++] = h, r[o++] = c, o; 9424 while (h == a && c == l); 9425 for (; t < i; ) { 9426 const u = as(e[t], n), d = as(e[t + 1], n); 9427 if (t += s, u == h && d == c) 9428 continue; 9429 const f = h - a, g = c - l, _ = u - a, m = d - l; 9430 if (f * m == g * _ && (f < 0 && _ < f || f == _ || f > 0 && _ > f) && (g < 0 && m < g || g == m || g > 0 && m > g)) { 9431 h = u, c = d; 9432 continue; 9433 } 9434 r[o++] = h, r[o++] = c, a = h, l = c, h = u, c = d; 9435 } 9436 return r[o++] = h, r[o++] = c, o; 9437} 9438function Yf(e, t, i, s, n, r, o, a) { 9439 for (let l = 0, h = i.length; l < h; ++l) { 9440 const c = i[l]; 9441 o = LE( 9442 e, 9443 t, 9444 c, 9445 s, 9446 n, 9447 r, 9448 o 9449 ), a.push(o), t = c; 9450 } 9451 return o; 9452} 9453function OE(e, t, i, s, n, r, o, a) { 9454 for (let l = 0, h = i.length; l < h; ++l) { 9455 const c = i[l], u = []; 9456 o = Yf( 9457 e, 9458 t, 9459 c, 9460 s, 9461 n, 9462 r, 9463 o, 9464 u 9465 ), a.push(u), t = c[c.length - 1]; 9466 } 9467 return o; 9468} 9469function ji(e, t, i, s, n) { 9470 n = n !== void 0 ? n : []; 9471 let r = 0; 9472 for (let o = t; o < i; o += s) 9473 n[r++] = e.slice(o, o + s); 9474 return n.length = r, n; 9475} 9476function lr(e, t, i, s, n) { 9477 n = n !== void 0 ? n : []; 9478 let r = 0; 9479 for (let o = 0, a = i.length; o < a; ++o) { 9480 const l = i[o]; 9481 n[r++] = ji( 9482 e, 9483 t, 9484 l, 9485 s, 9486 n[r] 9487 ), t = l; 9488 } 9489 return n.length = r, n; 9490} 9491function Cl(e, t, i, s, n) { 9492 n = n !== void 0 ? n : []; 9493 let r = 0; 9494 for (let o = 0, a = i.length; o < a; ++o) { 9495 const l = i[o]; 9496 n[r++] = l.length === 1 && l[0] === t ? [] : lr( 9497 e, 9498 t, 9499 l, 9500 s, 9501 n[r] 9502 ), t = l[l.length - 1]; 9503 } 9504 return n.length = r, n; 9505} 9506function Kf(e, t, i, s) { 9507 let n = 0, r = e[i - s], o = e[i - s + 1]; 9508 for (; t < i; t += s) { 9509 const a = e[t], l = e[t + 1]; 9510 n += o * a - r * l, r = a, o = l; 9511 } 9512 return n / 2; 9513} 9514function Vf(e, t, i, s) { 9515 let n = 0; 9516 for (let r = 0, o = i.length; r < o; ++r) { 9517 const a = i[r]; 9518 n += Kf(e, t, a, s), t = a; 9519 } 9520 return n; 9521} 9522function FE(e, t, i, s) { 9523 let n = 0; 9524 for (let r = 0, o = i.length; r < o; ++r) { 9525 const a = i[r]; 9526 n += Vf(e, t, a, s), t = a[a.length - 1]; 9527 } 9528 return n; 9529} 9530class Fo extends ts { 9531 /** 9532 * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates. 9533 * For internal use, flat coordinates in combination with `layout` are also accepted. 9534 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 9535 */ 9536 constructor(t, i) { 9537 super(), this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, i !== void 0 && !Array.isArray(t[0]) ? this.setFlatCoordinates( 9538 i, 9539 /** @type {Array<number>} */ 9540 t 9541 ) : this.setCoordinates( 9542 /** @type {Array<import("../coordinate.js").Coordinate>} */ 9543 t, 9544 i 9545 ); 9546 } 9547 /** 9548 * Make a complete copy of the geometry. 9549 * @return {!LinearRing} Clone. 9550 * @api 9551 */ 9552 clone() { 9553 return new Fo(this.flatCoordinates.slice(), this.layout); 9554 } 9555 /** 9556 * @param {number} x X. 9557 * @param {number} y Y. 9558 * @param {import("../coordinate.js").Coordinate} closestPoint Closest point. 9559 * @param {number} minSquaredDistance Minimum squared distance. 9560 * @return {number} Minimum squared distance. 9561 */ 9562 closestPointXY(t, i, s, n) { 9563 return n < Ss(this.getExtent(), t, i) ? n : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt( 9564 wh( 9565 this.flatCoordinates, 9566 0, 9567 this.flatCoordinates.length, 9568 this.stride, 9569 0 9570 ) 9571 ), this.maxDeltaRevision_ = this.getRevision()), Rh( 9572 this.flatCoordinates, 9573 0, 9574 this.flatCoordinates.length, 9575 this.stride, 9576 this.maxDelta_, 9577 !0, 9578 t, 9579 i, 9580 s, 9581 n 9582 )); 9583 } 9584 /** 9585 * Return the area of the linear ring on projected plane. 9586 * @return {number} Area (on projected plane). 9587 * @api 9588 */ 9589 getArea() { 9590 return Kf( 9591 this.flatCoordinates, 9592 0, 9593 this.flatCoordinates.length, 9594 this.stride 9595 ); 9596 } 9597 /** 9598 * Return the coordinates of the linear ring. 9599 * @return {Array<import("../coordinate.js").Coordinate>} Coordinates. 9600 * @api 9601 */ 9602 getCoordinates() { 9603 return ji( 9604 this.flatCoordinates, 9605 0, 9606 this.flatCoordinates.length, 9607 this.stride 9608 ); 9609 } 9610 /** 9611 * @param {number} squaredTolerance Squared tolerance. 9612 * @return {LinearRing} Simplified LinearRing. 9613 * @protected 9614 */ 9615 getSimplifiedGeometryInternal(t) { 9616 const i = []; 9617 return i.length = Ah( 9618 this.flatCoordinates, 9619 0, 9620 this.flatCoordinates.length, 9621 this.stride, 9622 t, 9623 i, 9624 0 9625 ), new Fo(i, "XY"); 9626 } 9627 /** 9628 * Get the type of this geometry. 9629 * @return {import("./Geometry.js").Type} Geometry type. 9630 * @api 9631 */ 9632 getType() { 9633 return "LinearRing"; 9634 } 9635 /** 9636 * Test if the geometry and the passed extent intersect. 9637 * @param {import("../extent.js").Extent} extent Extent. 9638 * @return {boolean} `true` if the geometry and the extent intersect. 9639 * @api 9640 */ 9641 intersectsExtent(t) { 9642 return !1; 9643 } 9644 /** 9645 * Set the coordinates of the linear ring. 9646 * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates. 9647 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 9648 * @api 9649 */ 9650 setCoordinates(t, i) { 9651 this.setLayout(i, t, 1), this.flatCoordinates || (this.flatCoordinates = []), this.flatCoordinates.length = da( 9652 this.flatCoordinates, 9653 0, 9654 t, 9655 this.stride 9656 ), this.changed(); 9657 } 9658} 9659const vu = Fo; 9660class Lh extends ts { 9661 /** 9662 * @param {import("../coordinate.js").Coordinate} coordinates Coordinates. 9663 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 9664 */ 9665 constructor(t, i) { 9666 super(), this.setCoordinates(t, i); 9667 } 9668 /** 9669 * Make a complete copy of the geometry. 9670 * @return {!Point} Clone. 9671 * @api 9672 */ 9673 clone() { 9674 const t = new Lh(this.flatCoordinates.slice(), this.layout); 9675 return t.applyProperties(this), t;
9676 } 9677 /** 9678 * @param {number} x X. 9679 * @param {number} y Y. 9680 * @param {import("../coordinate.js").Coordinate} closestPoint Closest point. 9681 * @param {number} minSquaredDistance Minimum squared distance. 9682 * @return {number} Minimum squared distance. 9683 */ 9684 closestPointXY(t, i, s, n) { 9685 const r = this.flatCoordinates, o = fi( 9686 t, 9687 i, 9688 r[0], 9689 r[1] 9690 ); 9691 if (o < n) { 9692 const a = this.stride; 9693 for (let l = 0; l < a; ++l) 9694 s[l] = r[l]; 9695 return s.length = a, o; 9696 } 9697 return n; 9698 } 9699 /** 9700 * Return the coordinate of the point. 9701 * @return {import("../coordinate.js").Coordinate} Coordinates. 9702 * @api 9703 */ 9704 getCoordinates() { 9705 return this.flatCoordinates ? this.flatCoordinates.slice() : []; 9706 } 9707 /** 9708 * @param {import("../extent.js").Extent} extent Extent. 9709 * @protected 9710 * @return {import("../extent.js").Extent} extent Extent. 9711 */ 9712 computeExtent(t) { 9713 return uo(this.flatCoordinates, t); 9714 } 9715 /** 9716 * Get the type of this geometry. 9717 * @return {import("./Geometry.js").Type} Geometry type. 9718 * @api 9719 */ 9720 getType() { 9721 return "Point"; 9722 } 9723 /** 9724 * Test if the geometry and the passed extent intersect. 9725 * @param {import("../extent.js").Extent} extent Extent. 9726 * @return {boolean} `true` if the geometry and the extent intersect. 9727 * @api 9728 */ 9729 intersectsExtent(t) { 9730 return Ul(t, this.flatCoordinates[0], this.flatCoordinates[1]); 9731 } 9732 /** 9733 * @param {!Array<*>} coordinates Coordinates. 9734 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 9735 * @api 9736 */ 9737 setCoordinates(t, i) { 9738 this.setLayout(i, t, 0), this.flatCoordinates || (this.flatCoordinates = []), this.flatCoordinates.length = $f( 9739 this.flatCoordinates, 9740 0, 9741 t, 9742 this.stride 9743 ), this.changed(); 9744 } 9745} 9746const pi = Lh; 9747function DE(e, t, i, s, n) { 9748 return !Xl( 9749 n, 9750 /** 9751 * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate. 9752 * @return {boolean} Contains (x, y). 9753 */ 9754 function(o) { 9755 return !cs( 9756 e, 9757 t, 9758 i, 9759 s, 9760 o[0], 9761 o[1] 9762 ); 9763 } 9764 ); 9765} 9766function cs(e, t, i, s, n, r) { 9767 let o = 0, a = e[i - s], l = e[i - s + 1]; 9768 for (; t < i; t += s) { 9769 const h = e[t], c = e[t + 1]; 9770 l <= r ? c > r && (h - a) * (r - l) - (n - a) * (c - l) > 0 && o++ : c <= r && (h - a) * (r - l) - (n - a) * (c - l) < 0 && o--, a = h, l = c; 9771 } 9772 return o !== 0; 9773} 9774function Oh(e, t, i, s, n, r) { 9775 if (i.length === 0 || !cs(e, t, i[0], s, n, r)) 9776 return !1; 9777 for (let o = 1, a = i.length; o < a; ++o) 9778 if (cs(e, i[o - 1], i[o], s, n, r)) 9779 return !1; 9780 return !0; 9781} 9782function NE(e, t, i, s, n, r) { 9783 if (i.length === 0) 9784 return !1; 9785 for (let o = 0, a = i.length; o < a; ++o) { 9786 const l = i[o]; 9787 if (Oh(e, t, l, s, n, r)) 9788 return !0; 9789 t = l[l.length - 1]; 9790 } 9791 return !1; 9792} 9793function qf(e, t, i, s, n, r, o) { 9794 let a, l, h, c, u, d, f; 9795 const g = n[r + 1], _ = []; 9796 for (let y = 0, v = i.length; y < v; ++y) { 9797 const E = i[y]; 9798 for (c = e[E - s], d = e[E - s + 1], a = t; a < E; a += s) 9799 u = e[a], f = e[a + 1], (g <= d && f <= g || d <= g && g <= f) && (h = (g - d) / (f - d) * (u - c) + c, _.push(h)), c = u, d = f; 9800 } 9801 let m = NaN, p = -1 / 0; 9802 for (_.sort(Cs), c = _[0], a = 1, l = _.length; a < l; ++a) { 9803 u = _[a]; 9804 const y = Math.abs(u - c); 9805 y > p && (h = (c + u) / 2, Oh(e, t, i, s, h, g) && (m = h, p = y)), c = u; 9806 } 9807 return isNaN(m) && (m = n[r]), o ? (o.push(m, g, p), o) : [m, g, p]; 9808} 9809function kE(e, t, i, s, n) { 9810 let r = []; 9811 for (let o = 0, a = i.length; o < a; ++o) { 9812 const l = i[o]; 9813 r = qf( 9814 e, 9815 t, 9816 l, 9817 s, 9818 n, 9819 2 * o, 9820 r 9821 ), t = l[l.length - 1]; 9822 } 9823 return r; 9824} 9825function Hf(e, t, i, s, n) { 9826 let r; 9827 for (t += s; t < i; t += s) 9828 if (r = n( 9829 e.slice(t - s, t), 9830 e.slice(t, t + s) 9831 ), r) 9832 return r; 9833 return !1; 9834} 9835function fa(e, t, i, s, n) { 9836 const r = Ad( 9837 ve(), 9838 e, 9839 t, 9840 i, 9841 s 9842 ); 9843 return ee(n, r) ? Gi(n, r) || r[0] >= n[0] && r[2] <= n[2] || r[1] >= n[1] && r[3] <= n[3] ? !0 : Hf( 9844 e, 9845 t, 9846 i, 9847 s, 9848 /** 9849 * @param {import("../../coordinate.js").Coordinate} point1 Start point. 9850 * @param {import("../../coordinate.js").Coordinate} point2 End point. 9851 * @return {boolean} `true` if the segment and the extent intersect, 9852 * `false` otherwise. 9853 */ 9854 function(o, a) { 9855 return By(n, o, a); 9856 } 9857 ) : !1; 9858} 9859function GE(e, t, i, s, n) { 9860 for (let r = 0, o = i.length; r < o; ++r) { 9861 if (fa(e, t, i[r], s, n)) 9862 return !0; 9863 t = i[r]; 9864 } 9865 return !1; 9866} 9867function Zf(e, t, i, s, n) { 9868 return !!(fa(e, t, i, s, n) || cs( 9869 e, 9870 t, 9871 i, 9872 s, 9873 n[0], 9874 n[1] 9875 ) || cs( 9876 e, 9877 t, 9878 i, 9879 s, 9880 n[0], 9881 n[3] 9882 ) || cs( 9883 e, 9884 t, 9885 i, 9886 s, 9887 n[2], 9888 n[1] 9889 ) || cs( 9890 e, 9891 t, 9892 i, 9893 s, 9894 n[2], 9895 n[3] 9896 )); 9897} 9898function Jf(e, t, i, s, n) { 9899 if (!Zf(e, t, i[0], s, n)) 9900 return !1; 9901 if (i.length === 1) 9902 return !0; 9903 for (let r = 1, o = i.length; r < o; ++r) 9904 if (DE( 9905 e, 9906 i[r - 1], 9907 i[r], 9908 s, 9909 n 9910 ) && !fa( 9911 e, 9912 i[r - 1], 9913 i[r], 9914 s, 9915 n 9916 )) 9917 return !1; 9918 return !0; 9919} 9920function zE(e, t, i, s, n) { 9921 for (let r = 0, o = i.length; r < o; ++r) { 9922 const a = i[r]; 9923 if (Jf(e, t, a, s, n)) 9924 return !0; 9925 t = a[a.length - 1]; 9926 } 9927 return !1; 9928} 9929function jE(e, t, i, s) { 9930 for (; t < i - s; ) { 9931 for (let n = 0; n < s; ++n) { 9932 const r = e[t + n]; 9933 e[t + n] = e[i - s + n], e[i - s + n] = r; 9934 } 9935 t += s, i -= s; 9936 } 9937} 9938function Qf(e, t, i, s) { 9939 let n = 0, r = e[i - s], o = e[i - s + 1]; 9940 for (; t < i; t += s) { 9941 const a = e[t], l = e[t + 1]; 9942 n += (a - r) * (l + o), r = a, o = l; 9943 } 9944 return n === 0 ? void 0 : n > 0; 9945} 9946function tg(e, t, i, s, n) { 9947 n = n !== void 0 ? n : !1; 9948 for (let r = 0, o = i.length; r < o; ++r) { 9949 const a = i[r], l = Qf( 9950 e, 9951 t, 9952 a, 9953 s 9954 ); 9955 if (r === 0) { 9956 if (n && l || !n && !l) 9957 return !1; 9958 } else if (n && !l || !n && l) 9959 return !1; 9960 t = a; 9961 } 9962 return !0; 9963} 9964function WE(e, t, i, s, n) { 9965 for (let r = 0, o = i.length; r < o; ++r) { 9966 const a = i[r]; 9967 if (!tg(e, t, a, s, n)) 9968 return !1; 9969 a.length && (t = a[a.length - 1]); 9970 } 9971 return !0; 9972} 9973function bl(e, t, i, s, n) { 9974 n = n !== void 0 ? n : !1; 9975 for (let r = 0, o = i.length; r < o; ++r) { 9976 const a = i[r], l = Qf( 9977 e, 9978 t, 9979 a, 9980 s 9981 ); 9982 (r === 0 ? n && l || !n && !l : n && !l || !n && l) && jE(e, t, a, s), t = a; 9983 } 9984 return t; 9985} 9986function Eu(e, t, i, s, n) { 9987 for (let r = 0, o = i.length; r < o; ++r) 9988 t = bl( 9989 e, 9990 t, 9991 i[r], 9992 s, 9993 n 9994 ); 9995 return t; 9996} 9997class vn extends ts { 9998 /** 9999 * @param {!Array<Array<import("../coordinate.js").Coordinate>>|!Array<number>} coordinates 10000 * Array of linear rings that define the polygon. The first linear ring of the 10001 * array defines the outer-boundary or surface of the polygon. Each subsequent 10002 * linear ring defines a hole in the surface of the polygon. A linear ring is 10003 * an array of vertices' coordinates where the first coordinate and the last are 10004 * equivalent. (For internal use, flat coordinates in combination with 10005 * `layout` and `ends` are also accepted.) 10006 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 10007 * @param {Array<number>} [ends] Ends (for internal use with flat coordinates). 10008 */ 10009 constructor(t, i, s) { 10010 super(), this.ends_ = [], this.flatInteriorPointRevision_ = -1, this.flatInteriorPoint_ = null, this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, this.orientedRevision_ = -1, this.orientedFlatCoordinates_ = null, i !== void 0 && s ? (this.setFlatCoordinates( 10011 i, 10012 /** @type {Array<number>} */ 10013 t 10014 ), this.ends_ = s) : this.setCoordinates( 10015 /** @type {Array<Array<import("../coordinate.js").Coordinate>>} */ 10016 t, 10017 i 10018 ); 10019 } 10020 /** 10021 * Append the passed linear ring to this polygon. 10022 * @param {LinearRing} linearRing Linear ring. 10023 * @api 10024 */ 10025 appendLinearRing(t) { 10026 this.flatCoordinates ? mi(this.flatCoordinates, t.getFlatCoordinates()) : this.flatCoordinates = t.getFlatCoordinates().slice(), this.ends_.push(this.flatCoordinates.length), this.changed(); 10027 } 10028 /** 10029 * Make a complete copy of the geometry. 10030 * @return {!Polygon} Clone. 10031 * @api 10032 */ 10033 clone() { 10034 const t = new vn( 10035 this.flatCoordinates.slice(), 10036 this.layout, 10037 this.ends_.slice() 10038 ); 10039 return t.applyProperties(this), t;
10040 } 10041 /** 10042 * @param {number} x X. 10043 * @param {number} y Y. 10044 * @param {import("../coordinate.js").Coordinate} closestPoint Closest point. 10045 * @param {number} minSquaredDistance Minimum squared distance. 10046 * @return {number} Minimum squared distance. 10047 */ 10048 closestPointXY(t, i, s, n) { 10049 return n < Ss(this.getExtent(), t, i) ? n : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt( 10050 Th( 10051 this.flatCoordinates, 10052 0, 10053 this.ends_, 10054 this.stride, 10055 0 10056 ) 10057 ), this.maxDeltaRevision_ = this.getRevision()), Ih( 10058 this.flatCoordinates, 10059 0, 10060 this.ends_, 10061 this.stride, 10062 this.maxDelta_, 10063 !0, 10064 t, 10065 i, 10066 s, 10067 n 10068 )); 10069 } 10070 /** 10071 * @param {number} x X. 10072 * @param {number} y Y. 10073 * @return {boolean} Contains (x, y). 10074 */ 10075 containsXY(t, i) { 10076 return Oh( 10077 this.getOrientedFlatCoordinates(), 10078 0, 10079 this.ends_, 10080 this.stride, 10081 t, 10082 i 10083 ); 10084 } 10085 /** 10086 * Return the area of the polygon on projected plane. 10087 * @return {number} Area (on projected plane). 10088 * @api 10089 */ 10090 getArea() { 10091 return Vf( 10092 this.getOrientedFlatCoordinates(), 10093 0, 10094 this.ends_, 10095 this.stride 10096 ); 10097 } 10098 /** 10099 * Get the coordinate array for this geometry. This array has the structure 10100 * of a GeoJSON coordinate array for polygons. 10101 * 10102 * @param {boolean} [right] Orient coordinates according to the right-hand 10103 * rule (counter-clockwise for exterior and clockwise for interior rings). 10104 * If `false`, coordinates will be oriented according to the left-hand rule 10105 * (clockwise for exterior and counter-clockwise for interior rings). 10106 * By default, coordinate orientation will depend on how the geometry was 10107 * constructed. 10108 * @return {Array<Array<import("../coordinate.js").Coordinate>>} Coordinates. 10109 * @api 10110 */ 10111 getCoordinates(t) { 10112 let i; 10113 return t !== void 0 ? (i = this.getOrientedFlatCoordinates().slice(), bl(i, 0, this.ends_, this.stride, t)) : i = this.flatCoordinates, lr(i, 0, this.ends_, this.stride); 10114 } 10115 /** 10116 * @return {Array<number>} Ends. 10117 */ 10118 getEnds() { 10119 return this.ends_; 10120 } 10121 /** 10122 * @return {Array<number>} Interior point. 10123 */ 10124 getFlatInteriorPoint() { 10125 if (this.flatInteriorPointRevision_ != this.getRevision()) { 10126 const t = ii(this.getExtent()); 10127 this.flatInteriorPoint_ = qf( 10128 this.getOrientedFlatCoordinates(), 10129 0, 10130 this.ends_, 10131 this.stride, 10132 t, 10133 0 10134 ), this.flatInteriorPointRevision_ = this.getRevision(); 10135 } 10136 return this.flatInteriorPoint_; 10137 } 10138 /** 10139 * Return an interior point of the polygon. 10140 * @return {Point} Interior point as XYM coordinate, where M is the 10141 * length of the horizontal intersection that the point belongs to. 10142 * @api 10143 */ 10144 getInteriorPoint() { 10145 return new pi(this.getFlatInteriorPoint(), "XYM"); 10146 } 10147 /** 10148 * Return the number of rings of the polygon, this includes the exterior 10149 * ring and any interior rings. 10150 * 10151 * @return {number} Number of rings. 10152 * @api 10153 */ 10154 getLinearRingCount() { 10155 return this.ends_.length; 10156 } 10157 /** 10158 * Return the Nth linear ring of the polygon geometry. Return `null` if the 10159 * given index is out of range. 10160 * The exterior linear ring is available at index `0` and the interior rings 10161 * at index `1` and beyond. 10162 * 10163 * @param {number} index Index. 10164 * @return {LinearRing|null} Linear ring. 10165 * @api 10166 */ 10167 getLinearRing(t) { 10168 return t < 0 || this.ends_.length <= t ? null : new vu( 10169 this.flatCoordinates.slice( 10170 t === 0 ? 0 : this.ends_[t - 1], 10171 this.ends_[t] 10172 ), 10173 this.layout 10174 ); 10175 } 10176 /** 10177 * Return the linear rings of the polygon. 10178 * @return {Array<LinearRing>} Linear rings. 10179 * @api 10180 */ 10181 getLinearRings() { 10182 const t = this.layout, i = this.flatCoordinates, s = this.ends_, n = []; 10183 let r = 0; 10184 for (let o = 0, a = s.length; o < a; ++o) { 10185 const l = s[o], h = new vu( 10186 i.slice(r, l), 10187 t 10188 ); 10189 n.push(h), r = l; 10190 } 10191 return n; 10192 } 10193 /** 10194 * @return {Array<number>} Oriented flat coordinates. 10195 */ 10196 getOrientedFlatCoordinates() { 10197 if (this.orientedRevision_ != this.getRevision()) { 10198 const t = this.flatCoordinates; 10199 tg(t, 0, this.ends_, this.stride) ? this.orientedFlatCoordinates_ = t : (this.orientedFlatCoordinates_ = t.slice(), this.orientedFlatCoordinates_.length = bl( 10200 this.orientedFlatCoordinates_, 10201 0, 10202 this.ends_, 10203 this.stride 10204 )), this.orientedRevision_ = this.getRevision(); 10205 } 10206 return this.orientedFlatCoordinates_; 10207 } 10208 /** 10209 * @param {number} squaredTolerance Squared tolerance. 10210 * @return {Polygon} Simplified Polygon. 10211 * @protected 10212 */ 10213 getSimplifiedGeometryInternal(t) { 10214 const i = [], s = []; 10215 return i.length = Yf( 10216 this.flatCoordinates, 10217 0, 10218 this.ends_, 10219 this.stride, 10220 Math.sqrt(t), 10221 i, 10222 0, 10223 s 10224 ), new vn(i, "XY", s); 10225 } 10226 /** 10227 * Get the type of this geometry. 10228 * @return {import("./Geometry.js").Type} Geometry type. 10229 * @api 10230 */ 10231 getType() { 10232 return "Polygon"; 10233 } 10234 /** 10235 * Test if the geometry and the passed extent intersect. 10236 * @param {import("../extent.js").Extent} extent Extent. 10237 * @return {boolean} `true` if the geometry and the extent intersect. 10238 * @api 10239 */ 10240 intersectsExtent(t) { 10241 return Jf( 10242 this.getOrientedFlatCoordinates(), 10243 0, 10244 this.ends_, 10245 this.stride, 10246 t 10247 ); 10248 } 10249 /** 10250 * Set the coordinates of the polygon. 10251 * @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates. 10252 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 10253 * @api 10254 */ 10255 setCoordinates(t, i) { 10256 this.setLayout(i, t, 2), this.flatCoordinates || (this.flatCoordinates = []); 10257 const s = Ph( 10258 this.flatCoordinates, 10259 0, 10260 t, 10261 this.stride, 10262 this.ends_ 10263 ); 10264 this.flatCoordinates.length = s.length === 0 ? 0 : s[s.length - 1], this.changed(); 10265 } 10266} 10267const En = vn; 10268function Mu(e) { 10269 const t = e[0], i = e[1], s = e[2], n = e[3], r = [ 10270 t, 10271 i, 10272 t, 10273 n, 10274 s, 10275 n, 10276 s, 10277 i, 10278 t, 10279 i 10280 ]; 10281 return new vn(r, "XY", [r.length]); 10282} 10283function BE(e, t, i) { 10284 t = t || 32; 10285 const s = e.getStride(), n = e.getLayout(), r = e.getCenter(), o = s * (t + 1), a = new Array(o); 10286 for (let c = 0; c < o; c += s) { 10287 a[c] = 0, a[c + 1] = 0; 10288 for (let u = 2; u < s; u++) 10289 a[c + u] = r[u]; 10290 } 10291 const l = [a.length], h = new vn(a, n, l); 10292 return UE(h, r, e.getRadius(), i), h; 10293} 10294function UE(e, t, i, s) { 10295 const n = e.getFlatCoordinates(), r = e.getStride(), o = n.length / r - 1, a = s || 0; 10296 for (let l = 0; l <= o; ++l) { 10297 const h = l * r, c = a + $i(l, o) * 2 * Math.PI / o; 10298 n[h] = t[0] + i * Math.cos(c), n[h + 1] = t[1] + i * Math.sin(c); 10299 } 10300 e.changed(); 10301} 10302const Fa = 0; 10303class XE extends ni { 10304 /** 10305 * @param {ViewOptions} [options] View options. 10306 */ 10307 constructor(t) { 10308 super(), this.on, this.once, this.un, t = Object.assign({}, t), this.hints_ = [0, 0], this.animations_ = [], this.updateAnimationKey_, this.projection_ = Vl(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 && Qy(), t.center && (t.center = It(t.center, this.projection_)), t.extent && (t.extent = He(t.extent, this.projection_)), this.applyOptions_(t); 10309 } 10310 /** 10311 * Set up the view with the given options. 10312 * @param {ViewOptions} options View options. 10313 */ 10314 applyOptions_(t) { 10315 const i = Object.assign({}, t); 10316 for (const a in Le) 10317 delete i[a]; 10318 this.setProperties(i, !0); 10319 const s = YE(t); 10320 this.maxResolution_ = s.maxResolution, this.minResolution_ = s.minResolution, this.zoomFactor_ = s.zoomFactor, this.resolutions_ = t.resolutions, this.padding_ = t.padding, this.minZoom_ = s.minZoom; 10321 const n = $E(t), r = s.constraint, o = KE(t); 10322 this.constraints_ = { 10323 center: n, 10324 resolution: r, 10325 rotation: o 10326 }, this.setRotation(t.rotation !== void 0 ? t.rotation : 0), this.setCenterInternal( 10327 t.center !== void 0 ? t.center : null 10328 ), t.resolution !== void 0 ? this.setResolution(t.resolution) : t.zoom !== void 0 && this.setZoom(t.zoom); 10329 } 10330 /** 10331 * Padding (in css pixels). 10332 * If the map viewport is partially covered with other content (overlays) along 10333 * its edges, this setting allows to shift the center of the viewport away from that 10334 * content. The order of the values in the array is top, right, bottom, left. 10335 * The default is no padding, which is equivalent to `[0, 0, 0, 0]`. 10336 * @type {Array<number>|undefined} 10337 * @api 10338 */ 10339 get padding() { 10340 return this.padding_; 10341 } 10342 set padding(t) { 10343 let i = this.padding_; 10344 this.padding_ = t; 10345 const s = this.getCenterInternal(); 10346 if (s) { 10347 const n = t || [0, 0, 0, 0]; 10348 i = i || [0, 0, 0, 0]; 10349 const r = this.getResolution(), o = r / 2 * (n[3] - i[3] + i[
103491] - n[1]), a = r / 2 * (n[0] - i[0] + i[2] - n[2]); 10350 this.setCenterInternal([s[0] + o, s[1] - a]); 10351 } 10352 } 10353 /** 10354 * Get an updated version of the view options used to construct the view. The 10355 * current resolution (or zoom), center, and rotation are applied to any stored 10356 * options. The provided options can be used to apply new min/max zoom or 10357 * resolution limits. 10358 * @param {ViewOptions} newOptions New options to be applied. 10359 * @return {ViewOptions} New options updated with the current view state. 10360 */ 10361 getUpdatedOptions_(t) { 10362 const i = this.getProperties(); 10363 return i.resolution !== void 0 ? i.resolution = this.getResolution() : i.zoom = this.getZoom(), i.center = this.getCenterInternal(), i.rotation = this.getRotation(), Object.assign({}, i, t); 10364 } 10365 /** 10366 * Animate the view. The view's center, zoom (or resolution), and rotation 10367 * can be animated for smooth transitions between view states. For example, 10368 * to animate the view to a new zoom level: 10369 * 10370 * view.animate({zoom: view.getZoom() + 1}); 10371 * 10372 * By default, the animation lasts one second and uses in-and-out easing. You 10373 * can customize this behavior by including `duration` (in milliseconds) and 10374 * `easing` options (see {@link module:ol/easing}). 10375 * 10376 * To chain together multiple animations, call the method with multiple 10377 * animation objects. For example, to first zoom and then pan: 10378 * 10379 * view.animate({zoom: 10}, {center: [0, 0]}); 10380 * 10381 * If you provide a function as the last argument to the animate method, it 10382 * will get called at the end of an animation series. The callback will be 10383 * called with `true` if the animation series completed on its own or `false` 10384 * if it was cancelled. 10385 * 10386 * Animations are cancelled by user interactions (e.g. dragging the map) or by 10387 * calling `view.setCenter()`, `view.setResolution()`, or `view.setRotation()` 10388 * (or another method that calls one of these). 10389 * 10390 * @param {...(AnimationOptions|function(boolean): void)} var_args Animation 10391 * options. Multiple animations can be run in series by passing multiple 10392 * options objects. To run multiple animations in parallel, call the method 10393 * multiple times. An optional callback can be provided as a final 10394 * argument. The callback will be called with a boolean indicating whether 10395 * the animation completed without being cancelled. 10396 * @api 10397 */ 10398 animate(t) { 10399 this.isDef() && !this.getAnimating() && this.resolveConstraints(0); 10400 const i = new Array(arguments.length); 10401 for (let s = 0; s < i.length; ++s) { 10402 let n = arguments[s]; 10403 n.center && (n = Object.assign({}, n), n.center = It( 10404 n.center, 10405 this.getProjection() 10406 )), n.anchor && (n = Object.assign({}, n), n.anchor = It( 10407 n.anchor, 10408 this.getProjection() 10409 )), i[s] = n; 10410 } 10411 this.animateInternal.apply(this, i); 10412 } 10413 /** 10414 * @param {...(AnimationOptions|function(boolean): void)} var_args Animation options. 10415 */ 10416 animateInternal(t) { 10417 let i = arguments.length, s; 10418 i > 1 && typeof arguments[i - 1] == "function" && (s = arguments[i - 1], --i); 10419 let n = 0; 10420 for (; n < i && !this.isDef(); ++n) { 10421 const c = arguments[n]; 10422 c.center && this.setCenterInternal(c.center), c.zoom !== void 0 ? this.setZoom(c.zoom) : c.resolution && this.setResolution(c.resolution), c.rotation !== void 0 && this.setRotation(c.rotation); 10423 } 10424 if (n === i) { 10425 s && Vr(s, !0); 10426 return; 10427 } 10428 let r = Date.now(), o = this.targetCenter_.slice(), a = this.targetResolution_, l = this.targetRotation_; 10429 const h = []; 10430 for (; n < i; ++n) { 10431 const c = ( 10432 /** @type {AnimationOptions} */ 10433 arguments[n] 10434 ), u = { 10435 start: r, 10436 complete: !1, 10437 anchor: c.anchor, 10438 duration: c.duration !== void 0 ? c.duration : 1e3, 10439 easing: c.easing || EE, 10440 callback: s 10441 }; 10442 if (c.center && (u.sourceCenter = o, u.targetCenter = c.center.slice(), o = u.targetCenter), c.zoom !== void 0 ? (u.sourceResolution = a, u.targetResolution = this.getResolutionForZoom(c.zoom), a = u.targetResolution) : c.resolution && (u.sourceResolution = a, u.targetResolution = c.resolution, a = u.targetResolution), c.rotation !== void 0) { 10443 u.sourceRotation = l; 10444 const d = $i(c.rotation - l + Math.PI, 2 * Math.PI) - Math.PI; 10445 u.targetRotation = l + d, l = u.targetRotation; 10446 } 10447 VE(u) ? u.complete = !0 : r += u.duration, h.push(u); 10448 } 10449 this.animations_.push(h), this.setHint(Xt.ANIMATING, 1), this.updateAnimations_(); 10450 } 10451 /** 10452 * Determine if the view is being animated. 10453 * @return {boolean} The view is being animated. 10454 * @api 10455 */ 10456 getAnimating() { 10457 return this.hints_[Xt.ANIMATING] > 0; 10458 } 10459 /** 10460 * Determine if the user is interacting with the view, such as panning or zooming. 10461 * @return {boolean} The view is being interacted with. 10462 * @api 10463 */ 10464 getInteracting() { 10465 return this.hints_[Xt.INTERACTING] > 0; 10466 } 10467 /** 10468 * Cancel any ongoing animations. 10469 * @api 10470 */ 10471 cancelAnimations() { 10472 this.setHint(Xt.ANIMATING, -this.hints_[Xt.ANIMATING]); 10473 let t; 10474 for (let i = 0, s = this.animations_.length; i < s; ++i) { 10475 const n = this.animations_[i]; 10476 if (n[0].callback && Vr(n[0].callback, !1), !t) 10477 for (let r = 0, o = n.length; r < o; ++r) { 10478 const a = n[r]; 10479 if (!a.complete) { 10480 t = a.anchor; 10481 break; 10482 } 10483 } 10484 } 10485 this.animations_.length = 0, this.cancelAnchor_ = t, this.nextCenter_ = null, this.nextResolution_ = NaN, this.nextRotation_ = NaN; 10486 } 10487 /** 10488 * Update all animations. 10489 */ 10490 updateAnimations_() { 10491 if (this.updateAnimationKey_ !== void 0 && (cancelAnimationFrame(this.updateAnimationKey_), this.updateAnimationKey_ = void 0), !this.getAnimating()) 10492 return; 10493 const t = Date.now(); 10494 let i = !1; 10495 for (let s = this.animations_.length - 1; s >= 0; --s) { 10496 const n = this.animations_[s]; 10497 let r = !0; 10498 for (let o = 0, a = n.length; o < a; ++o) { 10499 const l = n[o]; 10500 if (l.complete) 10501 continue; 10502 const h = t - l.start; 10503 let c = l.duration > 0 ? h / l.duration : 1; 10504 c >= 1 ? (l.complete = !0, c = 1) : r = !1; 10505 const u = l.easing(c); 10506 if (l.sourceCenter) { 10507 const d = l.sourceCenter[0], f = l.sourceCenter[1], g = l.targetCenter[0], _ = l.targetCenter[1]; 10508 this.nextCenter_ = l.targetCenter; 10509 const m = d + u * (g - d), p = f + u * (_ - f); 10510 this.targetCenter_ = [m, p]; 10511 } 10512 if (l.sourceResolution && l.targetResolution) { 10513 const d = u === 1 ? l.targetResolution : l.sourceResolution + u * (l.targetResolution - l.sourceResolution); 10514 if (l.anchor) { 10515 const f = this.getViewportSize_(this.getRotation()), g = this.constraints_.resolution( 10516 d, 10517 0, 10518 f, 10519 !0 10520 ); 10521 this.targetCenter_ = this.calculateCenterZoom( 10522 g, 10523 l.anchor 10524 ); 10525 } 10526 this.nextResolution_ = l.targetResolution, this.targetResolution_ = d, this.applyTargetState_(!0); 10527 } 10528 if (l.sourceRotation !== void 0 && l.targetRotation !== void 0) { 10529 const d = u === 1 ? $i(l.targetRotation + Math.PI, 2 * Math.PI) - Math.PI : l.sourceRotation + u * (l.targetRotation - l.sourceRotation); 10530 if (l.anchor) { 10531 const f = this.constraints_.rotation( 10532 d, 10533 !0 10534 ); 10535 this.targetCenter_ = this.calculateCenterRotate( 10536 f, 10537 l.anchor 10538 ); 10539 } 10540 this.nextRotation_ = l.targetRotation, this.targetRotation_ = d; 10541 } 10542 if (this.applyTargetState_(!0), i = !0, !l.complete) 10543 break; 10544 } 10545 if (r) { 10546 this.animations_[s] = null, this.setHint(Xt.ANIMATING, -1), this.nextCenter_ = null, this.nextResolution_ = NaN, this.nextRotation_ = NaN; 10547 const o = n[0].callback; 10548 o && Vr(o, !0); 10549 } 10550 } 10551 this.animations_ = this.animations_.filter(Boolean), i && this.updateAnimationKey_ === void 0 && (this.updateAnimationKey_ = requestAnimationFrame( 10552 this.updateAnimations_.bind(this) 10553 )); 10554 } 10555 /** 10556 * @param {number} rotation Target rotation. 10557 * @param {import("./coordinate.js").Coordinate} anchor Rotation anchor. 10558 * @return {import("./coordinate.js").Coordinate|undefined} Center for rotation and anchor. 10559 */ 10560 calculateCenterRotate(t, i) { 10561 let s; 10562 const n = this.getCenterInternal(); 10563 return n !== void 0 && (s = [n[0] - i[0], n[1] - i[1]], Yl(s, t - this.getRotation()), Ky(s, i)
10563), s; 10564 } 10565 /** 10566 * @param {number} resolution Target resolution. 10567 * @param {import("./coordinate.js").Coordinate} anchor Zoom anchor. 10568 * @return {import("./coordinate.js").Coordinate|undefined} Center for resolution and anchor. 10569 */ 10570 calculateCenterZoom(t, i) { 10571 let s; 10572 const n = this.getCenterInternal(), r = this.getResolution(); 10573 if (n !== void 0 && r !== void 0) { 10574 const o = i[0] - t * (i[0] - n[0]) / r, a = i[1] - t * (i[1] - n[1]) / r; 10575 s = [o, a]; 10576 } 10577 return s; 10578 } 10579 /** 10580 * Returns the current viewport size. 10581 * @private 10582 * @param {number} [rotation] Take into account the rotation of the viewport when giving the size 10583 * @return {import("./size.js").Size} Viewport size or `[100, 100]` when no viewport is found. 10584 */ 10585 getViewportSize_(t) { 10586 const i = this.viewportSize_; 10587 if (t) { 10588 const s = i[0], n = i[1]; 10589 return [ 10590 Math.abs(s * Math.cos(t)) + Math.abs(n * Math.sin(t)), 10591 Math.abs(s * Math.sin(t)) + Math.abs(n * Math.cos(t)) 10592 ]; 10593 } 10594 return i; 10595 } 10596 /** 10597 * Stores the viewport size on the view. The viewport size is not read every time from the DOM 10598 * to avoid performance hit and layout reflow. 10599 * This should be done on map size change. 10600 * Note: the constraints are not resolved during an animation to avoid stopping it 10601 * @param {import("./size.js").Size} [size] Viewport size; if undefined, [100, 100] is assumed 10602 */ 10603 setViewportSize(t) { 10604 this.viewportSize_ = Array.isArray(t) ? t.slice() : [100, 100], this.getAnimating() || this.resolveConstraints(0); 10605 } 10606 /** 10607 * Get the view center. 10608 * @return {import("./coordinate.js").Coordinate|undefined} The center of the view. 10609 * @observable 10610 * @api 10611 */ 10612 getCenter() { 10613 const t = this.getCenterInternal(); 10614 return t && Ms(t, this.getProjection()); 10615 } 10616 /** 10617 * Get the view center without transforming to user projection. 10618 * @return {import("./coordinate.js").Coordinate|undefined} The center of the view. 10619 */ 10620 getCenterInternal() { 10621 return ( 10622 /** @type {import("./coordinate.js").Coordinate|undefined} */ 10623 this.get(Le.CENTER) 10624 ); 10625 } 10626 /** 10627 * @return {Constraints} Constraints. 10628 */ 10629 getConstraints() { 10630 return this.constraints_; 10631 } 10632 /** 10633 * @return {boolean} Resolution constraint is set 10634 */ 10635 getConstrainResolution() { 10636 return this.get("constrainResolution"); 10637 } 10638 /** 10639 * @param {Array<number>} [hints] Destination array. 10640 * @return {Array<number>} Hint. 10641 */ 10642 getHints(t) { 10643 return t !== void 0 ? (t[0] = this.hints_[0], t[1] = this.hints_[1], t) : this.hints_.slice(); 10644 } 10645 /** 10646 * Calculate the extent for the current view state and the passed size. 10647 * The size is the pixel dimensions of the box into which the calculated extent 10648 * should fit. In most cases you want to get the extent of the entire map, 10649 * that is `map.getSize()`. 10650 * @param {import("./size.js").Size} [size] Box pixel size. If not provided, the size 10651 * of the map that uses this view will be used. 10652 * @return {import("./extent.js").Extent} Extent. 10653 * @api 10654 */ 10655 calculateExtent(t) { 10656 const i = this.calculateExtentInternal(t); 10657 return Zo(i, this.getProjection()); 10658 } 10659 /** 10660 * @param {import("./size.js").Size} [size] Box pixel size. If not provided, 10661 * the map's last known viewport size will be used. 10662 * @return {import("./extent.js").Extent} Extent. 10663 */ 10664 calculateExtentInternal(t) { 10665 t = t || this.getViewportSizeMinusPadding_(); 10666 const i = ( 10667 /** @type {!import("./coordinate.js").Coordinate} */ 10668 this.getCenterInternal() 10669 ); 10670 at(i, 1); 10671 const s = ( 10672 /** @type {!number} */ 10673 this.getResolution() 10674 ); 10675 at(s !== void 0, 2); 10676 const n = ( 10677 /** @type {!number} */ 10678 this.getRotation() 10679 ); 10680 return at(n !== void 0, 3), en(i, s, n, t); 10681 } 10682 /** 10683 * Get the maximum resolution of the view. 10684 * @return {number} The maximum resolution of the view. 10685 * @api 10686 */ 10687 getMaxResolution() { 10688 return this.maxResolution_; 10689 } 10690 /** 10691 * Get the minimum resolution of the view. 10692 * @return {number} The minimum resolution of the view. 10693 * @api 10694 */ 10695 getMinResolution() { 10696 return this.minResolution_; 10697 } 10698 /** 10699 * Get the maximum zoom level for the view. 10700 * @return {number} The maximum zoom level. 10701 * @api 10702 */ 10703 getMaxZoom() { 10704 return ( 10705 /** @type {number} */ 10706 this.getZoomForResolution(this.minResolution_) 10707 ); 10708 } 10709 /** 10710 * Set a new maximum zoom level for the view. 10711 * @param {number} zoom The maximum zoom level. 10712 * @api 10713 */ 10714 setMaxZoom(t) { 10715 this.applyOptions_(this.getUpdatedOptions_({ maxZoom: t })); 10716 } 10717 /** 10718 * Get the minimum zoom level for the view. 10719 * @return {number} The minimum zoom level. 10720 * @api 10721 */ 10722 getMinZoom() { 10723 return ( 10724 /** @type {number} */ 10725 this.getZoomForResolution(this.maxResolution_) 10726 ); 10727 } 10728 /** 10729 * Set a new minimum zoom level for the view. 10730 * @param {number} zoom The minimum zoom level. 10731 * @api 10732 */ 10733 setMinZoom(t) { 10734 this.applyOptions_(this.getUpdatedOptions_({ minZoom: t })); 10735 } 10736 /** 10737 * Set whether the view should allow intermediary zoom levels. 10738 * @param {boolean} enabled Whether the resolution is constrained. 10739 * @api 10740 */ 10741 setConstrainResolution(t) { 10742 this.applyOptions_(this.getUpdatedOptions_({ constrainResolution: t })); 10743 } 10744 /** 10745 * Get the view projection. 10746 * @return {import("./proj/Projection.js").default} The projection of the view. 10747 * @api 10748 */ 10749 getProjection() { 10750 return this.projection_; 10751 } 10752 /** 10753 * Get the view resolution. 10754 * @return {number|undefined} The resolution of the view. 10755 * @observable 10756 * @api 10757 */ 10758 getResolution() { 10759 return ( 10760 /** @type {number|undefined} */ 10761 this.get(Le.RESOLUTION) 10762 ); 10763 } 10764 /** 10765 * Get the resolutions for the view. This returns the array of resolutions 10766 * passed to the constructor of the View, or undefined if none were given. 10767 * @return {Array<number>|undefined} The resolutions of the view. 10768 * @api 10769 */ 10770 getResolutions() { 10771 return this.resolutions_; 10772 } 10773 /** 10774 * Get the resolution for a provided extent (in map units) and size (in pixels). 10775 * @param {import("./extent.js").Extent} extent Extent. 10776 * @param {import("./size.js").Size} [size] Box pixel size. 10777 * @return {number} The resolution at which the provided extent will render at 10778 * the given size. 10779 * @api 10780 */ 10781 getResolutionForExtent(t, i) { 10782 return this.getResolutionForExtentInternal( 10783 He(t, this.getProjection()), 10784 i 10785 ); 10786 } 10787 /** 10788 * Get the resolution for a provided extent (in map units) and size (in pixels). 10789 * @param {import("./extent.js").Extent} extent Extent. 10790 * @param {import("./size.js").Size} [size] Box pixel size. 10791 * @return {number} The resolution at which the provided extent will render at 10792 * the given size. 10793 */ 10794 getResolutionForExtentInternal(t, i) { 10795 i = i || this.getViewportSizeMinusPadding_(); 10796 const s = mt(t) / i[0], n = Yt(t) / i[1]; 10797 return Math.max(s, n); 10798 } 10799 /** 10800 * Return a function that returns a value between 0 and 1 for a 10801 * resolution. Exponential scaling is assumed. 10802 * @param {number} [power] Power. 10803 * @return {function(number): number} Resolution for value function. 10804 */ 10805 getResolutionForValueFunction(t) { 10806 t = t || 2; 10807 const i = this.getConstrainedResolution(this.maxResolution_), s = this.minResolution_, n = Math.log(i / s) / Math.log(t); 10808 return ( 10809 /** 10810 * @param {number} value Value. 10811 * @return {number} Resolution. 10812 */ 10813 function(r) { 10814 return i / Math.pow(t, r * n); 10815 } 10816 ); 10817 } 10818 /** 10819 * Get the view rotation. 10820 * @return {number} The rotation of the view in radians. 10821 * @observable 10822 * @api 10823 */ 10824 getRotation() { 10825 return ( 10826 /** @type {number} */ 10827 this.get(Le.ROTATION) 10828 ); 10829 } 10830 /** 10831 * Return a function that returns a resolution for a value between 10832 * 0 and 1. Exponential scaling is assumed. 10833 * @param {number} [power] Power. 10834 * @return {function(number): number} Value for resolution function. 10835 */ 10836 getValueForResolutionFunction(t) { 10837 const i = Math.log(t || 2), s = this.getConstrainedResolution(this.maxResolution_), n = this.minResolution_, r = Math.log(s / n) / i; 10838 return ( 10839 /** 10840 * @param {number} resolution Resolution. 10841 * @return {number} Value. 10842 */ 10843 function(o) { 10844 return Math.log(s / o) / i / r; 10845 } 10846 ); 10847 } 10848 /** 10849 * Returns the size of the viewport minus padding. 10850 * @private 10851 * @param {number} [rotation] Take into account the rotation of the viewport when giving the size 10852 * @return {import("./size.js").Size} Viewport size reduced by the padding. 10853 */ 10854 getViewportSizeMinusPadding_(t) { 10855 let i = this.getViewportSize_(t); 10856 const s = this.padding_; 10857 return s && (i = [ 10858 i[0] - s[1] - s[3], 10859 i[1] - s[0] - s[2] 10860 ]), i; 10861 } 10862 /** 10863 * @return {State} View state. 10864 */ 10865 getState() { 10866 const t = this.getProjection(), i = this.getResolution(), s = this.getRotation(); 10867 let n = ( 10868 /** @type {import("./coordinate.js").Coordinate} */ 10869 this.getCenterInternal() 10870 ); 10871 const r = this.padding_; 10872 if (r) { 10873 const o = this.getViewportSizeMinusPadding_(); 10874 n = Da( 10875 n, 10876 this.getViewportSize_(), 10877 [o[0] / 2 + r[3], o[1] / 2 + r[0]], 10878 i, 10879 s 10880 ); 10881 } 10882 return { 10883 center: n.slice(0), 10884 projection: t !== void 0 ? t : null, 10885 resolution: i, 10886 nextCenter: this.nextCenter_, 10887 nextResolution: this.nextResolution_, 10888 nextRotation: this.nextRotation_, 10889 rotation: s, 10890 zoom: this.getZoom() 10891 }; 10892 } 10893 /** 10894 * @return {ViewStateLayerStateExtent} Like `FrameState`, but just `viewState` and `extent`. 10895 */ 10896 getViewStateAndExtent() { 10897 return {
10898 viewState: this.getState(), 10899 extent: this.calculateExtent() 10900 }; 10901 } 10902 /** 10903 * Get the current zoom level. This method may return non-integer zoom levels 10904 * if the view does not constrain the resolution, or if an interaction or 10905 * animation is underway. 10906 * @return {number|undefined} Zoom. 10907 * @api 10908 */ 10909 getZoom() { 10910 let t; 10911 const i = this.getResolution(); 10912 return i !== void 0 && (t = this.getZoomForResolution(i)), t; 10913 } 10914 /** 10915 * Get the zoom level for a resolution. 10916 * @param {number} resolution The resolution. 10917 * @return {number|undefined} The zoom level for the provided resolution. 10918 * @api 10919 */ 10920 getZoomForResolution(t) { 10921 let i = this.minZoom_ || 0, s, n; 10922 if (this.resolutions_) { 10923 const r = ha(this.resolutions_, t, 1); 10924 i = r, s = this.resolutions_[r], r == this.resolutions_.length - 1 ? n = 2 : n = s / this.resolutions_[r + 1]; 10925 } else 10926 s = this.maxResolution_, n = this.zoomFactor_; 10927 return i + Math.log(s / t) / Math.log(n); 10928 } 10929 /** 10930 * Get the resolution for a zoom level. 10931 * @param {number} zoom Zoom level. 10932 * @return {number} The view resolution for the provided zoom level. 10933 * @api 10934 */ 10935 getResolutionForZoom(t) { 10936 if (this.resolutions_) { 10937 if (this.resolutions_.length <= 1) 10938 return 0; 10939 const i = Ot( 10940 Math.floor(t), 10941 0, 10942 this.resolutions_.length - 2 10943 ), s = this.resolutions_[i] / this.resolutions_[i + 1]; 10944 return this.resolutions_[i] / Math.pow(s, Ot(t - i, 0, 1)); 10945 } 10946 return this.maxResolution_ / Math.pow(this.zoomFactor_, t - this.minZoom_); 10947 } 10948 /** 10949 * Fit the given geometry or extent based on the given map size and border. 10950 * The size is pixel dimensions of the box to fit the extent into. 10951 * In most cases you will want to use the map size, that is `map.getSize()`. 10952 * Takes care of the map angle. 10953 * @param {import("./geom/SimpleGeometry.js").default|import("./extent.js").Extent} geometryOrExtent The geometry or 10954 * extent to fit the view to. 10955 * @param {FitOptions} [options] Options. 10956 * @api 10957 */ 10958 fit(t, i) { 10959 let s; 10960 if (at( 10961 Array.isArray(t) || typeof /** @type {?} */ 10962 t.getSimplifiedGeometry == "function", 10963 24 10964 ), Array.isArray(t)) { 10965 at(!Ts(t), 25); 10966 const n = He(t, this.getProjection()); 10967 s = Mu(n); 10968 } else if (t.getType() === "Circle") { 10969 const n = He( 10970 t.getExtent(), 10971 this.getProjection() 10972 ); 10973 s = Mu(n), s.rotate(this.getRotation(), ii(n)); 10974 } else 10975 s = t; 10976 this.fitInternal(s, i); 10977 } 10978 /** 10979 * Calculate rotated extent 10980 * @param {import("./geom/SimpleGeometry.js").default} geometry The geometry. 10981 * @return {import("./extent").Extent} The rotated extent for the geometry. 10982 */ 10983 rotatedExtentForGeometry(t) { 10984 const i = this.getRotation(), s = Math.cos(i), n = Math.sin(-i), r = t.getFlatCoordinates(), o = t.getStride(); 10985 let a = 1 / 0, l = 1 / 0, h = -1 / 0, c = -1 / 0; 10986 for (let u = 0, d = r.length; u < d; u += o) { 10987 const f = r[u] * s - r[u + 1] * n, g = r[u] * n + r[u + 1] * s; 10988 a = Math.min(a, f), l = Math.min(l, g), h = Math.max(h, f), c = Math.max(c, g); 10989 } 10990 return [a, l, h, c]; 10991 } 10992 /** 10993 * @param {import("./geom/SimpleGeometry.js").default} geometry The geometry. 10994 * @param {FitOptions} [options] Options. 10995 */ 10996 fitInternal(t, i) { 10997 i = i || {}; 10998 let s = i.size; 10999 s || (s = this.getViewportSizeMinusPadding_()); 11000 const n = i.padding !== void 0 ? i.padding : [0, 0, 0, 0], r = i.nearest !== void 0 ? i.nearest : !1; 11001 let o; 11002 i.minResolution !== void 0 ? o = i.minResolution : i.maxZoom !== void 0 ? o = this.getResolutionForZoom(i.maxZoom) : o = 0; 11003 const a = this.rotatedExtentForGeometry(t); 11004 let l = this.getResolutionForExtentInternal(a, [ 11005 s[0] - n[1] - n[3], 11006 s[1] - n[0] - n[2] 11007 ]); 11008 l = isNaN(l) ? o : Math.max(l, o), l = this.getConstrainedResolution(l, r ? 0 : 1); 11009 const h = this.getRotation(), c = Math.sin(h), u = Math.cos(h), d = ii(a); 11010 d[0] += (n[1] - n[3]) / 2 * l, d[1] += (n[0] - n[2]) / 2 * l; 11011 const f = d[0] * u - d[1] * c, g = d[1] * u + d[0] * c, _ = this.getConstrainedCenter([f, g], l), m = i.callback ? i.callback : xn; 11012 i.duration !== void 0 ? this.animateInternal( 11013 { 11014 resolution: l, 11015 center: _, 11016 duration: i.duration, 11017 easing: i.easing 11018 }, 11019 m 11020 ) : (this.targetResolution_ = l, this.targetCenter_ = _, this.applyTargetState_(!1, !0), Vr(m, !0)); 11021 } 11022 /** 11023 * Center on coordinate and view position. 11024 * @param {import("./coordinate.js").Coordinate} coordinate Coordinate. 11025 * @param {import("./size.js").Size} size Box pixel size. 11026 * @param {import("./pixel.js").Pixel} position Position on the view to center on. 11027 * @api 11028 */ 11029 centerOn(t, i, s) { 11030 this.centerOnInternal( 11031 It(t, this.getProjection()), 11032 i, 11033 s 11034 ); 11035 } 11036 /** 11037 * @param {import("./coordinate.js").Coordinate} coordinate Coordinate. 11038 * @param {import("./size.js").Size} size Box pixel size. 11039 * @param {import("./pixel.js").Pixel} position Position on the view to center on. 11040 */ 11041 centerOnInternal(t, i, s) { 11042 this.setCenterInternal( 11043 Da( 11044 t, 11045 i, 11046 s, 11047 this.getResolution(), 11048 this.getRotation() 11049 ) 11050 ); 11051 } 11052 /** 11053 * Calculates the shift between map and viewport center. 11054 * @param {import("./coordinate.js").Coordinate} center Center. 11055 * @param {number} resolution Resolution. 11056 * @param {number} rotation Rotation. 11057 * @param {import("./size.js").Size} size Size. 11058 * @return {Array<number>|undefined} Center shift. 11059 */ 11060 calculateCenterShift(t, i, s, n) { 11061 let r; 11062 const o = this.padding_; 11063 if (o && t) { 11064 const a = this.getViewportSizeMinusPadding_(-s), l = Da( 11065 t, 11066 n, 11067 [a[0] / 2 + o[3], a[1] / 2 + o[0]], 11068 i, 11069 s 11070 ); 11071 r = [ 11072 t[0] - l[0], 11073 t[1] - l[1] 11074 ]; 11075 } 11076 return r; 11077 } 11078 /** 11079 * @return {boolean} Is defined. 11080 */ 11081 isDef() { 11082 return !!this.getCenterInternal() && this.getResolution() !== void 0; 11083 } 11084 /** 11085 * Adds relative coordinates to the center of the view. Any extent constraint will apply. 11086 * @param {import("./coordinate.js").Coordinate} deltaCoordinates Relative value to add. 11087 * @api 11088 */ 11089 adjustCenter(t) { 11090 const i = Ms(this.targetCenter_, this.getProjection()); 11091 this.setCenter([ 11092 i[0] + t[0], 11093 i[1] + t[1] 11094 ]); 11095 } 11096 /** 11097 * Adds relative coordinates to the center of the view. Any extent constraint will apply. 11098 * @param {import("./coordinate.js").Coordinate} deltaCoordinates Relative value to add. 11099 */ 11100 adjustCenterInternal(t) { 11101 const i = this.targetCenter_; 11102 this.setCenterInternal([ 11103 i[0] + t[0], 11104 i[1] + t[1] 11105 ]); 11106 } 11107 /** 11108 * Multiply the view resolution by a ratio, optionally using an anchor. Any resolution 11109 * constraint will apply. 11110 * @param {number} ratio The ratio to apply on the view resolution. 11111 * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation. 11112 * @api 11113 */ 11114 adjustResolution(t, i) { 11115 i = i && It(i, this.getProjection()), this.adjustResolutionInternal(t, i); 11116 } 11117 /** 11118 * Multiply the view resolution by a ratio, optionally using an anchor. Any resolution 11119 * constraint will apply. 11120 * @param {number} ratio The ratio to apply on the view resolution. 11121 * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation. 11122 */ 11123 adjustResolutionInternal(t, i) { 11124 const s = this.getAnimating() || this.getInteracting(), n = this.getViewportSize_(this.getRotation()), r = this.constraints_.resolution( 11125 this.targetResolution_ * t, 11126 0, 11127 n, 11128 s 11129 ); 11130 i && (this.targetCenter_ = this.calculateCenterZoom(r, i)), this.targetResolution_ *= t, this.applyTargetState_(); 11131 } 11132 /** 11133 * Adds a value to the view zoom level, optionally using an anchor. Any resolution 11134 * constraint will apply. 11135 * @param {number} delta Relative value to add to the zoom level. 11136 * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation. 11137 * @api 11138 */ 11139 adjustZoom(t, i) { 11140 this.adjustResolution(Math.pow(this.zoomFactor_, -t), i); 11141 } 11142 /** 11143 * Adds a value to the view rotation, optionally using an anchor. Any rotation 11144 * constraint will apply. 11145 * @param {number} delta Relative value to add to the zoom rotation, in radians. 11146 * @param {import("./coordinate.js").Coordinate} [anchor] The rotation center. 11147 * @api 11148 */ 11149 adjustRotation(t, i) { 11150 i && (i = It(i, this.getProjection())), this.adjustRotationInternal(t, i); 11151 } 11152 /** 11153 * @param {number} delta Relative value to add to the zoom rotation, in radians. 11154 * @param {import("./coordinate.js").Coordinate} [anchor] The rotation center. 11155 */ 11156 adjustRotationInternal(t, i) { 11157 const s = this.getAnimating() || this.getInteracting(), n = this.constraints_.rotation( 11158 this.targetRotation_ + t, 11159 s 11160 ); 11161 i && (this.targetCenter_ = this.calculateCenterRotate(n, i)), this.targetRotation_ += t, this.applyTargetState_(); 11162 } 11163 /** 11164 * Set the center of the current view. Any extent constraint will apply. 11165 * @param {import("./coordinate.js").Coordinate|undefined} center The center of the view. 11166 * @observable 11167 * @api 11168 */ 11169 setCenter(t) { 11170 this.setCenterInternal( 11171 t && It(t, this.getProjection()) 11172 ); 11173 } 11174 /** 11175 * Set the center using the view projection (not the user projection). 11176 * @param {import("./coordinate.js").Coordinate|undefined} center The center of the view. 11177 */ 11178 setCenterInternal(t) { 11179 this.targetCenter_ = t, this.applyTargetState_(); 11180 } 11181 /** 11182 * @param {import("./ViewHint.js").default} hint Hint. 11183 * @param {number} delta Delta. 11184 * @return {number} New value. 11185 */ 11186 setHint(t, i) { 11187 return this.hints_[t] += i, this.changed(), this.hints_[t]; 11188 } 11189 /** 11190 * Set the resolution for this view. Any resolution constraint will apply. 11191 * @param {number|undefined} resolution The resolution of the view. 11192 * @observable 11193 * @api 11194 */ 11195 setResolution(t) { 11196 this.targetResolution_ = t, this.applyTargetState_(); 11197 } 11198 /** 11199 * Set the rotation for this view. Any rotation constraint will apply. 11200 * @param {number} rotation The rotation of the view in radians. 11201 * @observable 11202 * @api 11203 */ 11204 setRotation(t) { 11205 this.targetRotation_ = t, this.applyTargetState_(); 11206 } 11207 /** 11208 * Zoom to a specific zoom level. Any resolution constrain will apply. 11209 * @param {number} zoom Zoom level. 11210 * @api 11211 */ 11212 setZoom(t) { 11213 this.setResolution(this.getResolutionForZoom(t)); 11214 } 11215 /** 11216 * Recompute rotation/resolution/center based on target values. 11217 * Note: we have to compute rotation first, then resolution and center considering that 11218 * parameters can influence one another in case a view extent constraint is present. 11219 * @param {boolean}
11219 [doNotCancelAnims] Do not cancel animations. 11220 * @param {boolean} [forceMoving] Apply constraints as if the view is moving. 11221 * @private 11222 */ 11223 applyTargetState_(t, i) { 11224 const s = this.getAnimating() || this.getInteracting() || i, n = this.constraints_.rotation( 11225 this.targetRotation_, 11226 s 11227 ), r = this.getViewportSize_(n), o = this.constraints_.resolution( 11228 this.targetResolution_, 11229 0, 11230 r, 11231 s 11232 ), a = this.constraints_.center( 11233 this.targetCenter_, 11234 o, 11235 r, 11236 s, 11237 this.calculateCenterShift( 11238 this.targetCenter_, 11239 o, 11240 n, 11241 r 11242 ) 11243 ); 11244 this.get(Le.ROTATION) !== n && this.set(Le.ROTATION, n), this.get(Le.RESOLUTION) !== o && (this.set(Le.RESOLUTION, o), this.set("zoom", this.getZoom(), !0)), (!a || !this.get(Le.CENTER) || !Fe(this.get(Le.CENTER), a)) && this.set(Le.CENTER, a), this.getAnimating() && !t && this.cancelAnimations(), this.cancelAnchor_ = void 0; 11245 } 11246 /** 11247 * If any constraints need to be applied, an animation will be triggered. 11248 * This is typically done on interaction end. 11249 * Note: calling this with a duration of 0 will apply the constrained values straight away, 11250 * without animation. 11251 * @param {number} [duration] The animation duration in ms. 11252 * @param {number} [resolutionDirection] Which direction to zoom. 11253 * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation. 11254 */ 11255 resolveConstraints(t, i, s) { 11256 t = t !== void 0 ? t : 200; 11257 const n = i || 0, r = this.constraints_.rotation(this.targetRotation_), o = this.getViewportSize_(r), a = this.constraints_.resolution( 11258 this.targetResolution_, 11259 n, 11260 o 11261 ), l = this.constraints_.center( 11262 this.targetCenter_, 11263 a, 11264 o, 11265 !1, 11266 this.calculateCenterShift( 11267 this.targetCenter_, 11268 a, 11269 r, 11270 o 11271 ) 11272 ); 11273 if (t === 0 && !this.cancelAnchor_) { 11274 this.targetResolution_ = a, this.targetRotation_ = r, this.targetCenter_ = l, this.applyTargetState_(); 11275 return; 11276 } 11277 s = s || (t === 0 ? this.cancelAnchor_ : void 0), this.cancelAnchor_ = void 0, (this.getResolution() !== a || this.getRotation() !== r || !this.getCenterInternal() || !Fe(this.getCenterInternal(), l)) && (this.getAnimating() && this.cancelAnimations(), this.animateInternal({ 11278 rotation: r, 11279 center: l, 11280 resolution: a, 11281 duration: t, 11282 easing: Rn, 11283 anchor: s 11284 })); 11285 } 11286 /** 11287 * Notify the View that an interaction has started. 11288 * The view state will be resolved to a stable one if needed 11289 * (depending on its constraints). 11290 * @api 11291 */ 11292 beginInteraction() { 11293 this.resolveConstraints(0), this.setHint(Xt.INTERACTING, 1); 11294 } 11295 /** 11296 * Notify the View that an interaction has ended. The view state will be resolved 11297 * to a stable one if needed (depending on its constraints). 11298 * @param {number} [duration] Animation duration in ms. 11299 * @param {number} [resolutionDirection] Which direction to zoom. 11300 * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation. 11301 * @api 11302 */ 11303 endInteraction(t, i, s) { 11304 s = s && It(s, this.getProjection()), this.endInteractionInternal(t, i, s); 11305 } 11306 /** 11307 * Notify the View that an interaction has ended. The view state will be resolved 11308 * to a stable one if needed (depending on its constraints). 11309 * @param {number} [duration] Animation duration in ms. 11310 * @param {number} [resolutionDirection] Which direction to zoom. 11311 * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation. 11312 */ 11313 endInteractionInternal(t, i, s) { 11314 this.getInteracting() && (this.setHint(Xt.INTERACTING, -1), this.resolveConstraints(t, i, s)); 11315 } 11316 /** 11317 * Get a valid position for the view center according to the current constraints. 11318 * @param {import("./coordinate.js").Coordinate|undefined} targetCenter Target center position. 11319 * @param {number} [targetResolution] Target resolution. If not supplied, the current one will be used. 11320 * This is useful to guess a valid center position at a different zoom level. 11321 * @return {import("./coordinate.js").Coordinate|undefined} Valid center position. 11322 */ 11323 getConstrainedCenter(t, i) { 11324 const s = this.getViewportSize_(this.getRotation()); 11325 return this.constraints_.center( 11326 t, 11327 i || this.getResolution(), 11328 s 11329 ); 11330 } 11331 /** 11332 * Get a valid zoom level according to the current view constraints. 11333 * @param {number|undefined} targetZoom Target zoom. 11334 * @param {number} [direction=0] Indicate which resolution should be used 11335 * by a renderer if the view resolution does not match any resolution of the tile source. 11336 * If 0, the nearest resolution will be used. If 1, the nearest lower resolution 11337 * will be used. If -1, the nearest higher resolution will be used. 11338 * @return {number|undefined} Valid zoom level. 11339 */ 11340 getConstrainedZoom(t, i) { 11341 const s = this.getResolutionForZoom(t); 11342 return this.getZoomForResolution( 11343 this.getConstrainedResolution(s, i) 11344 ); 11345 } 11346 /** 11347 * Get a valid resolution according to the current view constraints. 11348 * @param {number|undefined} targetResolution Target resolution. 11349 * @param {number} [direction=0] Indicate which resolution should be used 11350 * by a renderer if the view resolution does not match any resolution of the tile source. 11351 * If 0, the nearest resolution will be used. If 1, the nearest lower resolution 11352 * will be used. If -1, the nearest higher resolution will be used. 11353 * @return {number|undefined} Valid resolution. 11354 */ 11355 getConstrainedResolution(t, i) { 11356 i = i || 0; 11357 const s = this.getViewportSize_(this.getRotation()); 11358 return this.constraints_.resolution(t, i, s); 11359 } 11360} 11361function Vr(e, t) { 11362 setTimeout(function() { 11363 e(t); 11364 }, 0); 11365} 11366function $E(e) { 11367 if (e.extent !== void 0) { 11368 const i = e.smoothExtentConstraint !== void 0 ? e.smoothExtentConstraint : !0; 11369 return _u(e.extent, e.constrainOnlyCenter, i); 11370 } 11371 const t = Vl(e.projection, "EPSG:3857"); 11372 if (e.multiWorld !== !0 && t.isGlobal()) { 11373 const i = t.getExtent().slice(); 11374 return i[0] = -1 / 0, i[2] = 1 / 0, _u(i, !1, !1); 11375 } 11376 return mE; 11377} 11378function YE(e) { 11379 let t, i, s, o = e.minZoom !== void 0 ? e.minZoom : Fa, a = e.maxZoom !== void 0 ? e.maxZoom : 28; 11380 const l = e.zoomFactor !== void 0 ? e.zoomFactor : 2, h = e.multiWorld !== void 0 ? e.multiWorld : !1, c = e.smoothResolutionConstraint !== void 0 ? e.smoothResolutionConstraint : !0, u = e.showFullExtent !== void 0 ? e.showFullExtent : !1, d = Vl(e.projection, "EPSG:3857"), f = d.getExtent(); 11381 let g = e.constrainOnlyCenter, _ = e.extent; 11382 if (!h && !_ && d.isGlobal() && (g = !1, _ = f), e.resolutions !== void 0) { 11383 const m = e.resolutions; 11384 i = m[o], s = m[a] !== void 0 ? m[a] : m[m.length - 1], e.constrainResolution ? t = pE( 11385 m, 11386 c, 11387 !g && _, 11388 u 11389 ) : t = mu( 11390 i, 11391 s, 11392 c, 11393 !g && _, 11394 u 11395 ); 11396 } else { 11397 const p = (f ? Math.max(mt(f), Yt(f)) : ( 11398 // use an extent that can fit the whole world if need be 11399 360 * er.degrees / d.getMetersPerUnit() 11400 )) / Eh / Math.pow(2, Fa), y = p / Math.pow(2, 28 - Fa); 11401 i = e.maxResolution, i !== void 0 ? o = 0 : i = p / Math.pow(l, o), s = e.minResolution, s === void 0 && (e.maxZoom !== void 0 ? e.maxResolution !== void 0 ? s = i / Math.pow(l, a) : s = p / Math.pow(l, a) : s = y), a = o + Math.floor( 11402 Math.log(i / s) / Math.log(l) 11403 ), s = i / Math.pow(l, a - o), e.constrainResolution ? t = yE( 11404 l, 11405 i, 11406 s, 11407 c, 11408 !g && _, 11409 u 11410 ) : t = mu( 11411 i, 11412 s, 11413 c, 11414 !g && _, 11415 u 11416 ); 11417 } 11418 return { 11419 constraint: t, 11420 maxResolution: i, 11421 minResolution: s, 11422 minZoom: o, 11423 zoomFactor: l 11424 }; 11425} 11426function KE(e) { 11427 if (e.enableRotation !== void 0 ? e.enableRotation : !0) { 11428 const i = e.constrainRotation; 11429 return i === void 0 || i === !0 ? vE() : i === !1 ? pu : typeof i == "number" ? xE(i) : pu; 11430 } 11431 return bh; 11432} 11433function VE(e) { 11434 return !(e.sourceCenter && e.targetCenter && !Fe(e.sourceCenter, e.targetCenter) || e.sourceResolution !== e.targetResolution || e.sourceRotation !== e.targetRotation); 11435} 11436function Da(e, t, i, s, n) {
11437 const r = Math.cos(-n); 11438 let o = Math.sin(-n), a = e[0] * r - e[1] * o, l = e[1] * r + e[0] * o; 11439 a += (t[0] / 2 - i[0]) * s, l += (i[1] - t[1] / 2) * s, o = -o; 11440 const h = a * r - l * o, c = l * r + a * o; 11441 return [h, c]; 11442} 11443const Ve = XE; 11444class qE extends Bf { 11445 /** 11446 * @param {Options<SourceType>} options Layer options. 11447 */ 11448 constructor(t) { 11449 const i = Object.assign({}, t); 11450 delete i.source, super(i), 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( 11451 Et.SOURCE, 11452 this.handleSourcePropertyChange_ 11453 ); 11454 const s = t.source ? ( 11455 /** @type {SourceType} */ 11456 t.source 11457 ) : null; 11458 this.setSource(s); 11459 } 11460 /** 11461 * @param {Array<import("./Layer.js").default>} [array] Array of layers (to be modified in place). 11462 * @return {Array<import("./Layer.js").default>} Array of layers. 11463 */ 11464 getLayersArray(t) { 11465 return t = t || [], t.push(this), t; 11466 } 11467 /** 11468 * @param {Array<import("./Layer.js").State>} [states] Optional list of layer states (to be modified in place). 11469 * @return {Array<import("./Layer.js").State>} List of layer states. 11470 */ 11471 getLayerStatesArray(t) { 11472 return t = t || [], t.push(this.getLayerState()), t; 11473 } 11474 /** 11475 * Get the layer source. 11476 * @return {SourceType|null} The layer source (or `null` if not yet set). 11477 * @observable 11478 * @api 11479 */ 11480 getSource() { 11481 return ( 11482 /** @type {SourceType} */ 11483 this.get(Et.SOURCE) || null 11484 ); 11485 } 11486 /** 11487 * @return {SourceType|null} The source being rendered. 11488 */ 11489 getRenderSource() { 11490 return this.getSource(); 11491 } 11492 /** 11493 * @return {import("../source/Source.js").State} Source state. 11494 */ 11495 getSourceState() { 11496 const t = this.getSource(); 11497 return t ? t.getState() : "undefined"; 11498 } 11499 /** 11500 * @private 11501 */ 11502 handleSourceChange_() { 11503 this.changed(), !(this.sourceReady_ || this.getSource().getState() !== "ready") && (this.sourceReady_ = !0, this.dispatchEvent("sourceready")); 11504 } 11505 /** 11506 * @private 11507 */ 11508 handleSourcePropertyChange_() { 11509 this.sourceChangeKey_ && (Mt(this.sourceChangeKey_), this.sourceChangeKey_ = null), this.sourceReady_ = !1; 11510 const t = this.getSource(); 11511 t && (this.sourceChangeKey_ = lt( 11512 t, 11513 et.CHANGE, 11514 this.handleSourceChange_, 11515 this 11516 ), t.getState() === "ready" && (this.sourceReady_ = !0, setTimeout(() => { 11517 this.dispatchEvent("sourceready"); 11518 }, 0))), this.changed(); 11519 } 11520 /** 11521 * @param {import("../pixel").Pixel} pixel Pixel. 11522 * @return {Promise<Array<import("../Feature").FeatureLike>>} Promise that resolves with 11523 * an array of features. 11524 */ 11525 getFeatures(t) { 11526 return this.renderer_ ? this.renderer_.getFeatures(t) : Promise.resolve([]); 11527 } 11528 /** 11529 * @param {import("../pixel").Pixel} pixel Pixel. 11530 * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data. 11531 */ 11532 getData(t) { 11533 return !this.renderer_ || !this.rendered ? null : this.renderer_.getData(t); 11534 } 11535 /** 11536 * The layer is visible on the map view, i.e. within its min/max resolution or zoom and 11537 * extent, not set to `visible: false`, and not inside a layer group that is set 11538 * to `visible: false`. 11539 * @param {View|import("../View.js").ViewStateLayerStateExtent} [view] View or {@link import("../Map.js").FrameState}. 11540 * Only required when the layer is not added to a map. 11541 * @return {boolean} The layer is visible in the map view. 11542 * @api 11543 */ 11544 isVisible(t) { 11545 let i; 11546 const s = this.getMapInternal(); 11547 !t && s && (t = s.getView()), t instanceof Ve ? i = { 11548 viewState: t.getState(), 11549 extent: t.calculateExtent() 11550 } : i = t, !i.layerStatesArray && s && (i.layerStatesArray = s.getLayerGroup().getLayerStatesArray()); 11551 let n; 11552 i.layerStatesArray ? n = i.layerStatesArray.find( 11553 (o) => o.layer === this 11554 ) : n = this.getLayerState(); 11555 const r = this.getExtent(); 11556 return Fh(n, i.viewState) && (!r || ee(r, i.extent)); 11557 } 11558 /** 11559 * Get the attributions of the source of this layer for the given view. 11560 * @param {View|import("../View.js").ViewStateLayerStateExtent} [view] View or {@link import("../Map.js").FrameState}. 11561 * Only required when the layer is not added to a map. 11562 * @return {Array<string>} Attributions for this layer at the given view. 11563 * @api 11564 */ 11565 getAttributions(t) { 11566 if (!this.isVisible(t)) 11567 return []; 11568 let i;
11569 const s = this.getSource(); 11570 if (s && (i = s.getAttributions()), !i) 11571 return []; 11572 const n = t instanceof Ve ? t.getViewStateAndExtent() : t; 11573 let r = i(n); 11574 return Array.isArray(r) || (r = [r]), r; 11575 } 11576 /** 11577 * In charge to manage the rendering of the layer. One layer type is 11578 * bounded with one layer renderer. 11579 * @param {?import("../Map.js").FrameState} frameState Frame state. 11580 * @param {HTMLElement} target Target which the renderer may (but need not) use 11581 * for rendering its content. 11582 * @return {HTMLElement|null} The rendered element. 11583 */ 11584 render(t, i) { 11585 const s = this.getRenderer(); 11586 return s.prepareFrame(t) ? (this.rendered = !0, s.renderFrame(t, i)) : null; 11587 } 11588 /** 11589 * Called when a layer is not visible during a map render. 11590 */ 11591 unrender() { 11592 this.rendered = !1; 11593 } 11594 /** 11595 * For use inside the library only. 11596 * @param {import("../Map.js").default|null} map Map. 11597 */ 11598 setMapInternal(t) { 11599 t || this.unrender(), this.set(Et.MAP, t); 11600 } 11601 /** 11602 * For use inside the library only. 11603 * @return {import("../Map.js").default|null} Map. 11604 */ 11605 getMapInternal() { 11606 return this.get(Et.MAP); 11607 } 11608 /** 11609 * Sets the layer to be rendered on top of other layers on a map. The map will 11610 * not manage this layer in its layers collection. This 11611 * is useful for temporary layers. To remove an unmanaged layer from the map, 11612 * use `#setMap(null)`. 11613 * 11614 * To add the layer to a map and have it managed by the map, use 11615 * {@link module:ol/Map~Map#addLayer} instead. 11616 * @param {import("../Map.js").default|null} map Map. 11617 * @api 11618 */ 11619 setMap(t) { 11620 this.mapPrecomposeKey_ && (Mt(this.mapPrecomposeKey_), this.mapPrecomposeKey_ = null), t || this.changed(), this.mapRenderKey_ && (Mt(this.mapRenderKey_), this.mapRenderKey_ = null), t && (this.mapPrecomposeKey_ = lt( 11621 t, 11622 Vi.PRECOMPOSE, 11623 function(i) { 11624 const n = /** @type {import("../render/Event.js").default} */ i.frameState.layerStatesArray, r = this.getLayerState(!1); 11625 at( 11626 !n.some(function(o) { 11627 return o.layer === r.layer; 11628 }), 11629 67 11630 ), n.push(r); 11631 }, 11632 this 11633 ), this.mapRenderKey_ = lt(this, et.CHANGE, t.render, t), this.changed()); 11634 } 11635 /** 11636 * Set the layer source. 11637 * @param {SourceType|null} source The layer source. 11638 * @observable 11639 * @api 11640 */ 11641 setSource(t) { 11642 this.set(Et.SOURCE, t); 11643 } 11644 /** 11645 * Get the renderer for this layer. 11646 * @return {RendererType|null} The layer renderer. 11647 */ 11648 getRenderer() { 11649 return this.renderer_ || (this.renderer_ = this.createRenderer()), this.renderer_; 11650 } 11651 /** 11652 * @return {boolean} The layer has a renderer. 11653 */ 11654 hasRenderer() { 11655 return !!this.renderer_; 11656 } 11657 /** 11658 * Create a renderer for this layer. 11659 * @return {RendererType} A layer renderer. 11660 * @protected 11661 */ 11662 createRenderer() { 11663 return null; 11664 } 11665 /** 11666 * Clean up. 11667 */ 11668 disposeInternal() { 11669 this.renderer_ && (this.renderer_.dispose(), delete this.renderer_), this.setSource(null), super.disposeInternal(); 11670 } 11671} 11672function Fh(e, t) { 11673 if (!e.visible) 11674 return !1; 11675 const i = t.resolution; 11676 if (i < e.minResolution || i >= e.maxResolution) 11677 return !1; 11678 const s = t.zoom; 11679 return s > e.minZoom && s <= e.maxZoom; 11680} 11681const Pr = qE; 11682class HE extends yh { 11683 /** 11684 * @param {import("../Map.js").default} map Map. 11685 */ 11686 constructor(t) { 11687 super(), this.map_ = t; 11688 } 11689 /** 11690 * @abstract 11691 * @param {import("../render/EventType.js").default} type Event type. 11692 * @param {import("../Map.js").FrameState} frameState Frame state. 11693 */ 11694 dispatchRenderEvent(t, i) { 11695 Z(); 11696 } 11697 /** 11698 * @param {import("../Map.js").FrameState} frameState FrameState. 11699 * @protected 11700 */ 11701 calculateMatrices2D(t) { 11702 const i = t.viewState, s = t.coordinateToPixelTransform, n = t.pixelToCoordinateTransform; 11703 si( 11704 s, 11705 t.size[0] / 2, 11706 t.size[1] / 2, 11707 1 / i.resolution, 11708 -1 / i.resolution, 11709 -i.rotation, 11710 -i.center[0], 11711 -i.center[1] 11712 ), ua(n, s); 11713 } 11714 /** 11715 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 11716 * @param {import("../Map.js").FrameState} frameState FrameState. 11717 * @param {number} hitTolerance Hit tolerance in pixels. 11718 * @param {boolean} checkWrapped Check for wrapped geometries. 11719 * @param {import("./vector.js").FeatureCallback<T>}
11719 callback Feature callback. 11720 * @param {S} thisArg Value to use as `this` when executing `callback`. 11721 * @param {function(this: U, import("../layer/Layer.js").default): boolean} layerFilter Layer filter 11722 * function, only layers which are visible and for which this function 11723 * returns `true` will be tested for features. By default, all visible 11724 * layers will be tested. 11725 * @param {U} thisArg2 Value to use as `this` when executing `layerFilter`. 11726 * @return {T|undefined} Callback result. 11727 * @template S,T,U 11728 */ 11729 forEachFeatureAtCoordinate(t, i, s, n, r, o, a, l) { 11730 let h; 11731 const c = i.viewState; 11732 function u(E, C, S, O) { 11733 return r.call(o, C, E ? S : null, O); 11734 } 11735 const d = c.projection, f = Fd(t.slice(), d), g = [[0, 0]]; 11736 if (d.canWrapX() && n) { 11737 const E = d.getExtent(), C = mt(E); 11738 g.push([-C, 0], [C, 0]); 11739 } 11740 const _ = i.layerStatesArray, m = _.length, p = ( 11741 /** @type {Array<HitMatch<T>>} */ 11742 [] 11743 ), y = []; 11744 for (let E = 0; E < g.length; E++) 11745 for (let C = m - 1; C >= 0; --C) { 11746 const S = _[C], O = S.layer; 11747 if (O.hasRenderer() && Fh(S, c) && a.call(l, O)) { 11748 const R = O.getRenderer(), j = O.getSource(); 11749 if (R && j) { 11750 const $ = j.getWrapX() ? f : t, q = u.bind( 11751 null, 11752 S.managed 11753 ); 11754 y[0] = $[0] + g[E][0], y[1] = $[1] + g[E][1], h = R.forEachFeatureAtCoordinate( 11755 y, 11756 i, 11757 s, 11758 q, 11759 p 11760 ); 11761 } 11762 if (h) 11763 return h; 11764 } 11765 } 11766 if (p.length === 0) 11767 return; 11768 const v = 1 / p.length; 11769 return p.forEach((E, C) => E.distanceSq += C * v), p.sort((E, C) => E.distanceSq - C.distanceSq), p.some((E) => h = E.callback(E.feature, E.layer, E.geometry)), h; 11770 } 11771 /** 11772 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 11773 * @param {import("../Map.js").FrameState} frameState FrameState. 11774 * @param {number} hitTolerance Hit tolerance in pixels. 11775 * @param {boolean} checkWrapped Check for wrapped geometries. 11776 * @param {function(this: U, import("../layer/Layer.js").default): boolean} layerFilter Layer filter 11777 * function, only layers which are visible and for which this function 11778 * returns `true` will be tested for features. By default, all visible 11779 * layers will be tested. 11780 * @param {U} thisArg Value to use as `this` when executing `layerFilter`. 11781 * @return {boolean} Is there a feature at the given coordinate? 11782 * @template U 11783 */ 11784 hasFeatureAtCoordinate(t, i, s, n, r, o) { 11785 return this.forEachFeatureAtCoordinate( 11786 t, 11787 i, 11788 s, 11789 n, 11790 bs, 11791 this, 11792 r, 11793 o 11794 ) !== void 0; 11795 } 11796 /** 11797 * @return {import("../Map.js").default} Map. 11798 */ 11799 getMap() { 11800 return this.map_; 11801 } 11802 /** 11803 * Render. 11804 * @abstract 11805 * @param {?import("../Map.js").FrameState} frameState Frame state. 11806 */ 11807 renderFrame(t) { 11808 Z(); 11809 } 11810 /** 11811 * @param {import("../Map.js").FrameState} frameState Frame state. 11812 * @protected 11813 */ 11814 scheduleExpireIconCache(t) { 11815 Lo.canExpireCache() && t.postRenderFunctions.push(ZE); 11816 } 11817} 11818function ZE(e, t) { 11819 Lo.expire(); 11820} 11821const JE = HE; 11822class QE extends Ae { 11823 /** 11824 * @param {import("./EventType.js").default} type Type. 11825 * @param {import("../transform.js").Transform} [inversePixelTransform] Transform for 11826 * CSS pixels to rendered pixels. 11827 * @param {import("../Map.js").FrameState} [frameState] Frame state. 11828 * @param {?(CanvasRenderingContext2D|WebGLRenderingContext)} [context] Context. 11829 */ 11830 constructor(t, i, s, n) { 11831 super(t), this.inversePixelTransform = i, this.frameState = s, this.context = n; 11832 } 11833} 11834const eg = QE, qr = "ol-hidden", ga = "ol-unselectable", Dh = "ol-control", Cu = "ol-collapsed", tM = new RegExp( 11835 [ 11836 "^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)", 11837 "(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)", 11838 "(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)", 11839 "(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?",
11840 "(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))", 11841 "(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))", 11842 `?\\s*([-,\\"\\'\\sa-z]+?)\\s*$` 11843 ].join(""), 11844 "i" 11845), bu = [ 11846 "style", 11847 "variant", 11848 "weight", 11849 "size", 11850 "lineHeight", 11851 "family" 11852], ig = function(e) { 11853 const t = e.match(tM); 11854 if (!t) 11855 return null; 11856 const i = ( 11857 /** @type {FontParameters} */ 11858 { 11859 lineHeight: "normal", 11860 size: "1.2em", 11861 style: "normal", 11862 weight: "normal", 11863 variant: "normal" 11864 } 11865 ); 11866 for (let s = 0, n = bu.length; s < n; ++s) { 11867 const r = t[s + 1]; 11868 r !== void 0 && (i[bu[s]] = r); 11869 } 11870 return i.families = i.family.split(/,\s?/), i; 11871}; 11872function re(e, t, i, s) { 11873 let n; 11874 return i && i.length ? n = i.shift() : xh ? n = new OffscreenCanvas(e || 300, t || 300) : n = document.createElement("canvas"), e && (n.width = e), t && (n.height = t), /** @type {CanvasRenderingContext2D} */ 11875 n.getContext("2d", s); 11876} 11877function _a(e) { 11878 const t = e.canvas; 11879 t.width = 1, t.height = 1, e.clearRect(0, 0, 1, 1); 11880} 11881function Su(e, t) { 11882 const i = t.parentNode; 11883 i && i.replaceChild(e, t); 11884} 11885function Sl(e) { 11886 return e && e.parentNode ? e.parentNode.removeChild(e) : null; 11887} 11888function eM(e) { 11889 for (; e.lastChild; ) 11890 e.removeChild(e.lastChild); 11891} 11892function iM(e, t) { 11893 const i = e.childNodes; 11894 for (let s = 0; ; ++s) { 11895 const n = i[s], r = t[s]; 11896 if (!n && !r) 11897 break; 11898 if (n !== r) { 11899 if (!n) { 11900 e.appendChild(r); 11901 continue; 11902 } 11903 if (!r) { 11904 e.removeChild(n), --s; 11905 continue; 11906 } 11907 e.insertBefore(r, n); 11908 } 11909 } 11910} 11911const sg = "10px sans-serif", yi = "#000", Do = "round", hr = [], cr = 0, Mn = "round", ur = 10, dr = "#000", fr = "center", No = "middle", us = [0, 0, 0, 0], gr = 1, hi = new ni(); 11912let zs = null, wl; 11913const Tl = {}, sM = function() { 11914 const t = "32px ", i = ["monospace", "serif"], s = i.length, n = "wmytzilWMYTZIL@#/&?$%10ï"; 11915 let r, o; 11916 function a(h, c, u) { 11917 let d = !0; 11918 for (let f = 0; f < s; ++f) { 11919 const g = i[f]; 11920 if (o = ko( 11921 h + " " + c + " " + t + g, 11922 n 11923 ), u != g) { 11924 const _ = ko( 11925 h + " " + c + " " + t + u + "," + g, 11926 n 11927 ); 11928 d = d && _ != o; 11929 } 11930 } 11931 return !!d; 11932 } 11933 function l() { 11934 let h = !0; 11935 const c = hi.getKeys(); 11936 for (let u = 0, d = c.length; u < d; ++u) { 11937 const f = c[u]; 11938 hi.get(f) < 100 && (a.apply(this, f.split(` 11939`)) ? (Sr(Tl), zs = null, wl = void 0, hi.set(f, 100)) : (hi.set(f, hi.get(f) + 1, !0), h = !1)); 11940 } 11941 h && (clearInterval(r), r = void 0); 11942 } 11943 return function(h) { 11944 const c = ig(h); 11945 if (!c) 11946 return; 11947 const u = c.families; 11948 for (let d = 0, f = u.length; d < f; ++d) { 11949 const g = u[d], _ = c.style + ` 11950` + c.weight + ` 11951` + g; 11952 hi.get(_) === void 0 && (hi.set(_, 100, !0), a(c.style, c.weight, g) || (hi.set(_, 0, !0), r === void 0 && (r = setInterval(l, 32)))); 11953 } 11954 }; 11955}(), nM = function() { 11956 let e; 11957 return function(t) { 11958 let i = Tl[t]; 11959 if (i == null) { 11960 if (xh) { 11961 const s = ig(t), n = ng(t, "Žg"); 11962 i = (isNaN(Number(s.lineHeight)) ? 1.2 : Number(s.lineHeight)) * (n.actualBoundingBoxAscent + n.actualBoundingBoxDescent); 11963 } else 11964 e || (e = document.createElement("div"), e.innerHTML = "M", e.style.minHeight = "0", e.style.maxHeight = "none", e.style.height = "auto", e.style.padding = "0", e.style.border = "none", e.style.position = "absolute", e.style.display = "block", e.style.left = "-99999px"), e.style.font = t, document.body.appendChild(e), i = e.offsetHeight, document.body.removeChild(e); 11965 Tl[t] = i; 11966 } 11967 return i; 11968 }; 11969}(); 11970function ng(e, t) { 11971 return zs || (zs = re(1, 1)), e != wl && (zs.font = e, wl = zs.font), zs.measureText(t); 11972} 11973function ko(e, t) { 11974 return ng(e, t).width; 11975} 11976function wu(e, t, i) { 11977 if (t in i) 11978 return i[t]; 11979 const s = t.split(` 11980`).reduce((n, r) => Math.max(n, ko(e, r)), 0); 11981 return i[t] = s, s; 11982} 11983function rM(e, t) { 11984 const i = [], s = [], n = []; 11985 let r = 0, o = 0, a = 0, l = 0; 11986 for (let h = 0, c = t.length; h <= c; h += 2) { 11987 const u = t[h]; 11988 if (u === ` 11989` || h === c) { 11990 r = Math.max(r, o), n.push(o), o = 0, a += l; 11991 continue; 11992 } 11993 const d = t[h + 1] || e.font, f = ko(d, u); 11994 i.push(f), o += f; 11995 const g = nM(d); 11996 s.push(g), l = Math.max(l, g); 11997 } 11998 return { width: r, height: a, widths: i, heights: s, lineWidths: n }; 11999} 12000function oM(e, t, i, s, n, r, o, a, l, h, c) { 12001 e.save(), i !== 1 && (e.globalAlpha *= i), t && e.setTransform.apply(e, t), /** @type {*} */
12002 s.contextInstructions ? (e.translate(l, h), e.scale(c[0], c[1]), aM( 12003 /** @type {Label} */ 12004 s, 12005 e 12006 )) : c[0] < 0 || c[1] < 0 ? (e.translate(l, h), e.scale(c[0], c[1]), e.drawImage( 12007 /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */ 12008 s, 12009 n, 12010 r, 12011 o, 12012 a, 12013 0, 12014 0, 12015 o, 12016 a 12017 )) : e.drawImage( 12018 /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */ 12019 s, 12020 n, 12021 r, 12022 o, 12023 a, 12024 l, 12025 h, 12026 o * c[0], 12027 a * c[1] 12028 ), e.restore(); 12029} 12030function aM(e, t) { 12031 const i = e.contextInstructions; 12032 for (let s = 0, n = i.length; s < n; s += 2) 12033 Array.isArray(i[s + 1]) ? t[i[s]].apply( 12034 t, 12035 i[s + 1] 12036 ) : t[i[s]] = i[s + 1]; 12037} 12038class lM extends JE { 12039 /** 12040 * @param {import("../Map.js").default} map Map. 12041 */ 12042 constructor(t) { 12043 super(t), this.fontChangeListenerKey_ = lt( 12044 hi, 12045 yn.PROPERTYCHANGE, 12046 t.redrawText.bind(t) 12047 ), this.element_ = document.createElement("div"); 12048 const i = this.element_.style; 12049 i.position = "absolute", i.width = "100%", i.height = "100%", i.zIndex = "0", this.element_.className = ga + " ol-layers"; 12050 const s = t.getViewport(); 12051 s.insertBefore(this.element_, s.firstChild || null), this.children_ = [], this.renderedVisible_ = !0; 12052 } 12053 /** 12054 * @param {import("../render/EventType.js").default} type Event type. 12055 * @param {import("../Map.js").FrameState} frameState Frame state. 12056 */ 12057 dispatchRenderEvent(t, i) { 12058 const s = this.getMap(); 12059 if (s.hasListener(t)) { 12060 const n = new eg(t, void 0, i); 12061 s.dispatchEvent(n); 12062 } 12063 } 12064 disposeInternal() { 12065 Mt(this.fontChangeListenerKey_), this.element_.parentNode.removeChild(this.element_), super.disposeInternal(); 12066 } 12067 /** 12068 * Render. 12069 * @param {?import("../Map.js").FrameState} frameState Frame state. 12070 */ 12071 renderFrame(t) { 12072 if (!t) { 12073 this.renderedVisible_ && (this.element_.style.display = "none", this.renderedVisible_ = !1); 12074 return; 12075 } 12076 this.calculateMatrices2D(t), this.dispatchRenderEvent(Vi.PRECOMPOSE, t); 12077 const i = t.layerStatesArray.sort(function(o, a) { 12078 return o.zIndex - a.zIndex; 12079 }), s = t.viewState; 12080 this.children_.length = 0; 12081 const n = []; 12082 let r = null; 12083 for (let o = 0, a = i.length; o < a; ++o) { 12084 const l = i[o]; 12085 t.layerIndex = o; 12086 const h = l.layer, c = h.getSourceState(); 12087 if (!Fh(l, s) || c != "ready" && c != "undefined") { 12088 h.unrender(); 12089 continue; 12090 } 12091 const u = h.render(t, r); 12092 u && (u !== r && (this.children_.push(u), r = u), "getDeclutter" in h && n.push( 12093 /** @type {import("../layer/BaseVector.js").default} */ 12094 h 12095 )); 12096 } 12097 for (let o = n.length - 1; o >= 0; --o) 12098 n[o].renderDeclutter(t); 12099 iM(this.element_, this.children_), this.dispatchRenderEvent(Vi.POSTCOMPOSE, t), this.renderedVisible_ || (this.element_.style.display = "", this.renderedVisible_ = !0), this.scheduleExpireIconCache(t); 12100 } 12101} 12102const hM = lM; 12103class Fi extends Ae { 12104 /** 12105 * @param {EventType} type The event type. 12106 * @param {BaseLayer} layer The layer. 12107 */ 12108 constructor(t, i) { 12109 super(t), this.layer = i; 12110 } 12111} 12112const Na = { 12113 LAYERS: "layers" 12114}; 12115class Nh extends Bf { 12116 /** 12117 * @param {Options} [options] Layer options. 12118 */ 12119 constructor(t) { 12120 t = t || {}; 12121 const i = ( 12122 /** @type {Options} */ 12123 Object.assign({}, t) 12124 ); 12125 delete i.layers; 12126 let s = t.layers; 12127 super(i), this.on, this.once, this.un, this.layersListenerKeys_ = [], this.listenerKeys_ = {}, this.addChangeListener(Na.LAYERS, this.handleLayersChanged_), s ? Array.isArray(s) ? s = new Pe(s.slice(), { unique: !0 }) : at(typeof /** @type {?} */ 12128 s.getArray == "function", 43) : s = new Pe(void 0, { unique: !0 }), this.setLayers(s); 12129 } 12130 /** 12131 * @private 12132 */ 12133 handleLayerChange_() { 12134 this.changed(); 12135 } 12136 /** 12137 * @private 12138 */ 12139 handleLayersChanged_() { 12140 this.layersListenerKeys_.forEach(Mt), this.layersListenerKeys_.length = 0; 12141 const t = this.getLayers(); 12142 this.layersListenerKeys_.push( 12143 lt(t, $t.ADD, this.handleLayersAdd_, this), 12144 lt(t, $t.REMOVE, this.handleLayersRemove_, this) 12145 ); 12146 for (const s in this.listenerKeys_)
12147 this.listenerKeys_[s].forEach(Mt); 12148 Sr(this.listenerKeys_); 12149 const i = t.getArray(); 12150 for (let s = 0, n = i.length; s < n; s++) { 12151 const r = i[s]; 12152 this.registerLayerListeners_(r), this.dispatchEvent(new Fi("addlayer", r)); 12153 } 12154 this.changed(); 12155 } 12156 /** 12157 * @param {BaseLayer} layer The layer. 12158 */ 12159 registerLayerListeners_(t) { 12160 const i = [ 12161 lt( 12162 t, 12163 yn.PROPERTYCHANGE, 12164 this.handleLayerChange_, 12165 this 12166 ), 12167 lt(t, et.CHANGE, this.handleLayerChange_, this) 12168 ]; 12169 t instanceof Nh && i.push( 12170 lt(t, "addlayer", this.handleLayerGroupAdd_, this), 12171 lt(t, "removelayer", this.handleLayerGroupRemove_, this) 12172 ), this.listenerKeys_[ot(t)] = i; 12173 } 12174 /** 12175 * @param {GroupEvent} event The layer group event. 12176 */ 12177 handleLayerGroupAdd_(t) { 12178 this.dispatchEvent(new Fi("addlayer", t.layer)); 12179 } 12180 /** 12181 * @param {GroupEvent} event The layer group event. 12182 */ 12183 handleLayerGroupRemove_(t) { 12184 this.dispatchEvent(new Fi("removelayer", t.layer)); 12185 } 12186 /** 12187 * @param {import("../Collection.js").CollectionEvent<import("./Base.js").default>} collectionEvent CollectionEvent. 12188 * @private 12189 */ 12190 handleLayersAdd_(t) { 12191 const i = t.element; 12192 this.registerLayerListeners_(i), this.dispatchEvent(new Fi("addlayer", i)), this.changed(); 12193 } 12194 /** 12195 * @param {import("../Collection.js").CollectionEvent<import("./Base.js").default>} collectionEvent CollectionEvent. 12196 * @private 12197 */ 12198 handleLayersRemove_(t) { 12199 const i = t.element, s = ot(i); 12200 this.listenerKeys_[s].forEach(Mt), delete this.listenerKeys_[s], this.dispatchEvent(new Fi("removelayer", i)), this.changed(); 12201 } 12202 /** 12203 * Returns the {@link module:ol/Collection~Collection collection} of {@link module:ol/layer/Layer~Layer layers} 12204 * in this group. 12205 * @return {!Collection<import("./Base.js").default>} Collection of 12206 * {@link module:ol/layer/Base~BaseLayer layers} that are part of this group. 12207 * @observable 12208 * @api 12209 */ 12210 getLayers() { 12211 return ( 12212 /** @type {!Collection<import("./Base.js").default>} */ 12213 this.get(Na.LAYERS) 12214 ); 12215 } 12216 /** 12217 * Set the {@link module:ol/Collection~Collection collection} of {@link module:ol/layer/Layer~Layer layers} 12218 * in this group. 12219 * @param {!Collection<import("./Base.js").default>} layers Collection of 12220 * {@link module:ol/layer/Base~BaseLayer layers} that are part of this group. 12221 * @observable 12222 * @api 12223 */ 12224 setLayers(t) { 12225 const i = this.getLayers(); 12226 if (i) { 12227 const s = i.getArray(); 12228 for (let n = 0, r = s.length; n < r; ++n) 12229 this.dispatchEvent(new Fi("removelayer", s[n])); 12230 } 12231 this.set(Na.LAYERS, t); 12232 } 12233 /** 12234 * @param {Array<import("./Layer.js").default>} [array] Array of layers (to be modified in place). 12235 * @return {Array<import("./Layer.js").default>} Array of layers. 12236 */ 12237 getLayersArray(t) { 12238 return t = t !== void 0 ? t : [], this.getLayers().forEach(function(i) { 12239 i.getLayersArray(t); 12240 }), t; 12241 } 12242 /** 12243 * Get the layer states list and use this groups z-index as the default 12244 * for all layers in this and nested groups, if it is unset at this point. 12245 * If dest is not provided and this group's z-index is undefined 12246 * 0 is used a the default z-index. 12247 * @param {Array<import("./Layer.js").State>} [dest] Optional list 12248 * of layer states (to be modified in place). 12249 * @return {Array<import("./Layer.js").State>} List of layer states. 12250 */ 12251 getLayerStatesArray(t) { 12252 const i = t !== void 0 ? t : [], s = i.length; 12253 this.getLayers().forEach(function(o) { 12254 o.getLayerStatesArray(i); 12255 }); 12256 const n = this.getLayerState(); 12257 let r = n.zIndex; 12258 !t && n.zIndex === void 0 && (r = 0); 12259 for (let o = s, a = i.length; o < a; o++) { 12260 const l = i[o]; 12261 l.opacity *= n.opacity, l.visible = l.visible && n.visible, l.maxResolution = Math.min( 12262 l.maxResolution, 12263 n.maxResolution 12264 ), l.minResolution = Math.max( 12265 l.minResolution, 12266 n.minResolution 12267 ), l.minZoom = Math.max(l.minZoom, n.minZoom), l.maxZoom = Math.min(l.maxZoom, n.maxZoom), n.extent !== void 0 && (l.extent !== void 0 ? l.extent = fs( 12268 l.extent, 12269 n.extent 12270 ) : l.extent = n.extent), l.zIndex === void 0 && (l.zIndex = r); 12271 } 12272 return i; 12273 } 12274 /** 12275 * @return {import("../source/Source.js").State} Source state. 12276 */ 12277 getSourceState() { 12278 return "ready"; 12279 } 12280} 12281const ma = Nh; 12282class cM extends Ae { 12283 /** 12284 * @param {string} type Event type. 12285 * @param {import("./Map.js").default} map Map. 12286 * @param {?import("./Map.js").FrameState} [frameState] Frame state. 12287 */ 12288 constructor(t, i, s) { 12289 super(t), this.map = i, this.frameState = s !== void 0 ? s : null; 12290 } 12291} 12292const js = cM; 12293class uM extends js { 12294 /** 12295 * @param {string} type Event type. 12296 * @param {import("./Map.js").default} map Map. 12297 * @param {EVENT} originalEvent Original event. 12298 * @param {boolean} [dragging] Is the map currently being dragged? 12299 * @param {import("./Map.js").FrameState} [frameState] Frame state. 12300 * @param {Array<PointerEvent>} [activePointers] Active pointers. 12301 */ 12302 constructor(t, i, s, n, r, o) { 12303 super(t, i, r), this.originalEvent = s, this.pixel_ = null, this.coordinate_ = null, this.dragging = n !== void 0 ? n : !1, this.activePointers = o; 12304 } 12305 /** 12306 * The map pixel relative to the viewport corresponding to the original event. 12307 * @type {import("./pixel.js").Pixel} 12308 * @api 12309 */ 12310 get pixel() { 12311 return this.pixel_ || (this.pixel_ = this.map.getEventPixel(this.originalEvent)), this.pixel_; 12312 } 12313 set pixel(t) { 12314 this.pixel_ = t; 12315 } 12316 /** 12317 * The coordinate corresponding to the original browser event. This will be in the user 12318 * projection if one is set. Otherwise it will be in the view projection. 12319 * @type {import("./coordinate.js").Coordinate} 12320 * @api 12321 */ 12322 get coordinate() { 12323 return this.coordinate_ || (this.coordinate_ = this.map.getCoordinateFromPixel(this.pixel)), this.coordinate_; 12324 } 12325 set coordinate(t) { 12326 this.coordinate_ = t; 12327 } 12328 /** 12329 * Prevents the default browser action. 12330 * See https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault. 12331 * @api 12332 */ 12333 preventDefault() { 12334 super.preventDefault(), "preventDefault" in this.originalEvent && this.originalEvent.preventDefault(); 12335 } 12336 /** 12337 * Prevents further propagation of the current event. 12338 * See https://developer.mozilla.org/en-US/docs/Web/API/event.stopPropagation. 12339 * @api 12340 */ 12341 stopPropagation() { 12342 super.stopPropagation(), "stopPropagation" in this.originalEvent && this.originalEvent.stopPropagation(); 12343 } 12344} 12345const ui = uM, dt = { 12346 /** 12347 * A true single click with no dragging and no double click. Note that this 12348 * event is delayed by 250 ms to ensure that it is not a double click. 12349 * @event module:ol/MapBrowserEvent~MapBrowserEvent#singleclick 12350 * @api 12351 */
12352 SINGLECLICK: "singleclick", 12353 /** 12354 * A click with no dragging. A double click will fire two of this. 12355 * @event module:ol/MapBrowserEvent~MapBrowserEvent#click 12356 * @api 12357 */ 12358 CLICK: et.CLICK, 12359 /** 12360 * A true double click, with no dragging. 12361 * @event module:ol/MapBrowserEvent~MapBrowserEvent#dblclick 12362 * @api 12363 */ 12364 DBLCLICK: et.DBLCLICK, 12365 /** 12366 * Triggered when a pointer is dragged. 12367 * @event module:ol/MapBrowserEvent~MapBrowserEvent#pointerdrag 12368 * @api 12369 */ 12370 POINTERDRAG: "pointerdrag", 12371 /** 12372 * Triggered when a pointer is moved. Note that on touch devices this is 12373 * triggered when the map is panned, so is not the same as mousemove. 12374 * @event module:ol/MapBrowserEvent~MapBrowserEvent#pointermove 12375 * @api 12376 */ 12377 POINTERMOVE: "pointermove", 12378 POINTERDOWN: "pointerdown", 12379 POINTERUP: "pointerup", 12380 POINTEROVER: "pointerover", 12381 POINTEROUT: "pointerout", 12382 POINTERENTER: "pointerenter", 12383 POINTERLEAVE: "pointerleave", 12384 POINTERCANCEL: "pointercancel" 12385}, Rl = { 12386 POINTERMOVE: "pointermove", 12387 POINTERDOWN: "pointerdown", 12388 POINTERUP: "pointerup", 12389 POINTEROVER: "pointerover", 12390 POINTEROUT: "pointerout", 12391 POINTERENTER: "pointerenter", 12392 POINTERLEAVE: "pointerleave", 12393 POINTERCANCEL: "pointercancel" 12394}; 12395class dM extends Ir { 12396 /** 12397 * @param {import("./Map.js").default} map The map with the viewport to listen to events on. 12398 * @param {number} [moveTolerance] The minimal distance the pointer must travel to trigger a move. 12399 */ 12400 constructor(t, i) { 12401 super(t), this.map_ = t, this.clickTimeoutId_, this.emulateClicks_ = !1, this.dragging_ = !1, this.dragListenerKeys_ = [], this.moveTolerance_ = i === void 0 ? 1 : i, this.down_ = null; 12402 const s = this.map_.getViewport(); 12403 this.activePointers_ = [], this.trackedTouches_ = {}, this.element_ = s, this.pointerdownListenerKey_ = lt( 12404 s, 12405 Rl.POINTERDOWN, 12406 this.handlePointerDown_, 12407 this 12408 ), this.originalPointerMoveEvent_, this.relayedListenerKey_ = lt( 12409 s, 12410 Rl.POINTERMOVE, 12411 this.relayMoveEvent_, 12412 this 12413 ), this.boundHandleTouchMove_ = this.handleTouchMove_.bind(this), this.element_.addEventListener( 12414 et.TOUCHMOVE, 12415 this.boundHandleTouchMove_, 12416 zf ? { passive: !1 } : !1 12417 ); 12418 } 12419 /** 12420 * @param {PointerEvent} pointerEvent Pointer 12421 * event. 12422 * @private 12423 */ 12424 emulateClick_(t) { 12425 let i = new ui( 12426 dt.CLICK, 12427 this.map_, 12428 t 12429 ); 12430 this.dispatchEvent(i), this.clickTimeoutId_ !== void 0 ? (clearTimeout(this.clickTimeoutId_), this.clickTimeoutId_ = void 0, i = new ui( 12431 dt.DBLCLICK, 12432 this.map_, 12433 t 12434 ), this.dispatchEvent(i)) : this.clickTimeoutId_ = setTimeout(() => { 12435 this.clickTimeoutId_ = void 0; 12436 const s = new ui( 12437 dt.SINGLECLICK, 12438 this.map_, 12439 t 12440 ); 12441 this.dispatchEvent(s); 12442 }, 250); 12443 } 12444 /** 12445 * Keeps track on how many pointers are currently active. 12446 * 12447 * @param {PointerEvent} pointerEvent Pointer 12448 * event. 12449 * @private 12450 */ 12451 updateActivePointers_(t) { 12452 const i = t, s = i.pointerId; 12453 if (i.type == dt.POINTERUP || i.type == dt.POINTERCANCEL) { 12454 delete this.trackedTouches_[s]; 12455 for (const n in this.trackedTouches_) 12456 if (this.trackedTouches_[n].target !== i.target) { 12457 delete this.trackedTouches_[n]; 12458 break; 12459 } 12460 } else 12461 (i.type == dt.POINTERDOWN || i.type == dt.POINTERMOVE) && (this.trackedTouches_[s] = i); 12462 this.activePointers_ = Object.values(this.trackedTouches_); 12463 } 12464 /** 12465 * @param {PointerEvent} pointerEvent Pointer 12466 * event. 12467 * @private 12468 */ 12469 handlePointerUp_(t) { 12470 this.updateActivePointers_(t); 12471 const i = new ui( 12472 dt.POINTERUP, 12473 this.map_, 12474 t, 12475 void 0, 12476 void 0, 12477 this.activePointers_ 12478 ); 12479 this.dispatchEvent(i), this.emulateClicks_ && !i.defaultPrevented && !this.dragging_ && this.isMouseActionButton_(t) && this.emulateClick_(this.down_), this.activePointers_.length === 0 && (this.dragListenerKeys_.forEach(Mt), this.dragListenerKeys_.length = 0, this.dragging_ = !1, this.down_ = null); 12480 } 12481 /** 12482 * @param {PointerEvent} pointerEvent Pointer 12483 * event. 12484 * @return {boolean} If the left mouse button was pressed. 12485 * @private 12486 */ 12487 isMouseActionButton_(t) { 12488 return t.button === 0; 12489 } 12490 /** 12491 * @param {PointerEvent} pointerEvent Pointer 12492 * event. 12493 * @private 12494 */ 12495 handlePointerDown_(t) { 12496 this.emulateClicks_ = this.activePointers_.length === 0, this.updateActivePointers_(t); 12497 const i = new ui( 12498 dt.POINTERDOWN, 12499 this.map_, 12500 t, 12501 void 0, 12502 void 0, 12503 this.activePointers_ 12504 ); 12505 if (this.dispatchEvent(i), this.down_ = new PointerEvent(t.type, t), Object.defineProperty(this.down_, "target", { 12506 writable: !1, 12507 value: t.target 12508 }), this.dragListenerKeys_.length === 0) { 12509 const s = this.map_.getOwnerDocument(); 12510 this.dragListenerKeys_.push( 12511 lt( 12512 s, 12513 dt.POINTERMOVE, 12514 this.handlePointerMove_, 12515 this 12516 ), 12517 lt(s, dt.POINTERUP, this.handlePointerUp_, this), 12518 /* Note that the listener for `pointercancel is set up on 12519 * `pointerEventHandler_` and not `documentPointerEventHandler_` like 12520 * the `pointerup` and `pointermove` listeners. 12521 * 12522 * The reason for this is the following: `TouchSource.vacuumTouches_()` 12523 * issues `pointercancel` events, when there was no `touchend` for a 12524 * `touchstart`. Now, let's say a first `touchstart` is registered on 12525 * `pointerEventHandler_`. The `documentPointerEventHandler_` is set up. 12526 * But `documentPointerEventHandler_` doesn't know about the first 12527 * `touchstart`. If there is no `touchend` for the `touchstart`, we can 12528 * only receive a `touchcancel` from `pointerEventHandler_`, because it is 12529 * only registered there. 12530 */ 12531 lt( 12532 this.element_, 12533 dt.POINTERCANCEL, 12534 this.handlePointerUp_, 12535 this 12536 ) 12537 ), this.element_.getRootNode && this.element_.getRootNode() !== s && this.dragListenerKeys_.push( 12538 lt( 12539 this.element_.getRootNode(), 12540 dt.POINTERUP, 12541 this.handlePointerUp_, 12542 this 12543 ) 12544 ); 12545 } 12546 } 12547 /** 12548 * @param {PointerEvent} pointerEvent Pointer 12549 * event. 12550 * @private 12551 */ 12552 handlePointerMove_(t) { 12553 if (this.isMoving_(t)) { 12554 this.updateActivePointers_(t), this.dragging_ = !0; 12555 const i = new ui( 12556 dt.POINTERDRAG, 12557 this.map_, 12558 t, 12559 this.dragging_, 12560 void 0, 12561 this.activePointers_ 12562 ); 12563 this.dispatchEvent(i); 12564 } 12565 } 12566 /** 12567 * Wrap and relay a pointermove event. 12568 * @param {PointerEvent} pointerEvent Pointer 12569 * event. 12570 * @private 12571 */ 12572 relayMoveEvent_(t) { 12573 this.originalPointerMoveEvent_ = t; 12574 const i = !!(this.down_ && this.isMoving_(t)); 12575 this.dispatchEvent( 12576 new ui( 12577 dt.POINTERMOVE, 12578 this.map_, 12579 t, 12580 i 12581 ) 12582 ); 12583 } 12584 /** 12585 * Flexible handling of a `touch-action: none` css equivalent: because calling 12586 * `preventDefault()` on a `pointermove` event does not stop n
12586ative page scrolling 12587 * and zooming, we also listen for `touchmove` and call `preventDefault()` on it 12588 * when an interaction (currently `DragPan` handles the event. 12589 * @param {TouchEvent} event Event. 12590 * @private 12591 */ 12592 handleTouchMove_(t) { 12593 const i = this.originalPointerMoveEvent_; 12594 (!i || i.defaultPrevented) && (typeof t.cancelable != "boolean" || t.cancelable === !0) && t.preventDefault(); 12595 } 12596 /** 12597 * @param {PointerEvent} pointerEvent Pointer 12598 * event. 12599 * @return {boolean} Is moving. 12600 * @private 12601 */ 12602 isMoving_(t) { 12603 return this.dragging_ || Math.abs(t.clientX - this.down_.clientX) > this.moveTolerance_ || Math.abs(t.clientY - this.down_.clientY) > this.moveTolerance_; 12604 } 12605 /** 12606 * Clean up. 12607 */ 12608 disposeInternal() { 12609 this.relayedListenerKey_ && (Mt(this.relayedListenerKey_), this.relayedListenerKey_ = null), this.element_.removeEventListener( 12610 et.TOUCHMOVE, 12611 this.boundHandleTouchMove_ 12612 ), this.pointerdownListenerKey_ && (Mt(this.pointerdownListenerKey_), this.pointerdownListenerKey_ = null), this.dragListenerKeys_.forEach(Mt), this.dragListenerKeys_.length = 0, this.element_ = null, super.disposeInternal(); 12613 } 12614} 12615const fM = dM, Li = { 12616 /** 12617 * Triggered after a map frame is rendered. 12618 * @event module:ol/MapEvent~MapEvent#postrender 12619 * @api 12620 */ 12621 POSTRENDER: "postrender", 12622 /** 12623 * Triggered when the map starts moving. 12624 * @event module:ol/MapEvent~MapEvent#movestart 12625 * @api 12626 */ 12627 MOVESTART: "movestart", 12628 /** 12629 * Triggered after the map is moved. 12630 * @event module:ol/MapEvent~MapEvent#moveend 12631 * @api 12632 */ 12633 MOVEEND: "moveend", 12634 /** 12635 * Triggered when loading of additional map data (tiles, images, features) starts. 12636 * @event module:ol/MapEvent~MapEvent#loadstart 12637 * @api 12638 */ 12639 LOADSTART: "loadstart", 12640 /** 12641 * Triggered when loading of additional map data has completed. 12642 * @event module:ol/MapEvent~MapEvent#loadend 12643 * @api 12644 */ 12645 LOADEND: "loadend" 12646}, Qt = { 12647 LAYERGROUP: "layergroup", 12648 SIZE: "size", 12649 TARGET: "target", 12650 VIEW: "view" 12651}, Go = 1 / 0; 12652class gM { 12653 /** 12654 * @param {function(T): number} priorityFunction Priority function. 12655 * @param {function(T): string} keyFunction Key function. 12656 */ 12657 constructor(t, i) { 12658 this.priorityFunction_ = t, this.keyFunction_ = i, this.elements_ = [], this.priorities_ = [], this.queuedElements_ = {}; 12659 } 12660 /** 12661 * FIXME empty description for jsdoc 12662 */ 12663 clear() { 12664 this.elements_.length = 0, this.priorities_.length = 0, Sr(this.queuedElements_); 12665 } 12666 /** 12667 * Remove and return the highest-priority element. O(log N). 12668 * @return {T} Element. 12669 */ 12670 dequeue() { 12671 const t = this.elements_, i = this.priorities_, s = t[0]; 12672 t.length == 1 ? (t.length = 0, i.length = 0) : (t[0] = t.pop(), i[0] = i.pop(), this.siftUp_(0)); 12673 const n = this.keyFunction_(s); 12674 return delete this.queuedElements_[n], s; 12675 } 12676 /** 12677 * Enqueue an element. O(log N). 12678 * @param {T} element Element. 12679 * @return {boolean} The element was added to the queue. 12680 */ 12681 enqueue(t) { 12682 at(!(this.keyFunction_(t) in this.queuedElements_), 31); 12683 const i = this.priorityFunction_(t); 12684 return i != Go ? (this.elements_.push(t), this.priorities_.push(i), this.queuedElements_[this.keyFunction_(t)] = !0, this.siftDown_(0, this.elements_.length - 1), !0) : !1; 12685 } 12686 /** 12687 * @return {number} Count. 12688 */ 12689 getCount() { 12690 return this.elements_.length; 12691 } 12692 /** 12693 * Gets the index of the left child of the node at the given index. 12694 * @param {number} index The index of the node to get the left child for. 12695 * @return {number} The index of the left child. 12696 * @private 12697 */ 12698 getLeftChildIndex_(t) { 12699 return t * 2 + 1; 12700 } 12701 /** 12702 * Gets the index of the right child of the node at the given index. 12703 * @param {number} index The index of the node to get the right child for. 12704 * @return {number} The index of the right child. 12705 * @private 12706 */ 12707 getRightChildIndex_(t) { 12708 return t * 2 + 2; 12709 } 12710 /** 12711 * Gets the index of the parent of the node at the given index. 12712 * @param {number} index The index of the node to get the parent for. 12713 * @return {number} The index of the parent. 12714 * @private 12715 */ 12716 getParentIndex_(t) { 12717 return t - 1 >> 1; 12718 } 12719 /**
12720 * Make this a heap. O(N). 12721 * @private 12722 */ 12723 heapify_() { 12724 let t; 12725 for (t = (this.elements_.length >> 1) - 1; t >= 0; t--) 12726 this.siftUp_(t); 12727 } 12728 /** 12729 * @return {boolean} Is empty. 12730 */ 12731 isEmpty() { 12732 return this.elements_.length === 0; 12733 } 12734 /** 12735 * @param {string} key Key. 12736 * @return {boolean} Is key queued. 12737 */ 12738 isKeyQueued(t) { 12739 return t in this.queuedElements_; 12740 } 12741 /** 12742 * @param {T} element Element. 12743 * @return {boolean} Is queued. 12744 */ 12745 isQueued(t) { 12746 return this.isKeyQueued(this.keyFunction_(t)); 12747 } 12748 /** 12749 * @param {number} index The index of the node to move down. 12750 * @private 12751 */ 12752 siftUp_(t) { 12753 const i = this.elements_, s = this.priorities_, n = i.length, r = i[t], o = s[t], a = t; 12754 for (; t < n >> 1; ) { 12755 const l = this.getLeftChildIndex_(t), h = this.getRightChildIndex_(t), c = h < n && s[h] < s[l] ? h : l; 12756 i[t] = i[c], s[t] = s[c], t = c; 12757 } 12758 i[t] = r, s[t] = o, this.siftDown_(a, t); 12759 } 12760 /** 12761 * @param {number} startIndex The index of the root. 12762 * @param {number} index The index of the node to move up. 12763 * @private 12764 */ 12765 siftDown_(t, i) { 12766 const s = this.elements_, n = this.priorities_, r = s[i], o = n[i]; 12767 for (; i > t; ) { 12768 const a = this.getParentIndex_(i); 12769 if (n[a] > o) 12770 s[i] = s[a], n[i] = n[a], i = a; 12771 else 12772 break; 12773 } 12774 s[i] = r, n[i] = o; 12775 } 12776 /** 12777 * FIXME empty description for jsdoc 12778 */ 12779 reprioritize() { 12780 const t = this.priorityFunction_, i = this.elements_, s = this.priorities_; 12781 let n = 0; 12782 const r = i.length; 12783 let o, a, l; 12784 for (a = 0; a < r; ++a) 12785 o = i[a], l = t(o), l == Go ? delete this.queuedElements_[this.keyFunction_(o)] : (s[n] = l, i[n++] = o); 12786 i.length = n, s.length = n, this.heapify_(); 12787 } 12788} 12789const _M = gM, H = { 12790 IDLE: 0, 12791 LOADING: 1, 12792 LOADED: 2, 12793 /** 12794 * Indicates that tile loading failed 12795 * @type {number} 12796 */ 12797 ERROR: 3, 12798 EMPTY: 4 12799}; 12800class mM extends _M { 12801 /** 12802 * @param {PriorityFunction} tilePriorityFunction Tile priority function. 12803 * @param {function(): ?} tileChangeCallback Function called on each tile change event. 12804 */ 12805 constructor(t, i) { 12806 super( 12807 /** 12808 * @param {Array} element Element. 12809 * @return {number} Priority. 12810 */ 12811 function(s) { 12812 return t.apply(null, s); 12813 }, 12814 /** 12815 * @param {Array} element Element. 12816 * @return {string} Key. 12817 */ 12818 function(s) { 12819 return ( 12820 /** @type {import("./Tile.js").default} */ 12821 s[0].getKey() 12822 ); 12823 } 12824 ), this.boundHandleTileChange_ = this.handleTileChange.bind(this), this.tileChangeCallback_ = i, this.tilesLoading_ = 0, this.tilesLoadingKeys_ = {}; 12825 } 12826 /** 12827 * @param {Array} element Element. 12828 * @return {boolean} The element was added to the queue. 12829 */ 12830 enqueue(t) { 12831 const i = super.enqueue(t); 12832 return i && t[0].addEventListener(et.CHANGE, this.boundHandleTileChange_), i; 12833 } 12834 /** 12835 * @return {number} Number of tiles loading. 12836 */ 12837 getTilesLoading() { 12838 return this.tilesLoading_; 12839 } 12840 /** 12841 * @param {import("./events/Event.js").default} event Event. 12842 * @protected 12843 */ 12844 handleTileChange(t) { 12845 const i = ( 12846 /** @type {import("./Tile.js").default} */ 12847 t.target 12848 ), s = i.getState(); 12849 if (s === H.LOADED || s === H.ERROR || s === H.EMPTY) { 12850 s !== H.ERROR && i.removeEventListener(et.CHANGE, this.boundHandleTileChange_); 12851 const n = i.getKey(); 12852 n in this.tilesLoadingKeys_ && (delete this.tilesLoadingKeys_[n], --this.tilesLoading_), this.tileChangeCallback_(); 12853 } 12854 } 12855 /** 12856 * @param {number} maxTotalLoading Maximum number tiles to load simultaneously. 12857 * @param {number} maxNewLoads Maximum number of new tiles to load. 12858 */ 12859 loadMoreTiles(t, i) { 12860 let s = 0, n, r, o; 12861 for (; this.tilesLoading_ < t && s < i && this.getCount() > 0; ) 12862 r = /** @type {import("./Tile.js").default} */ 12863 this.dequeue()[0], o = r.getKey(), n = r.getState(), n === H.IDLE && !(o in this.tilesLoadingKeys_) && (this.tilesLoadingKeys_[o] = !0, ++this.tilesLoading_, ++s, r.load()); 12864 } 12865} 12866const pM = mM; 12867function yM(e, t, i, s, n) { 12868 if (!e || !(i in e.wantedTiles) || !e.wantedTiles[i][t.getKey()]) 12869 return Go; 12870 const r = e.viewState.center, o = s[0] - r[0], a = s[1] - r[1]; 12871 return 65536 * Math.log(n) + Math.sqrt(o * o + a * a) / n; 12872} 12873class xM extends ni { 12874 /** 12875 * @param {Options} options Control options. 12876 */ 12877 constructor(t) { 12878 super(); 12879 const i = t.element; 12880 i && !t.target && !i.style.pointerEvents && (i.style.pointerEvents = "auto"), this.element = i || null, this.target_ = null, this.map_ = null, this.listenerKeys = [], t.render && (this.render = t.render), t.target && this.setTarget(t.target); 12881 } 12882 /** 12883 * Clean up. 12884 */ 12885 disposeInternal() { 12886 Sl(this.element), super.disposeInternal(); 12887 } 12888 /** 12889 * Get the map associated with this control. 12890 * @return {import("../Map.js").default|null} Map. 12891 * @api 12892 */ 12893 getMap() { 12894 return this.map_; 12895 } 12896 /** 12897 * Remove the control from its current map and attach it to the new map. 12898 * Pass `null` to just remove the control from the current map. 12899 * Subclasses may set up event handlers to get notified about changes to 12900 * the map here. 12901 * @param {import("../Map.js").default|null} map Map. 12902 * @api 12903 */ 12904 setMap(t) { 12905 this.map_ && Sl(this.element); 12906 for (let i = 0, s = this.listenerKeys.length; i < s; ++i) 12907 Mt(this.listenerKeys[i]); 12908 this.listenerKeys.length = 0, this.map_ = t, t && ((this.target_ ? this.target_ : t.getOverlayContainerStopEvent()).appendChild(this.element), this.render !== xn && this.listenerKeys.push( 12909 lt(t, Li.POSTRENDER, this.render, this) 12910 ), t.render()); 12911 } 12912 /** 12913 * Renders the control. 12914 * @param {import("../MapEvent.js").default} mapEvent Map event. 12915 * @api 12916 */ 12917 render(t) { 12918 } 12919 /** 12920 * This function is used to set a target element for the control. It has no 12921 * effect if it is called after the control has been added to the map (i.e. 12922 * after `setMap` is called on the control). If no `target` is set in the 12923 * options passed to the control constructor and if `setTarget` is not called 12924 * then the control is added to the map's overlay container. 12925 * @param {HTMLElement|string} target Target. 12926 * @api 12927 */ 12928 setTarget(t) { 12929 this.target_ = typeof t == "string" ? document.getElementById(t) : t; 12930 } 12931} 12932const kh = xM; 12933class vM extends kh { 12934 /** 12935 * @param {Options} [options] Attribution options. 12936 */ 12937 constructor(t) { 12938 t = t || {}, super({ 12939 element: document.createElement("div"), 12940 render: t.render, 12941 target: t.target 12942 }), this.ulElement_ = document.createElement("ul"), this.collapsed_ = t.collapsed !== void 0 ? t.collapsed : !0, this.userCollapsed_ = this.collapsed_, this.overrideCollapsible_ = t.collapsible !== void 0, this.collapsible_ = t.collapsible !== void 0 ? t.collapsible : !0, this.collapsible_ || (this.collapsed_ = !1); 12943 const i = t.className !== void 0 ? t.className : "ol-attribution", s = t.tipLabel !== void 0 ? t.tipLabel : "Attributions", n = t.expandClassName !== void 0 ? t.expandClassName : i + "-expand", r = t.collapseLabel !== void 0 ? t.collapseLabel : "âº", o = t.collapseClassName !== void 0 ? t.collapseClassName : i + "-collapse"; 12944 typeof r == "string" ? (this.collapseLabel_ = document.createElement("span"), this.collapseLabel_.textContent = r, this.collapseLabel_.className = o) : this.collapseLabel_ = r; 12945 const a = t.label !== void 0 ? t.label : "i"; 12946 typeof a == "string" ? (this.label_ = document.createElement("span"), this.label_.textContent = a, this.label_.className = n) : this.label_ = a; 12947 const l = this.collapsible_ && !this.collapsed_ ? this.collapseLabel_ : this.label_; 12948 this.toggleButton_ = document.createElement("button"), this.toggleButton_.setAttribute("type", "button"), this.toggleButton_.setAttribute("aria-expanded", String(!this.collapsed_)), this.toggleButton_.title = s, this.toggleButton_.appendChild(l), this.toggleButton_.addEventListener( 12949 et.CLICK, 12950 this.handleClick_.bind(this), 12951 !1 12952 ); 12953 const h = i + " " + ga + " " + Dh + (this.collapsed_ && this.collapsible_ ? " " + Cu : "") + (this.collapsible_ ? "" : " ol-uncollapsible"), c = this.element; 12954 c.className = h, c.appendChild(this.toggleButton_), c.appendChild(this.ulElement_), this.renderedAttributions_ = [], this.renderedVisible_ = !0; 12955 } 12956 /** 12957 * Collect a list of visible attributions and set the collapsible state. 12958 * @param {import("../Map.js").FrameState} frameState Frame state. 12959 * @return {Array<string>} Attributions. 12960 * @private 12961 */ 12962 collectSourceAttributions_(t) { 12963 const i = Array.from( 12964 new Set( 12965 this.getMap().getAllLayers().flatMap((n) => n.getAttributions(t)) 12966 ) 12967 ), s = !this.getMap().getAllLayers().some( 12968 (n) => n.getSource() && n.getSource().getAttributionsCollapsible() === !1 12969 ); 12970 return this.overrideCollapsible_ || this.setCollapsible(s), i; 12971 } 12972 /** 12973 * @private 12974 * @param {?import("../Map.js").FrameState} frameState Frame state. 12975 */ 12976 updateElement_(t) { 12977 if (!t) { 12978 this.renderedVisible_ && (this.element.style.display = "none", this.renderedVisible_ = !1); 12979 return; 12980 } 12981 const i = this.collectSourceAttributions_(t), s = i.length > 0; 12982 if (this.renderedVisible_ != s && (this.element.style.display = s ? "" : "none", this.renderedVisible_ = s), !bi(i, this.renderedAttributions_)) { 12983 eM(this.ulElement_); 12984 for (let n = 0, r = i.length; n < r; ++n) { 12985 const o = document.createElement("li"); 12986 o.innerHTML = i[n], this.ulElement_.appendChild(o); 12987 } 12988 this.renderedAttributions_ = i; 12989 } 12990 } 12991 /** 12992 * @param {MouseEvent} event The event to handle 12993 * @private 12994 */ 12995 handleClick_(t) { 12996 t.preventDefault(), this.handleToggle_(), this.userCollapsed_ = this.collapsed_; 12997 } 12998 /** 12999 * @private 13000 */ 13001 handleToggle_() { 13002 this.element.classList.toggle(Cu), this.collapsed_ ? Su(this.collapseLabel_, this.label_) : Su(this.label_, this.collapseLabel_), this.collapsed_ = !this.collapsed_, this.toggleButton_.setAttribute("aria-expanded", String(!this.collapsed_)); 13003 } 13004 /** 13005 * Return `true` if the attribution is collapsible, `false` otherwise. 13006 * @return {boolean} True if the widget is collapsible. 13007 * @api 13008 */ 13009 getCollapsible() { 13010 return this.collapsible_; 13011 } 13012 /** 13013 * Set whether the attribution should be collapsible. 13014 * @param {boolean} collapsible True if the widget is collapsible. 13015 * @api 13016 */ 13017 setCollapsible(t) { 13018 this.collapsible_ !== t && (this.collapsible_ = t, this.element.classList.toggle("ol-uncollapsible"), this.userCollapsed_ && this.handleToggle_()); 13019 } 13020 /** 13021 * Collapse or expand the attribution according to the passed parameter. Will 13022 * not do anything if the attribution isn't collapsible or if the current
13023 * collapsed state is already the one requested. 13024 * @param {boolean} collapsed True if the widget is collapsed. 13025 * @api 13026 */ 13027 setCollapsed(t) { 13028 this.userCollapsed_ = t, !(!this.collapsible_ || this.collapsed_ === t) && this.handleToggle_(); 13029 } 13030 /** 13031 * Return `true` when the attribution is currently collapsed or `false` 13032 * otherwise. 13033 * @return {boolean} True if the widget is collapsed. 13034 * @api 13035 */ 13036 getCollapsed() { 13037 return this.collapsed_; 13038 } 13039 /** 13040 * Update the attribution element. 13041 * @param {import("../MapEvent.js").default} mapEvent Map event. 13042 * @override 13043 */ 13044 render(t) { 13045 this.updateElement_(t.frameState); 13046 } 13047} 13048const EM = vM; 13049class MM extends kh { 13050 /** 13051 * @param {Options} [options] Rotate options. 13052 */ 13053 constructor(t) { 13054 t = t || {}, super({ 13055 element: document.createElement("div"), 13056 render: t.render, 13057 target: t.target 13058 }); 13059 const i = t.className !== void 0 ? t.className : "ol-rotate", s = t.label !== void 0 ? t.label : "â§", n = t.compassClassName !== void 0 ? t.compassClassName : "ol-compass"; 13060 this.label_ = null, typeof s == "string" ? (this.label_ = document.createElement("span"), this.label_.className = n, this.label_.textContent = s) : (this.label_ = s, this.label_.classList.add(n)); 13061 const r = t.tipLabel ? t.tipLabel : "Reset rotation", o = document.createElement("button"); 13062 o.className = i + "-reset", o.setAttribute("type", "button"), o.title = r, o.appendChild(this.label_), o.addEventListener( 13063 et.CLICK, 13064 this.handleClick_.bind(this), 13065 !1 13066 ); 13067 const a = i + " " + ga + " " + Dh, l = this.element; 13068 l.className = a, l.appendChild(o), this.callResetNorth_ = t.resetNorth ? t.resetNorth : void 0, this.duration_ = t.duration !== void 0 ? t.duration : 250, this.autoHide_ = t.autoHide !== void 0 ? t.autoHide : !0, this.rotation_ = void 0, this.autoHide_ && this.element.classList.add(qr); 13069 } 13070 /** 13071 * @param {MouseEvent} event The event to handle 13072 * @private 13073 */ 13074 handleClick_(t) { 13075 t.preventDefault(), this.callResetNorth_ !== void 0 ? this.callResetNorth_() : this.resetNorth_(); 13076 } 13077 /** 13078 * @private 13079 */ 13080 resetNorth_() { 13081 const i = this.getMap().getView(); 13082 if (!i) 13083 return; 13084 const s = i.getRotation(); 13085 s !== void 0 && (this.duration_ > 0 && s % (2 * Math.PI) !== 0 ? i.animate({ 13086 rotation: 0, 13087 duration: this.duration_, 13088 easing: Rn 13089 }) : i.setRotation(0)); 13090 } 13091 /** 13092 * Update the rotate control element. 13093 * @param {import("../MapEvent.js").default} mapEvent Map event. 13094 * @override 13095 */ 13096 render(t) { 13097 const i = t.frameState; 13098 if (!i) 13099 return; 13100 const s = i.viewState.rotation; 13101 if (s != this.rotation_) { 13102 const n = "rotate(" + s + "rad)"; 13103 if (this.autoHide_) { 13104 const r = this.element.classList.contains(qr); 13105 !r && s === 0 ? this.element.classList.add(qr) : r && s !== 0 && this.element.classList.remove(qr); 13106 } 13107 this.label_.style.transform = n; 13108 } 13109 this.rotation_ = s; 13110 } 13111} 13112const CM = MM; 13113class bM extends kh { 13114 /** 13115 * @param {Options} [options] Zoom options. 13116 */ 13117 constructor(t) { 13118 t = t || {}, super({ 13119 element: document.createElement("div"), 13120 target: t.target 13121 }); 13122 const i = t.className !== void 0 ? t.className : "ol-zoom", s = t.delta !== void 0 ? t.delta : 1, n = t.zoomInClassName !== void 0 ? t.zoomInClassName : i + "-in", r = t.zoomOutClassName !== void 0 ? t.zoomOutClassName : i + "-out", o = t.zoomInLabel !== void 0 ? t.zoomInLabel : "+", a = t.zoomOutLabel !== void 0 ? t.zoomOutLabel : "â", l = t.zoomInTipLabel !== void 0 ? t.zoomInTipLabel : "Zoom in", h = t.zoomOutTipLabel !== void 0 ? t.zoomOutTipLabel : "Zoom out", c = document.createElement("button"); 13123 c.className = n, c.setAttribute("type", "button"), c.title = l, c.appendChild( 13124 typeof o == "string" ? document.createTextNode(o) : o 13125 ), c.addEventListener( 13126 et.CLICK, 13127 this.handleClick_.bind(this, s), 13128 !1 13129 ); 13130 const u = document.createElement("button"); 13131 u.className = r, u.setAttribute("type", "button"), u.title = h, u.appendChild( 13132 typeof a == "string" ? document.createTextNode(a) : a 13133 ), u.addEventListener( 13134 et.CLICK, 13135 this.handleClick_.bind(this, -s), 13136 !1 13137 ); 13138 const d = i + " " + ga + " " + Dh, f = this.element; 13139 f.className = d, f.appendChild(c), f.appendChild(u), this.duration_ = t.duration !== void 0 ? t.duration : 250; 13140 } 13141 /** 13142 * @param {number} delta Zoom delta. 13143 * @param {MouseEvent} event The event to handle 13144 * @private 13145 */ 13146 handleClick_(t, i) { 13147 i.preventDefault(), this.zoomByDelta_(t); 13148 } 13149 /** 13150 * @param {number} delta Zoom delta. 13151 * @private 13152 */ 13153 zoomByDelta_(t) { 13154 const s = this.getMap().getView(); 13155 if (!s) 13156 return; 13157 const n = s.getZoom(); 13158 if (n !== void 0) { 13159 const r = s.getConstrainedZoom(n + t); 13160 this.duration_ > 0 ? (s.getAnimating() && s.cancelAnimations(), s.animate({ 13161 zoom: r, 13162 duration: this.duration_, 13163 easing: Rn 13164 })) : s.setZoom(r); 13165 } 13166 } 13167} 13168const SM = bM; 13169function wM(e) { 13170 e = e || {}; 13171 const t = new Pe(); 13172 return (e.zoom !== void 0 ? e.zoom : !0) && t.push(new SM(e.zoomOptions)), (e.rotate !== void 0 ? e.rotate : !0) && t.push(new CM(e.rotateOptions)), (e.attribution !== void 0 ? e.attribution : !0) && t.push(new EM(e.attributionOptions)), t; 13173} 13174const Il = { 13175 ACTIVE: "active" 13176}; 13177class TM extends ni { 13178 /** 13179 * @param {InteractionOptions} [options] Options. 13180 */ 13181 constructor(t) { 13182 super(), this.on, this.once, this.un, t && t.handleEvent && (this.handleEvent = t.handleEvent), this.map_ = null, this.setActive(!0); 13183 } 13184 /** 13185 * Return whether the interaction is currently active. 13186 * @return {boolean} `true` if the interaction is active, `false` otherwise. 13187 * @observable 13188 * @api 13189 */ 13190 getActive() { 13191 return ( 13192 /** @type {boolean} */ 13193 this.get(Il.ACTIVE) 13194 ); 13195 } 13196 /** 13197 * Get the map associated with this interaction. 13198 * @return {import("../Map.js").default|null} Map. 13199 * @api 13200 */ 13201 getMap() { 13202 return this.map_; 13203 } 13204 /** 13205 * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event}. 13206 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event. 13207 * @return {boolean} `false` to stop event propagation. 13208 * @api 13209 */ 13210 handleEvent(t) { 13211 return !0; 13212 } 13213 /** 13214 * Activate or deactivate the interaction. 13215 * @param {boolean} active Active. 13216 * @observable 13217 * @api 13218 */ 13219 setActive(t) { 13220 this.set(Il.ACTIVE, t); 13221 } 13222 /** 13223 * Remove the interaction from its current map and attach it to the new map. 13224 * Subclasses may set up event handlers to get notified about changes to 13225 * the map here. 13226 * @param {import("../Map.js").default|null} map Map. 13227 */ 13228 setMap(t) { 13229 this.map_ = t; 13230 } 13231} 13232function RM(e, t, i) { 13233 const s = e.getCenterInternal(); 13234 if (s) { 13235 const n = [s[0] + t[0], s[1] + t[1]]; 13236 e.animateInternal({ 13237 duration: i !== void 0 ? i : 250, 13238 easing: ME, 13239 center: e.getConstrainedCenter(n) 13240 }); 13241 } 13242} 13243function Gh(e, t, i, s) { 13244 const n = e.getZoom(); 13245 if (n === void 0) 13246 return; 13247 const r = e.getConstrainedZoom(n + t), o = e.getResolutionForZoom(r); 13248 e.getAnimating() && e.cancelAnimations(), e.animate({ 13249 resolution: o, 13250 anchor: i, 13251 duration: s !== void 0 ? s : 250, 13252 easing: Rn 13253 }); 13254} 13255const Ar = TM; 13256class IM extends Ar { 13257 /** 13258 * @param {Options} [options] Options. 13259 */ 13260 constructor(t) { 13261 super(), t = t || {}, this.delta_ = t.delta ? t.delta : 1, this.duration_ = t.duration !== void 0 ? t.duration : 250; 13262 } 13263 /** 13264 * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} (if it was a 13265 * doubleclick) and eventually zooms the map. 13266 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event. 13267 * @return {boolean} `false` to stop event propagation. 13268 */ 13269 handleEvent(t) { 13270 let i = !1; 13271 if (t.type == dt.DBLCLICK) { 13272 const s = ( 13273 /** @type {MouseEvent} */ 13274 t.originalEvent
13275 ), n = t.map, r = t.coordinate, o = s.shiftKey ? -this.delta_ : this.delta_, a = n.getView(); 13276 Gh(a, o, r, this.duration_), s.preventDefault(), i = !0; 13277 } 13278 return !i; 13279 } 13280} 13281const rg = IM; 13282class PM extends Ar { 13283 /** 13284 * @param {Options} [options] Options. 13285 */ 13286 constructor(t) { 13287 t = t || {}, super( 13288 /** @type {import("./Interaction.js").InteractionOptions} */ 13289 t 13290 ), t.handleDownEvent && (this.handleDownEvent = t.handleDownEvent), t.handleDragEvent && (this.handleDragEvent = t.handleDragEvent), t.handleMoveEvent && (this.handleMoveEvent = t.handleMoveEvent), t.handleUpEvent && (this.handleUpEvent = t.handleUpEvent), t.stopDown && (this.stopDown = t.stopDown), this.handlingDownUpSequence = !1, this.targetPointers = []; 13291 } 13292 /** 13293 * Returns the current number of pointers involved in the interaction, 13294 * e.g. `2` when two fingers are used. 13295 * @return {number} The number of pointers. 13296 * @api 13297 */ 13298 getPointerCount() { 13299 return this.targetPointers.length; 13300 } 13301 /** 13302 * Handle pointer down events. 13303 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13304 * @return {boolean} If the event was consumed. 13305 * @protected 13306 */ 13307 handleDownEvent(t) { 13308 return !1; 13309 } 13310 /** 13311 * Handle pointer drag events. 13312 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13313 * @protected 13314 */ 13315 handleDragEvent(t) { 13316 } 13317 /** 13318 * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may call into 13319 * other functions, if event sequences like e.g. 'drag' or 'down-up' etc. are 13320 * detected. 13321 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event. 13322 * @return {boolean} `false` to stop event propagation. 13323 * @api 13324 */ 13325 handleEvent(t) { 13326 if (!t.originalEvent) 13327 return !0; 13328 let i = !1; 13329 if (this.updateTrackedPointers_(t), this.handlingDownUpSequence) { 13330 if (t.type == dt.POINTERDRAG) 13331 this.handleDragEvent(t), t.originalEvent.preventDefault(); 13332 else if (t.type == dt.POINTERUP) { 13333 const s = this.handleUpEvent(t); 13334 this.handlingDownUpSequence = s && this.targetPointers.length > 0; 13335 } 13336 } else if (t.type == dt.POINTERDOWN) { 13337 const s = this.handleDownEvent(t); 13338 this.handlingDownUpSequence = s, i = this.stopDown(s); 13339 } else 13340 t.type == dt.POINTERMOVE && this.handleMoveEvent(t); 13341 return !i; 13342 } 13343 /** 13344 * Handle pointer move events. 13345 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13346 * @protected 13347 */ 13348 handleMoveEvent(t) { 13349 } 13350 /** 13351 * Handle pointer up events. 13352 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13353 * @return {boolean} If the event was consumed. 13354 * @protected 13355 */ 13356 handleUpEvent(t) { 13357 return !1; 13358 } 13359 /** 13360 * This function is used to determine if "down" events should be propagated 13361 * to other interactions or should be stopped. 13362 * @param {boolean} handled Was the event handled by the interaction? 13363 * @return {boolean} Should the `down` event be stopped? 13364 */ 13365 stopDown(t) { 13366 return t; 13367 } 13368 /** 13369 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13370 * @private 13371 */ 13372 updateTrackedPointers_(t) { 13373 t.activePointers && (this.targetPointers = t.activePointers); 13374 } 13375} 13376function zh(e) { 13377 const t = e.length; 13378 let i = 0, s = 0; 13379 for (let n = 0; n < t; n++) 13380 i += e[n].clientX, s += e[n].clientY; 13381 return { clientX: i / t, clientY: s / t }; 13382} 13383const es = PM; 13384function Pl(e) { 13385 const t = arguments; 13386 return function(i) { 13387 let s = !0; 13388 for (let n = 0, r = t.length; n < r && (s = s && t[n](i), !!s); ++n) 13389 ; 13390 return s; 13391 }; 13392} 13393const AM = function(e) { 13394 const t = ( 13395 /** @type {KeyboardEvent|MouseEvent|TouchEvent} */ 13396 e.originalEvent 13397 ); 13398 return t.altKey && !(t.metaKey || t.ctrlKey) && !t.shiftKey; 13399}, LM = function(e) { 13400 const t = ( 13401 /** @type {KeyboardEvent|MouseEvent|TouchEvent} */ 13402 e.originalEvent 13403 ); 13404 return t.altKey && !(t.metaKey || t.ctrlKey) && t.shiftKey; 13405}, OM = function(e) { 13406 const t = e.map.getTargetElement(), i = e.map.getOwnerDocument().activeElement; 13407 return t.contains(i); 13408}, og = function(e) { 13409 return e.map.getTargetElement().hasAttribute("tabindex") ? OM(e) : !0; 13410}, zo = bs, ag = function(e) { 13411 const t = ( 13412 /** @type {MouseEvent} */ 13413 e.originalEvent 13414 ); 13415 return t.button == 0 && !(eE && iE && t.ctrlKey); 13416}, FM = Rs, DM = function(e) { 13417 return e.type == dt.SINGLECLICK; 13418}, jh = function(e) { 13419 const t = ( 13420 /** @type {KeyboardEvent|MouseEvent|TouchEvent} */ 13421 e.originalEvent 13422 ); 13423 return !t.altKey && !(t.metaKey || t.ctrlKey) && !t.shiftKey; 13424}, lg = function(e) { 13425 const t = ( 13426 /** @type {KeyboardEvent|MouseEvent|TouchEvent} */ 13427 e.originalEvent 13428 ); 13429 return !t.altKey && !(t.metaKey || t.ctrlKey) && t.shiftKey; 13430}, hg = function(e) { 13431 const t = ( 13432 /** @type {KeyboardEvent|MouseEvent|TouchEvent} */ 13433 e.originalEvent 13434 ), i = ( 13435 /** @type {Element} */ 13436 t.target.tagName 13437 ); 13438 return i !== "INPUT" && i !== "SELECT" && i !== "TEXTAREA" && // `isContentEditable` is only available on `HTMLElement`, but it may al
13438so be a 13439 // different type like `SVGElement`. 13440 // @ts-ignore 13441 !t.target.isContentEditable; 13442}, ka = function(e) { 13443 const t = ( 13444 /** @type {import("../MapBrowserEvent").default} */ 13445 e.originalEvent 13446 ); 13447 return at(t !== void 0, 56), t.pointerType == "mouse"; 13448}, cg = function(e) { 13449 const t = ( 13450 /** @type {import("../MapBrowserEvent").default} */ 13451 e.originalEvent 13452 ); 13453 return at(t !== void 0, 56), t.isPrimary && t.button === 0; 13454}; 13455class NM extends es { 13456 /** 13457 * @param {Options} [options] Options. 13458 */ 13459 constructor(t) { 13460 super({ 13461 stopDown: Rs 13462 }), t = t || {}, this.kinetic_ = t.kinetic, this.lastCentroid = null, this.lastPointersCount_, this.panning_ = !1; 13463 const i = t.condition ? t.condition : Pl(jh, cg); 13464 this.condition_ = t.onFocusOnly ? Pl(og, i) : i, this.noKinetic_ = !1; 13465 } 13466 /** 13467 * Handle pointer drag events. 13468 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13469 */ 13470 handleDragEvent(t) { 13471 const i = t.map; 13472 this.panning_ || (this.panning_ = !0, i.getView().beginInteraction()); 13473 const s = this.targetPointers, n = i.getEventPixel(zh(s)); 13474 if (s.length == this.lastPointersCount_) { 13475 if (this.kinetic_ && this.kinetic_.update(n[0], n[1]), this.lastCentroid) { 13476 const r = [ 13477 this.lastCentroid[0] - n[0], 13478 n[1] - this.lastCentroid[1] 13479 ], a = t.map.getView(); 13480 qy(r, a.getResolution()), Yl(r, a.getRotation()), a.adjustCenterInternal(r); 13481 } 13482 } else 13483 this.kinetic_ && this.kinetic_.begin(); 13484 this.lastCentroid = n, this.lastPointersCount_ = s.length, t.originalEvent.preventDefault(); 13485 } 13486 /** 13487 * Handle pointer up events. 13488 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13489 * @return {boolean} If the event was consumed. 13490 */ 13491 handleUpEvent(t) { 13492 const i = t.map, s = i.getView(); 13493 if (this.targetPointers.length === 0) { 13494 if (!this.noKinetic_ && this.kinetic_ && this.kinetic_.end()) { 13495 const n = this.kinetic_.getDistance(), r = this.kinetic_.getAngle(), o = s.getCenterInternal(), a = i.getPixelFromCoordinateInternal(o), l = i.getCoordinateFromPixelInternal([ 13496 a[0] - n * Math.cos(r), 13497 a[1] - n * Math.sin(r) 13498 ]); 13499 s.animateInternal({ 13500 center: s.getConstrainedCenter(l), 13501 duration: 500, 13502 easing: Rn 13503 }); 13504 } 13505 return this.panning_ && (this.panning_ = !1, s.endInteraction()), !1; 13506 } 13507 return this.kinetic_ && this.kinetic_.begin(), this.lastCentroid = null, !0; 13508 } 13509 /** 13510 * Handle pointer down events. 13511 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13512 * @return {boolean} If the event was consumed. 13513 */ 13514 handleDownEvent(t) { 13515 if (this.targetPointers.length > 0 && this.condition_(t)) { 13516 const s = t.map.getView(); 13517 return this.lastCentroid = null, s.getAnimating() && s.cancelAnimations(), this.kinetic_ && this.kinetic_.begin(), this.noKinetic_ = this.targetPointers.length > 1, !0; 13518 } 13519 return !1; 13520 } 13521} 13522const kM = NM; 13523class GM extends es { 13524 /** 13525 * @param {Options} [options] Options. 13526 */ 13527 constructor(t) { 13528 t = t || {}, super({ 13529 stopDown: Rs 13530 }), this.condition_ = t.condition ? t.condition : LM, this.lastAngle_ = void 0, this.duration_ = t.duration !== void 0 ? t.duration : 250; 13531 } 13532 /** 13533 * Handle pointer drag events. 13534 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13535 */ 13536 handleDragEvent(t) { 13537 if (!ka(t)) 13538 return; 13539 const i = t.map, s = i.getView(); 13540 if (s.getConstraints().rotation === bh) 13541 return; 13542 const n = i.getSize(), r = t.pixel, o = Math.atan2(n[1] / 2 - r[1], r[0] - n[0] / 2); 13543 if (this.lastAngle_ !== void 0) { 13544 const a = o - this.lastAngle_; 13545 s.adjustRotationInternal(-a); 13546 } 13547 this.lastAngle_ = o; 13548 } 13549 /** 13550 * Handle pointer up events. 13551 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13552 * @return {boolean} If the event was consumed. 13553 */ 13554 handleUpEvent(t) { 13555 return ka(t) ? (t.map.getView().endInteraction(this.duration_), !1) : !0; 13556 } 13557 /** 13558 * Handle pointer down events. 13559 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13560 * @return {boolean} If the event was consumed. 13561 */ 13562 handleDownEvent(t) { 13563 return ka(t) && ag(t) && this.condition_(t) ? (t.map.getView().beginInteraction(), this.lastAngle_ = void 0, !0) : !1; 13564 } 13565} 13566const zM = GM; 13567class jM extends yh { 13568 /** 13569 * @param {string} className CSS class name. 13570 */ 13571 constructor(t) { 13572 super(), this.geometry_ = null, this.element_ = document.createElement("div"), this.element_.style.position = "absolute", this.element_.style.pointerEvents = "auto", this.element_.className = "ol-box " + t, this.map_ = null, this.startPixel_ = null, this.endPixel_ = null; 13573 } 13574 /** 13575 * Clean up. 13576 */ 13577 disposeInternal() { 13578 this.setMap(null); 13579 } 13580 /** 13581 * @private 13582 */ 13583 render_() { 13584 const t = this.startPixel_, i = this.endPixel_, s = "px", n = this.element_.style; 13585 n.left = Math.min(t[0], i[0]) + s, n.top = Math.min(t[1], i[1]) + s, n.width = Math.abs(i[0] - t[0]) + s, n.height = Math.abs(i[1] - t[1]) + s; 13586 } 13587 /** 13588 * @param {import("../Map.js").default|null} map Map. 13589 */ 13590 setMap(t) { 13591 if (this.map_) { 13592 this.map_.getOverlayContainer().removeChild(this.element_); 13593 const i = this.element_.style; 13594 i.left = "inherit", i.top = "inherit", i.width = "inherit", i.height = "
13594inherit"; 13595 } 13596 this.map_ = t, this.map_ && this.map_.getOverlayContainer().appendChild(this.element_); 13597 } 13598 /** 13599 * @param {import("../pixel.js").Pixel} startPixel Start pixel. 13600 * @param {import("../pixel.js").Pixel} endPixel End pixel. 13601 */ 13602 setPixels(t, i) { 13603 this.startPixel_ = t, this.endPixel_ = i, this.createOrUpdateGeometry(), this.render_(); 13604 } 13605 /** 13606 * Creates or updates the cached geometry. 13607 */ 13608 createOrUpdateGeometry() { 13609 const t = this.startPixel_, i = this.endPixel_, n = [ 13610 t, 13611 [t[0], i[1]], 13612 i, 13613 [i[0], t[1]] 13614 ].map( 13615 this.map_.getCoordinateFromPixelInternal, 13616 this.map_ 13617 ); 13618 n[4] = n[0].slice(), this.geometry_ ? this.geometry_.setCoordinates([n]) : this.geometry_ = new En([n]); 13619 } 13620 /** 13621 * @return {import("../geom/Polygon.js").default} Geometry. 13622 */ 13623 getGeometry() { 13624 return this.geometry_; 13625 } 13626} 13627const WM = jM, Hr = { 13628 /** 13629 * Triggered upon drag box start. 13630 * @event DragBoxEvent#boxstart 13631 * @api 13632 */ 13633 BOXSTART: "boxstart", 13634 /** 13635 * Triggered on drag when box is active. 13636 * @event DragBoxEvent#boxdrag 13637 * @api 13638 */ 13639 BOXDRAG: "boxdrag", 13640 /** 13641 * Triggered upon drag box end. 13642 * @event DragBoxEvent#boxend 13643 * @api 13644 */ 13645 BOXEND: "boxend", 13646 /** 13647 * Triggered upon drag box canceled. 13648 * @event DragBoxEvent#boxcancel 13649 * @api 13650 */ 13651 BOXCANCEL: "boxcancel" 13652}; 13653class Ga extends Ae { 13654 /** 13655 * @param {string} type The event type. 13656 * @param {import("../coordinate.js").Coordinate} coordinate The event coordinate. 13657 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Originating event. 13658 */ 13659 constructor(t, i, s) { 13660 super(t), this.coordinate = i, this.mapBrowserEvent = s; 13661 } 13662} 13663class BM extends es { 13664 /** 13665 * @param {Options} [options] Options. 13666 */ 13667 constructor(t) { 13668 super(), this.on, this.once, this.un, t = t || {}, this.box_ = new WM(t.className || "ol-dragbox"), this.minArea_ = t.minArea !== void 0 ? t.minArea : 64, t.onBoxEnd && (this.onBoxEnd = t.onBoxEnd), this.startPixel_ = null, this.condition_ = t.condition ? t.condition : ag, this.boxEndCondition_ = t.boxEndCondition ? t.boxEndCondition : this.defaultBoxEndCondition; 13669 } 13670 /** 13671 * The default condition for determining whether the boxend event 13672 * should fire. 13673 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent The originating MapBrowserEvent 13674 * leading to the box end. 13675 * @param {import("../pixel.js").Pixel} startPixel The starting pixel of the box. 13676 * @param {import("../pixel.js").Pixel} endPixel The end pixel of the box. 13677 * @return {boolean} Whether or not the boxend condition should be fired. 13678 */ 13679 defaultBoxEndCondition(t, i, s) { 13680 const n = s[0] - i[0], r = s[1] - i[1]; 13681 return n * n + r * r >= this.minArea_; 13682 } 13683 /** 13684 * Returns geometry of last drawn box. 13685 * @return {import("../geom/Polygon.js").default} Geometry. 13686 * @api 13687 */ 13688 getGeometry() { 13689 return this.box_.getGeometry(); 13690 } 13691 /** 13692 * Handle pointer drag events. 13693 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13694 */ 13695 handleDragEvent(t) { 13696 this.box_.setPixels(this.startPixel_, t.pixel), this.dispatchEvent( 13697 new Ga( 13698 Hr.BOXDRAG, 13699 t.coordinate, 13700 t 13701 ) 13702 ); 13703 } 13704 /** 13705 * Handle pointer up events. 13706 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13707 * @return {boolean} If the event was consumed. 13708 */ 13709 handleUpEvent(t) { 13710 this.box_.setMap(null); 13711 const i = this.boxEndCondition_( 13712 t, 13713 this.startPixel_, 13714 t.pixel 13715 ); 13716 return i && this.onBoxEnd(t), this.dispatchEvent( 13717 new Ga( 13718 i ? Hr.BOXEND : Hr.BOXCANCEL, 13719 t.coordinate, 13720 t 13721 ) 13722 ), !1; 13723 } 13724 /** 13725 * Handle pointer down events. 13726 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 13727 * @return {boolean} If the event was consumed. 13728 */ 13729 handleDownEvent(t) { 13730 return this.condition_(t) ? (this.startPixel_ = t.pixel, this.box_.setMap(t.map), this.box_.setPixels(this.startPixel_, this.startPixel_), this.dispatchEvent( 13731 new Ga( 13732 Hr.BOXSTART, 13733 t.coordinate, 13734 t 13735 ) 13736 ), !0) : !1; 13737 } 13738 /** 13739 * Function to execute just before `onboxend` is fired 13740 * @param {import("../MapBrowserEvent.js").default} event Event. 13741 */ 13742 onBoxEnd(t) { 13743 } 13744} 13745const UM = BM; 13746class XM extends UM { 13747 /** 13748 * @param {Options} [options] Options. 13749 */ 13750 constructor(t) { 13751 t = t || {}; 13752 const i = t.condition ? t.condition : lg; 13753 super({ 13754 condition: i, 13755 className: t.className || "ol-dragzoom", 13756 minArea: t.minArea 13757 }), this.duration_ = t.duration !== void 0 ? t.duration : 200, this.out_ = t.out !== void 0 ? t.out : !1; 13758 } 13759 /** 13760 * Function to execute just before `onboxend` is fired 13761 * @param {import("../MapBrowserEvent.js").default} event Event. 13762 */ 13763 onBoxEnd(t) { 13764 const s = (
13765 /** @type {!import("../View.js").default} */ 13766 this.getMap().getView() 13767 ); 13768 let n = this.getGeometry(); 13769 if (this.out_) { 13770 const r = s.rotatedExtentForGeometry(n), o = s.getResolutionForExtentInternal(r), a = s.getResolution() / o; 13771 n = n.clone(), n.scale(a * a); 13772 } 13773 s.fitInternal(n, { 13774 duration: this.duration_, 13775 easing: Rn 13776 }); 13777 } 13778} 13779const $M = XM, os = { 13780 LEFT: "ArrowLeft", 13781 UP: "ArrowUp", 13782 RIGHT: "ArrowRight", 13783 DOWN: "ArrowDown" 13784}; 13785class YM extends Ar { 13786 /** 13787 * @param {Options} [options] Options. 13788 */ 13789 constructor(t) { 13790 super(), t = t || {}, this.defaultCondition_ = function(i) { 13791 return jh(i) && hg(i); 13792 }, this.condition_ = t.condition !== void 0 ? t.condition : this.defaultCondition_, this.duration_ = t.duration !== void 0 ? t.duration : 100, this.pixelDelta_ = t.pixelDelta !== void 0 ? t.pixelDelta : 128; 13793 } 13794 /** 13795 * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} if it was a 13796 * `KeyEvent`, and decides the direction to pan to (if an arrow key was 13797 * pressed). 13798 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event. 13799 * @return {boolean} `false` to stop event propagation. 13800 */ 13801 handleEvent(t) { 13802 let i = !1; 13803 if (t.type == et.KEYDOWN) { 13804 const s = ( 13805 /** @type {KeyboardEvent} */ 13806 t.originalEvent 13807 ), n = s.key; 13808 if (this.condition_(t) && (n == os.DOWN || n == os.LEFT || n == os.RIGHT || n == os.UP)) { 13809 const o = t.map.getView(), a = o.getResolution() * this.pixelDelta_; 13810 let l = 0, h = 0; 13811 n == os.DOWN ? h = -a : n == os.LEFT ? l = -a : n == os.RIGHT ? l = a : h = a; 13812 const c = [l, h]; 13813 Yl(c, o.getRotation()), RM(o, c, this.duration_), s.preventDefault(), i = !0; 13814 } 13815 } 13816 return !i; 13817 } 13818} 13819const KM = YM; 13820class VM extends Ar { 13821 /** 13822 * @param {Options} [options] Options. 13823 */ 13824 constructor(t) { 13825 super(), t = t || {}, this.condition_ = t.condition ? t.condition : hg, this.delta_ = t.delta ? t.delta : 1, this.duration_ = t.duration !== void 0 ? t.duration : 100; 13826 } 13827 /** 13828 * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} if it was a 13829 * `KeyEvent`, and decides whether to zoom in or out (depending on whether the 13830 * key pressed was '+' or '-'). 13831 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event. 13832 * @return {boolean} `false` to stop event propagation. 13833 */ 13834 handleEvent(t) { 13835 let i = !1; 13836 if (t.type == et.KEYDOWN || t.type == et.KEYPRESS) { 13837 const s = ( 13838 /** @type {KeyboardEvent} */ 13839 t.originalEvent 13840 ), n = s.key; 13841 if (this.condition_(t) && (n === "+" || n === "-")) { 13842 const r = t.map, o = n === "+" ? this.delta_ : -this.delta_, a = r.getView(); 13843 Gh(a, o, void 0, this.duration_), s.preventDefault(), i = !0; 13844 } 13845 } 13846 return !i; 13847 } 13848} 13849const qM = VM; 13850class HM { 13851 /** 13852 * @param {number} decay Rate of decay (must be negative). 13853 * @param {number} minVelocity Minimum velocity (pixels/millisecond). 13854 * @param {number} delay Delay to consider to calculate the kinetic 13855 * initial values (milliseconds). 13856 */ 13857 constructor(t, i, s) { 13858 this.decay_ = t, this.minVelocity_ = i, this.delay_ = s, this.points_ = [], this.angle_ = 0, this.initialVelocity_ = 0; 13859 } 13860 /** 13861 * FIXME empty description for jsdoc 13862 */ 13863 begin() { 13864 this.points_.length = 0, this.angle_ = 0, this.initialVelocity_ = 0; 13865 } 13866 /** 13867 * @param {number} x X. 13868 * @param {number} y Y. 13869 */ 13870 update(t, i) { 13871 this.points_.push(t, i, Date.now()); 13872 } 13873 /** 13874 * @return {boolean} Whether we should do kinetic animation. 13875 */ 13876 end() { 13877 if (this.points_.length < 6) 13878 return !1; 13879 const t = Date.now() - this.delay_, i = this.points_.length - 3; 13880 if (this.points_[i + 2] < t) 13881 return !1; 13882 let s = i - 3; 13883 for (; s > 0 && this.points_[s + 2] > t; ) 13884 s -= 3; 13885 const n = this.points_[i + 2] - this.points_[s + 2]; 13886 if (n < 1e3 / 60) 13887 return !1; 13888 const r = this.points_[i] - this.points_[s], o = this.points_[i + 1] - this.points_[s + 1]; 13889 return this.angle_ = Math.atan2(o, r), this.initialVelocity_ = Math.sqrt(r * r + o * o) / n, this.initialVelocity_ > this.minVelocity_; 13890 } 13891 /** 13892 * @return {number} Total distance travelled (pixels). 13893 */ 13894 getDistance() { 13895 return (this.minVelocity_ - this.initialVelocity_) / this.decay_; 13896 } 13897 /** 13898 * @return {number} Angle of the kinetic panning animation (radians). 13899 */ 13900 getAngle() { 13901 return this.angle_; 13902 } 13903} 13904const ZM = HM; 13905class JM extends Ar { 13906 /** 13907 * @param {Options} [options] Options. 13908 */ 13909 constructor(t) { 13910 t = t || {}, super( 13911 /** @type {import("./Interaction.js").InteractionOptions} */ 13912 t 13913 ), this.totalDelta_ = 0, this.lastDelta_ = 0, this.maxDelta_ = t.maxDelta !== void 0 ? t.maxDelta : 1, this.duration_ = t.duration !== void 0 ? t.duration : 250, this.timeout_ = t.timeout !== void 0 ? t.timeout : 80, this.useAnchor_ = t.useAnchor !== void 0 ? t.useAnchor : !0, this.constrainResolution_ = t.constrainResolution !== void 0 ? t.constrainResolution : !1; 13914 const i = t.condition ? t.condition : zo; 13915 this.condition_ = t.onFocusOnly ? Pl(og, i) : i, this.lastAnchor_ = null, this.startTime_ = void 0, this.timeoutId_, this.mode_ = void 0, this.trackpadEventGap_ = 400, this.trackpadTimeoutId_, this.deltaPerZoom_ = 300; 13916 } 13917 /** 13918 * @private 13919 */ 13920 endInteraction_() { 13921 this.trackpadTimeoutId_ = void 0; 13922 const t = this.getMap(); 13923 if (!t) 13924 return; 13925 t.getView().endInteraction( 13926 void 0, 13927 this.lastDelta_ ? this.lastDelta_ > 0 ? 1 : -1 : 0, 13928 this.lastAnchor_ 13929 ); 13930 } 13931 /** 13932 * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} (if it was a mousewheel-event) and eventually 13933 * zooms the map. 13934 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event. 13935 * @return {boolean} `false` to stop event propagation. 13936 */ 13937 handleEvent(t) { 13938 if (!this.condition_(t) || t.type !== et.WHEEL) 13939 return !0; 13940 const s = t.map, n = ( 13941 /** @type {WheelEvent} */ 13942 t.originalEvent 13943 ); 13944 n.preventDefault(), this.useAnchor_ && (this.lastAnchor_ = t.coordinate); 13945 let r; 13946 if (t.type == et.WHEEL && (r = n.deltaY, Qv && n.deltaMode === WheelEvent.DOM_DELTA_PIXEL && (r /= Gf), n.deltaMode === WheelEvent.DOM_DELTA_LINE && (r *= 40)), r === 0) 13947 return !1; 13948 this.lastDelta_ = r; 13949 const o = Date.now(); 13950 this.startTime_ === void 0 && (this.startTime_ = o), (!this.mode_ || o - this.startTime_ > this.trackpadEventGap_) && (this.mode_ = Math.abs(r) < 4 ? "trackpad" : "wheel"); 13951 const a = s.getView(); 13952 if (this.mode_ === "trackpad" && !(a.getConstrainResolution() || this.constrainResolution_)) 13953 return this.trackpadTimeoutId_ ? clearTimeout(this.trackpadTimeoutId_) : (a.getAnimating() && a.cancelAnimations(), a.beginInteraction()), this.trackpadTimeoutId_ = setTimeout( 13954 this.endInteraction_.bind(this), 13955 this.timeout_ 13956 ), a.adjustZoom(-r / this.deltaPerZoom_, this.lastAnchor_), this.startTime_ = o, !1; 13957 this.totalDelta_ += r; 13958 const l = Math.max(this.timeout_ - (o - this.startTime_), 0); 13959 return clearTimeout(this.timeoutId_), this.timeoutId_ = setTimeout( 13960 this.handleWheelZoom_.bind(this, s), 13961 l 13962 ), !1; 13963 } 13964 /** 13965 * @private 13966 * @param {import("../Map.js").default} map Map. 13967 */ 13968 handleWheelZoom_(t) { 13969 const i = t.getView(); 13970 i.getAnimating() && i.cancelAnimations(); 13971 let s = -Ot( 13972 this.totalDelta_, 13973 -this.maxDelta_ * this.deltaPerZoom_, 13974 this.maxDelta_ * this.deltaPerZoom_ 13975 ) / this.deltaPerZoom_; 13976 (i.getConstrainResolution() || this.constrainResolution_) && (s = s ? s > 0 ? 1 : -1 : 0), Gh(i, s, this.lastAnchor_, this.duration_), this.mode_ = void 0, this.totalDelta_ = 0, this.lastAnchor_ = null, this.startTime_ = void 0, this.timeoutId_ = void 0; 13977 } 13978 /** 13979 * Enable or disable using the mouse's location as an anchor when zooming 13980 * @param {boolean} useAnchor true to zoom to the mouse's location, false 13981 * to zoom to the center of the map 13982 * @api 13983 */ 13984 setMouseAnchor(t) { 13985 this.useAnchor_ = t, t || (this.lastAnchor_ = null); 13986 } 13987} 13988const QM = JM; 13989class tC extends es { 13990 /** 13991 * @param {Options} [options] Options. 13992 */ 13993 constructor(t) { 13994 t = t || {}; 13995 const i = ( 13996 /** @type {import("./Pointer.js").Options} */ 13997 t 13998 ); 13999 i.stopDown || (i.stopDown = Rs), super(i), this.anchor_ = null, this.lastAngle_ = void 0, this.rotating_ = !1, this.rotationDelta_ = 0, this.threshold_ = t.threshold !== void 0 ? t.threshold : 0.3, this.duration_ = t.duration !== void 0 ? t.duration : 250; 14000 } 14001 /** 14002 * Handle pointer drag events. 14003 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 14004 */ 14005 handleDragEvent(t) { 14006 let i = 0; 14007 const s = this.targetPointers[0], n = this.targetPointers[1], r = Math.atan2( 14008 n.clientY - s.clientY, 14009 n.clientX - s.clientX 14010 ); 14011 if (this.lastAngle_ !== void 0) { 14012 const l = r - this.lastAngle_;
14013 this.rotationDelta_ += l, !this.rotating_ && Math.abs(this.rotationDelta_) > this.threshold_ && (this.rotating_ = !0), i = l; 14014 } 14015 this.lastAngle_ = r; 14016 const o = t.map, a = o.getView(); 14017 a.getConstraints().rotation !== bh && (this.anchor_ = o.getCoordinateFromPixelInternal( 14018 o.getEventPixel(zh(this.targetPointers)) 14019 ), this.rotating_ && (o.render(), a.adjustRotationInternal(i, this.anchor_))); 14020 } 14021 /** 14022 * Handle pointer up events. 14023 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 14024 * @return {boolean} If the event was consumed. 14025 */ 14026 handleUpEvent(t) { 14027 return this.targetPointers.length < 2 ? (t.map.getView().endInteraction(this.duration_), !1) : !0; 14028 } 14029 /** 14030 * Handle pointer down events. 14031 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 14032 * @return {boolean} If the event was consumed. 14033 */ 14034 handleDownEvent(t) { 14035 if (this.targetPointers.length >= 2) { 14036 const i = t.map; 14037 return this.anchor_ = null, this.lastAngle_ = void 0, this.rotating_ = !1, this.rotationDelta_ = 0, this.handlingDownUpSequence || i.getView().beginInteraction(), !0; 14038 } 14039 return !1; 14040 } 14041} 14042const eC = tC; 14043class iC extends es { 14044 /** 14045 * @param {Options} [options] Options. 14046 */ 14047 constructor(t) { 14048 t = t || {}; 14049 const i = ( 14050 /** @type {import("./Pointer.js").Options} */ 14051 t 14052 ); 14053 i.stopDown || (i.stopDown = Rs), super(i), this.anchor_ = null, this.duration_ = t.duration !== void 0 ? t.duration : 400, this.lastDistance_ = void 0, this.lastScaleDelta_ = 1; 14054 } 14055 /** 14056 * Handle pointer drag events. 14057 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 14058 */ 14059 handleDragEvent(t) { 14060 let i = 1; 14061 const s = this.targetPointers[0], n = this.targetPointers[1], r = s.clientX - n.clientX, o = s.clientY - n.clientY, a = Math.sqrt(r * r + o * o); 14062 this.lastDistance_ !== void 0 && (i = this.lastDistance_ / a), this.lastDistance_ = a; 14063 const l = t.map, h = l.getView(); 14064 i != 1 && (this.lastScaleDelta_ = i), this.anchor_ = l.getCoordinateFromPixelInternal( 14065 l.getEventPixel(zh(this.targetPointers)) 14066 ), l.render(), h.adjustResolutionInternal(i, this.anchor_); 14067 } 14068 /** 14069 * Handle pointer up events. 14070 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 14071 * @return {boolean} If the event was consumed. 14072 */ 14073 handleUpEvent(t) { 14074 if (this.targetPointers.length < 2) { 14075 const s = t.map.getView(), n = this.lastScaleDelta_ > 1 ? 1 : -1; 14076 return s.endInteraction(this.duration_, n), !1; 14077 } 14078 return !0; 14079 } 14080 /** 14081 * Handle pointer down events. 14082 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event. 14083 * @return {boolean} If the event was consumed. 14084 */ 14085 handleDownEvent(t) { 14086 if (this.targetPointers.length >= 2) { 14087 const i = t.map; 14088 return this.anchor_ = null, this.lastDistance_ = void 0, this.lastScaleDelta_ = 1, this.handlingDownUpSequence || i.getView().beginInteraction(), !0; 14089 } 14090 return !1; 14091 } 14092} 14093const sC = iC; 14094function nC(e) { 14095 e = e || {}; 14096 const t = new Pe(), i = new ZM(-5e-3, 0.05, 100); 14097 return (e.altShiftDragRotate !== void 0 ? e.altShiftDragRotate : !0) && t.push(new zM()), (e.doubleClickZoom !== void 0 ? e.doubleClickZoom : !0) && t.push( 14098 new rg({ 14099 delta: e.zoomDelta, 14100 duration: e.zoomDuration 14101 }) 14102 ), (e.dragPan !== void 0 ? e.dragPan : !0) && t.push( 14103 new kM({ 14104 onFocusOnly: e.onFocusOnly, 14105 kinetic: i 14106 }) 14107 ), (e.pinchRotate !== void 0 ? e.pinchRotate : !0) && t.push(new eC()), (e.pinchZoom !== void 0 ? e.pinchZoom : !0) && t.push( 14108 new sC({ 14109 duration: e.zoomDuration 14110 }) 14111 ), (e.keyboard !== void 0 ? e.keyboard : !0) && (t.push(new KM()), t.push( 14112 new qM({ 14113 delta: e.zoomDelta, 14114 duration: e.zoomDuration 14115 }) 14116 )), (e.mouseWheelZoom !== void 0 ? e.mouseWheelZoom : !0) && t.push( 14117 new QM({ 14118 onFocusOnly: e.onFocusOnly, 14119 duration: e.zoomDuration 14120 }) 14121 ), (e.shiftDragZoom !== void 0 ? e.shiftDragZoom : !0) && t.push( 14122 new $M({ 14123 duration: e.zoomDuration 14124 }) 14125 ), t; 14126} 14127function Tu(e, t, i) { 14128 return i === void 0 && (i = [0, 0]), i[0] = e[0] + 2 * t, i[1] = e[1] + 2 * t, i; 14129} 14130function Ru(e) { 14131 return e[0] > 0 && e[1] > 0; 14132} 14133function ug(e, t, i) { 14134 return i === void 0 && (i = [0, 0]), i[0] = e[0] * t + 0.5 | 0, i[1] = e[1] * t + 0.5 | 0, i; 14135} 14136function ye(e, t) { 14137 return Array.isArray(e) ? e : (t === void 0 ? t = [e, e] : (t[0] = e, t[1] = e), t); 14138} 14139function dg(e) { 14140 if (e instanceof Pr) { 14141 e.setMapInternal(null); 14142 return; 14143 }
14144 e instanceof ma && e.getLayers().forEach(dg); 14145} 14146function fg(e, t) { 14147 if (e instanceof Pr) { 14148 e.setMapInternal(t); 14149 return; 14150 } 14151 if (e instanceof ma) { 14152 const i = e.getLayers().getArray(); 14153 for (let s = 0, n = i.length; s < n; ++s) 14154 fg(i[s], t); 14155 } 14156} 14157let rC = class extends ni { 14158 /** 14159 * @param {MapOptions} [options] Map options. 14160 */ 14161 constructor(t) { 14162 super(), t = t || {}, this.on, this.once, this.un; 14163 const i = oC(t); 14164 this.renderComplete_, this.loaded_ = !0, this.boundHandleBrowserEvent_ = this.handleBrowserEvent.bind(this), this.maxTilesLoading_ = t.maxTilesLoading !== void 0 ? t.maxTilesLoading : 16, this.pixelRatio_ = t.pixelRatio !== void 0 ? t.pixelRatio : Gf, this.postRenderTimeoutHandle_, this.animationDelayKey_, this.animationDelay_ = this.animationDelay_.bind(this), this.coordinateToPixelTransform_ = Qe(), this.pixelToCoordinateTransform_ = Qe(), this.frameIndex_ = 0, this.frameState_ = null, this.previousExtent_ = null, this.viewPropertyListenerKey_ = null, this.viewChangeListenerKey_ = null, this.layerGroupPropertyListenerKeys_ = null, this.viewport_ = document.createElement("div"), this.viewport_.className = "ol-viewport" + ("ontouchstart" in window ? " ol-touch" : ""), this.viewport_.style.position = "relative", this.viewport_.style.overflow = "hidden", this.viewport_.style.width = "100%", this.viewport_.style.height = "100%", this.overlayContainer_ = document.createElement("div"), this.overlayContainer_.style.position = "absolute", this.overlayContainer_.style.zIndex = "0", this.overlayContainer_.style.width = "100%", this.overlayContainer_.style.height = "100%", this.overlayContainer_.style.pointerEvents = "none", this.overlayContainer_.className = "ol-overlaycontainer", this.viewport_.appendChild(this.overlayContainer_), this.overlayContainerStopEvent_ = document.createElement("div"), this.overlayContainerStopEvent_.style.position = "absolute", this.overlayContainerStopEvent_.style.zIndex = "0", this.overlayContainerStopEvent_.style.width = "100%", this.overlayContainerStopEvent_.style.height = "100%", this.overlayContainerStopEvent_.style.pointerEvents = "none", this.overlayContainerStopEvent_.className = "ol-overlaycontainer-stopevent", this.viewport_.appendChild(this.overlayContainerStopEvent_), this.mapBrowserEventHandler_ = null, this.moveTolerance_ = t.moveTolerance, this.keyboardEventTarget_ = i.keyboardEventTarget, this.targetChangeHandlerKeys_ = null, this.targetElement_ = null, this.resizeObserver_ = new ResizeObserver(() => this.updateSize()), this.controls = i.controls || wM(), this.interactions = i.interactions || nC({ 14165 onFocusOnly: !0 14166 }), this.overlays_ = i.overlays, this.overlayIdIndex_ = {}, this.renderer_ = null, this.postRenderFunctions_ = [], this.tileQueue_ = new pM( 14167 this.getTilePriority.bind(this), 14168 this.handleTileChange_.bind(this) 14169 ), this.addChangeListener( 14170 Qt.LAYERGROUP, 14171 this.handleLayerGroupChanged_ 14172 ), this.addChangeListener(Qt.VIEW, this.handleViewChanged_), this.addChangeListener(Qt.SIZE, this.handleSizeChanged_), this.addChangeListener(Qt.TARGET, this.handleTargetChanged_), this.setProperties(i.values); 14173 const s = this; 14174 t.view && !(t.view instanceof Ve) && t.view.then(function(n) { 14175 s.setView(new Ve(n)); 14176 }), this.controls.addEventListener( 14177 $t.ADD, 14178 /** 14179 * @param {import("./Collection.js").CollectionEvent<import("./control/Control.js").default>} event CollectionEvent 14180 */ 14181 (n) => { 14182 n.element.setMap(this); 14183 } 14184 ), this.controls.addEventListener( 14185 $t.REMOVE, 14186 /** 14187 * @param {import("./Collection.js").CollectionEvent<import("./control/Control.js").default>} event CollectionEvent. 14188 */ 14189 (n) => { 14190 n.element.setMap(null); 14191 } 14192 ), this.interactions.addEventListener( 14193 $t.ADD, 14194 /** 14195 * @param {import("./Collection.js").CollectionEvent<import("./interaction/Interaction.js").default>} event CollectionEvent. 14196 */ 14197 (n) => { 14198 n.element.setMap(this); 14199 } 14200 ), this.interactions.addEventListener( 14201 $t.REMOVE, 14202 /** 14203 * @param {import("./Collection.js").CollectionEvent<import("./interaction/Interaction.js").default>} event CollectionEvent. 14204 */ 14205 (n) => { 14206 n.element.setMap(null); 14207 } 14208 ), this.overlays_.addEventListener( 14209 $t.ADD, 14210 /** 14211 * @param {import("./Collection.js").CollectionEvent<import("./Overlay.js").default>} event CollectionEvent. 14212 */ 14213 (n) => { 14214 this.addOverlayInternal_(n.element); 14215 } 14216 ), this.overlays_.addEventListener( 14217 $t.REMOVE, 14218 /** 14219 * @param {import("./Collection.js").CollectionEvent<import("./Overlay.js").default>} event CollectionEvent. 14220 */ 14221 (n) => { 14222 const r = n.element.getId(); 14223 r !== void 0 && delete this.overlayIdIndex_[r.toString()], n.element.setMap(null); 14224 }
14225 ), this.controls.forEach( 14226 /** 14227 * @param {import("./control/Control.js").default} control Control. 14228 */ 14229 (n) => { 14230 n.setMap(this); 14231 } 14232 ), this.interactions.forEach( 14233 /** 14234 * @param {import("./interaction/Interaction.js").default} interaction Interaction. 14235 */ 14236 (n) => { 14237 n.setMap(this); 14238 } 14239 ), this.overlays_.forEach(this.addOverlayInternal_.bind(this)); 14240 } 14241 /** 14242 * Add the given control to the map. 14243 * @param {import("./control/Control.js").default} control Control. 14244 * @api 14245 */ 14246 addControl(t) { 14247 this.getControls().push(t); 14248 } 14249 /** 14250 * Add the given interaction to the map. If you want to add an interaction 14251 * at another point of the collection use `getInteractions()` and the methods 14252 * available on {@link module:ol/Collection~Collection}. This can be used to 14253 * stop the event propagation from the handleEvent function. The interactions 14254 * get to handle the events in the reverse order of this collection. 14255 * @param {import("./interaction/Interaction.js").default} interaction Interaction to add. 14256 * @api 14257 */ 14258 addInteraction(t) { 14259 this.getInteractions().push(t); 14260 } 14261 /** 14262 * Adds the given layer to the top of this map. If you want to add a layer 14263 * elsewhere in the stack, use `getLayers()` and the methods available on 14264 * {@link module:ol/Collection~Collection}. 14265 * @param {import("./layer/Base.js").default} layer Layer. 14266 * @api 14267 */ 14268 addLayer(t) { 14269 this.getLayerGroup().getLayers().push(t); 14270 } 14271 /** 14272 * @param {import("./layer/Group.js").GroupEvent} event The layer add event. 14273 * @private 14274 */ 14275 handleLayerAdd_(t) { 14276 fg(t.layer, this); 14277 } 14278 /** 14279 * Add the given overlay to the map. 14280 * @param {import("./Overlay.js").default} overlay Overlay. 14281 * @api 14282 */ 14283 addOverlay(t) { 14284 this.getOverlays().push(t); 14285 } 14286 /** 14287 * This deals with map's overlay collection changes. 14288 * @param {import("./Overlay.js").default} overlay Overlay. 14289 * @private 14290 */ 14291 addOverlayInternal_(t) { 14292 const i = t.getId(); 14293 i !== void 0 && (this.overlayIdIndex_[i.toString()] = t), t.setMap(this); 14294 } 14295 /** 14296 * 14297 * Clean up. 14298 */ 14299 disposeInternal() { 14300 this.controls.clear(), this.interactions.clear(), this.overlays_.clear(), this.resizeObserver_.disconnect(), this.setTarget(null), super.disposeInternal(); 14301 } 14302 /** 14303 * Detect features that intersect a pixel on the viewport, and execute a 14304 * callback with each intersecting feature. Layers included in the detection can 14305 * be configured through the `layerFilter` option in `options`. 14306 * @param {import("./pixel.js").Pixel} pixel Pixel. 14307 * @param {function(import("./Feature.js").FeatureLike, import("./layer/Layer.js").default<import("./source/Source").default>, import("./geom/SimpleGeometry.js").default): T} callback Feature callback. The callback will be 14308 * called with two arguments. The first argument is one 14309 * {@link module:ol/Feature~Feature feature} or 14310 * {@link module:ol/render/Feature~RenderFeature render feature} at the pixel, the second is 14311 * the {@link module:ol/layer/Layer~Layer layer} of the feature and will be null for 14312 * unmanaged layers. To stop detection, callback functions can return a 14313 * truthy value. 14314 * @param {AtPixelOptions} [options] Optional options. 14315 * @return {T|undefined} Callback result, i.e. the return value of last 14316 * callback execution, or the first truthy callback return value. 14317 * @template T 14318 * @api 14319 */ 14320 forEachFeatureAtPixel(t, i, s) { 14321 if (!this.frameState_ || !this.renderer_) 14322 return; 14323 const n = this.getCoordinateFromPixelInternal(t); 14324 s = s !== void 0 ? s : {}; 14325 const r = s.hitTolerance !== void 0 ? s.hitTolerance : 0, o = s.layerFilter !== void 0 ? s.layerFilter : bs, a = s.checkWrapped !== !1; 14326 return this.renderer_.forEachFeatureAtCoordinate( 14327 n, 14328 this.frameState_, 14329 r, 14330 a, 14331 i, 14332 null, 14333 o, 14334 null 14335 ); 14336 } 14337 /** 14338 * Get all features that intersect a pixel on the viewport. 14339 * @param {import("./pixel.js").Pixel} pixel Pixel. 14340 * @param {AtPixelOptions} [options] Optional options. 14341 * @return {Array<import("./Feature.js").FeatureLike>} The detected features or 14342 * an empty array if none were found. 14343 * @api 14344 */ 14345 getFeaturesAtPixel(t, i) { 14346 const s = []; 14347 return this.forEachFeatureAtPixel( 14348 t, 14349 function(n) { 14350 s.push(n); 14351 }, 14352 i 14353 ), s; 14354 } 14355 /** 14356 * Get all layers from all layer groups. 14357 * @return {Array<import("./layer/Layer.js").default>} Layers. 14358 * @api 14359 */ 14360 getAllLayers() { 14361 const t = []; 14362 function i(s) {
14363 s.forEach(function(n) { 14364 n instanceof ma ? i(n.getLayers()) : t.push(n); 14365 }); 14366 } 14367 return i(this.getLayers()), t; 14368 } 14369 /** 14370 * Detect if features intersect a pixel on the viewport. Layers included in the 14371 * detection can be configured through the `layerFilter` option. 14372 * @param {import("./pixel.js").Pixel} pixel Pixel. 14373 * @param {AtPixelOptions} [options] Optional options. 14374 * @return {boolean} Is there a feature at the given pixel? 14375 * @api 14376 */ 14377 hasFeatureAtPixel(t, i) { 14378 if (!this.frameState_ || !this.renderer_) 14379 return !1; 14380 const s = this.getCoordinateFromPixelInternal(t); 14381 i = i !== void 0 ? i : {}; 14382 const n = i.layerFilter !== void 0 ? i.layerFilter : bs, r = i.hitTolerance !== void 0 ? i.hitTolerance : 0, o = i.checkWrapped !== !1; 14383 return this.renderer_.hasFeatureAtCoordinate( 14384 s, 14385 this.frameState_, 14386 r, 14387 o, 14388 n, 14389 null 14390 ); 14391 } 14392 /** 14393 * Returns the coordinate in user projection for a browser event. 14394 * @param {MouseEvent} event Event. 14395 * @return {import("./coordinate.js").Coordinate} Coordinate. 14396 * @api 14397 */
14398 getEventCoordinate(t) { 14399 return this.getCoordinateFromPixel(this.getEventPixel(t)); 14400 } 14401 /** 14402 * Returns the coordinate in view projection for a browser event. 14403 * @param {MouseEvent} event Event. 14404 * @return {import("./coordinate.js").Coordinate} Coordinate. 14405 */ 14406 getEventCoordinateInternal(t) { 14407 return this.getCoordinateFromPixelInternal(this.getEventPixel(t)); 14408 } 14409 /** 14410 * Returns the map pixel position for a browser event relative to the viewport. 14411 * @param {UIEvent|{clientX: number, clientY: number}} event Event. 14412 * @return {import("./pixel.js").Pixel} Pixel. 14413 * @api 14414 */ 14415 getEventPixel(t) { 14416 const s = this.viewport_.getBoundingClientRect(), n = this.getSize(), r = s.width / n[0], o = s.height / n[1], a = ( 14417 //FIXME Are we really calling this with a TouchEvent anywhere? 14418 "changedTouches" in t ? ( 14419 /** @type {TouchEvent} */ 14420 t.changedTouches[0] 14421 ) : ( 14422 /** @type {MouseEvent} */ 14423 t 14424 ) 14425 ); 14426 return [ 14427 (a.clientX - s.left) / r, 14428 (a.clientY - s.top) / o 14429 ]; 14430 } 14431 /** 14432 * Get the target in which this map is rendered. 14433 * Note that this returns what is entered as an option or in setTarget: 14434 * if that was an element, it returns an element; if a string, it returns that. 14435 * @return {HTMLElement|string|undefined} The Element or id of the Element that the 14436 * map is rendered in. 14437 * @observable 14438 * @api 14439 */ 14440 getTarget() { 14441 return ( 14442 /** @type {HTMLElement|string|undefined} */ 14443 this.get(Qt.TARGET) 14444 ); 14445 } 14446 /** 14447 * Get the DOM element into which this map is rendered. In contrast to 14448 * `getTarget` this method always return an `Element`, or `null` if the 14449 * map has no target. 14450 * @return {HTMLElement} The element that the map is rendered in. 14451 * @api 14452 */ 14453 getTargetElement() { 14454 return this.targetElement_; 14455 } 14456 /** 14457 * Get the coordinate for a given pixel. This returns a coordinate in the 14458 * user projection. 14459 * @param {import("./pixel.js").Pixel} pixel Pixel position in the map viewport. 14460 * @return {import("./coordinate.js").Coordinate} The coordinate for the pixel position. 14461 * @api 14462 */ 14463 getCoordinateFromPixel(t) { 14464 return Ms( 14465 this.getCoordinateFromPixelInternal(t), 14466 this.getView().getProjection() 14467 ); 14468 } 14469 /** 14470 * Get the coordinate for a given pixel. This returns a coordinate in the 14471 * map view projection. 14472 * @param {import("./pixel.js").Pixel} pixel Pixel position in the map viewport. 14473 * @return {import("./coordinate.js").Coordinate} The coordinate for the pixel position. 14474 */ 14475 getCoordinateFromPixelInternal(t) { 14476 const i = this.frameState_; 14477 return i ? zt(i.pixelToCoordinateTransform, t.slice()) : null; 14478 } 14479 /** 14480 * Get the map controls. Modifying this collection changes the controls 14481 * associated with the map. 14482 * @return {Collection<import("./control/Control.js").default>} Controls. 14483 * @api 14484 */ 14485 getControls() { 14486 return this.controls; 14487 } 14488 /** 14489 * Get the map overlays. Modifying this collection changes the overlays 14490 * associated with the map. 14491 * @return {Collection<import("./Overlay.js").default>} Overlays. 14492 * @api 14493 */ 14494 getOverlays() { 14495 return this.overlays_; 14496 } 14497 /** 14498 * Get an overlay by its identifier (the value returned by overlay.getId()). 14499 * Note that the index treats string and numeric identifiers as the same. So 14500 * `map.getOverlayById(2)` will return an overlay with id `'2'` or `2`. 14501 * @param {string|number} id Overlay identifier. 14502 * @return {import("./Overlay.js").default} Overlay. 14503 * @api 14504 */ 14505 getOverlayById(t) { 14506 const i = this.overlayIdIndex_[t.toString()]; 14507 return i !== void 0 ? i : null; 14508 } 14509 /** 14510 * Get the map interactions. Modifying this collection changes the interactions 14511 * associated with the map. 14512 * 14513 * Interactions are used for e.g. pan, zoom and rotate. 14514 * @return {Collection<import("./interaction/Interaction.js").default>} Interactions. 14515 * @api 14516 */ 14517 getInteractions() { 14518 return this.interactions; 14519 } 14520 /** 14521 * Get the layergroup associated with this map. 14522 * @return {LayerGroup} A layer group containing the layers in this map. 14523 * @observable 14524 * @api 14525 */ 14526 getLayerGroup() { 14527 return ( 14528 /** @type {LayerGroup} */ 14529 this.get(Qt.LAYERGROUP) 14530 ); 14531 } 14532 /** 14533 * Clear any existing layers and add layers to the map. 14534 * @param {Array<import("./layer/Base.js").default>|Collection<import("./layer/Base.js").default>} layers The layers to be added to the map. 14535 * @api 14536 */ 14537 setLayers(t) { 14538 const i = this.getLayerGroup(); 14539 if (t instanceof Pe) { 14540 i.setLayers(t); 14541 return; 14542 } 14543 const s = i.getLayers(); 14544 s.clear(), s.extend(t); 14545 } 14546 /** 14547 * Get the collection of layers associated with this map. 14548 * @return {!Collection<import("./layer/Base.js").default>} Layers. 14549 * @api 14550 */ 14551 getLayers() { 14552 return this.getLayerGroup().getLayers(); 14553 } 14554 /** 14555 * @return {boolean} Layers have sources that are still loading. 14556 */
14557 getLoadingOrNotReady() { 14558 const t = this.getLayerGroup().getLayerStatesArray(); 14559 for (let i = 0, s = t.length; i < s; ++i) { 14560 const n = t[i]; 14561 if (!n.visible) 14562 continue; 14563 const r = n.layer.getRenderer(); 14564 if (r && !r.ready) 14565 return !0; 14566 const o = n.layer.getSource(); 14567 if (o && o.loading) 14568 return !0; 14569 } 14570 return !1; 14571 } 14572 /** 14573 * Get the pixel for a coordinate. This takes a coordinate in the user 14574 * projection and returns the corresponding pixel. 14575 * @param {import("./coordinate.js").Coordinate} coordinate A map coordinate. 14576 * @return {import("./pixel.js").Pixel} A pixel position in the map viewport. 14577 * @api 14578 */ 14579 getPixelFromCoordinate(t) { 14580 const i = It( 14581 t, 14582 this.getView().getProjection() 14583 ); 14584 return this.getPixelFromCoordinateInternal(i); 14585 } 14586 /** 14587 * Get the pixel for a coordinate. This takes a coordinate in the map view 14588 * projection and returns the corresponding pixel. 14589 * @param {import("./coordinate.js").Coordinate} coordinate A map coordinate. 14590 * @return {import("./pixel.js").Pixel} A pixel position in the map viewport. 14591 */ 14592 getPixelFromCoordinateInternal(t) { 14593 const i = this.frameState_; 14594 return i ? zt( 14595 i.coordinateToPixelTransform, 14596 t.slice(0, 2) 14597 ) : null; 14598 } 14599 /** 14600 * Get the map renderer. 14601 * @return {import("./renderer/Map.js").default|null} Renderer 14602 */ 14603 getRenderer() { 14604 return this.renderer_; 14605 } 14606 /** 14607 * Get the size of this map. 14608 * @return {import("./size.js").Size|undefined} The size in pixels of the map in the DOM. 14609 * @observable 14610 * @api 14611 */ 14612 getSize() { 14613 return ( 14614 /** @type {import("./size.js").Size|undefined} */ 14615 this.get(Qt.SIZE) 14616 ); 14617 } 14618 /** 14619 * Get the view associated with this map. A view manages properties such as 14620 * center and resolution. 14621 * @return {View} The view that controls this map. 14622 * @observable 14623 * @api 14624 */ 14625 getView() { 14626 return ( 14627 /** @type {View} */ 14628 this.get(Qt.VIEW) 14629 ); 14630 } 14631 /** 14632 * Get the element that serves as the map viewport. 14633 * @return {HTMLElement} Viewport. 14634 * @api 14635 */ 14636 getViewport() { 14637 return this.viewport_; 14638 } 14639 /** 14640 * Get the element that serves as the container for overlays. Elements added to 14641 * this container will let mousedown and touchstart events through to the map, 14642 * so clicks and gestures on an overlay will trigger {@link module:ol/MapBrowserEvent~MapBrowserEvent} 14643 * events. 14644 * @return {!HTMLElement} The map's overlay container. 14645 */ 14646 getOverlayContainer() { 14647 return this.overlayContainer_; 14648 } 14649 /** 14650 * Get the element that serves as a container for overlays that don't allow 14651 * event propagation. Elements added to this container won't let mousedown and 14652 * touchstart events through to the map, so clicks and gestures on an overlay 14653 * don't trigger any {@link module:ol/MapBrowserEvent~MapBrowserEvent}. 14654 * @return {!HTMLElement} The map's overlay container that stops events. 14655 */ 14656 getOverlayContainerStopEvent() { 14657 return this.overlayContainerStopEvent_; 14658 } 14659 /** 14660 * @return {!Document} The document where the map is displayed. 14661 */ 14662 getOwnerDocument() { 14663 const t = this.getTargetElement(); 14664 return t ? t.ownerDocument : document; 14665 } 14666 /** 14667 * @param {import("./Tile.js").default} tile Tile. 14668 * @param {string} tileSourceKey Tile source key. 14669 * @param {import("./coordinate.js").Coordinate} tileCenter Tile center. 14670 * @param {number} tileResolution Tile resolution. 14671 * @return {number} Tile priority. 14672 */ 14673 getTilePriority(t, i, s, n) { 14674 return yM( 14675 this.frameState_, 14676 t, 14677 i, 14678 s, 14679 n 14680 ); 14681 } 14682 /** 14683 * @param {UIEvent} browserEvent Browser event. 14684 * @param {string} [type] Type. 14685 */ 14686 handleBrowserEvent(t, i) { 14687 i = i || t.type; 14688 const s = new ui(i, this, t); 14689 this.handleMapBrowserEvent(s); 14690 } 14691 /** 14692 * @param {MapBrowserEvent} mapBrowserEvent The event to handle. 14693 */ 14694 handleMapBrowserEvent(t) { 14695 if (!this.frameState_) 14696 return; 14697 const i = ( 14698 /** @type {PointerEvent} */ 14699 t.originalEvent 14700 ), s = i.type; 14701 if (s === Rl.POINTERDOWN || s === et.WHEEL || s === et.KEYDOWN) { 14702 const n = this.getOwnerDocument(), r = this.viewport_.getRootNode ? this.viewport_.getRootNode() : n, o = ( 14703 /** @type {Node} */ 14704 i.target 14705 ); 14706 if ( 14707 // Abort if the target is a child of the container for elements whose events are not meant 14708 // to be handled by map interactions. 14709 this.overlayContainerStopEvent_.contains(o) || // Abort if the event target is a child of the container that is no longer in the page. 14710 // It's possible for the target to no longer be in the page if it has been removed in an 14711 // event listener, this might happen in a Control that recreates it's content based on 14712 // user interaction either manually or via a render in something like https://reactjs.org/ 14713 !(r === n ? n.documentElement : r).contains(o) 14714 ) 14715 return; 14716 } 14717 if (t.frameState = this.frameState_, this.dispatchEvent(t) !== !1) { 14718 const n = this.getInteractions().getArray().slice(); 14719 for (let r = n.length - 1; r >= 0; r--) { 14720 const o = n[r]; 14721 if (o.getMap() !== this || !o.getActive() || !this.getTargetElement()) 14722 continue; 14723 if (!o.handleEvent(t) || t.propagationStopped) 14724 break; 14725 } 14726 } 14727 } 14728 /** 14729 * @protected 14730 */ 14731 handlePostRender() { 14732 const t = this.frameState_, i = this.tileQueue_; 14733 if (!i.isEmpty()) { 14734 let n = this.maxTilesLoading_, r = n; 14735 if (t) { 14736 const o = t.viewHints; 14737 if (o[Xt.ANIMATING] || o[Xt.INTERACTING]) { 14738 const a = Date.now() - t.time > 8; 14739 n = a ? 0 : 8, r = a ? 0 : 2; 14740 } 14741 } 14742 i.getTilesLoading() < n && (i.reprioritize(), i.loadMoreTiles(n, r)); 14743 } 14744 t && this.renderer_ && !t.animate && (this.renderComplete_ === !0 ? (this.hasListener(Vi.RENDERCOMPLETE) && this.renderer_.dispatchRenderEvent( 14745 Vi.RENDERCOMPLETE, 14746 t 14747 ), this.loaded_ === !1 && (this.loaded_ = !0, this.dispatchEvent( 14748 new js(Li.LOADEND, this, t) 14749 ))) : this.loaded_ === !0 && (this.loaded_ = !1, this.dispatchEvent( 14750 new js(Li.LOADSTART, this, t) 14751 ))); 14752 const s = this.postRenderFunctions_; 14753 for (let n = 0, r = s.length; n < r; ++n) 14754 s[n](this, t); 14755 s.length = 0; 14756 } 14757 /** 14758 * @private 14759 */ 14760 handleSizeChanged_() { 14761 this.getView() && !this.getView().getAnimating() && this.getView().resolveConstraints(0), this.render(); 14762 } 14763 /** 14764 * @private 14765 */ 14766 handleTargetChanged_() { 14767 if (this.mapBrowserEventHandler_) { 14768 for (let s = 0, n = this.targetChangeHandlerKeys_.length; s < n; ++s) 14769 Mt(this.targetChangeHandlerKeys_[s]); 14770 this.targetChangeHandlerKeys_ = null, this.viewport_.removeEventListener( 14771 et.CONTEXTMENU, 14772 this.boundHandleBrowserEvent_ 14773 ), this.viewport_.removeEventListener( 14774 et.WHEEL, 14775 this.boundHandleBrowserEvent_ 14776 ), this.mapBrowserEventHandler_.dispose(), this.mapBrowserEventHandler_ = null, Sl(this.viewport_); 14777 } 14778 if (this.targetElement_) { 14779 this.resizeObserver_.unobserve(this.targetElement_); 14780 const s = this.targetElement_.getRootNode(); 14781 s instanceof ShadowRoot && this.resizeObserver_.unobserve(s.host), this.setSize(void 0); 14782 } 14783 const t = this.getTarget(), i = typeof t == "string" ? document.getElementById(t) : t; 14784 if (this.targetElement_ = i, !i) 14785 this.renderer_ && (clearTimeout(this.postRenderTimeoutHandle_), this.postRenderTimeoutHandle_ = void 0, this.postRenderFunctions_.length = 0, this.renderer_.dispose(), this.renderer_ = null), this.animationDelayKey_ && (cancelAnimationFrame(this.animationDelayKey_), this.animationDelayKey_ = void 0); 14786 else { 14787 i.appendChild(this.viewport_), this.renderer_ || (this.renderer_ = new hM(this)), this.mapBrowserEventHandler_ = new fM( 14788 this, 14789 this.moveTolerance_ 14790 ); 14791 for (const r in dt) 14792 this.mapBrowserEventHandler_.addEventListener( 14793 dt[r], 14794 this.handleMapBrowserEvent.bind(this) 14795 ); 14796 this.viewport_.addEventListener( 14797 et.CONTEXTMENU, 14798 this.boundHandleBrowserEvent_, 14799 !1 14800 ), this.viewport_.addEventListener( 14801 et.WHEEL, 14802 this.boundHandleBrowserEvent_, 14803 zf ? { passive: !1 } : !1 14804 ); 14805 const s = this.keyboardEventTarget_ ? this.keyboardEventTarget_ : i; 14806 this.targetChangeHandlerKeys_ = [ 14807 lt( 14808 s, 14809 et.KEYDOWN, 14810 this.handleBrowserEvent, 14811 this 14812 ), 14813 lt( 14814 s, 14815 et.KEYPRESS, 14816 this.handleBrowserEvent, 14817 this 14818 ) 14819 ]; 14820 const n = i.getRootNode(); 14821 n instanceof ShadowRoot && this.resizeObserver_.observe(n.host), this.resizeObserver_.observe(i); 14822 } 14823 this.updateSize(); 14824 } 14825 /** 14826 * @private 14827 */ 14828 handleTileChange_() { 14829 this.render(); 14830 } 14831 /** 14832 * @private 14833 */ 14834 handleViewPropertyChanged_() { 14835 this.render(); 14836 } 14837 /** 14838 * @private 14839 */ 14840 handleViewChanged_() { 14841 this.viewPropertyListenerKey_ && (Mt(this.viewPropertyListenerKey_), this.viewPropertyListenerKey_ = null), this.viewChangeListenerKey_ && (Mt(this.viewChangeListenerKey_), this.viewChangeListenerKey_ = null); 14842 const t = this.getView(); 14843 t && (this.updateViewportSize_(), this.viewPropertyListenerKey_ = lt( 14844 t, 14845 yn.PROPERTYCHANGE, 14846 this.handleViewPropertyChanged_, 14847 this 14848 ), this.viewChangeListenerKey_ = lt( 14849 t, 14850 et.CHANGE, 14851 this.handleViewPropertyChanged_, 14852 this
14853 ), t.resolveConstraints(0)), this.render(); 14854 } 14855 /** 14856 * @private 14857 */ 14858 handleLayerGroupChanged_() { 14859 this.layerGroupPropertyListenerKeys_ && (this.layerGroupPropertyListenerKeys_.forEach(Mt), this.layerGroupPropertyListenerKeys_ = null); 14860 const t = this.getLayerGroup(); 14861 t && (this.handleLayerAdd_(new Fi("addlayer", t)), this.layerGroupPropertyListenerKeys_ = [ 14862 lt(t, yn.PROPERTYCHANGE, this.render, this), 14863 lt(t, et.CHANGE, this.render, this), 14864 lt(t, "addlayer", this.handleLayerAdd_, this), 14865 lt(t, "removelayer", this.handleLayerRemove_, this) 14866 ]), this.render(); 14867 } 14868 /** 14869 * @return {boolean} Is rendered. 14870 */ 14871 isRendered() { 14872 return !!this.frameState_; 14873 } 14874 /** 14875 * @private 14876 */ 14877 animationDelay_() { 14878 this.animationDelayKey_ = void 0, this.renderFrame_(Date.now()); 14879 } 14880 /** 14881 * Requests an immediate render in a synchronous manner. 14882 * @api 14883 */ 14884 renderSync() { 14885 this.animationDelayKey_ && cancelAnimationFrame(this.animationDelayKey_), this.animationDelay_(); 14886 } 14887 /** 14888 * Redraws all text after new fonts have loaded 14889 */ 14890 redrawText() { 14891 const t = this.getLayerGroup().getLayerStatesArray(); 14892 for (let i = 0, s = t.length; i < s; ++i) { 14893 const n = t[i].layer; 14894 n.hasRenderer() && n.getRenderer().handleFontsChanged(); 14895 } 14896 } 14897 /** 14898 * Request a map rendering (at the next animation frame). 14899 * @api 14900 */ 14901 render() { 14902 this.renderer_ && this.animationDelayKey_ === void 0 && (this.animationDelayKey_ = requestAnimationFrame(this.animationDelay_)); 14903 } 14904 /** 14905 * Remove the given control from the map. 14906 * @param {import("./control/Control.js").default} control Control. 14907 * @return {import("./control/Control.js").default|undefined} The removed control (or undefined 14908 * if the control was not found). 14909 * @api 14910 */ 14911 removeControl(t) { 14912 return this.getControls().remove(t); 14913 } 14914 /** 14915 * Remove the given interaction from the map. 14916 * @param {import("./interaction/Interaction.js").default} interaction Interaction to remove. 14917 * @return {import("./interaction/Interaction.js").default|undefined} The removed interaction (or 14918 * undefined if the interaction was not found). 14919 * @api 14920 */ 14921 removeInteraction(t) { 14922 return this.getInteractions().remove(t); 14923 } 14924 /** 14925 * Removes the given layer from the map. 14926 * @param {import("./layer/Base.js").default} layer Layer. 14927 * @return {import("./layer/Base.js").default|undefined} The removed layer (or undefined if the 14928 * layer was not found). 14929 * @api 14930 */ 14931 removeLayer(t) { 14932 return this.getLayerGroup().getLayers().remove(t); 14933 } 14934 /** 14935 * @param {import("./layer/Group.js").GroupEvent} event The layer remove event. 14936 * @private 14937 */ 14938 handleLayerRemove_(t) { 14939 dg(t.layer); 14940 } 14941 /** 14942 * Remove the given overlay from the map. 14943 * @param {import("./Overlay.js").default} overlay Overlay. 14944 * @return {import("./Overlay.js").default|undefined} The removed overlay (or undefined 14945 * if the overlay was not found). 14946 * @api 14947 */ 14948 removeOverlay(t) { 14949 return this.getOverlays().remove(t); 14950 } 14951 /** 14952 * @param {number} time Time. 14953 * @private 14954 */ 14955 renderFrame_(t) { 14956 const i = this.getSize(), s = this.getView(), n = this.frameState_; 14957 let r = null; 14958 if (i !== void 0 && Ru(i) && s && s.isDef()) { 14959 const o = s.getHints( 14960 this.frameState_ ? this.frameState_.viewHints : void 0 14961 ), a = s.getState(); 14962 if (r = { 14963 animate: !1, 14964 coordinateToPixelTransform: this.coordinateToPixelTransform_, 14965 declutterTree: null, 14966 extent: en( 14967 a.center, 14968 a.resolution, 14969 a.rotation, 14970 i 14971 ), 14972 index: this.frameIndex_++, 14973 layerIndex: 0, 14974 layerStatesArray: this.getLayerGroup().getLayerStatesArray(), 14975 pixelRatio: this.pixelRatio_, 14976 pixelToCoordinateTransform: this.pixelToCoordinateTransform_, 14977 postRenderFunctions: [], 14978 size: i, 14979 tileQueue: this.tileQueue_, 14980 time: t, 14981 usedTiles: {}, 14982 viewState: a, 14983 viewHints: o, 14984 wantedTiles: {}, 14985 mapId: ot(this), 14986 renderTargets: {} 14987 }, a.nextCenter && a.nextResolution) { 14988 const l = isNaN(a.nextRotation) ? a.rotation : a.nextRotation; 14989 r.nextExtent = en( 14990 a.nextCenter, 14991 a.nextResolution, 14992 l, 14993 i 14994 ); 14995 } 14996 } 14997 this.frameState_ = r, this.renderer_.renderFrame(r), r && (r.animate && this.render(), Array.prototype.push.apply( 14998 this.postRenderFunctions_, 14999 r.postRenderFunctions 15000 ), n && (!this.previousExtent_ || !Ts(this.previousExtent_) && !fn(r.extent, this.previousExtent_)) && (this.dispatchEvent( 15001 new js(Li.MOVESTART, this, n) 15002 ), this.previousExtent_ = bn(this.previousExtent_)), this.previousExtent_ && !r.viewHints[Xt.AN
15002IMATING] && !r.viewHints[Xt.INTERACTING] && !fn(r.extent, this.previousExtent_) && (this.dispatchEvent( 15003 new js(Li.MOVEEND, this, r) 15004 ), Rd(r.extent, this.previousExtent_))), this.dispatchEvent(new js(Li.POSTRENDER, this, r)), this.renderComplete_ = this.hasListener(Li.LOADSTART) || this.hasListener(Li.LOADEND) || this.hasListener(Vi.RENDERCOMPLETE) ? !this.tileQueue_.getTilesLoading() && !this.tileQueue_.getCount() && !this.getLoadingOrNotReady() : void 0, this.postRenderTimeoutHandle_ || (this.postRenderTimeoutHandle_ = setTimeout(() => { 15005 this.postRenderTimeoutHandle_ = void 0, this.handlePostRender(); 15006 }, 0)); 15007 } 15008 /** 15009 * Sets the layergroup of this map. 15010 * @param {LayerGroup} layerGroup A layer group containing the layers in this map. 15011 * @observable 15012 * @api 15013 */ 15014 setLayerGroup(t) { 15015 const i = this.getLayerGroup(); 15016 i && this.handleLayerRemove_(new Fi("removelayer", i)), this.set(Qt.LAYERGROUP, t); 15017 } 15018 /** 15019 * Set the size of this map. 15020 * @param {import("./size.js").Size|undefined} size The size in pixels of the map in the DOM. 15021 * @observable 15022 * @api 15023 */ 15024 setSize(t) { 15025 this.set(Qt.SIZE, t); 15026 } 15027 /** 15028 * Set the target element to render this map into. 15029 * @param {HTMLElement|string} [target] The Element or id of the Element 15030 * that the map is rendered in. 15031 * @observable 15032 * @api 15033 */ 15034 setTarget(t) { 15035 this.set(Qt.TARGET, t); 15036 } 15037 /** 15038 * Set the view for this map. 15039 * @param {View|Promise<import("./View.js").ViewOptions>} view The view that controls this map. 15040 * It is also possible to pass a promise that resolves to options for constructing a view. This 15041 * alternative allows view properties to be resolved by sources or other components that load 15042 * view-related metadata. 15043 * @observable 15044 * @api 15045 */ 15046 setView(t) { 15047 if (!t || t instanceof Ve) { 15048 this.set(Qt.VIEW, t); 15049 return; 15050 } 15051 this.set(Qt.VIEW, new Ve()); 15052 const i = this; 15053 t.then(function(s) { 15054 i.setView(new Ve(s)); 15055 }); 15056 } 15057 /** 15058 * Force a recalculation of the map viewport size. This should be called when 15059 * third-party code changes the size of the map viewport. 15060 * @api 15061 */ 15062 updateSize() { 15063 const t = this.getTargetElement(); 15064 let i; 15065 if (t) { 15066 const n = getComputedStyle(t), r = t.offsetWidth - parseFloat(n.borderLeftWidth) - parseFloat(n.paddingLeft) - parseFloat(n.paddingRight) - parseFloat(n.borderRightWidth), o = t.offsetHeight - parseFloat(n.borderTopWidth) - parseFloat(n.paddingTop) - parseFloat(n.paddingBottom) - parseFloat(n.borderBottomWidth); 15067 !isNaN(r) && !isNaN(o) && (i = [r, o], !Ru(i) && (t.offsetWidth || t.offsetHeight || t.getClientRects().length) && kd( 15068 "No map visible because the map container's width or height are 0." 15069 )); 15070 } 15071 const s = this.getSize(); 15072 i && (!s || !bi(i, s)) && (this.setSize(i), this.updateViewportSize_()); 15073 } 15074 /** 15075 * Recomputes the viewport size and save it on the view object (if any) 15076 * @private 15077 */ 15078 updateViewportSize_() { 15079 const t = this.getView(); 15080 if (t) { 15081 let i; 15082 const s = getComputedStyle(this.viewport_); 15083 s.width && s.height && (i = [ 15084 parseInt(s.width, 10), 15085 parseInt(s.height, 10) 15086 ]), t.setViewportSize(i); 15087 } 15088 } 15089}; 15090function oC(e) { 15091 let t = null; 15092 e.keyboardEventTarget !== void 0 && (t = typeof e.keyboardEventTarget == "string" ? document.getElementById(e.keyboardEventTarget) : e.keyboardEventTarget); 15093 const i = {}, s = e.layers && typeof /** @type {?} */ 15094 e.layers.getLayers == "function" ? ( 15095 /** @type {LayerGroup} */ 15096 e.layers 15097 ) : new ma({ 15098 layers: ( 15099 /** @type {Collection<import("./layer/Base.js").default>|Array<import("./layer/Base.js").default>} */ 15100 e.layers 15101 ) 15102 }); 15103 i[Qt.LAYERGROUP] = s, i[Qt.TARGET] = e.target, i[Qt.VIEW] = e.view instanceof Ve ? e.view : new Ve(); 15104 let n; 15105 e.controls !== void 0 && (Array.isArray(e.controls) ? n = new Pe(e.controls.slice()) : (at( 15106 typeof /** @type {?} */ 15107 e.controls.getArray == "function", 15108 47 15109 ), n = e.controls)); 15110 let r; 15111 e.interactions !== void 0 && (Array.isArray(e.interactions) ? r = new Pe(e.interactions.slice()) : (at( 15112 typeof /** @type {?} */ 15113 e.interactions.getArray == "function", 15114 48 15115 ), r = e.interactions)); 15116 let o; 15117 return e.overlays !== void 0 ? Array.isArray(e.overlays) ? o = new Pe(e.overlays.slice()) : (at( 15118 typeof /** @type {?} */ 15119 e.overlays.getArray == "function", 15120 49 15121 ), o = e.overlays) : o = new Pe(), { 15122 controls: n, 15123 interactions: r, 15124 keyboardEventTarget: t, 15125 overlays: o, 15126 values: i 15127 }; 15128} 15129const aC = rC; 15130class Wh extends ni { 15131 /** 15132 * @param {Geometry|ObjectWithGeometry<Geometry>} [geometryOrProperties] 15133 * You may pass a Geometry object directly, or an object literal containing 15134 * properties. If you pass an object literal, you may include a Geometry 15135 * associated with a `geometry` key. 15136 */ 15137 constructor(t) { 15138 if (super(), this.on, this.once, this.un, this.id_ = void 0, this.geometryName_ = "geometry", this.style_ = null, this.styleFunction_ = void 0, this.geometryChangeKey_ = null, this.addChangeListener(this.geometryName_, this.handleGeometryChanged_), t) 15139 if (typeof /** @type {?} */ 15140 t.getSimplifiedGeometry == "function") { 15141 const i = ( 15142 /** @type {Geometry} */ 15143 t 15144 ); 15145 this.setGeometry(i); 15146 } else { 15147 const i = t; 15148 this.setProperties(i); 15149 } 15150 } 15151 /** 15152 * Clone this feature. If the original feature has a geometry it 15153 * is also cloned. The feature id is not set in the clone. 15154 * @return {Feature<Geometry>} The clone. 15155 * @api 15156 */ 15157 clone() { 15158 const t = ( 15159 /** @type {Feature<Geometry>} */ 15160 new Wh(this.hasProperties() ? this.getProperties() : null) 15161 ); 15162 t.setGeometryName(this.getGeometryName()); 15163 const i = this.getGeometry(); 15164 i && t.setGeometry( 15165 /** @type {Geometry} */ 15166 i.clone() 15167 );
15168 const s = this.getStyle(); 15169 return s && t.setStyle(s), t; 15170 } 15171 /** 15172 * Get the feature's default geometry. A feature may have any number of named 15173 * geometries. The "default" geometry (the one that is rendered by default) is 15174 * set when calling {@link module:ol/Feature~Feature#setGeometry}. 15175 * @return {Geometry|undefined} The default geometry for the feature. 15176 * @api 15177 * @observable 15178 */ 15179 getGeometry() { 15180 return ( 15181 /** @type {Geometry|undefined} */ 15182 this.get(this.geometryName_) 15183 ); 15184 } 15185 /** 15186 * Get the feature identifier. This is a stable identifier for the feature and 15187 * is either set when reading data from a remote source or set explicitly by 15188 * calling {@link module:ol/Feature~Feature#setId}. 15189 * @return {number|string|undefined} Id. 15190 * @api 15191 */ 15192 getId() { 15193 return this.id_; 15194 } 15195 /** 15196 * Get the name of the feature's default geometry. By default, the default 15197 * geometry is named `geometry`. 15198 * @return {string} Get the property name associated with the default geometry 15199 * for this feature. 15200 * @api 15201 */ 15202 getGeometryName() { 15203 return this.geometryName_; 15204 } 15205 /** 15206 * Get the feature's style. Will return what was provided to the 15207 * {@link module:ol/Feature~Feature#setStyle} method. 15208 * @return {import("./style/Style.js").StyleLike|undefined} The feature style. 15209 * @api 15210 */ 15211 getStyle() { 15212 return this.style_; 15213 } 15214 /** 15215 * Get the feature's style function. 15216 * @return {import("./style/Style.js").StyleFunction|undefined} Return a function 15217 * representing the current style of this feature. 15218 * @api 15219 */ 15220 getStyleFunction() { 15221 return this.styleFunction_; 15222 } 15223 /** 15224 * @private 15225 */ 15226 handleGeometryChange_() { 15227 this.changed(); 15228 } 15229 /** 15230 * @private 15231 */ 15232 handleGeometryChanged_() { 15233 this.geometryChangeKey_ && (Mt(this.geometryChangeKey_), this.geometryChangeKey_ = null); 15234 const t = this.getGeometry(); 15235 t && (this.geometryChangeKey_ = lt( 15236 t, 15237 et.CHANGE, 15238 this.handleGeometryChange_, 15239 this 15240 )), this.changed(); 15241 } 15242 /** 15243 * Set the default geometry for the feature. This will update the property 15244 * with the name returned by {@link module:ol/Feature~Feature#getGeometryName}. 15245 * @param {Geometry|undefined} geometry The new geometry. 15246 * @api 15247 * @observable 15248 */ 15249 setGeometry(t) { 15250 this.set(this.geometryName_, t); 15251 } 15252 /** 15253 * Set the style for the feature to override the layer style. This can be a 15254 * single style object, an array of styles, or a function that takes a 15255 * resolution and returns an array of styles. To unset the feature style, call 15256 * `setStyle()` without arguments or a falsey value. 15257 * @param {import("./style/Style.js").StyleLike} [style] Style for this feature. 15258 * @api 15259 * @fires module:ol/events/Event~BaseEvent#event:change 15260 */ 15261 setStyle(t) { 15262 this.style_ = t, this.styleFunction_ = t ? lC(t) : void 0, this.changed(); 15263 } 15264 /** 15265 * Set the feature id. The feature id is considered stable and may be used when 15266 * requesting features or comparing identifiers returned from a remote source. 15267 * The feature id can be used with the 15268 * {@link module:ol/source/Vector~VectorSource#getFeatureById} method. 15269 * @param {number|string|undefined} id The feature id. 15270 * @api 15271 * @fires module:ol/events/Event~BaseEvent#event:change 15272 */ 15273 setId(t) { 15274 this.id_ = t, this.changed(); 15275 } 15276 /** 15277 * Set the property name to be used when getting the feature's default geometry. 15278 * When calling {@link module:ol/Feature~Feature#getGeometry}, the value of the property with 15279 * this name will be returned. 15280 * @param {string} name The property name of the default geometry. 15281 * @api 15282 */ 15283 setGeometryName(t) { 15284 this.removeChangeListener(this.geometryName_, this.handleGeometryChanged_), this.geometryName_ = t, this.addChangeListener(this.geometryName_, this.handleGeometryChanged_), this.handleGeometryChanged_(); 15285 } 15286} 15287function lC(e) { 15288 if (typeof e == "function") 15289 return e; 15290 let t; 15291 return Array.isArray(e) ? t = e : (at(typeof /** @type {?} */ 15292 e.getZIndex == "function", 41), t = [ 15293 /** @type {import("./style/Style.js").default} */ 15294 e 15295 ]), function() { 15296 return t; 15297 }; 15298} 15299const Ni = Wh; 15300class Bh { 15301 /** 15302 * @param {Options} [options] Options. 15303 */ 15304 constructor(t) { 15305 t = t || {}, this.color_ = t.color !== void 0 ? t.color : null; 15306 } 15307 /** 15308 * Clones the style. The color is not cloned if it is an {@link module:ol/colorlike~ColorLike}. 15309 * @return {Fill} The cloned style. 15310 * @api 15311 */ 15312 clone() { 15313 const t = this.getColor(); 15314 return new Bh({ 15315 color: Array.isArray(t) ? t.slice() : t || void 0 15316 }); 15317 } 15318 /** 15319 * Get the fill color. 15320 * @return {import("../color.js").Color|import("../colorlike.js").ColorLike|null} Color. 15321 * @api 15322 */ 15323 getColor() { 15324 return this.color_; 15325 } 15326 /** 15327 * Set the color. 15328 * 15329 * @param {import("../color.js").Color|import("../colorlike.js").ColorLike|null} color Color. 15330 * @api 15331 */ 15332 setColor(t) { 15333 this.color_ = t; 15334 } 15335} 15336const Ei = Bh; 15337function gg(e, t, i, s, n, r, o) { 15338 let a, l; 15339 const h = (i - t) / s; 15340 if (h === 1) 15341 a = t; 15342 else if (h === 2) 15343 a = t, l = n; 15344 else if (h !== 0) {
15345 let c = e[t], u = e[t + 1], d = 0; 15346 const f = [0]; 15347 for (let m = t + s; m < i; m += s) { 15348 const p = e[m], y = e[m + 1]; 15349 d += Math.sqrt((p - c) * (p - c) + (y - u) * (y - u)), f.push(d), c = p, u = y; 15350 } 15351 const g = n * d, _ = Xv(f, g); 15352 _ < 0 ? (l = (g - f[-_ - 2]) / (f[-_ - 1] - f[-_ - 2]), a = t + (-_ - 2) * s) : a = t + _ * s; 15353 } 15354 o = o > 1 ? o : 2, r = r || new Array(o); 15355 for (let c = 0; c < o; ++c) 15356 r[c] = a === void 0 ? NaN : l === void 0 ? e[a + c] : we(e[a + c], e[a + s + c], l); 15357 return r; 15358} 15359function Al(e, t, i, s, n, r) { 15360 if (i == t) 15361 return null; 15362 let o; 15363 if (n < e[t + s - 1]) 15364 return r ? (o = e.slice(t, t + s), o[s - 1] = n, o) : null; 15365 if (e[i - 1] < n) 15366 return r ? (o = e.slice(i - s, i), o[s - 1] = n, o) : null; 15367 if (n == e[t + s - 1]) 15368 return e.slice(t, t + s); 15369 let a = t / s, l = i / s; 15370 for (; a < l; ) { 15371 const d = a + l >> 1; 15372 n < e[(d + 1) * s - 1] ? l = d : a = d + 1; 15373 } 15374 const h = e[a * s - 1]; 15375 if (n == h) 15376 return e.slice((a - 1) * s, (a - 1) * s + s); 15377 const c = e[(a + 1) * s - 1], u = (n - h) / (c - h); 15378 o = []; 15379 for (let d = 0; d < s - 1; ++d) 15380 o.push( 15381 we( 15382 e[(a - 1) * s + d], 15383 e[a * s + d], 15384 u 15385 ) 15386 ); 15387 return o.push(n), o; 15388} 15389function hC(e, t, i, s, n, r, o) { 15390 if (o) 15391 return Al( 15392 e, 15393 t, 15394 i[i.length - 1], 15395 s, 15396 n, 15397 r 15398 ); 15399 let a; 15400 if (n < e[s - 1]) 15401 return r ? (a = e.slice(0, s), a[s - 1] = n, a) : null; 15402 if (e[e.length - 1] < n) 15403 return r ? (a = e.slice(e.length - s), a[s - 1] = n, a) : null; 15404 for (let l = 0, h = i.length; l < h; ++l) { 15405 const c = i[l]; 15406 if (t != c) { 15407 if (n < e[t + s - 1]) 15408 return null; 15409 if (n <= e[c - 1]) 15410 return Al( 15411 e, 15412 t, 15413 c, 15414 s, 15415 n, 15416 !1 15417 ); 15418 t = c; 15419 } 15420 } 15421 return null; 15422} 15423function _g(e, t, i, s) { 15424 let n = e[t], r = e[t + 1], o = 0; 15425 for (let a = t + s; a < i; a += s) { 15426 const l = e[a], h = e[a + 1]; 15427 o += Math.sqrt((l - n) * (l - n) + (h - r) * (h - r)), n = l, r = h; 15428 } 15429 return o; 15430} 15431class jo extends ts { 15432 /** 15433 * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates. 15434 * For internal use, flat coordinates in combination with `layout` are also accepted. 15435 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 15436 */ 15437 constructor(t, i) { 15438 super(), this.flatMidpoint_ = null, this.flatMidpointRevision_ = -1, this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, i !== void 0 && !Array.isArray(t[0]) ? this.setFlatCoordinates( 15439 i, 15440 /** @type {Array<number>} */ 15441 t 15442 ) : this.setCoordinates( 15443 /** @type {Array<import("../coordinate.js").Coordinate>} */ 15444 t, 15445 i 15446 ); 15447 } 15448 /** 15449 * Append the passed coordinate to the coordinates of the linestring. 15450 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 15451 * @api 15452 */ 15453 appendCoordinate(t) { 15454 this.flatCoordinates ? mi(this.flatCoordinates, t) : this.flatCoordinates = t.slice(), this.changed(); 15455 } 15456 /** 15457 * Make a complete copy of the geometry. 15458 * @return {!LineString} Clone. 15459 * @api 15460 */ 15461 clone() { 15462 const t = new jo( 15463 this.flatCoordinates.slice(), 15464 this.layout 15465 ); 15466 return t.applyProperties(this), t; 15467 } 15468 /** 15469 * @param {number} x X. 15470 * @param {number} y Y. 15471 * @param {import("../coordinate.js").Coordinate} closestPoint Closest point. 15472 * @param {number} minSquaredDistance Minimum squared distance. 15473 * @return {number} Minimum squared distance. 15474 */ 15475 closestPointXY(t, i, s, n) { 15476 return n < Ss(this.getExtent(), t, i) ? n : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt( 15477 wh( 15478 this.flatCoordinates, 15479 0, 15480 this.flatCoordinates.length, 15481 this.stride, 15482 0 15483 ) 15484 ), this.maxDeltaRevision_ = this.getRevision()), Rh( 15485 this.flatCoordinates, 15486 0, 15487 this.flatCoordinates.length, 15488 this.stride, 15489 this.maxDelta_, 15490 !1, 15491 t, 15492 i, 15493 s, 15494 n 15495 )); 15496 } 15497 /** 15498 * Iterate over each segment, calling the provided callback. 15499 * If the callback returns a truthy value the function returns that 15500 * value immediately. Otherwise the function returns `false`. 15501 * 15502 * @param {function(this: S, import("../coordinate.js").Coordinate, import("../coordinate.js").Coordinate): T} callback Function 15503 * called for each segment. The function will receive two arguments, the start and end coordinates of the segment. 15504 * @return {T|boolean} Value. 15505 * @template T,S 15506 * @api 15507 */ 15508 forEachSegment(t) { 15509 return Hf( 15510 this.flatCoordinates, 15511 0, 15512 this.flatCoordinates.length, 15513 this.stride, 15514 t 15515 ); 15516 } 15517 /** 15518 * Returns the coordinate at `m` using linear interpolation, or `null` if no 15519 * such coordinate exists. 15520 * 15521 * `extrapolate` controls extrapolation beyond the range of Ms in the 15522 * MultiLineString. If `extrapolate` is `true` then Ms less than the first 15523 * M will return the first coordinate and Ms greater than the last M will 15524 * return the last coordinate. 15525 * 15526 * @param {number} m M. 15527 * @param {boolean} [extrapolate] Extrapolate. Default is `false`. 15528 * @return {import("../coordinate.js").Coordinate|null} Coordinate. 15529 * @api 15530 */ 15531 getCoordinateAtM(t, i) { 15532 return this.layout != "XYM" && this.layout != "XYZM" ? null : (i = i !== void 0 ? i : !1, Al( 15533 this.flatCoordinates, 15534 0, 15535 this.flatCoordinates.length, 15536 this.stride, 15537 t, 15538 i 15539 )); 15540 } 15541 /** 15542 * Return the coordinates of the linestring. 15543 * @return {Array<import("../coordinate.js").Coordinate>} Coordinates. 15544 * @api 15545 */ 15546 getCoordinates() { 15547 return ji( 15548 this.flatCoordinates, 15549 0, 15550 this.flatCoordinates.length, 15551 this.stride 15552 ); 15553 } 15554 /** 15555 * Return the coordinate at the provided fraction along the linestring. 15556 * The `fraction` is a number between 0 and 1, where 0 is the start of the 15557 * linestring and 1 is the end. 15558 * @param {number} fraction Fraction. 15559 * @param {import("../coordinate.js").Coordinate} [dest] Optional coordinate whose values will 15560 * be modified. If not provided, a new coordinate will be returned. 15561 * @return {import("../coordinate.js").Coordinate} Coordinate of the interpolated point. 15562 * @api 15563 */ 15564 getCoordinateAt(t, i) { 15565 return gg( 15566 this.flatCoordinates, 15567 0, 15568 this.flatCoordinates.length, 15569 this.stride, 15570 t, 15571 i, 15572 this.stride 15573 ); 15574 } 15575 /** 15576 * Return the length of the linestring on projected plane. 15577 * @return {number} Length (on projected plane). 15578 * @api 15579 */ 15580 getLength() { 15581 return _g( 15582 this.flatCoordinates, 15583 0, 15584 this.flatCoordinates.length, 15585 this.stride 15586 ); 15587 } 15588 /** 15589 * @return {Array<number>} Flat midpoint. 15590 */ 15591 getFlatMidpoint() { 15592 return this.flatMidpointRevision_ != this.getRevision() && (this.flatMidpoint_ = this.getCoordinateAt(0.5, this.flatMidpoint_), this.flatMidpointRevision_ = this.getRevision()), this.flatMidpoint_; 15593 } 15594 /** 15595 * @param {number} squaredTolerance Squared tolerance. 15596 * @return {LineString} Simplified LineString. 15597 * @protected 15598 */ 15599 getSimplifiedGeometryInternal(t) { 15600 const i = []; 15601 return i.length = Ah( 15602 this.flatCoordinates, 15603 0, 15604 this.flatCoordinates.length, 15605 this.stride, 15606 t, 15607 i, 15608 0 15609 ), new jo(i, "XY"); 15610 } 15611 /** 15612 * Get the type of this geometry. 15613 * @return {import("./Geometry.js").Type} Geometry type. 15614 * @api 15615 */ 15616 getType() { 15617 return "LineString"; 15618 } 15619 /** 15620 * Test if the geometry and the passed extent intersect. 15621 * @param {import("../extent.js").Extent} extent Extent. 15622 * @return {boolean} `true` if the geometry and the extent intersect. 15623 * @api 15624 */ 15625 intersectsExtent(t) { 15626 return fa( 15627 this.flatCoordinates, 15628 0, 15629 this.flatCoordinates.length, 15630 this.stride, 15631 t 15632 ); 15633 } 15634 /** 15635 * Set the coordinates of the linestring. 15636 * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates. 15637 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 15638 * @api 15639 */ 15640 setCoordinates(t, i) { 15641 this.setLayout(i, t, 1), this.flatCoordinates || (this.flatCoordinates = []), this.flatCoordinates.length = da( 15642 this.flatCoordinates, 15643 0, 15644 t, 15645 this.stride 15646 ), this.changed(); 15647 } 15648} 15649const ys = jo; 15650class Uh { 15651 /** 15652 * @param {Options} [options] Options. 15653 */ 15654 constructor(t) { 15655 t = t || {}, this.color_ = t.color !== void 0 ? t.color : null, this.lineCap_ = t.lineCap, this.lineDash_ = t.lineDash !== void 0 ? t.lineDash : null, this.lineDashOffset_ = t.lineDashOffset, this.lineJoin_ = t.lineJoin, this.miterLimit_ = t.miter
15655Limit, this.width_ = t.width; 15656 } 15657 /** 15658 * Clones the style. 15659 * @return {Stroke} The cloned style. 15660 * @api 15661 */ 15662 clone() { 15663 const t = this.getColor(); 15664 return new Uh({ 15665 color: Array.isArray(t) ? t.slice() : t || void 0, 15666 lineCap: this.getLineCap(), 15667 lineDash: this.getLineDash() ? this.getLineDash().slice() : void 0, 15668 lineDashOffset: this.getLineDashOffset(), 15669 lineJoin: this.getLineJoin(), 15670 miterLimit: this.getMiterLimit(), 15671 width: this.getWidth() 15672 }); 15673 } 15674 /** 15675 * Get the stroke color. 15676 * @return {import("../color.js").Color|import("../colorlike.js").ColorLike} Color. 15677 * @api 15678 */ 15679 getColor() { 15680 return this.color_; 15681 } 15682 /** 15683 * Get the line cap type for the stroke. 15684 * @return {CanvasLineCap|undefined} Line cap. 15685 * @api 15686 */ 15687 getLineCap() { 15688 return this.lineCap_; 15689 } 15690 /** 15691 * Get the line dash style for the stroke. 15692 * @return {Array<number>|null} Line dash. 15693 * @api 15694 */ 15695 getLineDash() { 15696 return this.lineDash_; 15697 } 15698 /** 15699 * Get the line dash offset for the stroke. 15700 * @return {number|undefined} Line dash offset. 15701 * @api 15702 */ 15703 getLineDashOffset() { 15704 return this.lineDashOffset_; 15705 } 15706 /** 15707 * Get the line join type for the stroke. 15708 * @return {CanvasLineJoin|undefined} Line join. 15709 * @api 15710 */ 15711 getLineJoin() { 15712 return this.lineJoin_; 15713 } 15714 /** 15715 * Get the miter limit for the stroke. 15716 * @return {number|undefined} Miter limit. 15717 * @api 15718 */ 15719 getMiterLimit() { 15720 return this.miterLimit_; 15721 } 15722 /** 15723 * Get the stroke width. 15724 * @return {number|undefined} Width. 15725 * @api 15726 */ 15727 getWidth() { 15728 return this.width_; 15729 } 15730 /** 15731 * Set the color. 15732 * 15733 * @param {import("../color.js").Color|import("../colorlike.js").ColorLike} color Color. 15734 * @api 15735 */ 15736 setColor(t) { 15737 this.color_ = t; 15738 } 15739 /** 15740 * Set the line cap. 15741 * 15742 * @param {CanvasLineCap|undefined} lineCap Line cap. 15743 * @api 15744 */ 15745 setLineCap(t) { 15746 this.lineCap_ = t; 15747 } 15748 /** 15749 * Set the line dash. 15750 * 15751 * @param {Array<number>|null} lineDash Line dash. 15752 * @api 15753 */ 15754 setLineDash(t) { 15755 this.lineDash_ = t; 15756 } 15757 /** 15758 * Set the line dash offset. 15759 * 15760 * @param {number|undefined} lineDashOffset Line dash offset. 15761 * @api 15762 */ 15763 setLineDashOffset(t) { 15764 this.lineDashOffset_ = t; 15765 } 15766 /** 15767 * Set the line join. 15768 * 15769 * @param {CanvasLineJoin|undefined} lineJoin Line join. 15770 * @api 15771 */ 15772 setLineJoin(t) { 15773 this.lineJoin_ = t; 15774 } 15775 /** 15776 * Set the miter limit. 15777 * 15778 * @param {number|undefined} miterLimit Miter limit. 15779 * @api 15780 */ 15781 setMiterLimit(t) { 15782 this.miterLimit_ = t; 15783 } 15784 /** 15785 * Set the width. 15786 * 15787 * @param {number|undefined} width Width. 15788 * @api 15789 */ 15790 setWidth(t) { 15791 this.width_ = t; 15792 } 15793} 15794const xi = Uh, rt = { 15795 IDLE: 0, 15796 LOADING: 1, 15797 LOADED: 2, 15798 ERROR: 3, 15799 EMPTY: 4 15800}; 15801class Xh { 15802 /** 15803 * @param {Options} options Options. 15804 */ 15805 constructor(t) { 15806 this.opacity_ = t.opacity, this.rotateWithView_ = t.rotateWithView, this.rotation_ = t.rotation, this.scale_ = t.scale, this.scaleArray_ = ye(t.scale), this.displacement_ = t.displacement, this.declutterMode_ = t.declutterMode; 15807 } 15808 /** 15809 * Clones the style. 15810 * @return {ImageStyle} The cloned style. 15811 * @api 15812 */ 15813 clone() { 15814 const t = this.getScale(); 15815 return new Xh({ 15816 opacity: this.getOpacity(), 15817 scale: Array.isArray(t) ? t.slice() : t, 15818 rotation: this.getRotation(), 15819 rotateWithView: this.getRotateWithView(), 15820 displacement: this.getDisplacement().slice(), 15821 declutterMode: this.getDeclutterMode() 15822 }); 15823 } 15824 /** 15825 * Get the symbolizer opacity. 15826 * @return {number} Opacity. 15827 * @api 15828 */ 15829 getOpacity() { 15830 return this.opacity_; 15831 } 15832 /** 15833 * Determine whether the symbolizer rotates with the map. 15834 * @return {boolean} Rotate with map. 15835 * @api 15836 */ 15837 getRotateWithView() { 15838 return this.rotateWithView_; 15839 } 15840 /** 15841 * Get the symoblizer rotation. 15842 * @return {number} Rotation. 15843 * @api 15844 */ 15845 getRotation() { 15846 return this.rotation_; 15847 } 15848 /** 15849 * Get the symbolizer scale. 15850 * @return {number|import("../size.js").Size} Scale. 15851 * @api 15852 */ 15853 getScale() { 15854 return this.scale_; 15855 } 15856 /** 15857 * Get the symbolizer scale array. 15858 * @return {import("../size.js").Size} Scale array. 15859 */ 15860 getScaleArray() { 15861 return this.scaleArray_; 15862 } 15863 /** 15864 * Get the displacement of the shape 15865 * @return {Array<number>} Shape's center displacement 15866 * @api 15867 */ 15868 getDisplacement() { 15869 return this.displacement_; 15870 } 15871 /** 15872 * Get the declutter mode of the shape 15873 * @return {"declutter"|"obstacle"|"none"|undefined} Shape's declutter mode 15874 * @api 15875 */ 15876 getDeclutterMode() { 15877 return this.declutterMode_; 15878 } 15879 /**
15880 * Get the anchor point in pixels. The anchor determines the center point for the 15881 * symbolizer. 15882 * @abstract 15883 * @return {Array<number>} Anchor. 15884 */ 15885 getAnchor() { 15886 return Z(); 15887 } 15888 /** 15889 * Get the image element for the symbolizer. 15890 * @abstract 15891 * @param {number} pixelRatio Pixel ratio. 15892 * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element. 15893 */ 15894 getImage(t) { 15895 return Z(); 15896 } 15897 /** 15898 * @abstract 15899 * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element. 15900 */ 15901 getHitDetectionImage() { 15902 return Z(); 15903 } 15904 /** 15905 * Get the image pixel ratio. 15906 * @param {number} pixelRatio Pixel ratio. 15907 * @return {number} Pixel ratio. 15908 */ 15909 getPixelRatio(t) { 15910 return 1; 15911 } 15912 /** 15913 * @abstract 15914 * @return {import("../ImageState.js").default} Image state. 15915 */ 15916 getImageState() { 15917 return Z(); 15918 } 15919 /** 15920 * @abstract 15921 * @return {import("../size.js").Size} Image size. 15922 */ 15923 getImageSize() { 15924 return Z(); 15925 } 15926 /** 15927 * Get the origin of the symbolizer. 15928 * @abstract 15929 * @return {Array<number>} Origin. 15930 */ 15931 getOrigin() { 15932 return Z(); 15933 } 15934 /** 15935 * Get the size of the symbolizer (in pixels). 15936 * @abstract 15937 * @return {import("../size.js").Size} Size. 15938 */ 15939 getSize() { 15940 return Z(); 15941 } 15942 /** 15943 * Set the displacement. 15944 * 15945 * @param {Array<number>} displacement Displacement. 15946 * @api 15947 */ 15948 setDisplacement(t) { 15949 this.displacement_ = t; 15950 } 15951 /** 15952 * Set the opacity. 15953 * 15954 * @param {number} opacity Opacity. 15955 * @api 15956 */ 15957 setOpacity(t) { 15958 this.opacity_ = t; 15959 } 15960 /** 15961 * Set whether to rotate the style with the view. 15962 * 15963 * @param {boolean} rotateWithView Rotate with map. 15964 * @api 15965 */ 15966 setRotateWithView(t) { 15967 this.rotateWithView_ = t; 15968 } 15969 /** 15970 * Set the rotation. 15971 * 15972 * @param {number} rotation Rotation. 15973 * @api 15974 */ 15975 setRotation(t) { 15976 this.rotation_ = t; 15977 } 15978 /** 15979 * Set the scale. 15980 * 15981 * @param {number|import("../size.js").Size} scale Scale. 15982 * @api 15983 */ 15984 setScale(t) { 15985 this.scale_ = t, this.scaleArray_ = ye(t); 15986 } 15987 /** 15988 * @abstract 15989 * @param {function(import("../events/Event.js").default): void} listener Listener function. 15990 */ 15991 listenImageChange(t) { 15992 Z(); 15993 } 15994 /** 15995 * Load not yet loaded URI. 15996 * @abstract 15997 */ 15998 load() { 15999 Z(); 16000 } 16001 /** 16002 * @abstract 16003 * @param {function(import("../events/Event.js").default): void} listener Listener function. 16004 */ 16005 unlistenImageChange(t) { 16006 Z(); 16007 } 16008} 16009const mg = Xh; 16010function Ze(e) { 16011 return Array.isArray(e) ? Wf(e) : e; 16012} 16013class $h extends mg { 16014 /** 16015 * @param {Options} options Options. 16016 */ 16017 constructor(t) { 16018 const i = t.rotateWithView !== void 0 ? t.rotateWithView : !1; 16019 super({ 16020 opacity: 1, 16021 rotateWithView: i, 16022 rotation: t.rotation !== void 0 ? t.rotation : 0, 16023 scale: t.scale !== void 0 ? t.scale : 1,
16024 displacement: t.displacement !== void 0 ? t.displacement : [0, 0], 16025 declutterMode: t.declutterMode 16026 }), this.canvas_ = void 0, this.hitDetectionCanvas_ = null, this.fill_ = t.fill !== void 0 ? t.fill : null, this.origin_ = [0, 0], this.points_ = t.points, this.radius_ = t.radius !== void 0 ? t.radius : t.radius1, this.radius2_ = t.radius2, this.angle_ = t.angle !== void 0 ? t.angle : 0, this.stroke_ = t.stroke !== void 0 ? t.stroke : null, this.size_ = null, this.renderOptions_ = null, this.render(); 16027 } 16028 /** 16029 * Clones the style. 16030 * @return {RegularShape} The cloned style. 16031 * @api 16032 */ 16033 clone() { 16034 const t = this.getScale(), i = new $h({ 16035 fill: this.getFill() ? this.getFill().clone() : void 0, 16036 points: this.getPoints(), 16037 radius: this.getRadius(), 16038 radius2: this.getRadius2(), 16039 angle: this.getAngle(), 16040 stroke: this.getStroke() ? this.getStroke().clone() : void 0, 16041 rotation: this.getRotation(), 16042 rotateWithView: this.getRotateWithView(), 16043 scale: Array.isArray(t) ? t.slice() : t, 16044 displacement: this.getDisplacement().slice(), 16045 declutterMode: this.getDeclutterMode() 16046 }); 16047 return i.setOpacity(this.getOpacity()), i; 16048 } 16049 /** 16050 * Get the anchor point in pixels. The anchor determines the center point for the 16051 * symbolizer. 16052 * @return {Array<number>} Anchor. 16053 * @api 16054 */ 16055 getAnchor() { 16056 const t = this.size_; 16057 if (!t) 16058 return null; 16059 const i = this.getDisplacement(), s = this.getScaleArray(); 16060 return [ 16061 t[0] / 2 - i[0] / s[0], 16062 t[1] / 2 + i[1] / s[1] 16063 ]; 16064 } 16065 /** 16066 * Get the angle used in generating the shape. 16067 * @return {number} Shape's rotation in radians. 16068 * @api 16069 */ 16070 getAngle() { 16071 return this.angle_; 16072 } 16073 /** 16074 * Get the fill style for the shape. 16075 * @return {import("./Fill.js").default} Fill style. 16076 * @api 16077 */ 16078 getFill() { 16079 return this.fill_; 16080 } 16081 /** 16082 * Set the fill style. 16083 * @param {import("./Fill.js").default} fill Fill style. 16084 * @api 16085 */ 16086 setFill(t) { 16087 this.fill_ = t, this.render(); 16088 } 16089 /** 16090 * @return {HTMLCanvasElement} Image element. 16091 */ 16092 getHitDetectionImage() { 16093 return this.hitDetectionCanvas_ || this.createHitDetectionCanvas_(this.renderOptions_), this.hitDetectionCanvas_; 16094 } 16095 /** 16096 * Get the image icon. 16097 * @param {number} pixelRatio Pixel ratio. 16098 * @return {HTMLCanvasElement} Image or Canvas element. 16099 * @api 16100 */ 16101 getImage(t) { 16102 let i = this.canvas_[t]; 16103 if (!i) { 16104 const s = this.renderOptions_, n = re( 16105 s.size * t, 16106 s.size * t 16107 ); 16108 this.draw_(s, n, t), i = n.canvas, this.canvas_[t] = i; 16109 } 16110 return i; 16111 } 16112 /** 16113 * Get the image pixel ratio. 16114 * @param {number} pixelRatio Pixel ratio. 16115 * @return {number} Pixel ratio. 16116 */ 16117 getPixelRatio(t) { 16118 return t; 16119 } 16120 /** 16121 * @return {import("../size.js").Size} Image size. 16122 */ 16123 getImageSize() { 16124 return this.size_; 16125 } 16126 /** 16127 * @return {import("../ImageState.js").default} Image state. 16128 */ 16129 getImageState() { 16130 return rt.LOADED; 16131 } 16132 /** 16133 * Get the origin of the symbolizer. 16134 * @return {Array<number>} Origin. 16135 * @api 16136 */ 16137 getOrigin() { 16138 return this.origin_; 16139 } 16140 /** 16141 * Get the number of points for generating the shape. 16142 * @return {number} Number of points for stars and regular polygons. 16143 * @api 16144 */ 16145 getPoints() { 16146 return this.points_; 16147 } 16148 /** 16149 * Get the (primary) radius for the shape. 16150 * @return {number} Radius. 16151 * @api 16152 */ 16153 getRadius() { 16154 return this.radius_; 16155 } 16156 /** 16157 * Get the secondary radius for the shape. 16158 * @return {number|undefined} Radius2. 16159 * @api 16160 */ 16161 getRadius2() { 16162 return this.radius2_; 16163 } 16164 /** 16165 * Get the size of the symbolizer (in pixels). 16166 * @return {import("../size.js").Size} Size. 16167 * @api 16168 */ 16169 getSize() { 16170 return this.size_; 16171 } 16172 /** 16173 * Get the stroke style for the shape. 16174 * @return {import("./Stroke.js").default} Stroke style. 16175 * @api 16176 */ 16177 getStroke() { 16178 return this.stroke_; 16179 } 16180 /** 16181 * Set the stroke style. 16182 * @param {import("./Stroke.js").default} stroke Stroke style. 16183 * @api 16184 */ 16185 setStroke(t) { 16186 this.stroke_ = t, this.render(); 16187 } 16188 /** 16189 * @param {function(import("../events/Event.js").default): void} listener Listener function. 16190 */ 16191 listenImageChange(t) { 16192 } 16193 /** 16194 * Load not yet loaded URI. 16195 */ 16196 load() { 16197 } 16198 /** 16199 * @param {function(import("../events/Event.js").default): void} listener Listener function. 16200 */ 16201 unlistenImageChange(t) { 16202 } 16203 /** 16204 * Calculate additional canvas size needed for the miter. 16205 * @param {string}
16205 lineJoin Line join 16206 * @param {number} strokeWidth Stroke width 16207 * @param {number} miterLimit Miter limit 16208 * @return {number} Additional canvas size needed 16209 * @private 16210 */ 16211 calculateLineJoinSize_(t, i, s) { 16212 if (i === 0 || this.points_ === 1 / 0 || t !== "bevel" && t !== "miter") 16213 return i; 16214 let n = this.radius_, r = this.radius2_ === void 0 ? n : this.radius2_; 16215 if (n < r) { 16216 const S = n; 16217 n = r, r = S; 16218 } 16219 const o = this.radius2_ === void 0 ? this.points_ : this.points_ * 2, a = 2 * Math.PI / o, l = r * Math.sin(a), h = Math.sqrt(r * r - l * l), c = n - h, u = Math.sqrt(l * l + c * c), d = u / l; 16220 if (t === "miter" && d <= s) 16221 return d * i; 16222 const f = i / 2 / d, g = i / 2 * (c / u), m = Math.sqrt((n + f) * (n + f) + g * g) - n; 16223 if (this.radius2_ === void 0 || t === "bevel") 16224 return m * 2; 16225 const p = n * Math.sin(a), y = Math.sqrt(n * n - p * p), v = r - y, C = Math.sqrt(p * p + v * v) / p; 16226 if (C <= s) { 16227 const S = C * i / 2 - r - n; 16228 return 2 * Math.max(m, S); 16229 } 16230 return m * 2; 16231 } 16232 /** 16233 * @return {RenderOptions} The render options 16234 * @protected 16235 */ 16236 createRenderOptions() { 16237 let t = Mn, i = 0, s = null, n = 0, r, o = 0; 16238 this.stroke_ && (r = this.stroke_.getColor(), r === null && (r = dr), r = Ze(r), o = this.stroke_.getWidth(), o === void 0 && (o = gr), s = this.stroke_.getLineDash(), n = this.stroke_.getLineDashOffset(), t = this.stroke_.getLineJoin(), t === void 0 && (t = Mn), i = this.stroke_.getMiterLimit(), i === void 0 && (i = ur)); 16239 const a = this.calculateLineJoinSize_(t, o, i), l = Math.max(this.radius_, this.radius2_ || 0), h = Math.ceil(2 * l + a); 16240 return { 16241 strokeStyle: r, 16242 strokeWidth: o, 16243 size: h, 16244 lineDash: s, 16245 lineDashOffset: n, 16246 lineJoin: t, 16247 miterLimit: i 16248 }; 16249 } 16250 /** 16251 * @protected 16252 */ 16253 render() { 16254 this.renderOptions_ = this.createRenderOptions(); 16255 const t = this.renderOptions_.size; 16256 this.canvas_ = {}, this.size_ = [t, t]; 16257 } 16258 /** 16259 * @private 16260 * @param {RenderOptions} renderOptions Render options. 16261 * @param {CanvasRenderingContext2D} context The rendering context. 16262 * @param {number} pixelRatio The pixel ratio. 16263 */ 16264 draw_(t, i, s) { 16265 if (i.scale(s, s), i.translate(t.size / 2, t.size / 2), this.createPath_(i), this.fill_) { 16266 let n = this.fill_.getColor(); 16267 n === null && (n = yi), i.fillStyle = Ze(n), i.fill(); 16268 } 16269 this.stroke_ && (i.strokeStyle = t.strokeStyle, i.lineWidth = t.strokeWidth, t.lineDash && (i.setLineDash(t.lineDash), i.lineDashOffset = t.lineDashOffset), i.lineJoin = t.lineJoin, i.miterLimit = t.miterLimit, i.stroke()); 16270 } 16271 /** 16272 * @private 16273 * @param {RenderOptions} renderOptions Render options. 16274 */ 16275 createHitDetectionCanvas_(t) { 16276 if (this.fill_) { 16277 let i = this.fill_.getColor(), s = 0; 16278 if (typeof i == "string" && (i = Ao(i)), i === null ? s = 1 : Array.isArray(i) && (s = i.length === 4 ? i[3] : 1), s === 0) { 16279 const n = re( 16280 t.size, 16281 t.size 16282 ); 16283 this.hitDetectionCanvas_ = n.canvas, this.drawHitDetectionCanvas_(t, n); 16284 } 16285 } 16286 this.hitDetectionCanvas_ || (this.hitDetectionCanvas_ = this.getImage(1)); 16287 } 16288 /** 16289 * @private 16290 * @param {CanvasRenderingContext2D} context The context to draw in. 16291 */ 16292 createPath_(t) { 16293 let i = this.points_; 16294 const s = this.radius_; 16295 if (i === 1 / 0) 16296 t.arc(0, 0, s, 0, 2 * Math.PI); 16297 else { 16298 const n = this.radius2_ === void 0 ? s : this.radius2_; 16299 this.radius2_ !== void 0 && (i *= 2); 16300 const r = this.angle_ - Math.PI / 2, o = 2 * Math.PI / i; 16301 for (let a = 0; a < i; a++) { 16302 const l = r + a * o, h = a % 2 === 0 ? s : n; 16303 t.lineTo(h * Math.cos(l), h * Math.sin(l)); 16304 } 16305 t.closePath(); 16306 } 16307 } 16308 /** 16309 * @private 16310 * @param {RenderOptions} renderOptions Render options. 16311 * @param {CanvasRenderingContext2D} context The context. 16312 */ 16313 drawHitDetectionCanvas_(t, i) { 16314 i.translate(t.size / 2, t.size / 2), this.createPath_(i), i.fillStyle = yi, i.fill(), this.stroke_ && (i.strokeStyle = t.strokeStyle, i.lineWidth = t.strokeWidth, t.lineDash && (i.setLineDash(t.lineDash), i.lineDashOffset = t.lineDashOffset), i.lineJoin = t.lineJoin, i.miterLimit = t.miter
16314Limit, i.stroke()); 16315 } 16316} 16317const pg = $h; 16318class Yh extends pg { 16319 /** 16320 * @param {Options} [options] Options. 16321 */ 16322 constructor(t) { 16323 t = t || { radius: 5 }, super({ 16324 points: 1 / 0, 16325 fill: t.fill, 16326 radius: t.radius, 16327 stroke: t.stroke, 16328 scale: t.scale !== void 0 ? t.scale : 1, 16329 rotation: t.rotation !== void 0 ? t.rotation : 0, 16330 rotateWithView: t.rotateWithView !== void 0 ? t.rotateWithView : !1, 16331 displacement: t.displacement !== void 0 ? t.displacement : [0, 0], 16332 declutterMode: t.declutterMode 16333 }); 16334 } 16335 /** 16336 * Clones the style. 16337 * @return {CircleStyle} The cloned style. 16338 * @api 16339 */ 16340 clone() { 16341 const t = this.getScale(), i = new Yh({ 16342 fill: this.getFill() ? this.getFill().clone() : void 0, 16343 stroke: this.getStroke() ? this.getStroke().clone() : void 0, 16344 radius: this.getRadius(), 16345 scale: Array.isArray(t) ? t.slice() : t, 16346 rotation: this.getRotation(), 16347 rotateWithView: this.getRotateWithView(), 16348 displacement: this.getDisplacement().slice(), 16349 declutterMode: this.getDeclutterMode() 16350 }); 16351 return i.setOpacity(this.getOpacity()), i; 16352 } 16353 /** 16354 * Set the circle radius. 16355 * 16356 * @param {number} radius Circle radius. 16357 * @api 16358 */ 16359 setRadius(t) { 16360 this.radius_ = t, this.render(); 16361 } 16362} 16363const Lr = Yh; 16364class Wi { 16365 /** 16366 * @param {Options} [options] Style options. 16367 */ 16368 constructor(t) { 16369 t = t || {}, this.geometry_ = null, this.geometryFunction_ = Iu, t.geometry !== void 0 && this.setGeometry(t.geometry), this.fill_ = t.fill !== void 0 ? t.fill : null, this.image_ = t.image !== void 0 ? t.image : null, this.renderer_ = t.renderer !== void 0 ? t.renderer : null, this.hitDetectionRenderer_ = t.hitDetectionRenderer !== void 0 ? t.hitDetectionRenderer : null, this.stroke_ = t.stroke !== void 0 ? t.stroke : null, this.text_ = t.text !== void 0 ? t.text : null, this.zIndex_ = t.zIndex; 16370 } 16371 /** 16372 * Clones the style. 16373 * @return {Style} The cloned style. 16374 * @api 16375 */ 16376 clone() { 16377 let t = this.getGeometry(); 16378 return t && typeof t == "object" && (t = /** @type {import("../geom/Geometry.js").default} */ 16379 t.clone()), new Wi({ 16380 geometry: t, 16381 fill: this.getFill() ? this.getFill().clone() : void 0, 16382 image: this.getImage() ? this.getImage().clone() : void 0, 16383 renderer: this.getRenderer(), 16384 stroke: this.getStroke() ? this.getStroke().clone() : void 0, 16385 text: this.getText() ? this.getText().clone() : void 0, 16386 zIndex: this.getZIndex() 16387 }); 16388 } 16389 /** 16390 * Get the custom renderer function that was configured with 16391 * {@link #setRenderer} or the `renderer` constructor option. 16392 * @return {RenderFunction|null} Custom renderer function. 16393 * @api 16394 */ 16395 getRenderer() { 16396 return this.renderer_; 16397 } 16398 /** 16399 * Sets a custom renderer function for this style. When set, `fill`, `stroke` 16400 * and `image` options of the style will be ignored. 16401 * @param {RenderFunction|null} renderer Custom renderer function. 16402 * @api 16403 */ 16404 setRenderer(t) { 16405 this.renderer_ = t; 16406 } 16407 /** 16408 * Sets a custom renderer function for this style used 16409 * in hit detection. 16410 * @param {RenderFunction|null} renderer Custom renderer function. 16411 * @api 16412 */ 16413 setHitDetectionRenderer(t) { 16414 this.hitDetectionRenderer_ = t; 16415 } 16416 /** 16417 * Get the custom renderer function that was configured with 16418 * {@link #setHitDetectionRenderer} or the `hitDetectionRenderer` constructor option. 16419 * @return {RenderFunction|null} Custom renderer function. 16420 * @api 16421 */ 16422 getHitDetectionRenderer() { 16423 return this.hitDetectionRenderer_; 16424 } 16425 /** 16426 * Get the geometry to be rendered. 16427 * @return {string|import("../geom/Geometry.js").default|GeometryFunction} 16428 * Feature property or geometry or function that returns the geometry that will 16429 * be rendered with this style. 16430 * @api 16431 */ 16432 getGeometry() { 16433 return this.geometry_; 16434 } 16435 /** 16436 * Get the function used to generate a geometry for rendering. 16437 * @return {!GeometryFunction} Function that is called with a feature 16438 * and returns the geometry to render instead of the feature's geometry. 16439 * @api 16440 */ 16441 getGeometryFunction() { 16442 return this.geometryFunction_; 16443 } 16444 /** 16445 * Get the fill style. 16446 * @return {import("./Fill.js").default} Fill style. 16447 * @api 16448 */ 16449 getFill() { 16450 return this.fill_; 16451 } 16452 /** 16453 * Set the fill style. 16454 * @param {import("./Fill.js").default} fill Fill style. 16455 * @api 16456 */ 16457 setFill(t) { 16458 this.fill_ = t; 16459 } 16460 /** 16461 * Get the image style. 16462 * @return {import("./Image.js").default} Image style. 16463 * @api 16464 */ 16465 getImage() { 16466 return this.image_; 16467 } 16468 /** 16469 * Set the image style. 16470 * @param {import("./Image.js").default} image Image style. 16471 * @api 16472 */ 16473 setImage(t) { 16474 this.image_ = t; 16475 } 16476 /** 16477 * Get the stroke style. 16478 * @return {import("./Stroke.js").default} Stroke style. 16479 * @api 16480 */ 16481 getStroke() { 16482 return this.stroke_; 16483 } 16484 /** 16485 * Set the stroke style. 16486 * @param {import("./Stroke.js").default} stroke Stroke style. 16487 * @api 16488 */ 16489 setStroke(t) { 16490 this.stroke_ = t; 16491 } 16492 /** 16493 * Get the text style. 16494 * @return {import("./Text.js").default} Text style. 16495 * @api 16496 */ 16497 getText() { 16498 return this.text_; 16499 } 16500 /** 16501 * Set the text style. 16502 * @param {import("./Text.js").default} text Text style. 16503 * @api 16504 */ 16505 setText(t) { 16506 this.text_ = t; 16507 } 16508 /** 16509 * Get the z-index for the style. 16510 * @return {number|undefined} ZIndex. 16511 * @api 16512 */ 16513 getZIndex() { 16514 return this.zIndex_; 16515 } 16516 /** 16517 * Set a geometry that is rendered instead of the feature's geometry. 16518 * 16519 * @param {string|import("../geom/Geometry.js").default|GeometryFunction} geometry 16520 * Feature property or geometry or function returning a geometry to render 16521 * for this style. 16522 * @api 16523 */ 16524 setGeometry(t) { 16525 typeof t == "function" ? this.geometryFunction_ = t : typeof t == "string" ? this.geometryFunction_ = function(i) { 16526 return ( 16527 /** @type {import("../geom/Geometry.js").default} */ 16528 i.get(t) 16529 ); 16530 } : t ? t !== void 0 && (this.geometryFunction_ = function() { 16531 return ( 16532 /** @type {import("../geom/Geometry.js").default} */ 16533 t 16534 ); 16535 }) : this.geometryFunction_ = Iu, this.geometry_ = t; 16536 } 16537 /** 16538 * Set the z-index. 16539 * 16540 * @param {number|undefined} zIndex ZIndex. 16541 * @api 16542 */ 16543 setZIndex(t) { 16544 this.zIndex_ = t; 16545 } 16546} 16547function cC(e) { 16548 let t; 16549 if (typeof e == "function") 16550 t = e; 16551 else { 16552 let i; 16553 Array.isArray(e) ? i = e : (at(typeof /** @type {?} */ 16554 e.getZIndex == "function", 41), i = [ 16555 /** @type {Style} */ 16556 e 16557 ]), t = function() { 16558 return i; 16559 }; 16560 } 16561 return t; 16562} 16563let za = null; 16564function uC(e, t) { 16565 if (!za) { 16566 const i = new Ei({ 16567 color: "rgba(255,255,255,0.4)" 16568 }), s = new xi({ 16569 color: "#3399CC", 16570 width: 1.25 16571 }); 16572 za = [ 16573 new Wi({ 16574 image: new Lr({ 16575 fill: i, 16576 stroke: s, 16577 radius: 5 16578 }), 16579 fill: i, 16580 stroke: s 16581 }) 16582 ]; 16583 } 16584 return za; 16585} 16586function yg() { 16587 const e = {}, t = [255, 255, 255, 1], i = [0, 153, 255, 1], s = 3; 16588 return e.Polygon = [ 16589 new Wi({ 16590 fill: new Ei({
16591 color: [255, 255, 255, 0.5] 16592 }) 16593 }) 16594 ], e.MultiPolygon = e.Polygon, e.LineString = [ 16595 new Wi({ 16596 stroke: new xi({ 16597 color: t, 16598 width: s + 2 16599 }) 16600 }), 16601 new Wi({ 16602 stroke: new xi({ 16603 color: i, 16604 width: s 16605 }) 16606 }) 16607 ], e.MultiLineString = e.LineString, e.Circle = e.Polygon.concat(e.LineString), e.Point = [ 16608 new Wi({ 16609 image: new Lr({ 16610 radius: s * 2, 16611 fill: new Ei({ 16612 color: i 16613 }), 16614 stroke: new xi({ 16615 color: t, 16616 width: s / 2 16617 }) 16618 }), 16619 zIndex: 1 / 0 16620 }) 16621 ], e.MultiPoint = e.Point, e.GeometryCollection = e.Polygon.concat( 16622 e.LineString, 16623 e.Point 16624 ), e; 16625} 16626function Iu(e) { 16627 return e.getGeometry(); 16628} 16629const _r = Wi, dC = "#333"; 16630class Kh { 16631 /** 16632 * @param {Options} [options] Options. 16633 */ 16634 constructor(t) { 16635 t = t || {}, this.font_ = t.font, this.rotation_ = t.rotation, this.rotateWithView_ = t.rotateWithView, this.scale_ = t.scale, this.scaleArray_ = ye(t.scale !== void 0 ? t.scale : 1), this.text_ = t.text, this.textAlign_ = t.textAlign, this.justify_ = t.justify, this.repeat_ = t.repeat, this.textBaseline_ = t.textBaseline, this.fill_ = t.fill !== void 0 ? t.fill : new Ei({ color: dC }), this.maxAngle_ = t.maxAngle !== void 0 ? t.maxAngle : Math.PI / 4, this.placement_ = t.placement !== void 0 ? t.placement : "point", this.overflow_ = !!t.overflow, this.stroke_ = t.stroke !== void 0 ? t.stroke : null, this.offsetX_ = t.offsetX !== void 0 ? t.offsetX : 0, this.offsetY_ = t.offsetY !== void 0 ? t.offsetY : 0, this.backgroundFill_ = t.backgroundFill ? t.backgroundFill : null, this.backgroundStroke_ = t.backgroundStroke ? t.backgroundStroke : null, this.padding_ = t.padding === void 0 ? null : t.padding; 16636 } 16637 /** 16638 * Clones the style. 16639 * @return {Text} The cloned style. 16640 * @api 16641 */ 16642 clone() { 16643 const t = this.getScale(); 16644 return new Kh({ 16645 font: this.getFont(), 16646 placement: this.getPlacement(), 16647 repeat: this.getRepeat(), 16648 maxAngle: this.getMaxAngle(), 16649 overflow: this.getOverflow(), 16650 rotation: this.getRotation(), 16651 rotateWithView: this.getRotateWithView(), 16652 scale: Array.isArray(t) ? t.slice() : t, 16653 text: this.getText(), 16654 textAlign: this.getTextAlign(), 16655 justify: this.getJustify(), 16656 textBaseline: this.getTextBaseline(), 16657 fill: this.getFill() ? this.getFill().clone() : void 0, 16658 stroke: this.getStroke() ? this.getStroke().clone() : void 0, 16659 offsetX: this.getOffsetX(), 16660 offsetY: this.getOffsetY(), 16661 backgroundFill: this.getBackgroundFill() ? this.getBackgroundFill().clone() : void 0, 16662 backgroundStroke: this.getBackgroundStroke() ? this.getBackgroundStroke().clone() : void 0, 16663 padding: this.getPadding() || void 0 16664 }); 16665 } 16666 /** 16667 * Get the `overflow` configuration. 16668 * @return {boolean} Let text overflow the length of the path they follow. 16669 * @api 16670 */ 16671 getOverflow() { 16672 return this.overflow_; 16673 } 16674 /** 16675 * Get the font name. 16676 * @return {string|undefined} Font. 16677 * @api 16678 */ 16679 getFont() { 16680 return this.font_; 16681 } 16682 /** 16683 * Get the maximum angle between adjacent characters. 16684 * @return {number} Angle in radians. 16685 * @api 16686 */ 16687 getMaxAngle() { 16688 return this.maxAngle_; 16689 } 16690 /** 16691 * Get the label placement. 16692 * @return {TextPlacement} Text placement. 16693 * @api 16694 */ 16695 getPlacement() { 16696 return this.placement_; 16697 } 16698 /** 16699 * Get the repeat interval of the text. 16700 * @return {number|undefined} Repeat interval in pixels. 16701 * @api 16702 */ 16703 getRepeat() { 16704 return this.repeat_; 16705 } 16706 /** 16707 * Get the x-offset for the text. 16708 * @return {number} Horizontal text offset. 16709 * @api 16710 */ 16711 getOffsetX() { 16712 return this.offsetX_; 16713 } 16714 /** 16715 * Get the y-offset for the text. 16716 * @return {number} Vertical text offset. 16717 * @api 16718 */ 16719 getOffsetY() { 16720 return this.offsetY_; 16721 } 16722 /** 16723 * Get the fill style for the text. 16724 * @return {import("./Fill.js").default} Fill style. 16725 * @api 16726 */ 16727 getFill() { 16728 return this.fill_; 16729 } 16730 /** 16731 * Determine whether the text rotates with the map. 16732 * @return {boolean|undefined} Rotate with map. 16733 * @api 16734 */ 16735 getRotateWithView() { 16736 return this.rotateWithView_; 16737 } 16738 /** 16739 * Get the text rotation. 16740 * @return {number|undefined} Rotation. 16741 * @api 16742 */ 16743 getRotation() { 16744 return this.rotation_; 16745 } 16746 /** 16747 * Get the text scale. 16748 * @return {number|import("../size.js").Size|undefined} Scale. 16749 * @api 16750 */ 16751 getScale() { 16752 return this.scale_; 16753 } 16754 /** 16755 * Get the symbolizer scale array. 16756 * @return {import("../size.js").Size} Scale array. 16757 */ 16758 getScaleArray() { 16759 return this.scaleArray_; 16760 } 16761 /** 16762 * Get the stroke style for the text. 16763 * @return {import("./Stroke.js").default} Stroke style. 16764 * @api 16765 */ 16766 getStroke() { 16767 return this.stroke_; 16768 } 16769 /** 16770 * Get the text to be rendered. 16771 * @return {string|Array<string>|undefined} Text. 16772 * @api 16773 */ 16774 getText() { 16775 return this.text_; 16776 } 16777 /** 16778 * Get the text alignment. 16779 * @return {CanvasTextAlign|undefined} Text align. 16780 * @api 16781 */ 16782 getTextAlign() { 16783 return this.textAlign_; 16784 } 16785 /** 16786 * Get the justification. 16787 * @return {TextJustify|undefined} Justification. 16788 * @api 16789 */ 16790 getJustify() { 16791 return this.justify_; 16792 } 16793 /** 16794 * Get the text baseline. 16795 * @return {CanvasTextBaseline|undefined} Text baseline. 16796 * @api 16797 */ 16798 getTextBaseline() { 16799 return this.textBaseline_; 16800 } 16801 /** 16802 * Get the background fill style for the text. 16803 * @return {import("./Fill.js").default} Fill style. 16804 * @api 16805 */
16806 getBackgroundFill() { 16807 return this.backgroundFill_; 16808 } 16809 /** 16810 * Get the background stroke style for the text. 16811 * @return {import("./Stroke.js").default} Stroke style. 16812 * @api 16813 */ 16814 getBackgroundStroke() { 16815 return this.backgroundStroke_; 16816 } 16817 /** 16818 * Get the padding for the text. 16819 * @return {Array<number>|null} Padding. 16820 * @api 16821 */ 16822 getPadding() { 16823 return this.padding_; 16824 } 16825 /** 16826 * Set the `overflow` property. 16827 * 16828 * @param {boolean} overflow Let text overflow the path that it follows. 16829 * @api 16830 */ 16831 setOverflow(t) { 16832 this.overflow_ = t; 16833 } 16834 /** 16835 * Set the font. 16836 * 16837 * @param {string|undefined} font Font. 16838 * @api 16839 */ 16840 setFont(t) { 16841 this.font_ = t; 16842 } 16843 /** 16844 * Set the maximum angle between adjacent characters. 16845 * 16846 * @param {number} maxAngle Angle in radians. 16847 * @api 16848 */ 16849 setMaxAngle(t) { 16850 this.maxAngle_ = t; 16851 } 16852 /** 16853 * Set the x offset. 16854 * 16855 * @param {number} offsetX Horizontal text offset. 16856 * @api 16857 */ 16858 setOffsetX(t) { 16859 this.offsetX_ = t; 16860 } 16861 /** 16862 * Set the y offset. 16863 * 16864 * @param {number} offsetY Vertical text offset. 16865 * @api 16866 */ 16867 setOffsetY(t) { 16868 this.offsetY_ = t; 16869 } 16870 /** 16871 * Set the text placement. 16872 * 16873 * @param {TextPlacement} placement Placement. 16874 * @api 16875 */ 16876 setPlacement(t) { 16877 this.placement_ = t; 16878 } 16879 /** 16880 * Set the repeat interval of the text. 16881 * @param {number|undefined} [repeat] Repeat interval in pixels. 16882 * @api 16883 */ 16884 setRepeat(t) { 16885 this.repeat_ = t; 16886 } 16887 /** 16888 * Set whether to rotate the text with the view. 16889 * 16890 * @param {boolean} rotateWithView Rotate with map. 16891 * @api 16892 */ 16893 setRotateWithView(t) { 16894 this.rotateWithView_ = t; 16895 } 16896 /** 16897 * Set the fill. 16898 * 16899 * @param {import("./Fill.js").default} fill Fill style. 16900 * @api 16901 */ 16902 setFill(t) { 16903 this.fill_ = t; 16904 } 16905 /** 16906 * Set the rotation. 16907 * 16908 * @param {number|undefined} rotation Rotation. 16909 * @api 16910 */ 16911 setRotation(t) { 16912 this.rotation_ = t; 16913 } 16914 /** 16915 * Set the scale. 16916 * 16917 * @param {number|import("../size.js").Size|undefined} scale Scale. 16918 * @api 16919 */ 16920 setScale(t) { 16921 this.scale_ = t, this.scaleArray_ = ye(t !== void 0 ? t : 1); 16922 } 16923 /** 16924 * Set the stroke. 16925 * 16926 * @param {import("./Stroke.js").default} stroke Stroke style. 16927 * @api 16928 */ 16929 setStroke(t) { 16930 this.stroke_ = t; 16931 } 16932 /** 16933 * Set the text. 16934 * 16935 * @param {string|Array<string>|undefined} text Text. 16936 * @api 16937 */ 16938 setText(t) { 16939 this.text_ = t; 16940 } 16941 /** 16942 * Set the text alignment. 16943 * 16944 * @param {CanvasTextAlign|undefined} textAlign Text align. 16945 * @api 16946 */ 16947 setTextAlign(t) { 16948 this.textAlign_ = t; 16949 } 16950 /** 16951 * Set the justification. 16952 * 16953 * @param {TextJustify|undefined} justify Justification. 16954 * @api 16955 */ 16956 setJustify(t) { 16957 this.justify_ = t; 16958 } 16959 /** 16960 * Set the text baseline. 16961 * 16962 * @param {CanvasTextBaseline|undefined} textBaseline Text baseline. 16963 * @api 16964 */ 16965 setTextBaseline(t) { 16966 this.textBaseline_ = t; 16967 } 16968 /** 16969 * Set the background fill. 16970 * 16971 * @param {import("./Fill.js").default} fill Fill style. 16972 * @api 16973 */ 16974 setBackgroundFill(t) { 16975 this.backgroundFill_ = t; 16976 } 16977 /** 16978 * Set the background stroke. 16979 * 16980 * @param {import("./Stroke.js").default} stroke Stroke style. 16981 * @api 16982 */ 16983 setBackgroundStroke(t) { 16984 this.backgroundStroke_ = t; 16985 } 16986 /** 16987 * Set the padding (`[top, right, bottom, left]`). 16988 * 16989 * @param {Array<number>|null} padding Padding. 16990 * @api 16991 */ 16992 setPadding(t) { 16993 this.padding_ = t; 16994 } 16995} 16996const fC = Kh; 16997function gC(e, t, i, s, n) { 16998 xg(e, t, i || 0, s || e.length - 1, n || _C); 16999} 17000function xg(e, t, i, s, n) { 17001 for (; s > i; ) { 17002 if (s - i > 600) { 17003 var r = s - i + 1, o = t - i + 1, a = Math.log(r), l = 0.5 * Math.exp(2 * a / 3), h = 0.5 * Math.sqrt(a * l * (r - l) / r) * (o - r / 2 < 0 ? -1 : 1), c = Math.max(i, Math.floor(t - o * l / r + h)), u = Math.min(s, Math.floor(t + (r - o) * l / r + h)); 17004 xg(e, t, c, u, n); 17005 } 17006 var d = e[t], f = i, g = s; 17007 for (Dn(e, i, t), n(e[s], d) > 0 && Dn(e, i, s); f < g; ) { 17008 for (Dn(e, f, g), f++, g--; n(e[f], d) < 0; ) 17009 f++; 17010 for (; n(e[g], d) > 0; ) 17011 g--; 17012 } 17013 n(e[i], d) === 0 ? Dn(e, i, g) : (g++, Dn(e, g, s)), g <= t && (i = g + 1), t
17013<= g && (s = g - 1); 17014 } 17015} 17016function Dn(e, t, i) { 17017 var s = e[t]; 17018 e[t] = e[i], e[i] = s; 17019} 17020function _C(e, t) { 17021 return e < t ? -1 : e > t ? 1 : 0; 17022} 17023let vg = class { 17024 constructor(t = 9) { 17025 this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear(); 17026 } 17027 all() { 17028 return this._all(this.data, []); 17029 } 17030 search(t) { 17031 let i = this.data; 17032 const s = []; 17033 if (!Jr(t, i)) 17034 return s; 17035 const n = this.toBBox, r = []; 17036 for (; i; ) { 17037 for (let o = 0; o < i.children.length; o++) { 17038 const a = i.children[o], l = i.leaf ? n(a) : a; 17039 Jr(t, l) && (i.leaf ? s.push(a) : Wa(t, l) ? this._all(a, s) : r.push(a)); 17040 } 17041 i = r.pop(); 17042 } 17043 return s; 17044 } 17045 collides(t) { 17046 let i = this.data; 17047 if (!Jr(t, i)) 17048 return !1; 17049 const s = []; 17050 for (; i; ) { 17051 for (let n = 0; n < i.children.length; n++) { 17052 const r = i.children[n], o = i.leaf ? this.toBBox(r) : r; 17053 if (Jr(t, o)) { 17054 if (i.leaf || Wa(t, o)) 17055 return !0; 17056 s.push(r); 17057 } 17058 } 17059 i = s.pop(); 17060 } 17061 return !1; 17062 } 17063 load(t) { 17064 if (!(t && t.length)) 17065 return this; 17066 if (t.length < this._minEntries) { 17067 for (let s = 0; s < t.length; s++) 17068 this.insert(t[s]); 17069 return this; 17070 } 17071 let i = this._build(t.slice(), 0, t.length - 1, 0); 17072 if (!this.data.children.length) 17073 this.data = i; 17074 else if (this.data.height === i.height) 17075 this._splitRoot(this.data, i); 17076 else { 17077 if (this.data.height < i.height) { 17078 const s = this.data; 17079 this.data = i, i = s; 17080 } 17081 this._insert(i, this.data.height - i.height - 1, !0); 17082 } 17083 return this; 17084 } 17085 insert(t) { 17086 return t && this._insert(t, this.data.height - 1), this; 17087 } 17088 clear() { 17089 return this.data = Ws([]), this; 17090 } 17091 remove(t, i) { 17092 if (!t) 17093 return this; 17094 let s = this.data; 17095 const n = this.toBBox(t), r = [], o = []; 17096 let a, l, h; 17097 for (; s || r.length; ) { 17098 if (s || (s = r.pop(), l = r[r.length - 1], a = o.pop(), h = !0), s.leaf) { 17099 const c = mC(t, s.children, i); 17100 if (c !== -1) 17101 return s.children.splice(c, 1), r.push(s), this._condense(r), this; 17102 } 17103 !h && !s.leaf && Wa(s, n) ? (r.push(s), o.push(a), a = 0, l = s, s = s.children[0]) : l ? (a++, s = l.children[a], h = !1) : s = null; 17104 } 17105 return this; 17106 } 17107 toBBox(t) { 17108 return t; 17109 } 17110 compareMinX(t, i) { 17111 return t.minX - i.minX; 17112 } 17113 compareMinY(t, i) { 17114 return t.minY - i.minY; 17115 } 17116 toJSON() { 17117 return this.data; 17118 } 17119 fromJSON(t) { 17120 return this.data = t, this; 17121 } 17122 _all(t, i) { 17123 const s = []; 17124 for (; t; ) 17125 t.leaf ? i.push(...t.children) : s.push(...t.children), t = s.pop(); 17126 return i; 17127 } 17128 _build(t, i, s, n) { 17129 const r = s - i + 1; 17130 let o = this._maxEntries, a; 17131 if (r <= o) 17132 return a = Ws(t.slice(i, s + 1)), Fs(a, this.toBBox), a; 17133 n || (n = Math.ceil(Math.log(r) / Math.log(o)), o = Math.ceil(r / Math.pow(o, n - 1))), a = Ws([]), a.leaf = !1, a.height = n; 17134 const l = Math.ceil(r / o), h = l * Math.ceil(Math.sqrt(o)); 17135 Pu(t, i, s, h, this.compareMinX); 17136 for (let c = i; c <= s; c += h) { 17137 const u = Math.min(c + h - 1, s); 17138 Pu(t, c, u, l, this.compareMinY); 17139 for (let d = c; d <= u; d += l) { 17140 const f = Math.min(d + l - 1, u); 17141 a.children.push(this._build(t, d, f, n - 1)); 17142 } 17143 } 17144 return Fs(a, this.toBBox), a; 17145 } 17146 _chooseSubtree(t, i, s, n) { 17147 for (; n.push(i), !(i.leaf || n.length - 1 === s); ) { 17148 let r = 1 / 0, o = 1 / 0, a; 17149 for (let l = 0; l < i.children.length; l++) { 17150 const h = i.children[l], c = ja(h), u = xC(t, h) - c; 17151 u < o ? (o = u, r = c < r ? c : r, a = h) : u === o && c < r && (r = c, a = h); 17152 } 17153 i = a || i.children[0]; 17154 } 17155 return i; 17156 } 17157 _insert(t, i, s) { 17158 const n = s ? t : this.toBBox(t), r = [], o = this._chooseSubtree(n, this.data, i, r); 17159 for (o.children.push(t), Xn(o, n); i >= 0 && r[i].children.length > this._maxEntries; ) 17160 this._split(r, i), i--; 17161 this._adjustParentBBoxes(n, r, i); 17162 } 17163 // split overflowed node into two 17164 _split(t, i) { 17165 const s = t[i], n = s.children.length, r = this._minEntries; 17166 this._chooseSplitAxis(s, r, n); 17167 const o = this._chooseSplitIndex(s, r, n), a = Ws(s.children.splice(o, s.children.length - o)); 17168 a.height = s.height, a.leaf = s.leaf, Fs(s, this.toBBox), Fs(a, this.toBBox), i ? t[i - 1].children.push(a) : this._splitRoot(s, a); 17169 } 17170 _splitRoot(t, i) { 17171 this.data = Ws([t, i]), this.data.height = t.height + 1, this.data.leaf = !1, Fs(this.data, this.toBBox); 17172 } 17173 _chooseSplitIndex(t, i, s) { 17174 let n, r = 1 / 0, o = 1 / 0; 17175 for (let a = i; a <= s - i; a++) { 17176 const l = Un(t, 0, a, this.toBBox), h = Un(t, a, s, this.toBBox), c = vC(l, h), u = ja(l) + ja(h); 17177 c < r ? (r = c, n = a, o = u < o ? u : o) : c === r && u < o && (o = u, n = a); 17178 } 17179 return n || s - i; 17180 } 17181 // sorts node children by the best axis for split 17182 _chooseSplitAxis(t, i, s) { 17183 const n = t.leaf ? this.compareMinX : pC, r = t.leaf ? this.compareMinY : yC, o = this._allDistMargin(t, i, s, n), a = this._allDistMargin(t, i, s, r); 17184 o < a && t.children.sort(n); 17185 } 17186 // total margin of all possible split distributions where each node is at least m full 17187 _allDistMargin(t, i, s, n) { 17188 t.children.sort(n); 17189 const r = this.toBBox, o = Un(t, 0, i, r), a = Un(t, s - i, s, r); 17190 let l = Zr(o) + Zr(a); 17191 for (let h = i; h < s - i; h++) { 17192 const c = t.children[h]; 17193 Xn(o, t.leaf ? r(c) : c), l += Zr(o); 17194 } 17195 for (let h = s - i - 1; h >= i; h--) { 17196 const c = t.children[h]; 17197 Xn(a, t.leaf ? r(c) : c), l += Zr(a); 17198 } 17199 return l; 17200 }
17201 _adjustParentBBoxes(t, i, s) { 17202 for (let n = s; n >= 0; n--) 17203 Xn(i[n], t); 17204 } 17205 _condense(t) { 17206 for (let i = t.length - 1, s; i >= 0; i--) 17207 t[i].children.length === 0 ? i > 0 ? (s = t[i - 1].children, s.splice(s.indexOf(t[i]), 1)) : this.clear() : Fs(t[i], this.toBBox); 17208 } 17209}; 17210function mC(e, t, i) { 17211 if (!i) 17212 return t.indexOf(e); 17213 for (let s = 0; s < t.length; s++) 17214 if (i(e, t[s])) 17215 return s; 17216 return -1; 17217} 17218function Fs(e, t) { 17219 Un(e, 0, e.children.length, t, e); 17220} 17221function Un(e, t, i, s, n) { 17222 n || (n = Ws(null)), n.minX = 1 / 0, n.minY = 1 / 0, n.maxX = -1 / 0, n.maxY = -1 / 0; 17223 for (let r = t; r < i; r++) { 17224 const o = e.children[r]; 17225 Xn(n, e.leaf ? s(o) : o); 17226 } 17227 return n; 17228} 17229function Xn(e, t) { 17230 return e.minX = Math.min(e.minX, t.minX), e.minY = Math.min(e.minY, t.minY), e.maxX = Math.max(e.maxX, t.maxX), e.maxY = Math.max(e.maxY, t.maxY), e; 17231} 17232function pC(e, t) { 17233 return e.minX - t.minX; 17234} 17235function yC(e, t) { 17236 return e.minY - t.minY; 17237} 17238function ja(e) { 17239 return (e.maxX - e.minX) * (e.maxY - e.minY); 17240} 17241function Zr(e) { 17242 return e.maxX - e.minX + (e.maxY - e.minY); 17243} 17244function xC(e, t) { 17245 return (Math.max(t.maxX, e.maxX) - Math.min(t.minX, e.minX)) * (Math.max(t.maxY, e.maxY) - Math.min(t.minY, e.minY)); 17246} 17247function vC(e, t) { 17248 const i = Math.max(e.minX, t.minX), s = Math.max(e.minY, t.minY), n = Math.min(e.maxX, t.maxX), r = Math.min(e.maxY, t.maxY); 17249 return Math.max(0, n - i) * Math.max(0, r - s); 17250} 17251function Wa(e, t) { 17252 return e.minX <= t.minX && e.minY <= t.minY && t.maxX <= e.maxX && t.maxY <= e.maxY; 17253} 17254function Jr(e, t) { 17255 return t.minX <= e.maxX && t.minY <= e.maxY && t.maxX >= e.minX && t.maxY >= e.minY; 17256} 17257function Ws(e) { 17258 return { 17259 children: e, 17260 height: 1, 17261 leaf: !0, 17262 minX: 1 / 0, 17263 minY: 1 / 0, 17264 maxX: -1 / 0, 17265 maxY: -1 / 0 17266 }; 17267} 17268function Pu(e, t, i, s, n) { 17269 const r = [t, i]; 17270 for (; r.length; ) { 17271 if (i = r.pop(), t = r.pop(), i - t <= s) 17272 continue; 17273 const o = t + Math.ceil((i - t) / s / 2) * s; 17274 gC(e, o, t, i, n), r.push(t, o, o, i); 17275 } 17276} 17277class EC extends Ir { 17278 /** 17279 * @param {import("./extent.js").Extent} extent Extent. 17280 * @param {number|undefined} resolution Resolution. 17281 * @param {number} pixelRatio Pixel ratio. 17282 * @param {import("./ImageState.js").default} state State. 17283 */ 17284 constructor(t, i, s, n) { 17285 super(), this.extent = t, this.pixelRatio_ = s, this.resolution = i, this.state = n; 17286 } 17287 /** 17288 * @protected 17289 */ 17290 changed() { 17291 this.dispatchEvent(et.CHANGE); 17292 } 17293 /** 17294 * @return {import("./extent.js").Extent} Extent. 17295 */ 17296 getExtent() { 17297 return this.extent; 17298 } 17299 /** 17300 * @abstract 17301 * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image. 17302 */ 17303 getImage() { 17304 return Z(); 17305 } 17306 /** 17307 * @return {number} PixelRatio. 17308 */ 17309 getPixelRatio() { 17310 return this.pixelRatio_; 17311 } 17312 /** 17313 * @return {number} Resolution. 17314 */ 17315 getResolution() { 17316 return ( 17317 /** @type {number} */ 17318 this.resolution 17319 ); 17320 } 17321 /** 17322 * @return {import("./ImageState.js").default} State. 17323 */ 17324 getState() { 17325 return this.state; 17326 } 17327 /** 17328 * Load not yet loaded URI. 17329 * @abstract 17330 */ 17331 load() { 17332 Z(); 17333 } 17334} 17335const Eg = EC;
17336class MC extends Eg { 17337 /** 17338 * @param {import("./extent.js").Extent} extent Extent. 17339 * @param {number|undefined} resolution Resolution. 17340 * @param {number} pixelRatio Pixel ratio. 17341 * @param {string} src Image source URI. 17342 * @param {?string} crossOrigin Cross origin. 17343 * @param {LoadFunction} imageLoadFunction Image load function. 17344 * @param {CanvasRenderingContext2D} [context] Canvas context. When provided, the image will be 17345 * drawn into the context's canvas, and `getImage()` will return the canvas once the image 17346 * has finished loading. 17347 */ 17348 constructor(t, i, s, n, r, o, a) { 17349 super(t, i, s, rt.IDLE), this.src_ = n, this.image_ = new Image(), r !== null && (this.image_.crossOrigin = r), this.context_ = a, this.unlisten_ = null, this.state = rt.IDLE, this.imageLoadFunction_ = o; 17350 } 17351 /** 17352 * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image. 17353 * @api 17354 */ 17355 getImage() { 17356 if (this.state == rt.LOADED && this.context_ && !(this.image_ instanceof HTMLCanvasElement)) { 17357 const t = this.context_.canvas; 17358 t.width = this.image_.width, t.height = this.image_.height, this.context_.drawImage(this.image_, 0, 0), this.image_ = this.context_.canvas; 17359 } 17360 return this.image_; 17361 } 17362 /** 17363 * Tracks loading or read errors. 17364 * 17365 * @private 17366 */ 17367 handleImageError_() { 17368 this.state = rt.ERROR, this.unlistenImage_(), this.changed(); 17369 } 17370 /** 17371 * Tracks successful image load. 17372 * 17373 * @private 17374 */ 17375 handleImageLoad_() { 17376 this.resolution === void 0 && (this.resolution = Yt(this.extent) / this.image_.height), this.state = rt.LOADED, this.unlistenImage_(), this.changed(); 17377 } 17378 /** 17379 * Load the image or retry if loading previously failed. 17380 * Loading is taken care of by the tile queue, and calling this method is 17381 * only needed for preloading or for reloading in case of an error. 17382 * @api 17383 */ 17384 load() { 17385 (this.state == rt.IDLE || this.state == rt.ERROR) && (this.state = rt.LOADING, this.changed(), this.imageLoadFunction_(this, this.src_), this.unlisten_ = Vh( 17386 this.image_, 17387 this.handleImageLoad_.bind(this), 17388 this.handleImageError_.bind(this) 17389 )); 17390 } 17391 /** 17392 * @param {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image. 17393 */ 17394 setImage(t) { 17395 this.image_ = t, this.resolution = Yt(this.extent) / this.image_.height; 17396 } 17397 /** 17398 * Discards event handlers which listen for load completion or errors. 17399 * 17400 * @private 17401 */ 17402 unlistenImage_() { 17403 this.unlisten_ && (this.unlisten_(), this.unlisten_ = null); 17404 } 17405} 17406function Vh(e, t, i) { 17407 const s = ( 17408 /** @type {HTMLImageElement} */ 17409 e 17410 ); 17411 let n = !0, r = !1, o = !1; 17412 const a = [ 17413 Po(s, et.LOAD, function() { 17414 o = !0, r || t(); 17415 }) 17416 ]; 17417 return s.src && sE ? (r = !0, s.decode().then(function() { 17418 n && t(); 17419 }).catch(function(l) { 17420 n && (o ? t() : i()); 17421 })) : a.push(Po(s, et.ERROR, i)), function() { 17422 n = !1, a.forEach(Mt); 17423 }; 17424} 17425const CC = MC; 17426let Nn = null; 17427class bC extends Ir { 17428 /** 17429 * @param {HTMLImageElement|HTMLCanvasElement} image Image. 17430 * @param {string|undefined} src Src. 17431 * @param {import("../size.js").Size} size Size. 17432 * @param {?string} crossOrigin Cross origin. 17433 * @param {import("../ImageState.js").default} imageState Image state. 17434 * @param {import("../color.js").Color} color Color. 17435 */ 17436 constructor(t, i, s, n, r, o) { 17437 super(), this.hitDetectionImage_ = null, this.image_ = t, this.crossOrigin_ = n, this.canvas_ = {}, this.color_ = o, this.unlisten_ = null, this.imageState_ = r, this.size_ = s, this.src_ = i, this.tainted_; 17438 } 17439 /** 17440 * @private 17441 */ 17442 initializeImage_() { 17443 this.image_ = new Image(), this.crossOrigin_ !== null && (this.image_.crossOrigin = this.crossOrigin_); 17444 } 17445 /** 17446 * @private 17447 * @return {boolean} The image canvas is tainted. 17448 */ 17449 isTainted_() { 17450 if (this.tainted_ === void 0 && this.imageState_ === rt.LOADED) { 17451 Nn || (Nn = re(1, 1, void 0, { 17452 willReadFrequently: !0 17453 })), Nn.drawImage(this.image_, 0, 0); 17454 try { 17455 Nn.getImageData(0, 0, 1, 1), this.tainted_ = !1; 17456 } catch { 17457 Nn = null, this.tainted_ = !0; 17458 } 17459 } 17460 return this.tainted_ === !0; 17461 } 17462 /** 17463 * @private 17464 */ 17465 dispatchChangeEvent_() { 17466 this.dispatchEvent(et.CHANGE); 17467 } 17468 /** 17469 * @private 17470 */ 17471 handleImageError_() { 17472 this.imageState_ = rt.ERROR, this.unlistenImage_(), this.dispatchChangeEvent_(); 17473 } 17474 /** 17475 * @private 17476 */ 17477 handleImageLoad_() { 17478 this.imageState_ = rt.LOADED, this.size_ ? (this.image_.width = this.size_[0], this.image_.height = this.size_[1]) : this.size_ = [this.image_.width, this.image_.height], this.unlistenImage_(), this.dispatchChangeEvent_(); 17479 } 17480 /** 17481 * @param {number} pixelRatio Pixel ratio. 17482 * @return {HTMLImageElement|HTMLCanvasElement} Image or Canvas element. 17483 */ 17484 getImage(t) { 17485 return this.image_ || this.initializeImage_(), this.replaceColor_(t), this.canvas_[t] ? this.canvas_[t] : this.image_; 17486 } 17487 /** 17488 * @param {number} pixelRatio Pixel ratio. 17489 * @return {number} Image or Canvas element. 17490 */ 17491 getPixelRatio(t) { 17492 return this.replaceColor_(t), this.canvas_[t] ? t : 1; 17493 } 17494 /** 17495 * @return {import("../ImageState.js").default} Image state. 17496 */ 17497 getImageState() { 17498 return this.imageState_; 17499 } 17500 /** 17501 * @return {HTMLImageElement|HTMLCanvasElement} Image element. 17502 */ 17503 getHitDetectionImage() { 17504 if (this.image_ || this.initializeImage_(), !this.hitDetectionImage_) 17505 if (this.isTainted_()) { 17506 const t = this.size_[0], i = this.size_[1], s = re(t, i); 17507 s.fillRect(0, 0, t, i), this.hitDetectionImage_ = s.canvas; 17508 } else 17509 this.hitDetectionImage_ = this.image_; 17510 return this.hitDetectionImage_; 17511 } 17512 /** 17513 * Get the size of the icon (in pixels). 17514 * @return {import("../size.js").Size} Image size. 17515 */ 17516 getSize() { 17517 return this.size_; 17518 } 17519 /** 17520 * @return {string|undefined} Image src. 17521 */ 17522 getSrc() { 17523 return this.src_; 17524 } 17525 /** 17526 * Load not yet loaded URI. 17527 */ 17528 load() { 17529 if (this.imageState_ === rt.IDLE) { 17530 this.image_ || this.initializeImage_(), this.imageState_ = rt.LOADING;
17531 try { 17532 this.image_.src = this.src_; 17533 } catch { 17534 this.handleImageError_(); 17535 } 17536 this.unlisten_ = Vh( 17537 this.image_, 17538 this.handleImageLoad_.bind(this), 17539 this.handleImageError_.bind(this) 17540 ); 17541 } 17542 } 17543 /** 17544 * @param {number} pixelRatio Pixel ratio. 17545 * @private 17546 */ 17547 replaceColor_(t) { 17548 if (!this.color_ || this.canvas_[t] || this.imageState_ !== rt.LOADED) 17549 return; 17550 const i = this.image_, s = document.createElement("canvas"); 17551 s.width = Math.ceil(i.width * t), s.height = Math.ceil(i.height * t); 17552 const n = s.getContext("2d"); 17553 n.scale(t, t), n.drawImage(i, 0, 0), n.globalCompositeOperation = "multiply", n.fillStyle = jf(this.color_), n.fillRect(0, 0, s.width / t, s.height / t), n.globalCompositeOperation = "destination-in", n.drawImage(i, 0, 0), this.canvas_[t] = s; 17554 } 17555 /** 17556 * Discards event handlers which listen for load completion or errors. 17557 * 17558 * @private 17559 */ 17560 unlistenImage_() { 17561 this.unlisten_ && (this.unlisten_(), this.unlisten_ = null); 17562 } 17563} 17564function SC(e, t, i, s, n, r) { 17565 let o = Lo.get(t, s, r); 17566 return o || (o = new bC(e, t, i, s, n, r), Lo.set(t, s, r, o)), o; 17567} 17568function Au(e, t, i, s) { 17569 return i !== void 0 && s !== void 0 ? [i / e, s / t] : i !== void 0 ? i / e : s !== void 0 ? s / t : 1; 17570} 17571class qh extends mg { 17572 /** 17573 * @param {Options} [options] Options. 17574 */ 17575 constructor(t) { 17576 t = t || {}; 17577 const i = t.opacity !== void 0 ? t.opacity : 1, s = t.rotation !== void 0 ? t.rotation : 0, n = t.scale !== void 0 ? t.scale : 1, r = t.rotateWithView !== void 0 ? t.rotateWithView : !1; 17578 super({ 17579 opacity: i, 17580 rotation: s, 17581 scale: n,
17582 displacement: t.displacement !== void 0 ? t.displacement : [0, 0], 17583 rotateWithView: r, 17584 declutterMode: t.declutterMode 17585 }), this.anchor_ = t.anchor !== void 0 ? t.anchor : [0.5, 0.5], this.normalizedAnchor_ = null, this.anchorOrigin_ = t.anchorOrigin !== void 0 ? t.anchorOrigin : "top-left", this.anchorXUnits_ = t.anchorXUnits !== void 0 ? t.anchorXUnits : "fraction", this.anchorYUnits_ = t.anchorYUnits !== void 0 ? t.anchorYUnits : "fraction", this.crossOrigin_ = t.crossOrigin !== void 0 ? t.crossOrigin : null; 17586 const o = t.img !== void 0 ? t.img : null; 17587 this.imgSize_ = t.imgSize; 17588 let a = t.src; 17589 at(!(a !== void 0 && o), 4), at(!o || o && this.imgSize_, 5), (a === void 0 || a.length === 0) && o && (a = /** @type {HTMLImageElement} */ 17590 o.src || ot(o)), at(a !== void 0 && a.length > 0, 6), at( 17591 !((t.width !== void 0 || t.height !== void 0) && t.scale !== void 0), 17592 69 17593 ); 17594 const l = t.src !== void 0 ? rt.IDLE : rt.LOADED; 17595 if (this.color_ = t.color !== void 0 ? Ao(t.color) : null, this.iconImage_ = SC( 17596 o, 17597 /** @type {string} */ 17598 a, 17599 this.imgSize_ !== void 0 ? this.imgSize_ : null, 17600 this.crossOrigin_, 17601 l, 17602 this.color_ 17603 ), this.offset_ = t.offset !== void 0 ? t.offset : [0, 0], this.offsetOrigin_ = t.offsetOrigin !== void 0 ? t.offsetOrigin : "top-left", this.origin_ = null, this.size_ = t.size !== void 0 ? t.size : null, t.width !== void 0 || t.height !== void 0) { 17604 let h, c; 17605 if (t.size) 17606 [h, c] = t.size; 17607 else { 17608 const u = this.getImage(1); 17609 if (u instanceof HTMLCanvasElement || u.src && u.complete) 17610 h = u.width, c = u.height; 17611 else { 17612 this.initialOptions_ = t; 17613 const d = () => { 17614 if (this.unlistenImageChange(d), !this.initialOptions_) 17615 return; 17616 const f = this.iconImage_.getSize(); 17617 this.setScale( 17618 Au( 17619 f[0], 17620 f[1], 17621 t.width, 17622 t.height 17623 ) 17624 ); 17625 }; 17626 this.listenImageChange(d); 17627 return; 17628 } 17629 } 17630 h !== void 0 && this.setScale( 17631 Au(h, c, t.width, t.height) 17632 ); 17633 } 17634 } 17635 /** 17636 * Clones the style. The underlying Image/HTMLCanvasElement is not cloned. 17637 * @return {Icon} The cloned style. 17638 * @api 17639 */ 17640 clone() { 17641 let t, i, s; 17642 return this.initialOptions_ ? (i = this.initialOptions_.width, s = this.initialOptions_.height) : (t = this.getScale(), t = Array.isArray(t) ? t.slice() : t), new qh({ 17643 anchor: this.anchor_.slice(), 17644 anchorOrigin: this.anchorOrigin_, 17645 anchorXUnits: this.anchorXUnits_, 17646 anchorYUnits: this.anchorYUnits_, 17647 color: this.color_ && this.color_.slice ? this.color_.slice() : this.color_ || void 0, 17648 crossOrigin: this.crossOrigin_, 17649 imgSize: this.imgSize_, 17650 offset: this.offset_.slice(), 17651 offsetOrigin: this.offsetOrigin_, 17652 opacity: this.getOpacity(), 17653 rotateWithView: this.getRotateWithView(), 17654 rotation: this.getRotation(), 17655 scale: t, 17656 width: i, 17657 height: s, 17658 size: this.size_ !== null ? this.size_.slice() : void 0, 17659 src: this.getSrc(), 17660 displacement: this.getDisplacement().slice(), 17661 declutterMode: this.getDeclutterMode() 17662 }); 17663 } 17664 /** 17665 * Get the anchor point in pixels. The anchor determines the center point for the 17666 * symbolizer. 17667 * @return {Array<number>} Anchor. 17668 * @api 17669 */ 17670 getAnchor() { 17671 let t = this.normalizedAnchor_; 17672 if (!t) { 17673 t = this.anchor_; 17674 const n = this.getSize(); 17675 if (this.anchorXUnits_ == "fraction" || this.anchorYUnits_ == "fraction") { 17676 if (!n) 17677 return null; 17678 t = this.anchor_.slice(), this.anchorXUnits_ == "fraction" && (t[0] *= n[0]), this.anchorYUnits_ == "fraction" && (t[1] *= n[1]); 17679 } 17680 if (this.anchorOrigin_ != "top-left") { 17681 if (!n) 17682 return null; 17683 t === this.anchor_ && (t = this.anchor_.slice()), (this.anchorOrigin_ == "top-right" || this.anchorOrigin_ == "bottom-right") && (t[0] =
17683-t[0] + n[0]), (this.anchorOrigin_ == "bottom-left" || this.anchorOrigin_ == "bottom-right") && (t[1] = -t[1] + n[1]); 17684 } 17685 this.normalizedAnchor_ = t; 17686 } 17687 const i = this.getDisplacement(), s = this.getScaleArray(); 17688 return [ 17689 t[0] - i[0] / s[0], 17690 t[1] + i[1] / s[1] 17691 ]; 17692 } 17693 /** 17694 * Set the anchor point. The anchor determines the center point for the 17695 * symbolizer. 17696 * 17697 * @param {Array<number>} anchor Anchor. 17698 * @api 17699 */ 17700 setAnchor(t) { 17701 this.anchor_ = t, this.normalizedAnchor_ = null; 17702 } 17703 /** 17704 * Get the icon color. 17705 * @return {import("../color.js").Color} Color. 17706 * @api 17707 */ 17708 getColor() { 17709 return this.color_; 17710 } 17711 /** 17712 * Get the image icon. 17713 * @param {number} pixelRatio Pixel ratio. 17714 * @return {HTMLImageElement|HTMLCanvasElement} Image or Canvas element. 17715 * @api 17716 */ 17717 getImage(t) { 17718 return this.iconImage_.getImage(t); 17719 } 17720 /** 17721 * Get the pixel ratio. 17722 * @param {number} pixelRatio Pixel ratio. 17723 * @return {number} The pixel ratio of the image. 17724 * @api 17725 */ 17726 getPixelRatio(t) { 17727 return this.iconImage_.getPixelRatio(t); 17728 } 17729 /** 17730 * @return {import("../size.js").Size} Image size. 17731 */ 17732 getImageSize() { 17733 return this.iconImage_.getSize(); 17734 } 17735 /** 17736 * @return {import("../ImageState.js").default} Image state. 17737 */ 17738 getImageState() { 17739 return this.iconImage_.getImageState(); 17740 } 17741 /** 17742 * @return {HTMLImageElement|HTMLCanvasElement} Image element. 17743 */ 17744 getHitDetectionImage() { 17745 return this.iconImage_.getHitDetectionImage(); 17746 } 17747 /** 17748 * Get the origin of the symbolizer. 17749 * @return {Array<number>} Origin. 17750 * @api 17751 */ 17752 getOrigin() { 17753 if (this.origin_) 17754 return this.origin_; 17755 let t = this.offset_; 17756 if (this.offsetOrigin_ != "top-left") { 17757 const i = this.getSize(), s = this.iconImage_.getSize(); 17758 if (!i || !s) 17759 return null; 17760 t = t.slice(), (this.offsetOrigin_ == "top-right" || this.offsetOrigin_ == "bottom-right") && (t[0] = s[0] - i[0] - t[0]), (this.offsetOrigin_ == "bottom-left" || this.offsetOrigin_ == "bottom-right") && (t[1] = s[1] - i[1] - t[1]); 17761 } 17762 return this.origin_ = t, this.origin_; 17763 } 17764 /** 17765 * Get the image URL. 17766 * @return {string|undefined} Image src. 17767 * @api 17768 */ 17769 getSrc() { 17770 return this.iconImage_.getSrc(); 17771 } 17772 /** 17773 * Get the size of the icon (in pixels). 17774 * @return {import("../size.js").Size} Image size. 17775 * @api 17776 */ 17777 getSize() { 17778 return this.size_ ? this.size_ : this.iconImage_.getSize(); 17779 } 17780 /** 17781 * Get the width of the icon (in pixels). Will return undefined when the icon image is not yet loaded. 17782 * @return {number} Icon width (in pixels). 17783 * @api 17784 */ 17785 getWidth() { 17786 const t = this.getScaleArray(); 17787 if (this.size_) 17788 return this.size_[0] * t[0]; 17789 if (this.iconImage_.getImageState() == rt.LOADED) 17790 return this.iconImage_.getSize()[0] * t[0]; 17791 } 17792 /** 17793 * Get the height of the icon (in pixels). Will return undefined when the icon image is not yet loaded. 17794 * @return {number} Icon height (in pixels). 17795 * @api 17796 */ 17797 getHeight() { 17798 const t = this.getScaleArray(); 17799 if (this.size_) 17800 return this.size_[1] * t[1]; 17801 if (this.iconImage_.getImageState() == rt.LOADED) 17802 return this.iconImage_.getSize()[1] * t[1]; 17803 } 17804 /** 17805 * Set the scale. 17806 * 17807 * @param {number|import("../size.js").Size} scale Scale. 17808 * @api 17809 */ 17810 setScale(t) { 17811 delete this.initialOptions_, super.setScale(t); 17812 } 17813 /** 17814 * @param {function(import("../events/Event.js").default): void} listener Listener function. 17815 */ 17816 listenImageChange(t) { 17817 this.iconImage_.addEventListener(et.CHANGE, t); 17818 } 17819 /** 17820 * Load not yet loaded URI. 17821 * When rendering a feature with an icon style, the vector renderer will 17822 * automatically call this method. However, you might want to call this 17823 * method yourself for preloading or other purposes. 17824 * @api 17825 */ 17826 load() { 17827 this.iconImage_.load(); 17828 } 17829 /** 17830 * @param {function(import("../events/Event.js").default): void} listener Listener function. 17831 */ 17832 unlistenImageChange(t) { 17833 this.iconImage_.removeEventListener(et.CHANGE, t); 17834 } 17835} 17836const Mg = qh; 17837function Lu(e) { 17838 return new _r({ 17839 fill: mr(e, ""), 17840 stroke: pr(e, ""), 17841 text: wC(e), 17842 image: TC(e) 17843 }); 17844} 17845function mr(e, t) { 17846 const i = e[t + "fill-color"]; 17847 if (i) 17848 return new Ei({ color: i }); 17849} 17850function pr(e, t) { 17851 const i = e[t + "stroke-width"], s = e[t + "stroke-color"]; 17852 if (!(!i && !s)) 17853 return new xi({ 17854 width: i, 17855 color: s, 17856 lineCap: e[t + "stroke-line-cap"], 17857 lineJoin: e[t + "stroke-line-join"], 17858 lineDash: e[t + "stroke-line-dash"], 17859 lineDashOffset: e[t + "stroke-line-dash-offset"], 17860 miterLimit: e[t + "stroke-miter-limit"] 17861 }); 17862} 17863function wC(e) { 17864 const t = e["text-value"]; 17865 return t ? new fC({ 17866 text: t, 17867 font: e["text-font"], 17868 maxAngle: e["text-max-angle"], 17869 offsetX: e["text-offset-x"], 17870 offsetY: e["text-offset-y"], 17871 overflow: e["text-overflow"], 17872 placement: e["text-placement"], 17873 repeat: e["text-repeat"], 17874 scale: e["text-scale"], 17875 rotateWithView: e["text-rotate-with-view"], 17876 rotation: e["text-rotation"], 17877 textAlign: e["text-align"], 17878 justify: e["text-justify"], 17879 textBaseline: e["text-baseline"], 17880 padding: e["text-padding"], 17881 fill: mr(e, "text-"), 17882 backgroundFill: mr(e, "text-background-"), 17883 stroke: pr(e, "text-"), 17884 backgroundStroke: pr(e, "text-background-") 17885 }) : void 0; 17886} 17887function TC(e) { 17888 const t = e["icon-src"], i = e["icon-img"]; 17889 if (t || i) 17890 return new Mg({ 17891 src: t, 17892 img: i, 17893 imgSize: e["icon-img-size"], 17894 anchor: e["icon-anchor"], 17895 anchorOrigin: e["icon-anchor-origin"], 17896 anchorXUnits: e["icon-anchor-x-units"], 17897 anchorYUnits: e["icon-anchor-y-units"], 17898 color: e["icon-color"], 17899 crossOrigin: e["icon-cross-origin"], 17900 offset: e["icon-offset"], 17901 displacement: e["icon-displacement"], 17902 opacity: e["icon-opacity"], 17903 scale: e["icon-scale"], 17904 width: e["icon-width"], 17905 height: e["icon-height"], 17906 rotation: e["icon-rotation"], 17907 rotateWithView: e["icon-rotate-with-view"], 17908 size: e["icon-size"], 17909 declutterMode: e["icon-declutter-mode"] 17910 }); 17911 const s = e["shape-points"]; 17912 if (s) { 17913 const r = "shape-"; 17914 return new pg({ 17915 points: s, 17916 fill: mr(e, r), 17917 stroke: pr(e, r), 17918 radius: e["shape-radius"], 17919 radius1: e["shape-radius1"], 17920 radius2: e["shape-radius2"], 17921 angle: e["shape-angle"], 17922 displacement: e["shape-displacement"], 17923 rotation: e["shape-rotation"], 17924 rotateWithView: e["shape-rotate-with-view"], 17925 scale: e["shape-scale"], 17926 declutterMode: e["shape-declutter-mode"] 17927 }); 17928 } 17929 const n = e["circle-radius"]; 17930 if (n) { 17931 const r = "circle-"; 17932 return new Lr({ 17933 radius: n, 17934 fill: mr(e, r), 17935 stroke: pr(e, r), 17936 displacement: e["circle-displacement"], 17937 scale: e["circle-scale"], 17938 rotation: e["circle-rotation"], 17939 rotateWithView: e["circle-rotate-with-view"], 17940 declutterMode: e["circle-declutter-mode"] 17941 }); 17942 } 17943} 17944const Ou = { 17945 RENDER_ORDER: "renderOrder" 17946}; 17947class RC extends Pr { 17948 /** 17949 * @param {Options<VectorSourceType>} [options] Options. 17950 */ 17951 constructor(t) { 17952 t = t || {}; 17953 const i = Object.assign({}, t); 17954 delete i.style, delete i.renderBuffer, delete i.updateWhileAnimating, delete i.updateWhileInteracting, super(i), this.declutter_ = t.declutter !== void 0 ? t.declutter : !1, this.renderBuffer_ = t.renderBuffer !== void 0 ? t.renderBuffer : 100, this.style_ = null, this.styleFunction_ = void 0, this.setStyle(t.style), this.updateWhileAnimating_ = t.updateWhileAnimating !== void 0 ? t.updateWhileAnimating : !1, this.updateWhileInteracting_ = t.updateWhileInteracting !== void 0 ? t.updateWhileInteracting : !1; 17955 } 17956 /** 17957 * @return {boolean} Declutter. 17958 */ 17959 getDeclutter() { 17960 return this.declutter_; 17961 } 17962 /** 17963 * Get the topmost feature that intersects the given pixel on the viewport. Returns a promise 17964 * that resolves with an array of features. The array will either contain the topmost feature 17965 * when a hit was detected, or it will be empty. 17966 * 17967 * The hit detection algorithm used for this method is optimized for performance, but is less 17968 * accurate than the one used in [map.getFeaturesAtPixel()]{@link import("../Map.js").default#getFeaturesAtPixel}. 17969 * Text is not considered, and icons are only represented by their bounding box instead of the exact 17970 * image. 17971 * 17972 * @param {import("../pixel.js").Pixel} pixel Pixel. 17973 * @return {Promise<Array<import("../Feature").FeatureLike>>} Promise that resolves with an array of features. 17974 * @api 17975 */ 17976 getFeatures(t) { 17977 return super.getFeatures(t); 17978 } 17979 /** 17980 * @return {number|undefined} Render buffer. 17981 */ 17982 getRenderBuffer() { 17983 return this.renderBuffer_; 17984 } 17985 /** 17986 * @return {function(import("../Feature.js").default, import("../Feature.js").default): number|null|undefined} Render 17987 * order. 17988 */ 17989 getRenderOrder() { 17990 return ( 17991 /** @type {import("../render.js").OrderFunction|null|undefined} */ 17992 this.get(Ou.RENDER_ORDER) 17993 ); 17994 } 17995 /** 17996 * Get the style for features. This returns whatever was passed to the `style` 17997 * option at construction or to the `setStyle` method. 17998 * @return {import("../style/Style.js").StyleLike|null|undefined} Layer style. 17999 * @api 18000 */ 18001 getStyle() { 18002 return this.style_; 18003 } 18004 /** 18005 * Get the style function. 18006 * @return {import("../style/Style.js").StyleFunction|undefined} Layer style function. 18007 * @api 18008 */ 18009 getStyleFunction() { 18010 return this.styleFunction_; 18011 } 18012 /** 18013 * @return {boolean} Whether the rendered layer should be updated while 18014 * animating. 18015 */ 18016 getUpdateWhileAnimating() { 18017 return this.updateWhileAnimating_; 18018 } 18019 /** 18020 * @return {boolean} Whether the rendered layer should be updated while 18021 * interacting. 18022 */ 18023 getUpdateWhileInteracting() { 18024 return this.updateWhileInteracting_; 18025 } 18026 /** 18027 * Render declutter items for this layer 18028 * @param {import("../Map.js").FrameState} frameState Frame state. 18029 */ 18030 renderDeclutter(t) { 18031 t.declutterTree || (t.declutterTree = new vg(9)), this.getRenderer().renderDeclutter(t); 18032 } 18033 /** 18034 * @param {import("../render.js").OrderFunction|null|undefined} renderOrder 18035 * Render order. 18036 */ 18037 setRenderOrder(t) { 18038 this.set(Ou.RENDER_ORDER, t); 18039 } 18040 /** 18041 * Set the style for features. This can be a single style object, an array 18042 * of styles, or a function that takes a feature and resolution and returns 18043 * an array of styles. If set to `null`, the layer has no style (a `null` style), 18044 * so only features that have their own styles will be rendered in the layer. C
18044all 18045 * `setStyle()` without arguments to reset to the default style. See 18046 * [the ol/style/Style module]{@link module:ol/style/Style~Style} for information on the default style. 18047 * 18048 * If your layer has a static style, you can use [flat style]{@link module:ol/style/flat~FlatStyle} object 18049 * literals instead of using the `Style` and symbolizer constructors (`Fill`, `Stroke`, etc.): 18050 * ```js 18051 * vectorLayer.setStyle({ 18052 * "fill-color": "yellow", 18053 * "stroke-color": "black", 18054 * "stroke-width": 4 18055 * }) 18056 * ``` 18057 * 18058 * @param {import("../style/Style.js").StyleLike|import("../style/flat.js").FlatStyleLike|null} [style] Layer style. 18059 * @api 18060 */ 18061 setStyle(t) { 18062 let i; 18063 if (t === void 0) 18064 i = uC; 18065 else if (t === null) 18066 i = null; 18067 else if (typeof t == "function") 18068 i = t; 18069 else if (t instanceof _r) 18070 i = t; 18071 else if (Array.isArray(t)) { 18072 const s = t.length, n = new Array(s); 18073 for (let r = 0; r < s; ++r) { 18074 const o = t[r]; 18075 o instanceof _r ? n[r] = o : n[r] = Lu(o); 18076 } 18077 i = n; 18078 } else 18079 i = Lu(t); 18080 this.style_ = i, this.styleFunction_ = t === null ? void 0 : cC(this.style_), this.changed(); 18081 } 18082} 18083const IC = RC, Or = { 18084 BEGIN_GEOMETRY: 0, 18085 BEGIN_PATH: 1, 18086 CIRCLE: 2, 18087 CLOSE_PATH: 3, 18088 CUSTOM: 4, 18089 DRAW_CHARS: 5, 18090 DRAW_IMAGE: 6, 18091 END_GEOMETRY: 7, 18092 FILL: 8, 18093 MOVE_TO_LINE_TO: 9, 18094 SET_FILL_STYLE: 10, 18095 SET_STROKE_STYLE: 11, 18096 STROKE: 12 18097}, Qr = [Or.FILL], Bi = [Or.STROKE], ds = [Or.BEGIN_PATH], Fu = [Or.CLOSE_PATH], Q = Or; 18098class PC { 18099 /** 18100 * Render a geometry with a custom renderer. 18101 * 18102 * @param {import("../geom/SimpleGeometry.js").default} geometry Geometry. 18103 * @param {import("../Feature.js").FeatureLike} feature Feature. 18104 * @param {Function} renderer Renderer. 18105 * @param {Function} hitDetectionRenderer Renderer. 18106 */ 18107 drawCustom(t, i, s, n) { 18108 } 18109 /** 18110 * Render a geometry. 18111 * 18112 * @param {import("../geom/Geometry.js").default} geometry The geometry to render. 18113 */ 18114 drawGeometry(t) { 18115 } 18116 /** 18117 * Set the rendering style. 18118 * 18119 * @param {import("../style/Style.js").default} style The rendering style. 18120 */ 18121 setStyle(t) { 18122 } 18123 /** 18124 * @param {import("../geom/Circle.js").default} circleGeometry Circle geometry. 18125 * @param {import("../Feature.js").default} feature Feature. 18126 */ 18127 drawCircle(t, i) { 18128 } 18129 /** 18130 * @param {import("../Feature.js").default} feature Feature. 18131 * @param {import("../style/Style.js").default} style Style. 18132 */ 18133 drawFeature(t, i) { 18134 } 18135 /** 18136 * @param {import("../geom/GeometryCollection.js").default} geometryCollectionGeometry Geometry collection. 18137 * @param {import("../Feature.js").default} feature Feature. 18138 */ 18139 drawGeometryCollection(t, i) { 18140 } 18141 /** 18142 * @param {import("../geom/LineString.js").default|import("./Feature.js").default} lineStringGeometry Line string geometry. 18143 * @param {import("../Feature.js").FeatureLike} feature Feature. 18144 */ 18145 drawLineString(t, i) { 18146 } 18147 /** 18148 * @param {import("../geom/MultiLineString.js").default|import("./Feature.js").default} multiLineStringGeometry MultiLineString geometry. 18149 * @param {import("../Feature.js").FeatureLike} feature Feature. 18150 */ 18151 drawMultiLineString(t, i) { 18152 } 18153 /** 18154 * @param {import("../geom/MultiPoint.js").default|import("./Feature.js").default} multiPointGeometry MultiPoint geometry. 18155 * @param {import("../Feature.js").FeatureLike} feature Feature. 18156 */ 18157 drawMultiPoint(t, i) { 18158 } 18159 /** 18160 * @param {import("../geom/MultiPolygon.js").default} multiPolygonGeometry MultiPolygon geometry. 18161 * @param {import("../Feature.js").FeatureLike} feature Feature. 18162 */ 18163 drawMultiPolygon(t, i) { 18164 } 18165 /** 18166 * @param {import("../geom/Point.js").default|import("./Feature.js").default} pointGeometry Point geometry. 18167 * @param {import("../Feature.js").FeatureLike} feature Feature. 18168 */ 18169 drawPoint(t, i) { 18170 } 18171 /** 18172 * @param {import("../geom/Polygon.js").default|import("./Feature.js").default} polygonGeometry Polygon geometry. 18173 * @param {import("../Feature.js").FeatureLike} feature Feature. 18174 */ 18175 drawPolygon(t, i) { 18176 } 18177 /** 18178 * @param {import("../geom/SimpleGeometry.js").default|import("./Feature.js").default} geometry Geometry. 18179 * @param {import("../Feature.js").FeatureLike} feature Feature. 18180 */ 18181 drawText(t, i) { 18182 } 18183 /** 18184 * @param {import("../style/Fill.js").default} fillStyle Fill style. 18185 * @param {import("../style/Stroke.js").default} strokeStyle Stroke style. 18186 */ 18187 setFillStrokeStyle(t, i) { 18188 } 18189 /** 18190 * @param {import("../style/Image.js").default} imageStyle Image style. 18191 * @param {import("../render/canvas.js").DeclutterImageWithText} [declutterImageWithText] Shared data for combined decluttering with a text style. 18192 */ 18193 setImageStyle(t, i) { 18194 } 18195 /** 18196 * @param {import("../style/Text.js").default} textStyle Text style. 18197 * @param {import("../render/canvas.js").DeclutterImageWithText} [declutterImageWithText] Shared data for combined decluttering with an image style. 18198 */ 18199 setTextStyle(t, i) { 18200 } 18201} 18202const Cg = PC; 18203class AC extends Cg { 18204 /** 18205 * @param {number} tolerance Tolerance. 18206 * @param {import("../../extent.js").Extent} maxExtent Maximum extent. 18207 * @param {number} resolution Resolution. 18208 * @param {number} pixelRatio Pixel ratio. 18209 */ 18210 constructor(t, i, s, n) { 18211 super(), this.tolerance = t, this.maxExtent = i, this.pixelRatio = n, this.maxLineWidth = 0, this.resolution = s, this.beginGeometryInstruction1_ = null, this.beginGeometryInstruction2_ = null, this.bufferedMaxExtent_ = null, this.instructions = [], this.coordinates = [], this.tmpCoordinate_ = [], this.hitDetectionInstructions = [], this.state = /** @type {import("../canvas.js").FillStrokeState} */ 18212 {}; 18213 } 18214 /** 18215 * @protected 18216 * @param {Array<number>} dashArray Dash array. 18217 * @return {Array<number>} Dash array with pixel ratio applied 18218 */ 18219 applyPixelRatio(t) { 18220 const i = this.pixelRatio; 18221 return i == 1 ? t : t.map(function(s) { 18222 return s * i; 18223 }); 18224 } 18225 /** 18226 * @param {Array<number>} flatCoordinates Flat coordinates. 18227 * @param {number} stride Stride. 18228 * @protected 18229 * @return {number} My end 18230 */ 18231 appendFlatPointCoordinates(t, i) { 18232 const s = this.getBufferedMaxExtent(), n = this.tmpCoordinate_, r = this.coordinates; 18233 let o = r.length; 18234 for (let a = 0, l = t.length; a < l; a += i) 18235 n[0] = t[a], n[1] = t[a + 1], wr(s, n) && (r[o++] = n[0], r[o++] = n[1]); 18236 return o; 18237 } 18238 /** 18239 * @param {Array<number>} flatCoordinates Flat coordinates. 18240 * @param {number} offset Offset. 18241 * @param {number} end End. 18242 * @param {number} stride Stride. 18243 * @param {boolean} closed Last input coordinate equals first. 18244 * @param {boolean} skipFirst Skip first coordinate. 18245 * @protected 18246 * @return {number} My end. 18247 */ 18248 appendFlatLineCoordinates(t, i, s, n, r, o) { 18249 const a = this.coordinates; 18250 let l = a.length; 18251 const h = this.getBufferedMaxExtent(); 18252 o && (i += n);
18253 let c = t[i], u = t[i + 1]; 18254 const d = this.tmpCoordinate_; 18255 let f = !0, g, _, m; 18256 for (g = i + n; g < s; g += n) 18257 d[0] = t[g], d[1] = t[g + 1], m = nl(h, d), m !== _ ? (f && (a[l++] = c, a[l++] = u, f = !1), a[l++] = d[0], a[l++] = d[1]) : m === Ut.INTERSECTING ? (a[l++] = d[0], a[l++] = d[1], f = !1) : f = !0, c = d[0], u = d[1], _ = m; 18258 return (r && f || g === i + n) && (a[l++] = c, a[l++] = u), l; 18259 } 18260 /** 18261 * @param {Array<number>} flatCoordinates Flat coordinates. 18262 * @param {number} offset Offset. 18263 * @param {Array<number>} ends Ends. 18264 * @param {number} stride Stride. 18265 * @param {Array<number>} builderEnds Builder ends. 18266 * @return {number} Offset. 18267 */ 18268 drawCustomCoordinates_(t, i, s, n, r) { 18269 for (let o = 0, a = s.length; o < a; ++o) { 18270 const l = s[o], h = this.appendFlatLineCoordinates( 18271 t, 18272 i, 18273 l, 18274 n, 18275 !1, 18276 !1 18277 ); 18278 r.push(h), i = l; 18279 } 18280 return i; 18281 } 18282 /** 18283 * @param {import("../../geom/SimpleGeometry.js").default} geometry Geometry. 18284 * @param {import("../../Feature.js").FeatureLike} feature Feature. 18285 * @param {Function} renderer Renderer. 18286 * @param {Function} hitDetectionRenderer Renderer. 18287 */ 18288 drawCustom(t, i, s, n) { 18289 this.beginGeometry(t, i); 18290 const r = t.getType(), o = t.getStride(), a = this.coordinates.length; 18291 let l, h, c, u, d; 18292 switch (r) { 18293 case "MultiPolygon": 18294 l = /** @type {import("../../geom/MultiPolygon.js").default} */ 18295 t.getOrientedFlatCoordinates(), u = []; 18296 const f = ( 18297 /** @type {import("../../geom/MultiPolygon.js").default} */ 18298 t.getEndss() 18299 ); 18300 d = 0; 18301 for (let g = 0, _ = f.length; g < _; ++g) { 18302 const m = []; 18303 d = this.drawCustomCoordinates_( 18304 l, 18305 d, 18306 f[g], 18307 o, 18308 m 18309 ), u.push(m); 18310 } 18311 this.instructions.push([ 18312 Q.CUSTOM, 18313 a, 18314 u, 18315 t, 18316 s, 18317 Cl 18318 ]), this.hitDetectionInstructions.push([ 18319 Q.CUSTOM, 18320 a, 18321 u, 18322 t, 18323 n || s, 18324 Cl 18325 ]); 18326 break; 18327 case "Polygon": 18328 case "MultiLineString": 18329 c = [], l = r == "Polygon" ? ( 18330 /** @type {import("../../geom/Polygon.js").default} */ 18331 t.getOrientedFlatCoordinates() 18332 ) : t.getFlatCoordinates(), d = this.drawCustomCoordinates_( 18333 l, 18334 0, 18335 /** @type {import("../../geom/Polygon.js").default|import("../../geom/MultiLineString.js").default} */ 18336 t.getEnds(), 18337 o, 18338 c 18339 ), this.instructions.push([ 18340 Q.CUSTOM, 18341 a, 18342 c, 18343 t, 18344 s, 18345 lr 18346 ]), this.hitDetectionInstructions.push([ 18347 Q.CUSTOM, 18348 a, 18349 c, 18350 t, 18351 n || s, 18352 lr 18353 ]); 18354 break; 18355 case "LineString": 18356 case "Circle": 18357 l = t.getFlatCoordinates(), h = this.appendFlatLineCoordinates( 18358 l, 18359 0, 18360 l.length, 18361 o, 18362 !1, 18363 !1 18364 ), this.instructions.push([ 18365 Q.CUSTOM, 18366 a, 18367 h, 18368 t, 18369 s, 18370 ji 18371 ]), this.hitDetectionInstructions.push([ 18372 Q.CUSTOM, 18373 a, 18374 h, 18375 t, 18376 n || s, 18377 ji 18378 ]); 18379 break; 18380 case "MultiPoint": 18381 l = t.getFlatCoordinates(), h = this.appendFlatPointCoordinates(l, o), h > a && (this.instructions.push([ 18382 Q.CUSTOM, 18383 a, 18384 h, 18385 t, 18386 s, 18387 ji 18388 ]), this.hitDetectionInstructions.push([ 18389 Q.CUSTOM, 18390 a, 18391 h, 18392 t, 18393 n || s, 18394 ji 18395 ])); 18396 break; 18397 case "Point": 18398 l = t.getFlatCoordinates(), this.coordinates.push(l[0], l[1]), h = this.coordinates.length, this.instructions.push([ 18399 Q.CUSTOM, 18400 a, 18401 h, 18402 t, 18403 s 18404 ]), this.hitDetectionInstructions.push([ 18405 Q.CUSTOM, 18406 a, 18407 h, 18408 t, 18409 n || s 18410 ]); 18411 break; 18412 } 18413 this.endGeometry(i); 18414 } 18415 /** 18416 * @protected 18417 * @param {import("../../geom/Geometry").default|import("../Feature.js").default} geometry The geometry. 18418 * @param {import("../../Feature.js").FeatureLike} feature Feature. 18419 */ 18420 beginGeometry(t, i) { 18421 this.beginGeometryInstruction1_ = [
18422 Q.BEGIN_GEOMETRY, 18423 i, 18424 0, 18425 t 18426 ], this.instructions.push(this.beginGeometryInstruction1_), this.beginGeometryInstruction2_ = [ 18427 Q.BEGIN_GEOMETRY, 18428 i, 18429 0, 18430 t 18431 ], this.hitDetectionInstructions.push(this.beginGeometryInstruction2_); 18432 } 18433 /** 18434 * @return {import("../canvas.js").SerializableInstructions} the serializable instructions. 18435 */ 18436 finish() { 18437 return { 18438 instructions: this.instructions, 18439 hitDetectionInstructions: this.hitDetectionInstructions, 18440 coordinates: this.coordinates 18441 }; 18442 } 18443 /** 18444 * Reverse the hit detection instructions. 18445 */ 18446 reverseHitDetectionInstructions() { 18447 const t = this.hitDetectionInstructions; 18448 t.reverse(); 18449 let i; 18450 const s = t.length; 18451 let n, r, o = -1; 18452 for (i = 0; i < s; ++i) 18453 n = t[i], r = /** @type {import("./Instruction.js").default} */ 18454 n[0], r == Q.END_GEOMETRY ? o = i : r == Q.BEGIN_GEOMETRY && (n[2] = i, $v(this.hitDetectionInstructions, o, i), o = -1); 18455 } 18456 /** 18457 * @param {import("../../style/Fill.js").default} fillStyle Fill style. 18458 * @param {import("../../style/Stroke.js").default} strokeStyle Stroke style. 18459 */ 18460 setFillStrokeStyle(t, i) { 18461 const s = this.state; 18462 if (t) { 18463 const n = t.getColor(); 18464 s.fillStyle = Ze( 18465 n || yi 18466 ); 18467 } else 18468 s.fillStyle = void 0; 18469 if (i) { 18470 const n = i.getColor(); 18471 s.strokeStyle = Ze( 18472 n || dr 18473 ); 18474 const r = i.getLineCap(); 18475 s.lineCap = r !== void 0 ? r : Do; 18476 const o = i.getLineDash(); 18477 s.lineDash = o ? o.slice() : hr; 18478 const a = i.getLineDashOffset(); 18479 s.lineDashOffset = a || cr; 18480 const l = i.getLineJoin(); 18481 s.lineJoin = l !== void 0 ? l : Mn; 18482 const h = i.getWidth(); 18483 s.lineWidth = h !== void 0 ? h : gr; 18484 const c = i.getMiterLimit(); 18485 s.miterLimit = c !== void 0 ? c : ur, s.lineWidth > this.maxLineWidth && (this.maxLineWidth = s.lineWidth, this.bufferedMaxExtent_ = null); 18486 } else 18487 s.strokeStyle = void 0, s.lineCap = void 0, s.lineDash = null, s.lineDashOffset = void 0, s.lineJoin = void 0, s.lineWidth = void 0, s.miterLimit = void 0; 18488 } 18489 /** 18490 * @param {import("../canvas.js").FillStrokeState} state State. 18491 * @return {Array<*>} Fill instruction. 18492 */ 18493 createFill(t) { 18494 const i = t.fillStyle, s = [Q.SET_FILL_STYLE, i]; 18495 return typeof i != "string" && s.push(!0), s; 18496 } 18497 /** 18498 * @param {import("../canvas.js").FillStrokeState} state State. 18499 */ 18500 applyStroke(t) { 18501 this.instructions.push(this.createStroke(t)); 18502 } 18503 /** 18504 * @param {import("../canvas.js").FillStrokeState} state State. 18505 * @return {Array<*>} Stroke instruction. 18506 */ 18507 createStroke(t) { 18508 return [ 18509 Q.SET_STROKE_STYLE, 18510 t.strokeStyle, 18511 t.lineWidth * this.pixelRatio, 18512 t.lineCap, 18513 t.lineJoin, 18514 t.miterLimit, 18515 this.applyPixelRatio(t.lineDash), 18516 t.lineDashOffset * this.pixelRatio 18517 ]; 18518 } 18519 /** 18520 * @param {import("../canvas.js").FillStrokeState} state State. 18521 * @param {function(this:CanvasBuilder, import("../canvas.js").FillStrokeState):Array<*>} createFill Create fill. 18522 */ 18523 updateFillStyle(t, i) { 18524 const s = t.fillStyle; 18525 (typeof s != "string" || t.currentFillStyle != s) && (s !== void 0 && this.instructions.push(i.call(this, t)), t.currentFillStyle = s); 18526 } 18527 /** 18528 * @param {import("../canvas.js").FillStrokeState} state State. 18529 * @param {function(this:CanvasBuilder, import("../canvas.js").FillStrokeState): void} applyStroke Apply stroke. 18530 */ 18531 updateStrokeStyle(t, i) { 18532 const s = t.strokeStyle, n = t.lineCap, r = t.lineDash, o = t.lineDashOffset, a = t.lineJoin, l = t.lineWidth, h = t.miterLimit; 18533 (t.currentStrokeStyle != s || t.currentLineCap != n || r != t.currentLineDash && !bi(t.currentLineDash, r) || t.currentLineDashOffset != o || t.currentLineJoin != a || t.currentLineWidth != l || t.currentMiterLimit != h) && (s !== void 0 && i.call(this, t), t.currentStrokeStyle = s, t.currentLineCap = n, t.currentLineDash = r, t.currentLineDashOffset = o, t.currentLineJoin = a, t.currentLineWidth = l, t.currentMiterLimit = h); 18534 } 18535 /** 18536 * @param {import("../../Feature.js").FeatureLike} feature Feature. 18537 */ 18538 endGeometry(t) { 18539 this.beginGeometryInstruction1_[2] = this.instructions.length, this.beginGeometryInstruction1_ = null, this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length, this.beginGeometryInstruction2_ = null; 18540 const i = [Q.END_GEOMETRY, t]; 18541 this.instructions.push(i), this.hitDetectionInstructions.push(i); 18542 } 18543 /** 18544 * Get the buffered rendering extent. Rendering will be clipped to the extent 18545 * provided to the constructor. To account for symbolizers that may intersect 18546 * this extent, we calculate a buffered extent (e.g. based on stroke width). 18547 * @return {import("../../extent.js").Extent} The buffered rendering extent. 18548 * @protected 18549 */ 18550 getBufferedMaxExtent() { 18551 if (!this.bufferedMaxExtent_ && (this.bufferedMaxExtent_ = Rd(this.maxExtent), this.maxLineWidth > 0)) { 18552 const t = this.resolution * (this.maxLineWidth + 1) / 2; 18553 Es(this.bufferedMaxExtent_, t, this.bufferedMaxExtent_); 18554 } 18555 return this.bufferedMaxExtent_; 18556 } 18557} 18558const Fr = AC; 18559class LC extends Fr { 18560 /** 18561 * @param {number} tolerance Tolerance. 18562 * @param {import("../../extent.js").Extent} maxExtent Maximum extent. 18563 * @param {number} resolution Resolution. 18564 * @param {number} pixelRatio Pixel ratio. 18565 */ 18566 constructor(t, i, s, n) { 18567 super(t, i, s, n), this.hitDetectionImage_ = null, this.image_ = null, this.imagePixelRatio_ = void 0, this.anchorX_ = void 0, this.anchorY_ = void 0, this.height_ = void 0, this.opacity_ = void 0, this.originX_ = void 0, this.originY_ = void 0, this.rotateWithView_ = void 0, this.rotation_ = void 0, this.scale_ = void 0, this.width_ = void 0, this.declutterMode_ = void 0, this.declutterImageWithText_ = void 0; 18568 } 18569 /** 18570 * @param {import("../../geom/Point.js").default|import("../Feature.js").default} pointGeometry Point geometry. 18571 * @param {import("../../Feature.js").FeatureLike} feature Feature. 18572 */ 18573 drawPoint(t, i) { 18574 if (!this.image_) 18575 return; 18576 this.beginGeometry(t, i); 18577 const s = t.getFlatCoordinates(), n = t.getStride(), r = this.coordinates.length, o = this.appendFlatPointCoordinates(s, n); 18578 this.instructions.push([ 18579 Q.DRAW_IMAGE, 18580 r, 18581 o, 18582 this.image_, 18583 // Remaining arguments to DRAW_IMAGE are in alphabetical order 18584 this.anchorX_ * this.imagePixelRatio_, 18585 this.anchorY_ * this.imagePixelRatio_, 18586 Math.ceil(this.height_ * this.imagePixelRatio_), 18587 this.opacity_, 18588 this.originX_ * this.imagePixelRatio_, 18589 this.originY_ * this.imagePixelRatio_, 18590 this.rotateWithView_, 18591 this.rotation_, 18592 [ 18593 this.scale_[0] * this.pixelRatio / this.imagePixelRatio_, 18594 this.scale_[1] * this.pixelRatio / this.imagePixelRatio_ 18595 ], 18596 Math.ceil(this.width_ * this.imagePixelRatio_), 18597 this.declutterMode_, 18598 this.declutterImageWithText_ 18599 ]), this.hitDetectionInstructions.push([ 18600 Q.DRAW_IMAGE, 18601 r, 18602 o, 18603 this.hitDetectionImage_, 18604 // Remaining arguments to DRAW_IMAGE are in alphabetical order 18605 this.anchorX_, 18606 this.anchorY_, 18607 this.height_, 18608 this.opacity_, 18609 this.originX_, 18610 this.originY_, 18611 this.rotateWithView_, 18612 this.rotation_, 18613 this.scale_, 18614 this.width_, 18615 this.declutterMode_, 18616 this.declutterImageWithText_ 18617 ]), this.endGeometry(i); 18618 } 18619 /** 18620 * @param {import("../../geom/MultiPoint.js").default|import("../Feature.js").default} multiPointGeometry MultiPoint geometry. 18621 * @param {import("../../Feature.js").FeatureLike} feature Feature. 18622 */ 18623 drawMultiPoint(t, i) { 18624 if (!this.image_) 18625 return; 18626 this.beginGeometry(t, i); 18627 const s = t.getFlatCoordinates(), n = t.getStride(), r = this.coordinates.length, o = this.appendFlatPointCoordinates(s, n); 18628 this.instructions.push([ 18629 Q.DRAW_IMAGE, 18630 r, 18631 o, 18632 this.image_, 18633 // Remaining arguments to DRAW_IMAGE are in alphabetical order 18634 this.anchorX_ * this.imagePixelRatio_, 18635 this.anchorY_ * this.imagePixelRatio_, 18636 Math.ceil(this.height_ * this.imagePixelRatio_), 18637 this.opacity_, 18638 this.originX_ * this.imagePixelRatio_, 18639 this.originY_ * this.imagePixelRatio_, 18640 this.rotateWithView_, 18641 this.rotation_, 18642 [ 18643 this.scale_[0] * this.pixelRatio / this.imagePixelRatio_, 18644 this.scale_[1] * this.pixelRatio / this.imagePixelRatio_ 18645 ], 18646 Math.ceil(this.width_ * this.imagePixelRatio_), 18647 this.declutterMode_, 18648 this.declutterImageWithText_ 18649 ]), this.hitDetectionInstructions.push([ 18650 Q.DRAW_IMAGE, 18651 r, 18652 o, 18653 this.hitDetectionImage_, 18654 // Remaining arguments to DRAW_IMAGE are in alphabetical order 18655 this.anchorX_, 18656 this.anchorY_, 18657 this.height_, 18658 this.opacity_, 18659 this.originX_, 18660 this.originY_, 18661 this.rotateWithView_, 18662 this.rotation_, 18663 this.scale_, 18664 this.width_, 18665 this.declutterMode_, 18666 this.declutterImageWithText_ 18667 ]), this.endGeometry(i); 18668 } 18669 /** 18670 * @return {import("../canvas.js").SerializableInstructions} the serializable instructions. 18671 */ 18672 finish() { 18673 return this.reverseHitDetectionInstructions(), this.anchorX_ = void 0, this.anchorY_ = void 0, this.hitDetectionImage_ = null, this.image_ = null, this.imagePixelRatio_ = void 0, this.height_ = void 0, this.scale_ = void 0, this.opacity_ = void 0, this.originX_ = void 0, this.originY_ = void 0, this.rotateWithView_ = void 0, this.rotation_ = void 0, this.width_ = void 0, super.finish(); 18674 } 18675 /** 18676 * @param {import("../../style/Image.js").default} imageStyle Image style. 18677 * @param {Object} [sharedData] Shared data. 18678 */ 18679 setImageStyle(t, i) { 18680 const s = t.getAnchor(), n = t.getSize(), r = t.getOrigin(); 18681 this.imagePixelRatio_ = t.getPixelRatio(this.pixelRatio), this.anchorX_ = s[0], this.anchorY_ = s[1], this.hitDetectionImage_ = t.getHitDetectionImage(), this.image_ = t.getImage(this.pixelRatio), this.height_ = n[1], this.opacity_ = t.getOpacity(), this.originX_ = r[0], this.originY_ = r[1], this.rotateWithView_ = t.getRotateWithView(), this.rotation_ = t.getRotation(), this.scale_ = t.getScaleArray(), this.width_ = n[0], this.declutterMode_ = t.getDeclutterMode(), this.declutterImageWithText_ = i; 18682 } 18683} 18684const OC = LC; 18685class FC extends Fr { 18686 /** 18687 * @param {number} tolerance Tolerance. 18688 * @param {import("../../extent.js").Extent} maxExtent Maximum extent. 18689 * @param {number} resolution Resolution. 18690 * @param {number} pixelRatio Pixel ratio. 18691 */ 18692 constructor(t, i, s, n) { 18693 super(t, i, s, n); 18694 } 18695 /** 18696 * @param {Array<number>} flatCoordinates Flat coordinates. 18697 * @param {number} offset Offset. 18698 * @param {number} end End. 18699 * @param {number} stride Stride. 18700 * @private 18701 * @return {number} end. 18702 */ 18703 drawFlatCoordinates_(t, i, s, n) { 18704 const r = this.coordinates.length, o = this.appendFlatLineCoordinates( 18705 t, 18706 i, 18707 s, 18708 n, 18709 !1, 18710 !1 18711 ), a = [ 18712 Q.MOVE_TO_LINE_TO, 18713 r, 18714 o 18715 ]; 18716 return this.instructions.push(a), this.hitDetectionInstructions.push(a), s; 18717 } 18718 /** 18719 * @param {import("../../geom/LineString.js").default|import("../Feature.js").default} lineStringGeometry Line string geometry. 18720 * @param {import("../../Feature.js").FeatureLike} feature Feature. 18721 */ 18722 drawLineString(t, i) { 18723 const s = this.state, n = s.strokeStyle, r = s.lineWidth; 18724 if (n === void 0 || r === void 0) 18725 return; 18726 this.updateStrokeStyle(s, this.applyStroke), this.beginGeometry(t, i), this.hitDetectionInstructions.push( 18727 [ 18728 Q.SET_STROKE_STYLE, 18729 s.strokeStyle, 18730 s.lineWidth, 18731 s.lineCap, 18732 s.lineJoin, 18733 s.miterLimit, 18734 hr, 18735 cr 18736 ], 18737 ds 18738 ); 18739 const o = t.getFlatCoordinates(), a = t.getStride(); 18740 this.drawFlatCoordinates_( 18741 o, 18742 0, 18743 o.length, 18744 a 18745 ), this.hitDetectionInstructions.push(Bi), this.endGeometry(i); 18746 } 18747 /** 18748 * @param {import("../../geom/MultiLineString.js").default|import("../Feature.js").default} multiLineStringGeometry MultiLineString geometry. 18749 * @param {import("../../Feature.js").FeatureLike} feature Feature. 18750 */ 18751 drawMultiLineString(t, i) { 18752 const s = this.state, n = s.strokeStyle, r = s.lineWidth; 18753 if (n === void 0 || r === void 0) 18754 return; 18755 this.updateStrokeStyle(s, this.applyStroke), this.beginGeometry(t, i), this.hitDetectionInstructions.push( 18756 [ 18757 Q.SET_STROKE_STYLE, 18758 s.strokeStyle, 18759 s.lineWidth, 18760 s.lineCap, 18761 s.lineJoin, 18762 s.miterLimit, 18763 s.lineDash, 18764 s.lineDashOffset 18765 ], 18766 ds 18767 ); 18768 const o = t.getEnds(), a = t.getFlatCoordinates(), l = t.getStride(); 18769 let h = 0; 18770 for (let c = 0, u = o.length; c < u; ++c) 18771 h = this.drawFlatCoordinates_( 18772 a, 18773 h, 18774 /** @type {number} */ 18775 o[c], 18776 l 18777 ); 18778 this.hitDetectionInstructions.push(Bi), this.endGeometry(i); 18779 } 18780 /** 18781 * @return {import("../canvas.js").SerializableInstructions} the serializable instructions. 18782 */ 18783 finish() { 18784 const t = this.state; 18785 return t.lastStroke != null && t.lastStroke != this.coordinates.length && this.instructions.push(Bi), this.reverseHitDetectionInstructions(), this.state = null, super.finish(); 18786 } 18787 /** 18788 * @param {import("../canvas.js").FillStrokeState} state State. 18789 */ 18790 applyStroke(t) { 18791 t.lastStroke != null && t.lastStroke != this.coordinates.length && (this.instructions.push(Bi), t.lastStroke = this.coordinates.length), t.lastStroke = 0, super.applyStroke(t), this.instructions.push(ds); 18792 } 18793} 18794const DC = FC; 18795class NC extends Fr { 18796 /** 18797 * @param {number} tolerance Tolerance. 18798 * @param {import("../../extent.js").Extent} maxExtent Maximum extent. 18799 * @param {number} resolution Resolution. 18800 * @param {number} pixelRatio Pixel ratio. 18801 */ 18802 constructor(t, i, s, n) { 18803 super(t, i, s, n); 18804 } 18805 /** 18806 * @param {Array<number>} flatCoordinates Flat coordinates. 18807 * @param {number} offset Offset. 18808 * @param {Array<number>} ends Ends. 18809 * @param {number} stride Stride. 18810 * @private 18811 * @return {number} End. 18812 */ 18813 drawFlatCoordinatess_(t, i, s, n) { 18814 const r = this.state, o = r.fillStyle !== void 0, a = r.strokeStyle !== void 0, l = s.length; 18815 this.instructions.push(ds), this.hitDetectionInstructions.push(ds); 18816 for (let h = 0; h < l; ++h) { 18817 const c = s[h], u = this.coordinates.length, d = this.appendFlatLineCoordinates( 18818 t, 18819 i, 18820 c, 18821 n, 18822 !0, 18823 !a 18824 ), f = [ 18825 Q.MOVE_TO_LINE_TO, 18826 u, 18827 d 18828 ]; 18829 this.instructions.push(f), this.hitDetectionInstructions.push(f), a && (this.instructions.push(Fu), this.hitDetectionInstructions.push(Fu)), i = c; 18830 } 18831 return o && (this.instructions.push(Qr), this.hitDetectionInstructions.push(Qr)), a && (this.instructions.push(Bi), this.hitDetectionInstructions.push(Bi)), i; 18832 } 18833 /** 18834 * @param {import("../../geom/Circle.js").default} circleGeometry Circle geometry. 18835 * @param {import("../../Feature.js").default} feature Feature. 18836 */ 18837 drawCircle(t, i) { 18838 const s = this.state, n = s.fillStyle, r = s.strokeStyle; 18839 if (n === void 0 && r === void 0) 18840 return; 18841 this.setFillStrokeStyles_(), this.beginGeometry(t, i), s.fillStyle !== void 0 && this.hitDetectionInstructions.push([ 18842 Q.SET_FILL_STYLE, 18843 yi 18844 ]), s.strokeStyle !== void 0 && this.hitDetectionInstructions.push([ 18845 Q.SET_STROKE_STYLE, 18846 s.strokeStyle, 18847 s.lineWidth, 18848 s.lineCap, 18849 s.lineJoin, 18850 s.miterLimit, 18851 s.lineDash, 18852 s.lineDashOffset 18853 ]); 18854 const o = t.getFlatCoordinates(), a = t.getStride(), l = this.coordinates.length; 18855 this.appendFlatLineCoordinates( 18856 o, 18857 0, 18858 o.length, 18859 a, 18860 !1, 18861 !1 18862 ); 18863 const h = [Q.CIRCLE, l]; 18864 this.instructions.push(ds, h), this.hitDetectionInstructions.push(ds, h), s.fillStyle !== void 0 && (this.instructions.push(Qr), this.hitDetectionInstructions.push(Qr)), s.strokeStyle !== void 0 && (this.instructions.push(Bi), this.hitDetectionInstructions.push(Bi)), this.endGeometry(i); 18865 } 18866 /** 18867 * @param {impo
18867rt("../../geom/Polygon.js").default|import("../Feature.js").default} polygonGeometry Polygon geometry. 18868 * @param {import("../../Feature.js").FeatureLike} feature Feature. 18869 */ 18870 drawPolygon(t, i) { 18871 const s = this.state, n = s.fillStyle, r = s.strokeStyle; 18872 if (n === void 0 && r === void 0) 18873 return; 18874 this.setFillStrokeStyles_(), this.beginGeometry(t, i), s.fillStyle !== void 0 && this.hitDetectionInstructions.push([ 18875 Q.SET_FILL_STYLE, 18876 yi 18877 ]), s.strokeStyle !== void 0 && this.hitDetectionInstructions.push([ 18878 Q.SET_STROKE_STYLE, 18879 s.strokeStyle, 18880 s.lineWidth, 18881 s.lineCap, 18882 s.lineJoin, 18883 s.miterLimit, 18884 s.lineDash, 18885 s.lineDashOffset 18886 ]); 18887 const o = t.getEnds(), a = t.getOrientedFlatCoordinates(), l = t.getStride(); 18888 this.drawFlatCoordinatess_( 18889 a, 18890 0, 18891 /** @type {Array<number>} */ 18892 o, 18893 l 18894 ), this.endGeometry(i); 18895 } 18896 /** 18897 * @param {import("../../geom/MultiPolygon.js").default} multiPolygonGeometry MultiPolygon geometry. 18898 * @param {import("../../Feature.js").FeatureLike} feature Feature. 18899 */ 18900 drawMultiPolygon(t, i) { 18901 const s = this.state, n = s.fillStyle, r = s.strokeStyle; 18902 if (n === void 0 && r === void 0) 18903 return; 18904 this.setFillStrokeStyles_(), this.beginGeometry(t, i), s.fillStyle !== void 0 && this.hitDetectionInstructions.push([ 18905 Q.SET_FILL_STYLE, 18906 yi 18907 ]), s.strokeStyle !== void 0 && this.hitDetectionInstructions.push([ 18908 Q.SET_STROKE_STYLE, 18909 s.strokeStyle, 18910 s.lineWidth, 18911 s.lineCap, 18912 s.lineJoin, 18913 s.miterLimit, 18914 s.lineDash, 18915 s.lineDashOffset 18916 ]); 18917 const o = t.getEndss(), a = t.getOrientedFlatCoordinates(), l = t.getStride(); 18918 let h = 0; 18919 for (let c = 0, u = o.length; c < u; ++c) 18920 h = this.drawFlatCoordinatess_( 18921 a, 18922 h, 18923 o[c], 18924 l 18925 ); 18926 this.endGeometry(i); 18927 } 18928 /** 18929 * @return {import("../canvas.js").SerializableInstructions} the serializable instructions. 18930 */ 18931 finish() { 18932 this.reverseHitDetectionInstructions(), this.state = null; 18933 const t = this.tolerance; 18934 if (t !== 0) { 18935 const i = this.coordinates; 18936 for (let s = 0, n = i.length; s < n; ++s) 18937 i[s] = as(i[s], t); 18938 } 18939 return super.finish(); 18940 } 18941 /** 18942 * @private 18943 */ 18944 setFillStrokeStyles_() { 18945 const t = this.state; 18946 t.fillStyle !== void 0 && this.updateFillStyle(t, this.createFill), t.strokeStyle !== void 0 && this.updateStrokeStyle(t, this.applyStroke); 18947 } 18948} 18949const Du = NC; 18950function kC(e, t, i, s, n) { 18951 const r = []; 18952 let o = i, a = 0, l = t.slice(i, 2); 18953 for (; a < e && o + n < s; ) { 18954 const [h, c] = l.slice(-2), u = t[o + n], d = t[o + n + 1], f = Math.sqrt( 18955 (u - h) * (u - h) + (d - c) * (d - c) 18956 ); 18957 if (a += f, a >= e) { 18958 const g = (e - a + f) / f, _ = we(h, u, g), m = we(c, d, g); 18959 l.push(_, m), r.push(l), l = [_, m], a == e && (o += n), a = 0; 18960 } else if (a < e) 18961 l.push( 18962 t[o + n], 18963 t[o + n + 1] 18964 ), o += n; 18965 else { 18966 const g = f - a, _ = we(h, u, g / f), m = we(c, d, g / f); 18967 l.push(_, m), r.push(l), l = [_, m], a = 0, o += n; 18968 } 18969 } 18970 return a > 0 && r.push(l), r; 18971} 18972function GC(e, t, i, s, n) { 18973 let r = i, o = i, a = 0, l = 0, h = i, c, u, d, f, g, _, m, p, y, v; 18974 for (u = i; u < s; u += n) { 18975 const E = t[u], C = t[u + 1]; 18976 g !== void 0 && (y = E - g, v = C - _, f = Math.sqrt(y * y + v * v), m !== void 0 && (l += d, c = Math.acos((m * y + p * v) / (d * f)), c > e && (l > a && (a = l, r = h, o = u), l = 0, h = u - n)), d = f, m = y, p = v), g = E, _ = C; 18977 } 18978 return l += f, l > a ? [h, u] : [r, o]; 18979} 18980const Hn = { 18981 left: 0, 18982 end: 0, 18983 center: 0.5, 18984 right: 1, 18985 start: 1, 18986 top: 0, 18987 middle: 0.5, 18988 hanging: 0.2, 18989 alphabetic: 0.8, 18990 ideographic: 0.8, 18991 bottom: 1 18992}; 18993class zC extends Fr { 18994 /** 18995 * @param {number} tolerance Tolerance. 18996 * @param {import("../../extent.js").Extent} maxExtent Maximum extent. 18997 * @param {number} resolution Resolution. 18998 * @param {number} pixelRatio Pixel ratio. 18999 */ 19000 constructor(t, i, s, n) { 19001 super(t, i, s, n), this.labels_ = null, this.text_ = "", this.textOffsetX_ = 0, this.textOffsetY_ = 0, this.textRotateWithView_ = void 0, this.textRotation_ = 0, this.textFillState_ = null, this.fillStates = {}, this.textStrokeState_ = null, this.strokeStates = {}, this.textState_ = /** @type {import("../canvas.js").TextState} */ 19002 {}, this.textStates = {}, this.textKey_ = "", this.fillKey_ = "", this.strokeKey_ = "", this.declutterImageWithText_ = void 0; 19003 } 19004 /** 19005 * @return {import("../canvas.js").SerializableInstructions} the serializable instructions. 19006 */ 19007 finish() { 19008 const t = super.finish(); 19009 return t.textStates = this.textStates, t.fillStates = this.fillStates, t.strokeStates = this.strokeStates, t; 19010 } 19011 /** 19012 * @param {import("../../geom/SimpleGeometry.js").default|import("../Feature.js").default} geometry Geometry. 19013 * @param {import("../../Feature.js").FeatureLike} feature Feature. 19014 */ 19015 drawText(t, i) { 19016 const s = this.textFillState_, n = this.textStrokeState_, r = this.textState_; 19017 if (this.text_ === "" || !r || !s && !n) 19018 return; 19019 const o = this.coordinates; 19020 let a = o.length; 19021 const l = t.getType(); 19022 let h = null, c = t.getStride(); 19023 if (r.placement === "line" && (l == "LineString" || l == "MultiLineString" || l == "Polygon" || l == "MultiPolygon")) { 19024 if (!ee(this.getBufferedMaxExtent(), t.getExtent())) 19025 return; 19026 let u; 19027 if (h = t.getFlatCoordinates(), l == "LineString") 19028 u = [h.length]; 19029 else if (l == "MultiLineString") 19030 u = /** @type {import("../../geom/MultiLineString.js").default} */ 19031 t.getEnds(); 19032 else if (l == "Polygon") 19033 u = /** @type {import("../../geom/Polygon.js").default} */ 19034 t.getEnds().slice(0, 1); 19035 else if (l == "MultiPolygon") { 19036 const _ = ( 19037 /** @type {import("../../geom/MultiPolygon.js").default} */ 19038 t.getEndss() 19039 ); 19040 u = []; 19041 for (let m = 0, p = _.length; m < p; ++m) 19042 u.push(_[m][0]); 19043 } 19044 this.beginGeometry(t, i); 19045 const d = r.repeat, f = d ? void 0 : r.textAlign; 19046 let g = 0; 19047 for (let _ = 0, m = u.length; _ < m; ++_) { 19048 let p; 19049 d ? p = kC( 19050 d * this.resolution, 19051 h, 19052 g, 19053 u[_], 19054 c 19055 ) : p = [h.slice(g, u[_])]; 19056 for (let y = 0, v = p.length; y < v; ++y) { 19057 const E = p[y]; 19058 let C = 0, S = E.length; 19059 if (f == null) { 19060 const R = GC( 19061 r.maxAngle, 19062 E, 19063 0, 19064 E.length, 19065 2 19066 ); 19067 C = R[0], S = R[1]; 19068 } 19069 for (let R = C; R < S; R += c) 19070 o.push(E[R], E[R + 1]); 19071 const O = o.length; 19072 g = u[_], this.drawChars_(a, O), a = O; 19073 } 19074 } 19075 this.endGeometry(i); 19076 } else { 19077 let u = r.overflow ? null : []; 19078 switch (l) { 19079 case "Point": 19080 case "MultiPoint": 19081 h = /** @type {import("../../geom/MultiPoint.js").default} */ 19082 t.getFlatCoordinates(); 19083 break; 19084 case "LineString": 19085 h = /** @type {import("../../geom/LineString.js").default} */ 19086 t.getFlatMidpoint(); 19087 break; 19088 case "Circle": 19089 h = /** @type {import("../../geom/Circle.js").default} */ 19090 t.getCenter(); 19091 break; 19092 case "MultiLineString": 19093 h = /** @type {import("../../geom/MultiLineString.js").default} */ 19094 t.getFlatMidpoints(), c = 2; 19095 break; 19096 case "Polygon": 19097 h = /** @type {import("../../geom/Polygon.js").default} */ 19098 t.getFlatInteriorPoint(), r.overflow || u.push(h[2] / this.resolution), c = 3; 19099 break; 19100 case "MultiPolygon": 19101 const m = ( 19102 /** @type {import("../../geom/MultiPolygon.js").default} */ 19103 t.getFlatInteriorPoints() 19104 ); 19105 h = []; 19106 for (let p = 0, y = m.length; p < y; p += 3) 19107 r.overflow || u.push(m[p + 2] / this.resolution), h.push(m[p], m[p + 1]); 19108 if (h.length === 0) 19109 return; 19110 c = 2; 19111 break; 19112 } 19113 const d = this.appendFlatPointCoordinates(h, c); 19114 if (d === a) 19115 return; 19116 if (u && (d - a) / 2 !== h.length / c) { 19117 let m = a / 2; 19118 u = u.filter((p, y) => { 19119 const v = o[(m + y) * 2] === h[y * c] && o[(m + y) * 2 + 1] === h[y * c + 1]; 19120 return v || --m, v; 19121 }); 19122 } 19123 this.saveTextStates_(), (r.backgroundFill || r.backgroundStroke) && (this.setFillStrokeStyle( 19124 r.backgroundFill, 19125 r.backgroundStroke 19126 ), r.backgroundFill && (this.updateFillStyle(this.state, this.createFill), this.hitDetectionInstructions.push(this.createFill(this.state))), r.backgroundStroke && (this.updateStrokeStyle(this.state, this.applyStroke), this.hitDetectionInstructions.push(this.createStroke(this.state)))), this.beginGeometry(t, i); 19127 let f = r.padding; 19128 if (f != us && (r.scale[0] < 0 || r.scale[1] < 0)) { 19129 let m = r.padding[0], p = r.padding[1], y = r.padding[2], v = r.padding[3]; 19130 r.scale[0] < 0 && (p = -p, v = -v), r.scale[1] < 0 && (m = -m, y = -y), f = [m, p, y, v]; 19131 } 19132 const g = this.pixelRatio; 19133 this.instructions.push([ 19134 Q.DRAW_IMAGE, 19135 a, 19136 d, 19137 null, 19138 NaN, 19139 NaN, 19140 NaN, 19141 1, 19142 0, 19143 0, 19144 this.textRotateWithView_, 19145 this.textRotation_, 19146 [1, 1], 19147 NaN, 19148 void 0, 19149 this.declutterImageWithText_, 19150 f == us ? us : f.map(function(m) { 19151 return m * g; 19152 }), 19153 !!r.backgroundFill, 19154 !!r.backgroundStroke, 19155 this.text_, 19156 this.textKey_, 19157 this.strokeKey_, 19158 this.fillKey_, 19159 this.textOffsetX_, 19160 this.textOffsetY_, 19161 u 19162 ]); 19163 const _ = 1 / g; 19164 this.hitDetectionInstructions.push([ 19165 Q.DRAW_IMAGE, 19166 a, 19167 d, 19168 null, 19169 NaN, 19170 NaN, 19171 NaN, 19172 1, 19173 0, 19174 0, 19175 this.textRotateWithView_, 19176 this.textRotation_, 19177 [_, _], 19178 NaN, 19179 void 0, 19180 this.declutterImageWithText_, 19181 f, 19182 !!r.backgroundFill, 19183 !!r.backgroundStroke, 19184 this.text_, 19185 this.textKey_, 19186 this.strokeKey_, 19187 this.fillKey_, 19188 this.textOffsetX_, 19189 this.textOffsetY_, 19190 u 19191 ]), this.endGeometry(i); 19192 } 19193 } 19194 /** 19195 * @private 19196 */ 19197 saveTextStates_() { 19198 const t = this.textStrokeState_, i = this.textState_, s = this.textFillState_, n = this.strokeKey_; 19199 t && (n in this.strokeStates || (this.strokeStates[n] = { 19200 strokeStyle: t.strokeStyle, 19201 lineCap: t.lineCap, 19202 lineDashOffset: t.lineDashOffset, 19203 lineWidth: t.lineWidth, 19204 lineJoin: t.lineJoin,
19205 miterLimit: t.miterLimit, 19206 lineDash: t.lineDash 19207 })); 19208 const r = this.textKey_; 19209 r in this.textStates || (this.textStates[r] = { 19210 font: i.font, 19211 textAlign: i.textAlign || fr, 19212 justify: i.justify, 19213 textBaseline: i.textBaseline || No, 19214 scale: i.scale 19215 }); 19216 const o = this.fillKey_; 19217 s && (o in this.fillStates || (this.fillStates[o] = { 19218 fillStyle: s.fillStyle 19219 })); 19220 } 19221 /** 19222 * @private 19223 * @param {number} begin Begin. 19224 * @param {number} end End. 19225 */ 19226 drawChars_(t, i) { 19227 const s = this.textStrokeState_, n = this.textState_, r = this.strokeKey_, o = this.textKey_, a = this.fillKey_; 19228 this.saveTextStates_(); 19229 const l = this.pixelRatio, h = Hn[n.textBaseline], c = this.textOffsetY_ * l, u = this.text_, d = s ? s.lineWidth * Math.abs(n.scale[0]) / 2 : 0; 19230 this.instructions.push([ 19231 Q.DRAW_CHARS, 19232 t, 19233 i, 19234 h, 19235 n.overflow, 19236 a, 19237 n.maxAngle, 19238 l, 19239 c, 19240 r, 19241 d * l, 19242 u, 19243 o, 19244 1 19245 ]), this.hitDetectionInstructions.push([ 19246 Q.DRAW_CHARS, 19247 t, 19248 i, 19249 h, 19250 n.overflow, 19251 a, 19252 n.maxAngle, 19253 1, 19254 c, 19255 r, 19256 d, 19257 u, 19258 o, 19259 1 / l 19260 ]); 19261 } 19262 /** 19263 * @param {import("../../style/Text.js").default} textStyle Text style. 19264 * @param {Object} [sharedData] Shared data. 19265 */ 19266 setTextStyle(t, i) { 19267 let s, n, r; 19268 if (!t) 19269 this.text_ = ""; 19270 else { 19271 const o = t.getFill(); 19272 o ? (n = this.textFillState_, n || (n = /** @type {import("../canvas.js").FillState} */ 19273 {}, this.textFillState_ = n), n.fillStyle = Ze( 19274 o.getColor() || yi 19275 )) : (n = null, this.textFillState_ = n); 19276 const a = t.getStroke(); 19277 if (!a) 19278 r = null, this.textStrokeState_ = r; 19279 else { 19280 r = this.textStrokeState_, r || (r = /** @type {import("../canvas.js").StrokeState} */ 19281 {}, this.textStrokeState_ = r); 19282 const g = a.getLineDash(), _ = a.getLineDashOffset(), m = a.getWidth(), p = a.getMiterLimit(); 19283 r.lineCap = a.getLineCap() || Do, r.lineDash = g ? g.slice() : hr, r.lineDashOffset = _ === void 0 ? cr : _, r.lineJoin = a.getLineJoin() || Mn, r.lineWidth = m === void 0 ? gr : m, r.miterLimit = p === void 0 ? ur : p, r.strokeStyle = Ze( 19284 a.getColor() || dr 19285 ); 19286 } 19287 s = this.textState_; 19288 const l = t.getFont() || sg; 19289 sM(l); 19290 const h = t.getScaleArray(); 19291 s.overflow = t.getOverflow(), s.font = l, s.maxAngle = t.getMaxAngle(), s.placement = t.getPlacement(), s.textAlign = t.getTextAlign(), s.repeat = t.getRepeat(), s.justify = t.getJustify(), s.textBaseline = t.getTextBaseline() || No, s.backgroundFill = t.getBackgroundFill(), s.backgroundStroke = t.getBackgroundStroke(), s.padding = t.getPadding() || us, s.scale = h === void 0 ? [1, 1] : h; 19292 const c = t.getOffsetX(), u = t.getOffsetY(), d = t.getRotateWithView(), f = t.getRotation(); 19293 this.text_ = t.getText() || "", this.textOffsetX_ = c === void 0 ? 0 : c, this.textOffsetY_ = u === void 0 ? 0 : u, this.textRotateWithView_ = d === void 0 ? !1 : d, this.textRotation_ = f === void 0 ? 0 : f, this.strokeKey_ = r ? (typeof r.strokeStyle == "string" ? r.strokeStyle : ot(r.strokeStyle)) + r.lineCap + r.lineDashOffset + "|" + r.lineWidth + r.lineJoin + r.miterLimit + "[" + r.lineDash.join() + "]" : "", this.textKey_ = s.font + s.scale + (s.textAlign || "?") + (s.repeat || "?") + (s.justify || "?") + (s.textBaseline || "?"), this.fillKey_ = n ? typeof n.fillStyle == "string" ? n.fillStyle : "|" + ot(n.fillStyle) : ""; 19294 } 19295 this.declutterImageWithText_ = i; 19296 } 19297} 19298const jC = { 19299 Circle: Du, 19300 Default: Fr, 19301 Image: OC, 19302 LineString: DC, 19303 Polygon: Du, 19304 Text: zC 19305}; 19306class WC { 19307 /** 19308 * @param {number} tolerance Tolerance. 19309 * @param {import("../../extent.js").Extent} maxExtent Max extent. 19310 * @param {number} resolution Resolution. 19311 * @param {number} pixelRatio Pixel ratio. 19312 */ 19313 constructor(t, i, s, n) { 19314 this.tolerance_ = t, this.maxExtent_ = i, this.pixelRatio_ = n, this.resolution_ = s, this.buildersByZIndex_ = {}; 19315 } 19316 /** 19317 * @return {!Object<string, !Object<import("../canvas.js").BuilderType, import("./Builder.js").SerializableInstructions>>}
19317 The serializable instructions 19318 */ 19319 finish() { 19320 const t = {}; 19321 for (const i in this.buildersByZIndex_) { 19322 t[i] = t[i] || {}; 19323 const s = this.buildersByZIndex_[i]; 19324 for (const n in s) { 19325 const r = s[n].finish(); 19326 t[i][n] = r; 19327 } 19328 } 19329 return t; 19330 } 19331 /** 19332 * @param {number|undefined} zIndex Z index. 19333 * @param {import("../canvas.js").BuilderType} builderType Replay type. 19334 * @return {import("../VectorContext.js").default} Replay. 19335 */ 19336 getBuilder(t, i) { 19337 const s = t !== void 0 ? t.toString() : "0"; 19338 let n = this.buildersByZIndex_[s]; 19339 n === void 0 && (n = {}, this.buildersByZIndex_[s] = n); 19340 let r = n[i]; 19341 if (r === void 0) { 19342 const o = jC[i]; 19343 r = new o( 19344 this.tolerance_, 19345 this.maxExtent_, 19346 this.resolution_, 19347 this.pixelRatio_ 19348 ), n[i] = r; 19349 } 19350 return r; 19351 } 19352} 19353const Nu = WC; 19354class BC extends kf { 19355 /** 19356 * @param {LayerType} layer Layer. 19357 */ 19358 constructor(t) { 19359 super(), this.ready = !0, this.boundHandleImageChange_ = this.handleImageChange_.bind(this), this.layer_ = t, this.declutterExecutorGroup = null; 19360 } 19361 /** 19362 * Asynchronous layer level hit detection. 19363 * @param {import("../pixel.js").Pixel} pixel Pixel. 19364 * @return {Promise<Array<import("../Feature").FeatureLike>>} Promise that resolves with 19365 * an array of features. 19366 */ 19367 getFeatures(t) { 19368 return Z(); 19369 } 19370 /** 19371 * @param {import("../pixel.js").Pixel} pixel Pixel. 19372 * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data. 19373 */ 19374 getData(t) { 19375 return null; 19376 } 19377 /** 19378 * Determine whether render should be called. 19379 * @abstract 19380 * @param {import("../Map.js").FrameState} frameState Frame state. 19381 * @return {boolean} Layer is ready to be rendered. 19382 */ 19383 prepareFrame(t) { 19384 return Z(); 19385 } 19386 /** 19387 * Render the layer. 19388 * @abstract 19389 * @param {import("../Map.js").FrameState} frameState Frame state. 19390 * @param {HTMLElement} target Target that may be used to render content to. 19391 * @return {HTMLElement} The rendered element. 19392 */ 19393 renderFrame(t, i) { 19394 return Z(); 19395 } 19396 /** 19397 * @param {Object<number, Object<string, import("../Tile.js").default>>} tiles Lookup of loaded tiles by zoom level. 19398 * @param {number} zoom Zoom level. 19399 * @param {import("../Tile.js").default} tile Tile. 19400 * @return {boolean|void} If `false`, the tile will not be considered loaded. 19401 */ 19402 loadedTileCallback(t, i, s) { 19403 t[i] || (t[i] = {}), t[i][s.tileCoord.toString()] = s; 19404 } 19405 /** 19406 * Create a function that adds loaded tiles to the tile lookup. 19407 * @param {import("../source/Tile.js").default} source Tile source. 19408 * @param {import("../proj/Projection.js").default} projection Projection of the tiles. 19409 * @param {Object<number, Object<string, import("../Tile.js").default>>} tiles Lookup of loaded tiles by zoom level. 19410 * @return {function(number, import("../TileRange.js").default):boolean} A function that can be 19411 * called with a zoom level and a tile range to add loaded tiles to the lookup. 19412 * @protected 19413 */ 19414 createLoadedTileFinder(t, i, s) { 19415 return ( 19416 /** 19417 * @param {number} zoom Zoom level. 19418 * @param {import("../TileRange.js").default} tileRange Tile range. 19419 * @return {boolean} The tile range is fully loaded. 19420 */ 19421 (n, r) => { 19422 const o = this.loadedTileCallback.bind(this, s, n); 19423 return t.forEachLoadedTile(i, n, r, o); 19424 } 19425 ); 19426 } 19427 /** 19428 * @abstract 19429 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 19430 * @param {import("../Map.js").FrameState} frameState Frame state. 19431 * @param {number} hitTolerance Hit tolerance in pixels. 19432 * @param {import("./vector.js").FeatureCallback<T>} callback Feature callback. 19433 * @param {Array<import("./Map.js").HitMatch<T>>} matches The hit detected matches with tolerance. 19434 * @return {T|undefined} Callback result. 19435 * @template T 19436 */ 19437 forEachFeatureAtCoordinate(t, i, s, n, r) { 19438 } 19439 /** 19440 * @return {LayerType} Layer. 19441 */ 19442 getLayer() { 19443 return this.layer_; 19444 } 19445 /** 19446 * Perform action necessary to get the layer rendered after new fonts have loaded 19447 * @abstract 19448 */ 19449 handleFontsChanged() { 19450 } 19451 /** 19452 * Handle changes in image state. 19453 * @param {import("../events/Event.js").default} event Image change event. 19454 * @private 19455 */ 19456 handleImageChange_(t) { 19457 /** @type {import("../Image.js").default} */ 19458 t.target.getState() === rt.LOADED && this.renderIfReadyAndVisible(); 19459 } 19460 /** 19461 * Load the image if not already loaded, and register the image change 19462 * listener if needed. 19463 * @param {import("../ImageBase.js").default} image Image. 19464 * @return {boolean} `true` if the image is already loaded, `false` otherwise. 19465 * @protected 19466 */ 19467 loadImage(t) { 19468 let i = t.getState(); 19469 return i != rt.LOADED && i != rt.ERROR && t.addEventListener(et.CHANGE, this.boundHandleImageChange_), i == rt.IDLE && (t.load(), i = t.getState()), i == rt.LOADED; 19470 } 19471 /** 19472 * @protected 19473 */ 19474 renderIfReadyAndVisible() { 19475 const t = this.getLayer(); 19476 t && t.getVisible() && t.getSourceState() === "ready" && t.changed(); 19477 } 19478 /** 19479 * Clean up. 19480 */ 19481 disposeInternal() { 19482 delete this.layer_, super.disposeInternal(); 19483 } 19484} 19485const UC = BC, ku = []; 19486let Bs = null; 19487function XC() { 19488 Bs = re(1, 1, void 0, { 19489 willReadFrequently: !0 19490 }); 19491} 19492class $C extends UC { 19493 /** 19494 * @param {LayerType} layer Layer. 19495 */ 19496 constructor(t) { 19497 super(t), this.container = null, this.renderedResolution, this.tempTransform = Qe(), this.pixelTransform = Qe(), this.inversePixelTransform = Qe(), this.context = null, this.containerReused = !1, this.pixelContext_ = null, this.frameState = null; 19498 } 19499 /** 19500 * @param {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image. 19501 * @param {number} col The column index. 19502 * @param {number} row The row index. 19503 * @return {Uint8ClampedArray|null} The image data. 19504 */ 19505 getImageData(t, i, s) { 19506 Bs || XC(), Bs.clearRect(0, 0, 1, 1); 19507 let n; 19508 try { 19509 Bs.drawImage(t, i, s, 1, 1, 0, 0, 1, 1), n = Bs.getImageData(0, 0, 1, 1).data; 19510 } catch { 19511 return Bs = null, null; 19512 } 19513 return n; 19514 } 19515 /** 19516 * @param {import('../../Map.js').FrameState} frameState Frame state. 19517 * @return {string}
19517 Background color. 19518 */ 19519 getBackground(t) { 19520 let s = this.getLayer().getBackground(); 19521 return typeof s == "function" && (s = s(t.viewState.resolution)), s || void 0; 19522 } 19523 /** 19524 * Get a rendering container from an existing target, if compatible. 19525 * @param {HTMLElement} target Potential render target. 19526 * @param {string} transform CSS Transform. 19527 * @param {string} [backgroundColor] Background color. 19528 */ 19529 useContainer(t, i, s) { 19530 const n = this.getLayer().getClassName(); 19531 let r, o; 19532 if (t && t.className === n && (!s || t && t.style.backgroundColor && bi( 19533 Ao(t.style.backgroundColor), 19534 Ao(s) 19535 ))) { 19536 const a = t.firstElementChild; 19537 a instanceof HTMLCanvasElement && (o = a.getContext("2d")); 19538 } 19539 if (o && o.canvas.style.transform === i ? (this.container = t, this.context = o, this.containerReused = !0) : this.containerReused && (this.container = null, this.context = null, this.containerReused = !1), !this.container) { 19540 r = document.createElement("div"), r.className = n; 19541 let a = r.style; 19542 a.position = "absolute", a.width = "100%", a.height = "100%", o = re(); 19543 const l = o.canvas; 19544 r.appendChild(l), a = l.style, a.position = "absolute", a.left = "0", a.transformOrigin = "top left", this.container = r, this.context = o; 19545 } 19546 !this.containerReused && s && !this.container.style.backgroundColor && (this.container.style.backgroundColor = s); 19547 } 19548 /** 19549 * @param {CanvasRenderingContext2D} context Context. 19550 * @param {import("../../Map.js").FrameState} frameState Frame state. 19551 * @param {import("../../extent.js").Extent} extent Clip extent. 19552 * @protected 19553 */ 19554 clipUnrotated(t, i, s) { 19555 const n = ws(s), r = Ho(s), o = qo(s), a = Vo(s); 19556 zt(i.coordinateToPixelTransform, n), zt(i.coordinateToPixelTransform, r), zt(i.coordinateToPixelTransform, o), zt(i.coordinateToPixelTransform, a); 19557 const l = this.inversePixelTransform; 19558 zt(l, n), zt(l, r), zt(l, o), zt(l, a), t.save(), t.beginPath(), t.moveTo(Math.round(n[0]), Math.round(n[1])), t.lineTo(Math.round(r[0]), Math.round(r[1])
19558), t.lineTo(Math.round(o[0]), Math.round(o[1])), t.lineTo(Math.round(a[0]), Math.round(a[1])), t.clip(); 19559 } 19560 /** 19561 * @param {import("../../render/EventType.js").default} type Event type. 19562 * @param {CanvasRenderingContext2D} context Context. 19563 * @param {import("../../Map.js").FrameState} frameState Frame state. 19564 * @private 19565 */ 19566 dispatchRenderEvent_(t, i, s) { 19567 const n = this.getLayer(); 19568 if (n.hasListener(t)) { 19569 const r = new eg( 19570 t, 19571 this.inversePixelTransform, 19572 s, 19573 i 19574 ); 19575 n.dispatchEvent(r); 19576 } 19577 } 19578 /** 19579 * @param {CanvasRenderingContext2D} context Context. 19580 * @param {import("../../Map.js").FrameState} frameState Frame state. 19581 * @protected 19582 */ 19583 preRender(t, i) { 19584 this.frameState = i, this.dispatchRenderEvent_(Vi.PRERENDER, t, i); 19585 } 19586 /** 19587 * @param {CanvasRenderingContext2D} context Context. 19588 * @param {import("../../Map.js").FrameState} frameState Frame state. 19589 * @protected 19590 */ 19591 postRender(t, i) { 19592 this.dispatchRenderEvent_(Vi.POSTRENDER, t, i); 19593 } 19594 /** 19595 * Creates a transform for rendering to an element that will be rotated after rendering. 19596 * @param {import("../../coordinate.js").Coordinate} center Center. 19597 * @param {number} resolution Resolution. 19598 * @param {number} rotation Rotation. 19599 * @param {number} pixelRatio Pixel ratio. 19600 * @param {number} width Width of the rendered element (in pixels). 19601 * @param {number} height Height of the rendered element (in pixels). 19602 * @param {number} offsetX Offset on the x-axis in view coordinates. 19603 * @protected 19604 * @return {!import("../../transform.js").Transform} Transform. 19605 */ 19606 getRenderTransform(t, i, s, n, r, o, a) { 19607 const l = r / 2, h = o / 2, c = n / i, u = -c, d = -t[0] + a, f = -t[1]; 19608 return si( 19609 this.tempTransform, 19610 l, 19611 h, 19612 c, 19613 u, 19614 -s, 19615 d, 19616 f 19617 ); 19618 } 19619 /** 19620 * Clean up. 19621 */ 19622 disposeInternal() { 19623 delete this.frameState, super.disposeInternal(); 19624 } 19625} 19626const Hh = $C; 19627function YC(e, t, i, s, n, r, o, a, l, h, c, u) { 19628 let d = e[t], f = e[t + 1], g = 0, _ = 0, m = 0, p = 0; 19629 function y() { 19630 g = d, _ = f, t += s, d = e[t], f = e[t + 1], p += m, m = Math.sqrt((d - g) * (d - g) + (f - _) * (f - _)); 19631 } 19632 do 19633 y(); 19634 while (t < i - s && p + m < r); 19635 let v = m === 0 ? 0 : (r - p) / m; 19636 const E = we(g, d, v), C = we(_, f, v), S = t - s, O = p, R = r + a * l(h, n, c); 19637 for (; t < i - s && p + m < R; ) 19638 y(); 19639 v = m === 0 ? 0 : (R - p) / m; 19640 const j = we(g, d, v), $ = we(_, f, v); 19641 let q; 19642 if (u) { 19643 const Y = [E, C, j, $]; 19644 Sh(Y, 0, 4, 2, u, Y, Y), q = Y[0] > Y[2]; 19645 } else 19646 q = E > j; 19647 const tt = Math.PI, J = [], St = S + s === t; 19648 t = S, m = 0, p = O, d = e[t], f = e[t + 1]; 19649 let K; 19650 if (St) { 19651 y(), K = Math.atan2(f - _, d - g), q && (K += K > 0 ? -tt : tt); 19652 const Y = (j + E) / 2, L = ($ + C) / 2; 19653 return J[0] = [Y, L, (R - r) / 2, K, n], J; 19654 } 19655 n = n.replace(/\n/g, " "); 19656 for (let Y = 0, L = n.length; Y < L; ) { 19657 y(); 19658 let W = Math.atan2(f - _, d - g); 19659 if (q && (W += W > 0 ? -tt : tt), K !== void 0) { 19660 let pt = W - K; 19661 if (pt += pt > tt ? -2 * tt : pt < -tt ? 2 * tt : 0, Math.abs(pt) > o) 19662 return null; 19663 } 19664 K = W; 19665 const ut = Y; 19666 let ft = 0; 19667 for (; Y < L; ++Y) { 19668 const pt = q ? L - Y - 1 : Y, vt = a * l(h, n[pt], c); 19669 if (t + s < i && p + m < r + ft + vt / 2) 19670 break; 19671 ft += vt; 19672 } 19673 if (Y === ut) 19674 continue; 19675 const wt = q ? n.substring(L - ut, L - Y) : n.substring(ut, Y); 19676 v = m === 0 ? 0 : (r + ft / 2 - p) / m; 19677 const I = we(g, d, v), qt = we(_, f, v); 19678 J.push([I, qt, ft / 2, W, wt]), r += ft; 19679 } 19680 return J; 19681} 19682const Ds = ve(), Ti = [], ai = [], li = [], Ri = []; 19683function Gu(e) { 19684 return e[3].declutterBox; 19685} 19686const KC = new RegExp( 19687 /* eslint-disable prettier/prettier */ 19688 "[" + String.fromCharCode(1425) + "-" + String.fromCharCode(2303) + String.fromCharCode(64285) + "-" + String.fromCharCode(65023) + String.fromCharCode(65136) + "-" + String.fromCharCode(65276) + String.fromCharCode(67584) + "-" + String.fromCharCode(69631) + String.fromCharCode(124928) + "-" + String.fromCharCode(126975) + "]" 19689 /* eslint-enable prettier/prettier */ 19690); 19691function zu(e, t) { 19692 return (t === "start" || t === "end") && !KC.test(e) && (t = t === "start" ? "left" : "right"), Hn[t]; 19693} 19694function VC(e, t, i) { 19695 return i > 0 && e.push(` 19696`, ""), e.push(t, ""), e; 19697} 19698class qC { 19699 /** 19700 * @param {number} resolution Resolution. 19701 * @param {number} pixelRatio Pixel ratio. 19702 * @param {boolean} overlaps The replay can have overlapping geometries. 19703 * @param {import("../canvas.js").SerializableInstructions}
19703 instructions The serializable instructions 19704 */ 19705 constructor(t, i, s, n) { 19706 this.overlaps = s, this.pixelRatio = i, this.resolution = t, this.alignFill_, this.instructions = n.instructions, this.coordinates = n.coordinates, this.coordinateCache_ = {}, this.renderedTransform_ = Qe(), this.hitDetectionInstructions = n.hitDetectionInstructions, this.pixelCoordinates_ = null, this.viewRotation_ = 0, this.fillStates = n.fillStates || {}, this.strokeStates = n.strokeStates || {}, this.textStates = n.textStates || {}, this.widths_ = {}, this.labels_ = {}; 19707 } 19708 /** 19709 * @param {string|Array<string>} text Text. 19710 * @param {string} textKey Text style key. 19711 * @param {string} fillKey Fill style key. 19712 * @param {string} strokeKey Stroke style key. 19713 * @return {import("../canvas.js").Label} Label. 19714 */ 19715 createLabel(t, i, s, n) { 19716 const r = t + i + s + n; 19717 if (this.labels_[r]) 19718 return this.labels_[r]; 19719 const o = n ? this.strokeStates[n] : null, a = s ? this.fillStates[s] : null, l = this.textStates[i], h = this.pixelRatio, c = [ 19720 l.scale[0] * h, 19721 l.scale[1] * h 19722 ], u = Array.isArray(t), d = l.justify ? Hn[l.justify] : zu( 19723 Array.isArray(t) ? t[0] : t, 19724 l.textAlign || fr 19725 ), f = n && o.lineWidth ? o.lineWidth : 0, g = u ? t : t.split(` 19726`).reduce(VC, []), { width: _, height: m, widths: p, heights: y, lineWidths: v } = rM( 19727 l, 19728 g 19729 ), E = _ + f, C = [], S = (E + 2) * c[0], O = (m + f) * c[1], R = { 19730 width: S < 0 ? Math.floor(S) : Math.ceil(S), 19731 height: O < 0 ? Math.floor(O) : Math.ceil(O), 19732 contextInstructions: C 19733 }; 19734 (c[0] != 1 || c[1] != 1) && C.push("scale", c), n && (C.push("strokeStyle", o.strokeStyle), C.push("lineWidth", f), C.push("lineCap", o.lineCap), C.push("lineJoin", o.lineJoin), C.push("miterLimit", o.miterLimit), C.push("setLineDash", [o.lineDash]), C.push("lineDashOffset", o.lineDashOffset)), s && C.push("fillStyle", a.fillStyle), C.push("textBaseline", "middle"), C.push("textAlign", "center"); 19735 const j = 0.5 - d; 19736 let $ = d * E + j * f; 19737 const q = [], tt = []; 19738 let J = 0, St = 0, K = 0, Y = 0, L; 19739 for (let W = 0, ut = g.length; W < ut; W += 2) { 19740 const ft = g[W]; 19741 if (ft === ` 19742`) { 19743 St += J, J = 0, $ = d * E + j * f, ++Y; 19744 continue; 19745 } 19746 const wt = g[W + 1] || l.font; 19747 wt !== L && (n && q.push("font", wt), s && tt.push("font", wt), L = wt), J = Math.max(J, y[K]); 19748 const I = [ 19749 ft, 19750 $ + j * p[K] + d * (p[K] - v[Y]), 19751 0.5 * (f + J) + St 19752 ]; 19753 $ += p[K], n && q.push("strokeText", I), s && tt.push("fillText", I), ++K; 19754 } 19755 return Array.prototype.push.apply(C, q), Array.prototype.push.apply(C, tt), this.labels_[r] = R, R; 19756 } 19757 /** 19758 * @param {CanvasRenderingContext2D} context Context. 19759 * @param {import("../../coordinate.js").Coordinate} p1 1st point of the background box. 19760 * @param {import("../../coordinate.js").Coordinate} p2 2nd point of the background box. 19761 * @param {import("../../coordinate.js").Coordinate} p3 3rd point of the background box. 19762 * @param {import("../../coordinate.js").Coordinate} p4 4th point of the background box. 19763 * @param {Array<*>} fillInstruction Fill instruction. 19764 * @param {Array<*>} strokeInstruction Stroke instruction. 19765 */ 19766 replayTextBackground_(t, i, s, n, r, o, a) { 19767 t.beginPath(), t.moveTo.apply(t, i), t.lineTo.apply(t, s), t.lineTo.apply(t, n), t.lineTo.apply(t, r), t.lineTo.apply(t, i), o && (this.alignFill_ = /** @type {boolean} */ 19768 o[2], this.fill_(t)), a && (this.setStrokeStyle_( 19769 t, 19770 /** @type {Array<*>} */ 19771 a 19772 ), t.stroke()); 19773 } 19774 /** 19775 * @private 19776 * @param {number} sheetWidth Width of the sprite sheet. 19777 * @param {number} sheetHeight Height of the sprite sheet. 19778 * @param {number} centerX X. 19779 * @param {number} centerY Y. 19780 * @param {number} width Width. 19781 * @param {number} height Height. 19782 * @param {number} anchorX Anchor X. 19783 * @param {number} anchorY Anchor Y. 19784 * @param {number} originX Origin X. 19785 * @param {number} originY Origin Y. 19786 * @param {number} rotation Rotation. 19787 * @param {import("../../size.js").Size} scale Scale. 19788 * @param {boolean} snapToPixel Snap to pixel. 19789 * @param {Array<number>} padding Padding. 19790 * @param {boolean}
19790 fillStroke Background fill or stroke. 19791 * @param {import("../../Feature.js").FeatureLike} feature Feature. 19792 * @return {ImageOrLabelDimensions} Dimensions for positioning and decluttering the image or label. 19793 */ 19794 calculateImageOrLabelDimensions_(t, i, s, n, r, o, a, l, h, c, u, d, f, g, _, m) { 19795 a *= d[0], l *= d[1]; 19796 let p = s - a, y = n - l; 19797 const v = r + h > t ? t - h : r, E = o + c > i ? i - c : o, C = g[3] + v * d[0] + g[1], S = g[0] + E * d[1] + g[2], O = p - g[3], R = y - g[0]; 19798 (_ || u !== 0) && (Ti[0] = O, Ri[0] = O, Ti[1] = R, ai[1] = R, ai[0] = O + C, li[0] = ai[0], li[1] = R + S, Ri[1] = li[1]); 19799 let j; 19800 return u !== 0 ? (j = si( 19801 Qe(), 19802 s, 19803 n, 19804 1, 19805 1, 19806 u, 19807 -s, 19808 -n 19809 ), zt(j, Ti), zt(j, ai), zt(j, li), zt(j, Ri), ei( 19810 Math.min(Ti[0], ai[0], li[0], Ri[0]), 19811 Math.min(Ti[1], ai[1], li[1], Ri[1]), 19812 Math.max(Ti[0], ai[0], li[0], Ri[0]), 19813 Math.max(Ti[1], ai[1], li[1], Ri[1]), 19814 Ds 19815 )) : ei( 19816 Math.min(O, O + C), 19817 Math.min(R, R + S), 19818 Math.max(O, O + C), 19819 Math.max(R, R + S), 19820 Ds 19821 ), f && (p = Math.round(p), y = Math.round(y)), { 19822 drawImageX: p, 19823 drawImageY: y, 19824 drawImageW: v, 19825 drawImageH: E, 19826 originX: h, 19827 originY: c, 19828 declutterBox: { 19829 minX: Ds[0], 19830 minY: Ds[1], 19831 maxX: Ds[2], 19832 maxY: Ds[3], 19833 value: m 19834 }, 19835 canvasTransform: j, 19836 scale: d 19837 }; 19838 } 19839 /** 19840 * @private 19841 * @param {CanvasRenderingContext2D} context Context. 19842 * @param {number} contextScale Scale of the context. 19843 * @param {import("../canvas.js").Label|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} imageOrLabel Image. 19844 * @param {ImageOrLabelDimensions} dimensions Dimensions. 19845 * @param {number} opacity Opacity. 19846 * @param {Array<*>} fillInstruction Fill instruction. 19847 * @param {Array<*>} strokeInstruction Stroke instruction. 19848 * @return {boolean} The image or label was rendered. 19849 */ 19850 replayImageOrLabel_(t, i, s, n, r, o, a) { 19851 const l = !!(o || a), h = n.declutterBox, c = t.canvas, u = a ? a[2] * n.scale[0] / 2 : 0; 19852 return h.minX - u <= c.width / i && h.maxX + u >= 0 && h.minY - u <= c.height / i && h.maxY + u >= 0 && (l && this.replayTextBackground_( 19853 t, 19854 Ti, 19855 ai, 19856 li, 19857 Ri, 19858 /** @type {Array<*>} */ 19859 o, 19860 /** @type {Array<*>} */ 19861 a 19862 ), oM( 19863 t, 19864 n.canvasTransform, 19865 r, 19866 s, 19867 n.originX, 19868 n.originY, 19869 n.drawImageW, 19870 n.drawImageH, 19871 n.drawImageX, 19872 n.drawImageY, 19873 n.scale 19874 )), !0; 19875 } 19876 /** 19877 * @private 19878 * @param {CanvasRenderingContext2D} context Context. 19879 */ 19880 fill_(t) { 19881 if (this.alignFill_) { 19882 const i = zt(this.renderedTransform_, [0, 0]), s = 512 * this.pixelRatio; 19883 t.save(), t.translate(i[0] % s, i[1] % s), t.rotate(this.viewRotation_); 19884 } 19885 t.fill(), this.alignFill_ && t.restore(); 19886 } 19887 /** 19888 * @private 19889 * @param {CanvasRenderingContext2D} context Context. 19890 * @param {Array<*>} instruction Instruction. 19891 */ 19892 setStrokeStyle_(t, i) { 19893 t.strokeStyle = /** @type {import("../../colorlike.js").ColorLike} */ 19894 i[1], t.lineWidth = /** @type {number} */ 19895 i[2], t.lineCap = /** @type {CanvasLineCap} */ 19896 i[3], t.lineJoin = /** @type {CanvasLineJoin} */ 19897 i[4], t.miterLimit = /** @type {number} */ 19898 i[5], t.lineDashOffset = /** @type {number} */ 19899 i[7], t.setLineDash( 19900 /** @type {Array<number>} */ 19901 i[6] 19902 ); 19903 } 19904 /** 19905 * @private 19906 * @param {string|Array<string>} text The text to draw. 19907 * @param {string} textKey The key of the text state. 19908 * @param {string} strokeKey The key for the stroke state. 19909 * @param {string} fillKey The key for the fill state. 19910 * @return {{label: import("../canvas.js").Label, anchorX: number, anchorY: number}} The text image and its anchor. 19911 */ 19912 drawLabelWithPointPlacement_(t, i, s, n) { 19913 const r = this.textStates[i], o = this.createLabel(t, i, n, s), a = this.strokeStates[s], l = this.pixelRatio, h = zu( 19914 Array.isArray(t) ? t[0] : t, 19915 r.textAlign || fr 19916 ), c = Hn[r.textBaseline || No], u = a && a.lineWidth ? a.lineWidth : 0, d = o.width / l - 2 * r.scale[0], f = h * d + 2 * (0.5 - h) * u, g = c * o.height / l + 2 * (0.5 - c) * u; 19917 return { 19918 label: o, 19919 anchorX: f, 19920 anchorY: g 19921 }; 19922 } 19923 /** 19924 * @private 19925 * @param {CanvasRenderingContext2D} context Context. 19926 * @param {number} contextScale Scale of the context. 19927 * @param {import("../../transform.js").Transform} transform Transform. 19928 * @param {Array<*>}
19928 instructions Instructions array. 19929 * @param {boolean} snapToPixel Snap point symbols and text to integer pixels. 19930 * @param {FeatureCallback<T>} [featureCallback] Feature callback. 19931 * @param {import("../../extent.js").Extent} [hitExtent] Only check 19932 * features that intersect this extent. 19933 * @param {import("rbush").default} [declutterTree] Declutter tree. 19934 * @return {T|undefined} Callback result. 19935 * @template T 19936 */ 19937 execute_(t, i, s, n, r, o, a, l) { 19938 let h; 19939 this.pixelCoordinates_ && bi(s, this.renderedTransform_) ? h = this.pixelCoordinates_ : (this.pixelCoordinates_ || (this.pixelCoordinates_ = []), h = ps( 19940 this.coordinates, 19941 0, 19942 this.coordinates.length, 19943 2, 19944 s, 19945 this.pixelCoordinates_ 19946 ), rE(this.renderedTransform_, s)); 19947 let c = 0; 19948 const u = n.length; 19949 let d = 0, f, g, _, m, p, y, v, E, C, S, O, R, j = 0, $ = 0, q = null, tt = null; 19950 const J = this.coordinateCache_, St = this.viewRotation_, K = Math.round(Math.atan2(-s[1], s[0]) * 1e12) / 1e12, Y = ( 19951 /** @type {import("../../render.js").State} */ 19952 { 19953 context: t, 19954 pixelRatio: this.pixelRatio, 19955 resolution: this.resolution, 19956 rotation: St 19957 } 19958 ), L = this.instructions != n || this.overlaps ? 0 : 200; 19959 let W, ut, ft, wt; 19960 for (; c < u; ) { 19961 const I = n[c]; 19962 switch ( 19963 /** @type {import("./Instruction.js").default} */ 19964 I[0] 19965 ) { 19966 case Q.BEGIN_GEOMETRY: 19967 W = /** @type {import("../../Feature.js").FeatureLike} */ 19968 I[1], wt = I[3], W.getGeometry() ? a !== void 0 && !ee(a, wt.getExtent()) ? c = /** @type {number} */ 19969 I[2] + 1 : ++c : c = /** @type {number} */ 19970 I[2]; 19971 break; 19972 case Q.BEGIN_PATH: 19973 j > L && (this.fill_(t), j = 0), $ > L && (t.stroke(), $ = 0), !j && !$ && (t.beginPath(), m = NaN, p = NaN), ++c; 19974 break; 19975 case Q.CIRCLE: 19976 d = /** @type {number} */ 19977 I[1]; 19978 const pt = h[d], vt = h[d + 1], Bt = h[d + 2], oe = h[d + 3], Gt = Bt - pt, Ht = oe - vt, Ue = Math.sqrt(Gt * Gt + Ht * Ht); 19979 t.moveTo(pt + Ue, vt), t.arc(pt, vt, Ue, 0, 2 * Math.PI, !0), ++c; 19980 break; 19981 case Q.CLOSE_PATH: 19982 t.closePath(), ++c; 19983 break; 19984 case Q.CUSTOM: 19985 d = /** @type {number} */ 19986 I[1], f = I[2]; 19987 const Si = ( 19988 /** @type {import("../../geom/SimpleGeometry.js").default} */ 19989 I[3] 19990 ), x = I[4], M = I.length == 6 ? I[5] : void 0; 19991 Y.geometry = Si, Y.feature = W, c in J || (J[c] = []); 19992 const b = J[c]; 19993 M ? M(h, d, f, 2, b) : (b[0] = h[d], b[1] = h[d + 1], b.length = 2), x(b, Y), ++c; 19994 break; 19995 case Q.DRAW_IMAGE: 19996 d = /** @type {number} */ 19997 I[1], f = /** @type {number} */ 19998 I[2], E = /** @type {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} */ 19999 I[3], g = /** @type {number} */ 20000 I[4], _ = /** @type {number} */ 20001 I[5]; 20002 let T = ( 20003 /** @type {number} */ 20004 I[6] 20005 ); 20006 const w = ( 20007 /** @type {number} */ 20008 I[7] 20009 ), D = ( 20010 /** @type {number} */ 20011 I[8] 20012 ), k = ( 20013 /** @type {number} */ 20014 I[9] 20015 ), F = ( 20016 /** @type {boolean} */ 20017 I[10] 20018 ); 20019 let N = ( 20020 /** @type {number} */ 20021 I[11] 20022 ); 20023 const P = ( 20024 /** @type {import("../../size.js").Size} */ 20025 I[12] 20026 ); 20027 let B = ( 20028 /** @type {number} */ 20029 I[13] 20030 ); 20031 const z = ( 20032 /** @type {"declutter"|"obstacle"|"none"|undefined} */ 20033 I[14] 20034 ), X = ( 20035 /** @type {import("../canvas.js").DeclutterImageWithText} */ 20036 I[15] 20037 ); 20038 if (!E && I.length >= 20) { 20039 C = /** @type {string} */ 20040 I[19], S = /** @type {string} */ 20041 I[20], O = /** @type {string} */ 20042 I[21], R = /** @type {string} */ 20043 I[22]; 20044 const be = this.drawLabelWithPointPlacement_( 20045 C, 20046 S, 20047 O, 20048 R 20049 ); 20050 E = be.label, I[3] = E; 20051 const As = ( 20052 /** @type {number} */ 20053 I[23] 20054 ); 20055 g = (be.anchorX - As) * this.pixelRatio, I[4] = g; 20056 const Te = ( 20057 /** @type {number} */ 20058 I[24] 20059 ); 20060 _ = (be.anchorY - Te) * this.pixelRatio, I[5] = _, T = E.height, I[6] = T, B = E.width, I[13] = B; 20061 } 20062 let V; 20063 I.length >
20063 25 && (V = /** @type {number} */ 20064 I[25]); 20065 let nt, gt, ct; 20066 I.length > 17 ? (nt = /** @type {Array<number>} */ 20067 I[16], gt = /** @type {boolean} */ 20068 I[17], ct = /** @type {boolean} */ 20069 I[18]) : (nt = us, gt = !1, ct = !1), F && K ? N += St : !F && !K && (N -= St); 20070 let bt = 0; 20071 for (; d < f; d += 2) { 20072 if (V && V[bt++] < B / this.pixelRatio) 20073 continue; 20074 const be = this.calculateImageOrLabelDimensions_( 20075 E.width, 20076 E.height, 20077 h[d], 20078 h[d + 1], 20079 B, 20080 T, 20081 g, 20082 _, 20083 D, 20084 k, 20085 N, 20086 P, 20087 r, 20088 nt, 20089 gt || ct, 20090 W 20091 ), As = [ 20092 t, 20093 i, 20094 E, 20095 be, 20096 w, 20097 gt ? ( 20098 /** @type {Array<*>} */ 20099 q 20100 ) : null, 20101 ct ? ( 20102 /** @type {Array<*>} */ 20103 tt 20104 ) : null 20105 ]; 20106 if (l) { 20107 if (z === "none") 20108 continue; 20109 if (z === "obstacle") { 20110 l.insert(be.declutterBox); 20111 continue; 20112 } else { 20113 let Te, ri; 20114 if (X) { 20115 const Se = f - d; 20116 if (!X[Se]) { 20117 X[Se] = As; 20118 continue; 20119 } 20120 if (Te = X[Se], delete X[Se], ri = Gu(Te), l.collides(ri)) 20121 continue; 20122 } 20123 if (l.collides(be.declutterBox)) 20124 continue; 20125 Te && (l.insert(ri), this.replayImageOrLabel_.apply(this, Te)), l.insert(be.declutterBox); 20126 } 20127 } 20128 this.replayImageOrLabel_.apply(this, As); 20129 } 20130 ++c; 20131 break; 20132 case Q.DRAW_CHARS: 20133 const Zt = ( 20134 /** @type {number} */ 20135 I[1] 20136 ), Dt = ( 20137 /** @type {number} */ 20138 I[2] 20139 ), Is = ( 20140 /** @type {number} */ 20141 I[3] 20142 ), is = ( 20143 /** @type {number} */ 20144 I[4] 20145 ); 20146 R = /** @type {string} */ 20147 I[5]; 20148 const Dr = ( 20149 /** @type {number} */ 20150 I[6] 20151 ), Jt = ( 20152 /** @type {number} */ 20153 I[7] 20154 ), Ce = ( 20155 /** @type {number} */ 20156 I[8] 20157 ); 20158 O = /** @type {string} */ 20159 I[9]; 20160 const Ps = ( 20161 /** @type {number} */ 20162 I[10] 20163 ); 20164 C = /** @type {string} */ 20165 I[11], S = /** @type {string} */ 20166 I[12]; 20167 const sc = [ 20168 /** @type {number} */ 20169 I[13], 20170 /** @type {number} */ 20171 I[13] 20172 ], Ea = this.textStates[S], Pn = Ea.font, An = [ 20173 Ea.scale[0] * Jt, 20174 Ea.scale[1] * Jt 20175 ]; 20176 let Ln; 20177 Pn in this.widths_ ? Ln = this.widths_[Pn] : (Ln = {}, this.widths_[Pn] = Ln); 20178 const nc = _g(h, Zt, Dt, 2), rc = Math.abs(An[0]) * wu(Pn, C, Ln); 20179 if (is || rc <= nc) { 20180 const be = this.textStates[S].textAlign, As = (nc - rc) * Hn[be], Te = YC( 20181 h, 20182 Zt, 20183 Dt, 20184 2, 20185 C, 20186 As, 20187 Dr, 20188 Math.abs(An[0]), 20189 wu, 20190 Pn, 20191 Ln, 20192 K ? 0 : this.viewRotation_ 20193 ); 20194 t: 20195 if (Te) { 20196 const ri = []; 20197 let Se, Nr, kr, fe, Re; 20198 if (O) 20199 for (Se = 0, Nr = Te.length; Se < Nr; ++Se) { 20200 Re = Te[Se], kr = /** @type {string} */ 20201 Re[4], fe = this.createLabel(kr, S, "", O), g = /** @type {number} */ 20202 Re[2] + (An[0] < 0 ? -Ps : Ps), _ = Is * fe.height + (0.5 - Is) * 2 * Ps * An[1] / An[0] - Ce; 20203 const oi = this.calculateImageOrLabelDimensions_( 20204 fe.width, 20205 fe.height, 20206 Re[0], 20207 Re[1], 20208 fe.width, 20209 fe.height, 20210 g, 20211 _, 20212 0, 20213 0, 20214 Re[3], 20215 sc, 20216 !1, 20217 us, 20218 !1, 20219 W 20220 ); 20221 if (l && l.collides(oi.declutterBox)) 20222 break t; 20223 ri.push([ 20224 t, 20225 i, 20226 fe, 20227 oi, 20228 1, 20229 null, 20230 null 20231 ]); 20232 } 20233 if (R) 20234 for (Se = 0, Nr = Te.length; Se < Nr; ++Se) { 20235 Re = Te[Se], kr = /** @type {string} */ 20236 Re[4], fe = this.createLabel(kr, S, R, ""), g = /** @type {number} */ 20237 Re[2], _ = Is * fe.height - Ce; 20238 const oi = this.calculateImageOrLabelDimensions_( 20239 fe.width, 20240 fe.height, 20241 Re[0], 20242 Re[1], 20243 fe.width, 20244 fe.height, 20245 g, 20246 _, 20247 0, 20248 0, 20249 Re[3], 20250 sc, 20251 !1, 20252 us, 20253 !1, 20254 W 20255 ); 20256 if (l && l.collides(oi.declutterBox)) 20257 break t; 20258 ri.push([ 20259 t, 20260 i, 20261 fe, 20262 oi, 20263 1, 20264 null, 20265 null 20266 ]); 20267 } 20268 l && l.load(ri.map(Gu)); 20269 for (let oi = 0, Vg = ri.length; oi < Vg; ++oi) 20270 this.replayImageOrLabel_.apply(this, ri[oi]); 20271 } 20272 } 20273 ++c; 20274 break; 20275 case Q.END_GEOMETRY: 20276 if (o !== void 0) { 20277 W = /** @type {import("../../Feature.js").FeatureLike} */ 20278 I[1]; 20279 const be = o(W, wt); 20280 if (be) 20281 return be; 20282 } 20283 ++c; 20284 break; 20285 case Q.FILL: 20286 L ? j++ : this.fill_(t), ++c; 20287 break; 20288 case Q.MOVE_TO_LINE_TO: 20289 for (d = /** @type {number} */ 20290 I[1], f = /** @type {number} */ 20291 I[2], ut = h[d], ft = h[d + 1], y = ut + 0.5 | 0, v = ft + 0.5 | 0, (y !== m || v !== p) && (t.moveTo(ut, ft), m = y, p = v), d += 2; d < f; d += 2) 20292 ut = h[d], ft = h[d + 1], y = ut + 0.5 | 0, v = ft + 0.5 | 0, (d == f - 2 || y !== m || v !== p) && (t.lineTo(ut, ft), m = y, p = v); 20293 ++c; 20294 break; 20295 case Q.SET_FILL_STYLE: 20296 q = I, this.alignFill_ = I[2], j && (this.fill_(t), j = 0, $ && (t.stroke(), $ = 0)), t.fillStyle = /** @type {import("../../colorlike.js").ColorLike} */ 20297 I[1], ++c; 20298 break; 20299 case Q.SET_STROKE_STYLE: 20300 tt = I, $ && (t.stroke(), $ = 0), this.setStrokeStyle_( 20301 t, 20302 /** @type {Array<*>} */ 20303 I 20304 ), ++c; 20305 break; 20306 case Q.STROKE: 20307 L ? $++ : t.stroke(), ++c; 20308 break; 20309 default: 20310 ++c; 20311 break; 20312 } 20313 } 20314 j && this.fill_(t), $ && t.stroke(); 20315 } 20316 /** 20317 * @param {CanvasRenderingContext2D} context Context. 20318 * @param {number} contextScale Scale of the context. 20319 * @param {import("../../transform.js").Transform} transform Transform. 20320 * @param {number} viewRotation View rotation. 20321 * @param {boolean} snapToPixel Snap point symbols and text to integer pixels. 20322 * @param {import("rbush").default} [declutterTree] Declutter tree. 20323 */ 20324 execute(t, i, s, n, r, o) { 20325 this.viewRotation_ = n, this.execute_( 20326 t, 20327 i, 20328 s, 20329 this.instructions, 20330 r, 20331 void 0, 20332 void 0, 20333 o 20334 ); 20335 } 20336 /** 20337 * @param {CanvasRenderingContext2D} context Context. 20338 * @param {import("../../transform.js").Transform} transform Transform. 20339 * @param {number} viewRotation View rotation. 20340 * @param {FeatureCallback<T>}
20340 [featureCallback] Feature callback. 20341 * @param {import("../../extent.js").Extent} [hitExtent] Only check 20342 * features that intersect this extent. 20343 * @return {T|undefined} Callback result. 20344 * @template T 20345 */ 20346 executeHitDetection(t, i, s, n, r) { 20347 return this.viewRotation_ = s, this.execute_( 20348 t, 20349 1, 20350 i, 20351 this.hitDetectionInstructions, 20352 !0, 20353 n, 20354 r 20355 ); 20356 } 20357} 20358const HC = qC, Ba = ["Polygon", "Circle", "LineString", "Image", "Text", "Default"]; 20359class ZC { 20360 /** 20361 * @param {import("../../extent.js").Extent} maxExtent Max extent for clipping. When a 20362 * `maxExtent` was set on the Builder for this executor group, the same `maxExtent` 20363 * should be set here, unless the target context does not exceed that extent (which 20364 * can be the case when rendering to tiles). 20365 * @param {number} resolution Resolution. 20366 * @param {number} pixelRatio Pixel ratio. 20367 * @param {boolean} overlaps The executor group can have overlapping geometries. 20368 * @param {!Object<string, !Object<import("../canvas.js").BuilderType, import("../canvas.js").SerializableInstructions>>} allInstructions 20369 * The serializable instructions. 20370 * @param {number} [renderBuffer] Optional rendering buffer. 20371 */ 20372 constructor(t, i, s, n, r, o) { 20373 this.maxExtent_ = t, this.overlaps_ = n, this.pixelRatio_ = s, this.resolution_ = i, this.renderBuffer_ = o, this.executorsByZIndex_ = {}, this.hitDetectionContext_ = null, this.hitDetectionTransform_ = Qe(), this.createExecutors_(r); 20374 } 20375 /** 20376 * @param {CanvasRenderingContext2D} context Context. 20377 * @param {import("../../transform.js").Transform} transform Transform. 20378 */ 20379 clip(t, i) { 20380 const s = this.getClipCoords(i); 20381 t.beginPath(), t.moveTo(s[0], s[1]), t.lineTo(s[2], s[3]), t.lineTo(s[4], s[5]), t.lineTo(s[6], s[7]), t.clip(); 20382 } 20383 /** 20384 * Create executors and populate them using the provided instructions. 20385 * @private 20386 * @param {!Object<string, !Object<import("../canvas.js").BuilderType, import("../canvas.js").SerializableInstructions>>} allInstructions The serializable instructions 20387 */ 20388 createExecutors_(t) { 20389 for (const i in t) { 20390 let s = this.executorsByZIndex_[i]; 20391 s === void 0 && (s = {}, this.executorsByZIndex_[i] = s); 20392 const n = t[i]; 20393 for (const r in n) { 20394 const o = n[r]; 20395 s[r] = new HC( 20396 this.resolution_, 20397 this.pixelRatio_, 20398 this.overlaps_, 20399 o 20400 ); 20401 } 20402 } 20403 } 20404 /** 20405 * @param {Array<import("../canvas.js").BuilderType>} executors Executors. 20406 * @return {boolean} Has executors of the provided types. 20407 */ 20408 hasExecutors(t) { 20409 for (const i in this.executorsByZIndex_) { 20410 const s = this.executorsByZIndex_[i]; 20411 for (let n = 0, r = t.length; n < r; ++n) 20412 if (t[n] in s) 20413 return !0; 20414 } 20415 return !1; 20416 } 20417 /** 20418 * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate. 20419 * @param {number} resolution Resolution. 20420 * @param {number} rotation Rotation. 20421 * @param {number} hitTolerance Hit tolerance in pixels. 20422 * @param {function(import("../../Feature.js").FeatureLike, import("../../geom/SimpleGeometry.js").default, number): T} callback Feature callback. 20423 * @param {Array<import("../../Feature.js").FeatureLike>} declutteredFeatures Decluttered features. 20424 * @return {T|undefined} Callback result. 20425 * @template T 20426 */ 20427 forEachFeatureAtCoordinate(t, i, s, n, r, o) { 20428 n = Math.round(n); 20429 const a = n * 2 + 1, l = si( 20430 this.hitDetectionTransform_, 20431 n + 0.5, 20432 n + 0.5, 20433 1 / i, 20434 -1 / i, 20435 -s, 20436 -t[0], 20437 -t[1] 20438 ), h = !this.hitDetectionContext_; 20439 h && (this.hitDetectionContext_ = re( 20440 a, 20441 a, 20442 void 0, 20443 { willReadFrequently: !0 } 20444 )); 20445 const c = this.hitDetectionContext_; 20446 c.canvas.width !== a || c.canvas.height !== a ? (c.canvas.width = a, c.canvas.height = a) : h || c.clearRect(0, 0, a, a); 20447 let u; 20448 this.renderBuffer_ !== void 0 && (u = ve(), Yn(u, t), Es( 20449 u, 20450 i * (this.renderBuffer_ + n), 20451 u 20452 )); 20453 const d = JC(n); 20454 let f; 20455 function g(C, S) { 20456 const O = c.getImageData( 20457 0, 20458 0, 20459 a, 20460 a 20461 ).data; 20462 for (let R = 0, j = d.length; R < j; R++) 20463 if (O[d[R]] > 0) { 20464 if (!o || f !== "Image" && f !== "Text" || o.includes(C)) {
20465 const $ = (d[R] - 3) / 4, q = n - $ % a, tt = n - ($ / a | 0), J = r(C, S, q * q + tt * tt); 20466 if (J) 20467 return J; 20468 } 20469 c.clearRect(0, 0, a, a); 20470 break; 20471 } 20472 } 20473 const _ = Object.keys(this.executorsByZIndex_).map(Number); 20474 _.sort(Cs); 20475 let m, p, y, v, E; 20476 for (m = _.length - 1; m >= 0; --m) { 20477 const C = _[m].toString(); 20478 for (y = this.executorsByZIndex_[C], p = Ba.length - 1; p >= 0; --p) 20479 if (f = Ba[p], v = y[f], v !== void 0 && (E = v.executeHitDetection( 20480 c, 20481 l, 20482 s, 20483 g, 20484 u 20485 ), E)) 20486 return E; 20487 } 20488 } 20489 /** 20490 * @param {import("../../transform.js").Transform} transform Transform. 20491 * @return {Array<number>|null} Clip coordinates. 20492 */ 20493 getClipCoords(t) { 20494 const i = this.maxExtent_; 20495 if (!i) 20496 return null; 20497 const s = i[0], n = i[1], r = i[2], o = i[3], a = [s, n, s, o, r, o, r, n]; 20498 return ps(a, 0, 8, 2, t, a), a; 20499 } 20500 /** 20501 * @return {boolean} Is empty. 20502 */ 20503 isEmpty() { 20504 return un(this.executorsByZIndex_); 20505 } 20506 /** 20507 * @param {CanvasRenderingContext2D} context Context. 20508 * @param {number} contextScale Scale of the context. 20509 * @param {import("../../transform.js").Transform} transform Transform. 20510 * @param {number} viewRotation View rotation. 20511 * @param {boolean} snapToPixel Snap point symbols and test to integer pixel. 20512 * @param {Array<import("../canvas.js").BuilderType>} [builderTypes] Ordered replay types to replay. 20513 * Default is {@link module:ol/render/replay~ORDER} 20514 * @param {import("rbush").default} [declutterTree] Declutter tree. 20515 */ 20516 execute(t, i, s, n, r, o, a) { 20517 const l = Object.keys(this.executorsByZIndex_).map(Number); 20518 l.sort(Cs), this.maxExtent_ && (t.save(), this.clip(t, s)), o = o || Ba; 20519 let h, c, u, d, f, g; 20520 for (a && l.reverse(), h = 0, c = l.length; h < c; ++h) { 20521 const _ = l[h].toString(); 20522 for (f = this.executorsByZIndex_[_], u = 0, d = o.length; u < d; ++u) { 20523 const m = o[u]; 20524 g = f[m], g !== void 0 && g.execute( 20525 t, 20526 i, 20527 s, 20528 n, 20529 r, 20530 a 20531 ); 20532 } 20533 } 20534 this.maxExtent_ && t.restore(); 20535 } 20536} 20537const Ua = {}; 20538function JC(e) { 20539 if (Ua[e] !== void 0) 20540 return Ua[e]; 20541 const t = e * 2 + 1, i = e * e, s = new Array(i + 1); 20542 for (let r = 0; r <= e; ++r) 20543 for (let o = 0; o <= e; ++o) { 20544 const a = r * r + o * o; 20545 if (a > i) 20546 break; 20547 let l = s[a]; 20548 l || (l = [], s[a] = l), l.push(((e + r) * t + (e + o)) * 4 + 3), r > 0 && l.push(((e - r) * t + (e + o)) * 4 + 3), o > 0 && (l.push(((e + r) * t + (e - o)) * 4 + 3), r > 0 && l.push(((e - r) * t + (e - o)) * 4 + 3)); 20549 } 20550 const n = []; 20551 for (let r = 0, o = s.length; r < o; ++r) 20552 s[r] && n.push(...s[r]); 20553 return Ua[e] = n, n; 20554} 20555const ju = ZC; 20556class QC extends Cg { 20557 /** 20558 * @param {CanvasRenderingContext2D} context Context. 20559 * @param {number} pixelRatio Pixel ratio. 20560 * @param {import("../../extent.js").Extent} extent Extent. 20561 * @param {import("../../transform.js").Transform} transform Transform. 20562 * @param {number} viewRotation View rotation. 20563 * @param {number} [squaredTolerance] Optional squared tolerance for simplification. 20564 * @param {import("../../proj.js").TransformFunction} [userTransform] Transform from user to view projection. 20565 */ 20566 constructor(t, i, s, n, r, o, a) { 20567 super(), this.context_ = t, this.pixelRatio_ = i, this.extent_ = s, this.transform_ = n, this.transformRotation_ = n ? Tr(Math.atan2(n[1], n[0]), 10) : 0, this.viewRotation_ = r, this.squaredTolerance_ = o, this.userTransform_ = a, this.contextFillState_ = null, this.contextStrokeState_ = null, this.contextTextState_ = null, this.fillState_ = null, this.strokeState_ = null, this.image_ = null, this.imageAnchorX_ = 0, this.imageAnchorY_ = 0, this.imageHeight_ = 0, this.imageOpacity_ = 0, this.imageOriginX_ = 0, this.imageOriginY_ = 0, this.imageRotateWithView_ = !1, this.imageRotation_ = 0, this.imageScale_ = [0, 0], this.imageWidth_ = 0, this.text_ = "", this.textOffsetX_ = 0, this.textOffsetY_ = 0, this.textRotateWithView_ = !1, this.textRotation_ = 0, this.textScale_ = [0, 0], this.textFillState_ = null, this.textStrokeState_ = null, this.textState_ = null, this.pixelCoordinates_ = [], this.tmpLocalTransform_ = Qe(); 20568 } 20569 /** 20570 * @param {Array<number>} flatCoordinates Flat coordinates. 20571 * @param {number} offset Offset. 20572 * @param {number} end End. 20573 * @param {number} stride Stride. 20574 * @private 20575 */ 20576 drawImages_(t, i, s, n) { 20577 if (!this.image_) 20578 return; 20579 const r = ps( 20580 t, 20581 i, 20582 s, 20583 n, 20584 this.transform_, 20585 this.pixelCoordinates_ 20586 ), o = this.context_, a = this.tmpLocalTransform_, l = o.globalAlpha; 20587 this.imageOpacity_ != 1 && (o.globalAlpha = l * this.imageOpacity_); 20588 let h = this.imageRotation_; 20589 this.transformRotation_ === 0 && (h -= this.viewRotation_), this.imageRotateWithView_ && (h += this.viewRotation_); 20590 for (let c = 0, u = r.length; c < u; c += 2) { 20591 const d = r[c] - this.imageAnchorX_, f = r[c + 1] - this.imageAnchorY_; 20592 if (h !== 0 || this.imageScale_[0] != 1 || this.imageScale_[1] != 1) { 20593 const g = d + this.imageAnchorX_, _ = f + this.imageAnchorY_; 20594 si( 20595 a, 20596 g, 20597 _, 20598 1, 20599 1, 20600 h, 20601 -g, 20602 -_ 20603 ), o.setTransform.apply(o, a), o.translate(g, _), o.scale(this.imageScale_[0], this.imageScale_[1]), o.drawImage( 20604 this.image_, 20605 this.imageOriginX_, 20606 this.imageOriginY_, 20607 this.imageWidth_, 20608 this.imageHeight_, 20609 -this.imageAnchorX_, 20610 -this.imageAnchorY_, 20611 this.imageWidth_, 20612 this.imageHeight_ 20613 ), o.setTransform(1, 0, 0, 1, 0, 0); 20614 } else 20615 o.drawImage( 20616 this.image_, 20617 this.imageOriginX_, 20618 this.imageOriginY_, 20619 this.imageWidth_, 20620 this.imageHeight_, 20621 d, 20622 f, 20623 this.imageWidth_, 20624 this.imageHeight_ 20625 ); 20626 } 20627 this.imageOpacity_ != 1 && (o.globalAlpha = l); 20628 } 20629 /** 20630 * @param {Array<number>} flatCoordinates Flat coordinates. 20631 * @param {number} offset Offset. 20632 * @param {number} end End. 20633 * @param {number} stride Stride. 20634 * @private 20635 */ 20636 drawText_(t, i, s, n) { 20637 if (!this.textState_ || this.text_ === "") 20638 return; 20639 this.textFillState_ && this.setContextFillState_(this.textFillState_), this.textStrokeState_ && this.setContextStrokeState_(this.textStrokeState_), this.setContextTextState_(this.textState_); 20640 const r = ps( 20641 t, 20642 i, 20643 s, 20644 n, 20645 this.transform_, 20646 this.pixelCoordinates_ 20647 ), o = this.context_; 20648 let a = this.textRotation_; 20649 for (this.transformRotation_ === 0 && (a -= this.viewRotation_), this.textRotateWithView_ && (a += this.viewRotation_); i < s; i += n) { 20650 const l = r[i] + this.textOffsetX_, h = r[i + 1] + this.textOffsetY_; 20651 a !== 0 || this.textScale_[0] != 1 || this.textScale_[1] != 1 ? (o.translate(l - this.textOffsetX_, h - this.textOffsetY_), o.rotate(a), o.translate(this.textOffsetX_, this.textOffsetY_), o.scale(this.textScale_[0], this.textScale_[1]), this.textStrokeState_ && o.strokeText(this.text_, 0, 0
20651), this.textFillState_ && o.fillText(this.text_, 0, 0), o.setTransform(1, 0, 0, 1, 0, 0)) : (this.textStrokeState_ && o.strokeText(this.text_, l, h), this.textFillState_ && o.fillText(this.text_, l, h)); 20652 } 20653 } 20654 /** 20655 * @param {Array<number>} flatCoordinates Flat coordinates. 20656 * @param {number} offset Offset. 20657 * @param {number} end End. 20658 * @param {number} stride Stride. 20659 * @param {boolean} close Close. 20660 * @private 20661 * @return {number} end End. 20662 */ 20663 moveToLineTo_(t, i, s, n, r) { 20664 const o = this.context_, a = ps( 20665 t, 20666 i, 20667 s, 20668 n, 20669 this.transform_, 20670 this.pixelCoordinates_ 20671 ); 20672 o.moveTo(a[0], a[1]); 20673 let l = a.length; 20674 r && (l -= 2); 20675 for (let h = 2; h < l; h += 2) 20676 o.lineTo(a[h], a[h + 1]); 20677 return r && o.closePath(), s; 20678 } 20679 /** 20680 * @param {Array<number>} flatCoordinates Flat coordinates. 20681 * @param {number} offset Offset. 20682 * @param {Array<number>} ends Ends. 20683 * @param {number} stride Stride. 20684 * @private 20685 * @return {number} End. 20686 */ 20687 drawRings_(t, i, s, n) { 20688 for (let r = 0, o = s.length; r < o; ++r) 20689 i = this.moveToLineTo_( 20690 t, 20691 i, 20692 s[r], 20693 n, 20694 !0 20695 ); 20696 return i; 20697 } 20698 /** 20699 * Render a circle geometry into the canvas. Rendering is immediate and uses 20700 * the current fill and stroke styles. 20701 * 20702 * @param {import("../../geom/Circle.js").default} geometry Circle geometry. 20703 * @api 20704 */ 20705 drawCircle(t) { 20706 if (this.squaredTolerance_ && (t = /** @type {import("../../geom/Circle.js").default} */ 20707 t.simplifyTransformed( 20708 this.squaredTolerance_, 20709 this.userTransform_ 20710 )), !!ee(this.extent_, t.getExtent())) { 20711 if (this.fillState_ || this.strokeState_) { 20712 this.fillState_ && this.setContextFillState_(this.fillState_), this.strokeState_ && this.setContextStrokeState_(this.strokeState_); 20713 const i = TE( 20714 t, 20715 this.transform_, 20716 this.pixelCoordinates_ 20717 ), s = i[2] - i[0], n = i[3] - i[1], r = Math.sqrt(s * s + n * n), o = this.context_; 20718 o.beginPath(), o.arc( 20719 i[0], 20720 i[1], 20721 r, 20722 0, 20723 2 * Math.PI 20724 ), this.fillState_ && o.fill(), this.strokeState_ && o.stroke(); 20725 } 20726 this.text_ !== "" && this.drawText_(t.getCenter(), 0, 2, 2); 20727 } 20728 } 20729 /** 20730 * Set the rendering style. Note that since this is an immediate rendering API, 20731 * any `zIndex` on the provided style will be ignored. 20732 * 20733 * @param {import("../../style/Style.js").default} style The rendering style. 20734 * @api 20735 */ 20736 setStyle(t) { 20737 this.setFillStrokeStyle(t.getFill(), t.getStroke()), this.setImageStyle(t.getImage()), this.setTextStyle(t.getText()); 20738 } 20739 /** 20740 * @param {import("../../transform.js").Transform} transform Transform. 20741 */ 20742 setTransform(t) { 20743 this.transform_ = t; 20744 } 20745 /** 20746 * Render a geometry into the canvas. Call 20747 * {@link module:ol/render/canvas/Immediate~CanvasImmediateRenderer#setStyle renderer.setStyle()} first to set the rendering style. 20748 * 20749 * @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry The geometry to render. 20750 * @api 20751 */ 20752 drawGeometry(t) { 20753 switch (t.getType()) { 20754 case "Point": 20755 this.drawPoint( 20756 /** @type {import("../../geom/Point.js").default} */ 20757 t 20758 ); 20759 break; 20760 case "LineString": 20761 this.drawLineString( 20762 /** @type {import("../../geom/LineString.js").default} */ 20763 t 20764 ); 20765 break; 20766 case "Polygon": 20767 this.drawPolygon( 20768 /** @type {import("../../geom/Polygon.js").default} */ 20769 t 20770 ); 20771 break; 20772 case "MultiPoint": 20773 this.drawMultiPoint( 20774 /** @type {import("../../geom/MultiPoint.js").default} */ 20775 t 20776 ); 20777 break; 20778 case "MultiLineString": 20779 this.drawMultiLineString( 20780 /** @type {import("../../geom/MultiLineString.js").default} */ 20781 t 20782 ); 20783 break; 20784 case "MultiPolygon": 20785 this.drawMultiPolygon( 20786 /** @type {import("../../geom/MultiPolygon.js").default} */ 20787 t 20788 ); 20789 break; 20790 case "GeometryCollection": 20791 this.drawGeometryCollection( 20792 /** @type {import("../../geom/GeometryCollection.js").default} */ 20793 t 20794 ); 20795 break; 20796 case "Circle": 20797 this.drawCircle( 20798 /** @type {import("../../geom/Circle.js").default} */ 20799 t 20800 ); 20801 break; 20802 } 20803 } 20804 /** 20805 * Render a feature into the canvas. Note that any `zIndex` on the provided 20806 * style will be ignored - features are rendered immediately in the order that 20807 * this method is called. If you need `zIndex` support, you should be using an 20808 * {@link module:ol/layer/Vector~VectorLayer} instead. 20809 * 20810 * @param {import("../../Feature.js").default} feature Feature. 20811 * @param {import("../../style/Style.js").default} style Style. 20812 * @api 20813 */ 20814 drawFeature(t, i) { 20815 const s = i.getGeometryFunction()(t); 20816 s && (this.setStyle(i), this.drawGeometry(s)); 20817 } 20818 /** 20819 * Render a GeometryCollection to the canvas. Rendering is immediate and 20820 * uses the current styles appropriate for each geometry in the collection. 20821 * 20822 * @param {import("../../geom/GeometryCollection.js").default} geometry Geometry collection. 20823 */ 20824 drawGeometryCollection(t) { 20825 const i = t.getGeometriesArray(); 20826 for (let s = 0, n = i.length; s < n; ++s) 20827 this.drawGeometry(i[s]); 20828 } 20829 /** 20830 * Render a Point geometry into the canvas. Rendering is immediate and uses 20831 * the current style. 20832 * 20833 * @param {import("../../geom/Point.js").default|import("../Feature.js").default} geometry Point geometry. 20834 */ 20835 drawPoint(t) { 20836 this.squaredTolerance_ && (t = /** @type {import("../../geom/Point.js").default} */ 20837 t.simplifyTransformed( 20838 this.squaredTolerance_, 20839 this.userTransform_ 20840 )); 20841 const i = t.getFlatCoordinates(), s = t.getStride(); 20842 this.image_ && this.drawImages_(i, 0, i.length, s), this.text_ !== "" && this.drawText_(i, 0, i.length, s); 20843 } 20844 /** 20845 * Render a MultiPoint geometry into the canvas. Rendering is immediate and 20846 * uses the current style. 20847 * 20848 * @param {import("../../geom/MultiPoint.js").default|import("../Feature.js").default} geometry MultiPoint geometry. 20849 */ 20850 drawMultiPoint(t) { 20851 this.squaredTolerance_ && (t = /** @type {import("../../geom/MultiPoint.js").default} */ 20852 t.simplifyTransformed( 20853 this.squaredTolerance_, 20854 this.userTransform_ 20855 )); 20856 const i = t.getFlatCoordinates(), s = t.getStride(); 20857 this.image_ && this.drawImages_(i, 0, i.length, s), this.text_ !== "" && this.drawText_(i, 0, i.length, s); 20858 } 20859 /** 20860 * Render a LineString into the canvas. Rendering is immediate and uses 20861 * the current style. 20862 * 20863 * @param {import("../../geom/LineString.js").default|import("../Feature.js").default} geometry LineString geometry. 20864 */ 20865 drawLineString(t) { 20866 if (this.squaredTolerance_ && (t = /** @type {import("../../geom/LineString.js").default} */ 20867 t.simplifyTransformed( 20868 this.squaredTolerance_, 20869 this.userTransform_ 20870 )), !!ee(this.extent_, t.getExtent())) { 20871 if (this.strokeState_) { 20872 this.setContextStrokeState_(this.strokeState_); 20873 const i = this.context_, s = t.getFlatCoordinates(); 20874 i.beginPath(), this.moveToLineTo_( 20875 s, 20876 0, 20877 s.length, 20878 t.getStride(), 20879 !1 20880 ), i.stroke(); 20881 } 20882 if (this.text_ !== "") { 20883 const i = t.getFlatMidpoint(); 20884 this.drawText_(i, 0, 2, 2); 20885 } 20886 } 20887 } 20888 /** 20889 * Render a MultiLineString geometry into the canvas. Rendering is immediate 20890 * and uses the current style. 20891 * 20892 * @param {import("../../geom/MultiLineString.js").default|import("../Feature.js").default} geometry MultiLineString geometry. 20893 */ 20894 drawMultiLineString(t) { 20895 this.squaredTolerance_ && (t = /** @type {import("../../geom/MultiLineString.js").default} */ 20896 t.simplifyTransformed( 20897 this.squaredTolerance_, 20898 this.userTransform_ 20899 )); 20900 const i = t.getExtent(); 20901 if (ee(this.extent_, i)) { 20902 if (this.strokeState_) { 20903 this.setContextStrokeState_(this.strokeState_); 20904 const s = this.context_, n = t.getFlatCoordinates(); 20905 let r = 0; 20906 const o = ( 20907 /** @type {Array<number>} */ 20908 t.getEnds() 20909 ), a = t.getStride(); 20910 s.beginPath(); 20911 for (let l = 0, h = o.length; l < h; ++l) 20912 r = this.moveToLineTo_( 20913 n, 20914 r, 20915 o[l], 20916 a, 20917 !1 20918 ); 20919 s.stroke(); 20920 } 20921 if (this.text_ !== "") { 20922 const s = t.getFlatMidpoints(); 20923 this.drawText_(s, 0, s.length, 2); 20924 } 20925 } 20926 } 20927 /** 20928 * Render a Polygon geometry into the canvas. Rendering is immediate and uses 20929 * the current style. 20930 * 20931 * @param {import("../../geom/Polygon.js").default|import("../Feature.js").default} geometry Polygon geometry. 20932 */ 20933 drawPolygon(t) { 20934 if (this.squaredTolerance_ && (t = /** @type {import("../../geom/Polygon.js").default} */ 20935 t.simplifyTransformed( 20936 this.squaredTolerance_, 20937 this.userTransform_ 20938 )), !!ee(this.extent_, t.getExtent())) { 20939 if (this.strokeState_ || this.fillState_) { 20940 this.fillState_ && this.setContextFillState_(this.fillState_), this.strokeState_ && this.setContextStrokeState_(this.strokeState_); 20941 const i = this.context_; 20942 i.beginPath(), this.drawRings_( 20943 t.getOrientedFlatCoordinates(), 20944 0, 20945 /** @type {Array<number>} */ 20946 t.getEnds(), 20947 t.getStride() 20948 ), this.fillState_ && i.fill(), this.strokeState_ && i.stroke(); 20949 } 20950 if (this.text_ !== "") { 20951 const i = t.getFlatInteriorPoint(); 20952 this.drawText_(i, 0, 2, 2); 20953 } 20954 } 20955 } 20956 /** 20957 * Render MultiPolygon geometry into the canvas. Rendering is immediate and 20958 * uses the current style. 20959 * @param {import("../../geom/MultiPolygon.js").default} geometry MultiPolygon geometry. 20960 */ 20961 drawMultiPolygon(t) { 20962 if (this.squaredTolerance_ && (t = /** @type {import("../../geom/MultiPolygon.js").default} */ 20963 t.simplifyTransformed( 20964 this.squaredTolerance_, 20965 this.userTransform_ 20966 )), !!ee(this.extent_, t.getExtent())) { 20967 if (this.strokeState_ || this.fillState_) { 20968 this.fillState_ && this.setContextFillState_(this.fillState_), this.strokeState_ && this.setContextStrokeState_(this.strokeState_); 20969 const i = this.context_, s = t.getOrientedFlatCoordinates(); 20970 let n = 0; 20971 const r = t.getEndss(), o = t.getStride(); 20972 i.beginPath(); 20973 for (let a = 0, l = r.length; a < l; ++a) { 20974 const h = r[a]; 20975 n = this.drawRings_(s, n, h, o); 20976 } 20977 this.fillState_ && i.fill(), this.strokeState_ && i.stroke(); 20978 } 20979 if (this.text_ !== "") { 20980 const i = t.getFlatInteriorPoints(); 20981 this.drawText_(i, 0, i.length, 2); 20982 } 20983 } 20984 } 20985 /** 20986 * @param {import("../canvas.js").FillState} fillState Fill state. 20987 * @private 20988 */ 20989 setContextFillState_(t) { 20990 const i = this.context_, s = this.contextFillState_; 20991 s ? s.fillStyle != t.fillStyle && (s.fillStyle = t.fillStyle, i.fillStyle = t.fillStyle) : (i.fillStyle = t.fillStyle, this.contextFillState_ = { 20992 fillStyle: t.fillStyle 20993 }); 20994 } 20995 /** 20996 * @param {import("../canvas.js").StrokeState} strokeState Stroke state. 20997 * @private 20998 */ 20999 setContextStrokeState_(t) { 21000 const i = this.context_, s = this.contextStrokeState_; 21001 s ? (s.lineCap != t.lineCap && (s.lineCap = t.lineCap, i.lineCap = t.lineCap), bi(s.lineDash, t.lineDash) || i.setLineDash( 21002 s.lineDash = t.lineDash 21003 ), s.lineDashOffset != t.lineDashOffset && (s.lineDashOffset = t.lineDashOffset, i.lineDashOffset = t.lineDashOffset), s.lineJoin != t.lineJoin && (s.lineJoin = t.lineJoin, i.lineJoin = t.lineJoin), s.lineWidth != t.lineWidth && (s.lineWidth = t.lineWidth, i.lineWidth = t.lineWidth), s.miterLimit != t.miter
21003Limit && (s.miterLimit = t.miterLimit, i.miterLimit = t.miterLimit), s.strokeStyle != t.strokeStyle && (s.strokeStyle = t.strokeStyle, i.strokeStyle = t.strokeStyle)) : (i.lineCap = t.lineCap, i.setLineDash(t.lineDash), i.lineDashOffset = t.lineDashOffset, i.lineJoin = t.lineJoin, i.lineWidth = t.lineWidth, i.miterLimit = t.miterLimit, i.strokeStyle = t.strokeStyle, this.contextStrokeState_ = { 21004 lineCap: t.lineCap, 21005 lineDash: t.lineDash, 21006 lineDashOffset: t.lineDashOffset, 21007 lineJoin: t.lineJoin, 21008 lineWidth: t.lineWidth, 21009 miterLimit: t.miterLimit, 21010 strokeStyle: t.strokeStyle 21011 }); 21012 } 21013 /** 21014 * @param {import("../canvas.js").TextState} textState Text state. 21015 * @private 21016 */ 21017 setContextTextState_(t) { 21018 const i = this.context_, s = this.contextTextState_, n = t.textAlign ? t.textAlign : fr; 21019 s ? (s.font != t.font && (s.font = t.font, i.font = t.font), s.textAlign != n && (s.textAlign = n, i.textAlign = n), s.textBaseline != t.textBaseline && (s.textBaseline = t.textBaseline, i.textBaseline = t.textBaseline)) : (i.font = t.font, i.textAlign = n, i.textBaseline = t.textBaseline, this.contextTextState_ = { 21020 font: t.font, 21021 textAlign: n, 21022 textBaseline: t.textBaseline 21023 }); 21024 } 21025 /** 21026 * Set the fill and stroke style for subsequent draw operations. To clear 21027 * either fill or stroke styles, pass null for the appropriate parameter. 21028 * 21029 * @param {import("../../style/Fill.js").default} fillStyle Fill style. 21030 * @param {import("../../style/Stroke.js").default} strokeStyle Stroke style. 21031 */ 21032 setFillStrokeStyle(t, i) { 21033 if (!t) 21034 this.fillState_ = null; 21035 else { 21036 const s = t.getColor(); 21037 this.fillState_ = { 21038 fillStyle: Ze( 21039 s || yi 21040 ) 21041 }; 21042 } 21043 if (!i) 21044 this.strokeState_ = null; 21045 else { 21046 const s = i.getColor(), n = i.getLineCap(), r = i.getLineDash(), o = i.getLineDashOffset(), a = i.getLineJoin(), l = i.getWidth(), h = i.getMiterLimit(), c = r || hr; 21047 this.strokeState_ = { 21048 lineCap: n !== void 0 ? n : Do, 21049 lineDash: this.pixelRatio_ === 1 ? c : c.map((u) => u * this.pixelRatio_), 21050 lineDashOffset: (o || cr) * this.pixelRatio_, 21051 lineJoin: a !== void 0 ? a : Mn, 21052 lineWidth: (l !== void 0 ? l : gr) * this.pixelRatio_, 21053 miterLimit: h !== void 0 ? h : ur, 21054 strokeStyle: Ze( 21055 s || dr 21056 ) 21057 }; 21058 } 21059 } 21060 /** 21061 * Set the image style for subsequent draw operations. Pass null to remove 21062 * the image style. 21063 * 21064 * @param {import("../../style/Image.js").default} imageStyle Image style. 21065 */ 21066 setImageStyle(t) { 21067 let i; 21068 if (!t || !(i = t.getSize())) { 21069 this.image_ = null; 21070 return; 21071 } 21072 const s = t.getPixelRatio(this.pixelRatio_), n = t.getAnchor(), r = t.getOrigin(); 21073 this.image_ = t.getImage(this.pixelRatio_), this.imageAnchorX_ = n[0] * s, this.imageAnchorY_ = n[1] * s, this.imageHeight_ = i[1] * s, this.imageOpacity_ = t.getOpacity(), this.imageOriginX_ = r[0], this.imageOriginY_ = r[1], this.imageRotateWithView_ = t.getRotateWithView(), this.imageRotation_ = t.getRotation(); 21074 const o = t.getScaleArray(); 21075 this.imageScale_ = [ 21076 o[0] * this.pixelRatio_ / s, 21077 o[1] * this.pixelRatio_ / s 21078 ], this.imageWidth_ = i[0] * s; 21079 } 21080 /** 21081 * Set the text style for subsequent draw operations. Pass null to 21082 * remove the text style. 21083 * 21084 * @param {import("../../style/Text.js").default} textStyle Text style. 21085 */ 21086 setTextStyle(t) { 21087 if (!t) 21088 this.text_ = ""; 21089 else { 21090 const i = t.getFill(); 21091 if (!i) 21092 this.textFillState_ = null; 21093 else { 21094 const f = i.getColor(); 21095 this.textFillState_ = { 21096 fillStyle: Ze( 21097 f || yi 21098 ) 21099 }; 21100 } 21101 const s = t.getStroke(); 21102 if (!s) 21103 this.textStrokeState_ = null; 21104 else { 21105 const f = s.getColor(), g = s.getLineCap(), _ = s.getLineDash(), m = s.getLineDashOffset(), p = s.getLineJoin(), y = s.getWidth(), v = s.getMiterLimit(); 21106 this.textStrokeState_ = { 21107 lineCap: g !== void 0 ? g : Do, 21108 lineDash: _ || hr, 21109 lineDashOffset: m || cr, 21110 lineJoin: p !== void 0 ? p : Mn, 21111 lineWidth: y !== void 0 ? y : gr, 21112 miterLimit: v !== void 0 ? v : ur, 21113 strokeStyle: Ze( 21114 f || dr 21115 ) 21116 }; 21117 } 21118 const n = t.getFont(), r = t.getOffsetX(), o = t.getOffsetY(), a = t.getRotateWithView(), l = t.getRotation(), h = t.getScaleArray(), c = t.getText(), u = t.getTextAlign(), d = t.getTextBaseline(); 21119 this.textState_ = { 21120 font: n !== void 0 ? n : sg, 21121 textAlign: u !== void 0 ? u : fr, 21122 textBaseline: d !== void 0 ? d : No 21123 }, this.text_ = c !== void 0 ? Array.isArray(c) ? c.reduce((f, g, _) => f += _ % 2 ? " " : g, "") : c : "", this.textOffsetX_ = r !== void 0 ? this.pixelRatio_ * r : 0, this.textOffsetY_ = o !== void 0 ? this.pixelRatio_ * o : 0, this.textRotateWithView_ = a !== void 0 ? a : !1, this.textRotation_ = l !== void 0 ? l : 0, this.textScale_ = [ 21124 this.pixelRatio_ * h[0], 21125 this.pixelRatio_ * h[1] 21126 ]; 21127 } 21128 } 21129} 21130const tb = QC, qe = 0.5; 21131function eb(e, t, i, s, n, r, o) { 21132 const a = e[0] * qe, l = e[1] * qe, h = re(a, l); 21133 h.imageSmoothingEnabled = !1; 21134 const c = h.canvas, u = new tb( 21135 h, 21136 qe, 21137 n, 21138 null, 21139 o 21140 ), d = i.length, f = Math.floor((256 * 256 * 256 - 1) / d), g = {}; 21141 for (let m = 1; m <= d; ++m) { 21142 const p = i[m - 1], y = p.getStyleFunction() || s; 21143 if (!s) 21144 continue; 21145 let v = y(p, r); 21146 if (!v) 21147 continue; 21148 Array.isArray(v) || (v = [v]); 21149 const C = (m * f).toString(16).padStart(7, "#00000"); 21150 for (let S = 0, O = v.length; S < O; ++S) { 21151 const R = v[S], j = R.getGeometryFunction()(p); 21152 if (!j || !ee(n, j.getExtent())) 21153 continue;
21154 const $ = R.clone(), q = $.getFill(); 21155 q && q.setColor(C); 21156 const tt = $.getStroke(); 21157 tt && (tt.setColor(C), tt.setLineDash(null)), $.setText(void 0); 21158 const J = R.getImage(); 21159 if (J && J.getOpacity() !== 0) { 21160 const L = J.getImageSize(); 21161 if (!L) 21162 continue; 21163 const W = re( 21164 L[0], 21165 L[1], 21166 void 0, 21167 { alpha: !1 } 21168 ), ut = W.canvas; 21169 W.fillStyle = C, W.fillRect(0, 0, ut.width, ut.height), $.setImage( 21170 new Mg({ 21171 img: ut, 21172 imgSize: L, 21173 anchor: J.getAnchor(), 21174 anchorXUnits: "pixels", 21175 anchorYUnits: "pixels", 21176 offset: J.getOrigin(), 21177 opacity: 1, 21178 size: J.getSize(), 21179 scale: J.getScale(), 21180 rotation: J.getRotation(), 21181 rotateWithView: J.getRotateWithView() 21182 }) 21183 ); 21184 } 21185 const St = $.getZIndex() || 0; 21186 let K = g[St]; 21187 K || (K = {}, g[St] = K, K.Polygon = [], K.Circle = [], K.LineString = [], K.Point = []); 21188 const Y = j.getType(); 21189 if (Y === "GeometryCollection") { 21190 const L = ( 21191 /** @type {import("../../geom/GeometryCollection.js").default} */ 21192 j.getGeometriesArrayRecursive() 21193 ); 21194 for (let W = 0, ut = L.length; W < ut; ++W) { 21195 const ft = L[W]; 21196 K[ft.getType().replace("Multi", "")].push( 21197 ft, 21198 $ 21199 ); 21200 } 21201 } else 21202 K[Y.replace("Multi", "")].push(j, $); 21203 } 21204 } 21205 const _ = Object.keys(g).map(Number).sort(Cs); 21206 for (let m = 0, p = _.length; m < p; ++m) { 21207 const y = g[_[m]]; 21208 for (const v in y) { 21209 const E = y[v]; 21210 for (let C = 0, S = E.length; C < S; C += 2) { 21211 u.setStyle(E[C + 1]); 21212 for (let O = 0, R = t.length; O < R; ++O) 21213 u.setTransform(t[O]), u.drawGeometry(E[C]); 21214 } 21215 } 21216 } 21217 return h.getImageData(0, 0, c.width, c.height); 21218} 21219function ib(e, t, i) { 21220 const s = []; 21221 if (i) { 21222 const n = Math.floor(Math.round(e[0]) * qe), r = Math.floor(Math.round(e[1]) * qe), o = (Ot(n, 0, i.width - 1) + Ot(r, 0, i.height - 1) * i.width) * 4, a = i.data[o], l = i.data[o + 1], c = i.data[o + 2] + 256 * (l + 256 * a), u = Math.floor((256 * 256 * 256 - 1) / t.length); 21223 c && c % u === 0 && s.push(t[c / u - 1]); 21224 } 21225 return s; 21226} 21227const sb = 0.5, bg = { 21228 Point: db, 21229 LineString: hb, 21230 Polygon: gb, 21231 MultiPoint: fb, 21232 MultiLineString: cb, 21233 MultiPolygon: ub, 21234 GeometryCollection: lb, 21235 Circle: ob 21236}; 21237function nb(e, t) { 21238 return parseInt(ot(e), 10) - parseInt(ot(t), 10); 21239} 21240function rb(e, t) { 21241 const i = Ll(e, t); 21242 return i * i; 21243} 21244function Ll(e, t) { 21245 return sb * e / t; 21246} 21247function ob(e, t, i, s, n) { 21248 const r = i.getFill(), o = i.getStroke(); 21249 if (r || o) { 21250 const l = e.getBuilder(i.getZIndex(), "Circle"); 21251 l.setFillStrokeStyle(r, o), l.drawCircle(t, s); 21252 } 21253 const a = i.getText(); 21254 if (a && a.getText()) { 21255 const l = (n || e).getBuilder( 21256 i.getZIndex(), 21257 "Text" 21258 ); 21259 l.setTextStyle(a), l.drawText(t, s); 21260 } 21261} 21262function Wu(e, t, i, s, n, r, o) { 21263 let a = !1; 21264 const l = i.getImage(); 21265 if (l) { 21266 const h = l.getImageState(); 21267 h == rt.LOADED || h == rt.ERROR ? l.unlistenImageChange(n) : (h == rt.IDLE && l.load(), l.listenImageChange(n), a = !0); 21268 } 21269 return ab( 21270 e, 21271 t, 21272 i, 21273 s, 21274 r, 21275 o 21276 ), a; 21277} 21278function ab(e, t, i, s, n, r) { 21279 const o = i.getGeometryFunction()(t); 21280 if (!o) 21281 return; 21282 const a = o.simplifyTransformed( 21283 s, 21284 n 21285 ); 21286 if (i.getRenderer()) 21287 Sg(e, a, i, t); 21288 else { 21289 const h = bg[a.getType()]; 21290 h( 21291 e, 21292 a, 21293 i, 21294 t, 21295 r 21296 ); 21297 } 21298} 21299function Sg(e, t, i, s) { 21300 if (t.getType() == "GeometryCollection") { 21301 const r = ( 21302 /** @type {import("../geom/GeometryCollection.js").default} */ 21303 t.getGeometries() 21304 ); 21305 for (let o = 0, a = r.length; o < a; ++o) 21306 Sg(e, r[o], i, s); 21307 return; 21308 } 21309 e.getBuilder(i.getZIndex(), "Default").drawCustom( 21310 /** @type {import("../geom/SimpleGeometry.js").default} */ 21311 t, 21312 s, 21313 i.getRenderer(), 21314 i.getHitDetectionRenderer() 21315 ); 21316} 21317function lb(e, t, i, s, n) { 21318 const r = t.getGeometriesArray(); 21319 let o, a; 21320 for (o = 0, a = r.length; o < a; ++o) { 21321 const l = bg[r[o].getType()]; 21322 l( 21323 e, 21324 r[o], 21325 i, 21326 s, 21327 n 21328 ); 21329 } 21330} 21331function hb(e, t, i, s, n) { 21332 const r = i.getStroke(); 21333 if (r) { 21334 const a = e.getBuilder( 21335 i.getZIndex(), 21336 "LineString" 21337 ); 21338 a.setFillStrokeStyle(null, r), a.drawLineString(t, s); 21339 } 21340 const o = i.getText(); 21341 if (o && o.getText()) { 21342 const a = (n || e).getBuilder( 21343 i.getZIndex(), 21344 "Text" 21345 ); 21346 a.setTextStyle(o), a.drawText(t, s); 21347 } 21348} 21349function cb(e, t, i, s, n) { 21350 const r = i.getStroke(); 21351 if (r) { 21352 const a = e.getBuilder( 21353 i.getZIndex(), 21354 "LineString" 21355 ); 21356 a.setFillStrokeStyle(null, r), a.drawMultiLineString(t, s); 21357 } 21358 const o = i.getText(); 21359 if (o && o.getText()) { 21360 const a = (n || e).getBuilder( 21361 i.getZIndex(), 21362 "Text" 21363 ); 21364 a.setTextStyle(o), a.drawText(t, s); 21365 } 21366} 21367function ub(e, t, i, s, n) { 21368 const r = i.getFill(), o = i.getStroke(); 21369 if (o || r) { 21370 const l = e.getBuilder(i.getZIndex(), "Polygon"); 21371 l.setFillStrokeStyle(r, o), l.drawMultiPolygon(t, s); 21372 } 21373 const a = i.getText(); 21374 if (a && a.getText()) { 21375 const l = (n || e).getBuilder( 21376 i.getZIndex(), 21377 "Text" 21378 ); 21379 l.setTextStyle(a), l.drawText(t, s); 21380 } 21381} 21382function db(e, t, i, s, n) { 21383 const r = i.getImage(), o = i.getText(); 21384 let a; 21385 if (r) { 21386 if (r.getImageState() != rt.LOADED) 21387 return; 21388 let l = e; 21389 if (n) { 21390 const c = r.getDeclutterMode(); 21391 if (c !== "none") 21392 if (l = n, c === "obstacle") { 21393 const u = e.getBuilder( 21394 i.getZIndex(), 21395 "Image" 21396 ); 21397 u.setImageStyle(r, a), u.drawPoint(t, s); 21398 } else 21399 o && o.getText() && (a = {}); 21400 } 21401 const h = l.getBuilder( 21402 i.getZIndex(), 21403 "Image" 21404 ); 21405 h.setImageStyle(r, a), h.drawPoint(t, s); 21406 } 21407 if (o && o.getText()) { 21408 let l = e; 21409 n && (l = n); 21410 const h = l.getBuilder(i.getZIndex(), "Text"); 21411 h.setTextStyle(o, a), h.drawText(t, s); 21412 } 21413} 21414function fb(e, t, i, s, n) { 21415 const r = i.getImage(), o = i.getText(); 21416 let a; 21417 if (r) { 21418 if (r.getImageState() != rt.LOADED) 21419 return; 21420 let l = e; 21421 if (n) { 21422 const c = r.getDeclutterMode(); 21423 if (c !== "none") 21424 if (l = n, c === "obstacle") { 21425 const u = e.getBuilder( 21426 i.getZIndex(), 21427 "Image" 21428 ); 21429 u.setImageStyle(r, a), u.drawMultiPoint(t, s); 21430 } else 21431 o && o.getText() && (a = {}); 21432 } 21433 const h = l.getBuilder( 21434 i.getZIndex(), 21435 "Image" 21436 ); 21437 h.setImageStyle(r, a), h.drawMultiPoint(t, s); 21438 } 21439 if (o && o.getText()) { 21440 let l = e; 21441 n && (l = n); 21442 const h = l.getBuilder(i.getZIndex(), "Text"); 21443 h.setTextStyle(o, a), h.drawText(t, s); 21444 } 21445} 21446function gb(e, t, i, s, n) { 21447 const r = i.getFill(), o = i.getStroke(); 21448 if (r || o) { 21449 const l = e.getBuilder(i.getZIndex(), "Polygon"); 21450 l.setFillStrokeStyle(r, o), l.drawPolygon(t, s); 21451 } 21452 const a = i.getText(); 21453 if (a && a.getText()) { 21454 const l = (n || e).getBuilder( 21455 i.getZIndex(), 21456 "Text" 21457 ); 21458 l.setTextStyle(a), l.drawText(t, s); 21459 } 21460} 21461class _b extends Hh { 21462 /** 21463 * @param {import("../../layer/BaseVector.js").default} vectorLayer Vector layer. 21464 */ 21465 constructor(t) { 21466 super(t), this.boundHandleStyleImageChange_ = this.handleStyleImageChange_.bind(this), this.animatingOrInteracting_, this.hitDetectionImageData_ = null, this.renderedFeatures_ = null, this.renderedRevision_ = -1, this.renderedResolution_ = NaN, this.renderedExtent_ = ve(), this.wrappedRenderedExtent_ = ve(), this.renderedRotation_, this.renderedCenter_ = null, this.renderedProjection_ = null, this.renderedRenderOrder_ = null, this.replayGroup_ = null, this.replayGroupChanged = !0, this.declutterExecutorGroup = null, this.clipping = !0, this.compositionContext_ = null, this.opacity_ = 1; 21467 } 21468 /** 21469 * @param {ExecutorGroup} executorGroup Executor group. 21470 * @param {import("../../Map.js").FrameState} frameState Frame state. 21471 * @param {import("rbush").default} [declutterTree] Declutter tree. 21472 */ 21473 renderWorlds(t, i, s) { 21474 const n = i.extent, r = i.viewState, o = r.center, a = r.resolution, l = r.projection, h = r.rotation, c = l.getExtent(), u = this.getLayer().getSource(), d = i.pixelRatio, f = i.viewHints, g = !(f[Xt.ANIMATING] || f[Xt.INTERACTING]), _ = this.compositionContext_, m = Math.round(i.size[0] * d), p = Math.round(i.size[1] * d), y = u.getWrapX() && l.canWrapX(), v = y ? mt(c) : null, E = y ? Math.ceil((n[2] - c[2]) / v) + 1 : 1; 21475 let C = y ? Math.floor((n[0] - c[0]) / v) : 0; 21476 do { 21477 const S = this.getRenderTransform( 21478 o, 21479 a, 21480 h, 21481 d, 21482 m, 21483 p, 21484 C * v 21485 ); 21486 t.execute( 21487 _, 21488 1, 21489 S, 21490 h, 21491 g, 21492 void 0, 21493 s 21494 ); 21495 } while (++C < E); 21496 } 21497 setupCompositionContext_() { 21498 if (this.opacity_ !== 1) { 21499 const t = re( 21500 this.context.canvas.width, 21501 this.context.canvas.height, 21502 ku 21503 ); 21504 this.compositionContext_ = t; 21505 } else 21506 this.compositionContext_ = this.context; 21507 } 21508 releaseCompositionContext_() { 21509 if (this.opacity_ !== 1) { 21510 const t = this.context.globalAlpha; 21511 this.context.globalAlpha = this.opacity_, this.context.drawImage(this.compositionContext_.canvas, 0, 0), this.context.globalAlpha = t, _a(this.compositionContext_), ku.pu
21511sh(this.compositionContext_.canvas), this.compositionContext_ = null; 21512 } 21513 } 21514 /** 21515 * Render declutter items for this layer 21516 * @param {import("../../Map.js").FrameState} frameState Frame state. 21517 */ 21518 renderDeclutter(t) { 21519 this.declutterExecutorGroup && (this.setupCompositionContext_(), this.renderWorlds( 21520 this.declutterExecutorGroup, 21521 t, 21522 t.declutterTree 21523 ), this.releaseCompositionContext_()); 21524 } 21525 /** 21526 * Render the layer. 21527 * @param {import("../../Map.js").FrameState} frameState Frame state. 21528 * @param {HTMLElement} target Target that may be used to render content to. 21529 * @return {HTMLElement} The rendered element. 21530 */ 21531 renderFrame(t, i) { 21532 const s = t.pixelRatio, n = t.layerStatesArray[t.layerIndex]; 21533 oE(this.pixelTransform, 1 / s, 1 / s), ua(this.inversePixelTransform, this.pixelTransform); 21534 const r = vh(this.pixelTransform); 21535 this.useContainer(i, r, this.getBackground(t)); 21536 const o = this.context, a = o.canvas, l = this.replayGroup_, h = this.declutterExecutorGroup; 21537 if ((!l || l.isEmpty()) && (!h || h.isEmpty())) 21538 return null; 21539 const c = Math.round(t.size[0] * s), u = Math.round(t.size[1] * s); 21540 a.width != c || a.height != u ? (a.width = c, a.height = u, a.style.transform !== r && (a.style.transform = r)) : this.containerReused || o.clearRect(0, 0, c, u), this.preRender(o, t); 21541 const d = t.viewState; 21542 d.projection, this.opacity_ = n.opacity, this.setupCompositionContext_(); 21543 let f = !1, g = !0; 21544 if (n.extent && this.clipping) { 21545 const _ = He(n.extent); 21546 g = ee(_, t.extent), f = g && !Gi(_, t.extent), f && this.clipUnrotated(this.compositionContext_, t, _); 21547 } 21548 return g && this.renderWorlds(l, t), f && this.compositionContext_.restore(), this.releaseCompositionContext_(), this.postRender(o, t), this.renderedRotation_ !== d.rotation && (this.renderedRotation_ = d.rotation, this.hitDetectionImageData_ = null), this.container; 21549 } 21550 /** 21551 * Asynchronous layer level hit detection. 21552 * @param {import("../../pixel.js").Pixel} pixel Pixel. 21553 * @return {Promise<Array<import("../../Feature").default>>} Promise 21554 * that resolves with an array of features. 21555 */ 21556 getFeatures(t) { 21557 return new Promise((i) => { 21558 if (!this.hitDetectionImageData_ && !this.animatingOrInteracting_) { 21559 const s = [this.context.canvas.width, this.context.canvas.height]; 21560 zt(this.pixelTransform, s); 21561 const n = this.renderedCenter_, r = this.renderedResolution_, o = this.renderedRotation_, a = this.renderedProjection_, l = this.wrappedRenderedExtent_, h = this.getLayer(), c = [], u = s[0] * qe, d = s[1] * qe; 21562 c.push( 21563 this.getRenderTransform( 21564 n, 21565 r, 21566 o, 21567 qe, 21568 u, 21569 d, 21570 0 21571 ).slice() 21572 ); 21573 const f = h.getSource(), g = a.getExtent(); 21574 if (f.getWrapX() && a.canWrapX() && !Gi(g, l)) { 21575 let _ = l[0]; 21576 const m = mt(g); 21577 let p = 0, y; 21578 for (; _ < g[0]; ) 21579 --p, y = m * p, c.push( 21580 this.getRenderTransform( 21581 n, 21582 r, 21583 o, 21584 qe, 21585 u, 21586 d, 21587 y 21588 ).slice() 21589 ), _ += m; 21590 for (p = 0, _ = l[2]; _ > g[2]; ) 21591 ++p, y = m * p, c.push( 21592 this.getRenderTransform( 21593 n, 21594 r, 21595 o, 21596 qe, 21597 u, 21598 d, 21599 y 21600 ).slice() 21601 ), _ -= m; 21602 } 21603 this.hitDetectionImageData_ = eb( 21604 s, 21605 c, 21606 this.renderedFeatures_, 21607 h.getStyleFunction(), 21608 l, 21609 r, 21610 o 21611 ); 21612 } 21613 i( 21614 ib(t, this.renderedFeatures_, this.hitDetectionImageData_) 21615 ); 21616 }); 21617 } 21618 /** 21619 * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate. 21620 * @param {import("../../Map.js").FrameState} frameState Frame state. 21621 * @param {number} hitTolerance Hit tolerance in pixels. 21622 * @param {import("../vector.js").FeatureCallback<T>}
21622 callback Feature callback. 21623 * @param {Array<import("../Map.js").HitMatch<T>>} matches The hit detected matches with tolerance. 21624 * @return {T|undefined} Callback result. 21625 * @template T 21626 */ 21627 forEachFeatureAtCoordinate(t, i, s, n, r) { 21628 if (!this.replayGroup_) 21629 return; 21630 const o = i.viewState.resolution, a = i.viewState.rotation, l = this.getLayer(), h = {}, c = function(f, g, _) { 21631 const m = ot(f), p = h[m]; 21632 if (p) { 21633 if (p !== !0 && _ < p.distanceSq) { 21634 if (_ === 0) 21635 return h[m] = !0, r.splice(r.lastIndexOf(p), 1), n(f, l, g); 21636 p.geometry = g, p.distanceSq = _; 21637 } 21638 } else { 21639 if (_ === 0) 21640 return h[m] = !0, n(f, l, g); 21641 r.push( 21642 h[m] = { 21643 feature: f, 21644 layer: l, 21645 geometry: g, 21646 distanceSq: _, 21647 callback: n 21648 } 21649 ); 21650 } 21651 }; 21652 let u; 21653 const d = [this.replayGroup_]; 21654 return this.declutterExecutorGroup && d.push(this.declutterExecutorGroup), d.some((f) => u = f.forEachFeatureAtCoordinate( 21655 t, 21656 o, 21657 a, 21658 s, 21659 c, 21660 f === this.declutterExecutorGroup && i.declutterTree ? i.declutterTree.all().map((g) => g.value) : null 21661 )), u; 21662 } 21663 /** 21664 * Perform action necessary to get the layer rendered after new fonts have loaded 21665 */ 21666 handleFontsChanged() { 21667 const t = this.getLayer(); 21668 t.getVisible() && this.replayGroup_ && t.changed(); 21669 } 21670 /** 21671 * Handle changes in image style state. 21672 * @param {import("../../events/Event.js").default} event Image style change event. 21673 * @private 21674 */ 21675 handleStyleImageChange_(t) { 21676 this.renderIfReadyAndVisible(); 21677 } 21678 /** 21679 * Determine whether render should be called. 21680 * @param {import("../../Map.js").FrameState} frameState Frame state. 21681 * @return {boolean} Layer is ready to be rendered. 21682 */ 21683 prepareFrame(t) { 21684 const i = this.getLayer(), s = i.getSource(); 21685 if (!s) 21686 return !1; 21687 const n = t.viewHints[Xt.ANIMATING], r = t.viewHints[Xt.INTERACTING], o = i.getUpdateWhileAnimating(), a = i.getUpdateWhileInteracting(); 21688 if (this.ready && !o && n || !a && r) 21689 return this.animatingOrInteracting_ = !0, !0; 21690 this.animatingOrInteracting_ = !1; 21691 const l = t.extent, h = t.viewState, c = h.projection, u = h.resolution, d = t.pixelRatio, f = i.getRevision(), g = i.getRenderBuffer(); 21692 let _ = i.getRenderOrder(); 21693 _ === void 0 && (_ = nb); 21694 const m = h.center.slice(), p = Es( 21695 l, 21696 g * u 21697 ), y = p.slice(), v = [p.slice()], E = c.getExtent(); 21698 if (s.getWrapX() && c.canWrapX() && !Gi(E, t.extent)) { 21699 const K = mt(E), Y = Math.max(mt(p) / 2, K); 21700 p[0] = E[0] - Y, p[2] = E[2] + Y, Fd(m, c); 21701 const L = Ld(v[0], c); 21702 L[0] < E[0] && L[2] < E[2] ? v.push([ 21703 L[0] + K, 21704 L[1], 21705 L[2] + K, 21706 L[3] 21707 ]) : L[0] > E[0] && L[2] > E[2] && v.push([ 21708 L[0] - K, 21709 L[1], 21710 L[2] - K, 21711 L[3] 21712 ]); 21713 } 21714 if (this.ready && this.renderedResolution_ == u && this.renderedRevision_ == f && this.renderedRenderOrder_ == _ && Gi(this.wrappedRenderedExtent_, p)) 21715 return bi(this.renderedExtent_, y) || (this.hitDetectionImageData_ = null, this.renderedExtent_ = y), this.renderedCenter_ = m, this.replayGroupChanged = !1, !0; 21716 this.replayGroup_ = null; 21717 const C = new Nu( 21718 Ll(u, d), 21719 p, 21720 u, 21721 d 21722 ); 21723 let S; 21724 this.getLayer().getDeclutter() && (S = new Nu( 21725 Ll(u, d), 21726 p, 21727 u, 21728 d 21729 )); 21730 let O; 21731 for (let K = 0, Y = v.length; K < Y; ++K) 21732 s.loadFeatures(v[K], u, c); 21733 const R = rb(u, d); 21734 let j = !0; 21735 const $ = ( 21736 /** 21737 * @param {import("../../Feature.js").default} feature Feature. 21738 */ 21739 (K) => { 21740 let Y; 21741 const L = K.getStyleFunction() || i.getStyleFunction(); 21742 if (L && (Y = L(K, u)), Y) { 21743 const W = this.renderFeature( 21744 K, 21745 R, 21746 Y, 21747 C, 21748 O, 21749 S 21750 ); 21751 j = j && !W; 21752 } 21753 } 21754 ), q = Zo(p), tt = s.getFeaturesInExtent(q); 21755 _ && tt.sort(_); 21756 for (let K = 0, Y = tt.length; K < Y; ++K) 21757 $(tt[K]); 21758 this.renderedFeatures_ = tt, this.ready = j; 21759 const J = C.finish(), St = new ju( 21760 p, 21761 u, 21762 d, 21763 s.getOverlaps(), 21764 J, 21765 i.getRenderBuffer() 21766 ); 21767 return S && (this.declutterExecutorGroup = new ju( 21768 p, 21769 u, 21770 d, 21771 s.getOverlaps(), 21772 S.finish(), 21773 i.getRenderBuffer() 21774 )), this.renderedResolution_ = u, this.renderedRevision_ = f, this.renderedRenderOrder_ = _, this.renderedExtent_ = y, this.wrappedRenderedExtent_ = p, this.renderedCenter_ = m, this.renderedProjection_ = c, this.replayGroup_ = St, this.hitDetectionImageData_ = null, this.replayGroupChanged = !0, !0; 21775 } 21776 /** 21777 * @param {import("../../Feature.js").default} feature Feature. 21778 * @param {number} squaredTolerance Squared render tolerance. 21779 * @param {import("../../style/Style.js").default|Array<import("../../style/Style.js").default>} styles The style or array of styles. 21780 * @param {import("../../render/canvas/BuilderGroup.js").default} builderGroup Builder group. 21781 * @param {import("../../proj.js").TransformFunction} [transform] Transform from user to view projection. 21782 * @param {import("../../render/canvas/BuilderGroup.js").default} [declutterBuilderGroup] Builder for decluttering. 21783 * @return {boolean} `true` if an image is loading. 21784 */ 21785 renderFeature(t, i, s, n, r, o) { 21786 if (!s) 21787 return !1; 21788 let a = !1; 21789 if (Array.isArray(s)) 21790 for (let l = 0, h = s.length; l < h; ++l) 21791 a = Wu( 21792 n, 21793 t, 21794 s[l], 21795 i, 21796 this.boundHandleStyleImageChange_, 21797 r, 21798 o 21799 ) || a; 21800 else 21801 a = Wu( 21802 n, 21803 t, 21804 s, 21805 i, 21806 this.boundHandleStyleImageChange_, 21807 r, 21808 o 21809 ); 21810 return a; 21811 } 21812} 21813const mb = _b; 21814class pb extends IC { 21815 /** 21816 * @param {import("./BaseVector.js").Options<VectorSourceType>} [options] Options. 21817 */ 21818 constructor(t) { 21819 super(t); 21820 } 21821 createRenderer() { 21822 return new mb(this); 21823 } 21824} 21825const pa = pb; 21826class yb { 21827 /** 21828 * @param {number} [maxEntries] Max entries. 21829 */ 21830 constructor(t) { 21831 this.rbush_ = new vg(t), this.items_ = {}; 21832 } 21833 /** 21834 * Insert a value into the RBush. 21835 * @param {import("../extent.js").Extent} extent Extent. 21836 * @param {T} value Value. 21837 */ 21838 insert(t, i) { 21839 const s = { 21840 minX: t[0], 21841 minY: t[1], 21842 maxX: t[2], 21843 maxY: t[3], 21844 value: i 21845 }; 21846 this.rbush_.insert(s), this.items_[ot(i)] = s; 21847 } 21848 /** 21849 * Bulk-insert values into the RBush. 21850 * @param {Array<import("../extent.js").Extent>} extents Extents. 21851 * @param {Array<T>} values Values. 21852 */ 21853 load(t, i) { 21854 const s = new Array(i.length); 21855 for (let n = 0, r = i.length; n < r; n++) { 21856 const o = t[n], a = i[n], l = { 21857 minX: o[0], 21858 minY: o[1], 21859 maxX: o[2], 21860 maxY: o[3], 21861 value: a 21862 }; 21863 s[n] = l, this.items_[ot(a)] = l; 21864 } 21865 this.rbush_.load(s); 21866 } 21867 /** 21868 * Remove a value from the RBush. 21869 * @param {T} value Value. 21870 * @return {boolean} Removed. 21871 */ 21872 remove(t) { 21873 const i = ot(t), s = this.items_[i]; 21874 return delete this.items_[i], this.rbush_.remove(s) !== null; 21875 } 21876 /** 21877 * Update the extent of a value in the RBush. 21878 * @param {import("../extent.js").Extent} extent Extent. 21879 * @param {T} value Value. 21880 */ 21881 update(t, i) { 21882 const s = this.items_[ot(i)], n = [s.minX, s.minY, s.maxX, s.maxY]; 21883 fn(n, t) || (this.remove(i), this.insert(t, i)); 21884 } 21885 /** 21886 * Return all values in the RBush. 21887 * @return {Array<T>} All. 21888 */ 21889 getAll() { 21890 return this.rbush_.all().map(function(i) { 21891 return i.value; 21892 }); 21893 } 21894 /** 21895 * Return all values in the given extent. 21896 * @param {import("../extent.js").Extent} extent Extent. 21897 * @return {Array<T>} All in extent. 21898 */ 21899 getInExtent(t) { 21900 const i = { 21901 minX: t[0], 21902 minY: t[1], 21903 maxX: t[2], 21904 maxY: t[3] 21905 }; 21906 return this.rbush_.search(i).map(function(n) { 21907 return n.value; 21908 }); 21909 } 21910 /** 21911 * Calls a callback function with each value in the tree. 21912 * If the callback returns a truthy value, this value is returned without 21913 * checking the rest of the tree. 21914 * @param {function(T): *} callback Callback. 21915 * @return {*} Callback return value. 21916 */ 21917 forEach(t) { 21918 return this.forEach_(this.getAll(), t); 21919 } 21920 /** 21921 * Calls a callback function with each value in the provided extent. 21922 * @param {import("../extent.js").Extent} extent Extent. 21923 * @param {function(T): *} callback Callback. 21924 * @return {*} Callback return value. 21925 */ 21926 forEachInExtent(t, i) { 21927 return this.forEach_(this.getInExtent(t), i); 21928 } 21929 /** 21930 * @param {Array<T>} values Values. 21931 * @param {function(T): *} callback Callback. 21932 * @private 21933 * @return {*} Callback return value. 21934 */ 21935 forEach_(t, i) { 21936 let s; 21937 for (let n = 0, r = t.length; n < r; n++) 21938 if (s = i(t[n]), s) 21939 return s; 21940 return s; 21941 } 21942 /** 21943 * @return {boolean} Is empty. 21944 */ 21945 isEmpty() { 21946 return un(this.items_); 21947 } 21948 /** 21949 * Remove all values from the RBush. 21950 */ 21951 clear() { 21952 this.rbush_.clear(), this.items_ = {}; 21953 } 21954 /** 21955 * @param {import("../extent.js").Extent} [extent] Extent. 21956 * @return {import("../extent.js").Extent} Extent. 21957 */ 21958 getExtent(t) { 21959 const i = this.rbush_.toJSON(); 21960 return ei(i.minX, i.minY, i.maxX, i.maxY, t); 21961 } 21962 /** 21963 * @param {RBush} rbush R-Tree. 21964 */ 21965 concat(t) { 21966 this.rbush_.load(t.rbush_.all()); 21967 for (const i in t.items_) 21968 this.items_[i] = t.items_[i]; 21969 } 21970} 21971const Wo = yb; 21972class xb extends ni { 21973 /** 21974 * @param {Options} options Source options. 21975 */ 21976 constructor(t) { 21977 super(), this.projection = Rt(t.projection), this.attributions_ = Bu(t.attributions), this.attributionsCollapsible_ = t.attributionsCollapsible !== void 0 ? 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; 21978 const i = this; 21979 this.viewPromise_ = new Promise(function(s, n) { 21980 i.viewResolver = s, i.viewRejector = n; 21981 }); 21982 } 21983 /** 21984 * Get the attribution function for the source. 21985 * @return {?Attribution} Attribution function. 21986 * @api 21987 */ 21988 getAttributions() { 21989 return this.attributions_; 21990 } 21991 /** 21992 * @return {boolean} Attributions are collapsible. 21993 * @api 21994 */ 21995 getAttributionsCollapsible() { 21996 return this.attributionsCollapsible_; 21997 } 21998 /** 21999 * Get the projection of the source. 22000 * @return {import("../proj/Projection.js").default|null} Projection. 22001 * @api 22002 */ 22003 getProjection() { 22004 return this.projection; 22005 } 22006 /** 22007 * @param {import("../proj/Projection").default} [projection] Projection. 22008 * @return {Array<number>|null} Resolutions. 22009 */ 22010 getResolutions(t) { 22011 return null; 22012 } 22013 /** 22014 * @return {Promise<import("../View.js").ViewOptions>} A promise for view-related properties. 22015 */ 22016 getView() { 22017 return this.viewPromise_; 22018 } 22019 /** 22020 * Get the state of the source, see {@link import("./Source.js").State} for possible states. 22021 * @return {import("./Source.js").State} State. 22022 * @api 22023 */ 22024 getState() { 22025 return this.state_; 22026 } 22027 /** 22028 * @return {boolean|undefined} Wrap X. 22029 */ 22030 getWrapX() { 22031 return this.wrapX_; 22032 } 22033 /** 22034 * @return {boolean} Use linear interpolation when resampling. 22035 */ 22036 getInterpolate() { 22037 return this.interpolate_; 22038 } 22039 /** 22040 * Refreshes the source. The source will be cleared, and data from the server will be reloaded. 22041 * @api 22042 */ 22043 refresh() { 22044 this.changed(); 22045 } 22046 /** 22047 * Set the attributions of the source. 22048 * @param {AttributionLike|undefined} attributions Attributions. 22049 * Can be passed as `string`, `Array<string>`, {@link module:ol/source/Source~Attribution}, 22050 * or `undefined`. 22051 * @api 22052 */ 22053 setAttributions(t) { 22054 this.attributions_ = Bu(t), this.changed(); 22055 } 22056 /** 22057 * Set the state of the source. 22058 * @param {import("./Source.js").State} state State. 22059 */ 22060 setState(t) { 22061 this.state_ = t, this.changed(); 22062 } 22063} 22064function Bu(e) { 22065 return e ? Array.isArray(e) ? function(t) { 22066 return e; 22067 } : typeof e == "function" ? e : function(t) { 22068 return [e]; 22069 } : null; 22070} 22071const Zh = xb, le = { 22072 /** 22073 * Triggered when a feature is added to the source. 22074 * @event module:ol/source/Vector.VectorSourceEvent#addfeature 22075 * @api 22076 */ 22077 ADDFEATURE: "addfeature", 22078 /** 22079 * Triggered when a feature is updated. 22080 * @event module:ol/source/Vector.VectorSourceEvent#changefeature 22081 * @api 22082 */ 22083 CHANGEFEATURE: "changefeature", 22084 /** 22085 * Triggered when the clear method is called on the source. 22086 * @event module:ol/source/Vector.VectorSourceEvent#clear 22087 * @api 22088 */ 22089 CLEAR: "clear", 22090 /** 22091 * Triggered when a feature is removed from the source. 22092 * See {@link module:ol/source/Vector~VectorSource#clear source.clear()} for exceptions. 22093 * @event module:ol/source/Vector.VectorSourceEvent#removefeature 22094 * @api 22095 */ 22096 REMOVEFEATURE: "removefeature", 22097 /** 22098 * Triggered when features starts loading. 22099 * @event module:ol/source/Vector.VectorSourceEvent#featuresloadstart 22100 * @api 22101 */ 22102 FEATURESLOADSTART: "featuresloadstart", 22103 /** 22104 * Triggered when features finishes loading. 22105 * @event module:ol/source/Vector.VectorSourceEvent#featuresloadend 22106 * @api 22107 */ 22108 FEATURESLOADEND: "featuresloadend", 22109 /** 22110 * Triggered if feature loading results in an error. 22111 * @event module:ol/source/Vector.VectorSourceEvent#featuresloaderror 22112 * @api 22113 */ 22114 FEATURESLOADERROR: "featuresloaderror" 22115}; 22116function vb(e, t) { 22117 return [[-1 / 0, -1 / 0, 1 / 0, 1 / 0]]; 22118} 22119let Eb = !1; 22120function Mb(e, t, i, s, n, r, o) { 22121 const a = new XMLHttpRequest(); 22122 a.open( 22123 "GET", 22124 typeof e == "function" ? e(i, s, n) : e, 22125 !0 22126 ), t.getType() == "arraybuffer" && (a.responseType = "arraybuffer"), a.withCredentials = Eb, a.onload = function(l) { 22127 if (!a.status || a.status >= 200 && a.status < 300) { 22128 const h = t.getType(); 22129 let c; 22130 h == "json" || h == "text" ? c = a.responseText : h == "xml" ? (c = a.responseXML, c || (c = new DOMParser().parseFromString( 22131 a.responseText, 22132 "application/xml" 22133 ))) : h == "arraybuffer" && (c = /** @type {ArrayBuffer} */ 22134 a.response), c ? r( 22135 /** @type {Array<import("./Feature.js").default>} */ 22136 t.readFeatures(c, { 22137 extent: i, 22138 featureProjection: n 22139 }), 22140 t.readProjection(c) 22141 ) : o(); 22142 } else 22143 o(); 22144 }, a.onerror = o, a.send(); 22145} 22146function Uu(e, t) { 22147 return function(i, s, n, r, o) { 22148 const a = ( 22149 /** @type {import("./source/Vector").default} */ 22150 this 22151 ); 22152 Mb( 22153 e, 22154 t, 22155 i, 22156 s, 22157 n, 22158 /** 22159 * @param {Array<import("./Feature.js").default>} features The loaded features. 22160 * @param {import("./proj/Projection.js").default} dataProjection Data 22161 * projection. 22162 */ 22163 function(l, h) { 22164 a.addFeatures(l), r !== void 0 && r(l); 22165 }, 22166 /* FIXME handle error */ 22167 o || xn 22168 ); 22169 }; 22170} 22171class Ii extends Ae { 22172 /** 22173 * @param {string} type Type. 22174 * @param {import("../Feature.js").default<Geometry>} [feature] Feature. 22175 * @param {Array<import("../Feature.js").default<Geometry>>} [features] Features. 22176 */ 22177 constructor(t, i, s) { 22178 super(t), this.feature = i, this.features = s; 22179 } 22180} 22181class Cb extends Zh { 22182 /** 22183 * @param {Options<Geometry>} [options] Vector source options. 22184 */ 22185 constructor(t) { 22186 t = t || {}, super({ 22187 attributions: t.attributions, 22188 interpolate: !0, 22189 projection: void 0, 22190 state: "ready", 22191 wrapX: t.wrapX !== void 0 ? t.wrapX : !0 22192 }), this.on, this.once, this.un, this.loader_ = xn, this.format_ = t.format, this.overlaps_ = t.overlaps === void 0 ? !0 : t.overlaps, this.url_ = t.url, t.loader !== void 0 ? this.loader_ = t.loader : this.url_ !== void 0 && (at(this.format_, 7), this.loader_ = Uu( 22193 this.url_, 22194 /** @type {import("../format/Feature.js").default} */ 22195 this.format_ 22196 )), this.strategy_ = t.strategy !== void 0 ? t.strategy : vb; 22197 cons
22197t i = t.useSpatialIndex !== void 0 ? t.useSpatialIndex : !0; 22198 this.featuresRtree_ = i ? new Wo() : null, this.loadedExtentsRtree_ = new Wo(), this.loadingExtentsCount_ = 0, this.nullGeometryFeatures_ = {}, this.idIndex_ = {}, this.uidIndex_ = {}, this.featureChangeKeys_ = {}, this.featuresCollection_ = null; 22199 let s, n; 22200 Array.isArray(t.features) ? n = t.features : t.features && (s = t.features, n = s.getArray()), !i && s === void 0 && (s = new Pe(n)), n !== void 0 && this.addFeaturesInternal(n), s !== void 0 && this.bindFeaturesCollection_(s); 22201 } 22202 /** 22203 * Add a single feature to the source. If you want to add a batch of features 22204 * at once, call {@link module:ol/source/Vector~VectorSource#addFeatures #addFeatures()} 22205 * instead. A feature will not be added to the source if feature with 22206 * the same id is already there. The reason for this behavior is to avoid 22207 * feature duplication when using bbox or tile loading strategies. 22208 * Note: this also applies if an {@link module:ol/Collection~Collection} is used for features, 22209 * meaning that if a feature with a duplicate id is added in the collection, it will 22210 * be removed from it right away. 22211 * @param {import("../Feature.js").default<Geometry>} feature Feature to add. 22212 * @api 22213 */ 22214 addFeature(t) { 22215 this.addFeatureInternal(t), this.changed(); 22216 } 22217 /** 22218 * Add a feature without firing a `change` event. 22219 * @param {import("../Feature.js").default<Geometry>} feature Feature. 22220 * @protected 22221 */ 22222 addFeatureInternal(t) { 22223 const i = ot(t); 22224 if (!this.addToIndex_(i, t)) { 22225 this.featuresCollection_ && this.featuresCollection_.remove(t); 22226 return; 22227 } 22228 this.setupChangeEvents_(i, t); 22229 const s = t.getGeometry(); 22230 if (s) { 22231 const n = s.getExtent(); 22232 this.featuresRtree_ && this.featuresRtree_.insert(n, t); 22233 } else 22234 this.nullGeometryFeatures_[i] = t; 22235 this.dispatchEvent( 22236 new Ii(le.ADDFEATURE, t) 22237 ); 22238 } 22239 /** 22240 * @param {string} featureKey Unique identifier for the feature. 22241 * @param {import("../Feature.js").default<Geometry>} feature The feature. 22242 * @private 22243 */ 22244 setupChangeEvents_(t, i) { 22245 this.featureChangeKeys_[t] = [ 22246 lt(i, et.CHANGE, this.handleFeatureChange_, this), 22247 lt( 22248 i, 22249 yn.PROPERTYCHANGE, 22250 this.handleFeatureChange_, 22251 this 22252 ) 22253 ]; 22254 } 22255 /** 22256 * @param {string} featureKey Unique identifier for the feature. 22257 * @param {import("../Feature.js").default<Geometry>} feature The feature. 22258 * @return {boolean} The feature is "valid", in the sense that it is also a 22259 * candidate for insertion into the Rtree. 22260 * @private 22261 */ 22262 addToIndex_(t, i) { 22263 let s = !0; 22264 const n = i.getId(); 22265 return n !== void 0 && (n.toString() in this.idIndex_ ? s = !1 : this.idIndex_[n.toString()] = i), s && (at(!(t in this.uidIndex_), 30), this.uidIndex_[t] = i), s; 22266 } 22267 /** 22268 * Add a batch of features to the source. 22269 * @param {Array<import("../Feature.js").default<Geometry>>} features Features to add. 22270 * @api 22271 */ 22272 addFeatures(t) { 22273 this.addFeaturesInternal(t), this.changed(); 22274 } 22275 /** 22276 * Add features without firing a `change` event. 22277 * @param {Array<import("../Feature.js").default<Geometry>>} features Features. 22278 * @protected 22279 */ 22280 addFeaturesInternal(t) { 22281 const i = [], s = [], n = []; 22282 for (let r = 0, o = t.length; r < o; r++) { 22283 const a = t[r], l = ot(a); 22284 this.addToIndex_(l, a) && s.push(a); 22285 } 22286 for (let r = 0, o = s.length; r < o; r++) { 22287 const a = s[r], l = ot(a); 22288 this.setupChangeEvents_(l, a); 22289 const h = a.getGeometry(); 22290 if (h) { 22291 const c = h.getExtent(); 22292 i.push(c), n.push(a); 22293 } else 22294 this.nullGeometryFeatures_[l] = a; 22295 } 22296 if (this.featuresRtree_ && this.featuresRtree_.load(i, n), this.hasListener(le.ADDFEATURE)) 22297 for (let r = 0, o = s.length; r < o; r++) 22298 this.dispatchEvent( 22299 new Ii(le.ADDFEATURE, s[r]) 22300 ); 22301 } 22302 /** 22303 * @param {!Collection<import("../Feature.js").default<Geometry>>} collection Collection. 22304 * @private 22305 */ 22306 bindFeaturesCollection_(t) { 22307 let i = !1; 22308 this.addEventListener( 22309 le.ADDFEATURE, 22310 /** 22311 * @param {VectorSourceEvent<Geometry>} evt The vector source event 22312 */ 22313 function(s) { 22314 i || (i = !0, t.push(s.feature), i = !1); 22315 } 22316 ), this.addEventListener( 22317 le.REMOVEFEATURE, 22318 /** 22319 * @param {VectorSourceEvent<Geometry>} evt The vector source event 22320 */ 22321 function(s) { 22322 i || (i = !0, t.remove(s.feature), i = !1); 22323 } 22324 ), t.addEventListener( 22325 $t.ADD, 22326 /** 22327 * @param {import("../Collection.js").CollectionEvent<import("../Feature.js").default<Geometry>>} evt The collection event 22328 */ 22329 (s) => { 22330 i || (i = !0, this.addFeature(s.element), i = !1); 22331 } 22332 ), t.addEventListener( 22333 $t.REMOVE, 22334 /** 22335 * @param {import("../Collection.js").CollectionEvent<import("../Feature.js").default<Geometry>>} evt The collection event 22336 */ 22337 (s) => {
22338 i || (i = !0, this.removeFeature(s.element), i = !1); 22339 } 22340 ), this.featuresCollection_ = t; 22341 } 22342 /** 22343 * Remove all features from the source. 22344 * @param {boolean} [fast] Skip dispatching of {@link module:ol/source/Vector.VectorSourceEvent#event:removefeature} events. 22345 * @api 22346 */ 22347 clear(t) { 22348 if (t) { 22349 for (const s in this.featureChangeKeys_) 22350 this.featureChangeKeys_[s].forEach(Mt); 22351 this.featuresCollection_ || (this.featureChangeKeys_ = {}, this.idIndex_ = {}, this.uidIndex_ = {}); 22352 } else if (this.featuresRtree_) { 22353 const s = (n) => { 22354 this.removeFeatureInternal(n); 22355 }; 22356 this.featuresRtree_.forEach(s); 22357 for (const n in this.nullGeometryFeatures_) 22358 this.removeFeatureInternal(this.nullGeometryFeatures_[n]); 22359 } 22360 this.featuresCollection_ && this.featuresCollection_.clear(), this.featuresRtree_ && this.featuresRtree_.clear(), this.nullGeometryFeatures_ = {}; 22361 const i = new Ii(le.CLEAR); 22362 this.dispatchEvent(i), this.changed(); 22363 } 22364 /** 22365 * Iterate through all features on the source, calling the provided callback 22366 * with each one. If the callback returns any "truthy" value, iteration will 22367 * stop and the function will return the same value. 22368 * Note: this function only iterate through the feature that have a defined geometry. 22369 * 22370 * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature 22371 * on the source. Return a truthy value to stop iteration. 22372 * @return {T|undefined} The return value from the last call to the callback. 22373 * @template T 22374 * @api 22375 */ 22376 forEachFeature(t) { 22377 if (this.featuresRtree_) 22378 return this.featuresRtree_.forEach(t); 22379 this.featuresCollection_ && this.featuresCollection_.forEach(t); 22380 } 22381 /** 22382 * Iterate through all features whose geometries contain the provided 22383 * coordinate, calling the callback with each feature. If the callback returns 22384 * a "truthy" value, iteration will stop and the function will return the same 22385 * value. 22386 * 22387 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 22388 * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature 22389 * whose goemetry contains the provided coordinate. 22390 * @return {T|undefined} The return value from the last call to the callback. 22391 * @template T 22392 */ 22393 forEachFeatureAtCoordinateDirect(t, i) { 22394 const s = [t[0], t[1], t[0], t[1]]; 22395 return this.forEachFeatureInExtent(s, function(n) { 22396 if (n.getGeometry().intersectsCoordinate(t)) 22397 return i(n); 22398 }); 22399 } 22400 /** 22401 * Iterate through all features whose bounding box intersects the provided 22402 * extent (note that the feature's geometry may not intersect the extent), 22403 * calling the callback with each feature. If the callback returns a "truthy" 22404 * value, iteration will stop and the function will return the same value. 22405 * 22406 * If you are interested in features whose geometry intersects an extent, call 22407 * the {@link module:ol/source/Vector~VectorSource#forEachFeatureIntersectingExtent #forEachFeatureIntersectingExtent()} method instead. 22408 * 22409 * When `useSpatialIndex` is set to false, this method will loop through all 22410 * features, equivalent to {@link module:ol/source/Vector~VectorSource#forEachFeature #forEachFeature()}. 22411 * 22412 * @param {import("../extent.js").Extent} extent Extent. 22413 * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature 22414 * whose bounding box intersects the provided extent. 22415 * @return {T|undefined} The return value from the last call to the callback. 22416 * @template T 22417 * @api 22418 */ 22419 forEachFeatureInExtent(t, i) { 22420 if (this.featuresRtree_) 22421 return this.featuresRtree_.forEachInExtent(t, i); 22422 this.featuresCollection_ && this.featuresCollection_.forEach(i); 22423 } 22424 /** 22425 * Iterate through all features whose geometry intersects the provided extent, 22426 * calling the callback with each feature. If the callback returns a "truthy" 22427 * value, iteration will stop and the function will return the same value. 22428 * 22429 * If you only want to test for bounding box intersection, call the 22430 * {@link module:ol/source/Vector~VectorSource#forEachFeatureInExtent #forEachFeatureInExtent()} method instead. 22431 * 22432 * @param {import("../extent.js").Extent} extent Extent. 22433 * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature 22434 * whose geometry intersects the provided extent. 22435 * @return {T|undefined} The return value from the last call to the callback. 22436 * @template T 22437 * @api 22438 */ 22439 forEachFeatureIntersectingExtent(t, i) { 22440 return this.forEachFeatureInExtent( 22441 t, 22442 /** 22443 * @param {import("../Feature.js").default<Geometry>} feature Feature. 22444 * @return {T|undefined} The return value from the last call to the callback. 22445 */ 22446 function(s) { 22447 if (s.getGeometry().intersectsExtent(t)) { 22448 const r = i(s); 22449 if (r) 22450 return r; 22451 } 22452 } 22453 ); 22454 } 22455 /** 22456 * Get the features collection associated with this source. Will be `null` 22457 * unless the source was configured with `useSpatialIndex` set to `false`, or 22458 * with an {@link module:ol/Collection~Collection} as `features`. 22459 * @return {Collection<import("../Feature.js").default<Geometry>>|null} The collection of features. 22460 * @api 22461 */ 22462 getFeaturesCollection() { 22463 return this.featuresCollection_; 22464 } 22465 /** 22466 * Get a snapshot of the features currently on the source in random order. The returned array 22467 * is a copy, the features are references to the features in the source. 22468 * @return {Array<import("../Feature.js").default<Geometry>>} Features. 22469 * @api 22470 */ 22471 getFeatures() { 22472 let t; 22473 return this.featuresCollection_ ? t = this.featuresCollection_.getArray().slice(0) : this.featuresRtree_ && (t = this.featuresRtree_.getAll(), un(this.nullGeometryFeatures_) || mi(t, Object.values(this.nullGeometryFeatures_))), /** @type {Array<import("../Feature.js").default<Geometry>>} */ 22474 t; 22475 } 22476 /** 22477 * Get all features whose geometry intersects the provided coordinate. 22478 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 22479 * @return {Array<import("../Feature.js").default<Geometry>>} Features. 22480 * @api 22481 */ 22482 getFeaturesAtCoordinate(t) { 22483 const i = []; 22484 return this.forEachFeatureAtCoordinateDirect(t, function(s) { 22485 i.push(s); 22486 }), i; 22487 } 22488 /** 22489 * Get all features whose bounding box intersects the provided extent. Note that this returns an array of 22490 * all features intersecting the given extent in random order (so it may include 22491 * features whose geometries do not intersect the extent). 22492 * 22493 * When `useSpatialIndex` is set to false, this method will return all 22494 * features. 22495 * 22496 * @param {import("../extent.js").Extent} extent Extent. 22497 * @param {import("../proj/Projection.js").default} [projection] Include features
22498 * where `extent` exceeds the x-axis bounds of `projection` and wraps around the world. 22499 * @return {Array<import("../Feature.js").default<Geometry>>} Features. 22500 * @api 22501 */ 22502 getFeaturesInExtent(t, i) { 22503 if (this.featuresRtree_) { 22504 if (!(i && i.canWrapX() && this.getWrapX())) 22505 return this.featuresRtree_.getInExtent(t); 22506 const n = Xy(t, i); 22507 return [].concat( 22508 ...n.map((r) => this.featuresRtree_.getInExtent(r)) 22509 ); 22510 } 22511 return this.featuresCollection_ ? this.featuresCollection_.getArray().slice(0) : []; 22512 } 22513 /** 22514 * Get the closest feature to the provided coordinate. 22515 * 22516 * This method is not available when the source is configured with 22517 * `useSpatialIndex` set to `false`. 22518 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 22519 * @param {function(import("../Feature.js").default<Geometry>):boolean} [filter] Feature filter function. 22520 * The filter function will receive one argument, the {@link module:ol/Feature~Feature feature} 22521 * and it should return a boolean value. By default, no filtering is made. 22522 * @return {import("../Feature.js").default<Geometry>} Closest feature. 22523 * @api 22524 */ 22525 getClosestFeatureToCoordinate(t, i) { 22526 const s = t[0], n = t[1]; 22527 let r = null; 22528 const o = [NaN, NaN]; 22529 let a = 1 / 0; 22530 const l = [-1 / 0, -1 / 0, 1 / 0, 1 / 0]; 22531 return i = i || bs, this.featuresRtree_.forEachInExtent( 22532 l, 22533 /** 22534 * @param {import("../Feature.js").default<Geometry>} feature Feature. 22535 */ 22536 function(h) { 22537 if (i(h)) { 22538 const c = h.getGeometry(), u = a; 22539 if (a = c.closestPointXY( 22540 s, 22541 n, 22542 o, 22543 a 22544 ), a < u) { 22545 r = h; 22546 const d = Math.sqrt(a); 22547 l[0] = s - d, l[1] = n - d, l[2] = s + d, l[3] = n + d; 22548 } 22549 } 22550 } 22551 ), r; 22552 } 22553 /** 22554 * Get the extent of the features currently in the source. 22555 * 22556 * This method is not available when the source is configured with 22557 * `useSpatialIndex` set to `false`. 22558 * @param {import("../extent.js").Extent} [extent] Destination extent. If provided, no new extent 22559 * will be created. Instead, that extent's coordinates will be overwritten. 22560 * @return {import("../extent.js").Extent} Extent. 22561 * @api 22562 */ 22563 getExtent(t) { 22564 return this.featuresRtree_.getExtent(t); 22565 } 22566 /** 22567 * Get a feature by its identifier (the value returned by feature.getId()). 22568 * Note that the index treats string and numeric identifiers as the same. So 22569 * `source.getFeatureById(2)` will return a feature with id `'2'` or `2`. 22570 * 22571 * @param {string|number} id Feature identifier. 22572 * @return {import("../Feature.js").default<Geometry>|null} The feature (or `null` if not found). 22573 * @api 22574 */ 22575 getFeatureById(t) { 22576 const i = this.idIndex_[t.toString()]; 22577 return i !== void 0 ? i : null; 22578 } 22579 /** 22580 * Get a feature by its internal unique identifier (using `getUid`). 22581 * 22582 * @param {string} uid Feature identifier. 22583 * @return {import("../Feature.js").default<Geometry>|null} The feature (or `null` if not found). 22584 */ 22585 getFeatureByUid(t) { 22586 const i = this.uidIndex_[t]; 22587 return i !== void 0 ? i : null; 22588 } 22589 /** 22590 * Get the format associated with this source. 22591 * 22592 * @return {import("../format/Feature.js").default|undefined} The feature format. 22593 * @api 22594 */ 22595 getFormat() { 22596 return this.format_; 22597 } 22598 /** 22599 * @return {boolean} The source can have overlapping geometries. 22600 */ 22601 getOverlaps() { 22602 return this.overlaps_; 22603 } 22604 /** 22605 * Get the url associated with this source. 22606 * 22607 * @return {string|import("../featureloader.js").FeatureUrlFunction|undefined} The url. 22608 * @api 22609 */ 22610 getUrl() { 22611 return this.url_; 22612 } 22613 /** 22614 * @param {Event} event Event. 22615 * @private 22616 */ 22617 handleFeatureChange_(t) { 22618 const i = ( 22619 /** @type {import("../Feature.js").default<Geometry>} */ 22620 t.target 22621 ), s = ot(i), n = i.getGeometry(); 22622 if (!n) 22623 s in this.nullGeometryFeatures_ || (this.featuresRtree_ && this.featuresRtree_.remove(i), this.nullGeometryFeatures_[s] = i); 22624 else { 22625 const o = n.getExtent(); 22626 s in this.nullGeometryFeatures_ ? (delete this.nullGeometryFeatures_[s], this.featuresRtree_ && this.featuresRtree_.insert(o, i)) : this.featuresRtree_ && this.featuresRtree_.update(o, i); 22627 } 22628 const r = i.getId(); 22629 if (r !== void 0) { 22630 const o = r.toString(); 22631 this.idIndex_[o] !== i && (this.removeFromIdIndex_(i), this.idIndex_[o] = i); 22632 } else 22633 this.removeFromIdIndex_(i), this.uidIndex_[s] = i; 22634 this.changed(), this.dispatchEvent( 22635 new Ii(le.CHANGEFEATURE, i) 22636 ); 22637 } 22638 /** 22639 * Returns true if the feature is contained within the source. 22640 * @param {import("../Feature.js").default<Geometry>} feature Feature. 22641 * @return {boolean} Has feature. 22642 * @api 22643 */ 22644 hasFeature(t) { 22645 const i = t.getId(); 22646 return i !== void 0 ? i in this.idIndex_ : ot(t) in this.uidIndex_; 22647 } 22648 /** 22649 * @return {boolean} Is empty. 22650 */ 22651 isEmpty() { 22652 return this.featuresRtree_ ? this.featuresRtree_.isEmpty() && un(this.nullGeometryFeatures_) : this.featuresCollection_ ? this.featuresCollection_.getLength() === 0 : !0; 22653 } 22654 /** 22655 * @param {import("../extent.js").Extent} extent Extent. 22656 * @param {number} resolution Resolution. 22657 * @param {import("../proj/Projection.js").default} projection Projection. 22658 */ 22659 loadFeatures(t, i, s) { 22660 const n = this.loadedExtentsRtree_, r = this.strategy_(t, i, s); 22661 for (let o = 0, a = r.length; o < a; ++o) { 22662 const l = r[o];
22663 n.forEachInExtent( 22664 l, 22665 /** 22666 * @param {{extent: import("../extent.js").Extent}} object Object. 22667 * @return {boolean} Contains. 22668 */ 22669 function(c) { 22670 return Gi(c.extent, l); 22671 } 22672 ) || (++this.loadingExtentsCount_, this.dispatchEvent( 22673 new Ii(le.FEATURESLOADSTART) 22674 ), this.loader_.call( 22675 this, 22676 l, 22677 i, 22678 s, 22679 (c) => { 22680 --this.loadingExtentsCount_, this.dispatchEvent( 22681 new Ii( 22682 le.FEATURESLOADEND, 22683 void 0, 22684 c 22685 ) 22686 ); 22687 }, 22688 () => { 22689 --this.loadingExtentsCount_, this.dispatchEvent( 22690 new Ii(le.FEATURESLOADERROR) 22691 ); 22692 } 22693 ), n.insert(l, { extent: l.slice() })); 22694 } 22695 this.loading = this.loader_.length < 4 ? !1 : this.loadingExtentsCount_ > 0; 22696 } 22697 refresh() { 22698 this.clear(!0), this.loadedExtentsRtree_.clear(), super.refresh(); 22699 } 22700 /** 22701 * Remove an extent from the list of loaded extents. 22702 * @param {import("../extent.js").Extent} extent Extent. 22703 * @api 22704 */ 22705 removeLoadedExtent(t) { 22706 const i = this.loadedExtentsRtree_; 22707 let s; 22708 i.forEachInExtent(t, function(n) { 22709 if (fn(n.extent, t)) 22710 return s = n, !0; 22711 }), s && i.remove(s); 22712 } 22713 /** 22714 * Remove a single feature from the source. If you want to remove all features 22715 * at once, use the {@link module:ol/source/Vector~VectorSource#clear #clear()} method 22716 * instead. 22717 * @param {import("../Feature.js").default<Geometry>} feature Feature to remove. 22718 * @api 22719 */ 22720 removeFeature(t) { 22721 if (!t) 22722 return; 22723 const i = ot(t); 22724 i in this.nullGeometryFeatures_ ? delete this.nullGeometryFeatures_[i] : this.featuresRtree_ && this.featuresRtree_.remove(t), this.removeFeatureInternal(t) && this.changed(); 22725 } 22726 /** 22727 * Remove feature without firing a `change` event. 22728 * @param {import("../Feature.js").default<Geometry>} feature Feature. 22729 * @return {import("../Feature.js").default<Geometry>|undefined} The removed feature 22730 * (or undefined if the feature was not found). 22731 * @protected 22732 */ 22733 removeFeatureInternal(t) { 22734 const i = ot(t), s = this.featureChangeKeys_[i]; 22735 if (!s) 22736 return;
22737 s.forEach(Mt), delete this.featureChangeKeys_[i]; 22738 const n = t.getId(); 22739 return n !== void 0 && delete this.idIndex_[n.toString()], delete this.uidIndex_[i], this.dispatchEvent( 22740 new Ii(le.REMOVEFEATURE, t) 22741 ), t; 22742 } 22743 /** 22744 * Remove a feature from the id index. Called internally when the feature id 22745 * may have changed. 22746 * @param {import("../Feature.js").default<Geometry>} feature The feature. 22747 * @return {boolean} Removed the feature from the index. 22748 * @private 22749 */ 22750 removeFromIdIndex_(t) { 22751 let i = !1; 22752 for (const s in this.idIndex_) 22753 if (this.idIndex_[s] === t) { 22754 delete this.idIndex_[s], i = !0; 22755 break; 22756 } 22757 return i; 22758 } 22759 /** 22760 * Set the new loader of the source. The next render cycle will use the 22761 * new loader. 22762 * @param {import("../featureloader.js").FeatureLoader} loader The loader to set. 22763 * @api 22764 */ 22765 setLoader(t) { 22766 this.loader_ = t; 22767 } 22768 /** 22769 * Points the source to a new url. The next render cycle will use the new url. 22770 * @param {string|import("../featureloader.js").FeatureUrlFunction} url Url. 22771 * @api 22772 */ 22773 setUrl(t) { 22774 at(this.format_, 7), this.url_ = t, this.setLoader(Uu(t, this.format_)); 22775 } 22776} 22777const ya = Cb; 22778class bb extends Ir { 22779 /** 22780 * @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate. 22781 * @param {import("./TileState.js").default} state State. 22782 * @param {Options} [options] Tile options. 22783 */ 22784 constructor(t, i, s) { 22785 super(), s = s || {}, this.tileCoord = t, this.state = i, this.interimTile = null, this.key = "", this.transition_ = s.transition === void 0 ? 250 : s.transition, this.transitionStarts_ = {}, this.interpolate = !!s.interpolate; 22786 } 22787 /** 22788 * @protected 22789 */ 22790 changed() { 22791 this.dispatchEvent(et.CHANGE); 22792 } 22793 /** 22794 * Called by the tile cache when the tile is removed from the cache due to expiry 22795 */ 22796 release() { 22797 this.state === H.ERROR && this.setState(H.EMPTY); 22798 } 22799 /** 22800 * @return {string} Key. 22801 */ 22802 getKey() { 22803 return this.key + "/" + this.tileCoord; 22804 } 22805 /** 22806 * Get the interim tile most suitable for rendering using the chain of interim 22807 * tiles. This corresponds to the most recent tile that has been loaded, if no 22808 * such tile exists, the original tile is returned. 22809 * @return {!Tile} Best tile for rendering. 22810 */ 22811 getInterimTile() { 22812 if (!this.interimTile) 22813 return this; 22814 let t = this.interimTile; 22815 do { 22816 if (t.getState() == H.LOADED) 22817 return this.transition_ = 0, t; 22818 t = t.interimTile; 22819 } while (t); 22820 return this; 22821 } 22822 /** 22823 * Goes through the chain of interim tiles and discards sections of the chain 22824 * that are no longer relevant. 22825 */ 22826 refreshInterimChain() { 22827 if (!this.interimTile) 22828 return; 22829 let t = this.interimTile, i = this; 22830 do { 22831 if (t.getState() == H.LOADED) { 22832 t.interimTile = null; 22833 break; 22834 } else 22835 t.getState() == H.LOADING ? i = t : t.getState() == H.IDLE ? i.interimTile = t.interimTile : i = t; 22836 t = i.interimTile; 22837 } while (t); 22838 } 22839 /** 22840 * Get the tile coordinate for this tile. 22841 * @return {import("./tilecoord.js").TileCoord} The tile coordinate. 22842 * @api 22843 */ 22844 getTileCoord() { 22845 return this.tileCoord; 22846 } 22847 /** 22848 * @return {import("./TileState.js").default} State. 22849 */ 22850 getState() { 22851 return this.state; 22852 } 22853 /** 22854 * Sets the state of this tile. If you write your own {@link module:ol/Tile~LoadFunction tileLoadFunction} , 22855 * it is important to set the state correctly to {@link module:ol/TileState~ERROR} 22856 * when the tile cannot be loaded. Otherwise the tile cannot be removed from 22857 * the tile queue and will block other requests. 22858 * @param {import("./TileState.js").default} state State. 22859 * @api 22860 */ 22861 setState(t) { 22862 if (this.state !== H.ERROR && this.state > t) 22863 throw new Error("Tile load sequence violation"); 22864 this.state = t, this.changed(); 22865 } 22866 /** 22867 * Load the image or retry if loading previously failed. 22868 * Loading is taken care of by the tile queue, and calling this method is 22869 * only needed for preloading or for reloading in case of an error. 22870 * @abstract 22871 * @api 22872 */ 22873 load() { 22874 Z(); 22875 } 22876 /** 22877 * Get the alpha value for rendering. 22878 * @param {string} id An id for the renderer. 22879 * @param {number} time The render frame time. 22880 * @return {number} A number between 0 and 1. 22881 */ 22882 getAlpha(t, i) { 22883 if (!this.transition_) 22884 return 1; 22885 let s = this.transitionStarts_[t]; 22886 if (!s) 22887 s = i, this.transitionStarts_[t] = s; 22888 else if (s === -1) 22889 return 1;
22890 const n = i - s + 1e3 / 60; 22891 return n >= this.transition_ ? 1 : Uf(n / this.transition_); 22892 } 22893 /** 22894 * Determine if a tile is in an alpha transition. A tile is considered in 22895 * transition if tile.getAlpha() has not yet been called or has been called 22896 * and returned 1. 22897 * @param {string} id An id for the renderer. 22898 * @return {boolean} The tile is in transition. 22899 */ 22900 inTransition(t) { 22901 return this.transition_ ? this.transitionStarts_[t] !== -1 : !1; 22902 } 22903 /** 22904 * Mark a transition as complete. 22905 * @param {string} id An id for the renderer. 22906 */ 22907 endTransition(t) { 22908 this.transition_ && (this.transitionStarts_[t] = -1); 22909 } 22910} 22911const wg = bb; 22912class Sb extends wg { 22913 /** 22914 * @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate. 22915 * @param {import("./TileState.js").default} state State. 22916 * @param {string} src Image source URI. 22917 * @param {?string} crossOrigin Cross origin. 22918 * @param {import("./Tile.js").LoadFunction} tileLoadFunction Tile load function. 22919 * @param {import("./Tile.js").Options} [options] Tile options. 22920 */ 22921 constructor(t, i, s, n, r, o) { 22922 super(t, i, o), this.crossOrigin_ = n, this.src_ = s, this.key = s, this.image_ = new Image(), n !== null && (this.image_.crossOrigin = n), this.unlisten_ = null, this.tileLoadFunction_ = r; 22923 } 22924 /** 22925 * Get the HTML image element for this tile (may be a Canvas, Image, or Video). 22926 * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image. 22927 * @api 22928 */ 22929 getImage() { 22930 return this.image_; 22931 } 22932 /** 22933 * Sets an HTML image element for this tile (may be a Canvas or preloaded Image). 22934 * @param {HTMLCanvasElement|HTMLImageElement} element Element. 22935 */ 22936 setImage(t) { 22937 this.image_ = t, this.state = H.LOADED, this.unlistenImage_(), this.changed(); 22938 } 22939 /** 22940 * Tracks loading or read errors. 22941 * 22942 * @private 22943 */ 22944 handleImageError_() { 22945 this.state = H.ERROR, this.unlistenImage_(), this.image_ = wb(), this.changed(); 22946 } 22947 /** 22948 * Tracks successful image load. 22949 * 22950 * @private 22951 */ 22952 handleImageLoad_() { 22953 const t = ( 22954 /** @type {HTMLImageElement} */ 22955 this.image_ 22956 ); 22957 t.naturalWidth && t.naturalHeight ? this.state = H.LOADED : this.state = H.EMPTY, this.unlistenImage_(), this.changed(); 22958 } 22959 /** 22960 * Load the image or retry if loading previously failed. 22961 * Loading is taken care of by the tile queue, and calling this method is 22962 * only needed for preloading or for reloading in case of an error. 22963 * 22964 * To retry loading tiles on failed requests, use a custom `tileLoadFunction` 22965 * that checks for error status codes and reloads only when the status code is 22966 * 408, 429, 500, 502, 503 and 504, and only when not too many retries have been 22967 * made already: 22968 * 22969 * ```js 22970 * const retryCodes = [408, 429, 500, 502, 503, 504]; 22971 * const retries = {}; 22972 * source.setTileLoadFunction((tile, src) => { 22973 * const image = tile.getImage(); 22974 * fetch(src) 22975 * .then((response) => { 22976 * if (retryCodes.includes(response.status)) { 22977 * retries[src] = (retries[src] || 0) + 1; 22978 * if (retries[src] <= 3) { 22979 * setTimeout(() => tile.load(), retries[src] * 1000); 22980 * } 22981 * return Promise.reject(); 22982 * } 22983 * return response.blob(); 22984 * }) 22985 * .then((blob) => { 22986 * const imageUrl = URL.createObjectURL(blob); 22987 * image.src = imageUrl; 22988 * setTimeout(() => URL.revokeObjectURL(imageUrl), 5000); 22989 * }) 22990 * .catch(() => tile.setState(3)); // error 22991 * }); 22992 * ``` 22993 * 22994 * @api 22995 */ 22996 load() { 22997 this.state == H.ERROR && (this.state = H.IDLE, this.image_ = new Image(), this.crossOrigin_ !== null && (this.image_.crossOrigin = this.crossOrigin_)), this.state == H.IDLE && (this.state = H.LOADING, this.changed(), this.tileLoadFunction_(this, this.src_), this.unlisten_ = Vh( 22998 this.image_, 22999 this.handleImageLoad_.bind(this), 23000 this.handleImageError_.bind(this) 23001 )); 23002 } 23003 /** 23004 * Discards event handlers which listen for load completion or errors. 23005 * 23006 * @private 23007 */ 23008 unlistenImage_() { 23009 this.unlisten_ && (this.unlisten_(), this.unlisten_ = null); 23010 } 23011} 23012function wb() { 23013 const e = re(1, 1); 23014 return e.fillStyle = "rgba(0,0,0,0)", e.fillRect(0, 0, 1, 1), e.canvas; 23015} 23016const Tg = Sb; 23017class Tb { 23018 /** 23019 * @param {number} [highWaterMark] High water mark. 23020 */ 23021 constructor(t) { 23022 this.highWaterMark = t !== void 0 ? t : 2048, this.count_ = 0, this.entries_ = {}, this.oldest_ = null, this.newest_ = null; 23023 } 23024 /** 23025 * @return {boolean} Can expire cache. 23026 */ 23027 canExpireCache() { 23028 return this.highWaterMark > 0 && this.getCount() > this.highWaterMark; 23029 } 23030 /** 23031 * Expire the cache. 23032 * @param {!Object<string, boolean>} [keep] Keys to keep. To be implemented by subclasses. 23033 */ 23034 expireCache(t) { 23035 for (; this.canExpireCache(); ) 23036 this.pop(); 23037 } 23038 /** 23039 * FIXME empty description for jsdoc 23040 */ 23041 clear() { 23042 this.count_ = 0, this.entries_ = {}, this.oldest_ = null, this.newest_ = null; 23043 } 23044 /** 23045 * @param {string} key Key. 23046 * @return {boolean} Contains key. 23047 */ 23048 containsKey(t) { 23049 return this.entries_.hasOwnProperty(t); 23050 } 23051 /** 23052 * @param {function(T, string, LRUCache<T>): ?} f The function 23053 * to call for every entry from the oldest to the newer. This function takes 23054 * 3 arguments (the entry value, the entry key and the LRUCache object). 23055 * The return value is ignored. 23056 */ 23057 forEach(t) { 23058 let i = this.oldest_; 23059 for (; i; ) 23060 t(i.value_, i.key_, this), i = i.newer; 23061 } 23062 /** 23063 * @param {string} key Key. 23064 * @param {*} [options] Options (reserved for subclasses). 23065 * @return {T} Value. 23066 */ 23067 get(t, i) { 23068 const s = this.entries_[t]; 23069 return at(s !== void 0, 15), s === this.newest_ || (s === this.oldest_ ? (this.oldest_ = /** @type {Entry} */ 23070 this.oldest_.newer, this.oldest_.older = null) : (s.newer.older = s.older, s.older.newer = s.newer), s.newer = null, s.older = this.newest_, this.newest_.newer = s, this.newest_ = s), s.value_; 23071 } 23072 /** 23073 * Remove an entry from the cache. 23074 * @param {string} key The entry key. 23075 * @return {T} The removed entry. 23076 */ 23077 remove(t) { 23078 const i = this.entries_[t]; 23079 return at(i !== void 0, 15), i === this.newest_ ? (this.newest_ = /** @type {Entry} */ 23080 i.older, this.newest_ && (this.newest_.newer = null)) : i === this.oldest_ ? (this.oldest_ = /** @type {Entry} */ 23081 i.newer, this.oldest_ && (this.oldest_.older = null)) : (i.newer.older = i.older, i.older.newer = i.newer), delete this.entries_[t], --this.count_, i.value_; 23082 } 23083 /** 23084 * @return {number} Count. 23085 */ 23086 getCount() { 23087 return this.count_; 23088 } 23089 /** 23090 * @return {Array<string>} Keys. 23091 */ 23092 getKeys() { 23093 const t = new Array(this.count_); 23094 let i = 0, s; 23095 for (s = this.newest_; s; s = s.older) 23096 t[i++] = s.key_; 23097 return t; 23098 } 23099 /** 23100 * @return {Array<T>} Values. 23101 */ 23102 getValues() { 23103 const t = new Array(this.count_); 23104 let i = 0, s; 23105 for (s = this.newest_; s; s = s.older) 23106 t[i++] = s.value_; 23107 return t; 23108 } 23109 /** 23110 * @return {T} Last value. 23111 */ 23112 peekLast() { 23113 return this.oldest_.value_; 23114 } 23115 /** 23116 * @return {string} Last key. 23117 */ 23118 peekLastKey() { 23119 return this.oldest_.key_;
23120 } 23121 /** 23122 * Get the key of the newest item in the cache. Throws if the cache is empty. 23123 * @return {string} The newest key. 23124 */ 23125 peekFirstKey() { 23126 return this.newest_.key_; 23127 } 23128 /** 23129 * Return an entry without updating least recently used time. 23130 * @param {string} key Key. 23131 * @return {T} Value. 23132 */ 23133 peek(t) { 23134 if (this.containsKey(t)) 23135 return this.entries_[t].value_; 23136 } 23137 /** 23138 * @return {T} value Value. 23139 */ 23140 pop() { 23141 const t = this.oldest_; 23142 return delete this.entries_[t.key_], t.newer && (t.newer.older = null), this.oldest_ = /** @type {Entry} */ 23143 t.newer, this.oldest_ || (this.newest_ = null), --this.count_, t.value_; 23144 } 23145 /** 23146 * @param {string} key Key. 23147 * @param {T} value Value. 23148 */ 23149 replace(t, i) { 23150 this.get(t), this.entries_[t].value_ = i; 23151 } 23152 /** 23153 * @param {string} key Key. 23154 * @param {T} value Value. 23155 */ 23156 set(t, i) { 23157 at(!(t in this.entries_), 16); 23158 const s = { 23159 key_: t, 23160 newer: null, 23161 older: this.newest_, 23162 value_: i 23163 }; 23164 this.newest_ ? this.newest_.newer = s : this.oldest_ = s, this.newest_ = s, this.entries_[t] = s, ++this.count_; 23165 } 23166 /** 23167 * Set a maximum number of entries for the cache. 23168 * @param {number} size Cache size. 23169 * @api 23170 */ 23171 setSize(t) { 23172 this.highWaterMark = t; 23173 } 23174} 23175const Rb = Tb; 23176function Xu(e, t, i, s) { 23177 return s !== void 0 ? (s[0] = e, s[1] = t, s[2] = i, s) : [e, t, i]; 23178} 23179function xa(e, t, i) { 23180 return e + "/" + t + "/" + i; 23181} 23182function Rg(e) { 23183 return xa(e[0], e[1], e[2]); 23184} 23185function Ib(e) { 23186 return e.split("/").map(Number); 23187} 23188function Ig(e) { 23189 return (e[1] << e[0]) + e[2]; 23190} 23191function Pb(e, t) { 23192 const i = e[0], s = e[1], n = e[2]; 23193 if (t.getMinZoom() > i || i > t.getMaxZoom()) 23194 return !1; 23195 const r = t.getFullTileRange(i); 23196 return r ? r.containsXY(s, n) : !0; 23197} 23198class Ab extends Rb { 23199 clear() { 23200 for (; this.getCount() > 0; ) 23201 this.pop().release(); 23202 super.clear(); 23203 } 23204 /** 23205 * @param {!Object<string, boolean>} usedTiles Used tiles. 23206 */ 23207 expireCache(t) { 23208 for (; this.canExpireCache() && !(this.peekLast().getKey() in t); ) 23209 this.pop().release(); 23210 } 23211 /** 23212 * Prune all tiles from the cache that don't have the same z as the newest tile. 23213 */ 23214 pruneExceptNewestZ() { 23215 if (this.getCount() === 0) 23216 return; 23217 const t = this.peekFirstKey(), s = Ib(t)[0]; 23218 this.forEach((n) => { 23219 n.tileCoord[0] !== s && (this.remove(Rg(n.tileCoord)), n.release()); 23220 }); 23221 } 23222} 23223const Pg = Ab; 23224class Ag { 23225 /** 23226 * @param {number} minX Minimum X. 23227 * @param {number} maxX Maximum X. 23228 * @param {number} minY Minimum Y. 23229 * @param {number} maxY Maximum Y. 23230 */ 23231 constructor(t, i, s, n) { 23232 this.minX = t, this.maxX = i, this.minY = s, this.maxY = n; 23233 } 23234 /** 23235 * @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate. 23236 * @return {boolean} Contains tile coordinate. 23237 */ 23238 contains(t) { 23239 return this.containsXY(t[1], t[2]); 23240 } 23241 /** 23242 * @param {TileRange} tileRange Tile range. 23243 * @return {boolean} Contains. 23244 */ 23245 containsTileRange(t) { 23246 return this.minX <= t.minX && t.maxX <= this.maxX && this.minY <= t.minY && t.maxY <= this.maxY; 23247 } 23248 /** 23249 * @param {number} x Tile coordinate x. 23250 * @param {number} y Tile coordinate y. 23251 * @return {boolean} Contains coordinate. 23252 */ 23253 containsXY(t, i) { 23254 return this.minX <= t && t <= this.maxX && this.minY <= i && i <= this.maxY; 23255 } 23256 /** 23257 * @param {TileRange} tileRange Tile range. 23258 * @return {boolean} Equals. 23259 */ 23260 equals(t) { 23261 return this.minX == t.minX && this.minY == t.minY && this.maxX == t.maxX && this.maxY == t.maxY; 23262 } 23263 /** 23264 * @param {TileRange} tileRange Tile range. 23265 */ 23266 extend(t) { 23267 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); 23268 } 23269 /** 23270 * @return {number} Height. 23271 */ 23272 getHeight() { 23273 return this.maxY - this.minY + 1; 23274 } 23275 /** 23276 * @return {import("./size.js").Size} Size. 23277 */ 23278 getSize() { 23279 return [this.getWidth(), this.getHeight()]; 23280 } 23281 /** 23282 * @return {number} Width. 23283 */ 23284 getWidth() { 23285 return this.maxX - this.minX + 1; 23286 } 23287 /** 23288 * @param {TileRange} tileRange Tile range. 23289 * @return {boolean} Intersects. 23290 */ 23291 intersects(t) { 23292 return this.minX <= t.maxX && this.maxX >= t.minX && this.minY <= t.maxY && this.maxY >= t.minY; 23293 } 23294} 23295function Ns(e, t, i, s, n) { 23296 return n !== void 0 ? (n.minX = e, n.maxX = t, n.minY = i, n.maxY = s, n) : new Ag(e, t, i, s); 23297} 23298const Lg = Ag, $u = 0, Zn = 1, Yu = [0, 0, 0, 0], an = [], Xa = { 23299 /** 23300 * Triggered upon feature modification start 23301 * @event ModifyEvent#modifystart 23302 * @api 23303 */ 23304 MODIFYSTART: "modifystart", 23305 /** 23306 * Triggered upon feature modification end 23307 * @event ModifyEvent#modifyend 23308 * @api 23309 */ 23310 MODIFYEND: "modifyend" 23311}; 23312class $a extends Ae { 23313 /** 23314 * @param {ModifyEventType} type Type. 23315 * @param {Collection<Feature>} features 23316 * The features modified. 23317 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent 23318 * Associated {@link module:ol/MapBrowserEvent~MapBrowserEvent}. 23319 */ 23320 constructor(t, i, s) { 23321 super(t), this.features = i, this.mapBrowserEvent = s; 23322 } 23323} 23324class Lb extends es { 23325 /** 23326 * @param {Options} options Options. 23327 */ 23328 constructor(t) { 23329 super( 23330 /** @type {import("./Pointer.js").Options} */ 23331 t 23332 ), this.on, this.once, this.un, this.boundHandleFeatureChange_ = this.handleFeatureChange_.bind(this), this.condition_ = t.condition ? t.condition : cg, this.defaultDeleteCondition_ = function(s) { 23333 return AM(s) && DM(s); 23334 }, this.deleteCondition_ = t.deleteCondition ? t.deleteCondition : this.defaultDeleteCondition_, this.insertVertexCondition_ = t.insertVertexCondition ? t.insertVertexCondition : zo, this.vertexFeature_ = null, this.vertexSegments_ = null, this.lastPixel_ = [0, 0], this.ignoreNextSingleClick_ = !1, this.featuresBeingModified_ = null, this.rBush_ = new Wo(), this.pixelTolerance_ = t.pixelTolerance !== void 0 ? t.pixelTolerance : 10, this.snappedToVertex_ = !1, this.changingFeature_ = !1, this.dragSegments_ = [], this.overlay_ = new pa({ 23335 source: new ya({ 23336 useSpatialIndex: !1, 23337 wrapX: !!t.wrapX 23338 }), 23339 style: t.style ? t.style : Fb(), 23340 updateWhileAnimating: !0, 23341 updateWhileInteracting: !0 23342 }), this.SEGMENT_WRITERS_ = { 23343 Point: this.writePointGeometry_.bind(this), 23344 LineString: this.writeLineStringGeometry_.bind(this), 23345 LinearRing: this.writeLineStringGeometry_.bind(this), 23346 Polygon: this.writePolygonGeometry_.bind(this), 23347 MultiPoint: this.writeMultiPointGeometry_.bind(this), 23348 MultiLineString: this.writeMultiLineStringGeometry_.bind(this), 23349 MultiPolygon: this.writeMultiPolygonGeometry_.bind(this), 23350 Circle: this.writeCircleGeometry_.bind(this), 23351 GeometryCollection: this.writeGeometryCollectionGeometry_.bind(this) 23352 }, this.source_ = null, this.hitDetection_ = null; 23353 let i; 23354 if (t.features ? i = t.features : t.source && (this.source_ = t.s
23354ource, i = new Pe(this.source_.getFeatures()), this.source_.addEventListener( 23355 le.ADDFEATURE, 23356 this.handleSourceAdd_.bind(this) 23357 ), this.source_.addEventListener( 23358 le.REMOVEFEATURE, 23359 this.handleSourceRemove_.bind(this) 23360 )), !i) 23361 throw new Error( 23362 "The modify interaction requires features, a source or a layer" 23363 ); 23364 t.hitDetection && (this.hitDetection_ = t.hitDetection), this.features_ = i, this.features_.forEach(this.addFeature_.bind(this)), this.features_.addEventListener( 23365 $t.ADD, 23366 this.handleFeatureAdd_.bind(this) 23367 ), this.features_.addEventListener( 23368 $t.REMOVE, 23369 this.handleFeatureRemove_.bind(this) 23370 ), this.lastPointerEvent_ = null, this.delta_ = [0, 0], this.snapToPointer_ = t.snapToPointer === void 0 ? !this.hitDetection_ : t.snapToPointer; 23371 } 23372 /** 23373 * @param {Feature} feature Feature. 23374 * @private 23375 */ 23376 addFeature_(t) { 23377 const i = t.getGeometry(); 23378 if (i) { 23379 const n = this.SEGMENT_WRITERS_[i.getType()]; 23380 n && n(t, i); 23381 } 23382 const s = this.getMap(); 23383 s && s.isRendered() && this.getActive() && this.handlePointerAtPixel_(this.lastPixel_, s), t.addEventListener(et.CHANGE, this.boundHandleFeatureChange_); 23384 } 23385 /** 23386 * @param {import("../MapBrowserEvent.js").default} evt Map browser event. 23387 * @param {Array<Array<SegmentData>>} segments The segments subject to modification. 23388 * @private 23389 */ 23390 willModifyFeatures_(t, i) { 23391 if (!this.featuresBeingModified_) { 23392 this.featuresBeingModified_ = new Pe(); 23393 const s = this.featuresBeingModified_.getArray(); 23394 for (let n = 0, r = i.length; n < r; ++n) { 23395 const o = i[n]; 23396 for (let a = 0, l = o.length; a < l; ++a) { 23397 const h = o[a].feature; 23398 h && !s.includes(h) && this.featuresBeingModified_.push(h); 23399 } 23400 } 23401 this.featuresBeingModified_.getLength() === 0 ? this.featuresBeingModified_ = null : this.dispatchEvent( 23402 new $a( 23403 Xa.MODIFYSTART, 23404 this.featuresBeingModified_, 23405 t 23406 ) 23407 ); 23408 } 23409 } 23410 /** 23411 * @param {Feature} feature Feature. 23412 * @private 23413 */ 23414 removeFeature_(t) { 23415 this.removeFeatureSegmentData_(t), this.vertexFeature_ && this.features_.getLength() === 0 && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null), t.removeEventListener( 23416 et.CHANGE, 23417 this.boundHandleFeatureChange_ 23418 ); 23419 } 23420 /** 23421 * @param {Feature} feature Feature. 23422 * @private 23423 */ 23424 removeFeatureSegmentData_(t) { 23425 const i = this.rBush_, s = []; 23426 i.forEach( 23427 /** 23428 * @param {SegmentData} node RTree node. 23429 */ 23430 function(n) { 23431 t === n.feature && s.push(n); 23432 } 23433 ); 23434 for (let n = s.length - 1; n >= 0; --n) { 23435 const r = s[n]; 23436 for (let o = this.dragSegments_.length - 1; o >= 0; --o) 23437 this.dragSegments_[o][0] === r && this.dragSegments_.splice(o, 1); 23438 i.remove(r); 23439 } 23440 } 23441 /** 23442 * Activate or deactivate the interaction. 23443 * @param {boolean} active Active. 23444 * @observable 23445 * @api 23446 */ 23447 setActive(t) { 23448 this.vertexFeature_ && !t && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null), super.setActive(t); 23449 } 23450 /** 23451 * Remove the interaction from its current map and attach it to the new map. 23452 * Subclasses may set up event handlers to get notified about changes to 23453 * the map here. 23454 * @param {import("../Map.js").default} map Map. 23455 */ 23456 setMap(t) { 23457 this.overlay_.setMap(t), super.setMap(t); 23458 } 23459 /** 23460 * Get the overlay layer that this interaction renders the modification point or vertex to. 23461 * @return {VectorLayer} Overlay layer. 23462 * @api 23463 */ 23464 getOverlay() { 23465 return this.overlay_; 23466 } 23467 /** 23468 * @param {import("../source/Vector.js").VectorSourceEvent} event Event. 23469 * @private 23470 */ 23471 handleSourceAdd_(t) { 23472 t.feature && this.features_.push(t.feature); 23473 } 23474 /** 23475 * @param {import("../source/Vector.js").VectorSourceEvent} event Event. 23476 * @private 23477 */ 23478 handleSourceRemove_(t) { 23479 t.feature && this.features_.remove(t.feature); 23480 } 23481 /** 23482 * @param {import("../Collection.js").CollectionEvent<Feature>} evt Event. 23483 * @private 23484 */ 23485 handleFeatureAdd_(t) { 23486 this.addFeature_(t.element); 23487 } 23488 /** 23489 * @param {import("../events/Event.js").default} evt Event. 23490 * @private 23491 */ 23492 handleFeatureChange_(t) { 23493 if (!this.changingFeature_) { 23494 const i = ( 23495 /** @type {Feature} */ 23496 t.target 23497 ); 23498 this.removeFeature_(i), this.addFeature_(i); 23499 } 23500 } 23501 /** 23502 * @param {import("../Collection.js").CollectionEvent<Feature>} evt Event. 23503 * @private 23504 */ 23505 handleFeatureRemove_(t) { 23506 this.removeFeature_(t.element); 23507 } 23508 /** 23509 * @param {Feature} feature Feature 23510 * @param {Point} geometry Geometry. 23511 * @private 23512 */ 23513 writePointGeometry_(t, i) { 23514 const s = i.getCoordinates(), n = { 23515 feature: t, 23516 geometry: i, 23517 segment: [s, s] 23518 }; 23519 this.rBush_.insert(i.getExtent(), n); 23520 } 23521 /** 23522 * @param {Feature} feature Feature 23523 * @param {import("../geom/MultiPoint.js").default} geometry Geometry. 23524 * @private 23525 */ 23526 writeMultiPointGeometry_(t, i) { 23527 const s = i.getCoordinates(); 23528 for (let n = 0, r = s.length; n < r; ++n) { 23529 const o = s[n], a = { 23530 feature: t, 23531 geometry: i, 23532 depth: [n], 23533 index: n, 23534 segment: [o, o] 23535 }; 23536 this.rBush_.insert(i.getExtent(), a); 23537 } 23538 } 23539 /** 23540 * @param {Feature} feature Feature 23541 * @param {import("../geom/LineString.js").default} geometry Geometry. 23542 * @private 23543 */ 23544 writeLineStringGeometry_(t, i) { 23545 const s = i.getCoordinates(); 23546 for (let n = 0, r = s.length - 1; n < r; ++n) { 23547 const o = s.slice(n, n + 2), a = { 23548 feature: t, 23549 geometry: i, 23550 index: n, 23551 segment: o 23552 }; 23553 this.rBush_.insert(ce(o), a); 23554 } 23555 } 23556 /** 23557 * @param {Feature} feature Feature 23558 * @param {import("../geom/MultiLineString.js").default} geometry Geometry. 23559 * @private 23560 */ 23561 writeMultiLineStringGeometry_(t, i) { 23562 const s = i.getCoordinates(); 23563 for (let n = 0, r = s.length; n < r; ++n) { 23564 const o = s[n]; 23565 for (let a = 0, l = o.length - 1; a < l; ++a) { 23566 const h = o.slice(a, a + 2), c = { 23567 feature: t, 23568 geometry: i, 23569 depth: [n], 23570 index: a, 23571 segment: h 23572 }; 23573 this.rBush_.insert(ce(h), c); 23574 } 23575 } 23576 } 23577 /** 23578 * @param {Feature} feature Feature 23579 * @param {import("../geom/Polygon.js").default} geometry Geometry. 23580 * @private 23581 */ 23582 writePolygonGeometry_(t, i) { 23583 const s = i.getCoordinates(); 23584 for (let n = 0, r = s.length; n < r; ++n) { 23585 const o = s[n]; 23586 for (let a = 0, l = o.length - 1; a < l; ++a) { 23587 const h = o.slice(a, a + 2), c = { 23588 feature: t, 23589 geometry: i, 23590 depth: [n], 23591 index: a, 23592 segment: h 23593 }; 23594 this.rBush_.insert(ce(h), c); 23595 } 23596 } 23597 } 23598 /** 23599 * @param {Feature} feature Feature 23600 * @param {import("../geom/MultiPolygon.js").default} geometry Geometry. 23601 * @private 23602 */ 23603 writeMultiPolygonGeometry_(t, i) { 23604 const s = i.getCoordinates(); 23605 for (let n = 0, r = s.length; n < r; ++n) { 23606 const o = s[n]; 23607 for (let a = 0, l = o.length; a < l; ++a) { 23608 const h = o[a]; 23609 for (let c = 0, u = h.length - 1; c < u; ++c) { 23610 const d = h.slice(c, c + 2), f = { 23611 feature: t, 23612 geometry: i, 23613 depth: [a, n], 23614 index: c, 23615 segment: d 23616 }; 23617 this.rBush_.insert(ce(d), f); 23618 } 23619 } 23620 } 23621 } 23622 /** 23623 * We convert a circle into two segments. The segment at index 23624 * {@link CIRCLE_CENTER_INDEX} is the 23625 * circle's center (a point). The segment at index 23626 * {@link CIRCLE_CIRCUMFERENCE_INDEX} is 23627 * the circumference, and is not a line segment. 23628 * 23629 * @param {Feature} feature Feature. 23630 * @param {import("../geom/Circle.js").default} geometry Geometry. 23631 * @private 23632 */ 23633 writeCircleGeometry_(t, i) { 23634 const s = i.getCenter(), n = { 23635 feature: t, 23636 geometry: i, 23637 index: $u, 23638 segment: [s, s] 23639 }, r = { 23640 feature: t, 23641 geometry: i, 23642 index: Zn, 23643 segment: [s, s] 23644 }, o = [n, r]; 23645 n.featureSegments = o, r.featureSegments = o, this.rBush_.insert(uo(s), n); 23646 let a = ( 23647 /** @type {import("../geom/Geometry.js").default} */ 23648 i 23649 ); 23650 this.rBush_.insert(a.getExtent(), r); 23651 } 23652 /** 23653 * @param {Feature} feature Feature 23654 * @param {import("../geom/GeometryCollection.js").default} geometry Geometry. 23655 * @private 23656 */ 23657 writeGeometryCollectionGeometry_(t, i) { 23658 const s = i.getGeometriesArray(); 23659 for (let n = 0; n < s.length; ++n) { 23660 const r = s[n], o = this.SEGMENT_WRITERS_[r.getType()]; 23661 o(t, r); 23662 } 23663 } 23664 /** 23665 * @param {import("../coordinate.js").Coordinate} coordinates Coordinates. 23666 * @param {Array<Feature>} features The features being modified. 23667 * @param {Array<import("../geom/SimpleGeometry.js").default>} geometries The geometries being modified. 23668 * @return {Feature} Vertex feature. 23669 * @private 23670 */ 23671 createOrUpdateVertexFeature_(t, i, s) { 23672 let n = this.vertexFeature_; 23673 return n ? n.getGeometry().setCoordinates(t) : (n = new Ni(new pi(t)), this.vertexFeature_ = n, this.overlay_.getSource().addFeature(n)), n.set("features", i), n.set("geometries", s), n; 23674 } 23675 /** 23676 * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may modify the geometry. 23677 * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event. 23678 * @return {boolean} `false` to stop event propagation. 23679 */ 23680 handleEvent(t) { 23681 if (!t.originalEvent) 23682 return !0; 23683 this.lastPointerEvent_ = t; 23684 let i; 23685 return !t.map.getView().getInteracting() && t.type == dt.POINTERMOVE && !this.handlingDownUpSequence && this.handlePointerMove_(t), this.vertexFeature_ && this.deleteCondition_(t) && (t.type != dt.SINGLECLICK || !this.ignoreNextSingleClick_ ? i = this.removePoint() : i = !0), t.type == dt.SINGLECLICK && (this.ignoreNextSingleClick_ = !1), super.handleEvent(t) && !i; 23686 } 23687 /** 23688 * Handle pointer drag events. 23689 * @param {import("../MapBrowserEvent.js").default} evt Event. 23690 */ 23691 handleDragEvent(t) { 23692 this.ignoreNextSingleClick_ = !1, this.willModifyFeatures_(t, this.dragSegments_); 23693 const i = [ 23694 t.coordinate[0] + this.delta_[0], 23695 t.coordinate[1] + this.delta_[1] 23696 ], s = [], n = []; 23697 for (let r = 0, o = this.dragSegments_.length; r < o; ++r) { 23698 const a = this.dragSegments_[r], l = a[0], h = l.feature; 23699 s.includes(h) || s.push(h); 23700 const c = l.geometry; 23701 n.includes(c) || n.push(c); 23702 const u = l.depth; 23703 let d; 23704 const f = l.segment, g = a[1]; 23705 for (; i.length < c.getStride(); ) 23706 i.push(f[g][i.length]); 23707 switch (c.getType()) { 23708 case "Point": 23709 d = i, f[0] = i, f[1] = i; 23710 break; 23711 case "MultiPoint": 23712 d = c.getCoordinates(), d[l.index] = i, f[0] = i, f[1] = i; 23713 break; 23714 case "LineString": 23715 d = c.getCoordinates(), d[l.index + g] = i, f[g] = i; 23716 break; 23717 case "MultiLineString": 23718 d = c.getCoordinates(), d[u[0]][l.index + g] = i, f[g] = i; 23719 break; 23720 case "Polygon": 23721 d = c.getCoordinates(), d[u[0]][l.index + g] = i, f[g] = i; 23722 break; 23723 case "MultiPolygon": 23724 d = c.getCoordinates(), d[u[1]][u[0]][l.index + g] = i, f[g] = i; 23725 break; 23726 case "Circle": 23727 if (f[0] = i, f[1] = i, l.index === $u) 23728 this.changingFeature_ = !0, c.setCenter(i), this.changingFeature_ = !1; 23729 else { 23730 this.changingFeature_ = !0, t.map.getView().getProjection(); 23731 let _ = Co( 23732 It(c.getCenter()), 23733 It(i) 23734 ); 23735 c.setRadius(_), this.changingFeature_ = !1; 23736 } 23737 break; 23738 } 23739 d && this.setGeometryCoordinates_(c, d); 23740 } 23741 this.createOrUpdateVertexFeature_(i, s, n); 23742 } 23743 /** 23744 * Handle pointer down events. 23745 * @param {import("../MapBrowserEvent.js").default} evt Event. 23746 * @return {boolean} If the event was consumed. 23747 */ 23748 handleDownEvent(t) { 23749 if (!this.condition_(t)) 23750 return !1; 23751 const i = t.coordinate; 23752 this.handlePointerAtPixel_(t.pixel, t.map, i), this.dragSegments_.length = 0, this.featuresBeingModified_ = null; 23753 const s = this.vertexFeature_; 23754 if (s) { 23755 t.map.getView().getProjection(); 23756 const n = [], r = s.getGeometry().getCoordinates(), o = ce([r]), a = this.rBush_.getInExtent(o), l = {}; 23757 a.sort(Ob); 23758 for (let h = 0, c = a.length; h < c; ++h) { 23759 const u = a[h], d = u.segment; 23760 let f = ot(u.geometry); 23761 const g = u.depth; 23762 if (g && (f += "-" + g.join("-")), l[f] || (l[f] = new Array(2)), u.geometry.getType() === "Circle" && u.index === Zn) { 23763 const _ = Vu( 23764 i, 23765 u 23766 );
23767 Fe(_, r) && !l[f][0] && (this.dragSegments_.push([u, 0]), l[f][0] = u); 23768 continue; 23769 } 23770 if (Fe(d[0], r) && !l[f][0]) { 23771 this.dragSegments_.push([u, 0]), l[f][0] = u; 23772 continue; 23773 } 23774 if (Fe(d[1], r) && !l[f][1]) { 23775 if (l[f][0] && l[f][0].index === 0) { 23776 let _ = u.geometry.getCoordinates(); 23777 switch (u.geometry.getType()) { 23778 case "LineString": 23779 case "MultiLineString": 23780 continue; 23781 case "MultiPolygon": 23782 _ = _[g[1]]; 23783 case "Polygon": 23784 if (u.index !== _[g[0]].length - 2) 23785 continue; 23786 break; 23787 } 23788 } 23789 this.dragSegments_.push([u, 1]), l[f][1] = u; 23790 continue; 23791 } 23792 ot(d) in this.vertexSegments_ && !l[f][0] && !l[f][1] && this.insertVertexCondition_(t) && n.push(u); 23793 } 23794 n.length && this.willModifyFeatures_(t, [n]); 23795 for (let h = n.length - 1; h >= 0; --h) 23796 this.insertVertex_(n[h], r); 23797 } 23798 return !!this.vertexFeature_; 23799 } 23800 /** 23801 * Handle pointer up events. 23802 * @param {import("../MapBrowserEvent.js").default} evt Event. 23803 * @return {boolean} If the event was consumed. 23804 */ 23805 handleUpEvent(t) { 23806 for (let i = this.dragSegments_.length - 1; i >= 0; --i) { 23807 const s = this.dragSegments_[i][0], n = s.geometry; 23808 if (n.getType() === "Circle") { 23809 const r = n.getCenter(), o = s.featureSegments[0], a = s.featureSegments[1]; 23810 o.segment[0] = r, o.segment[1] = r, a.segment[0] = r, a.segment[1] = r, this.rBush_.update(uo(r), o); 23811 let l = n; 23812 this.rBush_.update( 23813 l.getExtent(), 23814 a 23815 ); 23816 } else 23817 this.rBush_.update(ce(s.segment), s); 23818 } 23819 return this.featuresBeingModified_ && (this.dispatchEvent( 23820 new $a( 23821 Xa.MODIFYEND, 23822 this.featuresBeingModified_, 23823 t 23824 ) 23825 ), this.featuresBeingModified_ = null), !1; 23826 } 23827 /** 23828 * @param {import("../MapBrowserEvent.js").default} evt Event. 23829 * @private 23830 */ 23831 handlePointerMove_(t) { 23832 this.lastPixel_ = t.pixel, this.handlePointerAtPixel_(t.pixel, t.map, t.coordinate); 23833 } 23834 /** 23835 * @param {import("../pixel.js").Pixel} pixel Pixel 23836 * @param {import("../Map.js").default} map Map. 23837 * @param {import("../coordinate.js").Coordinate} [coordinate] The pixel Coordinate. 23838 * @private 23839 */ 23840 handlePointerAtPixel_(t, i, s) { 23841 const n = s || i.getCoordinateFromPixel(t); 23842 i.getView().getProjection(); 23843 const r = function(l, h) { 23844 return Ku(n, l) - Ku(n, h); 23845 }; 23846 let o, a; 23847 if (this.hitDetection_) { 23848 const l = typeof this.hitDetection_ == "object" ? (h) => h === this.hitDetection_ : void 0; 23849 i.forEachFeatureAtPixel( 23850 t, 23851 (h, c, u) => { 23852 u && (u = new pi( 23853 Ms(u.getCoordinates()) 23854 )); 23855 const d = u || h.getGeometry(); 23856 if (d.getType() === "Point" && h instanceof Ni && this.features_.getArray().includes(h)) { 23857 a = /** @type {Point} */ 23858 d; 23859 const f = ( 23860 /** @type {Point} */ 23861 h.getGeometry().getFlatCoordinates().slice(0, 2) 23862 ); 23863 o = [ 23864 { 23865 feature: h, 23866 geometry: a, 23867 segment: [f, f] 23868 } 23869 ]; 23870 } 23871 return !0; 23872 }, 23873 { layerFilter: l } 23874 ); 23875 } 23876 if (!o) { 23877 const l = He( 23878 uo(n, Yu) 23879 ), h = i.getView().getResolution() * this.pixelTolerance_, c = Zo( 23880 Es(l, h, Yu) 23881 ); 23882 o = this.rBush_.getInExtent(c); 23883 } 23884 if (o && o.length > 0) { 23885 const l = o.sort(r)[0], h = l.segment; 23886 let c = Vu(n, l); 23887 const u = i.getPixelFromCoordinate(c); 23888 let d = Co(t, u); 23889 if (a || d <= this.pixelTolerance_) { 23890 const f = {}; 23891 if (f[ot(h)] = !0, this.snapToPointer_ || (this.delta_[0] = c[0] - n[0], this.delta_[1] = c[1] - n[1]), l.geometry.getType() === "Circle" && l.index === Zn) 23892 this.snappedToVertex_ = !0, this.createOrUpdateVertexFeature_( 23893 c, 23894 [l.feature], 23895 [l.geometry] 23896 ); 23897 else {
23898 const g = i.getPixelFromCoordinate(h[0]), _ = i.getPixelFromCoordinate(h[1]), m = gi(u, g), p = gi(u, _); 23899 d = Math.sqrt(Math.min(m, p)), this.snappedToVertex_ = d <= this.pixelTolerance_, this.snappedToVertex_ && (c = m > p ? h[1] : h[0]), this.createOrUpdateVertexFeature_( 23900 c, 23901 [l.feature], 23902 [l.geometry] 23903 ); 23904 const y = {}; 23905 y[ot(l.geometry)] = !0; 23906 for (let v = 1, E = o.length; v < E; ++v) { 23907 const C = o[v].segment; 23908 if (Fe(h[0], C[0]) && Fe(h[1], C[1]) || Fe(h[0], C[1]) && Fe(h[1], C[0])) { 23909 const S = ot(o[v].geometry); 23910 S in y || (y[S] = !0, f[ot(C)] = !0); 23911 } else 23912 break; 23913 } 23914 } 23915 this.vertexSegments_ = f; 23916 return; 23917 } 23918 } 23919 this.vertexFeature_ && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null); 23920 } 23921 /** 23922 * @param {SegmentData} segmentData Segment data. 23923 * @param {import("../coordinate.js").Coordinate} vertex Vertex. 23924 * @private 23925 */ 23926 insertVertex_(t, i) { 23927 const s = t.segment, n = t.feature, r = t.geometry, o = t.depth, a = t.index; 23928 let l; 23929 for (; i.length < r.getStride(); ) 23930 i.push(0); 23931 switch (r.getType()) { 23932 case "MultiLineString": 23933 l = r.getCoordinates(), l[o[0]].splice(a + 1, 0, i); 23934 break; 23935 case "Polygon": 23936 l = r.getCoordinates(), l[o[0]].splice(a + 1, 0, i); 23937 break; 23938 case "MultiPolygon": 23939 l = r.getCoordinates(), l[o[1]][o[0]].splice(a + 1, 0, i); 23940 break; 23941 case "LineString": 23942 l = r.getCoordinates(), l.splice(a + 1, 0, i); 23943 break; 23944 default: 23945 return; 23946 } 23947 this.setGeometryCoordinates_(r, l); 23948 const h = this.rBush_; 23949 h.remove(t), this.updateSegmentIndices_(r, a, o, 1); 23950 const c = { 23951 segment: [s[0], i], 23952 feature: n, 23953 geometry: r, 23954 depth: o, 23955 index: a 23956 }; 23957 h.insert(ce(c.segment), c), this.dragSegments_.push([c, 1]); 23958 const u = { 23959 segment: [i, s[1]], 23960 feature: n, 23961 geometry: r, 23962 depth: o, 23963 index: a + 1 23964 }; 23965 h.insert(ce(u.segment), u), this.dragSegments_.push([u, 0]), this.ignoreNextSingleClick_ = !0; 23966 } 23967 /** 23968 * Removes the vertex currently being pointed. 23969 * @return {boolean} True when a vertex was removed. 23970 * @api 23971 */ 23972 removePoint() { 23973 if (this.lastPointerEvent_ && this.lastPointerEvent_.type != dt.POINTERDRAG) { 23974 const t = this.lastPointerEvent_; 23975 this.willModifyFeatures_(t, this.dragSegments_); 23976 const i = this.removeVertex_(); 23977 return this.featuresBeingModified_ && this.dispatchEvent( 23978 new $a( 23979 Xa.MODIFYEND, 23980 this.featuresBeingModified_, 23981 t 23982 ) 23983 ), this.featuresBeingModified_ = null, i; 23984 } 23985 return !1; 23986 } 23987 /** 23988 * Removes a vertex from all matching features. 23989 * @return {boolean} True when a vertex was removed. 23990 * @private 23991 */ 23992 removeVertex_() { 23993 const t = this.dragSegments_, i = {}; 23994 let s = !1, n, r, o, a, l, h, c, u, d, f, g; 23995 for (l = t.length - 1; l >= 0; --l) 23996 o = t[l], f = o[0], g = ot(f.feature), f.depth && (g += "-" + f.depth.join("-")), g in i || (i[g] = {}), o[1] === 0 ? (i[g].right = f, i[g].index = f.index) : o[1] == 1 && (i[g].left = f, i[g].index = f.index + 1); 23997 for (g in i) { 23998 switch (d = i[g].right, c = i[g].left, h = i[g].index, u = h - 1, c !== void 0 ? f = c : f = d, u < 0 && (u = 0), a = f.geometry, r = a.getCoordinates(), n = r, s = !1, a.getType()) { 23999 case "MultiLineString": 24000 r[f.depth[0]].length > 2 && (r[f.depth[0]].splice(h, 1), s = !0); 24001 break; 24002 case "LineString": 24003 r.length > 2 && (r.splice(h, 1), s = !0); 24004 break; 24005 case "MultiPolygon": 24006 n = n[f.depth[1]]; 24007 case "Polygon": 24008 n = n[f.depth[0]], n.length > 4 && (h == n.length - 1 && (h = 0), n.splice(h, 1), s = !0, h === 0 && (n.pop(), n.push(n[0]), u = n.length - 1)); 24009 break; 24010 } 24011 if (s) { 24012 this.setGeometryCoordinates_(a, r); 24013 const _ = []; 24014 if (c !== void 0 && (this.rBush_.remove(c), _.push(c.segment[0])), d !== void 0 && (this.rBush_.remove(d), _.push(d.segment[1])), c !== void 0 && d !== void 0) { 24015 const m = { 24016 depth: f.depth, 24017 feature: f.feature, 24018 geometry: f.geometry, 24019 index: u, 24020 segment: _ 24021 }; 24022 this.rBush_.insert( 24023 ce(m.segment), 24024 m 24025 ); 24026 } 24027 this.updateSegmentIndices_(a, h, f.depth, -1), this.vertexFeature_ && (this.overlay_.getSource().removeFeature
24027(this.vertexFeature_), this.vertexFeature_ = null), t.length = 0; 24028 } 24029 } 24030 return s; 24031 } 24032 /** 24033 * @param {import("../geom/SimpleGeometry.js").default} geometry Geometry. 24034 * @param {Array} coordinates Coordinates. 24035 * @private 24036 */ 24037 setGeometryCoordinates_(t, i) { 24038 this.changingFeature_ = !0, t.setCoordinates(i), this.changingFeature_ = !1; 24039 } 24040 /** 24041 * @param {import("../geom/SimpleGeometry.js").default} geometry Geometry. 24042 * @param {number} index Index. 24043 * @param {Array<number>|undefined} depth Depth. 24044 * @param {number} delta Delta (1 or -1). 24045 * @private 24046 */ 24047 updateSegmentIndices_(t, i, s, n) { 24048 this.rBush_.forEachInExtent( 24049 t.getExtent(), 24050 function(r) { 24051 r.geometry === t && (s === void 0 || r.depth === void 0 || bi(r.depth, s)) && r.index > i && (r.index += n); 24052 } 24053 ); 24054 } 24055} 24056function Ob(e, t) { 24057 return e.index - t.index; 24058} 24059function Ku(e, t, i) { 24060 const s = t.geometry; 24061 if (s.getType() === "Circle") { 24062 let r = ( 24063 /** @type {import("../geom/Circle.js").default} */ 24064 s 24065 ); 24066 if (t.index === Zn) { 24067 const o = gi( 24068 r.getCenter(), 24069 It(e) 24070 ), a = Math.sqrt(o) - r.getRadius(); 24071 return a * a; 24072 } 24073 } 24074 const n = It(e); 24075 return an[0] = It(t.segment[0]), an[1] = It(t.segment[1]), Hy(n, an); 24076} 24077function Vu(e, t, i) { 24078 const s = t.geometry; 24079 if (s.getType() === "Circle" && t.index === Zn) 24080 return Ms( 24081 /** @type {import("../geom/Circle.js").default} */ 24082 s.getClosestPoint( 24083 It(e) 24084 ) 24085 ); 24086 const n = It(e); 24087 return an[0] = It(t.segment[0]), an[1] = It(t.segment[1]), Ms( 24088 $l(n, an) 24089 ); 24090} 24091function Fb() { 24092 const e = yg(); 24093 return function(t, i) { 24094 return e.Point; 24095 }; 24096} 24097const Db = Lb, ne = ia({ 24098 geometry: null, 24099 // GeoJSON geometry: { type, coordinates } â Point | LineString | Polygon 24100 hasPoint: !1, 24101 resetSeq: 0 24102 // bumped by requestReportReset() so the map can clear its geometry 24103}); 24104function Nb(e) { 24105 ne.geometry = e, ne.hasPoint = !0; 24106} 24107function qu() { 24108 ne.geometry = null, ne.hasPoint = !1; 24109} 24110function kb() { 24111 ne.geometry = null, ne.hasPoint = !1, ne.resetSeq++; 24112} 24113class va extends ts { 24114 /** 24115 * @param {!import("../coordinate.js").Coordinate} center Center. 24116 * For internal use, flat coordinates in combination with `layout` and no 24117 * `radius` are also accepted. 24118 * @param {number} [radius] Radius. 24119 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 24120 */ 24121 constructor(t, i, s) { 24122 super(), s !== void 0 && i === void 0 ? this.setFlatCoordinates(s, t) : (i = i || 0, this.setCenterAndRadius(t, i, s)); 24123 } 24124 /** 24125 * Make a complete copy of the geometry. 24126 * @return {!Circle} Clone. 24127 * @api 24128 */ 24129 clone() { 24130 const t = new va( 24131 this.flatCoordinates.slice(), 24132 void 0, 24133 this.layout 24134 ); 24135 return t.applyProperties(this), t; 24136 } 24137 /** 24138 * @param {number} x X. 24139 * @param {number} y Y. 24140 * @param {import("../coordinate.js").Coordinate} closestPoint Closest point. 24141 * @param {number} minSquaredDistance Minimum squared distance. 24142 * @return {number} Minimum squared distance. 24143 */ 24144 closestPointXY(t, i, s, n) { 24145 const r = this.flatCoordinates, o = t - r[0], a = i - r[1], l = o * o + a * a; 24146 if (l < n) { 24147 if (l === 0) 24148 for (let h = 0; h < this.stride; ++h) 24149 s[h] = r[h]; 24150 else { 24151 const h = this.getRadius() / Math.sqrt(l); 24152 s[0] = r[0] + h * o, s[1] = r[1] + h * a; 24153 for (let c = 2; c < this.stride; ++c) 24154 s[c] = r[c]; 24155 } 24156 return s.length = this.stride, l; 24157 } 24158 return n; 24159 } 24160 /** 24161 * @param {number} x X. 24162 * @param {number} y Y. 24163 * @return {boolean} Contains (x, y). 24164 */ 24165 containsXY(t, i) { 24166 const s = this.flatCoordinates, n = t - s[0], r = i - s[1]; 24167 return n * n + r * r <= this.getRadiusSquared_(); 24168 } 24169 /** 24170 * Return the center of the circle as {@link module:ol/coordinate~Coordinate coordinate}. 24171 * @return {import("../coordinate.js").Coordinate} Center. 24172 * @api 24173 */ 24174 getCenter() { 24175 return this.flatCoordinates.slice(0, this.stride); 24176 } 24177 /** 24178 * @param {import("../extent.js").Extent} extent Extent. 24179 * @protected 24180 * @return {import("../extent.js").Extent} extent Extent. 24181 */ 24182 computeExtent(t) { 24183 const i = this.flatCoordinates, s = i[this.stride] - i[0]; 24184 return ei( 24185 i[0] - s, 24186 i[1] - s, 24187 i[0] + s, 24188 i[1] + s, 24189 t 24190 ); 24191 } 24192 /** 24193 * Return the radius of the circle. 24194 * @return {number} Radius. 24195 * @api 24196 */ 24197 getRadius() { 24198 return Math.sqrt(this.getRadiusSquared_()); 24199 } 24200 /** 24201 * @private 24202 * @return {number} Radius squared. 24203 */ 24204 getRadiusSquared_() { 24205 const t = this.flatCoordinates[this.stride] - this.flatCoordinates[0], i = this.flatCoordinates[this.stride + 1] - this.flatCoordinates[1]; 24206 return t * t + i * i; 24207 } 24208 /** 24209 * Get the type of this geometry. 24210 * @return {import("./Geometry.js").Type} Geometry type. 24211 * @api 24212 */ 24213 getType() { 24214 return "Circle"; 24215 } 24216 /** 24217 * Test if the geometry and the passed extent intersect. 24218 * @param {import("../extent.js").Extent} extent Extent. 24219 * @return {boolean} `true` if the geometry and the extent intersect. 24220 * @api 24221 */ 24222 intersectsExtent(t) { 24223 const i = this.getExtent(); 24224 if (ee(t, i)) { 24225 const s = this.getCenter(); 24226 return t[0] <= s[0] && t[2] >= s[0] || t[1] <= s[1] && t[3] >= s[1] ? !0 : Xl(t, this.intersectsCoordinate.bind(this)); 24227 } 24228 return !1; 24229 } 24230 /** 24231 * Set the center of the circle as {@link module:ol/coordinate~Co
24231ordinate coordinate}. 24232 * @param {import("../coordinate.js").Coordinate} center Center. 24233 * @api 24234 */ 24235 setCenter(t) { 24236 const i = this.stride, s = this.flatCoordinates[i] - this.flatCoordinates[0], n = t.slice(); 24237 n[i] = n[0] + s; 24238 for (let r = 1; r < i; ++r) 24239 n[i + r] = t[r]; 24240 this.setFlatCoordinates(this.layout, n), this.changed(); 24241 } 24242 /** 24243 * Set the center (as {@link module:ol/coordinate~Coordinate coordinate}) and the radius (as 24244 * number) of the circle. 24245 * @param {!import("../coordinate.js").Coordinate} center Center. 24246 * @param {number} radius Radius. 24247 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 24248 * @api 24249 */ 24250 setCenterAndRadius(t, i, s) { 24251 this.setLayout(s, t, 0), this.flatCoordinates || (this.flatCoordinates = []); 24252 const n = this.flatCoordinates; 24253 let r = $f(n, 0, t, this.stride); 24254 n[r++] = n[0] + i; 24255 for (let o = 1, a = this.stride; o < a; ++o) 24256 n[r++] = n[o]; 24257 n.length = r, this.changed(); 24258 } 24259 getCoordinates() { 24260 return null; 24261 } 24262 setCoordinates(t, i) { 24263 } 24264 /** 24265 * Set the radius of the circle. The radius is in the units of the projection. 24266 * @param {number} radius Radius. 24267 * @api 24268 */ 24269 setRadius(t) { 24270 this.flatCoordinates[this.stride] = this.flatCoordinates[0] + t, this.changed(); 24271 } 24272 /** 24273 * Rotate the geometry around a given coordinate. This modifies the geometry 24274 * coordinates in place. 24275 * @param {number} angle Rotation angle in counter-clockwise radians. 24276 * @param {import("../coordinate.js").Coordinate} anchor The rotation center. 24277 * @api 24278 */ 24279 rotate(t, i) { 24280 const s = this.getCenter(), n = this.getStride(); 24281 this.setCenter( 24282 Sh(s, 0, s.length, n, t, i, s) 24283 ), this.changed(); 24284 } 24285} 24286va.prototype.transform; 24287const Gb = va; 24288class Bo extends Xf { 24289 /** 24290 * @param {Array<Geometry>} [geometries] Geometries. 24291 */ 24292 constructor(t) { 24293 super(), this.geometries_ = t || null, this.changeEventsKeys_ = [], this.listenGeometriesChange_(); 24294 } 24295 /** 24296 * @private 24297 */ 24298 unlistenGeometriesChange_() { 24299 this.changeEventsKeys_.forEach(Mt), this.changeEventsKeys_.length = 0; 24300 } 24301 /** 24302 * @private 24303 */ 24304 listenGeometriesChange_() { 24305 if (this.geometries_) 24306 for (let t = 0, i = this.geometries_.length; t < i; ++t) 24307 this.changeEventsKeys_.push( 24308 lt(this.geometries_[t], et.CHANGE, this.changed, this) 24309 ); 24310 } 24311 /** 24312 * Make a complete copy of the geometry. 24313 * @return {!GeometryCollection} Clone. 24314 * @api 24315 */ 24316 clone() { 24317 const t = new Bo(null); 24318 return t.setGeometries(this.geometries_), t.applyProperties(this), t; 24319 } 24320 /** 24321 * @param {number} x X. 24322 * @param {number} y Y. 24323 * @param {import("../coordinate.js").Coordinate} closestPoint Closest point. 24324 * @param {number} minSquaredDistance Minimum squared distance. 24325 * @return {number} Minimum squared distance. 24326 */ 24327 closestPointXY(t, i, s, n) { 24328 if (n < Ss(this.getExtent(), t, i)) 24329 return n; 24330 const r = this.geometries_; 24331 for (let o = 0, a = r.length; o < a; ++o) 24332 n = r[o].closestPointXY( 24333 t, 24334 i, 24335 s, 24336 n 24337 ); 24338 return n; 24339 } 24340 /** 24341 * @param {number} x X. 24342 * @param {number} y Y. 24343 * @return {boolean} Contains (x, y). 24344 */ 24345 containsXY(t, i) { 24346 const s = this.geometries_; 24347 for (let n = 0, r = s.length; n < r; ++n) 24348 if (s[n].containsXY(t, i)) 24349 return !0; 24350 return !1; 24351 } 24352 /** 24353 * @param {import("../extent.js").Extent} extent Extent. 24354 * @protected 24355 * @return {import("../extent.js").Extent} extent Extent. 24356 */ 24357 computeExtent(t) { 24358 bn(t); 24359 const i = this.geometries_; 24360 for (let s = 0, n = i.length; s < n; ++s) 24361 Pd(t, i[s].getExtent()); 24362 return t; 24363 } 24364 /** 24365 * Return the geometries that make up this geometry collection. 24366 * @return {Array<Geometry>} Geometries. 24367 * @api 24368 */ 24369 getGeometries() { 24370 return Hu(this.geometries_); 24371 } 24372 /** 24373 * @return {Array<Geometry>} Geometries. 24374 */ 24375 getGeometriesArray() { 24376 return this.geometries_; 24377 } 24378 /** 24379 * @return {Array<Geometry>} Geometries. 24380 */ 24381 getGeometriesArrayRecursive() { 24382 let t = []; 24383 const i = this.geometries_; 24384 for (let s = 0, n = i.length; s < n; ++s) 24385 i[s].getType() === this.getType() ? t = t.concat( 24386 /** @type {GeometryCollection} */ 24387 i[s].getGeometriesArrayRecursive() 24388 ) : t.push(i[s]); 24389 return t; 24390 } 24391 /** 24392 * Create a simplified version of this geometry using the Douglas Peucker algorithm. 24393 * @param {number} squaredTolerance Squared tolerance. 24394 * @return {GeometryCollection} Simplified GeometryCollection. 24395 */ 24396 getSimplifiedGeometry(t) { 24397 if (this.simplifiedGeometryRevision !== this.getRevision() && (this.simplifiedGeometryMaxMinSquaredTolerance = 0, this.simplifiedGeometryRevision = this.getRevision()), t
24397< 0 || this.simplifiedGeometryMaxMinSquaredTolerance !== 0 && t < this.simplifiedGeometryMaxMinSquaredTolerance) 24398 return this; 24399 const i = [], s = this.geometries_; 24400 let n = !1; 24401 for (let r = 0, o = s.length; r < o; ++r) { 24402 const a = s[r], l = a.getSimplifiedGeometry(t); 24403 i.push(l), l !== a && (n = !0); 24404 } 24405 if (n) { 24406 const r = new Bo(null); 24407 return r.setGeometriesArray(i), r; 24408 } 24409 return this.simplifiedGeometryMaxMinSquaredTolerance = t, this; 24410 } 24411 /** 24412 * Get the type of this geometry. 24413 * @return {import("./Geometry.js").Type} Geometry type. 24414 * @api 24415 */ 24416 getType() { 24417 return "GeometryCollection"; 24418 } 24419 /** 24420 * Test if the geometry and the passed extent intersect. 24421 * @param {import("../extent.js").Extent} extent Extent. 24422 * @return {boolean} `true` if the geometry and the extent intersect. 24423 * @api 24424 */ 24425 intersectsExtent(t) { 24426 const i = this.geometries_; 24427 for (let s = 0, n = i.length; s < n; ++s) 24428 if (i[s].intersectsExtent(t)) 24429 return !0; 24430 return !1; 24431 } 24432 /** 24433 * @return {boolean} Is empty. 24434 */ 24435 isEmpty() { 24436 return this.geometries_.length === 0; 24437 } 24438 /** 24439 * Rotate the geometry around a given coordinate. This modifies the geometry 24440 * coordinates in place. 24441 * @param {number} angle Rotation angle in radians. 24442 * @param {import("../coordinate.js").Coordinate} anchor The rotation center. 24443 * @api 24444 */ 24445 rotate(t, i) { 24446 const s = this.geometries_; 24447 for (let n = 0, r = s.length; n < r; ++n) 24448 s[n].rotate(t, i); 24449 this.changed(); 24450 } 24451 /** 24452 * Scale the geometry (with an optional origin). This modifies the geometry 24453 * coordinates in place. 24454 * @abstract 24455 * @param {number} sx The scaling factor in the x-direction. 24456 * @param {number} [sy] The scaling factor in the y-direction (defaults to sx). 24457 * @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center 24458 * of the geometry extent). 24459 * @api 24460 */ 24461 scale(t, i, s) { 24462 s || (s = ii(this.getExtent())); 24463 const n = this.geometries_; 24464 for (let r = 0, o = n.length; r < o; ++r) 24465 n[r].scale(t, i, s); 24466 this.changed(); 24467 } 24468 /** 24469 * Set the geometries that make up this geometry collection. 24470 * @param {Array<Geometry>} geometries Geometries. 24471 * @api 24472 */ 24473 setGeometries(t) { 24474 this.setGeometriesArray(Hu(t)); 24475 } 24476 /** 24477 * @param {Array<Geometry>} geometries Geometries. 24478 */ 24479 setGeometriesArray(t) { 24480 this.unlistenGeometriesChange_(), this.geometries_ = t, this.listenGeometriesChange_(), this.changed(); 24481 } 24482 /** 24483 * Apply a transform function to the coordinates of the geometry. 24484 * The geometry is modified in place. 24485 * If you do not want the geometry modified in place, first `clone()` it and 24486 * then use this function on the clone. 24487 * @param {import("../proj.js").TransformFunction} transformFn Transform function. 24488 * Called with a flat array of geometry coordinates. 24489 * @api 24490 */ 24491 applyTransform(t) { 24492 const i = this.geometries_; 24493 for (let s = 0, n = i.length; s < n; ++s) 24494 i[s].applyTransform(t); 24495 this.changed(); 24496 } 24497 /** 24498 * Translate the geometry. This modifies the geometry coordinates in place. If 24499 * instead you want a new geometry, first `clone()` this geometry. 24500 * @param {number} deltaX Delta X. 24501 * @param {number} deltaY Delta Y. 24502 * @api 24503 */ 24504 translate(t, i) { 24505 const s = this.geometries_; 24506 for (let n = 0, r = s.length; n < r; ++n) 24507 s[n].translate(t, i); 24508 this.changed(); 24509 } 24510 /** 24511 * Clean up. 24512 */ 24513 disposeInternal() { 24514 this.unlistenGeometriesChange_(), super.disposeInternal(); 24515 } 24516} 24517function Hu(e) { 24518 const t = []; 24519 for (let i = 0, s = e.length; i < s; ++i) 24520 t.push(e[i].clone()); 24521 return t; 24522} 24523const Og = Bo; 24524class Uo extends ts { 24525 /** 24526 * @param {Array<Array<import("../coordinate.js").Coordinate>|LineString>|Array<number>} coordinates 24527 * Coordinates or LineString geometries. (For internal use, flat coordinates in 24528 * combination with `layout` and `ends` are also accepted.) 24529 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 24530 * @param {Array<number>} [ends] Flat coordinate ends for internal use. 24531 */ 24532 constructor(t, i, s) { 24533 if (super(), this.ends_ = [], this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, Array.isArray(t[0])) 24534 this.setCoordinates( 24535 /** @type {Array<Array<import("../coordinate.js").Coordinate>>} */ 24536 t, 24537 i 24538 ); 24539 else if (i !== void 0 && s) 24540 this.setFlatCoordinates( 24541 i, 24542 /** @type {Array<number>} */ 24543 t 24544 ), this.ends_ = s; 24545 else { 24546 let n = this.getLayout(); 24547 const r = ( 24548 /** @type {Array<LineString>} */ 24549 t 24550 ), o = [], a = []; 24551 for (let l = 0, h = r.length; l < h; ++l) { 24552 const c = r[l]; 24553 l === 0 && (n = c.getLayout()), mi(o, c.getFlatCoordinates()), a.push(o.length); 24554 } 24555 this.setFlatCoordinates(n, o), this.ends_ = a; 24556 } 24557 } 24558 /** 24559 * Append the passed linestring to the multilinestring. 24560 * @param {LineString} lineString LineString. 24561 * @api 24562 */ 24563 appendLineString(t) { 24564 this.flatCoordinates ? mi(this.flatCoordinates, t.getFlatCoordinates().slice()) : this.flatCoordinates = t.getFlatCoordinates().slice(), this.ends_.push(this.flatCoordinates.length), this.changed(); 24565 } 24566 /** 24567 * Make a complete copy of the geometry. 24568 * @return {!MultiLineString} Clone. 24569 * @api 24570 */ 24571 clone() { 24572 const t = new Uo( 24573 this.flatCoordinates.slice(), 24574 this.layout, 24575 this.ends_.slice() 24576 ); 24577 return t.applyProperties(this), t;
24578 } 24579 /** 24580 * @param {number} x X. 24581 * @param {number} y Y. 24582 * @param {import("../coordinate.js").Coordinate} closestPoint Closest point. 24583 * @param {number} minSquaredDistance Minimum squared distance. 24584 * @return {number} Minimum squared distance. 24585 */ 24586 closestPointXY(t, i, s, n) { 24587 return n < Ss(this.getExtent(), t, i) ? n : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt( 24588 Th( 24589 this.flatCoordinates, 24590 0, 24591 this.ends_, 24592 this.stride, 24593 0 24594 ) 24595 ), this.maxDeltaRevision_ = this.getRevision()), Ih( 24596 this.flatCoordinates, 24597 0, 24598 this.ends_, 24599 this.stride, 24600 this.maxDelta_, 24601 !1, 24602 t, 24603 i, 24604 s, 24605 n 24606 )); 24607 } 24608 /** 24609 * Returns the coordinate at `m` using linear interpolation, or `null` if no 24610 * such coordinate exists. 24611 * 24612 * `extrapolate` controls extrapolation beyond the range of Ms in the 24613 * MultiLineString. If `extrapolate` is `true` then Ms less than the first 24614 * M will return the first coordinate and Ms greater than the last M will 24615 * return the last coordinate. 24616 * 24617 * `interpolate` controls interpolation between consecutive LineStrings 24618 * within the MultiLineString. If `interpolate` is `true` the coordinates 24619 * will be linearly interpolated between the last coordinate of one LineString 24620 * and the first coordinate of the next LineString. If `interpolate` is 24621 * `false` then the function will return `null` for Ms falling between 24622 * LineStrings. 24623 * 24624 * @param {number} m M. 24625 * @param {boolean} [extrapolate] Extrapolate. Default is `false`. 24626 * @param {boolean} [interpolate] Interpolate. Default is `false`. 24627 * @return {import("../coordinate.js").Coordinate|null} Coordinate. 24628 * @api 24629 */ 24630 getCoordinateAtM(t, i, s) { 24631 return this.layout != "XYM" && this.layout != "XYZM" || this.flatCoordinates.length === 0 ? null : (i = i !== void 0 ? i : !1, s = s !== void 0 ? s : !1, hC( 24632 this.flatCoordinates, 24633 0, 24634 this.ends_, 24635 this.stride, 24636 t, 24637 i, 24638 s 24639 )); 24640 } 24641 /** 24642 * Return the coordinates of the multilinestring. 24643 * @return {Array<Array<import("../coordinate.js").Coordinate>>} Coordinates. 24644 * @api 24645 */ 24646 getCoordinates() { 24647 return lr( 24648 this.flatCoordinates, 24649 0, 24650 this.ends_, 24651 this.stride 24652 ); 24653 } 24654 /** 24655 * @return {Array<number>} Ends. 24656 */ 24657 getEnds() { 24658 return this.ends_; 24659 } 24660 /** 24661 * Return the linestring at the specified index. 24662 * @param {number} index Index. 24663 * @return {LineString} LineString. 24664 * @api 24665 */ 24666 getLineString(t) { 24667 return t < 0 || this.ends_.length <= t ? null : new ys( 24668 this.flatCoordinates.slice( 24669 t === 0 ? 0 : this.ends_[t - 1], 24670 this.ends_[t] 24671 ), 24672 this.layout 24673 ); 24674 } 24675 /** 24676 * Return the linestrings of this multilinestring. 24677 * @return {Array<LineString>} LineStrings. 24678 * @api 24679 */ 24680 getLineStrings() { 24681 const t = this.flatCoordinates, i = this.ends_, s = this.layout, n = []; 24682 let r = 0; 24683 for (let o = 0, a = i.length; o < a; ++o) { 24684 const l = i[o], h = new ys( 24685 t.slice(r, l), 24686 s 24687 ); 24688 n.push(h), r = l; 24689 } 24690 return n; 24691 } 24692 /** 24693 * @return {Array<number>} Flat midpoints. 24694 */ 24695 getFlatMidpoints() { 24696 const t = [], i = this.flatCoordinates; 24697 let s = 0; 24698 const n = this.ends_, r = this.stride; 24699 for (let o = 0, a = n.length; o < a; ++o) { 24700 const l = n[o], h = gg( 24701 i, 24702 s, 24703 l, 24704 r, 24705 0.5 24706 ); 24707 mi(t, h), s = l; 24708 } 24709 return t; 24710 } 24711 /** 24712 * @param {number} squaredTolerance Squared tolerance. 24713 * @return {MultiLineString} Simplified MultiLineString. 24714 * @protected 24715 */ 24716 getSimplifiedGeometryInternal(t) { 24717 const i = [], s = []; 24718 return i.length = AE( 24719 this.flatCoordinates, 24720 0, 24721 this.ends_, 24722 this.stride, 24723 t, 24724 i, 24725 0, 24726 s 24727 ), new Uo(i, "XY", s); 24728 } 24729 /** 24730 * Get the type of this geometry. 24731 * @return {import("./Geometry.js").Type} Geometry type. 24732 * @api 24733 */ 24734 getType() { 24735 return "MultiLineString"; 24736 } 24737 /** 24738 * Test if the geometry and the passed extent intersect. 24739 * @param {import("../extent.js").Extent} extent Extent. 24740 * @return {boolean} `true` if the geometry and the extent intersect. 24741 * @api 24742 */ 24743 intersectsExtent(t) { 24744 return GE( 24745 this.flatCoordinates, 24746 0, 24747 this.ends_, 24748 this.stride, 24749 t 24750 ); 24751 } 24752 /** 24753 * Set the coordinates of the multilinestring. 24754 * @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates. 24755 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 24756 * @api 24757 */ 24758 setCoordinates(t, i) { 24759 this.setLayout(i, t, 2), this.flatCoordinates || (this.flatCoordinates = []); 24760 const s = Ph( 24761 this.flatCoordinates, 24762 0, 24763 t, 24764 this.stride, 24765 this.ends_ 24766 ); 24767 this.flatCoordinates.length = s.length === 0 ? 0 : s[s.length - 1], this.changed(); 24768 } 24769} 24770const Jh = Uo; 24771class Qh extends ts { 24772 /** 24773 * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates. 24774 * For internal use, flat coordinates in combination with `layout` are also accepted. 24775 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 24776 */ 24777 constructor(t, i) { 24778 super(), i && !Array.isArray(t[0]) ? this.setFlatCoordinates( 24779 i, 24780 /** @type {Array<number>} */ 24781 t 24782 ) : this.setCoordinates( 24783 /** @type {Array<import("../coordinate.js").Coordinate>} */ 24784 t, 24785 i 24786 ); 24787 } 24788 /** 24789 * Append the passed point to this multipoint. 24790 * @param {Point} point Point. 24791 * @api 24792 */ 24793 appendPoint(t) { 24794 this.flatCoordinates ? mi(this.flatCoordinates, t.getFlatCoordinates()) : this.flatCoordinates = t.getFlatCoordinates().slice(), this.changed(); 24795 } 24796 /** 24797 * Make a complete copy of the geometry. 24798 * @return {!MultiPoint} Clone. 24799 * @api 24800 */ 24801 clone() { 24802 const t = new Qh( 24803 this.flatCoordinates.slice(), 24804 this.layout 24805 ); 24806 return t.applyProperties(this), t;
24807 } 24808 /** 24809 * @param {number} x X. 24810 * @param {number} y Y. 24811 * @param {import("../coordinate.js").Coordinate} closestPoint Closest point. 24812 * @param {number} minSquaredDistance Minimum squared distance. 24813 * @return {number} Minimum squared distance. 24814 */ 24815 closestPointXY(t, i, s, n) { 24816 if (n < Ss(this.getExtent(), t, i)) 24817 return n; 24818 const r = this.flatCoordinates, o = this.stride; 24819 for (let a = 0, l = r.length; a < l; a += o) { 24820 const h = fi( 24821 t, 24822 i, 24823 r[a], 24824 r[a + 1] 24825 ); 24826 if (h < n) { 24827 n = h; 24828 for (let c = 0; c < o; ++c) 24829 s[c] = r[a + c]; 24830 s.length = o; 24831 } 24832 } 24833 return n; 24834 } 24835 /** 24836 * Return the coordinates of the multipoint. 24837 * @return {Array<import("../coordinate.js").Coordinate>} Coordinates. 24838 * @api 24839 */ 24840 getCoordinates() { 24841 return ji( 24842 this.flatCoordinates, 24843 0, 24844 this.flatCoordinates.length, 24845 this.stride 24846 ); 24847 } 24848 /** 24849 * Return the point at the specified index. 24850 * @param {number} index Index. 24851 * @return {Point} Point. 24852 * @api 24853 */ 24854 getPoint(t) { 24855 const i = this.flatCoordinates ? this.flatCoordinates.length / this.stride : 0; 24856 return t < 0 || i <= t ? null : new pi( 24857 this.flatCoordinates.slice( 24858 t * this.stride, 24859 (t + 1) * this.stride 24860 ), 24861 this.layout 24862 ); 24863 } 24864 /** 24865 * Return the points of this multipoint. 24866 * @return {Array<Point>} Points. 24867 * @api 24868 */ 24869 getPoints() { 24870 const t = this.flatCoordinates, i = this.layout, s = this.stride, n = []; 24871 for (let r = 0, o = t.length; r < o; r += s) { 24872 const a = new pi(t.slice(r, r + s), i); 24873 n.push(a); 24874 } 24875 return n; 24876 } 24877 /** 24878 * Get the type of this geometry. 24879 * @return {import("./Geometry.js").Type} Geometry type. 24880 * @api 24881 */ 24882 getType() { 24883 return "MultiPoint"; 24884 } 24885 /** 24886 * Test if the geometry and the passed extent intersect. 24887 * @param {import("../extent.js").Extent} extent Extent. 24888 * @return {boolean} `true` if the geometry and the extent intersect. 24889 * @api 24890 */ 24891 intersectsExtent(t) { 24892 const i = this.flatCoordinates, s = this.stride; 24893 for (let n = 0, r = i.length; n < r; n += s) { 24894 const o = i[n], a = i[n + 1]; 24895 if (Ul(t, o, a)) 24896 return !0; 24897 } 24898 return !1; 24899 } 24900 /** 24901 * Set the coordinates of the multipoint. 24902 * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates. 24903 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 24904 * @api 24905 */ 24906 setCoordinates(t, i) { 24907 this.setLayout(i, t, 1), this.flatCoordinates || (this.flatCoordinates = []), this.flatCoordinates.length = da( 24908 this.flatCoordinates, 24909 0, 24910 t, 24911 this.stride 24912 ), this.changed(); 24913 } 24914} 24915const tc = Qh; 24916function zb(e, t, i, s) { 24917 const n = []; 24918 let r = ve(); 24919 for (let o = 0, a = i.length; o < a; ++o) { 24920 const l = i[o]; 24921 r = Id( 24922 e, 24923 t, 24924 l[0], 24925 s 24926 ), n.push((r[0] + r[2]) / 2, (r[1] + r[3]) / 2), t = l[l.length - 1]; 24927 } 24928 return n; 24929} 24930class Xo extends ts { 24931 /** 24932 * @param {Array<Array<Array<import("../coordinate.js").Coordinate>>|Polygon>|Array<number>} coordinates Coordinates. 24933 * For internal use, flat coordinates in combination with `layout` and `endss` are also accepted. 24934 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 24935 * @param {Array<Array<number>>} [endss] Array of ends for internal use with flat coordinates. 24936 */ 24937 constructor(t, i, s) { 24938 if (super(), this.endss_ = [], this.flatInteriorPointsRevision_ = -1, this.flatInteriorPoints_ = null, this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, this.orientedRevision_ = -1, this.orientedFlatCoordinates_ = null, !s && !Array.isArray(t[0])) { 24939 let n = this.getLayout(); 24940 const r = ( 24941 /** @type {Array<Polygon>} */ 24942 t 24943 ), o = [], a = []; 24944 for (let l = 0, h = r.length; l < h; ++l) { 24945 const c = r[l]; 24946 l === 0 && (n = c.getLayout()); 24947 const u = o.length, d = c.getEnds(); 24948 for (let f = 0, g = d.length; f < g; ++f) 24949 d[f] += u; 24950 mi(o, c.getFlatCoordinates()), a.push(d); 24951 } 24952 i = n, t = o, s = a; 24953 } 24954 i !== void 0 && s ? (this.setFlatCoordinates( 24955 i, 24956 /** @type {Array<number>} */ 24957 t 24958 ), this.endss_ = s) : this.setCoordinates( 24959 /** @type {Array<Array<Array<import("../coordinate.js").Coordinate>>>} */ 24960 t, 24961 i 24962 ); 24963 } 24964 /** 24965 * Append the passed polygon to this multipolygon. 24966 * @param {Polygon} polygon Polygon. 24967 * @api 24968 */ 24969 appendPolygon(t) { 24970 let i; 24971 if (!this.flatCoordinates) 24972 this.flatCoordinates = t.getFlatCoordinates().slice(), i = t.getEnds().slice(), this.endss_.push(); 24973 else { 24974 const s = this.flatCoordinates.length; 24975 mi(this.flatCoordinates, t.getFlatCoordinates()), i = t.getEnds().slice(); 24976 for (let n = 0, r = i.length; n < r; ++n) 24977 i[n] += s; 24978 } 24979 this.endss_.push(i), this.changed(); 24980 } 24981 /** 24982 * Make a complete copy of the geometry. 24983 * @return {!MultiPolygon} Clone. 24984 * @api 24985 */ 24986 clone() { 24987 const t = this.endss_.length, i = new Array(t); 24988 for (let n = 0; n < t; ++n) 24989 i[n] = this.endss_[n].slice(); 24990 const s = new Xo( 24991 this.flatCoordinates.slice(), 24992 this.layout, 24993 i 24994 ); 24995 return s.applyProperties(this), s; 24996 } 24997 /** 24998 * @param {number} x X. 24999 * @param {number} y Y. 25000 * @param {import("../coordinate.js").Coordinate} closestPoint Closest point. 25001 * @param {number} minSquaredDistance Minimum squared distance. 25002 * @return {number} Minimum squared distance. 25003 */ 25004 closestPointXY(t, i, s, n) { 25005 return n < Ss(this.getExtent(), t, i) ? n : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt( 25006 RE( 25007 this.flatCoordinates, 25008 0, 25009 this.endss_, 25010 this.stride, 25011 0 25012 ) 25013 ), this.maxDeltaRevision_ = this.getRevision()), IE( 25014 this.getOrientedFlatCoordinates(), 25015 0, 25016 this.endss_, 25017 this.stride, 25018 this.maxDelta_, 25019 !0, 25020 t, 25021 i, 25022 s, 25023 n 25024 )); 25025 } 25026 /** 25027 * @param {number} x X. 25028 * @param {number} y Y. 25029 * @return {boolean} Contains (x, y). 25030 */ 25031 containsXY(t, i) { 25032 return NE( 25033 this.getOrientedFlatCoordinates(), 25034 0, 25035 this.endss_, 25036 this.stride, 25037 t, 25038 i 25039 ); 25040 } 25041 /** 25042 * Return the area of the multipolygon on projected plane. 25043 * @return {number} Area (on projected plane). 25044 * @api 25045 */ 25046 getArea() { 25047 return FE( 25048 this.getOrientedFlatCoordinates(), 25049 0, 25050 this.endss_, 25051 this.stride 25052 ); 25053 } 25054 /** 25055 * Get the coordinate array for this geometry. This array has the structure 25056 * of a GeoJSON coordinate array for multi-polygons. 25057 * 25058 * @param {boolean} [right] Orient coordinates according to the right-hand 25059 * rule (counter-clockwise for exterior and clockwise for interior rings). 25060 * If `false`, coordinates will be oriented according to the left-hand rule 25061 * (clockwise for exterior and counter-clockwise for interior rings). 25062 * By default, coordinate orientation will depend on how the geometry was 25063 * constructed. 25064 * @return {Array<Array<Array<import("../coordinate.js").Coordinate>>>} Coordinates. 25065 * @api 25066 */ 25067 getCoordinates(t) { 25068 let i; 25069 return t !== void 0 ? (i = this.getOrientedFlatCoordinates().slice(), Eu( 25070 i, 25071 0, 25072 this.endss_, 25073 this.stride, 25074 t 25075 )) : i = this.flatCoordinates, Cl( 25076 i, 25077 0, 25078 this.endss_, 25079 this.stride 25080 ); 25081 } 25082 /** 25083 * @return {Array<Array<number>>} Endss. 25084 */ 25085 getEndss() { 25086 return this.endss_; 25087 } 25088 /** 25089 * @return {Array<number>} Flat interior points. 25090 */ 25091 getFlatInteriorPoints() { 25092 if (this.flatInteriorPointsRevision_ != this.getRevision()) { 25093 const t = zb( 25094 this.flatCoordinates, 25095 0, 25096 this.endss_, 25097 this.stride 25098 ); 25099 this.flatInteriorPoints_ = kE( 25100 this.getOrientedFlatCoordinates(), 25101 0, 25102 this.endss_, 25103 this.stride, 25104 t 25105 ), this.flatInteriorPointsRevision_ = this.getRevision(); 25106 } 25107 return this.flatInteriorPoints_; 25108 } 25109 /** 25110 * Return the interior points as {@link module:ol/geom/MultiPoint~MultiPoint multipoint}. 25111 * @return {MultiPoint} Interior points as XYM coordinates, where M is 25112 * the length of the horizontal intersection that the point belongs to. 25113 * @api 25114 */ 25115 getInteriorPoints() { 25116 return new tc(this.getFlatInteriorPoints().slice(), "XYM"); 25117 } 25118 /** 25119 * @return {Array<number>} Oriented flat coordinates. 25120 */ 25121 getOrientedFlatCoordinates() { 25122 if (this.orientedRevision_ != this.getRevision()) { 25123 const t = this.flatCoordinates; 25124 WE(t, 0, this.endss_, this.stride) ? this.orientedFlatCoordinates_ = t : (this.orientedFlatCoordinates_ = t.slice(), this.orientedFlatCoordinates_.length = Eu( 25125 this.orientedFlatCoordinates_, 25126 0, 25127 this.endss_, 25128 this.stride 25129 )), this.orientedRevision_ = this.getRevision(); 25130 } 25131 return this.orientedFlatCoordinates_; 25132 } 25133 /** 25134 * @param {number} squaredTolerance Squared tolerance. 25135 * @return {MultiPolygon} Simplified MultiPolygon. 25136 * @protected 25137 */ 25138 getSimplifiedGeometryInternal(t) { 25139 const i = [], s = []; 25140 return i.length = OE( 25141 this.flatCoordinates, 25142 0, 25143 this.endss_, 25144 this.stride, 25145 Math.sqrt(t), 25146 i, 25147 0, 25148 s 25149 ), new Xo(i, "XY", s); 25150 } 25151 /** 25152 * Return the polygon at the specified index. 25153 * @param {number} index Index. 25154 * @return {Polygon} Polygon. 25155 * @api 25156 */ 25157 getPolygon(t) { 25158 if (t < 0 || this.endss_.length <= t) 25159 return null; 25160 let i; 25161 if (t === 0) 25162 i = 0; 25163 else { 25164 const r = this.endss_[t - 1]; 25165 i = r[r.length - 1]; 25166 } 25167 const s = this.endss_[t].slice(), n = s[s.length - 1]; 25168 if (i !== 0) 25169 for (let r = 0, o = s.length; r < o; ++r) 25170 s[r] -= i; 25171 return new En( 25172 this.flatCoordinates.slice(i, n), 25173 this.layout, 25174 s 25175 ); 25176 } 25177 /** 25178 * Return the polygons of this multipolygon. 25179 * @return {Array<Polygon>} Polygons. 25180 * @api 25181 */ 25182 getPolygons() { 25183 const t = this.layout, i = this.flatCoordinates, s = this.endss_, n = []; 25184 let r = 0; 25185 for (let o = 0, a = s.length; o < a; ++o) { 25186 const l = s[o].slice(), h = l[l.length - 1]; 25187 if (r !== 0) 25188 for (let u = 0, d = l.length; u < d; ++u) 25189 l[u] -= r; 25190 const c = new En( 25191 i.slice(r, h), 25192 t, 25193 l 25194 ); 25195 n.push(c), r = h; 25196 } 25197 return n; 25198 } 25199 /** 25200 * Get the type of this geometry. 25201 * @return {import("./Geometry.js").Type} Geometry type. 25202 * @api 25203 */ 25204 getType() { 25205 return "MultiPolygon"; 25206 } 25207 /** 25208 * Test if the geometry and the passed extent intersect. 25209 * @param {import("../extent.js").Extent} extent Extent. 25210 * @return {boolean} `true` if the geometry and the extent intersect. 25211 * @api 25212 */ 25213 intersectsExtent(t) { 25214 return zE( 25215 this.getOrientedFlatCoordinates(), 25216 0, 25217 this.endss_, 25218 this.stride, 25219 t 25220 ); 25221 } 25222 /** 25223 * Set the coordinates of the multipolygon. 25224 * @param {!Array<Array<Array<import("../coordinate.js").Coordinate>>>} coordinates Coordinates. 25225 * @param {import("./Geometry.js").GeometryLayout} [layout] Layout. 25226 * @api 25227 */ 25228 setCoordinates(t, i) { 25229 this.setLayout(i, t, 3), this.flatCoordinates || (this.flatCoordinates = []); 25230 const s = PE( 25231 this.flatCoordinates, 25232 0, 25233 t, 25234 this.stride, 25235 this.endss_ 25236 ); 25237 if (s.length === 0) 25238 this.flatCoordinates.length = 0; 25239 else { 25240 const n = s[s.length - 1]; 25241 this.flatCoordinates.length = n.length === 0 ? 0 : n[n.length - 1]; 25242 } 25243 this.changed(); 25244 } 25245} 25246const ec = Xo, to = { 25247 /** 25248 * Triggered upon feature draw start 25249 * @event DrawEvent#drawstart 25250 * @api 25251 */ 25252 DRAWSTART: "drawstart", 25253 /** 25254 * Triggered upon feature draw end 25255 * @event DrawEvent#drawend 25256 * @api 25257 */ 25258 DRAWEND: "drawend", 25259 /** 25260 * Triggered upon feature draw abortion 25261 * @event DrawEvent#drawabort 25262 * @api 25263 */ 25264 DRAWABORT: "drawabort" 25265}; 25266class eo extends Ae { 25267 /** 25268 * @param {DrawEventType} type Type. 25269 * @param {Feature} feature The feature drawn. 25270 */ 25271 constructor(t, i) { 25272 super(t), this.feature = i; 25273 } 25274} 25275function jb(e, t) { 25276 const i = []; 25277 for (let s = 0; s < t.length; ++s) { 25278 const r = t[s].getGeometry(); 25279 Fg(e, r, i); 25280 } 25281 return i; 25282} 25283function io(e, t) { 25284 return fi(e[0], e[1], t[0], t[1]); 25285} 25286function Hs(e, t) { 25287 const i = e.length; 25288 return t < 0 ? e[t + i] : t >= i ? e[t - i] : e[t]; 25289} 25290function so(e, t, i) { 25291 let s, n; 25292 t < i ? (s = t, n = i) : (s = i, n = t);
25293 const r = Math.ceil(s), o = Math.floor(n); 25294 if (r > o) { 25295 const l = Zs(e, s), h = Zs(e, n); 25296 return io(l, h); 25297 } 25298 let a = 0; 25299 if (s < r) { 25300 const l = Zs(e, s), h = Hs(e, r); 25301 a += io(l, h); 25302 } 25303 if (o < n) { 25304 const l = Hs(e, o), h = Zs(e, n); 25305 a += io(l, h); 25306 } 25307 for (let l = r; l < o - 1; ++l) { 25308 const h = Hs(e, l), c = Hs(e, l + 1); 25309 a += io(h, c); 25310 } 25311 return a; 25312} 25313function Fg(e, t, i) { 25314 if (t instanceof ys) { 25315 no(e, t.getCoordinates(), !1, i); 25316 return; 25317 } 25318 if (t instanceof Jh) { 25319 const s = t.getCoordinates(); 25320 for (let n = 0, r = s.length; n < r; ++n) 25321 no(e, s[n], !1, i); 25322 return; 25323 } 25324 if (t instanceof En) { 25325 const s = t.getCoordinates(); 25326 for (let n = 0, r = s.length; n < r; ++n) 25327 no(e, s[n], !0, i); 25328 return; 25329 } 25330 if (t instanceof ec) { 25331 const s = t.getCoordinates(); 25332 for (let n = 0, r = s.length; n < r; ++n) { 25333 const o = s[n]; 25334 for (let a = 0, l = o.length; a < l; ++a) 25335 no(e, o[a], !0, i); 25336 } 25337 return; 25338 } 25339 if (t instanceof Og) { 25340 const s = t.getGeometries(); 25341 for (let n = 0; n < s.length; ++n) 25342 Fg(e, s[n], i); 25343 return; 25344 } 25345} 25346const Ya = { index: -1, endIndex: NaN }; 25347function Wb(e, t, i, s) { 25348 const n = e[0], r = e[1]; 25349 let o = 1 / 0, a = -1, l = NaN; 25350 for (let u = 0; u < t.targets.length; ++u) { 25351 const d = t.targets[u], f = d.coordinates; 25352 let g = 1 / 0, _; 25353 for (let m = 0; m < f.length - 1; ++m) { 25354 const p = f[m], y = f[m + 1], v = Dg(n, r, p, y); 25355 v.squaredDistance < g && (g = v.squaredDistance, _ = m + v.along); 25356 } 25357 g < o && (o = g, d.ring && t.targetIndex === u && (d.endIndex > d.startIndex ? _ < d.startIndex && (_ += f.length) : d.endIndex < d.startIndex && _ > d.startIndex && (_ -= f.length)), l = _, a = u); 25358 } 25359 const h = t.targets[a]; 25360 let c = h.ring; 25361 if (t.targetIndex === a && c) { 25362 const u = Zs( 25363 h.coordinates, 25364 l 25365 ), d = i.getPixelFromCoordinate(u); 25366 Co(d, t.startPx) > s && (c = !1); 25367 } 25368 if (c) { 25369 const u = h.coordinates, d = u.length, f = h.startIndex, g = l; 25370 if (f < g) { 25371 const _ = so( 25372 u, 25373 f, 25374 g 25375 ); 25376 so( 25377 u, 25378 f, 25379 g - d 25380 ) < _ && (l -= d); 25381 } else { 25382 const _ = so( 25383 u, 25384 f, 25385 g 25386 ); 25387 so( 25388 u, 25389 f, 25390 g + d 25391 ) < _ && (l += d); 25392 } 25393 } 25394 return Ya.index = a, Ya.endIndex = l, Ya; 25395} 25396function no(e, t, i, s) { 25397 const n = e[0], r = e[1]; 25398 for (let o = 0, a = t.length - 1; o < a; ++o) { 25399 const l = t[o], h = t[o + 1], c = Dg(n, r, l, h); 25400 if (c.squaredDistance === 0) { 25401 const u = o + c.along; 25402 s.push({ 25403 coordinates: t, 25404 ring: i, 25405 startIndex: u, 25406 endIndex: u 25407 }); 25408 return; 25409 } 25410 } 25411} 25412const Ka = { along: 0, squaredDistance: 0 }; 25413function Dg(e, t, i, s) { 25414 const n = i[0], r = i[1], o = s[0], a = s[1], l = o - n, h = a - r; 25415 let c = 0, u = n, d = r; 25416 return (l !== 0 || h !== 0) && (c = Ot(((e - n) * l + (t - r) * h) / (l * l + h * h), 0, 1), u += l * c, d += h * c), Ka.along = c, Ka.squaredDistance = Tr(fi(e, t, u, d), 10), Ka; 25417} 25418function Zs(e, t) { 25419 const i = e.length; 25420 let s = Math.floor(t); 25421 const n = t - s; 25422 s >= i ? s -= i : s < 0 && (s += i); 25423 let r = s + 1; 25424 r >= i && (r -= i); 25425 const o = e[s], a = o[0], l = o[1], h = e[r], c = h[0] - a, u = h[1] - l; 25426 return [a + c * n, l + u * n]; 25427} 25428class Bb extends es { 25429 /** 25430 * @param {Options} options Options. 25431 */ 25432 constructor(t) { 25433 const i = ( 25434 /** @type {import("./Pointer.js").Options} */ 25435 t 25436 ); 25437 i.stopDown || (i.stopDown = Rs), super(i), this.on, this.once, this.un, this.shouldHandle_ = !1, this.downPx_ = null, this.downTimeout_, this.lastDragTime_, this.pointerType_, this.freehand_ = !1, this.source_ = t.source ? t.source : null, this.features_ = t.features ? t.features : null, this.snapTolerance_ = t.snapTolerance ? t.snapTolerance : 12, this.type_ = /** @type {import("../geom/Geometry.js").Type} */ 25438 t.type, this.mode_ = Xb(this.type_), this.stopClick_ = !!t.stopClick, this.minPoints_ = t.minPoints ? t.minPoints : this.mode_ === "Polygon" ? 3 : 2, this.maxPoints_ = this.mode_ === "Circle" ? 2 : t.maxPoints ? t.maxPoints : 1 / 0, this.finishCondition_ = t.finishCondition ? t.finishCondition : bs, this.geometryLayout_ = t.geometryLayout ? t.geometryLayout : "XY"; 25439 let s = t.geometryFunction; 25440 if (!s) { 25441 const n = this.mode_; 25442 if (n === "Circle") 25443 s = function(r, o, a) { 25444 const l = o || new Gb([NaN, NaN]), h = It(r[0]), c = gi( 25445 h, 25446 It(r[r.length - 1]) 25447 ); 25448 return l.setCenterAndRadius( 25449 h, 25450 Math.sqrt(c), 25451 this.geometryLayout_ 25452 ), l; 25453 }; 25454 else { 25455 let r; 25456 n === "Point" ? r = pi : n === "LineString" ? r = ys : n === "Polygon" && (r = En), s = function(o, a, l) { 25457 return a ? n === "Polygon" ? o[0].length ? a.setCoordinates( 25458 [o[0].concat([o[0][0]])], 25459 this.geometryLayout_ 25460 ) : a.setCoordinates([], this.geometryLayout_) : a.setCoordinates(o, this.geometryLayout_) : a = new r(o, this.geometryLayout_), a; 25461 }; 25462 } 25463 } 25464 this.geometryFunction_ = s, this.dragVertexDelay_ = t.dragVertexDelay !== void 0 ? t.dragVertexDelay : 500, this.finishCoordinate_ = null, this.sketchFeature_ = null, this.sketchPoint_ = null, this.sketchCoords_ = null, this.sketchLine_ = null, this.sketchLineCoords_ = null, this.squaredClickTolerance_ = t.clickTolerance ? t.clickTolerance * t.clickTolerance : 36, this.overlay_ = new pa({ 25465 source: new ya({ 25466 useSpatialIndex: !1, 25467 wrapX: t.wrapX ? t.wrapX : !1 25468 }), 25469 style: t.style ? t.style : Ub(), 25470 updateWhileInteracting: !0 25471 }), this.geometryName_ = t.geometryName, this.condition_ = t.condition ? t.condition : jh, this.freehandCondition_, t.freehand ? this.freehandCondition_ = zo : this.freehandCondition_ = t.freehandCondition ? t.freehandCondition : lg, this.traceCondition_, this.setTrace(t.trace || !1), this.traceState_ = { active: !1 }
25471, this.traceSource_ = t.traceSource || t.source || null, this.addChangeListener(Il.ACTIVE, this.updateState_); 25472 } 25473 /** 25474 * Toggle tracing mode or set a tracing condition. 25475 * 25476 * @param {boolean|import("../events/condition.js").Condition} trace A boolean to toggle tracing mode or an event 25477 * condition that will be checked when a feature is clicked to determine if tracing should be active. 25478 */ 25479 setTrace(t) { 25480 let i; 25481 t ? t === !0 ? i = zo : i = t : i = FM, this.traceCondition_ = i; 25482 } 25483 /** 25484 * Remove the interaction from its current map and attach it to the new map. 25485 * Subclasses may set up event handlers to get notified about changes to 25486 * the map here. 25487 * @param {import("../Map.js").default} map Map. 25488 */ 25489 setMap(t) { 25490 super.setMap(t), this.updateState_(); 25491 } 25492 /** 25493 * Get the overlay layer that this interaction renders sketch features to. 25494 * @return {VectorLayer} Overlay layer. 25495 * @api 25496 */ 25497 getOverlay() { 25498 return this.overlay_; 25499 } 25500 /** 25501 * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may actually draw or finish the drawing. 25502 * @param {import("../MapBrowserEvent.js").default} event Map browser event. 25503 * @return {boolean} `false` to stop event propagation. 25504 * @api 25505 */ 25506 handleEvent(t) { 25507 t.originalEvent.type === et.CONTEXTMENU && t.originalEvent.preventDefault(), this.freehand_ = this.mode_ !== "Point" && this.freehandCondition_(t); 25508 let i = t.type === dt.POINTERMOVE, s = !0; 25509 return !this.freehand_ && this.lastDragTime_ && t.type === dt.POINTERDRAG && (Date.now() - this.lastDragTime_ >= this.dragVertexDelay_ ? (this.downPx_ = t.pixel, this.shouldHandle_ = !this.freehand_, i = !0) : this.lastDragTime_ = void 0, this.shouldHandle_ && this.downTimeout_ !== void 0 && (clearTimeout(this.downTimeout_), this.downTimeout_ = void 0)), this.freehand_ && t.type === dt.POINTERDRAG && this.sketchFeature_ !== null ? (this.addToDrawing_(t.coordinate), s = !1) : this.freehand_ && t.type === dt.POINTERDOWN ? s = !1 : i && this.getPointerCount() < 2 ? (s = t.type === dt.POINTERMOVE, s && this.freehand_ ? (this.handlePointerMove_(t), this.shouldHandle_ && t.originalEvent.preventDefault()) : (t.originalEvent.pointerType === "mouse" || t.type === dt.POINTERDRAG && this.downTimeout_ === void 0) && this.handlePointerMove_(t)) : t.type === dt.DBLCLICK && (s = !1), super.handleEvent(t) && s; 25510 } 25511 /** 25512 * Handle pointer down events. 25513 * @param {import("../MapBrowserEvent.js").default} event Event. 25514 * @return {boolean} If the event was consumed. 25515 */ 25516 handleDownEvent(t) { 25517 return this.shouldHandle_ = !this.freehand_, this.freehand_ ? (this.downPx_ = t.pixel, this.finishCoordinate_ || this.startDrawing_(t.coordinate), !0) : this.condition_(t) ? (this.lastDragTime_ = Date.now(), this.downTimeout_ = setTimeout(() => { 25518 this.handlePointerMove_( 25519 new ui( 25520 dt.POINTERMOVE, 25521 t.map, 25522 t.originalEvent, 25523 !1, 25524 t.frameState 25525 ) 25526 ); 25527 }, this.dragVertexDelay_), this.downPx_ = t.pixel, !0) : (this.lastDragTime_ = void 0, !1); 25528 } 25529 /** 25530 * @private 25531 */ 25532 deactivateTrace_() { 25533 this.traceState_ = { active: !1 }; 25534 } 25535 /** 25536 * Activate or deactivate trace state based on a browser event. 25537 * @param {import("../MapBrowserEvent.js").default} event Event. 25538 * @private 25539 */ 25540 toggleTraceState_(t) {
25541 if (!this.traceSource_ || !this.traceCondition_(t)) 25542 return; 25543 if (this.traceState_.active) { 25544 this.deactivateTrace_(); 25545 return; 25546 } 25547 const i = this.getMap(), s = i.getCoordinateFromPixel([ 25548 t.pixel[0] - this.snapTolerance_, 25549 t.pixel[1] + this.snapTolerance_ 25550 ]), n = i.getCoordinateFromPixel([ 25551 t.pixel[0] + this.snapTolerance_, 25552 t.pixel[1] - this.snapTolerance_ 25553 ]), r = ce([s, n]), o = this.traceSource_.getFeaturesInExtent(r); 25554 if (o.length === 0) 25555 return; 25556 const a = jb(t.coordinate, o); 25557 a.length && (this.traceState_ = { 25558 active: !0, 25559 startPx: t.pixel.slice(), 25560 targets: a, 25561 targetIndex: -1 25562 }); 25563 } 25564 /** 25565 * @param {TraceTarget} target The trace target. 25566 * @param {number} endIndex The new end index of the trace. 25567 * @private 25568 */ 25569 addOrRemoveTracedCoordinates_(t, i) { 25570 const s = t.startIndex <= t.endIndex, n = t.startIndex <= i; 25571 s === n ? s && i > t.endIndex || !s && i < t.endIndex ? this.addTracedCoordinates_(t, t.endIndex, i) : (s && i < t.endIndex || !s && i > t.endIndex) && this.removeTracedCoordinates_(i, t.endIndex) : (this.removeTracedCoordinates_(t.startIndex, t.endIndex), this.addTracedCoordinates_(t, t.startIndex, i)); 25572 } 25573 /** 25574 * @param {number} fromIndex The start index. 25575 * @param {number} toIndex The end index. 25576 * @private 25577 */ 25578 removeTracedCoordinates_(t, i) { 25579 if (t === i) 25580 return; 25581 let s = 0; 25582 if (t < i) { 25583 const n = Math.ceil(t); 25584 let r = Math.floor(i); 25585 r === i && (r -= 1), s = r - n + 1; 25586 } else { 25587 const n = Math.floor(t); 25588 let r = Math.ceil(i); 25589 r === i && (r += 1), s = n - r + 1; 25590 } 25591 s > 0 && this.removeLastPoints_(s); 25592 } 25593 /** 25594 * @param {TraceTarget} target The trace target. 25595 * @param {number} fromIndex The start index. 25596 * @param {number} toIndex The end index. 25597 * @private 25598 */ 25599 addTracedCoordinates_(t, i, s) { 25600 if (i === s) 25601 return; 25602 const n = []; 25603 if (i < s) { 25604 const r = Math.ceil(i); 25605 let o = Math.floor(s); 25606 o === s && (o -= 1); 25607 for (let a = r; a <= o; ++a) 25608 n.push(Hs(t.coordinates, a)); 25609 } else { 25610 const r = Math.floor(i); 25611 let o = Math.ceil(s); 25612 o === s && (o += 1); 25613 for (let a = r; a >= o; --a) 25614 n.push(Hs(t.coordinates, a)); 25615 } 25616 n.length && this.appendCoordinates(n); 25617 } 25618 /** 25619 * Update the trace. 25620 * @param {import("../MapBrowserEvent.js").default} event Event. 25621 * @private 25622 */ 25623 updateTrace_(t) { 25624 const i = this.traceState_; 25625 if (!i.active || i.targetIndex === -1 && Co(i.startPx, t.pixel) < this.snapTolerance_) 25626 return; 25627 const s = Wb( 25628 t.coordinate, 25629 i, 25630 this.getMap(), 25631 this.snapTolerance_ 25632 ); 25633 if (i.targetIndex !== s.index) { 25634 if (i.targetIndex !== -1) { 25635 const l = i.targets[i.targetIndex]; 25636 this.removeTracedCoordinates_(l.startIndex, l.endIndex); 25637 } 25638 const a = i.targets[s.index]; 25639 this.addTracedCoordinates_( 25640 a, 25641 a.startIndex, 25642 s.endIndex 25643 ); 25644 } else { 25645 const a = i.targets[i.targetIndex]; 25646 this.addOrRemoveTracedCoordinates_(a, s.endIndex); 25647 } 25648 i.targetIndex = s.index; 25649 const n = i.targets[i.targetIndex]; 25650 n.endIndex = s.endIndex; 25651 const r = Zs( 25652 n.coordinates, 25653 n.endIndex 25654 ), o = this.getMap().getPixelFromCoordinate(r); 25655 t.coordinate = r, t.pixel = [Math.round(o[0]), Math.round(o[1])]; 25656 } 25657 /** 25658 * Handle pointer up events. 25659 * @param {import("../MapBrowserEvent.js").default} event Event. 25660 * @return {boolean} If the event was consumed. 25661 */ 25662 handleUpEvent(t) { 25663 let i = !0; 25664 if (this.getPointerCount() === 0) { 25665 this.downTimeout_ && (clearTimeout(this.downTimeout_), this.downTimeout_ = void 0), this.handlePointerMove_(t); 25666 const s = this.traceState_.active; 25667 if (this.toggleTraceState_(t), this.shouldHandle_) { 25668 const n = !this.finishCoordinate_; 25669 n && this.startDrawing_(t.coordinate), !n && this.freehand_ ? this.finishDrawing() : !this.freehand_ && (!n || this.mode_ === "Point") && (this.atFinish_(t.pixel, s) ? this.finishCondition_(t) && this.finishDrawing() : this.addToDrawing_(t.coordinate)), i = !1; 25670 } else 25671 this.freehand_ && this.abortDrawing(); 25672 } 25673 return !i && this.stopClick_ && t.preventDefault(), i; 25674 } 25675 /** 25676 * Handle move events. 25677 * @param {import("../MapBrowserEvent.js").default} event A move event. 25678 * @private 25679 */ 25680 handlePointerMove_(t) { 25681 if (this.pointerType_ = t.originalEvent.pointerType, this.downPx_ && (!this.freehand_ && this.shouldHandle_ || this.freehand_ && !this.shouldHandle_)) { 25682 const i = this.downPx_, s = t.pixel, n = i[0] - s[0], r = i[
256821] - s[1], o = n * n + r * r; 25683 if (this.shouldHandle_ = this.freehand_ ? o > this.squaredClickTolerance_ : o <= this.squaredClickTolerance_, !this.shouldHandle_) 25684 return; 25685 } 25686 if (!this.finishCoordinate_) { 25687 this.createOrUpdateSketchPoint_(t.coordinate.slice()); 25688 return; 25689 } 25690 this.updateTrace_(t), this.modifyDrawing_(t.coordinate); 25691 } 25692 /** 25693 * Determine if an event is within the snapping tolerance of the start coord. 25694 * @param {import("../pixel.js").Pixel} pixel Pixel. 25695 * @param {boolean} [tracing] Drawing in trace mode (only stop if at the starting point). 25696 * @return {boolean} The event is within the snapping tolerance of the start. 25697 * @private 25698 */ 25699 atFinish_(t, i) { 25700 let s = !1; 25701 if (this.sketchFeature_) { 25702 let n = !1, r = [this.finishCoordinate_]; 25703 const o = this.mode_; 25704 if (o === "Point") 25705 s = !0; 25706 else if (o === "Circle") 25707 s = this.sketchCoords_.length === 2; 25708 else if (o === "LineString") 25709 n = !i && this.sketchCoords_.length > this.minPoints_; 25710 else if (o === "Polygon") { 25711 const a = ( 25712 /** @type {PolyCoordType} */ 25713 this.sketchCoords_ 25714 ); 25715 n = a[0].length > this.minPoints_, r = [ 25716 a[0][0], 25717 a[0][a[0].length - 2] 25718 ], i ? r = [a[0][0]] : r = [ 25719 a[0][0], 25720 a[0][a[0].length - 2] 25721 ]; 25722 } 25723 if (n) { 25724 const a = this.getMap(); 25725 for (let l = 0, h = r.length; l < h; l++) { 25726 const c = r[l], u = a.getPixelFromCoordinate(c), d = t[0] - u[0], f = t[1] - u[1], g = this.freehand_ ? 1 : this.snapTolerance_; 25727 if (s = Math.sqrt(d * d + f * f) <= g, s) { 25728 this.finishCoordinate_ = c; 25729 break; 25730 } 25731 } 25732 } 25733 } 25734 return s; 25735 } 25736 /** 25737 * @param {import("../coordinate").Coordinate} coordinates Coordinate. 25738 * @private 25739 */ 25740 createOrUpdateSketchPoint_(t) { 25741 this.sketchPoint_ ? this.sketchPoint_.getGeometry().setCoordinates(t) : (this.sketchPoint_ = new Ni(new pi(t)), this.updateSketchFeatures_()); 25742 } 25743 /** 25744 * @param {import("../geom/Polygon.js").default} geometry Polygon geometry. 25745 * @private 25746 */ 25747 createOrUpdateCustomSketchLine_(t) { 25748 this.sketchLine_ || (this.sketchLine_ = new Ni()); 25749 const i = t.getLinearRing(0); 25750 let s = this.sketchLine_.getGeometry(); 25751 s ? (s.setFlatCoordinates( 25752 i.getLayout(), 25753 i.getFlatCoordinates() 25754 ), s.changed()) : (s = new ys( 25755 i.getFlatCoordinates(), 25756 i.getLayout() 25757 ), this.sketchLine_.setGeometry(s)); 25758 } 25759 /** 25760 * Start the drawing. 25761 * @param {import("../coordinate.js").Coordinate} start Start coordinate. 25762 * @private 25763 */ 25764 startDrawing_(t) { 25765 const i = this.getMap().getView().getProjection(), s = Oo(this.geometryLayout_); 25766 for (; t.length < s; ) 25767 t.push(0); 25768 this.finishCoordinate_ = t, this.mode_ === "Point" ? this.sketchCoords_ = t.slice() : this.mode_ === "Polygon" ? (this.sketchCoords_ = [[t.slice(), t.slice()]], this.sketchLineCoords_ = this.sketchCoords_[0]) : this.sketchCoords_ = [t.slice(), t.slice()], this.sketchLineCoords_ && (this.sketchLine_ = new Ni(new ys(this.sketchLineCoords_))); 25769 const n = this.geometryFunction_( 25770 this.sketchCoords_, 25771 void 0, 25772 i 25773 ); 25774 this.sketchFeature_ = new Ni(), this.geometryName_ && this.sketchFeature_.setGeometryName(this.geometryName_), this.sketchFeature_.setGeometry(n), this.updateSketchFeatures_(), this.dispatchEvent( 25775 new eo(to.DRAWSTART, this.sketchFeature_) 25776 ); 25777 } 25778 /** 25779 * Modify the drawing. 25780 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 25781 * @private 25782 */ 25783 modifyDrawing_(t) { 25784 const i = this.getMap(), s = this.sketchFeature_.getGeometry(), n = i.getView().getProjection(), r = Oo(this.geometryLayout_); 25785 let o, a; 25786 for (; t.length < r; ) 25787 t.push(0); 25788 this.mode_ === "Point" ? a = this.sketchCoords_ : this.mode_ === "Polygon" ? (o = /** @type {PolyCoordType} */ 25789 this.sketchCoords_[0], a = o[o.length - 1], this.atFinish_(i.getPixelFromCoordinate(t)) && (t = this.finishCoordinate_.slice())) : (o = this.sketchCoords_, a = o[o.length - 1]), a[0] = t[0], a[1] = t[1], this.geometryFunction_(
25790 /** @type {!LineCoordType} */ 25791 this.sketchCoords_, 25792 s, 25793 n 25794 ), this.sketchPoint_ && this.sketchPoint_.getGeometry().setCoordinates(t), s.getType() === "Polygon" && this.mode_ !== "Polygon" ? this.createOrUpdateCustomSketchLine_( 25795 /** @type {Polygon} */ 25796 s 25797 ) : this.sketchLineCoords_ && this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_), this.updateSketchFeatures_(); 25798 } 25799 /** 25800 * Add a new coordinate to the drawing. 25801 * @param {!PointCoordType} coordinate Coordinate 25802 * @private 25803 */ 25804 addToDrawing_(t) { 25805 const i = this.sketchFeature_.getGeometry(), s = this.getMap().getView().getProjection(); 25806 let n, r; 25807 const o = this.mode_; 25808 o === "LineString" || o === "Circle" ? (this.finishCoordinate_ = t.slice(), r = /** @type {LineCoordType} */ 25809 this.sketchCoords_, r.length >= this.maxPoints_ && (this.freehand_ ? r.pop() : n = !0), r.push(t.slice()), this.geometryFunction_(r, i, s)) : o === "Polygon" && (r = /** @type {PolyCoordType} */ 25810 this.sketchCoords_[0], r.length >= this.maxPoints_ && (this.freehand_ ? r.pop() : n = !0), r.push(t.slice()), n && (this.finishCoordinate_ = r[0]), this.geometryFunction_(this.sketchCoords_, i, s)), this.createOrUpdateSketchPoint_(t.slice()), this.updateSketchFeatures_(), n && this.finishDrawing(); 25811 } 25812 /** 25813 * @param {number} n The number of points to remove. 25814 */ 25815 removeLastPoints_(t) { 25816 if (!this.sketchFeature_) 25817 return; 25818 const i = this.sketchFeature_.getGeometry(), s = this.getMap().getView().getProjection(), n = this.mode_; 25819 for (let r = 0; r < t; ++r) { 25820 let o; 25821 if (n === "LineString" || n === "Circle") { 25822 if (o = /** @type {LineCoordType} */ 25823 this.sketchCoords_, o.splice(-2, 1), o.length >= 2) { 25824 this.finishCoordinate_ = o[o.length - 2].slice(); 25825 const a = this.finishCoordinate_.slice(); 25826 o[o.length - 1] = a, this.createOrUpdateSketchPoint_(a); 25827 } 25828 this.geometryFunction_(o, i, s), i.getType() === "Polygon" && this.sketchLine_ && this.createOrUpdateCustomSketchLine_( 25829 /** @type {Polygon} */ 25830 i 25831 ); 25832 } else if (n === "Polygon") { 25833 o = /** @type {PolyCoordType} */ 25834 this.sketchCoords_[0], o.splice(-2, 1); 25835 const a = this.sketchLine_.getGeometry(); 25836 if (o.length >= 2) { 25837 const l = o[o.length - 2].slice(); 25838 o[o.length - 1] = l, this.createOrUpdateSketchPoint_(l); 25839 } 25840 a.setCoordinates(o), this.geometryFunction_(this.sketchCoords_, i, s); 25841 } 25842 if (o.length === 1) { 25843 this.abortDrawing(); 25844 break; 25845 } 25846 } 25847 this.updateSketchFeatures_(); 25848 } 25849 /** 25850 * Remove last point of the feature currently being drawn. Does not do anything when 25851 * drawing POINT or MULTI_POINT geometries. 25852 * @api 25853 */ 25854 removeLastPoint() { 25855 this.removeLastPoints_(1); 25856 } 25857 /** 25858 * Stop drawing and add the sketch feature to the target layer. 25859 * The {@link module:ol/interaction/Draw~DrawEventType.DRAWEND} event is 25860 * dispatched before inserting the feature. 25861 * @api 25862 */ 25863 finishDrawing() { 25864 const t = this.abortDrawing_(); 25865 if (!t) 25866 return; 25867 let i = this.sketchCoords_; 25868 const s = t.getGeometry(), n = this.getMap().getView().getProjection(); 25869 this.mode_ === "LineString" ? (i.pop(), this.geometryFunction_(i, s, n)) : this.mode_ === "Polygon" && (i[0].pop(), this.geometryFunction_(i, s, n), i = s.getCoordinates()), this.type_ === "MultiPoint" ? t.setGeometry( 25870 new tc([ 25871 /** @type {PointCoordType} */ 25872 i 25873 ]) 25874 ) : this.type_ === "MultiLineString" ? t.setGeometry( 25875 new Jh([ 25876 /** @type {LineCoordType} */ 25877 i 25878 ]) 25879 ) : this.type_ === "MultiPolygon" && t.setGeometry( 25880 new ec([ 25881 /** @type {PolyCoordType} */ 25882 i 25883 ]) 25884 ), this.dispatchEvent(new eo(to.DRAWEND, t)), this.features_ && this.features_.push(t), this.source_ && this.source_.addFeature(t); 25885 } 25886 /** 25887 * Stop drawing without adding the sketch feature to the target layer. 25888 * @return {Feature<import("../geom/SimpleGeometry.js").default>|null} The sketch feature (or null if none). 25889 * @private 25890 */ 25891 abortDrawing_() { 25892 this.finishCoordinate_ = null; 25893 const t = this.sketchFeature_; 25894 return this.sketchFeature_ = null, this.sketchPoint_ = null, this.sketchLine_ = null, this.overlay_.getSource().clear(!0), this.deactivateTrace_(), t; 25895 } 25896 /** 25897 * Stop drawing without adding the sketch feature to the target layer. 25898 * @api 25899 */ 25900 abortDrawing() { 25901 const t = this.abortDrawing_(); 25902 t && this.dispatchEvent(new eo(to.DRAWABORT, t)); 25903 } 25904 /** 25905 * Append coordinates to the end of the geometry that is currently being drawn. 25906 * This can be used when drawing LineStrings or Polygons. Coordinates will 25907 * either be appended to the current LineString or the outer ring of the current 25908 * Polygon. If no geometry is being drawn, a new one will be created. 25909 * @param {!LineCoordType}
25909 coordinates Linear coordinates to be appended to 25910 * the coordinate array. 25911 * @api 25912 */ 25913 appendCoordinates(t) { 25914 const i = this.mode_, s = !this.sketchFeature_; 25915 s && this.startDrawing_(t[0]); 25916 let n; 25917 if (i === "LineString" || i === "Circle") 25918 n = /** @type {LineCoordType} */ 25919 this.sketchCoords_; 25920 else if (i === "Polygon") 25921 n = this.sketchCoords_ && this.sketchCoords_.length ? ( 25922 /** @type {PolyCoordType} */ 25923 this.sketchCoords_[0] 25924 ) : []; 25925 else 25926 return; 25927 s && n.shift(), n.pop(); 25928 for (let o = 0; o < t.length; o++) 25929 this.addToDrawing_(t[o]); 25930 const r = t[t.length - 1]; 25931 this.addToDrawing_(r), this.modifyDrawing_(r); 25932 } 25933 /** 25934 * Initiate draw mode by starting from an existing geometry which will 25935 * receive new additional points. This only works on features with 25936 * `LineString` geometries, where the interaction will extend lines by adding 25937 * points to the end of the coordinates array. 25938 * This will change the original feature, instead of drawing a copy. 25939 * 25940 * The function will dispatch a `drawstart` event. 25941 * 25942 * @param {!Feature<LineString>} feature Feature to be extended. 25943 * @api 25944 */ 25945 extend(t) { 25946 const s = t.getGeometry(); 25947 this.sketchFeature_ = t, this.sketchCoords_ = s.getCoordinates(); 25948 const n = this.sketchCoords_[this.sketchCoords_.length - 1]; 25949 this.finishCoordinate_ = n.slice(), this.sketchCoords_.push(n.slice()), this.sketchPoint_ = new Ni(new pi(n)), this.updateSketchFeatures_(), this.dispatchEvent( 25950 new eo(to.DRAWSTART, this.sketchFeature_) 25951 ); 25952 } 25953 /** 25954 * Redraw the sketch features. 25955 * @private 25956 */ 25957 updateSketchFeatures_() { 25958 const t = []; 25959 this.sketchFeature_ && t.push(this.sketchFeature_), this.sketchLine_ && t.push(this.sketchLine_), this.sketchPoint_ && t.push(this.sketchPoint_); 25960 const i = this.overlay_.getSource(); 25961 i.clear(!0), i.addFeatures(t); 25962 } 25963 /** 25964 * @private 25965 */ 25966 updateState_() { 25967 const t = this.getMap(), i = this.getActive(); 25968 (!t || !i) && this.abortDrawing(), this.overlay_.setMap(i ? t : null); 25969 } 25970} 25971function Ub() { 25972 const e = yg(); 25973 return function(t, i) { 25974 return e[t.getGeometry().getType()]; 25975 }; 25976} 25977function Xb(e) { 25978 switch (e) { 25979 case "Point": 25980 case "MultiPoint": 25981 return "Point"; 25982 case "LineString": 25983 case "MultiLineString": 25984 return "LineString"; 25985 case "Polygon": 25986 case "MultiPolygon": 25987 return "Polygon"; 25988 case "Circle": 25989 return "Circle"; 25990 default: 25991 throw new Error("Invalid type: " + e); 25992 } 25993} 25994const $b = Bb; 25995function Zu(e) { 25996 return ( 25997 /** @type {import("../source/Vector.js").VectorSourceEvent} */ 25998 e.feature ? ( 25999 /** @type {import("../source/Vector.js").VectorSourceEvent} */ 26000 e.feature 26001 ) : ( 26002 /** @type {import("../Collection.js").CollectionEvent<import("../Feature.js").default>} */ 26003 e.element ? ( 26004 /** @type {import("../Collection.js").CollectionEvent<import("../Feature.js").default>} */ 26005 e.element 26006 ) : null 26007 ) 26008 ); 26009} 26010const Va = []; 26011class Yb extends es { 26012 /** 26013 * @param {Options} [options] Options. 26014 */ 26015 constructor(t) { 26016 t = t || {}; 26017 const i = ( 26018 /** @type {import("./Pointer.js").Options} */ 26019 t 26020 ); 26021 i.handleDownEvent || (i.handleDownEvent = bs), i.stopDown || (i.stopDown = Rs), super(i), this.source_ = t.source ? t.source : null, this.vertex_ = t.vertex !== void 0 ? t.vertex : !0, this.edge_ = t.edge !== void 0 ? t.edge : !0, this.features_ = t.features ? t.features : null, this.featuresListenerKeys_ = [], this.featureChangeListenerKeys_ = {}, this.indexedFeaturesExtents_ = {}, this.pendingFeatures_ = {}, this.pixelTolerance_ = t.pixelTolerance !== void 0 ? t.pixelTolerance : 10, this.rBush_ = new Wo(), this.GEOMETRY_SEGMENTERS_ = { 26022 Point: this.segmentPointGeometry_.bind(this), 26023 LineString: this.segmentLineStringGeometry_.bind(this), 26024 LinearRing: this.segmentLineStringGeometry_.bind(this), 26025 Polygon: this.segmentPolygonGeometry_.bind(this), 26026 MultiPoint: this.segmentMultiPointGeometry_.bind(this), 26027 MultiLineString: this.segmentMultiLineStringGeometry_.bind(this), 26028 MultiPolygon: this.segmentMultiPolygonGeometry_.bind(this), 26029 GeometryCollection: this.segmentGeometryCollectionGeometry_.bind(this), 26030 Circle: this.segmentCircleGeometry_.bind(this) 26031 }; 26032 } 26033 /** 26034 * Add a feature to the collection of features that we may snap to. 26035 * @param {import("../Feature.js").default} feature Feature. 26036 * @param {boolean} [register] Whether to listen to the feature change or not 26037 * Defaults to `true`. 26038 * @api 26039 */ 26040 addFeature(t, i) { 26041 i = i !== void 0 ? i : !0; 26042 const s = ot(t), n = t.getGeometry(); 26043 if (n) { 26044 const r = this.GEOMETRY_SEGMENTERS_[n.getType()]; 26045 if (r) { 26046 this.indexedFeaturesExtents_[s] = n.getExtent( 26047 ve() 26048 ); 26049 const o = ( 26050 /** @type {Array<Array<import('../coordinate.js').Coordinate>>} */ 26051 [] 26052 ); 26053 if (r(o, n), o.length === 1) 26054 this.rBush_.insert(ce(o[0]), { 26055 feature: t, 26056 segment: o[0] 26057 }); 26058 else if (o.length > 1) { 26059 const a = o.map((h) => ce(h)), l = o.map((h) => ({ 26060 feature: t, 26061 segment: h 26062 })); 26063 this.rBush_.load(a, l); 26064 } 26065 } 26066 } 26067 i && (this.featureChangeListenerKeys_[s] = lt( 26068 t, 26069 et.CHANGE, 26070 this.handleFeatureChange_, 26071 this 26072 )); 26073 } 26074 /** 26075 * @return {import("../Collection.js").default<import("../Feature.js").default>|Array<import("../Feature.js").default>} Features. 26076 * @private 26077 */ 26078 getFeatures_() { 26079 let t; 26080 return this.features_ ? t = this.features_ : this.source_ && (t = this.source_.getFeatures()), t; 26081 } 26082 /** 26083 * @param {import("../MapBrowserEvent.js").default} evt Map browser event. 26084 * @return {boolean} `false` to stop event propagation. 26085 */ 26086 handleEvent(t) {
26087 const i = this.snapTo(t.pixel, t.coordinate, t.map); 26088 return i && (t.coordinate = i.vertex.slice(0, 2), t.pixel = i.vertexPixel), super.handleEvent(t); 26089 } 26090 /** 26091 * @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent<import("../Feature.js").default>} evt Event. 26092 * @private 26093 */ 26094 handleFeatureAdd_(t) { 26095 const i = Zu(t); 26096 i && this.addFeature(i); 26097 } 26098 /** 26099 * @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent<import("../Feature.js").default>} evt Event. 26100 * @private 26101 */ 26102 handleFeatureRemove_(t) { 26103 const i = Zu(t); 26104 i && this.removeFeature(i); 26105 } 26106 /** 26107 * @param {import("../events/Event.js").default} evt Event. 26108 * @private 26109 */ 26110 handleFeatureChange_(t) { 26111 const i = ( 26112 /** @type {import("../Feature.js").default} */ 26113 t.target 26114 ); 26115 if (this.handlingDownUpSequence) { 26116 const s = ot(i); 26117 s in this.pendingFeatures_ || (this.pendingFeatures_[s] = i); 26118 } else 26119 this.updateFeature_(i); 26120 } 26121 /** 26122 * Handle pointer up events. 26123 * @param {import("../MapBrowserEvent.js").default} evt Event. 26124 * @return {boolean} If the event was consumed. 26125 */ 26126 handleUpEvent(t) { 26127 const i = Object.values(this.pendingFeatures_); 26128 return i.length && (i.forEach(this.updateFeature_.bind(this)), this.pendingFeatures_ = {}), !1; 26129 } 26130 /** 26131 * Remove a feature from the collection of features that we may snap to. 26132 * @param {import("../Feature.js").default} feature Feature 26133 * @param {boolean} [unlisten] Whether to unlisten to the feature change 26134 * or not. Defaults to `true`. 26135 * @api 26136 */ 26137 removeFeature(t, i) { 26138 const s = i !== void 0 ? i : !0, n = ot(t), r = this.indexedFeaturesExtents_[n]; 26139 if (r) { 26140 const o = this.rBush_, a = []; 26141 o.forEachInExtent(r, function(l) { 26142 t === l.feature && a.push(l); 26143 }); 26144 for (let l = a.length - 1; l >= 0; --l) 26145 o.remove(a[l]); 26146 } 26147 s && (Mt(this.featureChangeListenerKeys_[n]), delete this.featureChangeListenerKeys_[n]); 26148 } 26149 /** 26150 * Remove the interaction from its current map and attach it to the new map. 26151 * Subclasses may set up event handlers to get notified about changes to 26152 * the map here. 26153 * @param {import("../Map.js").default} map Map. 26154 */ 26155 setMap(t) { 26156 const i = this.getMap(), s = this.featuresListenerKeys_, n = ( 26157 /** @type {Array<import("../Feature.js").default>} */ 26158 this.getFeatures_() 26159 ); 26160 i && (s.forEach(Mt), s.length = 0, this.rBush_.clear(), Object.values(this.featureChangeListenerKeys_).forEach(Mt), this.featureChangeListenerKeys_ = {}), super.setMap(t), t && (this.features_ ? s.push( 26161 lt( 26162 this.features_, 26163 $t.ADD, 26164 this.handleFeatureAdd_, 26165 this 26166 ), 26167 lt( 26168 this.features_, 26169 $t.REMOVE, 26170 this.handleFeatureRemove_, 26171 this 26172 ) 26173 ) : this.source_ && s.push( 26174 lt( 26175 this.source_, 26176 le.ADDFEATURE, 26177 this.handleFeatureAdd_, 26178 this 26179 ), 26180 lt( 26181 this.source_, 26182 le.REMOVEFEATURE, 26183 this.handleFeatureRemove_, 26184 this 26185 ) 26186 ), n.forEach((r) => this.addFeature(r))); 26187 } 26188 /** 26189 * @param {import("../pixel.js").Pixel} pixel Pixel 26190 * @param {import("../coordinate.js").Coordinate} pixelCoordinate Coordinate 26191 * @param {import("../Map.js").default} map Map. 26192 * @return {Result|null} Snap result 26193 */ 26194 snapTo(t, i, s) { 26195 s.getView().getProjection(); 26196 const n = It(i), r = Zo( 26197 Es( 26198 ce([n]), 26199 s.getView().getResolution() * this.pixelTolerance_ 26200 ) 26201 ), o = this.rBush_.getInExtent(r), a = o.length; 26202 if (a === 0) 26203 return null; 26204 let l, h = 1 / 0; 26205 const c = this.pixelTolerance_ * this.pixelTolerance_, u = () => { 26206 if (l) { 26207 const d = s.getPixelFromCoordinate(l); 26208 if (gi(t, d) <= c) 26209 return { 26210 vertex: l, 26211 vertexPixel: [ 26212 Math.round(d[0]), 26213 Math.round(d[1]) 26214 ] 26215 }; 26216 } 26217 return null; 26218 }; 26219 if (this.vertex_) { 26220 for (let f = 0; f < a; ++f) { 26221 const g = o[f]; 26222 g.feature.getGeometry().getType() !== "Circle" && g.segment.forEach((_) => { 26223 const m = It(_), p = gi(n, m); 26224 p < h && (l = _, h = p); 26225 }); 26226 } 26227 const d = u(); 26228 if (d) 26229 return d; 26230 } 26231 if (this.edge_) { 26232 for (let f = 0; f < a; ++f) { 26233 let g = null; 26234 const _ = o[f]; 26235 if (_.feature.getGeometry().getType() === "Circle") { 26236 let m = _.feature.getGeometry(); 26237 g = Vy( 26238 n, 26239 /** @type {import("../geom/Circle.js").default} */ 26240 m 26241 ); 26242 } else { 26243 const [m, p] = _.segment; 26244 p && (Va[0] = It(m), Va[1] = It(p), g = $l(n, Va)); 26245 } 26246 if (g) { 26247 const m = gi(n, g);
26248 m < h && (l = Ms(g), h = m); 26249 } 26250 } 26251 const d = u(); 26252 if (d) 26253 return d; 26254 } 26255 return null; 26256 } 26257 /** 26258 * @param {import("../Feature.js").default} feature Feature 26259 * @private 26260 */ 26261 updateFeature_(t) { 26262 this.removeFeature(t, !1), this.addFeature(t, !1); 26263 } 26264 /** 26265 * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments 26266 * @param {import("../geom/Circle.js").default} geometry Geometry. 26267 * @private 26268 */ 26269 segmentCircleGeometry_(t, i) { 26270 this.getMap().getView().getProjection(); 26271 const r = BE(i).getCoordinates()[0]; 26272 for (let o = 0, a = r.length - 1; o < a; ++o) 26273 t.push(r.slice(o, o + 2)); 26274 } 26275 /** 26276 * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments 26277 * @param {import("../geom/GeometryCollection.js").default} geometry Geometry. 26278 * @private 26279 */ 26280 segmentGeometryCollectionGeometry_(t, i) { 26281 const s = i.getGeometriesArray(); 26282 for (let n = 0; n < s.length; ++n) { 26283 const r = this.GEOMETRY_SEGMENTERS_[s[n].getType()]; 26284 r && r(t, s[n]); 26285 } 26286 } 26287 /** 26288 * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments 26289 * @param {import("../geom/LineString.js").default} geometry Geometry. 26290 * @private 26291 */ 26292 segmentLineStringGeometry_(t, i) { 26293 const s = i.getCoordinates(); 26294 for (let n = 0, r = s.length - 1; n < r; ++n) 26295 t.push(s.slice(n, n + 2)); 26296 } 26297 /** 26298 * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments 26299 * @param {import("../geom/MultiLineString.js").default} geometry Geometry. 26300 * @private 26301 */ 26302 segmentMultiLineStringGeometry_(t, i) { 26303 const s = i.getCoordinates(); 26304 for (let n = 0, r = s.length; n < r; ++n) { 26305 const o = s[n]; 26306 for (let a = 0, l = o.length - 1; a < l; ++a) 26307 t.push(o.slice(a, a + 2)); 26308 } 26309 } 26310 /** 26311 * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments 26312 * @param {import("../geom/MultiPoint.js").default} geometry Geometry. 26313 * @private 26314 */ 26315 segmentMultiPointGeometry_(t, i) {
26316 i.getCoordinates().forEach((s) => { 26317 t.push([s]); 26318 }); 26319 } 26320 /** 26321 * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments 26322 * @param {import("../geom/MultiPolygon.js").default} geometry Geometry. 26323 * @private 26324 */ 26325 segmentMultiPolygonGeometry_(t, i) { 26326 const s = i.getCoordinates(); 26327 for (let n = 0, r = s.length; n < r; ++n) { 26328 const o = s[n]; 26329 for (let a = 0, l = o.length; a < l; ++a) { 26330 const h = o[a]; 26331 for (let c = 0, u = h.length - 1; c < u; ++c) 26332 t.push(h.slice(c, c + 2)); 26333 } 26334 } 26335 } 26336 /** 26337 * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments 26338 * @param {import("../geom/Point.js").default} geometry Geometry. 26339 * @private 26340 */ 26341 segmentPointGeometry_(t, i) { 26342 t.push([i.getCoordinates()]); 26343 } 26344 /** 26345 * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments 26346 * @param {import("../geom/Polygon.js").default} geometry Geometry. 26347 * @private 26348 */ 26349 segmentPolygonGeometry_(t, i) { 26350 const s = i.getCoordinates(); 26351 for (let n = 0, r = s.length; n < r; ++n) { 26352 const o = s[n]; 26353 for (let a = 0, l = o.length - 1; a < l; ++a) 26354 t.push(o.slice(a, a + 2)); 26355 } 26356 } 26357} 26358const Kb = Yb, ro = 100, Vb = { 26359 Point: "Point", 26360 LineString: "LineString", 26361 Polygon: "Polygon" 26362}; 26363function Ng(e) { 26364 return Array.isArray(e) ? Array.isArray(e[0]) ? e.map(Ng) : [Math.round(e[0] * ro) / ro, Math.round(e[1] * ro) / ro] : e; 26365} 26366function qb(e) { 26367 var n, r, o; 26368 const t = (n = e == null ? void 0 : e.getGeometry) == null ? void 0 : n.call(e), i = Vb[(r = t == null ? void 0 : t.getType) == null ? void 0 : r.call(t)]; 26369 if (!i) 26370 return null; 26371 const s = (o = t.getCoordinates) == null ? void 0 : o.call(t); 26372 return Array.isArray(s) ? { type: i, coordinates: Ng(s) } : null; 26373} 26374function Hb(e) { 26375 if (!e || !Array.isArray(e.coordinates)) 26376 return !1; 26377 const t = (i) => new Set(i.map((s) => `${s[0]},${s[1]}`)).size; 26378 switch (e.type) { 26379 case "Point": 26380 return e.coordinates.length === 2 && e.coordinates.every(Number.isFinite); 26381 case "LineString": 26382 return t(e.coordinates) >= 2; 26383 case "Polygon": 26384 return t(e.coordinates[0] || []) >= 3; 26385 default: 26386 return !1; 26387 } 26388} 26389function kg(e, t = 1) { 26390 const i = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(String(e ?? "").trim()); 26391 if (!i) 26392 return e; 26393 let s = i[1]; 26394 s.length === 3 && (s = s.split("").map((r) => r + r).join("")); 26395 const n = parseInt(s, 16); 26396 return `rgba(${n >> 16 & 255}, ${n >> 8 & 255}, ${n & 255}, ${t})`; 26397} 26398const Zb = `:root,:host{--ol-background-color: white;--ol-accent-background-color: #F5F5F5;--ol-subtle-background-color: rgba(128, 128, 128, .25);--ol-partial-background-color: rgba(255, 255, 255, .75);--ol-foreground-color: #333333;--ol-subtle-foreground-color: #666666;--ol-brand-color: #00AAFF}.ol-box{box-sizing:border-box;border-radius:2px;border:1.5px solid var(--ol-background-color);background-color:var(--ol-partial-background-color)}.ol-mouse-position{top:8px;right:8px;position:absolute}.ol-scale-line{background:var(--ol-partial-background-color);border-radius:4px;bottom:8px;left:8px;padding:2px;position:absolute}.ol-scale-line-inner{border:1px solid var(--ol-subtle-foreground-color);border-top:none;color:var(--ol-foreground-color);font-size:10px;text-align:center;margin:1px;will-change:contents,width;transition:all .25s}.ol-scale-bar{position:absolute;bottom:8px;left:8px}.ol-scale-bar-inner{display:flex}.ol-scale-step-marker{width:1px;height:15px;background-color:var(--ol-foreground-color);float:right;z-index:10}.ol-scale-step-text{position:absolute;bottom:-5px;font-size:10px;z-index:11;color:var(--ol-foreground-color);text-shadow:-1.5px 0 var(--ol-partial-background-color),0 1.5px var(--ol-partial-background-color),1.5px 0 var(--ol-partial-background-color),0 -1.5px var(--ol-partial-background-color)}.ol-scale-text{position:absolute;font-size:12px;text-align:center;bottom:25px;color:var(--ol-foreground-color);text-shadow:-1.5px 0 var(--ol-partial-background-color),0 1.5px var(--ol-partial-background-color),1.5px 0 var(--ol-partial-background-color),0 -1.5px var(--ol-partial-background-color)}.ol-scale-singlebar{position:relative;height:10px;z-index:9;box-sizing:border-box;border:1px solid var(--ol-foreground-color)}.ol-scale-singlebar-even{background-color:var(--ol-subtle-foreground-color)}.ol-scale-singlebar-odd{background-color:var(--ol-background-color)}
26398.ol-unsupported{display:none}.ol-viewport,.ol-unselectable{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.ol-viewport canvas{all:unset}.ol-selectable{-webkit-touch-callout:default;-webkit-user-select:text;-moz-user-select:text;user-select:text}.ol-grabbing{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.ol-grab{cursor:move;cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.ol-control{position:absolute;background-color:var(--ol-subtle-background-color);border-radius:4px}.ol-zoom{top:.5em;left:.5em}.ol-rotate{top:.5em;right:.5em;transition:opacity .25s linear,visibility 0s linear}.ol-rotate.ol-hidden{opacity:0;visibility:hidden;transition:opacity .25s linear,visibility 0s linear .25s}.ol-zoom-extent{top:4.643em;left:.5em}.ol-full-screen{right:.5em;top:.5em}.ol-control button{display:block;margin:1px;padding:0;color:var(--ol-subtle-foreground-color);font-weight:700;text-decoration:none;font-size:inherit;text-align:center;height:1.375em;width:1.375em;line-height:.4em;background-color:var(--ol-background-color);border:none;border-radius:2px}.ol-control button::-moz-focus-inner{border:none;padding:0}.ol-zoom-extent button{line-height:1.4em}.ol-compass{display:block;font-weight:400;will-change:transform}.ol-touch .ol-control button{font-size:1.5em}.ol-touch .ol-zoom-extent{top:5.5em}.ol-control button:hover,.ol-control button:focus{text-decoration:none;outline:1px solid var(--ol-subtle-foreground-color);color:var(--ol-foreground-color)}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px}.ol-attribution{text-align:right;bottom:.5em;right:.5em;max-width:calc(100% - 1.3em);display:flex;flex-flow:row-reverse;align-items:center}.ol-attribution a{color:var(--ol-subtle-foreground-color);text-decoration:none}.ol-attribution ul{margin:0;padding:1px .5em;color:var(--ol-foreground-color);text-shadow:0 0 2px var(--ol-background-color);font-size:12px}.ol-attribution li{display:inline;list-style:none}.ol-attribution li:not(:last-child):after{content:" "}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle}.ol-attribution button{flex-shrink:0}.ol-attribution.ol-collapsed ul{display:none}.ol-attribution:not(.ol-collapsed){background:var(--ol-partial-background-color)}.ol-attribution.ol-uncollapsible{bottom:0;right:0;border-radius:4px 0 0}.ol-attribution.ol-uncollapsible img{margin-top:-.2em;max-height:1.6em}.ol-attribution.ol-uncollapsible button{display:none}.ol-zoomslider{top:4.5em;left:.5em;height:200px}.ol-zoomslider button{position:relative;height:10px}.ol-touch .ol-zoomslider{top:5.5em}.ol-overviewmap{left:.5em;bottom:.5em}.ol-overviewmap.ol-uncollapsible{bottom:0;left:0;border-radius:0 4px 0 0}.ol-overviewmap .ol-overviewmap-map,.ol-overviewmap button{display:block}.ol-overviewmap .ol-overviewmap-map{border:1px solid var(--ol-subtle-foreground-color);height:150px;width:150px}.ol-overviewmap:not(.ol-collapsed) button{bottom:0;left:0;position:absolute}.ol-overviewmap.ol-collapsed .ol-overviewmap-map,.ol-overviewmap.ol-uncollapsible button{display:none}.ol-overviewmap:not(.ol-collapsed){background:var(--ol-subtle-background-color)}.ol-overviewmap-box{border:1.5px dotted var(--ol-subtle-foreground-color)}.ol-overviewmap .ol-overviewmap-box:hover{cursor:move}.ol-control{background-color:var(--xmap-primary);border:1px solid var(--xmap-secondary)}.ol-control button{background-color:var(--xmap-primary);margin:0;color:var(--xmap-secondary);font-size:1.2em;line-height:1.2em}.ol-control button:hover{background-color:var(--xmap-secondary);color:var(--xmap-primary);outline:none;cursor:pointer}.xmap-web-map-container{height:100%;width:100%;position:relative}.xmap-draw-hud{position:absolute;top:.5em;right:.5em;z-index:1;padding:2px}.xmap-draw-hud button{display:flex;align-items:center;justify-content:center;width:1.7em;height:1.7em;padding:0;line-height:1}.xmap-web-map-footer{align-self:flex-end}#xmap-map{height:100%;min-height:0} 26399`, Jb = { 26400 name: "XmapWebMap", 26401 inject: ["primaryColor", "secondaryColor"], 26402 emits: ["xmap-geometry-changed", "xmap-geometry-cleared"], 26403 props: { 26404 extent: { 26405 type: String, 26406 default: null 26407 }, 26408 width: { 26409 type: Number, 26410 default: "auto" 26411 }, 26412 height: { 26413 type: Number, 26414 default: "auto" 26415 }, 26416 x: { 26417 type: Number, 26418 default: 0 26419 }, 26420 y: { 26421 type: Number, 26422 default: 0 26423 }, 26424 z: { 26425 type: Number, 26426 default: 0 26427 }, 26428 // Interaction mode, not a layer: "point" | "line" | "polygon". 26429 // Per the object-vs-behaviour principle, draw is an attribute on the map. 26430 draw: { 26431 type: String, 26432 default: null 26433 } 26434 }, 26435 methods: { 26436 updateMaxWidth() {
26437 this.maxWidth = this.$parent.$refs.xmapMain.clientWidth; 26438 }, 26439 updateMaxHeight() { 26440 this.maxHeight = this.$parent.$refs.xmapMain.clientHeight; 26441 }, 26442 // Fit the view to an arbitrary extent, deferring until the map has a real 26443 // size (XMP-2228). Shared by the map's own `extent` and by child layers' 26444 // `fit` (XMP-2234). Returns true when applied now. 26445 fitToExtent(e, t = {}) { 26446 if (!this.map || !e) 26447 return !1; 26448 const i = this.map.getSize(); 26449 return !i || !i[0] || !i[1] ? (this.map.once("change:size", () => this.fitToExtent(e, t)), !1) : (this.map.getView().fit(e, { size: i, ...t }), !0); 26450 }, 26451 // Fit the view to `extent`. Returns true when applied. No-op without an 26452 // extent; deferred until the first non-zero size when the map is unsized. 26453 // Keeps its own guard so `_pendingFit` still means "one pending fit of the 26454 // map's own extent" and a deferred layer fit cannot cancel it. 26455 fitExtent() { 26456 if (!this.map || !this.extent) 26457 return !1; 26458 const e = this.map.getSize(); 26459 return !e || !e[0] || !e[1] ? (this._pendingFit || (this._pendingFit = !0, this.map.once("change:size", () => { 26460 this._pendingFit = !1, this.fitExtent(); 26461 })), !1) : this.fitToExtent(this.formattedExtent); 26462 }, 26463 // ---- Draw / Report It --------------------------------------------------- 26464 setupDraw() { 26465 if (!this.map || !this.drawType) 26466 return; 26467 this.teardownDraw(); 26468 const e = this.primaryColor || "#263746"; 26469 this._drawSource = new ya(), this._drawLayer = new pa({ 26470 source: this._drawSource, 26471 zIndex: 100, 26472 // One style covers all three geometry types: `stroke` draws the line and 26473 // the polygon outline, `fill` gives the polygon body (which also makes it 26474 // grabbable by its interior, not just its edges), and `image` keeps point 26475 // rendering plus vertex visibility for Modify. A style carrying only 26476 // `image` renders lines and polygons as nothing at all. 26477 style: new _r({ 26478 stroke: new xi({ color: e, width: 3 }), 26479 fill: new Ei({ color: kg(e, 0.2) }), 26480 image: new Lr({ 26481 radius: 7, 26482 fill: new Ei({ color: e }), 26483 stroke: new xi({ color: "#fff", width: 2 }) 26484 }) 26485 }) 26486 }), this.map.addLayer(this._drawLayer), this.drawType !== "Point" && (this._dblClickZoom = this.map.getInteractions().getArray().find((t) => t instanceof rg) || null, this._dblClickZoom && this._dblClickZoom.setActive(!1)), this._draw = new $b({ source: this._drawSource, type: this.drawType }), this._modify = new Db({ source: this._drawSource }), this._snap = new Kb({ source: this._drawSource }), this.map.addInteraction(this._draw), this.map.addInteraction(this._modify), this.map.addInteraction(this._snap), this._draw.on("drawend", (t) => { 26487 this._draw.setActive(!1), this.captureGeometry(t.feature); 26488 }), this._modify.on("modifyend", (t) => this.captureGeometry(t.features.item(0))); 26489 }, 26490 // Remove the drawn geometry and re-enable drawing a new one (e.g. after submit). 26491 clearMapPoint() { 26492 this._drawSource && this._drawSource.clear(), this._draw && this._draw.setActive(!0), qu(); 26493 }, 26494 // Public counterpart to clearMapPoint(): removes the geometry AND tells the host. 26495 // Used by the Clear control and exposed on the custom element as clearGeometry(). 26496 // Only announces when there was something to clear, so (a) a first draw that is 26497 // immediately degenerate stays silent, and (b) the post-submit reset â where 26498 // requestReportReset() has already emptied the bus â does not fire a spurious 26499 // event on top of xmap-report-submitted. 26500 clearGeometry() { 26501 const e = ne.hasPoint; 26502 this.clearMapPoint(), e && this.emitHost("xmap-geometry-cleared", {}); 26503 }, 26504 teardownDraw() { 26505 this._draw && this.map && this.map.removeInteraction(this._draw), this._draw = null, this._modify && this.map && this.map.removeInteraction(this._modify), this._modify = null, this._snap && this.map && this.map.removeInteraction(this._snap), this._snap = null, this._drawLayer && this.map && this.map.removeLayer(this._drawLayer), this._drawLayer = null, this._drawSource = null, this._dblClickZoom && this._dblClickZoom.setActive(!0), this._dblClickZoom = null, qu(); 26506 }, 26507 // Capture whatever was drawn (Point | LineString | Polygon) as GeoJSON in 26508 // EPSG:27700 â the map's native projection, so no reprojection. 26509 captureGeometry(e) { 26510 const t = qb(e);
26511 if (!Hb(t)) { 26512 this.clearGeometry(); 26513 return; 26514 } 26515 Nb(t), this.emitHost("xmap-geometry-changed", { 26516 geometry: t, 26517 type: t.type, 26518 coordinates: t.coordinates, 26519 // Kept for the common point case so a listener reads coordinates directly. 26520 ...t.type === "Point" ? { easting: t.coordinates[0], northing: t.coordinates[1] } : {} 26521 }); 26522 }, 26523 // Dispatch on the custom-element host so the event reaches the host page 26524 // (composed:true to cross the shadow boundary). 26525 emitHost(e, t) { 26526 var s, n, r; 26527 const i = ((r = (n = (s = this.$el) == null ? void 0 : s.getRootNode) == null ? void 0 : n.call(s)) == null ? void 0 : r.host) || this.$el; 26528 i == null || i.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 })); 26529 } 26530 }, 26531 computed: { 26532 drawType() { 26533 return this.draw && { point: "Point", line: "LineString", polygon: "Polygon" }[String(this.draw).toLowerCase()] || null; 26534 }, 26535 // Drives the Clear control. Reads the bus rather than the vector source so it 26536 // stays reactive â an OL source is markRaw'd and its mutations are invisible to Vue. 26537 hasGeometry() { 26538 return ne.hasPoint; 26539 }, 26540 busResetSeq() { 26541 return ne.resetSeq; 26542 }, 26543 mapX: { 26544 get() { 26545 return this.x; 26546 }, 26547 set(e) { 26548 this.$emit("update:x", e); 26549 } 26550 }, 26551 formattedExtent() { 26552 return this.extent && Array.isArray(this.extent) ? this.extent : this.extent ? this.extent.split(",").map((e) => Number(e)) : [Number(this.mapX), Number(this.y), Number(this.mapX), Number(this.y)]; 26553 } 26554 }, 26555 data: () => ({ 26556 map: null, 26557 maxWidth: 0, 26558 maxHeight: 0 26559 }), 26560 mounted() { 26561 this.$nextTick(() => { 26562 var t, i, s; 26563 this.updateMaxWidth(), this.updateMaxHeight(), this.map.setTarget(this.$refs.map), window.XMAP_MAP = this.map, this.draw && this.setupDraw(); 26564 const e = (s = (i = (t = this.$el) == null ? void 0 : t.getRootNode) == null ? void 0 : i.call(t)) == null ? void 0 : s.host; 26565 e && (e.clearGeometry = () => this.clearGeometry()), this.$nextTick(() => this.fitExtent()); 26566 }), window.addEventListener("resize", (e) => { 26567 this.updateMaxWidth(), this.updateMaxHeight(), this.map.updateSize(); 26568 }); 26569 }, 26570 watch: { 26571 // Re-fit when the host changes the attribute after mount. 26572 extent() { 26573 this.fitExtent(); 26574 }, 26575 // Toggle draw mode reactively when the attribute is set/changed/removed. 26576 draw() { 26577 var t, i, s; 26578 if (!this.map) 26579 return; 26580 this.teardownDraw(), this.draw && this.setupDraw(); 26581 const e = (s = (i = (t = this.$el) == null ? void 0 : t.getRootNode) == null ? void 0 : i.call(t)) == null ? void 0 : s.host; 26582 e && (e.clearGeometry = () => this.clearGeometry()); 26583 }, 26584 // The form requests a reset after a successful submit -> clear the point. 26585 // Drives the Clear control. Reads the bus rather than the vector source so it 26586 // stays reactive â an OL source is markRaw'd and its mutations are invisible to Vue. 26587 hasGeometry() { 26588 return ne.hasPoint; 26589 }, 26590 busResetSeq() { 26591 this.clearMapPoint(); 26592 } 26593 }, 26594 beforeUnmount() { 26595 this.teardownDraw(); 26596 }, 26597 created() { 26598 let e = ii(this.formattedExtent); 26599 this.map = _n(new aC({ 26600 view: new Ve({ 26601 projection: "EPSG:27700", 26602 center: e, 26603 zoom: this.z || 0, 26604 constrainResolution: !1 26605 }) 26606 })), this.map.on("moveend", (t) => { 26607 let i = t.map.getView().getCenter(); 26608 this.mapX = i[0], i[1], t.map.getView().getZoom(); 26609 }); 26610 } 26611}, Qb = { 26612 ref: "map", 26613 id: "xmap-map" 26614}, tS = { 26615 key: 0, 26616 class: "ol-control xmap-draw-hud" 26617}, eS = /* @__PURE__ */ kt("svg", { 26618 viewBox: "0 0 24 24", 26619 width: "1em", 26620 height: "1em", 26621 fill: "none", 26622 stroke: "currentColor", 26623 "stroke-width": "2", 26624 "stroke-linecap": "round", 26625 "stroke-linejoin": "round", 26626 "aria-hidden": "true", 26627 focusable: "false" 26628}, [ 26629 /* @__PURE__ */ kt("path", { d: "M3 6h18" }), 26630 /* @__PURE__ */ kt("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }),
26631 /* @__PURE__ */ kt("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }), 26632 /* @__PURE__ */ kt("path", { d: "M10 11v6" }), 26633 /* @__PURE__ */ kt("path", { d: "M14 11v6" }) 26634], -1), iS = [ 26635 eS 26636]; 26637function sS(e, t, i, s, n, r) { 26638 return Tt(), Pt("div", { 26639 class: "xmap-web-map xmap-web-map-container", 26640 style: Rr({ 26641 width: `${e.maxWidth}px`, 26642 height: `${e.maxHeight}px`, 26643 "--xmap-primary": r.primaryColor || "#263746", 26644 "--xmap-secondary": r.secondaryColor || "#a1d0ca" 26645 }) 26646 }, [ 26647 kt("div", Qb, null, 512), 26648 r.drawType && r.hasGeometry ? (Tt(), Pt("div", tS, [ 26649 kt("button", { 26650 type: "button", 26651 onClick: t[0] || (t[0] = (o) => r.clearGeometry()), 26652 "aria-label": "Clear drawing", 26653 title: "Clear drawing" 26654 }, iS) 26655 ])) : _s("", !0) 26656 ], 4); 26657} 26658const nS = /* @__PURE__ */ la(Jb, [["render", sS], ["styles", [Zb]]]), Gg = 0.5, rS = 10, Ju = 0.25; 26659class oS { 26660 /** 26661 * @param {import("../proj/Projection.js").default} sourceProj Source projection. 26662 * @param {import("../proj/Projection.js").default} targetProj Target projection. 26663 * @param {import("../extent.js").Extent} targetExtent Target extent to triangulate. 26664 * @param {import("../extent.js").Extent} maxSourceExtent Maximal source extent that can be used. 26665 * @param {number} errorThreshold Acceptable error (in source units). 26666 * @param {?number} destinationResolution The (optional) resolution of the destination. 26667 */ 26668 constructor(t, i, s, n, r, o) { 26669 this.sourceProj_ = t, this.targetProj_ = i; 26670 let a = {}; 26671 const l = ir(this.targetProj_, this.sourceProj_); 26672 this.transformInv_ = function(y) { 26673 const v = y[0] + "/" + y[1]; 26674 return a[v] || (a[v] = l(y)), a[v]; 26675 }, this.maxSourceExtent_ = n, this.errorThresholdSquared_ = r * r, this.triangles_ = [], this.wrapsXInSource_ = !1, this.canWrapXInSource_ = this.sourceProj_.canWrapX() && !!n && !!this.sourceProj_.getExtent() && mt(n) >= mt(this.sourceProj_.getExtent()), this.sourceWorldWidth_ = this.sourceProj_.getExtent() ? mt(this.sourceProj_.getExtent()) : null, this.targetWorldWidth_ = this.targetProj_.getExtent() ? mt(this.targetProj_.getExtent()) : null; 26676 const h = ws(s), c = Ho(s), u = qo(s), d = Vo(s), f = this.transformInv_(h), g = this.transformInv_(c), _ = this.transformInv_(u), m = this.transformInv_(d), p = rS + (o ? Math.max( 26677 0, 26678 Math.ceil( 26679 Math.log2( 26680 rl(s) / (o * o * 256 * 256) 26681 ) 26682 ) 26683 ) : 0); 26684 if (this.addQuad_( 26685 h, 26686 c, 26687 u, 26688 d, 26689 f, 26690 g, 26691 _, 26692 m, 26693 p 26694 ), this.wrapsXInSource_) { 26695 let y = 1 / 0; 26696 this.triangles_.forEach(function(v, E, C) { 26697 y = Math.min( 26698 y, 26699 v.source[0][0], 26700 v.source[1][0], 26701 v.source[2][0] 26702 ); 26703 }), this.triangles_.forEach((v) => { 26704 if (Math.max( 26705 v.source[0][0], 26706 v.source[1][0], 26707 v.source[2][0] 26708 ) - y > this.sourceWorldWidth_ / 2) { 26709 const E = [ 26710 [v.source[0][0], v.source[0][1]], 26711 [v.source[1][0], v.source[1][1]], 26712 [v.source[2][0], v.source[2][1]] 26713 ]; 26714 E[0][0] - y > this.sourceWorldWidth_ / 2 && (E[0][0] -= this.sourceWorldWidth_), E[1][0] - y > this.sourceWorldWidth_ / 2 && (E[1][0] -= this.sourceWorldWidth_), E[2][0] - y > this.sourceWorldWidth_ / 2 && (E[2][0] -= this.sourceWorldWidth_); 26715 const C = Math.min( 26716 E[0][0], 26717 E[1][0], 26718 E[2][0] 26719 ); 26720 Math.max( 26721 E[0][0], 26722 E[1][0], 26723 E[2][0] 26724 ) - C < this.sourceWorldWidth_ / 2 && (v.source = E); 26725 } 26726 }); 26727 } 26728 a = {}; 26729 } 26730 /** 26731 * Adds triangle to the triangulation. 26732 * @param {import("../coordinate.js").Coordinate} a The target a coordinate. 26733 * @param {import("../coordinate.js").Coordinate} b The target b coordinate. 26734 * @param {import("../coordinate.js").Coordinate} c The target c coordinate. 26735 * @param {import("../coordinate.js").Coordinate} aSrc The source a coordinate. 26736 * @param {import("../coordinate.js").Coordinate} bSrc The source b coordinate. 26737 * @param {import("../coordinate.js").Coordinate} cSrc The source c coordinate. 26738 * @private 26739 */ 26740 addTriangle_(t, i, s, n, r, o) { 26741 this.triangles_.push({ 26742 source: [n, r, o], 26743 target: [t, i, s] 26744 }); 26745 } 26746 /** 26747 * Adds quad (points in clock-wise order) to the triangulation 26748 * (and reprojects the vertices) if valid. 26749 * Performs quad subdivision if needed to increase precision. 26750 * 26751 * @param {import("../coordinate.js").Coordinate} a The target a coordinate. 26752 * @param {import("../coordinate.js").Coordinate} b The target b coordinate. 26753 * @param {import("../coordinate.js").Coordinate} c The target c coordinate. 26754 * @param {import("../coordinate.js").Coordinate} d The target d coordinate. 26755 * @param {import("../coordinate.js").Coordinate} aSrc The source a coordinate. 26756 * @param {import("../coordinate.js").Coordinate} bSrc The source b coordinate. 26757 * @param {import("../coordinate.js").Coordinate} cSrc The source c coordinate. 26758 * @param {import("../coordinate.js").Coordinate} dSrc The source d coordinate. 26759 * @param {number} maxSubdivision Maximal allowed subdivision of the quad. 26760 * @private 26761 */ 26762 addQuad_(t, i, s, n, r, o, a, l, h) { 26763 const c = ce([r, o, a, l]), u = this.sourceWorldWidth_ ? mt(c) / this.sourceWorldWidth_ : null, d = ( 26764 /** @type {number} */ 26765 this.sourceWorldWidth_ 26766 ), f = this.sourceProj_.canWrapX() && u > 0.5 && u < 1; 26767 let g = !1; 26768 if (h > 0) { 26769 if (this.targetProj_.isGlobal() && this.targetWorldWidth_) { 26770 const m = ce([t, i, s, n]); 26771 g = mt(m) / this.targetWorldWidth_ > Ju || g; 26772 } 26773 !f && this.sourceProj_.isGlobal() && u && (g = u > Ju || g); 26774 } 26775 if (!g && this.maxSourceExtent_ && isFinite(c[0]) && isFinite(c[1]) && isFinite(c[2]) && isFinite(c[3]) && !ee(c, this.maxSourceExtent_)) 26776 return; 26777 let _ = 0; 26778 if (!g && (!isFinite(r[0]) || !isFinite(r[1]) || !isFinite(o[0]) || !isFinite(o[1]) || !isFinite(a[0]) || !isFinite(a[1]) || !isFinite(l[0]) || !isFinite(l[1]))) { 26779 if (h > 0) 26780 g = !0; 26781 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) 26782 return; 26783 } 26784 if (h > 0) { 26785 if (!g) { 26786 const m = [(t[0] + s[0]) / 2, (t[1] + s[1]) / 2], p = this.transformInv_(m); 26787 let y; 26788 f ? y = ($i(r[0], d) + $i(a[0], d)) / 2 - $i(p[0], d) : y = (r[0] + a[0]) / 2 - p[0]; 26789 const v = (r[1] + a[1]) / 2 - p[1]; 26790 g = y * y + v * v > this.errorThresholdSquared_; 26791 } 26792 if (g) { 26793 if (Math.abs(t[0] - s[0]) <= Math.abs(t[1] - s[1])) { 26794 const m = [(i[0] + s[0]) / 2, (i[1] + s[1]) / 2], p = this.transformInv_(m), y = [(n[0] + t[0]) / 2, (n[1] + t[1]) / 2], v = this.transformInv_(y); 26795 this.addQuad_( 26796 t, 26797 i, 26798 m, 26799 y, 26800 r, 26801 o, 26802 p, 26803 v, 26804 h - 1 26805 ), this.addQuad_( 26806 y, 26807 m, 26808 s, 26809 n, 26810 v, 26811 p, 26812 a, 26813 l, 26814 h - 1 26815 ); 26816 } else { 26817 const m = [(t[0] + i[0]) / 2, (t[1] + i[1]) / 2], p = this.transformInv_(m), y = [(s[0] + n[0]) / 2, (s[1] + n[1]) / 2], v = this.transformInv_(y); 26818 this.addQuad_( 26819 t, 26820 m, 26821 y, 26822 n, 26823 r, 26824 p, 26825 v, 26826 l, 26827 h - 1 26828 ), this.addQuad_( 26829 m, 26830 i, 26831 s, 26832 y, 26833 p, 26834 o, 26835 a, 26836 v, 26837 h - 1 26838 ); 26839 } 26840 return; 26841 } 26842 } 26843 if (f) { 26844 if (!this.canWrapXInSource_) 26845 return; 26846 this.wrapsXInSource_ = !0; 26847 } 26848 _ & 11 || this.addTriangle_(t, s, n, r, a, l), _ & 14 || this.addTriangle_(t, s, i, r, a, o), _ && (_ & 13 || this.addTriangle_(i, n, t, o, l, r), _ & 7 || this.addTriangle_(i, n, s, o, l, a)); 26849 } 26850 /** 26851 * Calculates extent of the `source` coordinates from all the triangles. 26852 * 26853 * @return {import("../extent.js").Extent} Calculated extent. 26854 */ 26855 calculateSourceExtent() { 26856 const t = ve(); 26857 return this.triangles_.forEach(function(i, s, n) { 26858 const r = i.source; 26859 Yn(t, r[0]), Yn(t, r[1]), Yn(t, r[2]); 26860 }), t; 26861 } 26862 /** 26863 * @return {Array<Triangle>} Array of the calculated triangles. 26864 */ 26865 getTriangles() { 26866 return this.triangles_; 26867 } 26868} 26869const zg = oS; 26870let qa; 26871const ln = []; 26872function Qu(e, t, i, s, n) { 26873 e.beginPath(), e.moveTo(0, 0), e.lineTo(t, i), e.lineTo(s, n), e.closePath(), e.save(), e.clip(), e.fillRect(0, 0, Math.max(t, s) + 1, Math.max(i, n)), e.restore(
26873); 26874} 26875function Ha(e, t) { 26876 return Math.abs(e[t * 4] - 210) > 2 || Math.abs(e[t * 4 + 3] - 0.75 * 255) > 2; 26877} 26878function aS() { 26879 if (qa === void 0) { 26880 const e = re(6, 6, ln); 26881 e.globalCompositeOperation = "lighter", e.fillStyle = "rgba(210, 0, 0, 0.75)", Qu(e, 4, 5, 4, 0), Qu(e, 4, 5, 0, 5); 26882 const t = e.getImageData(0, 0, 3, 3).data; 26883 qa = Ha(t, 0) || Ha(t, 4) || Ha(t, 8), _a(e), ln.push(e.canvas); 26884 } 26885 return qa; 26886} 26887function yr(e, t, i, s) { 26888 const n = Hl(i, t, e); 26889 let r = Ic( 26890 t, 26891 s, 26892 i 26893 ); 26894 const o = t.getMetersPerUnit(); 26895 o !== void 0 && (r *= o); 26896 const a = e.getMetersPerUnit(); 26897 a !== void 0 && (r /= a); 26898 const l = e.getExtent(); 26899 if (!l || wr(l, n)) { 26900 const h = Ic(e, r, n) / r; 26901 isFinite(h) && h > 0 && (r /= h); 26902 } 26903 return r; 26904} 26905function lS(e, t, i, s) { 26906 const n = ii(i); 26907 let r = yr( 26908 e, 26909 t, 26910 n, 26911 s 26912 ); 26913 return (!isFinite(r) || r <= 0) && Xl(i, function(o) { 26914 return r = yr( 26915 e, 26916 t, 26917 o, 26918 s 26919 ), isFinite(r) && r > 0; 26920 }), r; 26921} 26922function jg(e, t, i, s, n, r, o, a, l, h, c, u) { 26923 const d = re( 26924 Math.round(i * e), 26925 Math.round(i * t), 26926 ln 26927 ); 26928 if (u || (d.imageSmoothingEnabled = !1), l.length === 0) 26929 return d.canvas; 26930 d.scale(i, i); 26931 function f(E) { 26932 return Math.round(E * i) / i; 26933 } 26934 d.globalCompositeOperation = "lighter"; 26935 const g = ve(); 26936 l.forEach(function(E, C, S) { 26937 Pd(g, E.extent); 26938 }); 26939 const _ = mt(g), m = Yt(g), p = re( 26940 Math.round(i * _ / s), 26941 Math.round(i * m / s), 26942 ln 26943 ); 26944 u || (p.imageSmoothingEnabled = !1); 26945 const y = i / s; 26946 l.forEach(function(E, C, S) { 26947 const O = E.extent[0] - g[0], R = -(E.extent[3] - g[3]), j = mt(E.extent), $ = Yt(E.extent); 26948 E.image.width > 0 && E.image.height > 0 && p.drawImage( 26949 E.image, 26950 h, 26951 h, 26952 E.image.width - 2 * h, 26953 E.image.height - 2 * h, 26954 O * y, 26955 R * y, 26956 j * y, 26957 $ * y 26958 ); 26959 }); 26960 const v = ws(o);
26961 return a.getTriangles().forEach(function(E, C, S) { 26962 const O = E.source, R = E.target; 26963 let j = O[0][0], $ = O[0][1], q = O[1][0], tt = O[1][1], J = O[2][0], St = O[2][1]; 26964 const K = f((R[0][0] - v[0]) / r), Y = f( 26965 -(R[0][1] - v[1]) / r 26966 ), L = f((R[1][0] - v[0]) / r), W = f( 26967 -(R[1][1] - v[1]) / r 26968 ), ut = f((R[2][0] - v[0]) / r), ft = f( 26969 -(R[2][1] - v[1]) / r 26970 ), wt = j, I = $; 26971 j = 0, $ = 0, q -= wt, tt -= I, J -= wt, St -= I; 26972 const qt = [ 26973 [q, tt, 0, 0, L - K], 26974 [J, St, 0, 0, ut - K], 26975 [0, 0, q, tt, W - Y], 26976 [0, 0, J, St, ft - Y] 26977 ], pt = Yy(qt); 26978 if (pt) { 26979 if (d.save(), d.beginPath(), aS() || !u) { 26980 d.moveTo(L, W); 26981 const vt = 4, Bt = K - L, oe = Y - W; 26982 for (let Gt = 0; Gt < vt; Gt++) 26983 d.lineTo( 26984 L + f((Gt + 1) * Bt / vt), 26985 W + f(Gt * oe / (vt - 1)) 26986 ), Gt != vt - 1 && d.lineTo( 26987 L + f((Gt + 1) * Bt / vt), 26988 W + f((Gt + 1) * oe / (vt - 1)) 26989 ); 26990 d.lineTo(ut, ft); 26991 } else 26992 d.moveTo(L, W), d.lineTo(K, Y), d.lineTo(ut, ft); 26993 d.clip(), d.transform( 26994 pt[0], 26995 pt[2], 26996 pt[1], 26997 pt[3], 26998 K, 26999 Y 27000 ), d.translate( 27001 g[0] - wt, 27002 g[3] - I 27003 ), d.scale( 27004 s / i, 27005 -s / i 27006 ), d.drawImage(p.canvas, 0, 0), d.restore(); 27007 } 27008 }), _a(p), ln.push(p.canvas), c && (d.save(), d.globalCompositeOperation = "source-over", d.strokeStyle = "black", d.lineWidth = 1, a.getTriangles().forEac
27008h(function(E, C, S) { 27009 const O = E.target, R = (O[0][0] - v[0]) / r, j = -(O[0][1] - v[1]) / r, $ = (O[1][0] - v[0]) / r, q = -(O[1][1] - v[1]) / r, tt = (O[2][0] - v[0]) / r, J = -(O[2][1] - v[1]) / r; 27010 d.beginPath(), d.moveTo($, q), d.lineTo(R, j), d.lineTo(tt, J), d.closePath(), d.stroke(); 27011 }), d.restore()), d.canvas; 27012} 27013class hS extends Eg { 27014 /** 27015 * @param {import("../proj/Projection.js").default} sourceProj Source projection (of the data). 27016 * @param {import("../proj/Projection.js").default} targetProj Target projection. 27017 * @param {import("../extent.js").Extent} targetExtent Target extent. 27018 * @param {number} targetResolution Target resolution. 27019 * @param {number} pixelRatio Pixel ratio. 27020 * @param {FunctionType} getImageFunction 27021 * Function returning source images (extent, resolution, pixelRatio). 27022 * @param {boolean} interpolate Use linear interpolation when resampling. 27023 */ 27024 constructor(t, i, s, n, r, o, a) { 27025 let l = t.getExtent(); 27026 l && t.canWrapX() && (l = l.slice(), l[0] = -1 / 0, l[2] = 1 / 0); 27027 let h = i.getExtent(); 27028 h && i.canWrapX() && (h = h.slice(), h[0] = -1 / 0, h[2] = 1 / 0); 27029 const c = h ? fs(s, h) : s, u = ii(c), d = yr( 27030 t, 27031 i, 27032 u, 27033 n 27034 ), f = Gg, g = new zg( 27035 t, 27036 i, 27037 c, 27038 l, 27039 d * f, 27040 n 27041 ), _ = g.calculateSourceExtent(), m = Ts(_) ? null : o(_, d, r), p = m ? rt.IDLE : rt.EMPTY, y = m ? m.getPixelRatio() : 1; 27042 super(s, n, y, p), this.targetProj_ = i, this.maxSourceExtent_ = l, this.triangulation_ = g, this.targetResolution_ = n, this.targetExtent_ = s, this.sourceImage_ = m, this.sourcePixelRatio_ = y, this.interpolate_ = a, this.canvas_ = null, this.sourceListenerKey_ = null; 27043 } 27044 /** 27045 * Clean up. 27046 */ 27047 disposeInternal() { 27048 this.state == rt.LOADING && this.unlistenSource_(), super.disposeInternal(); 27049 } 27050 /** 27051 * @return {HTMLCanvasElement} Image. 27052 */ 27053 getImage() { 27054 return this.canvas_; 27055 } 27056 /** 27057 * @return {import("../proj/Projection.js").default} Projection. 27058 */ 27059 getProjection() { 27060 return this.targetProj_; 27061 } 27062 /** 27063 * @private 27064 */ 27065 reproject_() { 27066 const t = this.sourceImage_.getState(); 27067 if (t == rt.LOADED) { 27068 const i = mt(this.targetExtent_) / this.targetResolution_, s = Yt(this.targetExtent_) / this.targetResolution_; 27069 this.canvas_ = jg( 27070 i, 27071 s, 27072 this.sourcePixelRatio_, 27073 this.sourceImage_.getResolution(), 27074 this.maxSourceExtent_, 27075 this.targetResolution_, 27076 this.targetExtent_, 27077 this.triangulation_, 27078 [ 27079 { 27080 extent: this.sourceImage_.getExtent(), 27081 image: this.sourceImage_.getImage() 27082 } 27083 ], 27084 0, 27085 void 0, 27086 this.interpolate_ 27087 ); 27088 } 27089 this.state = t, this.changed(); 27090 } 27091 /** 27092 * Load not yet loaded URI. 27093 */ 27094 load() { 27095 if (this.state == rt.IDLE) { 27096 this.state = rt.LOADING, this.changed(); 27097 const t = this.sourceImage_.getState(); 27098 t == rt.LOADED || t == rt.ERROR ? this.reproject_() : (this.sourceListenerKey_ = lt( 27099 this.sourceImage_, 27100 et.CHANGE, 27101 function(i) { 27102 const s = this.sourceImage_.getState(); 27103 (s == rt.LOADED || s == rt.ERROR) && (this.unlistenSource_(), this.reproject_()); 27104 }, 27105 this 27106 ), this.sourceImage_.load()); 27107 } 27108 } 27109 /** 27110 * @private 27111 */ 27112 unlistenSource_() { 27113 Mt( 27114 /** @type {!import("../events.js").EventsKey} */ 27115 this.sourceListenerKey_ 27116 ), this.sourceListenerKey_ = null; 27117 } 27118} 27119const cS = hS, Za = { 27120 /** 27121 * Triggered when an image starts loading. 27122 * @event module:ol/source/Image.ImageSourceEvent#imageloadstart 27123 * @api 27124 */ 27125 IMAGELOADSTART: "imageloadstart", 27126 /** 27127 * Triggered when an image finishes loading. 27128 * @event module:ol/source/Image.ImageSourceEvent#imageloadend 27129 * @api 27130 */ 27131 IMAGELOADEND: "imageloadend", 27132 /** 27133 * Triggered if image loading results in an error. 27134 * @event module:ol/source/Image.ImageSourceEvent#imageloaderror 27135 * @api 27136 */ 27137 IMAGELOADERROR: "imageloaderror" 27138}; 27139class uS extends Ae { 27140 /** 27141 * @param {string} type Type. 27142 * @param {import("../Image.js").default} image The image. 27143 */ 27144 constructor(t, i) { 27145 super(t), this.image = i; 27146 } 27147} 27148class dS extends Zh { 27149 /** 27150 * @param {Options} options Single image source options. 27151 */ 27152 constructor(t) { 27153 super({ 27154 attributions: t.attributions, 27155 projection: t.projection, 27156 state: t.state, 27157 interpolate: t.interpolate !== void 0 ? t.interpolate : !0 27158 }), this.on, this.once, this.un, this.resolutions_ = t.resolutions !== void 0 ? t.resolutions : null, this.reprojectedImage_ = null, this.reprojectedRevision_ = 0; 27159 } 27160 /** 27161 * @return {Array<number>|null} Resolutions. 27162 */ 27163 getResolutions() { 27164 return this.resolutions_; 27165 } 27166 /** 27167 * @param {Array<number>|null} resolutions Resolutions. 27168 */ 27169 setResolutions(t) { 27170 this.resolutions_ = t; 27171 } 27172 /** 27173 * @protected 27174 * @param {number} resolution Resolution. 27175 * @return {number} Resolution. 27176 */ 27177 findNearestResolution(t) { 27178 const i = this.getResolutions(); 27179 if (i) { 27180 const s = ha(i, t, 0); 27181 t = i[s]; 27182 } 27183 return t; 27184 } 27185 /** 27186 * @param {import("../extent.js").Extent} extent Extent. 27187 * @param {number} resolution Resolution. 27188 * @param {number} pixelRatio Pixel ratio. 27189 * @param {import("../proj/Projection.js").default} projection Projection. 27190 * @return {import("../ImageBase.js").default} Single image. 27191 */ 27192 getImage(t, i, s, n) { 27193 const r = this.getProjection(); 27194 if (!r || !n || di(r, n)) 27195 return r && (n = r), this.getImageInternal(t, i, s, n); 27196 if (this.reprojectedImage_) { 27197 if (this.reprojectedRevision_ == this.getRevision() && di(this.reprojectedImage_.getProjection(), n) && this.reprojectedImage_.getResolution() == i && fn(this.reprojectedImage_.getExtent(), t)) 27198 return this.reprojectedImage_; 27199 this.reprojectedImage_.dispose(), this.reprojectedImage_ = null; 27200 } 27201 return this.reprojectedImage_ = new cS( 27202 r, 27203 n, 27204 t, 27205 i, 27206 s, 27207 (o, a, l) => this.getImageInternal(o, a, l, r), 27208 this.getInterpolate() 27209 ), this.reprojectedRevision_ = this.getRevision(), this.reprojectedImage_; 27210 } 27211 /** 27212 * @abstract 27213 * @param {import("../extent.js").Extent} extent Extent. 27214 * @param {number} resolution Resolution. 27215 * @param {number} pixelRatio Pixel ratio. 27216 * @param {import("../proj/Projection.js").default} projection Projection. 27217 * @return {import("../ImageBase.js").default} Single image. 27218 * @protected 27219 */ 27220 getImageInternal(t, i, s, n) { 27221 return Z(); 27222 } 27223 /** 27224 * Handle image change events. 27225 * @param {import("../events/Event.js").default} event Event. 27226 * @protected 27227 */ 27228 handleImageChange(t) { 27229 const i = ( 27230 /** @type {import("../Image.js").default} */ 27231 t.target 27232 ); 27233 let s; 27234 switch (i.getState()) { 27235 case rt.LOADING: 27236 this.loading = !0, s = Za.IMAGELOADSTART; 27237 break; 27238 case rt.LOADED: 27239 this.loading = !1, s = Za.IMAGELOADEND; 27240 break; 27241 case rt.ERROR: 27242 this.loading = !1, s = Za.IMAGELOADERROR; 27243 break; 27244 default: 27245 return; 27246 } 27247 this.hasListener(s) && this.dispatchEvent(new uS(s, i)); 27248 } 27249} 27250function fS(e, t) { 27251 e.getImage().src = t; 27252}
27253const gS = dS, Ui = "1.3.0"; 27254function $o(e, t) { 27255 const i = []; 27256 Object.keys(t).forEach(function(n) { 27257 t[n] !== null && t[n] !== void 0 && i.push(n + "=" + encodeURIComponent(t[n])); 27258 }); 27259 const s = i.join("&"); 27260 return e = e.replace(/[?&]$/, ""), e += e.includes("?") ? "&" : "?", e + s; 27261} 27262const Pi = 4, td = [101, 101]; 27263class _S extends gS { 27264 /** 27265 * @param {Options} [options] ImageWMS options. 27266 */ 27267 constructor(t) { 27268 t = t || {}, super({ 27269 attributions: t.attributions, 27270 interpolate: t.interpolate, 27271 projection: t.projection, 27272 resolutions: t.resolutions 27273 }), this.context_ = re(1, 1), this.crossOrigin_ = t.crossOrigin !== void 0 ? t.crossOrigin : null, this.url_ = t.url, this.imageLoadFunction_ = t.imageLoadFunction !== void 0 ? t.imageLoadFunction : fS, this.params_ = Object.assign({}, t.params), this.v13_ = !0, this.updateV13_(), this.serverType_ = t.serverType, this.hidpi_ = t.hidpi !== void 0 ? t.hidpi : !0, this.image_ = null, this.imageSize_ = [0, 0], this.renderedRevision_ = 0, this.ratio_ = t.ratio !== void 0 ? t.ratio : 1.5; 27274 } 27275 /** 27276 * Return the GetFeatureInfo URL for the passed coordinate, resolution, and 27277 * projection. Return `undefined` if the GetFeatureInfo URL cannot be 27278 * constructed. 27279 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 27280 * @param {number} resolution Resolution. 27281 * @param {import("../proj.js").ProjectionLike} projection Projection. 27282 * @param {!Object} params GetFeatureInfo params. `INFO_FORMAT` at least should 27283 * be provided. If `QUERY_LAYERS` is not provided then the layers specified 27284 * in the `LAYERS` parameter will be used. `VERSION` should not be 27285 * specified here. 27286 * @return {string|undefined} GetFeatureInfo URL. 27287 * @api 27288 */ 27289 getFeatureInfoUrl(t, i, s, n) { 27290 if (this.url_ === void 0) 27291 return; 27292 const r = Rt(s), o = this.getProjection(); 27293 o && o !== r && (i = yr( 27294 o, 27295 r, 27296 t, 27297 i 27298 ), t = Hl(t, r, o)); 27299 const a = en( 27300 t, 27301 i, 27302 0, 27303 td 27304 ), l = { 27305 SERVICE: "WMS", 27306 VERSION: Ui, 27307 REQUEST: "GetFeatureInfo", 27308 FORMAT: "image/png", 27309 TRANSPARENT: !0, 27310 QUERY_LAYERS: this.params_.LAYERS 27311 }; 27312 Object.assign(l, this.params_, n); 27313 const h = Vs((t[0] - a[0]) / i, Pi), c = Vs((a[3] - t[1]) / i, Pi); 27314 return l[this.v13_ ? "I" : "X"] = h, l[this.v13_ ? "J" : "Y"] = c, this.getRequestUrl_( 27315 a, 27316 td, 27317 1, 27318 o || r, 27319 l 27320 ); 27321 } 27322 /** 27323 * Return the GetLegendGraphic URL, optionally optimized for the passed 27324 * resolution and possibly including any passed specific parameters. Returns 27325 * `undefined` if the GetLegendGraphic URL cannot be constructed. 27326 * 27327 * @param {number} [resolution] Resolution. If set to undefined, `SCALE` 27328 * will not be calculated and included in URL. 27329 * @param {Object} [params] GetLegendGraphic params. If `LAYER` is set, the 27330 * request is generated for this wms layer, else it will try to use the 27331 * configured wms layer. Default `FORMAT` is `image/png`. 27332 * `VERSION` should not be specified here. 27333 * @return {string|undefined} GetLegendGraphic URL. 27334 * @api 27335 */ 27336 getLegendUrl(t, i) { 27337 if (this.url_ === void 0) 27338 return; 27339 const s = { 27340 SERVICE: "WMS", 27341 VERSION: Ui, 27342 REQUEST: "GetLegendGraphic", 27343 FORMAT: "image/png" 27344 }; 27345 if (i === void 0 || i.LAYER === void 0) { 27346 const n = this.params_.LAYERS; 27347 if (!(!Array.isArray(n) || n.length === 1)) 27348 return; 27349 s.LAYER = n; 27350 } 27351 if (t !== void 0) { 27352 const n = this.getProjection() ? this.getProjection().getMetersPerUnit() : 1, r = 28e-5; 27353 s.SCALE = t * n / r; 27354 } 27355 return Object.assign(s, i), $o( 27356 /** @type {string} */ 27357 this.url_, 27358 s 27359 ); 27360 } 27361 /** 27362 * Get the user-provided params, i.e. those passed to the constructor through 27363 * the "params" option, and possibly updated using the updateParams method. 27364 * @return {Object} Params. 27365 * @api 27366 */ 27367 getParams() { 27368 return this.params_; 27369 } 27370 /** 27371 * @param {import("../extent.js").Extent} extent Extent. 27372 * @param {number} resolution Resolution. 27373 * @param {number} pixelRatio Pixel ratio. 27374 * @param {import("../proj/Projection.js").default} projection Projection. 27375 * @return {import("../Image.js").default} Single image. 27376 */ 27377 getImageInternal(t, i, s, n) { 27378 if (this.url_ === void 0) 27379 return null; 27380 i = this.findNearestResolution(i), s != 1 && (!this.hidpi_ || this.serverType_ === void 0) && (s = 1); 27381 const r = i / s, o = ii(t), a = zi(mt(t) / r, Pi), l = zi(Yt(t) / r, Pi), h = en(o, r, 0, [ 27382 a, 27383 l 27384 ]), c = zi( 27385 this.ratio_ * mt(t) / r, 27386 Pi 27387 ), u = zi( 27388 this.ratio_ * Yt(t) / r, 27389 Pi 27390 ), d = en(o, r, 0, [ 27391 c, 27392 u 27393 ]), f = this.image_; 27394 if (f && this.renderedRevision_ == this.getRevision() && f.getResolution() == i && f.getPixelRatio() == s && Gi(f.getExtent(), h)) 27395 return f; 27396 const g = { 27397 SERVICE: "WMS", 27398 VERSION: Ui, 27399 REQUEST: "GetMap", 27400 FORMAT: "image/png", 27401 TRANSPARENT: !0 27402 };
27403 Object.assign(g, this.params_), this.imageSize_[0] = Tc( 27404 mt(d) / r, 27405 Pi 27406 ), this.imageSize_[1] = Tc( 27407 Yt(d) / r, 27408 Pi 27409 ); 27410 const _ = this.getRequestUrl_( 27411 d, 27412 this.imageSize_, 27413 s, 27414 n, 27415 g 27416 ); 27417 return this.image_ = new CC( 27418 d, 27419 i, 27420 s, 27421 _, 27422 this.crossOrigin_, 27423 this.imageLoadFunction_, 27424 this.context_ 27425 ), this.renderedRevision_ = this.getRevision(), this.image_.addEventListener( 27426 et.CHANGE, 27427 this.handleImageChange.bind(this) 27428 ), this.image_; 27429 } 27430 /** 27431 * Return the image load function of the source. 27432 * @return {import("../Image.js").LoadFunction} The image load function. 27433 * @api 27434 */ 27435 getImageLoadFunction() { 27436 return this.imageLoadFunction_; 27437 } 27438 /** 27439 * @param {import("../extent.js").Extent} extent Extent. 27440 * @param {import("../size.js").Size} size Size. 27441 * @param {number} pixelRatio Pixel ratio. 27442 * @param {import("../proj/Projection.js").default} projection Projection. 27443 * @param {Object} params Params. 27444 * @return {string} Request URL. 27445 * @private 27446 */ 27447 getRequestUrl_(t, i, s, n, r) { 27448 if (at(this.url_ !== void 0, 9), r[this.v13_ ? "CRS" : "SRS"] = n.getCode(), "STYLES" in this.params_ || (r.STYLES = ""), s != 1) 27449 switch (this.serverType_) { 27450 case "geoserver": 27451 const l = 90 * s + 0.5 | 0; 27452 "FORMAT_OPTIONS" in r ? r.FORMAT_OPTIONS += ";dpi:" + l : r.FORMAT_OPTIONS = "dpi:" + l; 27453 break; 27454 case "mapserver": 27455 r.MAP_RESOLUTION = 90 * s; 27456 break; 27457 case "carmentaserver": 27458 case "qgis": 27459 r.DPI = 90 * s; 27460 break; 27461 default: 27462 at(!1, 8); 27463 break; 27464 } 27465 r.WIDTH = i[0], r.HEIGHT = i[1]; 27466 const o = n.getAxisOrientation(); 27467 let a; 27468 return this.v13_ && o.substr(0, 2) == "ne" ? a = [t[1], t[0], t[3], t[2]] : a = t, r.BBOX = a.join(","), $o( 27469 /** @type {string} */ 27470 this.url_, 27471 r 27472 ); 27473 } 27474 /** 27475 * Return the URL used for this WMS source. 27476 * @return {string|undefined} URL. 27477 * @api 27478 */ 27479 getUrl() { 27480 return this.url_; 27481 } 27482 /** 27483 * Set the image load function of the source. 27484 * @param {import("../Image.js").LoadFunction} imageLoadFunction Image load function. 27485 * @api 27486 */ 27487 setImageLoadFunction(t) { 27488 this.image_ = null, this.imageLoadFunction_ = t, this.changed(); 27489 } 27490 /** 27491 * Set the URL to use for requests. 27492 * @param {string|undefined} url URL. 27493 * @api 27494 */ 27495 setUrl(t) { 27496 t != this.url_ && (this.url_ = t, this.image_ = null, this.changed()); 27497 } 27498 /** 27499 * Update the user-provided params. 27500 * @param {Object} params Params. 27501 * @api 27502 */ 27503 updateParams(t) { 27504 Object.assign(this.params_, t), this.updateV13_(), this.image_ = null, this.changed(); 27505 } 27506 /** 27507 * @private 27508 */ 27509 updateV13_() { 27510 const t = this.params_.VERSION || Ui; 27511 this.v13_ = Od(t, "1.3") >= 0; 27512 } 27513} 27514const mS = _S; 27515class pS extends wg { 27516 /** 27517 * @param {import("../proj/Projection.js").default} sourceProj Source projection. 27518 * @param {import("../tilegrid/TileGrid.js").default} sourceTileGrid Source tile grid. 27519 * @param {import("../proj/Projection.js").default} targetProj Target projection. 27520 * @param {import("../tilegrid/TileGrid.js").default} targetTileGrid Target tile grid. 27521 * @param {import("../tilecoord.js").TileCoord} tileCoord Coordinate of the tile. 27522 * @param {import("../tilecoord.js").TileCoord} wrappedTileCoord Coordinate of the tile wrapped in X. 27523 * @param {number} pixelRatio Pixel ratio. 27524 * @param {number} gutter Gutter of the source tiles. 27525 * @param {FunctionType} getTileFunction 27526 * Function returning source tiles (z, x, y, pixelRatio). 27527 * @param {number} [errorThreshold] Acceptable reprojection error (in px). 27528 * @param {boolean} [renderEdges] Render reprojection edges. 27529 * @param {boolean} [interpolate] Use linear interpolation when resampling. 27530 */ 27531 constructor(t, i, s, n, r, o, a, l, h, c, u, d) { 27532 super(r, H.IDLE, { interpolate: !!d }), this.renderEdges_ = u !== void 0 ? u : !1, this.pixelRatio_ = a, this.gutter_ = l, this.canvas_ = null, this.sourceTileGrid_ = i, this.targetTileGrid_ = n, this.wrappedTileCoord_ = o || r, this.sourceTiles_ = [], this.sourcesListenerKeys_ = null, this.sourceZ_ = 0; 27533 const f = n.getTileCoordExtent( 27534 this.wrappedTileCoord_ 27535 ), g = this.targetTileGrid_.getExtent(); 27536 let _ = this.sourceTileGrid_.getExtent(); 27537 const m = g ? fs(f, g) : f; 27538 if (rl(m) === 0) { 27539 this.state = H.EMPTY; 27540 return; 27541 } 27542 const p = t.getExtent(); 27543 p && (_ ? _ = fs(_, p) : _ = p); 27544 const y = n.getResolution( 27545 this.wrappedTileCoord_[0] 27546 ), v = lS( 27547 t, 27548 s, 27549 m, 27550 y 27551 ); 27552 if (!isFinite(v) || v <= 0) { 27553 this.state = H.EMPTY; 27554 return; 27555 } 27556 const E = c !== void 0 ? c : Gg; 27557 if (this.triangulation_ = new zg( 27558 t, 27559 s, 27560 m, 27561 _, 27562 v * E, 27563 y
27564 ), this.triangulation_.getTriangles().length === 0) { 27565 this.state = H.EMPTY; 27566 return; 27567 } 27568 this.sourceZ_ = i.getZForResolution(v); 27569 let C = this.triangulation_.calculateSourceExtent(); 27570 if (_ && (t.canWrapX() ? (C[1] = Ot( 27571 C[1], 27572 _[1], 27573 _[3] 27574 ), C[3] = Ot( 27575 C[3], 27576 _[1], 27577 _[3] 27578 )) : C = fs(C, _)), !rl(C)) 27579 this.state = H.EMPTY; 27580 else { 27581 const S = i.getTileRangeForExtentAndZ( 27582 C, 27583 this.sourceZ_ 27584 ); 27585 for (let O = S.minX; O <= S.maxX; O++) 27586 for (let R = S.minY; R <= S.maxY; R++) { 27587 const j = h(this.sourceZ_, O, R, a); 27588 j && this.sourceTiles_.push(j); 27589 } 27590 this.sourceTiles_.length === 0 && (this.state = H.EMPTY); 27591 } 27592 } 27593 /** 27594 * Get the HTML Canvas element for this tile. 27595 * @return {HTMLCanvasElement} Canvas. 27596 */ 27597 getImage() { 27598 return this.canvas_; 27599 } 27600 /** 27601 * @private 27602 */ 27603 reproject_() { 27604 const t = []; 27605 if (this.sourceTiles_.forEach((i) => { 27606 i && i.getState() == H.LOADED && t.push({ 27607 extent: this.sourceTileGrid_.getTileCoordExtent(i.tileCoord), 27608 image: i.getImage() 27609 }); 27610 }), this.sourceTiles_.length = 0, t.length === 0) 27611 this.state = H.ERROR; 27612 else { 27613 const i = this.wrappedTileCoord_[0], s = this.targetTileGrid_.getTileSize(i), n = typeof s == "number" ? s : s[0], r = typeof s == "number" ? s : s[1], o = this.targetTileGrid_.getResolution(i), a = this.sourceTileGrid_.getResolution( 27614 this.sourceZ_ 27615 ), l = this.targetTileGrid_.getTileCoordExtent( 27616 this.wrappedTileCoord_ 27617 ); 27618 this.canvas_ = jg( 27619 n, 27620 r, 27621 this.pixelRatio_, 27622 a, 27623 this.sourceTileGrid_.getExtent(), 27624 o, 27625 l, 27626 this.triangulation_, 27627 t, 27628 this.gutter_, 27629 this.renderEdges_, 27630 this.interpolate 27631 ), this.state = H.LOADED; 27632 } 27633 this.changed(); 27634 } 27635 /** 27636 * Load not yet loaded URI. 27637 */ 27638 load() { 27639 if (this.state == H.IDLE) { 27640 this.state = H.LOADING, this.changed(); 27641 let t = 0; 27642 this.sourcesListenerKeys_ = [], this.sourceTiles_.forEach((i) => { 27643 const s = i.getState(); 27644 if (s == H.IDLE || s == H.LOADING) { 27645 t++; 27646 const n = lt( 27647 i, 27648 et.CHANGE, 27649 function(r) { 27650 const o = i.getState(); 27651 (o == H.LOADED || o == H.ERROR || o == H.EMPTY) && (Mt(n), t--, t === 0 && (this.unlistenSources_(), this.reproject_())); 27652 }, 27653 this 27654 ); 27655 this.sourcesListenerKeys_.push(n); 27656 } 27657 }), t === 0 ? setTimeout(this.reproject_.bind(this), 0) : this.sourceTiles_.forEach(function(i, s, n) { 27658 i.getState() == H.IDLE && i.load(); 27659 }); 27660 } 27661 } 27662 /** 27663 * @private 27664 */ 27665 unlistenSources_() { 27666 this.sourcesListenerKeys_.forEach(Mt), this.sourcesListenerKeys_ = null; 27667 } 27668 /** 27669 * Remove from the cache due to expiry 27670 */ 27671 release() { 27672 this.canvas_ && (_a(this.canvas_.getContext("2d")), ln.push(this.canvas_), this.canvas_ = null), super.release(); 27673 } 27674} 27675const Ol = pS, Ja = { 27676 /** 27677 * Triggered when a tile starts loading. 27678 * @event module:ol/source/Tile.TileSourceEvent#tileloadstart 27679 * @api 27680 */ 27681 TILELOADSTART: "tileloadstart", 27682 /** 27683 * Triggered when a tile finishes loading, either when its data is loaded, 27684 * or when loading was aborted because the tile is no longer needed. 27685 * @event module:ol/source/Tile.TileSourceEvent#tileloadend 27686 * @api 27687 */ 27688 TILELOADEND: "tileloadend", 27689 /** 27690 * Triggered if tile loading results in an error. Note that this is not the 27691 * right place to re-fetch tiles. See {@link module:ol/ImageTile~ImageTile#load} 27692 * for details. 27693 * @event module:ol/source/Tile.TileSourceEvent#tileloaderror 27694 * @api 27695 */ 27696 TILELOADERROR: "tileloaderror" 27697}, ks = [0, 0, 0], Ai = 5; 27698class yS { 27699 /** 27700 * @param {Options} options Tile grid options. 27701 */ 27702 constructor(t) { 27703 this.minZoom = t.minZoom !== void 0 ? t.minZoom : 0, this.resolutions_ = t.resolutions, at( 27704 Yv( 27705 this.resolutions_, 27706 function(n, r) { 27707 return r - n; 27708 }, 27709 !0 27710 ), 27711 17 27712 ); 27713 let i; 27714 if (!t.origins) { 27715 for (let n = 0, r = this.resolutions_.length - 1; n < r; ++n) 27716 if (!i) 27717 i = this.resolutions_[n] / this.resolutions_[n + 1]; 27718 else if (this.resolutions_[n] / this.resolutions_[n + 1] !== i) { 27719 i = void 0; 27720 break; 27721 } 27722 } 27723 this.zoomFactor_ = i, 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, at(this.origins_.length == this.resolutions_.length, 20)); 27724 const s = t.extent; 27725 s !== void 0 && !this.origin_ && !this.origins_ && (this.origin_ = ws(s)), at( 27726 !this.origin_ && this.origins_ || this.origin_ && !this.origins_, 27727 18 27728 ), this.tileSizes_ = null, t.tileSizes !== void 0 && (this.tileSizes_ = t.tileSizes, at(this.tileSizes_.length == this.resolutions_.length, 19)), this.tileSize_ = t.tileSize !== void 0 ? t.tileSize : this.tileSizes_ ? null : Eh, at( 27729 !this.tileSize_ && this.tileSizes_ || this.tileSize_ && !this.tileSizes_, 27730 22 27731 ), this.extent_ = s !== void 0 ? s : null, this.fullTileRanges_ = null, this.tmpSize_ = [0, 0], this.tmpExtent_ = [0, 0, 0, 0], t.sizes !== void 0 ? this.fullTileRanges_ = t.sizes.map(function(n, r) { 27732 const o = new Lg( 27733 Math.min(0, n[0]), 27734 Math.max(n[0] - 1, -1), 27735 Math.min(0, n[1]), 27736 Math.max(n[1] - 1, -1) 27737 ); 27738 if (s) { 27739 const a = this.getTileRangeForExtentAndZ(s, r); 27740 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); 27741 } 27742 return o; 27743 }, this) : s && this.calculateTileRanges_(s); 27744 } 27745 /** 27746 * Call a function with each tile coordinate for a given extent and zoom level. 27747 * 27748 * @param {import("../extent.js").Extent} extent Extent. 27749 * @param {number} zoom Integer zoom level. 27750 * @param {function(import("../tilecoord.js").TileCoord): void} callback Function called with each tile coordinate. 27751 * @api 27752 */ 27753 forEachTileCoord(t, i, s) { 27754 const n = this.getTileRangeForExtentAndZ(t, i); 27755 for (let r = n.minX, o = n.maxX; r <= o; ++r) 27756 for (let a = n.minY, l = n.maxY; a <= l; ++a) 27757 s([i, r, a]); 27758 } 27759 /** 27760 * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate. 27761 * @param {function(number, import("../TileRange.js").default): boolean} callback Callback. 27762 * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object. 27763 * @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object. 27764 * @return {boolean} Callback succeeded. 27765 */ 27766 forEachTileCoordParentTileRange(t, i, s, n) { 27767 let r, o, a, l = null, h = t[0] - 1; 27768 for (this.zoomFactor_ === 2 ? (o = t[1], a = t[2]) : l = this.getTileCoordExtent(t, n); h >= this.minZoom; ) { 27769 if (this.zoomFactor_ === 2 ? (o = Math.floor(o / 2), a = Math.floor(a / 2), r = Ns(o, o, a, a, s)) : r = this.getTileRangeForExtentAndZ( 27770 l, 27771 h, 27772 s 27773 ), i(h, r)) 27774 return !0; 27775 --h; 27776 } 27777 return !1; 27778 } 27779 /** 27780 * Get the extent for this tile grid, if it was configured. 27781 * @return {import("../extent.js").Extent} Extent. 27782 * @api 27783 */ 27784 getExtent() { 27785 return this.extent_; 27786 } 27787 /** 27788 * Get the maximum zoom level for the grid. 27789 * @return {number} Max zoom. 27790 * @api 27791 */ 27792 getMaxZoom() { 27793 return this.maxZoom; 27794 } 27795 /** 27796 * Get the minimum zoom level for the grid. 27797 * @return {number} Min zoom. 27798 * @api 27799 */ 27800 getMinZoom() { 27801 return this.minZoom; 27802 } 27803 /** 27804 * Get the origin for the grid at the given zoom level. 27805 * @param {number} z Integer zoom level. 27806 * @return {import("../coordinate.js").Coordinate} Origin. 27807 * @api 27808 */ 27809 getOrigin(t) { 27810 return this.origin_ ? this.origin_ : this.origins_[t]; 27811 } 27812 /** 27813 * Get the resolution for the given zoom level. 27814 * @param {number} z Integer zoom level. 27815 * @return {number} Resolution. 27816 * @api 27817 */ 27818 getResolution(t) { 27819 return this.resolutions_[t]; 27820 } 27821 /** 27822 * Get the list of resolutions for the tile grid. 27823 * @return {Array<number>} Resolutions. 27824 * @api 27825 */ 27826 getResolutions() { 27827 return this.resolutions_; 27828 } 27829 /** 27830 * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate. 27831 * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object. 27832 * @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object. 27833 * @return {import("../TileRange.js").default|null} Tile range. 27834 */ 27835 getTileCoordChildTileRange(t, i, s) { 27836 if (t[0] < this.maxZoom) { 27837 if (this.zoomFactor_ === 2) { 27838 const r = t[1] * 2, o = t[2] * 2; 27839 return Ns( 27840 r, 27841 r + 1, 27842 o, 27843 o + 1, 27844 i 27845 ); 27846 } 27847 const n = this.getTileCoordExtent( 27848 t, 27849 s || this.tmpExtent_ 27850 ); 27851 return this.getTileRangeForExtentAndZ( 27852 n, 27853 t[0] + 1, 27854 i 27855 ); 27856 } 27857 return null; 27858 } 27859 /** 27860 * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate. 27861 * @param {number} z Integer zoom level. 27862 * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object. 27863 * @return {import("../TileRange.js").default|null} Tile range. 27864 */ 27865 getTileRangeForTileCoordAndZ(t, i, s) { 27866 if (i > this.maxZoom || i < this.minZoom) 27867 return null; 27868 const n = t[0], r = t[1], o = t[2]; 27869 if (i === n) 27870 return Ns( 27871 r, 27872 o, 27873 r, 27874 o, 27875 s 27876 ); 27877 if (this.zoomFactor_) { 27878 const l = Math.pow(this.zoomFactor_, i - n), h = Math.floor(r * l), c = Math.floor(o * l); 27879 if (i < n) 27880 return Ns(h, h, c, c, s); 27881 const u = Math.floor(l * (r + 1)) - 1, d = Math.floor(l * (o + 1)) - 1; 27882 return Ns(h, u, c, d, s); 27883 } 27884 const a = this.getTileCoordExtent(t, this.tmpExtent_); 27885 return this.getTileRangeForExtentAndZ(a, i, s); 27886 } 27887 /** 27888 * Get a tile range for the given extent and integer zoom level. 27889 * @param {import("../extent.js").Extent} extent Extent. 27890 * @param {number} z Integer zoom level. 27891 * @param {import("../TileRange.js").default} [tempTileRange] Temporary tile range object. 27892 * @return {import("../TileRange.js").default} Tile range. 27893 */ 27894 getTileRangeForExtentAndZ(t, i, s) { 27895 this.getTileCoordForXYAndZ_(t[0], t[3], i, !1, ks); 27896 const n = ks[1], r = ks[2]; 27897 this.getTileCoordForXYAndZ_(t[2], t[1], i, !0, ks); 27898 const o = ks[1], a = ks[2]; 27899 return Ns(n, o, r, a, s); 27900 } 27901 /** 27902 * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate. 27903 * @return {import("../coordinate.js").Coordinate} Tile center. 27904 */ 27905 getTileCoordCenter(t) { 27906 const i = this.getOrigin(t[0]), s = this.getResolution(t[0]), n = ye(this.getTileSize(t[0]), this.tmpSize_); 27907 return [
27908 i[0] + (t[1] + 0.5) * n[0] * s, 27909 i[1] - (t[2] + 0.5) * n[1] * s 27910 ]; 27911 } 27912 /** 27913 * Get the extent of a tile coordinate. 27914 * 27915 * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate. 27916 * @param {import("../extent.js").Extent} [tempExtent] Temporary extent object. 27917 * @return {import("../extent.js").Extent} Extent. 27918 * @api 27919 */ 27920 getTileCoordExtent(t, i) { 27921 const s = this.getOrigin(t[0]), n = this.getResolution(t[0]), r = ye(this.getTileSize(t[0]), this.tmpSize_), o = s[0] + t[1] * r[0] * n, a = s[1] - (t[2] + 1) * r[1] * n, l = o + r[0] * n, h = a + r[1] * n; 27922 return ei(o, a, l, h, i); 27923 } 27924 /** 27925 * Get the tile coordinate for the given map coordinate and resolution. This 27926 * method considers that coordinates that intersect tile boundaries should be 27927 * assigned the higher tile coordinate. 27928 * 27929 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 27930 * @param {number} resolution Resolution. 27931 * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object. 27932 * @return {import("../tilecoord.js").TileCoord} Tile coordinate. 27933 * @api 27934 */ 27935 getTileCoordForCoordAndResolution(t, i, s) { 27936 return this.getTileCoordForXYAndResolution_( 27937 t[0], 27938 t[1], 27939 i, 27940 !1, 27941 s 27942 ); 27943 } 27944 /** 27945 * Note that this method should not be called for resolutions that correspond 27946 * to an integer zoom level. Instead call the `getTileCoordForXYAndZ_` method. 27947 * @param {number} x X. 27948 * @param {number} y Y. 27949 * @param {number} resolution Resolution (for a non-integer zoom level). 27950 * @param {boolean} reverseIntersectionPolicy Instead of letting edge 27951 * intersections go to the higher tile coordinate, let edge intersections 27952 * go to the lower tile coordinate. 27953 * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object. 27954 * @return {import("../tilecoord.js").TileCoord} Tile coordinate. 27955 * @private 27956 */ 27957 getTileCoordForXYAndResolution_(t, i, s, n, r) { 27958 const o = this.getZForResolution(s), a = s / this.getResolution(o), l = this.getOrigin(o), h = ye(this.getTileSize(o), this.tmpSize_); 27959 let c = a * (t - l[0]) / s / h[0], u = a * (l[1] - i) / s / h[1]; 27960 return n ? (c = zi(c, Ai) - 1, u = zi(u, Ai) - 1) : (c = Vs(c, Ai), u = Vs(u, Ai)), Xu(o, c, u, r); 27961 } 27962 /** 27963 * Although there is repetition between this method and `getTileCoordForXYAndResolution_`, 27964 * they should have separate implementations. This method is for integer zoom 27965 * levels. The other method should only be called for resolutions corresponding 27966 * to non-integer zoom levels. 27967 * @param {number} x Map x coordinate. 27968 * @param {number} y Map y coordinate. 27969 * @param {number} z Integer zoom level. 27970 * @param {boolean} reverseIntersectionPolicy Instead of letting edge 27971 * intersections go to the higher tile coordinate, let edge intersections 27972 * go to the lower tile coordinate. 27973 * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object. 27974 * @return {import("../tilecoord.js").TileCoord} Tile coordinate. 27975 * @private 27976 */ 27977 getTileCoordForXYAndZ_(t, i, s, n, r) { 27978 const o = this.getOrigin(s), a = this.getResolution(s), l = ye(this.getTileSize(s), this.tmpSize_); 27979 let h = (t - o[0]) / a / l[0], c = (o[1] - i) / a / l[1]; 27980 return n ? (h = zi(h, Ai) - 1, c = zi(c, Ai) - 1) : (h = Vs(h, Ai), c = Vs(c, Ai)), Xu(s, h, c, r); 27981 } 27982 /** 27983 * Get a tile coordinate given a map coordinate and zoom level. 27984 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 27985 * @param {number} z Zoom level. 27986 * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object. 27987 * @return {import("../tilecoord.js").TileCoord} Tile coordinate. 27988 * @api 27989 */ 27990 getTileCoordForCoordAndZ(t, i, s) { 27991 return this.getTileCoordForXYAndZ_( 27992 t[0], 27993 t[1], 27994 i, 27995 !1, 27996 s 27997 ); 27998 } 27999 /** 28000 * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate. 28001 * @return {number} Tile resolution. 28002 */ 28003 getTileCoordResolution(t) { 28004 return this.resolutions_[t[0]]; 28005 } 28006 /** 28007 * Get the tile size for a zoom level. The type of the return value matches the 28008 * `tileSize` or `tileSizes` that the tile grid was configured with. To always 28009 * get an {@link import("../size.js").Size}, run the result through {@link module:ol/size.toSize}. 28010 * @param {number} z Z. 28011 * @return {number|import("../size.js").Size} Tile size. 28012 * @api 28013 */ 28014 getTileSize(t) { 28015 return this.tileSize_ ? this.tileSize_ : this.tileSizes_[t]; 28016 } 28017 /** 28018 * @param {number} z Zoom level. 28019 * @return {import("../TileRange.js").default} Extent tile range for the specified zoom level. 28020 */ 28021 getFullTileRange(t) { 28022 return this.fullTileRanges_ ? this.fullTileRanges_[t] : this.extent_ ? this.getTileRangeForExtentAndZ(this.extent_, t) : null; 28023 } 28024 /** 28025 * @param {number} resolution Resolution. 28026 * @param {number|import("../array.js").NearestDirectionFunction} [opt_direction] 28027 * If 0, the nearest resolution will be used. 28028 * If 1, the nearest higher resolution (lower Z) will be used. If -1, the 28029 * nearest lower resolution (higher Z) will be used. Default is 0. 28030 * Use a {@link module:ol/array~NearestDirectionFunction} for more precise control. 28031 * 28032 * For example to change tile Z at the midpoint of zoom levels 28033 * ```js 28034 * function(value, high, low) { 28035 * return value - low * Math.sqrt(high / low); 28036 * } 28037 * ``` 28038 * @return {number} Z. 28039 * @api 28040 */ 28041 getZForResolution(t, i) { 28042 const s = ha( 28043 this.resolutions_, 28044 t, 28045 i || 0 28046 ); 28047 return Ot(s, this.minZoom, this.maxZoom); 28048 } 28049 /** 28050 * The tile with the provided tile coordinate intersects the given viewport. 28051 * @param {import('../tilecoord.js').TileCoord} tileCoord Tile coordinate. 28052 * @param {Array<number>} viewport Viewport as returned from {@link module:ol/extent.getRotatedViewport}. 28053 * @return {boolean} The tile with the provided tile coordinate intersects the given viewport. 28054 */ 28055 tileCoordIntersectsViewport(t, i) { 28056 return Zf( 28057 i, 28058 0, 28059 i.length, 28060 2, 28061 this.getTileCoordExtent(t) 28062 ); 28063 } 28064 /** 28065 * @param {!import("../extent.js").Extent} extent Extent for this tile grid. 28066 * @private 28067 */ 28068 calculateTileRanges_(t) { 28069 const i = this.resolutions_.length, s = new Array(i); 28070 for (let n = this.minZoom; n < i; ++n) 28071 s[n] = this.getTileRangeForExtentAndZ(t, n); 28072 this.fullTileRanges_ = s; 28073 } 28074} 28075const xS = yS; 28076function Wg(e) { 28077 let t = e.getDefaultTileGrid(); 28078 return t || (t = CS(e), e.setDefaultTileGrid(t)), t; 28079} 28080function vS(e, t, i) { 28081 const s = t[0], n = e.getTileCoordCenter(t), r = Bg(i); 28082 if (!wr(r, n)) { 28083 const o = mt(r), a = Math.ceil( 28084 (r[0] - n[0]) / o 28085 ); 28086 return n[0] += o * a, e.getTileCoordForCoordAndZ(n, s); 28087 } 28088 return t; 28089} 28090function ES(e, t, i, s) { 28091 s = s !== void 0 ? s : "top-left"; 28092 const n = MS(e, t, i); 28093 return new xS({ 28094 extent: e, 28095 origin: jy(e, s), 28096 resolutions: n, 28097 tileSize: i 28098 }); 28099} 28100function MS(e, t, i, s) { 28101 t = t !== void 0 ? t : _E, i = ye(i !== void 0 ? i : Eh); 28102 const n = Yt(e), r = mt(e); 28103 s = s > 0 ? s : Math.max(r / i[0], n / i[1]); 28104 const o = t + 1, a = new Array(o); 28105 for (let l = 0; l < o; ++l) 28106 a[l] = s / Math.pow(2, l); 28107 return a; 28108} 28109function CS(e, t, i, s) { 28110 const n = Bg(e); 28111 return ES(n, t, i, s); 28112} 28113function Bg(e) { 28114 e = Rt(e); 28115 let t = e.getExtent(); 28116 if (!t) { 28117 const i = 180 * er.degrees / e.getMetersPerUnit(); 28118 t = ei(-i, -i, i, i); 28119 } 28120 return t; 28121} 28122class bS extends Zh { 28123 /** 28124 * @param {Options} options SourceTile source options. 28125 */ 28126 constructor(t) { 28127 super({ 28128 attributions: t.attributions, 28129 attributionsCollapsible: t.attributionsCollapsible, 28130 projection: t.projection, 28131 state: t.state, 28132 wrapX: t.wrapX, 28133 interpolate: t.interpolate 28134 }), this.on, this.once, this.un, this.opaque_ = t.opaque !== void 0 ? t.opaque : !1, this.tilePixelRatio_ = t.tilePixelRatio !== void 0 ? t.tilePixelRatio : 1, this.tileGrid = t.tileGrid !== void 0 ? t.tileGrid : null; 28135 const i = [256, 256]; 28136 this.tileGrid && ye(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()), i), this.tileCache = new Pg(t.cacheSize || 0), this.tmpSize = [0, 0], this.key_ = t.key || "", this.tileOptions = { 28137 transition: t.transition, 28138 interpolate: t.interpolate 28139 }, this.zDirection = t.zDirection ? t.zDirection : 0; 28140 } 28141 /** 28142 * @return {boolean} Can expire cache. 28143 */ 28144 canExpireCache() { 28145 return this.tileCache.canExpireCache(); 28146 } 28147 /** 28148 * @param {import("../proj/Projection.js").default} projection Projection. 28149 * @param {!Object<string, boolean>} usedTiles Used tiles. 28150 */ 28151 expireCache(t, i) { 28152 const s = this.getTileCacheForProjection(t); 28153 s && s.expireCache(i); 28154 } 28155 /** 28156 * @param {import("../proj/Projection.js").default} projection Projection. 28157 * @param {number} z Zoom level. 28158 * @param {import("../TileRange.js").default} tileRange Tile range. 28159 * @param {function(import("../Tile.js").default):(boolean|void)} callback Called with each 28160 * loaded tile. If the callback returns `false`, the tile will not be 28161 * considered loaded. 28162 * @return {boolean} The tile range is fully covered with loaded tiles. 28163 */ 28164 forEachLoadedTile(t, i, s, n) { 28165 const r = this.getTileCacheForProjection(t); 28166 if (!r) 28167 return !1; 28168 let o = !0, a, l, h; 28169 for (let c = s.minX; c <= s.maxX; ++c) 28170 for (let u = s.minY; u <= s.maxY; ++u)
28171 l = xa(i, c, u), h = !1, r.containsKey(l) && (a = /** @type {!import("../Tile.js").default} */ 28172 r.get(l), h = a.getState() === H.LOADED, h && (h = n(a) !== !1)), h || (o = !1); 28173 return o; 28174 } 28175 /** 28176 * @param {import("../proj/Projection.js").default} projection Projection. 28177 * @return {number} Gutter. 28178 */ 28179 getGutterForProjection(t) { 28180 return 0; 28181 } 28182 /** 28183 * Return the key to be used for all tiles in the source. 28184 * @return {string} The key for all tiles. 28185 */ 28186 getKey() { 28187 return this.key_; 28188 } 28189 /** 28190 * Set the value to be used as the key for all tiles in the source. 28191 * @param {string} key The key for tiles. 28192 * @protected 28193 */ 28194 setKey(t) { 28195 this.key_ !== t && (this.key_ = t, this.changed()); 28196 } 28197 /** 28198 * @param {import("../proj/Projection.js").default} projection Projection. 28199 * @return {boolean} Opaque. 28200 */ 28201 getOpaque(t) { 28202 return this.opaque_; 28203 } 28204 /** 28205 * @param {import("../proj/Projection").default} [projection] Projection. 28206 * @return {Array<number>|null} Resolutions. 28207 */ 28208 getResolutions(t) { 28209 const i = t ? this.getTileGridForProjection(t) : this.tileGrid; 28210 return i ? i.getResolutions() : null; 28211 } 28212 /** 28213 * @abstract 28214 * @param {number} z Tile coordinate z. 28215 * @param {number} x Tile coordinate x. 28216 * @param {number} y Tile coordinate y. 28217 * @param {number} pixelRatio Pixel ratio. 28218 * @param {import("../proj/Projection.js").default} projection Projection. 28219 * @return {!import("../Tile.js").default} Tile. 28220 */ 28221 getTile(t, i, s, n, r) { 28222 return Z(); 28223 } 28224 /** 28225 * Return the tile grid of the tile source. 28226 * @return {import("../tilegrid/TileGrid.js").default|null} Tile grid. 28227 * @api 28228 */ 28229 getTileGrid() { 28230 return this.tileGrid; 28231 } 28232 /** 28233 * @param {import("../proj/Projection.js").default} projection Projection. 28234 * @return {!import("../tilegrid/TileGrid.js").default} Tile grid. 28235 */ 28236 getTileGridForProjection(t) { 28237 return this.tileGrid ? this.tileGrid : Wg(t); 28238 } 28239 /** 28240 * @param {import("../proj/Projection.js").default} projection Projection. 28241 * @return {import("../TileCache.js").default} Tile cache. 28242 * @protected 28243 */ 28244 getTileCacheForProjection(t) { 28245 const i = this.getProjection(); 28246 return at( 28247 i === null || di(i, t), 28248 68 28249 // A VectorTile source can only be rendered if it has a projection compatible with the view projection. 28250 ), this.tileCache; 28251 } 28252 /** 28253 * Get the tile pixel ratio for this source. Subclasses may override this 28254 * method, which is meant to return a supported pixel ratio that matches the 28255 * provided `pixelRatio` as close as possible. 28256 * @param {number} pixelRatio Pixel ratio. 28257 * @return {number} Tile pixel ratio. 28258 */ 28259 getTilePixelRatio(t) { 28260 return this.tilePixelRatio_; 28261 } 28262 /** 28263 * @param {number} z Z. 28264 * @param {number} pixelRatio Pixel ratio. 28265 * @param {import("../proj/Projection.js").default} projection Projection. 28266 * @return {import("../size.js").Size} Tile size. 28267 */ 28268 getTilePixelSize(t, i, s) { 28269 const n = this.getTileGridForProjection(s), r = this.getTilePixelRatio(i), o = ye(n.getTileSize(t), this.tmpSize); 28270 return r == 1 ? o : ug(o, r, this.tmpSize); 28271 } 28272 /** 28273 * Returns a tile coordinate wrapped around the x-axis. When the tile coordinate 28274 * is outside the resolution and extent range of the tile grid, `null` will be 28275 * returned. 28276 * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate. 28277 * @param {import("../proj/Projection.js").default} [projection] Projection. 28278 * @return {import("../tilecoord.js").TileCoord} Tile coordinate to be passed to the tileUrlFunction or 28279 * null if no tile URL should be created for the passed `tileCoord`. 28280 */ 28281 getTileCoordForTileUrlFunction(t, i) { 28282 i = i !== void 0 ? i : this.getProjection(); 28283 const s = this.getTileGridForProjection(i); 28284 return this.getWrapX() && i.isGlobal() && (t = vS(s, t, i)), Pb(t, s) ? t : null; 28285 } 28286 /** 28287 * Remove all cached tiles from the source. The next render cycle will fetch new tiles. 28288 * @api 28289 */ 28290 clear() { 28291 this.tileCache.clear(); 28292 } 28293 refresh() { 28294 this.clear(), super.refresh(); 28295 } 28296 /** 28297 * Increases the cache size if needed 28298 * @param {number} tileCount Minimum number of tiles needed. 28299 * @param {import("../proj/Projection.js").default} projection Projection. 28300 */ 28301 updateCacheSize(t, i) { 28302 const s = this.getTileCacheForProjection(i); 28303 t > s.highWaterMark && (s.highWaterMark = t); 28304 } 28305 /** 28306 * Marks a tile coord as being used, without triggering a load. 28307 * @abstract 28308 * @param {number} z Tile coordinate z. 28309 * @param {number} x Tile coordinate x. 28310 * @param {number} y Tile coordinate y. 28311 * @param {import("../proj/Projection.js").default} projection Projection. 28312 */ 28313 useTile(t, i, s, n) { 28314 } 28315} 28316class SS extends Ae { 28317 /** 28318 * @param {string} type Type. 28319 * @param {import("../Tile.js").default} tile The tile. 28320 */ 28321 constructor(t, i) { 28322 super(t), this.tile = i; 28323 } 28324} 28325const wS = bS; 28326function TS(e, t) { 28327 const i = /\{z\}/g, s = /\{x\}/g, n = /\{y\}/g, r = /\{-y\}/g; 28328 return ( 28329 /** 28330 * @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate. 28331 * @param {number} pixelRatio Pixel ratio. 28332 * @param {import("./proj/Projection.js").default} projection Projection. 28333 * @return {string|undefined} Tile URL. 28334 */ 28335 function(o, a, l) { 28336 if (o) 28337 return e.replace(i, o[0].toString()).replace(s, o[1].toString()).replace(n, o[2].toString()).replace(r, function() { 28338 const h = o[0], c = t.getFullTileRange(h); 28339 return at(c, 55), (c.getHeight() - o[2] - 1).toString(); 28340 }); 28341 } 28342 ); 28343} 28344function RS(e, t) { 28345 const i = e.length, s = new Array(i); 28346 for (let n = 0; n < i; ++n) 28347 s[n] = TS(e[n], t); 28348 return IS(s); 28349} 28350function IS(e) { 28351 return e.length === 1 ? e[0] : ( 28352 /** 28353 * @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate. 28354 * @param {number} pixelRatio Pixel ratio. 28355 * @param {import("./proj/Projection.js").default} projection Projection. 28356 * @return {string|undefined} Tile URL. 28357 */ 28358 function(t, i, s) { 28359 if (!t) 28360 return; 28361 const n = Ig(t), r = $i(n, e.length); 28362 return e[r](t, i, s); 28363 } 28364 ); 28365} 28366function PS(e) { 28367 const t = []; 28368 let i = /\{([a-z])-([a-z])\}/.exec(e); 28369 if (i) {
28370 const s = i[1].charCodeAt(0), n = i[2].charCodeAt(0); 28371 let r; 28372 for (r = s; r <= n; ++r) 28373 t.push(e.replace(i[0], String.fromCharCode(r))); 28374 return t; 28375 } 28376 if (i = /\{(\d+)-(\d+)\}/.exec(e), i) { 28377 const s = parseInt(i[2], 10); 28378 for (let n = parseInt(i[1], 10); n <= s; n++) 28379 t.push(e.replace(i[0], n.toString())); 28380 return t; 28381 } 28382 return t.push(e), t; 28383} 28384class ic extends wS { 28385 /** 28386 * @param {Options} options Image tile options. 28387 */ 28388 constructor(t) { 28389 super({ 28390 attributions: t.attributions, 28391 cacheSize: t.cacheSize, 28392 opaque: t.opaque, 28393 projection: t.projection, 28394 state: t.state, 28395 tileGrid: t.tileGrid, 28396 tilePixelRatio: t.tilePixelRatio, 28397 wrapX: t.wrapX, 28398 transition: t.transition, 28399 interpolate: t.interpolate, 28400 key: t.key, 28401 attributionsCollapsible: t.attributionsCollapsible, 28402 zDirection: t.zDirection 28403 }), this.generateTileUrlFunction_ = this.tileUrlFunction === ic.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_ = {}; 28404 } 28405 /** 28406 * Return the tile load function of the source. 28407 * @return {import("../Tile.js").LoadFunction} TileLoadFunction 28408 * @api 28409 */ 28410 getTileLoadFunction() { 28411 return this.tileLoadFunction; 28412 } 28413 /** 28414 * Return the tile URL function of the source. 28415 * @return {import("../Tile.js").UrlFunction} TileUrlFunction 28416 * @api 28417 */ 28418 getTileUrlFunction() { 28419 return Object.getPrototypeOf(this).tileUrlFunction === this.tileUrlFunction ? this.tileUrlFunction.bind(this) : this.tileUrlFunction; 28420 } 28421 /** 28422 * Return the URLs used for this source. 28423 * When a tileUrlFunction is used instead of url or urls, 28424 * null will be returned. 28425 * @return {!Array<string>|null} URLs. 28426 * @api 28427 */ 28428 getUrls() { 28429 return this.urls; 28430 } 28431 /** 28432 * Handle tile change events. 28433 * @param {import("../events/Event.js").default} event Event. 28434 * @protected 28435 */ 28436 handleTileChange(t) { 28437 const i = ( 28438 /** @type {import("../Tile.js").default} */ 28439 t.target 28440 ), s = ot(i), n = i.getState(); 28441 let r; 28442 n == H.LOADING ? (this.tileLoadingKeys_[s] = !0, r = Ja.TILELOADSTART) : s in this.tileLoadingKeys_ && (delete this.tileLoadingKeys_[s], r = n == H.ERROR ? Ja.TILELOADERROR : n == H.LOADED ? Ja.TILELOADEND : void 0), r != null && this.dispatchEvent(new SS(r, i)); 28443 } 28444 /** 28445 * Set the tile load function of the source. 28446 * @param {import("../Tile.js").LoadFunction} tileLoadFunction Tile load function. 28447 * @api 28448 */ 28449 setTileLoadFunction(t) { 28450 this.tileCache.clear(), this.tileLoadFunction = t, this.changed(); 28451 } 28452 /** 28453 * Set the tile URL function of the source. 28454 * @param {import("../Tile.js").UrlFunction} tileUrlFunction Tile URL function. 28455 * @param {string} [key] Optional new tile key for the source. 28456 * @api 28457 */ 28458 setTileUrlFunction(t, i) { 28459 this.tileUrlFunction = t, this.tileCache.pruneExceptNewestZ(), typeof i < "u" ? this.setKey(i) : this.changed(); 28460 } 28461 /** 28462 * Set the URL to use for requests. 28463 * @param {string} url URL. 28464 * @api 28465 */ 28466 setUrl(t) { 28467 const i = PS(t); 28468 this.urls = i, this.setUrls(i); 28469 } 28470 /** 28471 * Set the URLs to use for requests. 28472 * @param {Array<string>} urls URLs. 28473 * @api 28474 */ 28475 setUrls(t) { 28476 this.urls = t; 28477 const i = t.join(` 28478`); 28479 this.generateTileUrlFunction_ ? this.setTileUrlFunction(RS(t, this.tileGrid), i) : this.setKey(i); 28480 } 28481 /** 28482 * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate. 28483 * @param {number} pixelRatio Pixel ratio. 28484 * @param {import("../proj/Projection.js").default} projection Projection. 28485 * @return {string|undefined} Tile URL. 28486 */ 28487 tileUrlFunction(t, i, s) { 28488 } 28489 /** 28490 * Marks a tile coord as being used, without triggering a load. 28491 * @param {number} z Tile coordinate z. 28492 * @param {number} x Tile coordinate x. 28493 * @param {number} y Tile coordinate y. 28494 */ 28495 useTile(t, i, s) { 28496 const n = xa(t, i, s); 28497 this.tileCache.containsKey(n) && this.tileCache.get(n); 28498 } 28499} 28500const AS = ic; 28501class LS extends AS { 28502 /** 28503 * @param {!Options} options Image tile options. 28504 */ 28505 constructor(t) { 28506 super({ 28507 attributions: t.attributions, 28508 cacheSize: t.cacheSize, 28509 opaque: t.opaque, 28510 projection: t.projection, 28511 state: t.state, 28512 tileGrid: t.tileGrid, 28513 tileLoadFunction: t.tileLoadFunction ? t.tileLoadFunction : OS, 28514 tilePixelRatio: t.tilePixelRatio, 28515 tileUrlFunction: t.tileUrlFunction, 28516 url: t.url, 28517 urls: t.urls, 28518 wrapX: t.wrapX, 28519 transition: t.transition, 28520 interpolate: t.interpolate !== void 0 ? t.interpolate : !0, 28521 key: t.key, 28522 attributionsCollapsible: t.attributionsCollapsible, 28523 zDirection: t.zDirection 28524 }), this.crossOrigin = t.crossOrigin !== void 0 ? t.crossOrigin : null, this.tileClass = t.tileClass !== void 0 ? t.tileClass : Tg, this.tileCacheForProjection = {}, this.tileGridForProjection = {}, this.reprojectionErrorThreshold_ = t.reprojectionErrorThreshold, this.renderReprojectionEdges_ = !1; 28525 } 28526 /** 28527 * @return {boolean} Can expire cache. 28528 */ 28529 canExpireCache() { 28530 if (this.tileCache.canExpireCache()) 28531 return !0; 28532 for (const t in this.tileCacheForProjection) 28533 if (this.tileCacheForProjection[t].canExpireCache()) 28534 return !0; 28535 return !1; 28536 } 28537 /** 28538 * @param {import("../proj/Projection.js").default} projection Projection. 28539 * @param {!Object<string, boolean>} usedTiles Used tiles. 28540 */ 28541 expireCache(t, i) { 28542 const s = this.getTileCacheForProjection(t); 28543 this.tileCache.expireCache( 28544 this.tileCache == s ? i : {} 28545 ); 28546 for (const n in this.tileCacheForProjection) { 28547 const r = this.tileCacheForProjection[n]; 28548 r.expireCache(r == s ? i : {}); 28549 } 28550 } 28551 /** 28552 * @param {import("../proj/Projection.js").default} projection Projection. 28553 * @return {number} Gutter. 28554 */ 28555 getGutterForProjection(t) { 28556 return this.getProjection() && t && !di(this.getProjection(), t) ? 0 : this.getGutter(); 28557 } 28558 /** 28559 * @return {number} Gutter. 28560 */ 28561 getGutter() { 28562 return 0; 28563 } 28564 /** 28565 * Return the key to be used for all tiles in the source. 28566 * @return {string} The key for all tiles. 28567 */ 28568 getKey() { 28569 let t = super.getKey(); 28570 return this.getInterpolate() || (t += ":disable-interpolation"), t; 28571 } 28572 /** 28573 * @param {import("../proj/Projection.js").default} projection Projection. 28574 * @return {boolean} Opaque. 28575 */ 28576 getOpaque(t) { 28577 return this.getProjection() && t && !di(this.getProjection(), t) ? !1 : super.getOpaque(t); 28578 } 28579 /** 28580 * @param {import("../proj/Projection.js").default} projection Projection. 28581 * @return {!import("../tilegrid/TileGrid.js").default} Tile grid. 28582 */ 28583 getTileGridForProjection(t) { 28584 const i = this.getProjection(); 28585 if (this.tileGrid && (!i || di(i, t))) 28586 return this.tileGrid; 28587 const s = ot(t); 28588 return s in this.tileGridForProjection || (this.tileGridForProjection[s] = Wg(t)), this.tileGridForProjection[s]; 28589 } 28590 /** 28591 * @param {import("../proj/Projection.js").default} projection Projection. 28592 * @return {import("../TileCache.js").default} Tile cache. 28593 */ 28594 getTileCacheForProjection(t) { 28595 const i = this.getProjection(); 28596 if (!i || di(i, t)) 28597 return this.tileCache; 28598 const s = ot(t); 28599 return s in this.tileCacheForProjection || (this.tileCacheForProjection[s] = new Pg( 28600 this.tileCache.highWaterMark 28601 )), this.tileCacheForProjection[s]; 28602 } 28603 /** 28604 * @param {number} z Tile coordinate z. 28605 * @param {number} x Tile coordinate x. 28606 * @param {number} y Tile coordinate y. 28607 * @param {number} pixelRatio Pixel ratio. 28608 * @param {import("../proj/Projection.js").default} projection Projection. 28609 * @param {string} key The key set on the tile. 28610 * @return {!ImageTile} Tile. 28611 * @private 28612 */ 28613 createTile_(t, i, s, n, r, o) { 28614 const a = [t, i, s], l = this.getTileCoordForTileUrlFunction( 28615 a, 28616 r 28617 ), h = l ? this.tileUrlFunction(l, n, r) : void 0, c = new this.tileClass( 28618 a, 28619 h !== void 0 ? H.IDLE : H.EMPTY, 28620 h !== void 0 ? h : "", 28621 this.crossOrigin, 28622 this.tileLoadFunction, 28623 this.tileOptions 28624 ); 28625 return c.key = o, c.addEventListener(et.CHANGE, this.handleTileChange.bind(this)), c; 28626 } 28627 /** 28628 * @param {number} z Tile coordinate z. 28629 * @param {number} x Tile coordinate x. 28630 * @param {number} y Tile coordinate y. 28631 * @param {number} pixelRatio Pixel ratio. 28632 * @param {import("../proj/Projection.js").default} projection Projection. 28633 * @return {!(ImageTile|ReprojTile)} Tile. 28634 */ 28635 getTile(t, i, s, n, r) { 28636 const o = this.getProjection(); 28637 if (!o || !r || di(o, r)) 28638 return this.getTileInternal( 28639 t, 28640 i, 28641 s, 28642 n, 28643 o || r 28644 ); 28645 const a = this.getTileCacheForProjection(r), l = [t, i, s]; 28646 let h; 28647 const c = Rg(l); 28648 a.containsKey(c) && (h = a.get(c)); 28649 const u = this.getKey(); 28650 if (h && h.key == u) 28651 return h; 28652 const d = this.getTileGridForProjection(o), f = this.getTileGridForProjection(r), g = this.getTileCoordForTileUrlFunction( 28653 l, 28654 r 28655 ), _ = new Ol( 28656 o, 28657 d, 28658 r, 28659 f, 28660 l, 28661 g, 28662 this.getTilePixelRatio(n), 28663 this.getGutter(), 28664 (m, p, y, v) => this.getTileInternal(m, p, y, v, o), 28665 this.reprojectionErrorThreshold_, 28666 this.renderReprojectionEdges_, 28667 this.getInterpolate() 28668 ); 28669 return _.key = u, h ? (_.interimTile = h, _.refreshInterimChain(), a.replace(c, _)) : a.set(c, _), _; 28670 } 28671 /** 28672 * @param {number} z Tile coordinate z. 28673 * @param {number} x Tile coordinate x. 28674 * @param {number} y Tile coordinate y. 28675 * @param {number} pixelRatio Pixel ratio. 28676 * @param {!import("../proj/Projection.js").default} projection Projection. 28677 * @return {!ImageTile} Tile. 28678 * @protected 28679 */ 28680 getTileInternal(t, i, s, n, r) { 28681 let o = null; 28682 const a = xa(t, i, s), l = this.getKey(); 28683 if (!this.tileCache.containsKey(a)) 28684 o = this.createTile_(t, i, s, n, r, l), this.tileCache.set(a, o); 28685 else if (o = this.tileCache.get(a), o.key != l) { 28686 const h = o;
28687 o = this.createTile_(t, i, s, n, r, l), h.getState() == H.IDLE ? o.interimTile = h.interimTile : o.interimTile = h, o.refreshInterimChain(), this.tileCache.replace(a, o); 28688 } 28689 return o; 28690 } 28691 /** 28692 * Sets whether to render reprojection edges or not (usually for debugging). 28693 * @param {boolean} render Render the edges. 28694 * @api 28695 */ 28696 setRenderReprojectionEdges(t) { 28697 if (this.renderReprojectionEdges_ != t) { 28698 this.renderReprojectionEdges_ = t; 28699 for (const i in this.tileCacheForProjection) 28700 this.tileCacheForProjection[i].clear(); 28701 this.changed(); 28702 } 28703 } 28704 /** 28705 * Sets the tile grid to use when reprojecting the tiles to the given 28706 * projection instead of the default tile grid for the projection. 28707 * 28708 * This can be useful when the default tile grid cannot be created 28709 * (e.g. projection has no extent defined) or 28710 * for optimization reasons (custom tile size, resolutions, ...). 28711 * 28712 * @param {import("../proj.js").ProjectionLike} projection Projection. 28713 * @param {import("../tilegrid/TileGrid.js").default} tilegrid Tile grid to use for the projection. 28714 * @api 28715 */ 28716 setTileGridForProjection(t, i) { 28717 const s = Rt(t); 28718 if (s) { 28719 const n = ot(s); 28720 n in this.tileGridForProjection || (this.tileGridForProjection[n] = i); 28721 } 28722 } 28723 clear() { 28724 super.clear(); 28725 for (const t in this.tileCacheForProjection) 28726 this.tileCacheForProjection[t].clear(); 28727 } 28728} 28729function OS(e, t) { 28730 e.getImage().src = t; 28731} 28732const FS = LS; 28733class DS extends FS { 28734 /** 28735 * @param {Options} [options] Tile WMS options. 28736 */ 28737 constructor(t) { 28738 t = t || /** @type {Options} */ 28739 {}; 28740 const i = Object.assign({}, t.params), s = "TRANSPARENT" in i ? i.TRANSPARENT : !0; 28741 super({ 28742 attributions: t.attributions, 28743 attributionsCollapsible: t.attributionsCollapsible, 28744 cacheSize: t.cacheSize, 28745 crossOrigin: t.crossOrigin, 28746 interpolate: t.interpolate, 28747 opaque: !s, 28748 projection: t.projection, 28749 reprojectionErrorThreshold: t.reprojectionErrorThreshold, 28750 tileClass: t.tileClass, 28751 tileGrid: t.tileGrid, 28752 tileLoadFunction: t.tileLoadFunction, 28753 url: t.url, 28754 urls: t.urls, 28755 wrapX: t.wrapX !== void 0 ? t.wrapX : !0, 28756 transition: t.transition, 28757 zDirection: t.zDirection 28758 }), this.gutter_ = t.gutter !== void 0 ? t.gutter : 0, this.params_ = i, this.v13_ = !0, this.serverType_ = t.serverType, this.hidpi_ = t.hidpi !== void 0 ? t.hidpi : !0, this.tmpExtent_ = ve(), this.updateV13_(), this.setKey(this.getKeyForParams_()); 28759 } 28760 /** 28761 * Return the GetFeatureInfo URL for the passed coordinate, resolution, and 28762 * projection. Return `undefined` if the GetFeatureInfo URL cannot be 28763 * constructed. 28764 * @param {import("../coordinate.js").Coordinate} coordinate Coordinate. 28765 * @param {number} resolution Resolution. 28766 * @param {import("../proj.js").ProjectionLike} projection Projection. 28767 * @param {!Object} params GetFeatureInfo params. `INFO_FORMAT` at least should 28768 * be provided. If `QUERY_LAYERS` is not provided then the layers specified 28769 * in the `LAYERS` parameter will be used. `VERSION` should not be 28770 * specified here. 28771 * @return {string|undefined} GetFeatureInfo URL. 28772 * @api 28773 */ 28774 getFeatureInfoUrl(t, i, s, n) { 28775 const r = Rt(s), o = this.getProjection(); 28776 let a = this.getTileGrid(); 28777 a || (a = this.getTileGridForProjection(r)); 28778 const l = a.getZForResolution(i, this.zDirection), h = a.getTileCoordForCoordAndZ(t, l); 28779 if (a.getResolutions().length <= h[0]) 28780 return; 28781 let c = a.getResolution(h[0]), u = a.getTileCoordExtent(h, this.tmpExtent_), d = ye(a.getTileSize(h[0]), this.tmpSize); 28782 const f = this.gutter_; 28783 f !== 0 && (d = Tu(d, f, this.tmpSize), u = Es(u, c * f, u)), o && o !== r && (c = yr( 28784 o, 28785 r, 28786 t, 28787 c 28788 ), u = s1( 28789 u, 28790 r, 28791 o 28792 ), t = Hl(t, r, o)); 28793 const g = { 28794 SERVICE: "WMS", 28795 VERSION: Ui, 28796 REQUEST: "GetFeatureInfo", 28797 FORMAT: "image/png", 28798 TRANSPARENT: !0, 28799 QUERY_LAYERS: this.params_.LAYERS 28800 };
28801 Object.assign(g, this.params_, n); 28802 const _ = Math.floor((t[0] - u[0]) / c), m = Math.floor((u[3] - t[1]) / c); 28803 return g[this.v13_ ? "I" : "X"] = _, g[this.v13_ ? "J" : "Y"] = m, this.getRequestUrl_( 28804 h, 28805 d, 28806 u, 28807 1, 28808 o || r, 28809 g 28810 ); 28811 } 28812 /** 28813 * Return the GetLegendGraphic URL, optionally optimized for the passed 28814 * resolution and possibly including any passed specific parameters. Returns 28815 * `undefined` if the GetLegendGraphic URL cannot be constructed. 28816 * 28817 * @param {number} [resolution] Resolution. If set to undefined, `SCALE` 28818 * will not be calculated and included in URL. 28819 * @param {Object} [params] GetLegendGraphic params. If `LAYER` is set, the 28820 * request is generated for this wms layer, else it will try to use the 28821 * configured wms layer. Default `FORMAT` is `image/png`. 28822 * `VERSION` should not be specified here. 28823 * @return {string|undefined} GetLegendGraphic URL. 28824 * @api 28825 */ 28826 getLegendUrl(t, i) { 28827 if (this.urls[0] === void 0) 28828 return; 28829 const s = { 28830 SERVICE: "WMS", 28831 VERSION: Ui, 28832 REQUEST: "GetLegendGraphic", 28833 FORMAT: "image/png" 28834 }; 28835 if (i === void 0 || i.LAYER === void 0) { 28836 const n = this.params_.LAYERS; 28837 if (!(!Array.isArray(n) || n.length === 1)) 28838 return; 28839 s.LAYER = n; 28840 } 28841 if (t !== void 0) { 28842 const n = this.getProjection() ? this.getProjection().getMetersPerUnit() : 1, r = 28e-5; 28843 s.SCALE = t * n / r; 28844 } 28845 return Object.assign(s, i), $o( 28846 /** @type {string} */ 28847 this.urls[0], 28848 s 28849 ); 28850 } 28851 /** 28852 * @return {number} Gutter. 28853 */ 28854 getGutter() { 28855 return this.gutter_; 28856 } 28857 /** 28858 * Get the user-provided params, i.e. those passed to the constructor through 28859 * the "params" option, and possibly updated using the updateParams method. 28860 * @return {Object} Params. 28861 * @api 28862 */ 28863 getParams() { 28864 return this.params_; 28865 } 28866 /** 28867 * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate. 28868 * @param {import("../size.js").Size} tileSize Tile size. 28869 * @param {import("../extent.js").Extent} tileExtent Tile extent. 28870 * @param {number} pixelRatio Pixel ratio. 28871 * @param {import("../proj/Projection.js").default} projection Projection. 28872 * @param {Object} params Params. 28873 * @return {string|undefined} Request URL. 28874 * @private 28875 */ 28876 getRequestUrl_(t, i, s, n, r, o) { 28877 const a = this.urls; 28878 if (!a) 28879 return; 28880 if (o.WIDTH = i[0], o.HEIGHT = i[1], o[this.v13_ ? "CRS" : "SRS"] = r.getCode(), "STYLES" in this.params_ || (o.STYLES = ""), n != 1) 28881 switch (this.serverType_) { 28882 case "geoserver": 28883 const u = 90 * n + 0.5 | 0; 28884 "FORMAT_OPTIONS" in o ? o.FORMAT_OPTIONS += ";dpi:" + u : o.FORMAT_OPTIONS = "dpi:" + u; 28885 break; 28886 case "mapserver": 28887 o.MAP_RESOLUTION = 90 * n; 28888 break; 28889 case "carmentaserver": 28890 case "qgis": 28891 o.DPI = 90 * n; 28892 break; 28893 default: 28894 at(!1, 52); 28895 break; 28896 } 28897 const l = r.getAxisOrientation(), h = s; 28898 if (this.v13_ && l.substr(0, 2) == "ne") { 28899 let u; 28900 u = s[0], h[0] = s[1], h[1] = u, u = s[2], h[2] = s[3], h[3] = u; 28901 } 28902 o.BBOX = h.join(","); 28903 let c; 28904 if (a.length == 1) 28905 c = a[0]; 28906 else { 28907 const u = $i(Ig(t), a.length); 28908 c = a[u]; 28909 } 28910 return $o(c, o); 28911 } 28912 /** 28913 * Get the tile pixel ratio for this source. 28914 * @param {number} pixelRatio Pixel ratio. 28915 * @return {number} Tile pixel ratio. 28916 */ 28917 getTilePixelRatio(t) { 28918 return !this.hidpi_ || this.serverType_ === void 0 ? 1 : t; 28919 } 28920 /** 28921 * @private 28922 * @return {string} The key for the current params. 28923 */ 28924 getKeyForParams_() { 28925 let t = 0; 28926 const i = []; 28927 for (const s in this.params_) 28928 i[t++] = s + "-" + this.params_[s]; 28929 return i.join("/"); 28930 } 28931 /** 28932 * Update the user-provided params. 28933 * @param {Object} params Params. 28934 * @api 28935 */ 28936 updateParams(t) { 28937 Object.assign(this.params_, t), this.updateV13_(), this.setKey(this.getKeyForParams_()); 28938 } 28939 /** 28940 * @private 28941 */ 28942 updateV13_() { 28943 const t = this.params_.VERSION || Ui; 28944 this.v13_ = Od(t, "1.3") >= 0; 28945 } 28946 /** 28947 * @param {import("../tilecoord.js").TileCoord} tileCoord The tile coordinate 28948 * @param {number} pixelRatio The pixel ratio 28949 * @param {import("../proj/Projection.js").default} projection The projection 28950 * @return {string|undefined} The tile URL 28951 * @override 28952 */ 28953 tileUrlFunction(t, i, s) { 28954 let n = this.getTileGrid(); 28955 if (n || (n = this.getTileGridForProjection(s)), n.getResolutions().length <= t[0]) 28956 return; 28957 i != 1 && (!this.hidpi_ || this.serverType_ === void 0) && (i = 1); 28958 const r = n.getResolution(t[0]); 28959 let o = n.getTileCoordExtent(t, this.tmpExtent_), a = ye(n.getTileSize(t[0]), this.tmpSize); 28960 const l = this.gutter_; 28961 l !== 0 && (a = Tu(a, l, this.tmpSize), o = Es(o, r * l, o)), i != 1 && (a = ug(a, i, this.tmpSize)); 28962 const h = { 28963 SERVICE: "WMS", 28964 VERSION: Ui, 28965 REQUEST: "GetMap", 28966 FORMAT: "image/png", 28967 TRANSPARENT: !0 28968 }; 28969 return Object.assign(h, this.params_), this.getRequestUrl_( 28970 t, 28971 a, 28972 o, 28973 i, 28974 s, 28975 h 28976 ); 28977 } 28978} 28979const NS = DS; 28980class kS extends Pr { 28981 /** 28982 * @param {Options<ImageSourceType>} [options] Layer options. 28983 */ 28984 constructor(t) { 28985 t = t || {}, super(t); 28986 } 28987} 28988const GS = kS; 28989class zS extends Hh { 28990 /** 28991 * @param {import("../../layer/Image.js").default} imageLayer Image layer. 28992 */ 28993 constructor(t) { 28994 super(t), this.image_ = null; 28995 } 28996 /** 28997 * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image. 28998 */ 28999 getImage() { 29000 return this.image_ ? this.image_.getImage() : null; 29001 } 29002 /** 29003 * Determine whether render should be called. 29004 * @param {import("../../Map.js").FrameState} frameState Frame state. 29005 * @return {boolean} Layer is ready to be rendered. 29006 */ 29007 prepareFrame(t) { 29008 const i = t.layerStatesArray[t.layerIndex], s = t.pixelRatio, n = t.viewState, r = n.resolution, o = this.getLayer().getSource(), a = t.viewHints; 29009 let l = t.extent; 29010 if (i.extent !== void 0 && (l = fs( 29011 l, 29012 He(i.extent, n.projection) 29013 )), !a[Xt.ANIMATING] && !a[Xt.INTERACTING] && !Ts(l)) 29014 if (o) { 29015 const h = n.projection, c = o.getImage( 29016 l, 29017 r, 29018 s, 29019 h 29020 ); 29021 c && (this.loadImage(c) ? this.image_ = c : c.getState() === rt.EMPTY && (this.image_ = null)); 29022 } else 29023 this.image_ = null; 29024 return !!this.image_; 29025 } 29026 /** 29027 * @param {import("../../pixel.js").Pixel} pixel Pixel. 29028 * @return {Uint8ClampedArray} Data at the pixel location. 29029 */ 29030 getData(t) { 29031 const i = this.frameState; 29032 if (!i) 29033 return null; 29034 const s = this.getLayer(), n = zt( 29035 i.pixelToCoordinateTransform, 29036 t.slice() 29037 ), r = s.getExtent(); 29038 if (r && !wr(r, n)) 29039 return null; 29040 const o = this.image_.getExtent(), a = this.getImage(), l = mt(o), h = Math.floor( 29041 a.width * ((n[0] - o[0]) / l) 29042 ); 29043 if (h < 0 || h >= a.width) 29044 return null; 29045 const c = Yt(o), u = Math.floor(
29046 a.height * ((o[3] - n[1]) / c) 29047 ); 29048 return u < 0 || u >= a.height ? null : this.getImageData(a, h, u); 29049 } 29050 /** 29051 * Render the layer. 29052 * @param {import("../../Map.js").FrameState} frameState Frame state. 29053 * @param {HTMLElement} target Target that may be used to render content to. 29054 * @return {HTMLElement} The rendered element. 29055 */ 29056 renderFrame(t, i) { 29057 const s = this.image_, n = s.getExtent(), r = s.getResolution(), o = s.getPixelRatio(), a = t.layerStatesArray[t.layerIndex], l = t.pixelRatio, h = t.viewState, c = h.center, u = h.resolution, d = l * r / (u * o), f = t.extent, g = h.resolution, _ = h.rotation, m = Math.round(mt(f) / g * l), p = Math.round(Yt(f) / g * l); 29058 si( 29059 this.pixelTransform, 29060 t.size[0] / 2, 29061 t.size[1] / 2, 29062 1 / l, 29063 1 / l, 29064 _, 29065 -m / 2, 29066 -p / 2 29067 ), ua(this.inversePixelTransform, this.pixelTransform); 29068 const y = vh(this.pixelTransform); 29069 this.useContainer(i, y, this.getBackground(t)); 29070 const v = this.context, E = v.canvas; 29071 E.width != m || E.height != p ? (E.width = m, E.height = p) : this.containerReused || v.clearRect(0, 0, m, p); 29072 let C = !1, S = !0; 29073 if (a.extent) { 29074 const q = He( 29075 a.extent, 29076 h.projection 29077 ); 29078 S = ee(q, t.extent), C = S && !Gi(q, t.extent), C && this.clipUnrotated(v, t, q); 29079 } 29080 const O = this.getImage(), R = si( 29081 this.tempTransform, 29082 m / 2, 29083 p / 2, 29084 d, 29085 d, 29086 0, 29087 o * (n[0] - c[0]) / r, 29088 o * (c[1] - n[3]) / r 29089 ); 29090 this.renderedResolution = r * l / o; 29091 const j = O.width * R[0], $ = O.height * R[3]; 29092 if (this.getLayer().getSource().getInterpolate() || (v.imageSmoothingEnabled = !1), this.preRender(v, t), S && j >= 0.5 && $ >= 0.5) { 29093 const q = R[4], tt = R[5], J = a.opacity; 29094 let St; 29095 J !== 1 && (St = v.globalAlpha, v.globalAlpha = J), v.drawImage(O, 0, 0, +O.width, +O.height, q, tt, j, $), J !== 1 && (v.globalAlpha = St); 29096 } 29097 return this.postRender(v, t), C && v.restore(), v.imageSmoothingEnabled = !0, y !== E.style.transform && (E.style.transform = y), this.container; 29098 } 29099} 29100const jS = zS; 29101class WS extends GS { 29102 /** 29103 * @param {import("./BaseImage.js").Options<ImageSourceType>} [options] Layer options. 29104 */ 29105 constructor(t) { 29106 super(t); 29107 } 29108 createRenderer() { 29109 return new jS(this); 29110 } 29111 /** 29112 * Get data for a pixel location. A four element RGBA array will be returned. For requests outside the 29113 * layer extent, `null` will be returned. Data for an image can only be retrieved if the 29114 * source's `crossOrigin` property is set. 29115 * 29116 * ```js 29117 * // display layer data on every pointer move 29118 * map.on('pointermove', (event) => { 29119 * console.log(layer.getData(event.pixel)); 29120 * }); 29121 * ``` 29122 * @param {import("../pixel").Pixel} pixel Pixel. 29123 * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data. 29124 * @api 29125 */ 29126 getData(t) { 29127 return super.getData(t); 29128 } 29129} 29130const BS = WS, oo = { 29131 PRELOAD: "preload", 29132 USE_INTERIM_TILES_ON_ERROR: "useInterimTilesOnError" 29133}; 29134class US extends Pr { 29135 /** 29136 * @param {Options<TileSourceType>} [options] Tile layer options. 29137 */ 29138 constructor(t) { 29139 t = t || {}; 29140 const i = Object.assign({}, t); 29141 delete i.preload, delete i.useInterimTilesOnError, super(i), this.on, this.once, this.un, this.setPreload(t.preload !== void 0 ? t.preload : 0), this.setUseInterimTilesOnError( 29142 t.useInterimTilesOnError !== void 0 ? t.useInterimTilesOnError : !0 29143 ); 29144 } 29145 /** 29146 * Return the level as number to which we will preload tiles up to. 29147 * @return {number} The level to preload tiles up to. 29148 * @observable 29149 * @api 29150 */ 29151 getPreload() { 29152 return ( 29153 /** @type {number} */ 29154 this.get(oo.PRELOAD) 29155 ); 29156 } 29157 /** 29158 * Set the level as number to which we will preload tiles up to. 29159 * @param {number} preload The level to preload tiles up to. 29160 * @observable 29161 * @api 29162 */ 29163 setPreload(t) { 29164 this.set(oo.PRELOAD, t); 29165 } 29166 /** 29167 * Whether we use interim tiles on error. 29168 * @return {boolean} Use interim tiles on error. 29169 * @observable 29170 * @api 29171 */ 29172 getUseInterimTilesOnError() { 29173 return ( 29174 /** @type {boolean} */ 29175 this.get(oo.USE_INTERIM_TILES_ON_ERROR) 29176 ); 29177 } 29178 /** 29179 * Set whether we use interim tiles on error. 29180 * @param {boolean} useInterimTilesOnError Use interim tiles on error. 29181 * @observable 29182 * @api 29183 */ 29184 setUseInterimTilesOnError(t) { 29185 this.set(oo.USE_INTERIM_TILES_ON_ERROR, t); 29186 } 29187 /** 29188 * Get data for a pixel location. The return type depends on the source data. For image tiles, 29189 * a four element RGBA array will be returned. For data tiles, the array length
29189will match the 29190 * number of bands in the dataset. For requests outside the layer extent, `null` will be returned. 29191 * Data for a image tiles can only be retrieved if the source's `crossOrigin` property is set. 29192 * 29193 * ```js 29194 * // display layer data on every pointer move 29195 * map.on('pointermove', (event) => { 29196 * console.log(layer.getData(event.pixel)); 29197 * }); 29198 * ``` 29199 * @param {import("../pixel").Pixel} pixel Pixel. 29200 * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data. 29201 * @api 29202 */ 29203 getData(t) { 29204 return super.getData(t); 29205 } 29206} 29207const XS = US; 29208class $S extends Hh { 29209 /** 29210 * @param {LayerType} tileLayer Tile layer. 29211 */ 29212 constructor(t) { 29213 super(t), this.extentChanged = !0, this.renderedExtent_ = null, this.renderedPixelRatio, this.renderedProjection = null, this.renderedRevision, this.renderedTiles = [], this.newTiles_ = !1, this.tmpExtent = ve(), this.tmpTileRange_ = new Lg(0, 0, 0, 0); 29214 } 29215 /** 29216 * @protected 29217 * @param {import("../../Tile.js").default} tile Tile. 29218 * @return {boolean} Tile is drawable. 29219 */ 29220 isDrawableTile(t) { 29221 const i = this.getLayer(), s = t.getState(), n = i.getUseInterimTilesOnError(); 29222 return s == H.LOADED || s == H.EMPTY || s == H.ERROR && !n; 29223 } 29224 /** 29225 * @param {number} z Tile coordinate z. 29226 * @param {number} x Tile coordinate x. 29227 * @param {number} y Tile coordinate y. 29228 * @param {import("../../Map.js").FrameState} frameState Frame state. 29229 * @return {!import("../../Tile.js").default} Tile. 29230 */ 29231 getTile(t, i, s, n) { 29232 const r = n.pixelRatio, o = n.viewState.projection, a = this.getLayer(); 29233 let h = a.getSource().getTile(t, i, s, r, o); 29234 return h.getState() == H.ERROR && a.getUseInterimTilesOnError() && a.getPreload() > 0 && (this.newTiles_ = !0), this.isDrawableTile(h) || (h = h.getInterimTile()), h; 29235 } 29236 /** 29237 * @param {import("../../pixel.js").Pixel} pixel Pixel. 29238 * @return {Uint8ClampedArray} Data at the pixel location. 29239 */ 29240 getData(t) { 29241 const i = this.frameState; 29242 if (!i) 29243 return null; 29244 const s = this.getLayer(), n = zt( 29245 i.pixelToCoordinateTransform, 29246 t.slice() 29247 ), r = s.getExtent(); 29248 if (r && !wr(r, n)) 29249 return null; 29250 const o = i.pixelRatio, a = i.viewState.projection, l = i.viewState, h = s.getRenderSource(), c = h.getTileGridForProjection(l.projection), u = h.getTilePixelRatio(i.pixelRatio); 29251 for (let d = c.getZForResolution(l.resolution); d >= c.getMinZoom(); --d) { 29252 const f = c.getTileCoordForCoordAndZ(n, d), g = h.getTile( 29253 d, 29254 f[1], 29255 f[2], 29256 o, 29257 a 29258 ); 29259 if (!(g instanceof Tg || g instanceof Ol) || g instanceof Ol && g.getState() === H.EMPTY) 29260 return null; 29261 if (g.getState() !== H.LOADED) 29262 continue; 29263 const _ = c.getOrigin(d), m = ye(c.getTileSize(d)), p = c.getResolution(d), y = Math.floor( 29264 u * ((n[0] - _[0]) / p - f[1] * m[0]) 29265 ), v = Math.floor( 29266 u * ((_[1] - n[1]) / p - f[2] * m[1]) 29267 ), E = Math.round( 29268 u * h.getGutterForProjection(l.projection) 29269 ); 29270 return this.getImageData(g.getImage(), y + E, v + E); 29271 } 29272 return null; 29273 } 29274 /** 29275 * @param {Object<number, Object<string, import("../../Tile.js").default>>} tiles Lookup of loaded tiles by zoom level. 29276 * @param {number} zoom Zoom level. 29277 * @param {import("../../Tile.js").default} tile Tile. 29278 * @return {boolean|void} If `false`, the tile will not be considered loaded. 29279 */ 29280 loadedTileCallback(t, i, s) { 29281 return this.isDrawableTile(s) ? super.loadedTileCallback(t, i, s) : !1; 29282 } 29283 /** 29284 * Determine whether render should be called. 29285 * @param {import("../../Map.js").FrameState} frameState Frame state. 29286 * @return {boolean} Layer is ready to be rendered. 29287 */ 29288 prepareFrame(t) { 29289 return !!this.getLayer().getSource(); 29290 } 29291 /** 29292 * Render the layer. 29293 * @param {import("../../Map.js").FrameState} frameState Frame state. 29294 * @param {HTMLElement} target Target that may be used to render content to. 29295 * @return {HTMLElement} The rendered element. 29296 */ 29297 renderFrame(t, i) { 29298 const s = t.layerStatesArray[t.layerIndex], n = t.viewState, r = n.projection, o = n.resolution, a = n.center, l = n.rotation, h = t.pixelRatio, c = this.getLayer(), u = c.getSource(), d = u.getRevision(), f = u.getTileGridForProjection(r), g = f.getZForResolution(o, u.zDirection), _ = f.getResolution(g); 29299 let m = t.extent; 29300 const p = t.viewState.resolution, y = u.getTilePixelRatio(h), v = Math.round(mt(m) / p * h), E = Math.round(Yt(m) / p * h), C = s.extent && He(s.extent); 29301 C && (m = fs( 29302 m, 29303 He(s.extent) 29304 )); 29305 const S = _ * v / 2 / y, O = _ * E / 2 / y, R = [ 29306 a[0] - S, 29307 a[1] - O,
29308 a[0] + S, 29309 a[1] + O 29310 ], j = f.getTileRangeForExtentAndZ(m, g), $ = {}; 29311 $[g] = {}; 29312 const q = this.createLoadedTileFinder( 29313 u, 29314 r, 29315 $ 29316 ), tt = this.tmpExtent, J = this.tmpTileRange_; 29317 this.newTiles_ = !1; 29318 const St = l ? ol( 29319 n.center, 29320 p, 29321 l, 29322 t.size 29323 ) : void 0; 29324 for (let qt = j.minX; qt <= j.maxX; ++qt) 29325 for (let pt = j.minY; pt <= j.maxY; ++pt) { 29326 if (l && !f.tileCoordIntersectsViewport([g, qt, pt], St)) 29327 continue; 29328 const vt = this.getTile(g, qt, pt, t); 29329 if (this.isDrawableTile(vt)) { 29330 const Gt = ot(this); 29331 if (vt.getState() == H.LOADED) { 29332 $[g][vt.tileCoord.toString()] = vt; 29333 let Ht = vt.inTransition(Gt); 29334 Ht && s.opacity !== 1 && (vt.endTransition(Gt), Ht = !1), !this.newTiles_ && (Ht || !this.renderedTiles.includes(vt)) && (this.newTiles_ = !0); 29335 } 29336 if (vt.getAlpha(Gt, t.time) === 1) 29337 continue; 29338 } 29339 const Bt = f.getTileCoordChildTileRange( 29340 vt.tileCoord, 29341 J, 29342 tt 29343 ); 29344 let oe = !1; 29345 Bt && (oe = q(g + 1, Bt)), oe || f.forEachTileCoordParentTileRange( 29346 vt.tileCoord, 29347 q, 29348 J, 29349 tt 29350 ); 29351 } 29352 const K = _ / o * h / y; 29353 si( 29354 this.pixelTransform, 29355 t.size[0] / 2, 29356 t.size[1] / 2, 29357 1 / h, 29358 1 / h, 29359 l, 29360 -v / 2, 29361 -E / 2 29362 ); 29363 const Y = vh(this.pixelTransform); 29364 this.useContainer(i, Y, this.getBackground(t)); 29365 const L = this.context, W = L.canvas; 29366 ua(this.inversePixelTransform, this.pixelTransform), si( 29367 this.tempTransform, 29368 v / 2, 29369 E / 2, 29370 K, 29371 K, 29372 0, 29373 -v / 2, 29374 -E / 2 29375 ), W.width != v || W.height != E ? (W.width = v, W.height = E) : this.containerReused || L.clearRect(0, 0, v, E), C && this.clipUnrotated(L, t, C), u.getInterpolate() || (L.imageSmoothingEnabled = !1), this.preRender(L, t), this.renderedTiles.length = 0; 29376 let ut = Object.keys($).map(Number); 29377 ut.sort(Cs); 29378 let ft, wt, I; 29379 s.opacity === 1 && (!this.containerReused || u.getOpaque(t.viewState.projection)) ? ut = ut.reverse() : (ft = [], wt = []); 29380 for (let qt = ut.length - 1; qt >= 0; --qt) { 29381 const pt = ut[qt], vt = u.getTilePixelSize( 29382 pt, 29383 h, 29384 r 29385 ), oe = f.getResolution(pt) / _, Gt = vt[0] * oe * K, Ht = vt[1] * oe * K, Ue = f.getTileCoordForCoordAndZ( 29386 ws(R), 29387 pt 29388 ), Si = f.getTileCoordExtent(Ue), x = zt(this.tempTransform, [ 29389 y * (Si[0] - R[0]) / _, 29390 y * (R[3] - Si[3]) / _ 29391 ]), M = y * u.getGutterForProjection(r), b = $[pt]; 29392 for (const T in b) { 29393 const w = ( 29394 /** @type {import("../../ImageTile.js").default} */ 29395 b[T] 29396 ), D = w.tileCoord, k = Ue[1] - D[1], F = Math.round(x[0] - (k - 1) * Gt), N = Ue[2] - D[2], P = Math.round(x[1] - (N - 1) * Ht), B = Math.round(x[0] - k * Gt), z = Math.round(x[1] - N * Ht), X = F - B, V = P - z, nt = g === pt, gt = nt && w.getAlpha(ot(this), t.time) !== 1; 29397 let ct = !1; 29398 if (!gt) 29399 if (ft) { 29400 I = [B, z, B + X, z, B + X, z + V, B, z + V]; 29401 for (let bt = 0, Zt = ft.length; bt < Zt; ++bt) 29402 if (g !== pt && pt < wt[bt]) { 29403 const Dt = ft[bt]; 29404 ee( 29405 [B, z, B + X, z + V], 29406 [Dt[0], Dt[3], Dt[4], Dt[7]] 29407 ) && (ct || (L.save(), ct = !0), L.beginPath(), L.moveTo(I[0], I[1]), L.lineTo(I[2], I[3]), L.lineTo(I[4], I[5]), L.lineTo(I[6], I[7]), L.moveTo(Dt[6], Dt[7]), L.lineTo(Dt[4], Dt[5]), L.lineTo(Dt[2], Dt[3]), L.lineTo(Dt[0], Dt[1]), L.clip()); 29408 } 29409 ft.push(I), wt.push(pt); 29410 } else 29411 L.clearRect(B, z, X, V); 29412 this.drawTileImage( 29413 w, 29414 t, 29415 B, 29416 z, 29417 X, 29418 V, 29419 M, 29420 nt 29421 ), ft && !gt ? (ct && L.restore(), this.renderedTiles.unshift(w)) : this.renderedTiles.push(w), this.updateUsedTiles(t.usedTiles, u, w); 29422 } 29423 } 29424 return this.renderedRevision = d, this.renderedResolution = _, this.extentChanged = !this.renderedExtent_ || !fn(this.renderedExtent_, R), this.renderedExtent_ = R, this.renderedPixelRatio = h, this.renderedProjection = r, this.manageTilePyramid( 29425 t, 29426 u, 29427 f, 29428 h, 29429 r, 29430 m, 29431 g, 29432 c.getPreload() 29433 ), this.scheduleExpireCache(t, u), this.postRender(L, t), s.extent && L.restore(
29433), L.imageSmoothingEnabled = !0, Y !== W.style.transform && (W.style.transform = Y), this.container; 29434 } 29435 /** 29436 * @param {import("../../ImageTile.js").default} tile Tile. 29437 * @param {import("../../Map.js").FrameState} frameState Frame state. 29438 * @param {number} x Left of the tile. 29439 * @param {number} y Top of the tile. 29440 * @param {number} w Width of the tile. 29441 * @param {number} h Height of the tile. 29442 * @param {number} gutter Tile gutter. 29443 * @param {boolean} transition Apply an alpha transition. 29444 */ 29445 drawTileImage(t, i, s, n, r, o, a, l) { 29446 const h = this.getTileImage(t); 29447 if (!h) 29448 return; 29449 const c = ot(this), u = i.layerStatesArray[i.layerIndex], d = u.opacity * (l ? t.getAlpha(c, i.time) : 1), f = d !== this.context.globalAlpha; 29450 f && (this.context.save(), this.context.globalAlpha = d), this.context.drawImage( 29451 h, 29452 a, 29453 a, 29454 h.width - 2 * a, 29455 h.height - 2 * a, 29456 s, 29457 n, 29458 r, 29459 o 29460 ), f && this.context.restore(), d !== u.opacity ? i.animate = !0 : l && t.endTransition(c); 29461 } 29462 /** 29463 * @return {HTMLCanvasElement} Image 29464 */ 29465 getImage() { 29466 const t = this.context; 29467 return t ? t.canvas : null; 29468 } 29469 /** 29470 * Get the image from a tile. 29471 * @param {import("../../ImageTile.js").default} tile Tile. 29472 * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image. 29473 * @protected 29474 */ 29475 getTileImage(t) { 29476 return t.getImage(); 29477 } 29478 /** 29479 * @param {import("../../Map.js").FrameState} frameState Frame state. 29480 * @param {import("../../source/Tile.js").default} tileSource Tile source. 29481 * @protected 29482 */ 29483 scheduleExpireCache(t, i) { 29484 if (i.canExpireCache()) { 29485 const s = (function(n, r, o) { 29486 const a = ot(n); 29487 a in o.usedTiles && n.expireCache( 29488 o.viewState.projection, 29489 o.usedTiles[a] 29490 ); 29491 }).bind(null, i); 29492 t.postRenderFunctions.push( 29493 /** @type {import("../../Map.js").PostRenderFunction} */ 29494 s 29495 ); 29496 } 29497 } 29498 /** 29499 * @param {!Object<string, !Object<string, boolean>>} usedTiles Used tiles. 29500 * @param {import("../../source/Tile.js").default} tileSource Tile source. 29501 * @param {import('../../Tile.js').default} tile Tile. 29502 * @protected 29503 */ 29504 updateUsedTiles(t, i, s) { 29505 const n = ot(i); 29506 n in t || (t[n] = {}), t[n][s.getKey()] = !0; 29507 } 29508 /** 29509 * Manage tile pyramid. 29510 * This function performs a number of functions related to the tiles at the 29511 * current zoom and lower zoom levels: 29512 * - registers idle tiles in frameState.wantedTiles so that they are not 29513 * discarded by the tile queue 29514 * - enqueues missing tiles 29515 * @param {import("../../Map.js").FrameState} frameState Frame state. 29516 * @param {import("../../source/Tile.js").default} tileSource Tile source. 29517 * @param {import("../../tilegrid/TileGrid.js").default} tileGrid Tile grid. 29518 * @param {number} pixelRatio Pixel ratio. 29519 * @param {import("../../proj/Projection.js").default} projection Projection. 29520 * @param {import("../../extent.js").Extent} extent Extent. 29521 * @param {number} currentZ Current Z. 29522 * @param {number} preload Load low resolution tiles up to `preload` levels. 29523 * @param {function(import("../../Tile.js").default):void} [tileCallback] Tile callback. 29524 * @protected 29525 */ 29526 manageTilePyramid(t, i, s, n, r, o, a, l, h) { 29527 const c = ot(i); 29528 c in t.wantedTiles || (t.wantedTiles[c] = {}); 29529 const u = t.wantedTiles[c], d = t.tileQueue, f = s.getMinZoom(), g = t.viewState.rotation, _ = g ? ol( 29530 t.viewState.center, 29531 t.viewState.resolution, 29532 g, 29533 t.size 29534 ) : void 0; 29535 let m = 0, p, y, v, E, C, S; 29536 for (S = f; S <= a; ++S) 29537 for (y = s.getTileRangeForExtentAndZ(o, S, y), v = s.getResolution(S), E = y.minX; E <= y.maxX; ++E) 29538 for (C = y.minY; C <= y.maxY; ++C) 29539 g && !s.tileCoordIntersectsViewport([S, E, C], _) || (a - S <= l ? (++m, p = i.getTile(S, E, C, n, r), p.getState() == H.IDLE && (u[p.getKey()] = !0, d.isKeyQueued(p.getKey()) || d.enqueue([ 29540 p, 29541 c, 29542 s.getTileCoordCenter(p.tileCoord), 29543 v 29544 ])), h !== void 0 && h(p)) : i.useTile(S, E, C, r)); 29545 i.updateCacheSize(m, r); 29546 } 29547} 29548const YS = $S; 29549class KS extends XS { 29550 /** 29551 * @param {import("./BaseTile.js").Options<TileSourceType>} [options] Tile layer options. 29552 */ 29553 constructor(t) { 29554 super(t); 29555 } 29556 createRenderer() { 29557 return new YS(this); 29558 } 29559} 29560const VS = KS, Ug = "EPSG:27700", qS = "#263746", HS = "#a1d0ca", ZS = { 29561 "EPSG:27700": "EPSG:27700", 29562 27700: "EPSG:27700", 29563 "EPSG:4326": "EPSG:4326", 29564 4326: "EPSG:4326" 29565}; 29566function JS(e) { 29567 return e == null ? null : ZS[String(e).trim().toUpperCase()] || null; 29568} 29569const QS = /* @__PURE__ */ new Set([ 29570 "FeatureCollection", 29571 "Feature", 29572 "Point", 29573 "MultiPoint", 29574 "LineString", 29575 "MultiLineString", 29576 "Polygon", 29577 "MultiPolygon", 29578 "GeometryCollection" 29579]); 29580function tw(e) { 29581 if (typeof e != "string" || !e.trim()) 29582 return { ok: !1, message: "Invalid GeoJSON (empty response)" }; 29583 let t; 29584 try { 29585 t = JSON.parse(e); 29586 } catch { 29587 return { ok: !1, message: "Invalid GeoJSON (not JSON)" }; 29588 } 29589 return !t || typeof t != "object" || Array.isArray(t) || !QS.has(t.type) ? { ok: !1, message: 'Invalid GeoJSON (no recognised "type")' } : { ok: !0, object: t }; 29590} 29591function ew(e, t) { 29592 var s, n; 29593 const i = e == null ? "" : String(e).trim(); 29594 if (i) 29595 return JS(i); 29596 if (!((n = (s = t == null ? void 0 : t.crs) == null ? void 0 : s.properties) != null && n.name)) 29597 return Ug; 29598} 29599const Fl = (e, t) => String(t).split(".").reduce((i, s) => i == null ? void 0 : i[s], e), ed = (e) => { 29600 if (typeof e == "number") 29601 return Number.isFinite(e) ? e : null; 29602 if (typeof e == "string" && e.trim() !== "") { 29603 const t = Number(e); 29604 return Number.isFinite(t) ? t : null; 29605 } 29606 return null; 29607}; 29608function iw(e, { xField: t, yField: i } = {}) { 29609 const s = []; 29610 let n = 0; 29611 for (const r of e) { 29612 if (!r || typeof r != "object") { 29613 n++; 29614 continue; 29615 } 29616 const o = ed(Fl(r, t)), a = ed(Fl(r, i)); 29617 if (o === null || a === null) { 29618 n++; 29619 continue; 29620 } 29621 const l = { ...r }; 29622 delete l[t], delete l[i], s.push({ type: "Feature", properties: l, geometry: { type: "Point", coordinates: [o, a] } }); 29623 } 29624 return { type: "FeatureCollection", features: s, skipped: n }; 29625} 29626function sw(e, { xField: t, yField: i, recordsField: s } = {}) { 29627 const n = tw(e); 29628 if (n.ok) 29629 return { ok: !0, object: n.object, skipped: 0 }; 29630 let r; 29631 try { 29632 r = JSON.parse(e); 29633 } catch { 29634 return n; 29635 } 29636 const o = s ? Fl(r, s) : r; 29637 if (!Array.isArray(o)) 29638 return s ? { ok: !1, message: `Invalid GeoJSON, and "${s}" is not an array of records` } : n; 29639 if (!t || !i) 29640 return { ok: !1, message: "Body is an array of records, not GeoJSON: set x-field and y-field to read it" }; 29641 const a = iw(o, { xField: t, yField: i }); 29642 return { ok: !0, object: a, skipped: a.skipped }; 29643} 29644const nw = /* @__PURE__ */ new Set(["", "true", "1", "yes", "on"]), rw = /* @__PURE__ */ new Set(["false", "0", "no", "off"]); 29645function po(e, t = !1) { 29646 if (e == null) 29647 return t; 29648 if (typeof e == "boolean") 29649 return e; 29650 const i = String(e).trim().toLowerCase(); 29651 return nw.has(i) ? !0 : rw.has(i) ? !1 : t; 29652} 29653const id = (e, t) => { 29654 const i = Number(e); 29655 return Number.isFinite(i) && i > 0 ? i : t; 29656}; 29657function ow({ fillColor: e, strokeColor: t, strokeWidth: i, pointRadius: s, primary: n, secondary: r } = {}) { 29658 const o = n || qS, a = r || HS, l = t || o; 29659 return new _r({ 29660 stroke: new xi({ color: l, width: id(i, 2) }), 29661 fill: new Ei({ color: e || kg(a, 0.35) }), 29662 image: new Lr({ 29663 radius: id(s, 6), 29664 fill: new Ei({ color: e || a }), 29665 stroke: new xi({ color: l, width: 2 }) 29666 }) 29667 }); 29668} 29669const aw = { 29670 name: "XmapWebLayerWms", 29671 props: { 29672 url: { 29673 type: String, 29674 default: null 29675 }, 29676 layer: { 29677 type: String, 29678 default: null 29679 }, 29680 opacity: { 29681 type: Number, 29682 default: 100 29683 }, 29684 // Boolean-as-string: Vue's custom-element wrapper only coerces Number props. 29685 tiled: { 29686 type: String, 29687 default: null 29688 } 29689 }, 29690 created() { 29691 this.l = _n(this.buildLayer()); 29692 }, 29693 methods: { 29694 isTiled() { 29695 return po(this.tiled, !1); 29696 }, 29697 buildLayer() { 29698 const e = this.opacity / 100, t = { 29699 projection: "EPSG:27700", 29700 url: this.url, 29701 params: { LAYERS: this.layer } 29702 }; 29703 return this.isTiled() ? new VS({ 29704 opacity: e, 29705 source: new NS({ ...t, params: { ...t.params, TILED: !0 } }) 29706 }) : new BS({ 29707 opacity: e, 29708 source: new mS(t) 29709 }); 29710 } 29711 }, 29712 watch: { 29713 opacity(e) { 29714 this.l.setOpacity(e / 100); 29715 } 29716 }, 29717 mounted() { 29718 this.$parent.map.addLayer(this.l); 29719 } 29720}, lw = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", hw = "https://challenges.cloudflare.com/turnstile/"; 29721let kn = null; 29722function cw(e = globalThis.document, t = globalThis.window) { 29723 return t && t.turnstile ? Promise.resolve(t.turnstile) : kn || (kn = new Promise((i, s) => { 29724 const n = e.querySelector(`script[src^="${hw}"]`), r = n || e.createElement("script"); 29725 n || (r.src = lw, r.async = !0, r.defer = !0), r.addEventListener("load", () => { 29726 t.turnstile ? i(t.turnstile) : s(new Error("Turnstile script loaded but window.turnstile is missing")); 29727 }), r.addEventListener("error", () => { 29728 kn = null, s(new Error("Turnstile script failed to load")); 29729 }), n || e.head.appendChild(r); 29730 }), kn); 29731} 29732const uw = `.xmap-report-form{display:flex;flex-direction:column;gap:8px;font-family:Roboto,system-ui,sans-serif;
29732color:#1a1a1a}.xrf-fields{display:flex;flex-direction:column;gap:8px}.xrf-field{display:flex;flex-direction:column;gap:4px}.xrf-field label{font-size:13px;font-weight:600}.xrf-field input,.xrf-field textarea,.xrf-field select{font:inherit;padding:6px 8px;border:1px solid #b3bcc4;border-radius:4px}.xmap-report-form button{font:inherit;font-weight:600;padding:9px 14px;border:0;border-radius:4px;background:#263746;color:#fff;cursor:pointer;align-self:flex-start}.xmap-report-form button:disabled{background:#9aa7b1;cursor:not-allowed}.xrf-hint{font-size:12px;color:#505a62;margin:0}.xrf-hint.error{color:#d4351c}::slotted(.xrf-turnstile){display:block;min-height:65px}.xrf-status{font-size:13px;min-height:1.2em;margin:0}.xrf-status.error{color:#d4351c}.xrf-status.ok{color:#00703c} 29733`, dw = "https://api.hub.xmap.cloud", fw = "cf-turnstile-response", gw = "turnstile_failed", _w = "Please wait for the security check to finish, then try again.", mw = "We could not verify your browser. Please try again.", pw = "The security check could not load. Please refresh the page and try again.", yw = { 29734 name: "XmapReportForm", 29735 emits: ["xmap-report-submitted", "xmap-report-error"], 29736 props: { 29737 customer: { type: String, default: null }, 29738 target: { type: String, default: null }, 29739 apiBase: { type: String, default: dw }, 29740 geometryField: { type: String, default: "geometry" }, 29741 // Declarative schema. Accepts an Array (JS property) or a JSON string (attribute). 29742 fields: { type: [Array, String], default: () => [] }, 29743 submitLabel: { type: String, default: "Submit report" }, 29744 // Keep the drawn geometry on the map after a successful submit. Default false 29745 // preserves the existing clear-on-submit behaviour for navigate-away flows; 29746 // set it when the host prefills a form on the same page, so the citizen's 29747 // geometry does not vanish while they are still filling fields in. 29748 keepGeometry: { type: Boolean, default: !1 }, 29749 // Cloudflare Turnstile site key (public). When set, a widget is rendered above 29750 // the button and submission is refused until a token exists (XMP-2294). The 29751 // Hub verifies the token server-side; a missing/replayed token is a 403. 29752 turnstileSiteKey: { type: String, default: null } 29753 }, 29754 data() { 29755 return { 29756 slotMode: !1, 29757 submitting: !1, 29758 status: "", 29759 statusKind: "", 29760 turnstileToken: null, 29761 turnstileWidgetId: null, 29762 turnstileState: "idle" 29763 // idle | loading | ready | error 29764 }; 29765 }, 29766 computed: { 29767 hasPoint() { 29768 return ne.hasPoint; 29769 }, 29770 parsedFields() { 29771 if (Array.isArray(this.fields)) 29772 return this.fields; 29773 if (typeof this.fields == "string" && this.fields.trim()) 29774 try { 29775 return JSON.parse(this.fields); 29776 } catch { 29777 return []; 29778 } 29779 return []; 29780 }, 29781 turnstileEnabled() { 29782 return !!(this.turnstileSiteKey && String(this.turnstileSiteKey).trim()); 29783 }, 29784 canSubmit() { 29785 return !this.submitting && this.hasPoint && (!this.turnstileEnabled || !!this.turnstileToken); 29786 }, 29787 turnstileHint() { 29788 return !this.turnstileEnabled || this.turnstileToken ? "" : this.turnstileState === "error" ? pw : "Checking your browserâ¦"; 29789 } 29790 }, 29791 watch: { 29792 // `immediate` covers a key present at mount; the watcher itself covers hosts 29793 // that bind the key from config loaded after mount (the Hub does). 29794 turnstileSiteKey: { 29795 immediate: !0, 29796 handler() { 29797 this.mountTurnstile(); 29798 } 29799 } 29800 }, 29801 mounted() { 29802 const e = this.hostEl(); 29803 this.slotMode = !!(e && e.querySelectorAll("[name]").length); 29804 }, 29805 beforeUnmount() { 29806 this.removeTurnstile(); 29807 }, 29808 methods: { 29809 hostEl() { 29810 var e, t, i; 29811 return ((i = (t = (e = this.$el) == null ? void 0 : e.getRootNode) == null ? void 0 : t.call(e)) == null ? void 0 : i.host) || null; 29812 }, 29813 collectFields() { 29814 const e = {}; 29815 return ((i) => { 29816 i && i.querySelectorAll("[name]").forEach((s) => { 29817 const n = s.getAttribute("name"); 29818 n && (e[n] = s.type === "checkbox" ? s.checked : s.value); 29819 }); 29820 })(this.slotMode ? this.hostEl() : this.$refs.form), e; 29821 }, 29822 validate() { 29823 if (this.slotMode) { 29824 const e = this.hostEl(); 29825 return e ? [...e.querySelectorAll("[name]")].every( 29826 (t) => typeof t.reportValidity == "function" ? t.reportValidity() : !0 29827 ) : !0; 29828 } 29829 return this.$refs.form.reportValidity(); 29830 }, 29831 async onSubmit() { 29832 var t; 29833 if (this.submitting) 29834 return; 29835 if (!this.customer || !this.target) { 29836 this.fail('Misconfigured: "customer" and "target" are required.'); 29837 return; 29838 } 29839 if (!ne.hasPoint) { 29840 this.fail("Please add a location on the map first."); 29841 return; 29842 } 29843 if (!this.validate()) 29844 return; 29845 if (this.turnstileEnabled && !this.turnstileToken) { 29846 this.fail(_w); 29847 return; 29848 } 29849 const e = { 29850 ...this.collectFields(), 29851 [this.geometryField]: ne.geometry 29852 }; 29853 this.turnstileEnabled && (e[fw] = this.turnstileToken), this.submitting = !0, this.setStatus("Submittingâ¦", "");
29854 try { 29855 const i = await fetch(`${this.apiBase}/${this.customer}/report/${this.target}`, { 29856 method: "POST", 29857 headers: { "content-type": "application/json" }, 29858 body: JSON.stringify(e) 29859 }), s = await i.json().catch(() => ({})); 29860 if (!i.ok) { 29861 if (s.code === gw) { 29862 this.fail(mw, i.status, s.code); 29863 return; 29864 } 29865 this.fail(s.error || `Submission failed (${i.status})`, i.status, s.code); 29866 return; 29867 } 29868 const n = ((t = s.data) == null ? void 0 : t[0]) ?? {}, r = ne.geometry ? JSON.parse(JSON.stringify(ne.geometry)) : null; 29869 this.setStatus("Report submitted. Thank you.", "ok"), this.emitHost("xmap-report-submitted", { 29870 id: n.id ?? null, 29871 // The Hub aliases its columns on the way out: target_pk_value -> object_id, 29872 // geom_stats -> metadata (report-queries.js:30). Read the wire names. 29873 targetPk: n.object_id ?? null, 29874 // PK of the row created in the council's layer 29875 stats: n.metadata ?? null, 29876 // geometry stats derived server-side 29877 geometry: r 29878 }), this.keepGeometry || kb(); 29879 } catch (i) { 29880 this.fail(i.message || "Network error"); 29881 } finally { 29882 this.submitting = !1, this.turnstileEnabled && this.resetTurnstile(); 29883 } 29884 }, 29885 // --- Turnstile ------------------------------------------------------------- 29886 async mountTurnstile() { 29887 if (this.removeTurnstile(), !this.turnstileEnabled) 29888 return; 29889 this.turnstileState = "loading"; 29890 const e = this.turnstileSiteKey; 29891 try { 29892 await this.$nextTick(); 29893 const t = await cw(); 29894 if (e !== this.turnstileSiteKey) 29895 return; 29896 const i = this.ensureTurnstileContainer(); 29897 if (!i) 29898 return; 29899 this.turnstileWidgetId = t.render(i, { 29900 sitekey: e, 29901 // We hold the token in state and add it to the body ourselves, so slot 29902 // and schema mode behave identically. Cloudflare's hidden input would 29903 // otherwise be harvested by collectFields() in one mode and not the other. 29904 "response-field": !1, 29905 callback: (s) => { 29906 this.turnstileToken = s, this.turnstileState = "ready"; 29907 }, 29908 "expired-callback": () => { 29909 this.turnstileToken = null; 29910 }, 29911 "timeout-callback": () => { 29912 this.turnstileToken = null; 29913 }, 29914 "error-callback": () => { 29915 this.turnstileToken = null, this.turnstileState = "error"; 29916 } 29917 }); 29918 } catch { 29919 this.turnstileToken = null, this.turnstileState = "error"; 29920 } 29921 }, 29922 // Light-DOM container for the widget (see the template comment). The div goes on 29923 // the host element and is projected through the default <slot>. It carries no 29924 // `name`, so slot-mode harvesting and the slotMode check ignore it. 29925 ensureTurnstileContainer() { 29926 const e = this.hostEl(); 29927 if (!e) 29928 return null; 29929 let t = e.querySelector(":scope > .xrf-turnstile"); 29930 return t || (t = e.ownerDocument.createElement("div"), t.className = "xrf-turnstile", t.setAttribute("data-xmap-turnstile", ""), e.appendChild(t)), t; 29931 }, 29932 resetTurnstile() { 29933 var t; 29934 this.turnstileToken = null; 29935 const e = (t = globalThis.window) == null ? void 0 : t.turnstile; 29936 if (e && this.turnstileWidgetId != null) 29937 try { 29938 e.reset(this.turnstileWidgetId); 29939 } catch { 29940 } 29941 }, 29942 removeTurnstile() { 29943 var i, s; 29944 this.turnstileToken = null; 29945 const e = (i = globalThis.window) == null ? void 0 : i.turnstile; 29946 if (e && this.turnstileWidgetId != null) 29947 try { 29948 e.remove(this.turnstileWidgetId); 29949 } catch { 29950 } 29951 this.turnstileWidgetId = null, this.turnstileState = "idle"; 29952 const t = this.hostEl(); 29953 (s = t == null ? void 0 : t.querySelector(":scope > .xrf-turnstile")) == null || s.remove(); 29954 }, 29955 fail(e, t, i) { 29956 this.setStatus(e, "error"); 29957 const s = { status: t, message: e }; 29958 i && (s.code = i), this.emitHost("xmap-report-error", s); 29959 }, 29960 setStatus(e, t) { 29961 this.status = e, this.statusKind = t; 29962 }, 29963 emitHost(e, t) { 29964 const i = this.hostEl() || this.$el; 29965 i == null || i.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 })); 29966 } 29967 } 29968}, xw = { 29969 key: 0, 29970 class: "xrf-fields" 29971}, vw = ["for"], Ew = { key: 0 }, Mw = ["id", "name", "required", "placeholder"], Cw = ["id", "name", "required"], bw = ["value"], Sw = ["id", "name", "required"], ww = ["type", "id", "name", "required", "placeholder", "pattern"], Tw = ["disabled"], Rw = { 29972 key: 1, 29973 class: "xrf-hint" 29974}; 29975function Iw(e, t, i, s, n, r) { 29976 return Tt(), Pt("form", { 29977 ref: "form", 29978 class: "xmap-report-form",
29979 onSubmit: t[0] || (t[0] = Nf((...o) => r.onSubmit && r.onSubmit(...o), ["prevent"])) 29980 }, [ 29981 n.slotMode ? _s("", !0) : (Tt(), Pt("div", xw, [ 29982 (Tt(!0), Pt(me, null, ml(r.parsedFields, (o) => (Tt(), Pt("div", { 29983 key: o.name, 29984 class: "xrf-field" 29985 }, [ 29986 kt("label", { 29987 for: `xrf-${o.name}` 29988 }, [ 29989 Of(Di(o.label || o.name), 1), 29990 o.required ? (Tt(), Pt("span", Ew, " *")) : _s("", !0) 29991 ], 8, vw), 29992 o.type === "textarea" ? (Tt(), Pt("textarea", { 29993 key: 0, 29994 id: `xrf-${o.name}`, 29995 name: o.name, 29996 required: !!o.required, 29997 placeholder: o.placeholder || "" 29998 }, null, 8, Mw)) : o.type === "select" ? (Tt(), Pt("select", { 29999 key: 1, 30000 id: `xrf-${o.name}`, 30001 name: o.name, 30002 required: !!o.required 30003 }, [ 30004 (Tt(!0), Pt(me, null, ml(o.options || [], (a) => (Tt(), Pt("option", { 30005 key: a, 30006 value: a 30007 }, Di(a), 9, bw))), 128)) 30008 ], 8, Cw)) : o.type === "checkbox" ? (Tt(), Pt("input", { 30009 key: 2, 30010 type: "checkbox", 30011 id: `xrf-${o.name}`, 30012 name: o.name, 30013 required: !!o.required 30014 }, null, 8, Sw)) : (Tt(), Pt("input", { 30015 key: 3, 30016 type: o.type || "text", 30017 id: `xrf-${o.name}`, 30018 name: o.name, 30019 required: !!o.required, 30020 placeholder: o.placeholder || "", 30021 pattern: o.pattern || null 30022 }, null, 8, ww)) 30023 ]))), 128)) 30024 ])), 30025 xf(e.$slots, "default"), 30026 kt("button", { 30027 type: "submit", 30028 disabled: !r.canSubmit 30029 }, Di(n.submitting ? "Submittingâ¦" : i.submitLabel), 9, Tw), 30030 r.hasPoint ? r.turnstileHint ? (Tt(), Pt("p", { 30031 key: 2, 30032 class: gn(["xrf-hint", { error: n.turnstileState === "error" }]) 30033 }, Di(r.turnstileHint), 3)) : _s("", !0) : (Tt(), Pt("p", Rw, "Add a location on the map to enable submission.")), 30034 kt("p", { 30035 class: gn(["xrf-status", n.statusKind]) 30036 }, Di(n.status), 3) 30037 ], 544); 30038} 30039const Pw = /* @__PURE__ */ la(yw, [["render", Iw], ["styles", [uw]]]), Xg = "https://search.xmap.cloud", $g = { llpg: "llpg/v2", ngd: "ngd" }; 30040function Yg(e) { 30041 const t = String(e || "").toLowerCase(); 30042 return $g[t] ? t : "llpg"; 30043} 30044function Aw(e, t, i, s = "llpg") { 30045 const n = String(e || Xg).replace(/\/+$/, ""), r = $g[Yg(s)]; 30046 return `${n}/${encodeURIComponent(t)}/${r}?query=${encodeURIComponent(i)}`; 30047} 30048function Lw(e) { 30049 if (!e) 30050 return null; 30051 const t = (n) => n == null || n === "" ? NaN : Number(n), i = t(e.easting), s = t(e.northing); 30052 return !Number.isFinite(i) || !Number.isFinite(s) ? null : { 30053 address: e.postal_address || "", 30054 uprn: e.uprn != null ? String(e.uprn) : null, 30055 usrn: e.usrn != null ? String(e.usrn) : null, 30056 postcode: e.postcode || null, 30057 easting: i, 30058 northing: s, 30059 geometry: { type: "Point", coordinates: [i, s] } 30060 }; 30061} 30062function Ow(e) { 30063 var i, s; 30064 const t = ((i = e == null ? void 0 : e.data) == null ? void 0 : i.status) ?? (e == null ? void 0 : e.status); 30065 return t && t !== "success" ? ((s = e == null ? void 0 : e.data) == null ? void 0 : s.message) || (e == null ? void 0 : e.message) || `Search failed (${t})` : null; 30066} 30067function Fw(e) { 30068 return /key\s*fail|access key/i.test(String(e || "")); 30069} 30070function Dw(e, t = 10) { 30071 var n; 30072 const i = (n = e == null ? void 0 : e.data) == null ? void 0 : n.lpi; 30073 if (!Array.isArray(i)) 30074 return []; 30075 const s = []; 30076 for (const r of i) { 30077 const o = Lw(r); 30078 if (o && s.push(o), s.length >= t) 30079 break; 30080 } 30081 return s; 30082} 30083const Nw = `.xmap-address-search{position:relative;font-family:Roboto,system-ui,sans-serif;color:#1a1a1a;text-align:left}.xas-row{display:flex;gap:6px}.xmap-address-search input{font:inherit;flex:1 1 auto;min-width:0;box-sizing:border-box;padding:6px 8px;border:1px solid #b3bcc4;border-radius:4px}.xas-button{font:inherit;font-weight:600;padding:6px 12px;border:0;border-radius:4px;background:#263746;color:#fff;cursor:pointer;white-space:nowrap}.xas-button:disabled{background:#9aa7b1;cursor:not-allowed}.xas-list{position:absolute;z-index:10;left:0;right:0;margin:2px 0 0;padding:0;list-style:none;max-height:240px;overflow-y:auto;background:#fff;border:1px solid #b3bcc4;border-radius:4px;box-shadow:0 4px 12px #0000001f;font-size:13px}.xas-list li{padding:6px 8px;cursor:pointer}.xas-list li.active{background:#263746;color:#fff}.xas-note{color:#505a62;cursor:default}.xas-error{color:#d4351c} 30084`, kw = { 30085 name: "XmapAddressSearch", 30086 emits: ["xmap-address-selected", "xmap-address-error"], 30087 props: { 30088 apiBase: { type: String, default: Xg }, 30089 apiKey: { type: String, default: null }, 30090 // Which gazetteer to query: "llpg" (default) or "ngd". 30091 source: { type: String, default: "llpg" }, 30092 // "submit" (default): search on Enter or the Search button. 30093 // "typeahead": search as the user types (debounced). 30094 mode: { type: String, default: "submit" }, 30095 // Client-side cap: llpg/v2 ignores its limit param. 30096 limit: { type: [Number, String], default: 10 },
30097 minChars: { type: [Number, String], default: 3 }, 30098 placeholder: { type: String, default: "Search for an address" }, 30099 searchLabel: { type: String, default: "Search" }, 30100 // Typeahead only. Also guards the explicit path against double-fires 30101 // (Enter then an immediate click) by collapsing them into one request. 30102 debounce: { type: [Number, String], default: 300 } 30103 }, 30104 data() { 30105 return { 30106 text: "", 30107 suggestions: [], 30108 activeIndex: -1, 30109 open: !1, 30110 loading: !1, 30111 error: "", 30112 _timer: null, 30113 _controller: null 30114 }; 30115 }, 30116 computed: { 30117 activeId() { 30118 return this.activeIndex >= 0 ? `xas-opt-${this.activeIndex}` : null; 30119 }, 30120 isTypeahead() { 30121 return String(this.mode).toLowerCase() === "typeahead"; 30122 }, 30123 canSearch() { 30124 return this.text.trim().length >= Number(this.minChars); 30125 }, 30126 sourceKey() { 30127 return Yg(this.source); 30128 } 30129 }, 30130 methods: { 30131 hostEl() { 30132 var e, t, i; 30133 return ((i = (t = (e = this.$el) == null ? void 0 : e.getRootNode) == null ? void 0 : t.call(e)) == null ? void 0 : i.host) || null; 30134 }, 30135 emitHost(e, t) { 30136 const i = this.hostEl() || this.$el; 30137 i == null || i.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 })); 30138 }, 30139 onInput(e) { 30140 if (this.text = e.target.value, this.activeIndex = -1, clearTimeout(this._timer), !this.canSearch) { 30141 this.abort(), this.suggestions = [], this.open = !1; 30142 return; 30143 } 30144 if (!this.isTypeahead) { 30145 this.suggestions = [], this.open = !1; 30146 return; 30147 } 30148 this.scheduleSearch(); 30149 }, 30150 // Every search goes through one debounced timer, so rapid triggers 30151 // (keystrokes in typeahead, Enter + click in submit mode) coalesce. 30152 scheduleSearch() { 30153 clearTimeout(this._timer), this._timer = setTimeout(() => this.search(this.text.trim()), Number(this.debounce)); 30154 }, 30155 submitSearch() { 30156 this.canSearch && this.scheduleSearch(); 30157 }, 30158 onFocus() { 30159 this.suggestions.length && (this.open = !0); 30160 }, 30161 onBlur() { 30162 setTimeout(() => { 30163 this.open = !1; 30164 }, 120); 30165 }, 30166 onKeydown(e) { 30167 const t = this.open && this.suggestions.length > 0; 30168 if (e.key === "Escape") { 30169 this.open = !1; 30170 return; 30171 } 30172 if (e.key === "Enter") { 30173 e.preventDefault(), t && (this.activeIndex >= 0 || this.isTypeahead) ? this.select(this.suggestions[Math.max(this.activeIndex, 0)]) : this.submitSearch(); 30174 return; 30175 } 30176 if (!t) 30177 return; 30178 const i = this.suggestions.length; 30179 e.key === "ArrowDown" ? (e.preventDefault(), this.activeIndex = (this.activeIndex + 1) % i) : e.key === "ArrowUp" && (e.preventDefault(), this.activeIndex = (this.activeIndex - 1 + i) % i); 30180 }, 30181 abort() { 30182 this._controller && (this._controller.abort(), this._controller = null), this.loading = !1; 30183 }, 30184 async search(e) { 30185 if (!this.apiKey) { 30186 this.error = 'Misconfigured: "api-key" is required.', this.open = !0, this.emitHost("xmap-address-error", { message: this.error }); 30187 return; 30188 } 30189 this.abort(); 30190 const t = new AbortController(); 30191 this._controller = t, this.loading = !0, this.error = "", this.open = !0; 30192 try { 30193 const i = await fetch(Aw(this.apiBase, this.apiKey, e, this.sourceKey), { signal: t.signal }), s = await i.json().catch(() => ({})); 30194 if (t.signal.aborted) 30195 return; 30196 if (!i.ok) { 30197 this.fail(s.message || `Search failed (${i.status})`, i.status); 30198 return; 30199 } 30200 const n = Ow(s); 30201 if (n) { 30202 this.fail(Fw(n) ? "Address search is not configured correctly (invalid API key)." : n, i.status); 30203 return; 30204 } 30205 this.suggestions = Dw(s, Number(this.limit)), this.activeIndex = -1; 30206 } catch (i) { 30207 if (i.name === "AbortError") 30208 return; 30209 this.fail(i.message || "Network error"); 30210 } finally { 30211 this._controller === t && (this._controller = null, this.loading = !1); 30212 } 30213 }, 30214 fail(e, t) { 30215 this.suggestions = [], this.error = e, this.emitHost("xmap-address-error", { status: t, message: e }); 30216 }, 30217 select(e) { 30218 e && (this.text = e.address, this.open = !1, this.suggestions = [e], this.activeIndex = 0, this.emitHost("xmap-address-selected", JSON.parse(JSON.stringify(e)))); 30219 } 30220 }, 30221 beforeUnmount() { 30222 clearTimeout(this._timer), this.abort(); 30223 } 30224}, Gw = ["aria-expanded"], zw = { class: "xas-row" }, jw = ["placeholder", "value", "aria-activedescendant"], Ww = ["disabled"], Bw = { 30225 key: 0, 30226 id: "xas-list", 30227 class: "xas-list", 30228 role: "listbox"
30229}, Uw = { 30230 key: 0, 30231 class: "xas-note" 30232}, Xw = { 30233 key: 1, 30234 class: "xas-note xas-error" 30235}, $w = { 30236 key: 2, 30237 class: "xas-note" 30238}, Yw = ["id", "aria-selected", "onMousedown", "onMousemove"]; 30239function Kw(e, t, i, s, n, r) { 30240 return Tt(), Pt("div", { 30241 class: "xmap-address-search", 30242 role: "combobox", 30243 "aria-expanded": n.open ? "true" : "false", 30244 "aria-haspopup": "listbox", 30245 "aria-owns": "xas-list" 30246 }, [ 30247 kt("div", zw, [ 30248 kt("input", { 30249 ref: "input", 30250 type: "text", 30251 autocomplete: "off", 30252 spellcheck: "false", 30253 maxlength: "100", 30254 placeholder: i.placeholder, 30255 value: n.text, 30256 "aria-activedescendant": r.activeId, 30257 "aria-autocomplete": "list", 30258 "aria-controls": "xas-list", 30259 onInput: t[0] || (t[0] = (...o) => r.onInput && r.onInput(...o)), 30260 onKeydown: t[1] || (t[1] = (...o) => r.onKeydown && r.onKeydown(...o)), 30261 onFocus: t[2] || (t[2] = (...o) => r.onFocus && r.onFocus(...o)), 30262 onBlur: t[3] || (t[3] = (...o) => r.onBlur && r.onBlur(...o)) 30263 }, null, 40, jw), 30264 r.isTypeahead ? _s("", !0) : (Tt(), Pt("button", { 30265 key: 0, 30266 type: "button", 30267 class: "xas-button", 30268 disabled: n.loading || !r.canSearch, 30269 onClick: t[4] || (t[4] = (o) => r.submitSearch()) 30270 }, Di(i.searchLabel), 9, Ww)) 30271 ]), 30272 n.open ? (Tt(), Pt("ul", Bw, [ 30273 n.loading ? (Tt(), Pt("li", Uw, "Searchingâ¦")) : n.error ? (Tt(), Pt("li", Xw, Di(n.error), 1)) : n.suggestions.length ? _s("", !0) : (Tt(), Pt("li", $w, "No addresses found")), 30274 (Tt(!0), Pt(me, null, ml(n.suggestions, (o, a) => (Tt(), Pt("li", { 30275 key: o.uprn || a, 30276 id: `xas-opt-${a}`, 30277 role: "option", 30278 class: gn({ active: a === n.activeIndex }), 30279 "aria-selected": a === n.activeIndex ? "true" : "false", 30280 onMousedown: Nf((l) => r.select(o), ["prevent"]), 30281 onMousemove: (l) => n.activeIndex = a 30282 }, Di(o.address), 43, Yw))), 128)) 30283 ])) : _s("", !0) 30284 ], 8, Gw); 30285} 30286const Vw = /* @__PURE__ */ la(kw, [["render", Kw], ["styles", [Nw]]]); 30287class qw { 30288 constructor() { 30289 this.dataProjection = void 0, this.defaultFeatureProjection = void 0, this.supportedMediaTypes = null; 30290 } 30291 /** 30292 * Adds the data projection to the read options. 30293 * @param {Document|Element|Object|string} source Source. 30294 * @param {ReadOptions} [options] Options. 30295 * @return {ReadOptions|undefined} Options. 30296 * @protected 30297 */ 30298 getReadOptions(t, i) { 30299 if (i) { 30300 let s = i.dataProjection ? Rt(i.dataProjection) : this.readProjection(t); 30301 i.extent && s && s.getUnits() === "tile-pixels" && (s = Rt(s), s.setWorldExtent(i.extent)), i = { 30302 dataProjection: s, 30303 featureProjection: i.featureProjection 30304 }; 30305 } 30306 return this.adaptOptions(i); 30307 } 30308 /** 30309 * Sets the `dataProjection` on the options, if no `dataProjection` 30310 * is set. 30311 * @param {WriteOptions|ReadOptions|undefined} options 30312 * Options. 30313 * @protected 30314 * @return {WriteOptions|ReadOptions|undefined} 30315 * Updated options. 30316 */ 30317 adaptOptions(t) { 30318 return Object.assign( 30319 { 30320 dataProjection: this.dataProjection, 30321 featureProjection: this.defaultFeatureProjection 30322 }, 30323 t 30324 ); 30325 } 30326 /** 30327 * @abstract 30328 * @return {Type} The format type. 30329 */ 30330 getType() { 30331 return Z(); 30332 } 30333 /** 30334 * Read a single feature from a source. 30335 * 30336 * @abstract 30337 * @param {Document|Element|Object|string} source Source. 30338 * @param {ReadOptions} [options] Read options. 30339 * @return {import("../Feature.js").FeatureLike} Feature. 30340 */ 30341 readFeature(t, i) { 30342 return Z(); 30343 } 30344 /** 30345 * Read all features from a source. 30346 * 30347 * @abstract 30348 * @param {Document|Element|ArrayBuffer|Object|string} source Source. 30349 * @param {ReadOptions} [options] Read options. 30350 * @return {Array<import("../Feature.js").FeatureLike>} Features. 30351 */ 30352 readFeatures(t, i) { 30353 return Z(); 30354 } 30355 /** 30356 * Read a single geometry from a source. 30357 * 30358 * @abstract 30359 * @param {Document|Element|Object|string} source Source. 30360 * @param {ReadOptions} [options] Read options. 30361 * @return {import("../geom/Geometry.js").default} Geometry. 30362 */ 30363 readGeometry(t, i) { 30364 return Z(); 30365 } 30366 /** 30367 * Read the projection from a source. 30368 * 30369 * @abstract
30370 * @param {Document|Element|Object|string} source Source. 30371 * @return {import("../proj/Projection.js").default|undefined} Projection. 30372 */ 30373 readProjection(t) { 30374 return Z(); 30375 } 30376 /** 30377 * Encode a feature in this format. 30378 * 30379 * @abstract 30380 * @param {import("../Feature.js").default} feature Feature. 30381 * @param {WriteOptions} [options] Write options. 30382 * @return {string|ArrayBuffer} Result. 30383 */ 30384 writeFeature(t, i) { 30385 return Z(); 30386 } 30387 /** 30388 * Encode an array of features in this format. 30389 * 30390 * @abstract 30391 * @param {Array<import("../Feature.js").default>} features Features. 30392 * @param {WriteOptions} [options] Write options. 30393 * @return {string|ArrayBuffer} Result. 30394 */ 30395 writeFeatures(t, i) { 30396 return Z(); 30397 } 30398 /** 30399 * Write a single geometry in this format. 30400 * 30401 * @abstract 30402 * @param {import("../geom/Geometry.js").default} geometry Geometry. 30403 * @param {WriteOptions} [options] Write options. 30404 * @return {string|ArrayBuffer} Result. 30405 */ 30406 writeGeometry(t, i) { 30407 return Z(); 30408 } 30409} 30410function Kg(e, t, i) { 30411 const s = i ? Rt(i.featureProjection) : null, n = i ? Rt(i.dataProjection) : null; 30412 let r; 30413 if (s && n && !di(s, n) ? r = (t ? e.clone() : e).transform( 30414 t ? s : n, 30415 t ? n : s 30416 ) : r = e, t && i && /** @type {WriteOptions} */ 30417 i.decimals !== void 0) { 30418 const o = Math.pow( 30419 10, 30420 /** @type {WriteOptions} */ 30421 i.decimals 30422 ), a = function(l) { 30423 for (let h = 0, c = l.length; h < c; ++h) 30424 l[h] = Math.round(l[h] * o) / o; 30425 return l; 30426 }; 30427 r === e && (r = e.clone()), r.applyTransform(a); 30428 } 30429 return r; 30430} 30431class Hw extends qw { 30432 constructor() { 30433 super(); 30434 } 30435 /** 30436 * @return {import("./Feature.js").Type} Format. 30437 */ 30438 getType() { 30439 return "json"; 30440 } 30441 /** 30442 * Read a feature. Only works for a single feature. Use `readFeatures` to 30443 * read a feature collection. 30444 * 30445 * @param {ArrayBuffer|Document|Element|Object|string} source Source. 30446 * @param {import("./Feature.js").ReadOptions} [options] Read options. 30447 * @return {import("../Feature.js").default} Feature. 30448 * @api 30449 */ 30450 readFeature(t, i) { 30451 return this.readFeatureFromObject( 30452 ao(t), 30453 this.getReadOptions(t, i) 30454 ); 30455 } 30456 /** 30457 * Read all features. Works with both a single feature and a feature 30458 * collection. 30459 * 30460 * @param {ArrayBuffer|Document|Element|Object|string} source Source. 30461 * @param {import("./Feature.js").ReadOptions} [options] Read options. 30462 * @return {Array<import("../Feature.js").default>} Features. 30463 * @api 30464 */ 30465 readFeatures(t, i) { 30466 return this.readFeaturesFromObject( 30467 ao(t), 30468 this.getReadOptions(t, i) 30469 ); 30470 } 30471 /** 30472 * @abstract 30473 * @param {Object} object Object. 30474 * @param {import("./Feature.js").ReadOptions} [options] Read options. 30475 * @protected 30476 * @return {import("../Feature.js").default} Feature. 30477 */ 30478 readFeatureFromObject(t, i) { 30479 return Z(); 30480 } 30481 /** 30482 * @abstract 30483 * @param {Object} object Object. 30484 * @param {import("./Feature.js").ReadOptions} [options] Read options. 30485 * @protected 30486 * @return {Array<import("../Feature.js").default>} Features. 30487 */ 30488 readFeaturesFromObject(t, i) { 30489 return Z(); 30490 } 30491 /** 30492 * Read a geometry. 30493 * 30494 * @param {ArrayBuffer|Document|Element|Object|string} source Source. 30495 * @param {import("./Feature.js").ReadOptions} [options] Read options. 30496 * @return {import("../geom/Geometry.js").default} Geometry. 30497 * @api 30498 */ 30499 readGeometry(t, i) { 30500 return this.readGeometryFromObject( 30501 ao(t), 30502 this.getReadOptions(t, i) 30503 ); 30504 } 30505 /** 30506 * @abstract 30507 * @param {Object} object Object. 30508 * @param {import("./Feature.js").ReadOptions} [options] Read options. 30509 * @protected 30510 * @return {import("../geom/Geometry.js").default} Geometry. 30511 */ 30512 readGeometryFromObject(t, i) { 30513 return Z(); 30514 } 30515 /** 30516 * Read the projection. 30517 * 30518 * @param {ArrayBuffer|Document|Element|Object|string} source Source. 30519 * @return {import("../proj/Projection.js").default} Projection. 30520 * @api 30521 */ 30522 readProjection(t) { 30523 return this.readProjectionFromObject(ao(t)); 30524 } 30525 /** 30526 * @abstract 30527 * @param {Object} object Object. 30528 * @protected 30529 * @return {import("../proj/Projection.js").default} Projection. 30530 */ 30531 readProjectionFromObject(t) { 30532 return Z(); 30533 } 30534 /** 30535 * Encode a feature as string. 30536 * 30537 * @param {import("../Feature.js").default} feature Feature. 30538 * @param {import("./Feature.js").WriteOptions} [options] Write options. 30539 * @return {string} Encoded feature. 30540 * @api 30541 */
30542 writeFeature(t, i) { 30543 return JSON.stringify(this.writeFeatureObject(t, i)); 30544 } 30545 /** 30546 * @abstract 30547 * @param {import("../Feature.js").default} feature Feature. 30548 * @param {import("./Feature.js").WriteOptions} [options] Write options. 30549 * @return {Object} Object. 30550 */ 30551 writeFeatureObject(t, i) { 30552 return Z(); 30553 } 30554 /** 30555 * Encode an array of features as string. 30556 * 30557 * @param {Array<import("../Feature.js").default>} features Features. 30558 * @param {import("./Feature.js").WriteOptions} [options] Write options. 30559 * @return {string} Encoded features. 30560 * @api 30561 */ 30562 writeFeatures(t, i) { 30563 return JSON.stringify(this.writeFeaturesObject(t, i)); 30564 } 30565 /** 30566 * @abstract 30567 * @param {Array<import("../Feature.js").default>} features Features. 30568 * @param {import("./Feature.js").WriteOptions} [options] Write options. 30569 * @return {Object} Object. 30570 */ 30571 writeFeaturesObject(t, i) { 30572 return Z(); 30573 } 30574 /** 30575 * Encode a geometry as string. 30576 * 30577 * @param {import("../geom/Geometry.js").default} geometry Geometry. 30578 * @param {import("./Feature.js").WriteOptions} [options] Write options. 30579 * @return {string} Encoded geometry. 30580 * @api 30581 */ 30582 writeGeometry(t, i) { 30583 return JSON.stringify(this.writeGeometryObject(t, i)); 30584 } 30585 /** 30586 * @abstract 30587 * @param {import("../geom/Geometry.js").default} geometry Geometry. 30588 * @param {import("./Feature.js").WriteOptions} [options] Write options. 30589 * @return {Object} Object. 30590 */ 30591 writeGeometryObject(t, i) { 30592 return Z(); 30593 } 30594} 30595function ao(e) { 30596 if (typeof e == "string") { 30597 const t = JSON.parse(e); 30598 return t || null; 30599 } 30600 return e !== null ? e : null; 30601} 30602const Zw = Hw; 30603class Jw extends Zw { 30604 /** 30605 * @param {Options} [options] Options. 30606 */ 30607 constructor(t) { 30608 t = t || {}, super(), this.dataProjection = Rt( 30609 t.dataProjection ? t.dataProjection : "EPSG:4326" 30610 ), t.featureProjection && (this.defaultFeatureProjection = Rt(t.featureProjection)), this.geometryName_ = t.geometryName, this.extractGeometryName_ = t.extractGeometryName, this.supportedMediaTypes = [ 30611 "application/geo+json", 30612 "application/vnd.geo+json" 30613 ]; 30614 } 30615 /** 30616 * @param {Object} object Object. 30617 * @param {import("./Feature.js").ReadOptions} [options] Read options. 30618 * @protected 30619 * @return {import("../Feature.js").default} Feature. 30620 */ 30621 readFeatureFromObject(t, i) { 30622 let s = null; 30623 t.type === "Feature" ? s = /** @type {GeoJSONFeature} */ 30624 t : s = { 30625 type: "Feature", 30626 geometry: ( 30627 /** @type {GeoJSONGeometry} */ 30628 t 30629 ), 30630 properties: null 30631 }; 30632 const n = Dl(s.geometry, i), r = new Ni(); 30633 return this.geometryName_ ? r.setGeometryName(this.geometryName_) : this.extractGeometryName_ && "geometry_name" in s !== void 0 && r.setGeometryName(s.geometry_name), r.setGeometry(n), "id" in s && r.setId(s.id), s.properties && r.setProperties(s.properties, !0), r; 30634 } 30635 /** 30636 * @param {Object} object Object. 30637 * @param {import("./Feature.js").ReadOptions} [options] Read options. 30638 * @protected 30639 * @return {Array<Feature>} Features. 30640 */ 30641 readFeaturesFromObject(t, i) { 30642 const s = ( 30643 /** @type {GeoJSONObject} */ 30644 t 30645 ); 30646 let n = null; 30647 if (s.type === "FeatureCollection") { 30648 const r = ( 30649 /** @type {GeoJSONFeatureCollection} */ 30650 t 30651 ); 30652 n = []; 30653 const o = r.features; 30654 for (let a = 0, l = o.length; a < l; ++a) 30655 n.push(this.readFeatureFromObject(o[a], i)); 30656 } else 30657 n = [this.readFeatureFromObject(t, i)]; 30658 return n; 30659 } 30660 /** 30661 * @param {GeoJSONGeometry} object Object. 30662 * @param {import("./Feature.js").ReadOptions} [options] Read options. 30663 * @protected 30664 * @return {import("../geom/Geometry.js").default} Geometry. 30665 */ 30666 readGeometryFromObject(t, i) { 30667 return Dl(t, i); 30668 } 30669 /** 30670 * @param {Object} object Object. 30671 * @protected 30672 * @return {import("../proj/Projection.js").default} Projection. 30673 */ 30674 readProjectionFromObject(t) { 30675 const i = t.crs; 30676 let s; 30677 return i ? i.type == "name" ? s = Rt(i.properties.name) : i.type === "EPSG" ? s = Rt("EPSG:" + i.properties.code) : at(!1, 36) : s = this.dataProjection, /** @type {import("../proj/Projection.js").default} */ 30678 s; 30679 } 30680 /** 30681 * Encode a feature as a GeoJSON Feature object. 30682 * 30683 * @param {import("../Feature.js").default} feature Feature. 30684 * @param {import("./Feature.js").WriteOptions} [options] Write options. 30685 * @return {GeoJSONFeature} Object. 30686 * @api 30687 */ 30688 writeFeatureObject(t, i) { 30689 i = this.adaptOptions(i); 30690 const s = { 30691 type: "Feature", 30692 geometry: null, 30693 properties: null 30694 }, n = t.getId(); 30695 if (n !== void 0 && (s.id = n), !t.hasProperties()) 30696 return s; 30697 const r = t.getProperties(), o = t.getGeometry(); 30698 return o && (s.geometry = Nl(o, i), delete r[t.getGeometryName()]), un(r) || (s.properties = r), s; 30699 } 30700 /** 30701 * Encode an array of features as a GeoJSON object. 30702 * 30703 * @param {Array<import("../Feature.js").default>} features Features. 30704 * @param {import("./Feature.js").WriteOptions} [options] Write options. 30705 * @return {GeoJSONFeatureCollection} GeoJSON Object. 30706 * @api 30707 */ 30708 writeFeaturesObject(t, i) { 30709 i = this.adaptOptions(i); 30710 const s = []; 30711 for (let n = 0, r = t.length; n < r; ++n) 30712 s.push(this.writeFeatureObject(t[n], i)); 30713 return { 30714 type: "FeatureCollection", 30715 features: s 30716 }; 30717 } 30718 /** 30719 * Encode a geometry as a GeoJSON object. 30720 * 30721 * @param {import("../geom/Geometry.js").default} geometry Geometry. 30722 * @param {import("./Feature.js").WriteOptions} [options] Write options. 30723 * @return {GeoJSONGeometry|GeoJSONGeometryCollection} Object. 30724 * @api 30725 */ 30726 writeGeometryObject(t, i) { 30727 return Nl(t, this.adaptOptions(i)); 30728 } 30729} 30730function Dl(e, t) { 30731 if (!e) 30732 return null; 30733 let i; 30734 switch (e.type) { 30735 case "Point": { 30736 i = tT( 30737 /** @type {GeoJSONPoint} */ 30738 e 30739 ); 30740 break; 30741 } 30742 case "LineString": { 30743 i = eT( 30744 /** @type {GeoJSONLineString} */ 30745 e 30746 ); 30747 break; 30748 } 30749 case "Polygon": { 30750 i = rT( 30751 /** @type {GeoJSONPolygon} */ 30752 e 30753 ); 30754 break; 30755 } 30756 case "MultiPoint": { 30757 i = sT( 30758 /** @type {GeoJSONMultiPoint} */ 30759 e 30760 ); 30761 break; 30762 } 30763 case "MultiLineString": { 30764 i = iT( 30765 /** @type {GeoJSONMultiLineString} */ 30766 e 30767 ); 30768 break; 30769 } 30770 case "MultiPolygon": { 30771 i = nT( 30772 /** @type {GeoJSONMultiPolygon} */ 30773 e 30774 ); 30775 break; 30776 } 30777 case "GeometryCollection": { 30778 i = Qw( 30779 /** @type {GeoJSONGeometryCollection} */ 30780 e 30781 ); 30782 break; 30783 } 30784 default: 30785 throw new Error("Unsupported GeoJSON type: " + e.type); 30786 } 30787 return Kg(i, !1, t); 30788} 30789function Qw(e, t) { 30790 const i = e.geometries.map( 30791 /** 30792 * @param {GeoJSONGeometry} geometry Geometry. 30793 * @return {import("../geom/Geometry.js").default} geometry Geometry. 30794 */ 30795 function(s) { 30796 return Dl(s, t); 30797 } 30798 ); 30799 return new Og(i); 30800} 30801function tT(e) { 30802 return new pi(e.coordinates); 30803} 30804function eT(e) { 30805 return new ys(e.coordinates); 30806} 30807function iT(e) { 30808 return new Jh(e.coordinates); 30809} 30810function sT(e) { 30811 return new tc(e.coordinates); 30812} 30813function nT(e) { 30814 return new ec(e.coordinates); 30815} 30816function rT(e) { 30817 return new En(e.coordinates); 30818} 30819function Nl(e, t) { 30820 e = Kg(e, !0, t); 30821 const i = e.getType(); 30822 let s; 30823 switch (i) { 30824 case "Point": { 30825 s = uT( 30826 /** @type {Point} */ 30827 e 30828 ); 30829 break; 30830 } 30831 case "LineString": { 30832 s = aT( 30833 /** @type {LineString} */ 30834 e 30835 ); 30836 break; 30837 } 30838 case "Polygon": { 30839 s = dT( 30840 /** @type {Polygon} */ 30841 e, 30842 t 30843 ); 30844 break; 30845 } 30846 case "MultiPoint": { 30847 s = hT( 30848 /** @type {MultiPoint} */ 30849 e 30850 ); 30851 break; 30852 } 30853 case "MultiLineString": { 30854 s = lT( 30855 /** @type {MultiLineString} */ 30856 e 30857 ); 30858 break; 30859 } 30860 case "MultiPolygon": { 30861 s = cT( 30862 /** @type {MultiPolygon} */ 30863 e, 30864 t 30865 ); 30866 break; 30867 } 30868 case "GeometryCollection": { 30869 s = oT( 30870 /** @type {GeometryCollection} */ 30871 e, 30872 t 30873 ); 30874 break; 30875 } 30876 case "Circle": { 30877 s = { 30878 type: "GeometryCollection", 30879 geometries: [] 30880 }; 30881 break; 30882 } 30883 default: 30884 throw new Error("Unsupported geometry type: " + i); 30885 } 30886 return s; 30887} 30888function oT(e, t) { 30889 return t = Object.assign({}, t), delete t.featureProjection, { 30890 type: "GeometryCollection", 30891 geometries: e.getGeometriesArray().map(function(s) { 30892 return Nl(s, t); 30893 }) 30894 }; 30895} 30896function aT(e, t) { 30897 return { 30898 type: "LineString", 30899 coordinates: e.getCoordinates() 30900 }; 30901} 30902function lT(e, t) { 30903 return { 30904 type: "MultiLineString", 30905 coordinates: e.getCoordinates() 30906 }; 30907} 30908function hT(e, t) { 30909 return { 30910 type: "MultiPoint", 30911 coordinates: e.getCoordinates() 30912 }; 30913} 30914function cT(e, t) { 30915 let i; 30916 return t && (i = t.rightHanded), { 30917 type: "MultiPolygon", 30918 coordinates: e.getCoordinates(i) 30919 }; 30920} 30921function uT(e, t) { 30922 return { 30923 type: "Point", 30924 coordinates: e.getCoordinates() 30925 }; 30926} 30927function dT(e, t) { 30928 let i; 30929 return t && (i = t.rightHanded), { 30930 type: "Polygon", 30931 coordinates: e.getCoordinates(i) 30932 }; 30933} 30934const fT = Jw, gT = { 30935 name: "XmapWebLayerGeoJson", 30936 // Nothing to render: the layer lives on the parent's map. An explicit null 30937 // render keeps Vue from warning about a missing template. 30938 render() { 30939 return null; 30940 }, 30941 // Defaults so a layer placed outside <xmap-app> (or in a test) does not warn. 30942 inject: { 30943 primaryColor: { default: null }, 30944 secondaryColor: { default: null } 30945 }, 30946 props: { 30947 // Fetched on mount and on change. Ignored while `data` is non-empty. 30948 url: { type: String, default: null }, 30949 // Inline GeoJSON text. Wins over `url`. 30950 data: { type: String, default: null }, 30951 // EPSG:27700 (default) | EPSG:4326. Absent + a `crs` member â OL reads the member. 30952 projection: { type: String, default: null }, 30953 // 0â100, as the WMS layer. 30954 opacity: { type: Number, default: 100 }, 30955 // String, not Boolean: Vue only coerces Number attributes, so a Boolean prop 30956 // would make visible="false" truthy. Read through boolAttr(). 30957 visible: { type: String, default: null }, 30958 // Fit the view to the loaded extent once per load (XMP-2228 guard applies). 30959 fit: { type: String, default: null }, 30960 fillColor: { type: String, default: null }, 30961 strokeColor: { type: String, default: null }, 30962 strokeWidth: { type: Number, default: 2 }, 30963 pointRadius: { type: Number, default: 6 }, 30964 // For bodies that are an array of records rather than GeoJSON: the keys 30965 // holding the point coordinates, and optionally the key (dotted path) of 30966 // the array inside a wrapping object. Each record becomes a Point.
30967 xField: { type: String, default: null }, 30968 yField: { type: String, default: null }, 30969 recordsField: { type: String, default: null } 30970 }, 30971 methods: { 30972 // Walk up to the component that owns the map rather than reading 30973 // this.$parent.map blind. window.XMAP_MAP is deliberately not used: it holds 30974 // only the last map to mount, so two maps on one page would cross-wire. 30975 resolveMapComponent() { 30976 let e = this.$parent; 30977 for (; e; ) { 30978 if (e.map) 30979 return e; 30980 e = e.$parent; 30981 } 30982 return null; 30983 }, 30984 currentStyle() { 30985 return ow({ 30986 fillColor: this.fillColor, 30987 strokeColor: this.strokeColor, 30988 strokeWidth: this.strokeWidth, 30989 pointRadius: this.pointRadius, 30990 primary: this.primaryColor, 30991 secondary: this.secondaryColor 30992 }); 30993 }, 30994 ensureLayer() { 30995 this._layer || (this._source = _n(new ya()), this._layer = _n(new pa({ 30996 source: this._source, 30997 // Above the WMS layers (no zIndex â 0), below the draw layer (100): the 30998 // user's own drawing is never hidden behind loaded data. 30999 zIndex: 50, 31000 style: this.currentStyle(), 31001 opacity: this.opacity / 100, 31002 visible: po(this.visible, !0) 31003 }))); 31004 }, 31005 applyStyle() { 31006 this._layer && this._layer.setStyle(this.currentStyle()); 31007 }, 31008 abort() { 31009 this._controller && (this._controller.abort(), this._controller = null); 31010 }, 31011 // Re-read the source. Precedence: data (trimmed, non-empty) â url â empty 31012 // layer. Both absent is not an error; it is an empty layer and emits nothing. 31013 async reload() { 31014 if (this.abort(), this._fitted = !1, !this._source) 31015 return; 31016 const e = typeof this.data == "string" ? this.data.trim() : ""; 31017 if (e) { 31018 this.setFromText(e); 31019 return; 31020 } 31021 if (!this.url) { 31022 this._source.clear(); 31023 return; 31024 } 31025 const t = new AbortController(); 31026 this._controller = t; 31027 try { 31028 const i = await fetch(this.url, { signal: t.signal }), s = await i.text(); 31029 if (t.signal.aborted) 31030 return; 31031 if (!i.ok) { 31032 this.fail(`Layer request failed (${i.status})`); 31033 return; 31034 } 31035 this.setFromText(s); 31036 } catch (i) { 31037 if ((i == null ? void 0 : i.name) === "AbortError") 31038 return; 31039 this.fail((i == null ? void 0 : i.message) || "Network error"); 31040 } finally { 31041 this._controller === t && (this._controller = null); 31042 } 31043 }, 31044 setFromText(e) { 31045 if (!this._source) 31046 return; 31047 const t = sw(e, { xField: this.xField, yField: this.yField, recordsField: this.recordsField }); 31048 if (!t.ok) { 31049 this.fail(t.message); 31050 return; 31051 } 31052 const i = ew(this.projection, t.object); 31053 if (i === null) { 31054 this.fail(`Unsupported projection "${this.projection}" (use EPSG:27700 or EPSG:4326)`); 31055 return; 31056 } 31057 let s; 31058 try { 31059 s = new fT().readFeatures(t.object, { 31060 ...i ? { dataProjection: i } : {}, 31061 featureProjection: Ug 31062 }); 31063 } catch (n) { 31064 this.fail(`Invalid GeoJSON (${(n == null ? void 0 : n.message) || "unreadable geometry"})`); 31065 return; 31066 } 31067 this._source.clear(), this._source.addFeatures(s), this.emitHost("xmap-layer-loaded", { count: s.length, skipped: t.skipped }), this.maybeFit(); 31068 }, 31069 // Once per load, only when `fit` is on. Delegates to the map component's 31070 // fitToExtent so the XMP-2228 sized-map guard applies. maxZoom is not 31071 // optional: a single point has a zero-size extent and view.fit would 31072 // otherwise zoom to the view's maximum. 31073 maybeFit() { 31074 var t, i; 31075 if (this._fitted || !this._source || !po(this.fit, !1)) 31076 return; 31077 const e = this._source.getExtent(); 31078 Ts(e) || (this._fitted = !0, (i = (t = this._mapComponent) == null ? void 0 : t.fitToExtent) == null || i.call(t, e, { padding: [24, 24, 24, 24], maxZoom: 18 })); 31079 }, 31080 // Every failure path: clear our own source, touch nothing else on the map. 31081 fail(e) { 31082 this._source && this._source.clear(), this.emitHost("xmap-layer-error", { message: e }); 31083 }, 31084 // Dispatch on the custom-element host so the event reaches the host page. 31085 // A template-less component's $el is Vue's placeholder comment inside the 31086 // shadow root; getRootNode().host on it is still the custom element. 31087 emitHost(e, t) { 31088 var s, n, r; 31089 const i = ((r = (n = (s = this.$el) == null ? void 0 : s.getRootNode) == null ? void 0 : n.call(s)) == null ? void 0 : r.host) || this.$el; 31090 i == null || i.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 })); 31091 }, 31092 // False when no parent map is reachable; otherwise the (truthy) promise of 31093 // the first load, so callers can await it. 31094 // 31095 // The first load is deferred to the next task on purpose. Custom elements 31096 // upgrade synchronously when the bundle defines them, so an inline `data` 31097 // load would emit xmap-layer-loaded before a host script placed after the 31098 // bundle has added its listener, and the event would be lost. A microtask 31099 // is not enough: the browser runs a microtask checkpoint between scripts. 31100 attach() { 31101 const e = this.resolveMapComponent(); 31102 return e ? (this._mapComponent = e, this.ensureLayer(), e.map.addLayer(this._layer), new Promise((t) => setTimeout(() => t(this.reload()), 0))) : !1; 31103 } 31104 }, 31105 watch: { 31106 url() { 31107 this.reload(); 31108 }, 31109 data() { 31110 this.reload(); 31111 }, 31112 projection() { 31113 this.reload(); 31114 }, 31115 xField() { 31116 this.reload(); 31117 }, 31118 yField() { 31119 this.reload(); 31120 }, 31121 recordsField() { 31122 this.reload(); 31123 }, 31124 opacity(e) { 31125 this._layer && this._layer.setOpacity(e / 100); 31126 }, 31127 visible(e) { 31128 this._layer && this._layer.setVisible(po(e, !0)); 31129 }, 31130 fit() { 31131 this._fitted = !1, this.maybeFit(); 31132 }, 31133 fillColor() { 31134 this.applyStyle(); 31135 }, 31136 strokeColor() { 31137 this.applyStyle(); 31138 }, 31139 strokeWidth() { 31140 this.applyStyle(); 31141 }, 31142 pointRadius() { 31143 this.applyStyle(); 31144 } 31145 }, 31146 mounted() { 31147 this.attach() || this.$nextTick(() => { 31148 this.attach() || this.emitHost("xmap-layer-error", { message: "<xmap-web-layer-geojson> must be a child of <xmap-web-map>" }); 31149 }); 31150 }, 31151 beforeUnmount() { 31152 var t; 31153 this.abort(); 31154 const e = (t = this._mapComponent) == null ? void 0 : t.map; 31155 e && this._layer && e.removeLayer(this._layer), this._layer = null, this._source = null, this._mapComponent = null; 31156 } 31157}; 31158xe.defs("EPSG:27700", "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs"); 31159o1(xe); 31160const _T = Rt("EPSG:27700"); 31161_T.setExtent([0, 0, 7e5, 13e5]); 31162const mT = Tn(Wv), pT = Tn(nS), yT = Tn(aw), xT = Tn(Pw), vT = Tn(Vw), ET = Tn(gT), In = (e, t) => { 31163 customElements.get(e) || customElements.define(e, t); 31164}; 31165In("xmap-app", mT); 31166In("xmap-web-map", pT); 31167In("xmap-web-layer-wms", yT); 31168In("xmap-report-form", xT); 31169In("xmap-address-search", vT); 31170In("xmap-web-layer-geojson", ET);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.