GeoJSONSourceWorker-NOAEMPL4.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. import {
  2. L,
  3. O as O2,
  4. T
  5. } from "./chunk-YVTH4OGO.js";
  6. import {
  7. a as a2,
  8. f as f2,
  9. g as g3,
  10. m,
  11. w
  12. } from "./chunk-XHRYELNQ.js";
  13. import {
  14. a,
  15. l,
  16. u as u2
  17. } from "./chunk-4D6PVVFX.js";
  18. import {
  19. u
  20. } from "./chunk-5FHVUYVE.js";
  21. import {
  22. Y
  23. } from "./chunk-NP2BYFXT.js";
  24. import "./chunk-6H5PP7QI.js";
  25. import "./chunk-HSPVIAVJ.js";
  26. import "./chunk-XIEPNAEI.js";
  27. import {
  28. f,
  29. g as g2
  30. } from "./chunk-M5BTTMP6.js";
  31. import "./chunk-WQJRLXWG.js";
  32. import "./chunk-ETWBEEKL.js";
  33. import "./chunk-XZA4MVET.js";
  34. import "./chunk-4GGRJYTB.js";
  35. import "./chunk-D5GG5NVO.js";
  36. import "./chunk-USORKAIZ.js";
  37. import "./chunk-Q34L5KZA.js";
  38. import "./chunk-ROWZMUVJ.js";
  39. import "./chunk-7IKYLNB5.js";
  40. import "./chunk-P4UZNLD5.js";
  41. import {
  42. Q,
  43. W,
  44. ee,
  45. ne,
  46. te
  47. } from "./chunk-FYNVVMWY.js";
  48. import "./chunk-Q52DVFYK.js";
  49. import "./chunk-HBMVUVZX.js";
  50. import "./chunk-QOV6ITMI.js";
  51. import "./chunk-DH2OBAUC.js";
  52. import "./chunk-TNLRDNTC.js";
  53. import "./chunk-KUXNUNAI.js";
  54. import {
  55. d
  56. } from "./chunk-KMAHKQ2G.js";
  57. import "./chunk-522WBHUO.js";
  58. import "./chunk-WNCU6BFU.js";
  59. import {
  60. i
  61. } from "./chunk-F6A2QQ26.js";
  62. import "./chunk-EOSZHC5H.js";
  63. import "./chunk-C43UE3Z5.js";
  64. import "./chunk-NE3ESGA6.js";
  65. import "./chunk-YIS6BAC3.js";
  66. import "./chunk-7XXXCK2A.js";
  67. import "./chunk-7ZIDBK7B.js";
  68. import {
  69. P
  70. } from "./chunk-WZQZRKNH.js";
  71. import "./chunk-LRDX4TO7.js";
  72. import "./chunk-WDLTDV2L.js";
  73. import "./chunk-TERAW6FT.js";
  74. import "./chunk-N2663GRX.js";
  75. import "./chunk-O4FY3ITT.js";
  76. import "./chunk-JXW4QTJA.js";
  77. import "./chunk-UXF37FQ4.js";
  78. import "./chunk-ZOEK6QHJ.js";
  79. import "./chunk-XNLG7T2T.js";
  80. import "./chunk-IR4PV7VK.js";
  81. import {
  82. v
  83. } from "./chunk-2Z6LERTI.js";
  84. import "./chunk-OWVBLVP3.js";
  85. import "./chunk-MXB2XLKV.js";
  86. import "./chunk-ALDCDSPV.js";
  87. import "./chunk-DT6EAZQ5.js";
  88. import "./chunk-HNOZUNJ4.js";
  89. import {
  90. U
  91. } from "./chunk-VNFRAYHO.js";
  92. import "./chunk-R5IG2D6H.js";
  93. import "./chunk-VBRY5KJM.js";
  94. import "./chunk-PDKDCAAD.js";
  95. import "./chunk-ECW2QABR.js";
  96. import "./chunk-GCDJLKH4.js";
  97. import {
  98. E,
  99. c
  100. } from "./chunk-MRJEICT6.js";
  101. import "./chunk-Y3WMVFTW.js";
  102. import "./chunk-SAS7RONY.js";
  103. import "./chunk-WSRBH7BF.js";
  104. import "./chunk-IHXECKQQ.js";
  105. import {
  106. O,
  107. g
  108. } from "./chunk-ULGDPLM2.js";
  109. import {
  110. s,
  111. s3 as s2
  112. } from "./chunk-EMJ4ZSM2.js";
  113. import "./chunk-IKP3YN53.js";
  114. import {
  115. r
  116. } from "./chunk-GZT4BVFP.js";
  117. import "./chunk-A5ICIBVI.js";
  118. // node_modules/@arcgis/core/layers/graphics/sources/geojson/GeoJSONSourceWorker.js
  119. var O3 = { hasAttachments: false, capabilities: "query, editing, create, delete, update", useStandardizedQueries: true, supportsCoordinatesQuantization: true, supportsReturningQueryGeometry: true, advancedQueryCapabilities: { supportsQueryAttachments: false, supportsStatistics: true, supportsPercentileStatistics: true, supportsReturningGeometryCentroid: true, supportsQueryWithDistance: true, supportsDistinct: true, supportsReturningQueryExtent: true, supportsReturningGeometryProperties: false, supportsHavingClause: true, supportsOrderBy: true, supportsPagination: true, supportsQueryWithResultType: false, supportsSqlExpression: true, supportsDisjointSpatialRel: true } };
  120. var C = class {
  121. constructor() {
  122. this._queryEngine = null, this._snapshotFeatures = async (e) => {
  123. const t = await this._fetch(e);
  124. return this._createFeatures(t);
  125. };
  126. }
  127. destroy() {
  128. this._queryEngine?.destroy(), this._queryEngine = this._fieldsIndex = this._createDefaultAttributes = null;
  129. }
  130. async load(e, s3 = {}) {
  131. this.loadOptions = { url: e.url, customParameters: e.customParameters };
  132. const i2 = [];
  133. await this._checkProjection(e.spatialReference);
  134. let r2 = null;
  135. e.url && (r2 = await this._fetch(s3?.signal));
  136. const n = T(r2, { geometryType: e.geometryType }), a3 = e.fields || n.fields || [], u3 = e.hasZ != null ? e.hasZ : n.hasZ, l2 = n.geometryType, d2 = e.objectIdField || n.objectIdFieldName || "__OBJECTID", p = e.spatialReference || c;
  137. let c2 = e.timeInfo;
  138. a3 === n.fields && n.unknownFields.length > 0 && i2.push({ name: "geojson-layer:unknown-field-types", message: "Some fields types couldn't be inferred from the features and were dropped", details: { unknownFields: n.unknownFields } });
  139. let y = a3.find((e2) => e2.name === d2);
  140. y ? (y.type !== "esriFieldTypeString" && (y.type = "esriFieldTypeOID"), y.editable = false, y.nullable = false) : (y = { alias: d2, name: d2, type: n.objectIdFieldType === "string" ? "esriFieldTypeString" : "esriFieldTypeOID", editable: false, nullable: false }, a3.unshift(y));
  141. const m2 = {};
  142. for (const o of a3) {
  143. if (o.name == null && (o.name = o.alias), o.alias == null && (o.alias = o.name), !o.name)
  144. throw new s2("geojson-layer:invalid-field-name", "field name is missing", { field: o });
  145. if (!i.jsonValues.includes(o.type))
  146. throw new s2("geojson-layer:invalid-field-type", `invalid type for field "${o.name}"`, { field: o });
  147. if (o.name !== y.name) {
  148. const e2 = P(o);
  149. e2 !== void 0 && (m2[o.name] = e2);
  150. }
  151. }
  152. this._fieldsIndex = new d(a3);
  153. const f3 = this._fieldsIndex.requiredFields.indexOf(y);
  154. if (f3 > -1 && this._fieldsIndex.requiredFields.splice(f3, 1), c2) {
  155. if (c2.startTimeField) {
  156. const e2 = this._fieldsIndex.get(c2.startTimeField);
  157. e2 ? (c2.startTimeField = e2.name, e2.type = "esriFieldTypeDate") : c2.startTimeField = null;
  158. }
  159. if (c2.endTimeField) {
  160. const e2 = this._fieldsIndex.get(c2.endTimeField);
  161. e2 ? (c2.endTimeField = e2.name, e2.type = "esriFieldTypeDate") : c2.endTimeField = null;
  162. }
  163. if (c2.trackIdField) {
  164. const e2 = this._fieldsIndex.get(c2.trackIdField);
  165. e2 ? c2.trackIdField = e2.name : (c2.trackIdField = null, i2.push({ name: "geojson-layer:invalid-timeInfo-trackIdField", message: "trackIdField is missing", details: { timeInfo: c2 } }));
  166. }
  167. c2.startTimeField || c2.endTimeField || (i2.push({ name: "geojson-layer:invalid-timeInfo", message: "startTimeField and endTimeField are missing", details: { timeInfo: c2 } }), c2 = null);
  168. }
  169. const I = l2 ? u2(l2) : null, j = { warnings: i2, featureErrors: [], layerDefinition: { ...O3, drawingInfo: I, templates: l(m2), extent: null, geometryType: l2, objectIdField: d2, fields: a3, hasZ: !!u3, timeInfo: c2 } };
  170. this._queryEngine = new Y({ fields: a3, geometryType: l2, hasM: false, hasZ: u3, objectIdField: d2, spatialReference: p, timeInfo: c2, featureStore: new u({ geometryType: l2, hasM: false, hasZ: u3 }), cacheSpatialQueries: true }), this._createDefaultAttributes = a(m2, d2);
  171. const T2 = await this._createFeatures(r2);
  172. this._objectIdGenerator = this._createObjectIdGenerator(this._queryEngine, T2);
  173. const w2 = this._normalizeFeatures(T2, j.warnings, j.featureErrors);
  174. if (this._queryEngine.featureStore.addMany(w2), j.layerDefinition.extent = this._queryEngine.fullExtent, j.layerDefinition.timeInfo) {
  175. const { start: e2, end: t } = this._queryEngine.timeExtent;
  176. j.layerDefinition.timeInfo.timeExtent = [e2, t];
  177. }
  178. return j;
  179. }
  180. async applyEdits(e) {
  181. const { spatialReference: t, geometryType: s3 } = this._queryEngine;
  182. return await Promise.all([w(t, s3), f(e.adds, t), f(e.updates, t)]), await this._waitSnapshotComplete(), this._applyEdits(e);
  183. }
  184. async queryFeatures(e = {}, t = {}) {
  185. return await this._waitSnapshotComplete(), this._queryEngine.executeQuery(e, t.signal);
  186. }
  187. async queryFeatureCount(e = {}, t = {}) {
  188. return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForCount(e, t.signal);
  189. }
  190. async queryObjectIds(e = {}, t = {}) {
  191. return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForIds(e, t.signal);
  192. }
  193. async queryExtent(e = {}, t = {}) {
  194. return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForExtent(e, t.signal);
  195. }
  196. async querySnapping(e, t = {}) {
  197. return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForSnapping(e, t.signal);
  198. }
  199. async refresh(e) {
  200. return this.loadOptions.customParameters = e, this._snapshotTask?.abort(), this._snapshotTask = O(this._snapshotFeatures), this._snapshotTask.promise.then((e2) => {
  201. this._queryEngine.featureStore.clear(), this._objectIdGenerator = this._createObjectIdGenerator(this._queryEngine, e2);
  202. const t = this._normalizeFeatures(e2);
  203. t && this._queryEngine.featureStore.addMany(t);
  204. }, (e2) => {
  205. this._queryEngine.featureStore.clear(), g(e2) || s.getLogger("esri.layers.GeoJSONLayer").error(new s2("geojson-layer:refresh", "An error occurred during refresh", { error: e2 }));
  206. }), await this._waitSnapshotComplete(), { extent: this._queryEngine.fullExtent, timeExtent: this._queryEngine.timeExtent };
  207. }
  208. async _createFeatures(e) {
  209. const { geometryType: t, hasZ: s3, objectIdField: r2 } = this._queryEngine, n = L(e, { geometryType: t, hasZ: s3, objectIdField: r2 });
  210. if (!E(this._queryEngine.spatialReference, c))
  211. for (const a3 of n)
  212. r(a3.geometry) && (a3.geometry = te(g2(ne(a3.geometry, this._queryEngine.geometryType, this._queryEngine.hasZ, false), c, this._queryEngine.spatialReference)));
  213. return n;
  214. }
  215. async _waitSnapshotComplete() {
  216. if (this._snapshotTask && !this._snapshotTask.finished) {
  217. try {
  218. await this._snapshotTask.promise;
  219. } catch {
  220. }
  221. return this._waitSnapshotComplete();
  222. }
  223. }
  224. async _fetch(t) {
  225. const { url: s3, customParameters: i2 } = this.loadOptions, r2 = (await U(s3, { responseType: "json", query: { ...i2 }, signal: t })).data;
  226. return await O2(r2), r2;
  227. }
  228. _normalizeFeatures(e, t, s3) {
  229. const { objectIdField: i2 } = this._queryEngine, r2 = [];
  230. for (const n of e) {
  231. const e2 = this._createDefaultAttributes(), a3 = m(this._fieldsIndex, e2, n.attributes, true, t);
  232. a3 ? s3?.push(a3) : (this._assignObjectId(e2, n.attributes, true), n.attributes = e2, n.objectId = e2[i2], r2.push(n));
  233. }
  234. return r2;
  235. }
  236. _applyEdits(e) {
  237. const { adds: t, updates: s3, deletes: i2 } = e, r2 = { addResults: [], deleteResults: [], updateResults: [], uidToObjectId: {} };
  238. if (t && t.length && this._applyAddEdits(r2, t), s3 && s3.length && this._applyUpdateEdits(r2, s3), i2 && i2.length) {
  239. for (const e2 of i2)
  240. r2.deleteResults.push(f2(e2));
  241. this._queryEngine.featureStore.removeManyById(i2);
  242. }
  243. return { extent: this._queryEngine.fullExtent, timeExtent: this._queryEngine.timeExtent, featureEditResults: r2 };
  244. }
  245. _applyAddEdits(e, t) {
  246. const { addResults: s3 } = e, { geometryType: r2, hasM: n, hasZ: o, objectIdField: u3, spatialReference: l2, featureStore: d2 } = this._queryEngine, c2 = [];
  247. for (const p of t) {
  248. if (p.geometry && r2 !== v(p.geometry)) {
  249. s3.push(a2("Incorrect geometry type."));
  250. continue;
  251. }
  252. const t2 = this._createDefaultAttributes(), n2 = m(this._fieldsIndex, t2, p.attributes);
  253. if (n2)
  254. s3.push(n2);
  255. else {
  256. if (this._assignObjectId(t2, p.attributes), p.attributes = t2, p.uid != null) {
  257. const t3 = p.attributes[u3];
  258. e.uidToObjectId[p.uid] = t3;
  259. }
  260. r(p.geometry) && (p.geometry = g2(g3(p.geometry, l2), p.geometry.spatialReference, l2)), c2.push(p), s3.push(f2(p.attributes[u3]));
  261. }
  262. }
  263. d2.addMany(W([], c2, r2, o, n, u3));
  264. }
  265. _applyUpdateEdits({ updateResults: e }, t) {
  266. const { geometryType: s3, hasM: r2, hasZ: n, objectIdField: o, spatialReference: u3, featureStore: l2 } = this._queryEngine;
  267. for (const d2 of t) {
  268. const { attributes: t2, geometry: p } = d2, h = t2 && t2[o];
  269. if (h == null) {
  270. e.push(a2(`Identifier field ${o} missing`));
  271. continue;
  272. }
  273. if (!l2.has(h)) {
  274. e.push(a2(`Feature with object id ${h} missing`));
  275. continue;
  276. }
  277. const m2 = ee(l2.getFeature(h), s3, n, r2);
  278. if (r(p)) {
  279. if (s3 !== v(p)) {
  280. e.push(a2("Incorrect geometry type."));
  281. continue;
  282. }
  283. m2.geometry = g2(g3(p, u3), p.spatialReference, u3);
  284. }
  285. if (t2) {
  286. const s4 = m(this._fieldsIndex, m2.attributes, t2);
  287. if (s4) {
  288. e.push(s4);
  289. continue;
  290. }
  291. }
  292. l2.add(Q(m2, s3, n, r2, o)), e.push(f2(h));
  293. }
  294. }
  295. _createObjectIdGenerator(e, t) {
  296. const s3 = e.fieldsIndex.get(e.objectIdField);
  297. if (s3.type === "esriFieldTypeString")
  298. return () => s3.name + "-" + Date.now().toString(16);
  299. let i2 = Number.NEGATIVE_INFINITY;
  300. for (const r2 of t)
  301. r2.objectId && (i2 = Math.max(i2, r2.objectId));
  302. return i2 = Math.max(0, i2) + 1, () => i2++;
  303. }
  304. _assignObjectId(e, t, s3 = false) {
  305. const i2 = this._queryEngine.objectIdField;
  306. e[i2] = s3 && i2 in t ? t[i2] : this._objectIdGenerator();
  307. }
  308. async _checkProjection(e) {
  309. try {
  310. await f(c, e);
  311. } catch {
  312. throw new s2("geojson-layer", "Projection not supported");
  313. }
  314. }
  315. };
  316. export {
  317. C as default
  318. };
  319. //# sourceMappingURL=GeoJSONSourceWorker-NOAEMPL4.js.map