ElevationQuery-H57OAGAY.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. import {
  2. fn,
  3. rn
  4. } from "./chunk-DH2OBAUC.js";
  5. import "./chunk-TNLRDNTC.js";
  6. import "./chunk-TERAW6FT.js";
  7. import {
  8. R,
  9. c as c2,
  10. f,
  11. u,
  12. w as w2
  13. } from "./chunk-N2663GRX.js";
  14. import {
  15. z
  16. } from "./chunk-O4FY3ITT.js";
  17. import "./chunk-UXF37FQ4.js";
  18. import "./chunk-ZOEK6QHJ.js";
  19. import "./chunk-XNLG7T2T.js";
  20. import "./chunk-IR4PV7VK.js";
  21. import "./chunk-2Z6LERTI.js";
  22. import {
  23. m,
  24. m2
  25. } from "./chunk-OWVBLVP3.js";
  26. import {
  27. a
  28. } from "./chunk-WJ3OEUD3.js";
  29. import "./chunk-MXB2XLKV.js";
  30. import "./chunk-HNOZUNJ4.js";
  31. import "./chunk-VNFRAYHO.js";
  32. import "./chunk-R5IG2D6H.js";
  33. import "./chunk-VBRY5KJM.js";
  34. import "./chunk-PDKDCAAD.js";
  35. import {
  36. M,
  37. j2 as j
  38. } from "./chunk-ECW2QABR.js";
  39. import "./chunk-GCDJLKH4.js";
  40. import "./chunk-MRJEICT6.js";
  41. import "./chunk-Y3WMVFTW.js";
  42. import "./chunk-SAS7RONY.js";
  43. import "./chunk-WSRBH7BF.js";
  44. import "./chunk-IHXECKQQ.js";
  45. import {
  46. E,
  47. w,
  48. y
  49. } from "./chunk-ULGDPLM2.js";
  50. import {
  51. s,
  52. s3 as s2
  53. } from "./chunk-EMJ4ZSM2.js";
  54. import "./chunk-IKP3YN53.js";
  55. import {
  56. c,
  57. r,
  58. t
  59. } from "./chunk-GZT4BVFP.js";
  60. import "./chunk-A5ICIBVI.js";
  61. // node_modules/@arcgis/core/layers/support/ElevationSampler.js
  62. var m3 = s.getLogger("esri.layers.support.ElevationSampler");
  63. var c3 = class {
  64. queryElevation(e2) {
  65. return h(e2.clone(), this);
  66. }
  67. on() {
  68. return g;
  69. }
  70. projectIfRequired(e2, t2) {
  71. return f2(e2, t2);
  72. }
  73. };
  74. var u2 = class extends c3 {
  75. constructor(e2, t2, n) {
  76. super(), this.tile = e2, this.noDataValue = n, this.extent = f(e2.tile.extent, t2.spatialReference), this.extent.zmin = e2.zmin, this.extent.zmax = e2.zmax, this.aaExtent = e2.tile.extent;
  77. const o = z(t2.spatialReference), a2 = t2.lodAt(e2.tile.level).resolution * o;
  78. this.demResolution = { min: a2, max: a2 };
  79. }
  80. get spatialReference() {
  81. return this.extent.spatialReference;
  82. }
  83. contains(e2) {
  84. const n = this.projectIfRequired(e2, this.spatialReference);
  85. return !t(n) && this.containsAt(n.x, n.y);
  86. }
  87. containsAt(e2, t2) {
  88. return w2(this.aaExtent, e2, t2);
  89. }
  90. elevationAt(e2, t2) {
  91. if (!this.containsAt(e2, t2)) {
  92. const n = this.extent, s3 = `${n.xmin}, ${n.ymin}, ${n.xmax}, ${n.ymax}`;
  93. return m3.warn("#elevationAt()", `Point used to sample elevation (${e2}, ${t2}) is outside of the sampler extent (${s3})`), this.noDataValue;
  94. }
  95. return c(this.tile.sample(e2, t2), this.noDataValue);
  96. }
  97. };
  98. var p = class extends c3 {
  99. constructor(e2, t2, n) {
  100. let s3;
  101. super(), typeof t2 == "number" ? (this.noDataValue = t2, s3 = null) : (s3 = t2, this.noDataValue = n), this.samplers = s3 ? e2.map((e3) => new u2(e3, s3, this.noDataValue)) : e2;
  102. const o = this.samplers[0];
  103. if (o) {
  104. this.extent = o.extent.clone();
  105. const { min: e3, max: t3 } = o.demResolution;
  106. this.demResolution = { min: e3, max: t3 };
  107. for (let n2 = 1; n2 < this.samplers.length; n2++) {
  108. const e4 = this.samplers[n2];
  109. this.extent.union(e4.extent), this.demResolution.min = Math.min(this.demResolution.min, e4.demResolution.min), this.demResolution.max = Math.max(this.demResolution.max, e4.demResolution.max);
  110. }
  111. } else
  112. this.extent = f(u(), s3.spatialReference), this.demResolution = { min: 0, max: 0 };
  113. }
  114. get spatialReference() {
  115. return this.extent.spatialReference;
  116. }
  117. elevationAt(e2, t2) {
  118. for (const n of this.samplers)
  119. if (n.containsAt(e2, t2))
  120. return n.elevationAt(e2, t2);
  121. return m3.warn("#elevationAt()", `Point used to sample elevation (${e2}, ${t2}) is outside of the sampler`), this.noDataValue;
  122. }
  123. };
  124. function h(e2, t2) {
  125. const n = f2(e2, t2.spatialReference);
  126. if (!n)
  127. return null;
  128. switch (e2.type) {
  129. case "point":
  130. x(e2, n, t2);
  131. break;
  132. case "polyline":
  133. R2(e2, n, t2);
  134. break;
  135. case "multipoint":
  136. d(e2, n, t2);
  137. }
  138. return e2;
  139. }
  140. function f2(e2, n) {
  141. if (t(e2))
  142. return null;
  143. const s3 = e2.spatialReference;
  144. if (s3.equals(n))
  145. return e2;
  146. const i2 = M(e2, n);
  147. return i2 || m3.error(`Cannot project geometry spatial reference (wkid:${s3.wkid}) to elevation sampler spatial reference (wkid:${n.wkid})`), i2;
  148. }
  149. function x(e2, t2, n) {
  150. e2.z = n.elevationAt(t2.x, t2.y);
  151. }
  152. function R2(e2, t2, n) {
  153. y2.spatialReference = t2.spatialReference;
  154. const s3 = e2.hasM && !e2.hasZ;
  155. for (let i2 = 0; i2 < e2.paths.length; i2++) {
  156. const o = e2.paths[i2], a2 = t2.paths[i2];
  157. for (let e3 = 0; e3 < o.length; e3++) {
  158. const t3 = o[e3], i3 = a2[e3];
  159. y2.x = i3[0], y2.y = i3[1], s3 && (t3[3] = t3[2]), t3[2] = n.elevationAt(y2.x, y2.y);
  160. }
  161. }
  162. e2.hasZ = true;
  163. }
  164. function d(e2, t2, n) {
  165. y2.spatialReference = t2.spatialReference;
  166. const s3 = e2.hasM && !e2.hasZ;
  167. for (let i2 = 0; i2 < e2.points.length; i2++) {
  168. const o = e2.points[i2], a2 = t2.points[i2];
  169. y2.x = a2[0], y2.y = a2[1], s3 && (o[3] = o[2]), o[2] = n.elevationAt(y2.x, y2.y);
  170. }
  171. e2.hasZ = true;
  172. }
  173. var y2 = new j();
  174. var g = { remove() {
  175. } };
  176. // node_modules/@arcgis/core/layers/support/ElevationTile.js
  177. var i = class {
  178. constructor(a2, i2 = null) {
  179. if (this.tile = a2, this.zmin = 0, this.zmax = 0, r(i2)) {
  180. const t2 = a2.extent;
  181. this.samplerData = { pixelData: i2.values, width: i2.width, height: i2.height, safeWidth: 0.99999999 * (i2.width - 1), noDataValue: i2.noDataValue, dx: (i2.width - 1) / (t2[2] - t2[0]), dy: (i2.width - 1) / (t2[3] - t2[1]), x0: t2[0], y1: t2[3] }, this.zmin = i2.minValue, this.zmax = i2.maxValue;
  182. }
  183. }
  184. sample(t2, i2) {
  185. if (t(this.samplerData))
  186. return;
  187. const { safeWidth: h2, width: s3, pixelData: l, noDataValue: n, dx: o, dy: r2, y1: m4, x0: d2 } = this.samplerData, u3 = e(r2 * (m4 - i2), 0, h2), x3 = e(o * (t2 - d2), 0, h2), f3 = Math.floor(u3), c4 = Math.floor(x3), p2 = f3 * s3 + c4, D = p2 + s3, w4 = l[p2], y3 = l[D], V = l[p2 + 1], z2 = l[D + 1];
  188. if (w4 !== n && y3 !== n && V !== n && z2 !== n) {
  189. const t3 = x3 - c4, a2 = w4 + (V - w4) * t3;
  190. return a2 + (y3 + (z2 - y3) * t3 - a2) * (u3 - f3);
  191. }
  192. }
  193. };
  194. function e(t2, a2, i2) {
  195. return t2 < a2 ? a2 : t2 > i2 ? i2 : t2;
  196. }
  197. // node_modules/@arcgis/core/layers/support/ElevationQuery.js
  198. var v = class {
  199. async queryAll(e2, i2, o) {
  200. if (!(e2 = o && o.ignoreInvisibleLayers ? e2.filter((e3) => e3.visible) : e2.slice()).length)
  201. throw new s2("elevation-query:invalid-layer", "Elevation queries require at least one elevation layer to fetch tiles from");
  202. const s3 = x2.fromGeometry(i2);
  203. let l = false;
  204. o && o.returnSampleInfo || (l = true);
  205. const n = { ...R3, ...o, returnSampleInfo: true }, a2 = await this.query(e2[e2.length - 1], s3, n), r2 = await this._queryAllContinue(e2, a2, n);
  206. return r2.geometry = r2.geometry.export(), l && delete r2.sampleInfo, r2;
  207. }
  208. async query(e2, i2, o) {
  209. if (!e2)
  210. throw new s2("elevation-query:invalid-layer", "Elevation queries require an elevation layer to fetch tiles from");
  211. if (!i2 || !(i2 instanceof x2) && i2.type !== "point" && i2.type !== "multipoint" && i2.type !== "polyline")
  212. throw new s2("elevation-query:invalid-geometry", "Only point, polyline and multipoint geometries can be used to query elevation");
  213. const s3 = { ...R3, ...o }, l = new w3(e2, i2.spatialReference, s3), n = s3.signal;
  214. return await e2.load({ signal: n }), await this._createGeometryDescriptor(l, i2, n), await this._selectTiles(l, n), await this._populateElevationTiles(l, n), this._sampleGeometryWithElevation(l), this._createQueryResult(l, n);
  215. }
  216. async createSampler(e2, i2, o) {
  217. if (!e2)
  218. throw new s2("elevation-query:invalid-layer", "Elevation queries require an elevation layer to fetch tiles from");
  219. if (!i2 || i2.type !== "extent")
  220. throw new s2("elevation-query:invalid-extent", "Invalid or undefined extent");
  221. const s3 = { ...R3, ...o };
  222. return this._createSampler(e2, i2, s3);
  223. }
  224. async createSamplerAll(e2, i2, o) {
  225. if (!(e2 = o && o.ignoreInvisibleLayers ? e2.filter((e3) => e3.visible) : e2.slice()).length)
  226. throw new s2("elevation-query:invalid-layer", "Elevation queries require at least one elevation layer to fetch tiles from");
  227. if (!i2 || i2.type !== "extent")
  228. throw new s2("elevation-query:invalid-extent", "Invalid or undefined extent");
  229. const s3 = { ...R3, ...o, returnSampleInfo: true }, l = await this._createSampler(e2[e2.length - 1], i2, s3);
  230. return this._createSamplerAllContinue(e2, i2, l, s3);
  231. }
  232. async _createSampler(e2, t2, i2, o) {
  233. const s3 = i2.signal;
  234. await e2.load({ signal: s3 });
  235. const l = t2.spatialReference, n = e2.tileInfo.spatialReference;
  236. l.equals(n) || (await fn([{ source: l, dest: n }], { signal: s3 }), t2 = rn(t2, n));
  237. const a2 = new _(e2, t2, i2, o);
  238. return await this._selectTiles(a2, s3), await this._populateElevationTiles(a2, s3), new p(a2.elevationTiles, a2.layer.tileInfo, a2.options.noDataValue);
  239. }
  240. async _createSamplerAllContinue(e2, t2, i2, o) {
  241. if (e2.pop(), !e2.length)
  242. return i2;
  243. const s3 = i2.samplers.map((e3) => c2(e3.extent)), l = await this._createSampler(e2[e2.length - 1], t2, o, s3);
  244. if (l.samplers.length === 0)
  245. return i2;
  246. const n = i2.samplers.concat(l.samplers), a2 = new p(n, o.noDataValue);
  247. return this._createSamplerAllContinue(e2, t2, a2, o);
  248. }
  249. async _queryAllContinue(e2, t2, i2) {
  250. const o = e2.pop(), s3 = t2.geometry.coordinates, l = [], n = [];
  251. for (let c4 = 0; c4 < s3.length; c4++) {
  252. const i3 = t2.sampleInfo[c4];
  253. i3.demResolution >= 0 ? i3.source || (i3.source = o) : e2.length && (l.push(s3[c4]), n.push(c4));
  254. }
  255. if (!e2.length || l.length === 0)
  256. return t2;
  257. const a2 = t2.geometry.clone(l), r2 = await this.query(e2[e2.length - 1], a2, i2);
  258. return n.forEach((e3, i3) => {
  259. s3[e3].z = r2.geometry.coordinates[i3].z, t2.sampleInfo[e3].demResolution = r2.sampleInfo[i3].demResolution;
  260. }), this._queryAllContinue(e2, t2, i2);
  261. }
  262. async _createQueryResult(e2, t2) {
  263. const i2 = { geometry: (await e2.geometry.project(e2.outSpatialReference, t2)).export(), noDataValue: e2.options.noDataValue };
  264. return e2.options.returnSampleInfo && (i2.sampleInfo = this._extractSampleInfo(e2)), e2.geometry.coordinates.forEach((e3) => {
  265. e3.tile = null, e3.elevationTile = null;
  266. }), i2;
  267. }
  268. async _createGeometryDescriptor(e2, i2, o) {
  269. let s3;
  270. const l = e2.layer.tileInfo.spatialReference;
  271. if (i2 instanceof x2 ? s3 = await i2.project(l, o) : (await fn([{ source: i2.spatialReference, dest: l }], { signal: o }), s3 = rn(i2, l)), !s3)
  272. throw new s2("elevation-query:spatial-reference-mismatch", `Cannot query elevation in '${i2.spatialReference.wkid}' on an elevation service in '${l.wkid}'`);
  273. e2.geometry = x2.fromGeometry(s3);
  274. }
  275. async _selectTiles(e2, i2) {
  276. const o = e2.options.demResolution;
  277. if (e2.type === "geometry" && this._preselectOutsideLayerExtent(e2), typeof o == "number")
  278. this._selectTilesClosestResolution(e2);
  279. else if (o === "finest-contiguous")
  280. await this._selectTilesFinestContiguous(e2, i2);
  281. else {
  282. if (o !== "auto")
  283. throw new s2("elevation-query:invalid-dem-resolution", `Invalid dem resolution value '${o}', expected a number, "finest-contiguous" or "auto"`);
  284. await this._selectTilesAuto(e2, i2);
  285. }
  286. }
  287. _preselectOutsideLayerExtent(e2) {
  288. if (t(e2.layer.fullExtent))
  289. return;
  290. const t2 = new i(null);
  291. t2.sample = () => e2.options.noDataValue, e2.outsideExtentTile = t2;
  292. const o = e2.layer.fullExtent;
  293. e2.geometry.coordinates.forEach((e3) => {
  294. const i2 = e3.x, s3 = e3.y;
  295. (i2 < o.xmin || i2 > o.xmax || s3 < o.ymin || s3 > o.ymax) && (e3.elevationTile = t2);
  296. });
  297. }
  298. _selectTilesClosestResolution(e2) {
  299. const t2 = e2.layer.tileInfo, i2 = this._findNearestDemResolutionLODIndex(t2, e2.options.demResolution);
  300. e2.selectTilesAtLOD(i2);
  301. }
  302. _findNearestDemResolutionLODIndex(e2, t2) {
  303. const i2 = t2 / z(e2.spatialReference);
  304. let o = e2.lods[0], s3 = 0;
  305. for (let l = 1; l < e2.lods.length; l++) {
  306. const t3 = e2.lods[l];
  307. Math.abs(t3.resolution - i2) < Math.abs(o.resolution - i2) && (o = t3, s3 = l);
  308. }
  309. return s3;
  310. }
  311. async _selectTilesFinestContiguous(e2, t2) {
  312. const i2 = E2(e2.layer.tileInfo, e2.options.minDemResolution);
  313. await this._selectTilesFinestContiguousAt(e2, i2, t2);
  314. }
  315. async _selectTilesFinestContiguousAt(e2, i2, o) {
  316. const n = e2.layer;
  317. if (e2.selectTilesAtLOD(i2), i2 < 0)
  318. return;
  319. const a2 = n.tilemapCache, r2 = e2.getTilesToFetch();
  320. try {
  321. if (a2)
  322. await y(Promise.all(r2.map((e3) => a2.fetchAvailability(e3.level, e3.row, e3.col, { signal: o }))), o);
  323. else if (await this._populateElevationTiles(e2, o), !e2.allElevationTilesFetched())
  324. throw e2.clearElevationTiles(), new s2("elevation-query:has-unavailable-tiles");
  325. } catch (c4) {
  326. w(c4), await this._selectTilesFinestContiguousAt(e2, i2 - 1, o);
  327. }
  328. }
  329. async _populateElevationTiles(e2, t2) {
  330. const i2 = e2.getTilesToFetch(), l = {}, a2 = e2.options.cache, r2 = e2.options.noDataValue, c4 = i2.map(async (i3) => {
  331. const s3 = `${e2.layer.uid}:${i3.id}:${r2}`, n = r(a2) ? a2.get(s3) : null, c5 = r(n) ? n : await e2.layer.fetchTile(i3.level, i3.row, i3.col, { noDataValue: r2, signal: t2 });
  332. r(a2) && a2.put(s3, c5), l[i3.id] = new i(i3, c5);
  333. });
  334. await y(E(c4), t2), e2.populateElevationTiles(l);
  335. }
  336. async _selectTilesAuto(t2, i2) {
  337. this._selectTilesAutoFinest(t2), this._reduceTilesForMaximumRequests(t2);
  338. const o = t2.layer.tilemapCache;
  339. if (!o)
  340. return this._selectTilesAutoPrefetchUpsample(t2, i2);
  341. const n = t2.getTilesToFetch(), a2 = {}, r2 = n.map(async (t3) => {
  342. const s3 = { id: null, level: 0, row: 0, col: 0, extent: u() }, n2 = await a(o.fetchAvailabilityUpsample(t3.level, t3.row, t3.col, s3, { signal: i2 }));
  343. n2.ok === false ? w(n2.error) : a2[t3.id] = s3;
  344. });
  345. await y(Promise.all(r2), i2), t2.remapTiles(a2);
  346. }
  347. _reduceTilesForMaximumRequests(e2) {
  348. const t2 = e2.layer.tileInfo;
  349. let i2 = 0;
  350. const o = {}, s3 = (e3) => {
  351. e3.id in o ? o[e3.id]++ : (o[e3.id] = 1, i2++);
  352. }, l = (e3) => {
  353. const t3 = o[e3.id];
  354. t3 === 1 ? (delete o[e3.id], i2--) : o[e3.id] = t3 - 1;
  355. };
  356. e2.forEachTileToFetch(s3, l);
  357. let n = true;
  358. for (; n && (n = false, e2.forEachTileToFetch((o2) => {
  359. i2 <= e2.options.maximumAutoTileRequests || (l(o2), t2.upsampleTile(o2) && (n = true), s3(o2));
  360. }, l), n); )
  361. ;
  362. }
  363. _selectTilesAutoFinest(e2) {
  364. const t2 = E2(e2.layer.tileInfo, e2.options.minDemResolution);
  365. e2.selectTilesAtLOD(t2, e2.options.maximumAutoTileRequests);
  366. }
  367. async _selectTilesAutoPrefetchUpsample(e2, t2) {
  368. const i2 = e2.layer.tileInfo;
  369. await this._populateElevationTiles(e2, t2);
  370. let o = false;
  371. e2.forEachTileToFetch((e3, t3) => {
  372. i2.upsampleTile(e3) ? o = true : t3();
  373. }), o && await this._selectTilesAutoPrefetchUpsample(e2, t2);
  374. }
  375. _sampleGeometryWithElevation(e2) {
  376. e2.geometry.coordinates.forEach((t2) => {
  377. const i2 = t2.elevationTile;
  378. let s3 = e2.options.noDataValue;
  379. if (i2) {
  380. const e3 = i2.sample(t2.x, t2.y);
  381. r(e3) ? s3 = e3 : t2.elevationTile = null;
  382. }
  383. t2.z = s3;
  384. });
  385. }
  386. _extractSampleInfo(e2) {
  387. const t2 = e2.layer.tileInfo, i2 = z(t2.spatialReference);
  388. return e2.geometry.coordinates.map((o) => {
  389. let s3 = -1;
  390. if (o.elevationTile && o.elevationTile !== e2.outsideExtentTile) {
  391. s3 = t2.lodAt(o.elevationTile.tile.level).resolution * i2;
  392. }
  393. return { demResolution: s3 };
  394. });
  395. }
  396. };
  397. var x2 = class {
  398. export() {
  399. return this._exporter(this.coordinates, this.spatialReference);
  400. }
  401. clone(e2) {
  402. const t2 = new x2();
  403. return t2.geometry = this.geometry, t2.spatialReference = this.spatialReference, t2.coordinates = e2 || this.coordinates.map((e3) => this._cloneCoordinate(e3)), t2._exporter = this._exporter, t2;
  404. }
  405. async project(e2, t2) {
  406. if (this.spatialReference.equals(e2))
  407. return this.clone();
  408. await fn([{ source: this.spatialReference, dest: e2 }], { signal: t2 });
  409. const i2 = new m({ spatialReference: this.spatialReference, points: this.coordinates.map((e3) => [e3.x, e3.y]) }), o = rn(i2, e2);
  410. if (!o)
  411. return null;
  412. const s3 = this.coordinates.map((e3, t3) => {
  413. const i3 = this._cloneCoordinate(e3), s4 = o.points[t3];
  414. return i3.x = s4[0], i3.y = s4[1], i3;
  415. }), l = this.clone(s3);
  416. return l.spatialReference = e2, l;
  417. }
  418. _cloneCoordinate(e2) {
  419. return { x: e2.x, y: e2.y, z: e2.z, m: e2.m, tile: null, elevationTile: null };
  420. }
  421. static fromGeometry(e2) {
  422. const t2 = new x2();
  423. if (t2.geometry = e2, t2.spatialReference = e2.spatialReference, e2 instanceof x2)
  424. t2.coordinates = e2.coordinates.map((e3) => t2._cloneCoordinate(e3)), t2._exporter = (t3, i2) => {
  425. const o = e2.clone(t3);
  426. return o.spatialReference = i2, o;
  427. };
  428. else
  429. switch (e2.type) {
  430. case "point": {
  431. const i2 = e2, { hasZ: o, hasM: s3 } = i2;
  432. t2.coordinates = o && s3 ? [{ x: i2.x, y: i2.y, z: i2.z, m: i2.m }] : o ? [{ x: i2.x, y: i2.y, z: i2.z }] : s3 ? [{ x: i2.x, y: i2.y, m: i2.m }] : [{ x: i2.x, y: i2.y }], t2._exporter = (t3, i3) => e2.hasM ? new j(t3[0].x, t3[0].y, t3[0].z, t3[0].m, i3) : new j(t3[0].x, t3[0].y, t3[0].z, i3);
  433. break;
  434. }
  435. case "multipoint": {
  436. const i2 = e2, { hasZ: o, hasM: s3 } = i2;
  437. t2.coordinates = o && s3 ? i2.points.map((e3) => ({ x: e3[0], y: e3[1], z: e3[2], m: e3[3] })) : o ? i2.points.map((e3) => ({ x: e3[0], y: e3[1], z: e3[2] })) : s3 ? i2.points.map((e3) => ({ x: e3[0], y: e3[1], m: e3[2] })) : i2.points.map((e3) => ({ x: e3[0], y: e3[1] })), t2._exporter = (t3, i3) => e2.hasM ? new m({ points: t3.map((e3) => [e3.x, e3.y, e3.z, e3.m]), hasZ: true, hasM: true, spatiaReference: i3 }) : new m(t3.map((e3) => [e3.x, e3.y, e3.z]), i3);
  438. break;
  439. }
  440. case "polyline": {
  441. const i2 = e2, o = [], s3 = [], { hasZ: l, hasM: n } = e2;
  442. let a2 = 0;
  443. for (const e3 of i2.paths)
  444. if (s3.push([a2, a2 + e3.length]), a2 += e3.length, l && n)
  445. for (const t3 of e3)
  446. o.push({ x: t3[0], y: t3[1], z: t3[2], m: t3[3] });
  447. else if (l)
  448. for (const t3 of e3)
  449. o.push({ x: t3[0], y: t3[1], z: t3[2] });
  450. else if (n)
  451. for (const t3 of e3)
  452. o.push({ x: t3[0], y: t3[1], m: t3[2] });
  453. else
  454. for (const t3 of e3)
  455. o.push({ x: t3[0], y: t3[1] });
  456. t2.coordinates = o, t2._exporter = (t3, i3) => {
  457. const o2 = e2.hasM ? t3.map((e3) => [e3.x, e3.y, e3.z, e3.m]) : t3.map((e3) => [e3.x, e3.y, e3.z]), l2 = s3.map((e3) => o2.slice(e3[0], e3[1]));
  458. return new m2({ paths: l2, hasM: e2.hasM, hasZ: true, spatialReference: i3 });
  459. };
  460. break;
  461. }
  462. }
  463. return t2;
  464. }
  465. };
  466. var g2 = class {
  467. constructor(e2, t2) {
  468. this.layer = e2, this.options = t2;
  469. }
  470. };
  471. var w3 = class extends g2 {
  472. constructor(e2, t2, i2) {
  473. super(e2, i2), this.outSpatialReference = t2, this.type = "geometry";
  474. }
  475. selectTilesAtLOD(e2) {
  476. if (e2 < 0)
  477. this.geometry.coordinates.forEach((e3) => e3.tile = null);
  478. else {
  479. const t2 = this.layer.tileInfo, i2 = t2.lods[e2].level;
  480. this.geometry.coordinates.forEach((e3) => {
  481. e3.tile = t2.tileAt(i2, e3.x, e3.y);
  482. });
  483. }
  484. }
  485. allElevationTilesFetched() {
  486. return !this.geometry.coordinates.some((e2) => !e2.elevationTile);
  487. }
  488. clearElevationTiles() {
  489. for (const e2 of this.geometry.coordinates)
  490. e2.elevationTile !== this.outsideExtentTile && (e2.elevationTile = null);
  491. }
  492. populateElevationTiles(e2) {
  493. for (const t2 of this.geometry.coordinates)
  494. !t2.elevationTile && t2.tile && (t2.elevationTile = e2[t2.tile.id]);
  495. }
  496. remapTiles(e2) {
  497. for (const t2 of this.geometry.coordinates)
  498. t2.tile = e2[t2.tile.id];
  499. }
  500. getTilesToFetch() {
  501. const e2 = {}, t2 = [];
  502. for (const i2 of this.geometry.coordinates) {
  503. const o = i2.tile;
  504. i2.elevationTile || !i2.tile || e2[o.id] || (e2[o.id] = o, t2.push(o));
  505. }
  506. return t2;
  507. }
  508. forEachTileToFetch(e2) {
  509. for (const t2 of this.geometry.coordinates)
  510. t2.tile && !t2.elevationTile && e2(t2.tile, () => t2.tile = null);
  511. }
  512. };
  513. var _ = class extends g2 {
  514. constructor(e2, t2, i2, o) {
  515. super(e2, i2), this.type = "extent", this.elevationTiles = [], this.candidateTiles = [], this.fetchedCandidates = new Set(), this.extent = t2.intersection(e2.fullExtent), this.maskExtents = o;
  516. }
  517. selectTilesAtLOD(e2, t2) {
  518. const i2 = this._maximumLodForRequests(t2), o = Math.min(i2, e2);
  519. o < 0 ? this.candidateTiles.length = 0 : this._selectCandidateTilesCoveringExtentAt(o);
  520. }
  521. _maximumLodForRequests(e2) {
  522. const t2 = this.layer.tileInfo;
  523. if (!e2)
  524. return t2.lods.length - 1;
  525. const o = this.extent;
  526. if (t(o))
  527. return -1;
  528. for (let i2 = t2.lods.length - 1; i2 >= 0; i2--) {
  529. const s3 = t2.lods[i2], l = s3.resolution * t2.size[0], n = s3.resolution * t2.size[1];
  530. if (Math.ceil(o.width / l) * Math.ceil(o.height / n) <= e2)
  531. return i2;
  532. }
  533. return -1;
  534. }
  535. allElevationTilesFetched() {
  536. return this.candidateTiles.length === this.elevationTiles.length;
  537. }
  538. clearElevationTiles() {
  539. this.elevationTiles.length = 0, this.fetchedCandidates.clear();
  540. }
  541. populateElevationTiles(e2) {
  542. for (const t2 of this.candidateTiles) {
  543. const i2 = e2[t2.id];
  544. i2 && (this.fetchedCandidates.add(t2), this.elevationTiles.push(i2));
  545. }
  546. }
  547. remapTiles(e2) {
  548. this.candidateTiles = this._uniqueNonOverlappingTiles(this.candidateTiles.map((t2) => e2[t2.id]));
  549. }
  550. getTilesToFetch() {
  551. return this.candidateTiles;
  552. }
  553. forEachTileToFetch(e2, t2) {
  554. const i2 = this.candidateTiles;
  555. this.candidateTiles = [], i2.forEach((i3) => {
  556. if (this.fetchedCandidates.has(i3))
  557. return void (t2 && t2(i3));
  558. let o = false;
  559. e2(i3, () => o = true), o ? t2 && t2(i3) : this.candidateTiles.push(i3);
  560. }), this.candidateTiles = this._uniqueNonOverlappingTiles(this.candidateTiles, t2);
  561. }
  562. _uniqueNonOverlappingTiles(e2, t2) {
  563. const i2 = {}, o = [];
  564. for (const l of e2)
  565. i2[l.id] ? t2 && t2(l) : (i2[l.id] = l, o.push(l));
  566. const s3 = o.sort((e3, t3) => e3.level - t3.level);
  567. return s3.filter((e3, i3) => {
  568. for (let o2 = 0; o2 < i3; o2++)
  569. if (R(s3[o2].extent, e3.extent))
  570. return t2 && t2(e3), false;
  571. return true;
  572. });
  573. }
  574. _selectCandidateTilesCoveringExtentAt(e2) {
  575. this.candidateTiles.length = 0;
  576. const t2 = this.extent;
  577. if (t(t2))
  578. return;
  579. const o = this.layer.tileInfo, s3 = o.lods[e2], l = o.tileAt(s3.level, t2.xmin, t2.ymin), n = s3.resolution * o.size[0], a2 = s3.resolution * o.size[1], r2 = Math.ceil((t2.xmax - l.extent[0]) / n), c4 = Math.ceil((t2.ymax - l.extent[1]) / a2);
  580. for (let i2 = 0; i2 < c4; i2++)
  581. for (let e3 = 0; e3 < r2; e3++) {
  582. const t3 = { id: null, level: l.level, row: l.row - i2, col: l.col + e3 };
  583. o.updateTileInfo(t3), this._tileIsMasked(t3) || this.candidateTiles.push(t3);
  584. }
  585. }
  586. _tileIsMasked(e2) {
  587. return !!this.maskExtents && this.maskExtents.some((t2) => R(t2, e2.extent));
  588. }
  589. };
  590. function E2(e2, t2) {
  591. let i2 = e2.lods.length - 1;
  592. if (t2 > 0) {
  593. const o = e2.lods.findIndex((e3) => e3.resolution < t2);
  594. o === 0 ? i2 = 0 : o > 0 && (i2 = o - 1);
  595. }
  596. return i2;
  597. }
  598. var R3 = { maximumAutoTileRequests: 20, noDataValue: 0, returnSampleInfo: false, demResolution: "auto", minDemResolution: 0 };
  599. export {
  600. v as ElevationQuery,
  601. x2 as GeometryDescriptor,
  602. E2 as getFinestLodIndex
  603. };
  604. //# sourceMappingURL=ElevationQuery-H57OAGAY.js.map