UNPKG

geoserver-terrain-1saglayici

Version:

839 lines (838 loc) 40.5 kB
"use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } var v = window.Cesium; function G(e, r) { var t = Math.max(e.west, r.west), i = Math.min(e.east, r.east), a = Math.max(e.south, r.south), n = Math.min(e.north, r.north), l; return i <= t || a >= n ? l = null : l = new v.Rectangle(t, a, i, n), l; } var D = [{ name: "CRS:84", ellipsoid: v.Ellipsoid.WGS84, firstAxeIsLatitude: !1, tilingScheme: v.GeographicTilingScheme, supportedCRS: "urn:ogc:def:crs:OGC:2:84" }, { name: "EPSG:4326", ellipsoid: v.Ellipsoid.WGS84, firstAxeIsLatitude: !0, tilingScheme: v.GeographicTilingScheme, supportedCRS: "urn:ogc:def:crs:EPSG::4326" }, { name: "EPSG:3857", ellipsoid: v.Ellipsoid.WGS84, firstAxeIsLatitude: !1, tilingScheme: v.WebMercatorTilingScheme, supportedCRS: "urn:ogc:def:crs:EPSG::3857" }, { name: "OSGEO:41001", ellipsoid: v.Ellipsoid.WGS84, firstAxeIsLatitude: !1, tilingScheme: v.WebMercatorTilingScheme, supportedCRS: "urn:ogc:def:crs:EPSG::3857" }]; var H = [{ format: "image/png", extension: "png" }, { format: "image/jpeg", extension: "jpg" }, { format: "image/jpeg", extension: "jpeg" }, { format: "image/gif", extension: "gif" }, { format: "image/png; mode=8bit", extension: "png" }]; var X = [{ format: "image/bil", postProcessArray: function postProcessArray(e, r, t, i, a) { var n = null, l = new DataView(e), g = new ArrayBuffer(r.height * r.width * 2), f = new DataView(g); if (g.byteLength === e.byteLength) { var d, p = 0, x = 0; for (var y = 0; y < g.byteLength; y += 2) if (d = l.getInt16(y, !1) - a, d > i && d < t) f.setInt16(y, d, !0), x += d, p++;else { var I = p === 0 ? 1 : x / p; f.setInt16(y, I, !0); } n = new Int16Array(g); } return n; } }]; var k = { service: "WMS", maxLevel: 11, heightMapWidth: 65, heightMapHeight: 65, offset: 0, highest: 12000, lowest: -500, hasStyledImage: !1 }, O = { heightScale: 1, heightOffset: 0, elementsPerHeight: 1, stride: 1, elementMultiplier: 256, isBigEndian: !1, lowestEncodedHeight: 0, highestEncodedHeight: 10000 }; function W(e, r) { r.heightMapWidth = e.heightMapWidth, r.heightMapHeight = e.heightMapHeight, r.ready = !1, r.maximumLevel = e.maxLevel, r.levelZeroMaximumGeometricError = void 0, r.offset = e.offset, r.highest = e.highest, r.lowest = e.lowest, r.hasStyledImage = e.hasStyledImage || typeof e.styleName == "string"; } function V(e, r, t, i) { return i.postProcessArray(e, t, r.highest, r.lowest, r.offset); } function Y(e, r, t, i) { var a = v.getImagePixels(e, t.width, t.height), n = new Int16Array(a.length / 4), l = 0, g = 0; for (var f = 0; f < a.length; f += 4) { var d = a[f], p = a[f + 1], x = a[f + 2] > 128, y = (d << 8 | p) - r.offset - 32768; y > r.lowest && y < r.highest && (x || i) ? (n[f / 4] = y, g += y, l++) : n[f / 4] = l === 0 ? 0 : g / l; } return n; } var Z = window.Cesium, Q = Z.Resource.fetchXML; function K(_x) { return _K.apply(this, arguments); } function _K() { _K = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(e) { var r; return _regeneratorRuntime().wrap(function _callee5$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: if (!e.url) { _context5.next = 9; break; } _context5.next = 3; return Q({ url: e.url + "/gwc/service/tms/1.0.0" }); case 3: e.xml = _context5.sent; _context5.next = 6; return j(e); case 6: r = _context5.sent; _context5.next = 16; break; case 9: if (!e.xml) { _context5.next = 15; break; } _context5.next = 12; return j(e); case 12: r = _context5.sent; _context5.next = 16; break; case 15: throw new Error("either description.url or description.xml are required."); case 16: return _context5.abrupt("return", r); case 17: case "end": return _context5.stop(); } }, _callee5); })); return _K.apply(this, arguments); } function j(_x2) { return _j.apply(this, arguments); } function _j() { _j = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(e) { var r, t, i; return _regeneratorRuntime().wrap(function _callee6$(_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: r = e.xml; if (r instanceof XMLDocument) { _context6.next = 3; break; } throw new Error("xml must be a XMLDocument"); case 3: if (!(r.querySelector("TileMapService") !== null)) { _context6.next = 12; break; } if (e.layerName) { _context6.next = 6; break; } throw new Error("layerName is required."); case 6: i = Array.from(r.querySelectorAll("TileMap[title='" + e.layerName + "']")).map(function (a) { var n = a.getAttribute("href"); return e.proxy && (n = e.proxy.getURL(n)), Q({ url: n }).then(function (l) { return e.xml = l, z(e); }); }); _context6.next = 9; return Promise.race(i); case 9: t = _context6.sent; _context6.next = 13; break; case 12: t = z(e); case 13: return _context6.abrupt("return", t); case 14: case "end": return _context6.stop(); } }, _callee6); })); return _j.apply(this, arguments); } function z(e) { var r = e.xml, t = {}; W(e, t); var i = e.maxLevel, a = e.proxy, n = r.querySelector("SRS").textContent, l = D.find(function (m) { return m.name === n; }); l && (t.tilingScheme = new l.tilingScheme({ ellipsoid: l.ellipsoid })); var g = r.querySelector("TileFormat"), f = H.find(function (m) { return m.extension == g.getAttribute("extension"); }); f && (t.formatImage = f, t.imageSize = { width: parseInt(g.getAttribute("width"), 10), height: parseInt(g.getAttribute("height"), 10) }); var d = Array.from(r.querySelectorAll("TileSets>TileSet")), p = []; if (t.formatImage && (p = d.map(function (m) { var o = m.getAttribute("href") + "/{x}/{tmsY}." + t.formatImage.extension; a && (o = a.getURL(o)); var u = parseInt(m.getAttribute("order")); return { url: o, level: u }; }), p.sort(function (m, o) { return m.level - o.level; })), p.length === 0 || !t.formatImage || !t.tilingScheme) throw new Error("no tilesets, no formatImage and no formatArray"); t.URLtemplateImage = function (m, o, u) { var b = ""; return u < p.length && (b = p[u].url), b; }; var x = r.querySelector("BoundingBox"), y = parseFloat(x.getAttribute("miny")), I = parseFloat(x.getAttribute("maxy")), L = parseFloat(x.getAttribute("minx")), c = parseFloat(x.getAttribute("maxx")), S = new Z.Rectangle(L, y, c, I); return t.getTileDataAvailable = function (m, o, u) { var b = t.tilingScheme.tileXYToNativeRectangle(m, o, u); return G(S, b) !== null && u < i && u < p.length; }, t.ready = !0, t; } var _ = window.Cesium, ae = _.Resource.fetchXML; function $(_x3) { return _$.apply(this, arguments); } function _$() { _$ = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(e) { var r, t, i, a; return _regeneratorRuntime().wrap(function _callee7$(_context7) { while (1) switch (_context7.prev = _context7.next) { case 0: if (!e.url) { _context7.next = 12; break; } t = e.url, i = t.lastIndexOf("?"); i > -1 && (t = t.substring(0, i)); a = t + "/ows?SERVICE=WMS&REQUEST=GetCapabilities&tiled=true"; console.log(a); e.proxy && (a = e.proxy.getURL(a)); _context7.next = 8; return ae({ url: a }); case 8: e.xml = _context7.sent; r = J(e); _context7.next = 17; break; case 12: if (!e.xml) { _context7.next = 16; break; } r = J(e); _context7.next = 17; break; case 16: throw new Error("either description.url or description.xml are required."); case 17: return _context7.abrupt("return", r); case 18: case "end": return _context7.stop(); } }, _callee7); })); return _$.apply(this, arguments); } function J(e) { if (!(e.xml instanceof XMLDocument)) throw new Error("xml must be a XMLDocument"); if (!e.layerName) throw new Error("description.layerName is required."); var r = e.xml, t = {}, i = e.layerName, a = e.maxLevel, n = null, l = { width: 65, height: 65 }, g; W(e, t), t.formatImage = e.formatImage, t.formatArray = e.formatArray, t.tilingScheme = void 0; var f, d, p = e.styleName, x = r.querySelector("[version]"); x !== null && (n = x.getAttribute("version"), d = /^1\.[3-9]\./.test(n)); var y = r.querySelector("Request>GetMap OnlineResource").getAttribute("xlink:href"), I = y.indexOf("?"); I > -1 && (y = y.substring(0, I)), e.proxy && (y = e.proxy.getURL(y)); var L = Array.from(r.querySelectorAll("Request>GetMap>Format")).map(function (m) { return m.textContent; }); var _loop = function _loop(m) { t.formatImage || (t.formatImage = H.find(function (o) { return o.format === L[m]; })), t.formatArray || (t.formatArray = X.find(function (o) { return o.format === L[m]; })); }; for (var m = 0; m < L.length; m++) { _loop(m); } t.formatArray && typeof t.formatArray.format == "string" && typeof t.formatArray.postProcessArray == "function" ? t.formatArray.terrainDataStructure = Object.assign({}, O) : delete t.formatArray, (!t.formatImage || typeof t.formatImage.format != "string") && (t.formatImage = void 0); var c = r.querySelectorAll("Layer[queryable='1'],Layer[queryable='true']"), S = null; for (var _m = 0; _m < c.length && S === null; _m++) if (c[_m].querySelector("Name").textContent === i) { S = c[_m]; var o = S.getAttribute("fixedHeight"), u = S.getAttribute("fixedWidth"); o !== null && (o = parseInt(o, 10), t.heightMapHeight = o > 0 && o < t.heightMapHeight ? o : t.heightMapHeight, l.height = o > 0 ? o : l.height), u !== null && (u = parseInt(u, 10), t.heightMapWidth = u > 0 && u < t.heightMapWidth ? u : t.heightMapWidth, l.width = u > 0 ? u : l.width); } if (S !== null && n !== null) { var _m2 = !1; var _loop2 = function _loop2() { var s = D[b], R = s.name, h = S.querySelector("BoundingBox[SRS='" + R + "'],BoundingBox[CRS='" + R + "']"); if (h !== null) { g = R, f = s.firstAxeIsLatitude, t.tilingScheme = new s.tilingScheme({ ellipsoid: s.ellipsoid }); var A, F, w, T; f && d ? (A = parseFloat(h.getAttribute("miny")), F = parseFloat(h.getAttribute("maxy")), w = parseFloat(h.getAttribute("minx")), T = parseFloat(h.getAttribute("maxx"))) : (A = parseFloat(h.getAttribute("minx")), F = parseFloat(h.getAttribute("maxx")), w = parseFloat(h.getAttribute("miny")), T = parseFloat(h.getAttribute("maxy"))); var M = new _.Rectangle(A, w, F, T); t.getTileDataAvailable = function (C, E, q) { var U = !1, ie = t.tilingScheme.tileXYToNativeRectangle(C, E, q); return q < a && (U = G(M, ie) !== null), U; }, _m2 = !0; } }; for (var b = 0; b < D.length && !_m2; b++) { _loop2(); } if (p) { var _b = S.querySelectorAll("Style>Name"), s = !1; for (var R = 0; R < _b.length && !s; R++) p === _b[R].textContent && (s = !0); s || (p = null); } var _o = r.querySelectorAll("VendorSpecificCapabilities>TileSet"), _u = !1; for (var _b2 = 0; _b2 < _o.length && !_u; _b2++) { var _s = _o[_b2].querySelector("BoundingBox[SRS='" + g + "'],BoundingBox[CRS='" + g + "']") !== null; _o[_b2].querySelector("Layers").textContent === i && _s && (l.width = parseInt(_o[_b2].querySelector("Width").textContent, 10), l.height = parseInt(_o[_b2].querySelector("Height").textContent, 10), _u = !0); } t.ready = _m2 && (t.formatImage || t.formatArray) && n !== null; } if (t.ready) { var _m3 = y + "?SERVICE=WMS&REQUEST=GetMap&layers=" + i + "&version=" + n + "&bbox="; if (d && f ? _m3 += "{south},{west},{north},{east}" : _m3 += "{west},{south},{east},{north}", _m3 += "&crs=" + g + "&srs=" + g, t.formatImage) { var _o2 = _m3 + "&format=" + t.formatImage.format + "&width=" + l.width + "&height=" + l.height; p && (_o2 += "&styles=" + p + "&style=" + p), t.URLtemplateImage = function () { return _o2; }, t.imageSize = l; } if (t.formatArray) { var _o3 = _m3 + "&format=" + t.formatArray.format + "&width=" + t.heightMapWidth + "&height=" + t.heightMapHeight; t.URLtemplateArray = function () { return _o3; }; } } return t; } var ne = window.Cesium, oe = ne.Resource.fetchXML; function te(_x4) { return _te.apply(this, arguments); } function _te() { _te = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(e) { var r, t, i, a; return _regeneratorRuntime().wrap(function _callee8$(_context8) { while (1) switch (_context8.prev = _context8.next) { case 0: if (!e.url) { _context8.next = 11; break; } t = e.url, i = t.lastIndexOf("?"); i > -1 && (t = t.substring(0, i)); a = t + "/gwc/service/wmts?REQUEST=GetCapabilities"; e.proxy && (a = e.proxy.getURL(a)); _context8.next = 7; return oe({ url: a }); case 7: e.xml = _context8.sent; r = ee(e); _context8.next = 16; break; case 11: if (!e.xml) { _context8.next = 15; break; } r = ee(e); _context8.next = 16; break; case 15: throw new Error("either description.url or description.xml are required."); case 16: return _context8.abrupt("return", r); case 17: case "end": return _context8.stop(); } }, _callee8); })); return _te.apply(this, arguments); } function ee(e) { var r = e.xml; if (!(r instanceof XMLDocument)) throw new Error("xml must be a XMLDocument"); var t = {}, i = e.layerName; W(e, t); var a = e.maxLevel, n = e.proxy, l = e.styleName, g = null, f = [], d = null, p = null, x = null; Array.from(r.querySelectorAll('Operation[name="GetTile"] HTTP Get')).map(function (c) { return { node: c, type: c.querySelector("Value").textContent }; }).forEach(function (c) { c.type === "RESTful" && p === null && (p = c.node.getAttribute("xlink:href"), n && (p = n.getURL(p))), c.type === "KVP" && d === null && (d = c.node.getAttribute("xlink:href"), n && (d = n.getURL(d))); }); var y = r.querySelectorAll("Contents>Layer>Identifier"), I = null; for (var c = 0; c < y.length && I === null; c++) i === y[c].textContent && (I = y[c].parentNode); if (I !== null) { var _c, S; Array.from(I.querySelectorAll("Style")).forEach(function (o) { var u = o.querySelector("Identifier").textContent; o.getAttribute("isDefault") != null && (_c = u), u === l && (S = u); }), (!l || l !== S) && (l = _c || ""); var m = Array.from(I.querySelectorAll("Format")); var _loop3 = function _loop3(o) { m.filter(function (b) { return b.textContent === H[o].format; }).length > 0 && (x = H[o]); }; for (var o = 0; o < H.length && x === null; o++) { _loop3(o); } f = Array.from(I.querySelectorAll("TileMatrixSetLink")); } var L = Array.from(r.querySelectorAll("TileMatrixSet>Identifier")); var _loop4 = function _loop4() { var S = f[_c2], m = S.querySelector("TileMatrixSet").textContent, o = null, u = null; for (var s = 0; s < L.length && o === null; s++) L[s].textContent === m && (o = L[s].parentNode); var b = o.querySelector("SupportedCRS").textContent; for (var _s2 = 0; _s2 < D.length && u === null; _s2++) D[_s2].supportedCRS === b && (u = D[_s2]); if (u !== null) { var _s3 = Array.from(o.querySelectorAll("TileMatrix")).map(function (h) { var A = h.querySelector("Identifier").textContent, F = parseInt(h.querySelector("MatrixWidth").textContent, 10), w = parseInt(h.querySelector("MatrixHeight").textContent, 10), T = parseInt(h.querySelector("TileWidth").textContent, 10), M = parseInt(h.querySelector("TileHeight").textContent, 10), C = parseFloat(h.querySelector("ScaleDenominator").textContent); return { id: A, maxWidth: F, maxHeight: w, scaleDenominator: C, complete: !1, tileWidth: T, tileHeight: M }; }).sort(function (h, A) { return A.scaleDenominator - h.scaleDenominator; }), R = Array.from(S.querySelectorAll("TileMatrixSetLimits>TileMatrixLimits")).map(function (h) { return { id: h.querySelector("TileMatrix").textContent, bbox: { minTileRow: parseInt(h.querySelector("MinTileRow").textContent, 10), maxTileRow: parseInt(h.querySelector("MaxTileRow").textContent, 10), minTileCol: parseInt(h.querySelector("MinTileCol").textContent, 10), maxTileCol: parseInt(h.querySelector("MaxTileCol").textContent, 10) } }; }); if (_s3.forEach(function (h) { R.forEach(function (A) { h.id === A.id && (h.bbox = A.bbox, h.complete = !0); }); }), _s3.length > 0) { t.tilingScheme = new u.tilingScheme({ ellipsoid: u.ellipsoid, numberOfLevelZeroTilesX: _s3[0].maxWidth, numberOfLevelZeroTilesY: _s3[0].maxHeight }); var h = I.querySelector("ResourceURL[format='" + x.format + "']"); if (h !== null ? g = h.getAttribute("template").replace("{TileRow}", "{y}").replace("{TileCol}", "{x}").replace("{style}", l).replace("{Style}", l).replace("{TileMatrixSet}", m).replace("{layer}", i).replace("{infoFormatExtension}", x.extension) : d !== null && (g = d + "service=WMTS&request=GetTile&version=1.0.0&layer=" + i + "&style=" + l + "&format=" + x.format + "&TileMatrixSet=" + m + "&TileMatrix={TileMatrix}&TileRow={y}&TileCol={x}"), g !== null) { t.getTileDataAvailable = function (w, T, M) { var C = !1; if (M < a && M < _s3.length) { var E = _s3[M], q = E.bbox; E.complete ? C = T <= q.maxTileRow && T >= q.minTileRow && w <= q.maxTileCol && w >= q.minTileCol : C = w < E.maxWidth && T < E.maxHeight; } return C; }, t.URLtemplateImage = function (w, T, M) { var C = ""; if (t.getTileDataAvailable(w, T, M)) { var E = _s3[M]; C = g.replace("{TileMatrix}", E.id); } return C; }; var A = { width: _s3[0].tileWidth, height: _s3[0].tileHeight }; _s3.filter(function (w) { return w.tileWidth != A.width || w.tileHeight != A.height; }).length === 0 && (t.imageSize = A), t.ready = !0; } } } }; for (var _c2 = 0; _c2 < f.length && !t.ready; _c2++) { _loop4(); } return t; } var P = window.Cesium, _P$Resource = P.Resource, Le = _P$Resource.fetchArrayBuffer, De = _P$Resource.fetchImage, N = /*#__PURE__*/function () { function N(r) { var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; _classCallCheck(this, N); _defineProperty(this, "errorEvent", new P.Event()); _defineProperty(this, "credit", void 0); _defineProperty(this, "tilingScheme", void 0); _defineProperty(this, "ready", !1); _defineProperty(this, "hasVertexNormals", !1); _defineProperty(this, "readyPromise", void 0); _defineProperty(this, "hasWaterMask", void 0); _defineProperty(this, "heightMapHeight", void 0); _defineProperty(this, "heightMapWidth", void 0); _defineProperty(this, "availability", void 0); this.credit = new P.Credit(t), this.tilingScheme = r.tilingScheme, this.getTileDataAvailable = r.getTileDataAvailable, this.hasWaterMask = !1, this.heightMapHeight = r.heightMapHeight, this.heightMapWidth = r.heightMapWidth, this.availability = new P.TileAvailability(this.tilingScheme, r.maximumLevel), this.getLevelMaximumGeometricError = function (i) { return r.levelZeroMaximumGeometricError / (1 << i); }, this.requestTileGeometry = /*#__PURE__*/function () { var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(i, a, n) { var l, g, f; return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return r.GeometryCallback(i, a, n); case 2: g = _context.sent; f = le(i, a, n, r); return _context.abrupt("return", new P.HeightmapTerrainData({ buffer: g, width: r.heightMapWidth, height: r.heightMapHeight, childTileMask: f })); case 5: case "end": return _context.stop(); } }, _callee); })); return function (_x5, _x6, _x7) { return _ref.apply(this, arguments); }; }(), this.ready = r.ready, this.readyPromise = new Promise(function (i) { return !0; }); } return _createClass(N, [{ key: "requestTileGeometry", value: function requestTileGeometry(r, t, i, a) { throw new Error("Method not implemented."); } }, { key: "getLevelMaximumGeometricError", value: function getLevelMaximumGeometricError(r) { throw new Error("Method not implemented."); } }, { key: "getTileDataAvailable", value: function getTileDataAvailable(r, t, i) { throw new Error("Method not implemented."); } }]); }(); function le(e, r, t, i) { var a = 0, n = t + 1; return a |= i.getTileDataAvailable(2 * e, 2 * r, n) ? 1 : 0, a |= i.getTileDataAvailable(2 * e + 1, 2 * r, n) ? 2 : 0, a |= i.getTileDataAvailable(2 * e, 2 * r + 1, n) ? 4 : 0, a |= i.getTileDataAvailable(2 * e + 1, 2 * r + 1, n) ? 8 : 0, a; } var B = window.Cesium, _B$Resource = B.Resource, me = _B$Resource.fetchArrayBuffer, se = _B$Resource.fetchImage; function ue(_x8) { return _ue.apply(this, arguments); } function _ue() { _ue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(e) { var r, t; return _regeneratorRuntime().wrap(function _callee9$(_context9) { while (1) switch (_context9.prev = _context9.next) { case 0: e = Object.assign(k, e); _context9.t0 = e.service; _context9.next = _context9.t0 === "TMS" ? 4 : _context9.t0 === "WMTS" ? 6 : 8; break; case 4: r = K(e); return _context9.abrupt("break", 9); case 6: r = te(e); return _context9.abrupt("break", 9); case 8: r = $(e); case 9: _context9.next = 11; return r; case 11: t = _context9.sent; return _context9.abrupt("return", (he(t), e.service === "WMTS" ? new N(t) : new B.CustomHeightmapTerrainProvider({ height: t.heightMapHeight, width: t.heightMapWidth, tilingScheme: t.tilingScheme, callback: t.GeometryCallback }))); case 13: case "end": return _context9.stop(); } }, _callee9); })); return _ue.apply(this, arguments); } window.Cesium.GeoserverTerrainProvider = ue; function he(e) { e.levelZeroMaximumGeometricError = B.TerrainProvider.getEstimatedLevelZeroGeometricErrorForAHeightmap(e.tilingScheme.ellipsoid, e.heightMapWidth, e.tilingScheme.getNumberOfXTilesAtLevel(0)), e.URLtemplateImage && (e.getBufferImage = /*#__PURE__*/function () { var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(r, t, i) { var a, n, l; return _regeneratorRuntime().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: a = null; if (isNaN(r + t + i)) { _context2.next = 6; break; } n = re(e.URLtemplateImage(r, t, i), r, t, i, e), l = { highest: e.highest, lowest: e.lowest, offset: e.offset }; _context2.next = 5; return se({ url: n }).then(function (f) { return Y(f, l, { width: e.heightMapWidth, height: e.heightMapHeight }, e.hasStyledImage); })["catch"](function () { return new Int16Array(e.heightMapWidth * e.heightMapHeight); }); case 5: a = _context2.sent; case 6: return _context2.abrupt("return", a); case 7: case "end": return _context2.stop(); } }, _callee2); })); return function (_x9, _x10, _x11) { return _ref2.apply(this, arguments); }; }()), e.URLtemplateArray && (e.getBufferArray = /*#__PURE__*/function () { var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(r, t, i) { var a, n, l; return _regeneratorRuntime().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: a = null; if (isNaN(r + t + i)) { _context3.next = 6; break; } n = re(e.URLtemplateArray(r, t, i), r, t, i, e), l = { highest: e.highest, lowest: e.lowest, offset: e.offset }; _context3.next = 5; return me({ url: n }).then(function (f) { return V(f, l, { width: e.heightMapWidth, height: e.heightMapHeight }, e.formatArray); })["catch"](function () { return new Int16Array(e.heightMapWidth * e.heightMapHeight); }); case 5: a = _context3.sent; case 6: return _context3.abrupt("return", a); case 7: case "end": return _context3.stop(); } }, _callee3); })); return function (_x12, _x13, _x14) { return _ref3.apply(this, arguments); }; }()), e.GeometryCallback = /*#__PURE__*/function () { var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(r, t, i) { var a; return _regeneratorRuntime().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (!e.getBufferArray) { _context4.next = 6; break; } _context4.next = 3; return e.getBufferArray(r, t, i); case 3: a = _context4.sent; _context4.next = 11; break; case 6: _context4.t0 = e.getBufferImage; if (!_context4.t0) { _context4.next = 11; break; } _context4.next = 10; return e.getBufferImage(r, t, i); case 10: a = _context4.sent; case 11: return _context4.abrupt("return", a); case 12: case "end": return _context4.stop(); } }, _callee4); })); return function (_x15, _x16, _x17) { return _ref4.apply(this, arguments); }; }(); } function re(e, r, t, i, a) { var n = a.tilingScheme.tileXYToNativeRectangle(r, t, i), l = (n.east - n.west) / (a.heightMapWidth - 1), g = (n.north - n.south) / (a.heightMapHeight - 1); n.west -= l * .5, n.east += l * .5, n.south -= g * .5, n.north += g * .5; var d = a.tilingScheme.getNumberOfYTilesAtLevel(i) - t - 1; return e.replace("{south}", n.south.toString()).replace("{north}", n.north.toString()).replace("{west}", n.west.toString()).replace("{east}", n.east.toString()).replace("{x}", r.toString()).replace("{y}", t.toString()).replace("{tmsY}", d.toString()); }