GeoJSONSourceWorker-ZQVDDZS5.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. import {
  2. I,
  3. L,
  4. T
  5. } from "./chunk-JK76NUHI.js";
  6. import {
  7. a as a2,
  8. f as f2,
  9. g as g2,
  10. m,
  11. w
  12. } from "./chunk-QR6V6X5R.js";
  13. import {
  14. a,
  15. i as i2,
  16. o
  17. } from "./chunk-A6WD5XTM.js";
  18. import {
  19. u
  20. } from "./chunk-RDOYANC4.js";
  21. import {
  22. Y
  23. } from "./chunk-FSIQKOJP.js";
  24. import "./chunk-OQSZOHTF.js";
  25. import "./chunk-OP2HNSVZ.js";
  26. import "./chunk-UVQJ7AVD.js";
  27. import "./chunk-DMVKVC5I.js";
  28. import "./chunk-Y7BZ6TKQ.js";
  29. import {
  30. f,
  31. g
  32. } from "./chunk-VEJPYAE4.js";
  33. import "./chunk-4GGDRIJK.js";
  34. import "./chunk-D5UVUJIX.js";
  35. import "./chunk-PZ7XDUL6.js";
  36. import "./chunk-ULSPZIPE.js";
  37. import "./chunk-UMUHMVL4.js";
  38. import "./chunk-FZSI6IGI.js";
  39. import "./chunk-B5O7N7PM.js";
  40. import "./chunk-KOKTANE6.js";
  41. import "./chunk-OKUFE7TO.js";
  42. import {
  43. X,
  44. nt,
  45. ot,
  46. rt,
  47. tt
  48. } from "./chunk-JKFWEHNK.js";
  49. import "./chunk-IIAN3QNN.js";
  50. import "./chunk-P24XEEHY.js";
  51. import "./chunk-WOXHUQGM.js";
  52. import "./chunk-FMPQIGFA.js";
  53. import "./chunk-EDHROVWI.js";
  54. import "./chunk-3IRT3YKJ.js";
  55. import "./chunk-SAJAEMIJ.js";
  56. import "./chunk-ZSW35JPD.js";
  57. import {
  58. r as r2
  59. } from "./chunk-JLSNMUQJ.js";
  60. import "./chunk-ECY35CJI.js";
  61. import "./chunk-PT62335L.js";
  62. import {
  63. i
  64. } from "./chunk-QEWF7QPH.js";
  65. import "./chunk-FNA5GLRW.js";
  66. import "./chunk-MCWCB5IY.js";
  67. import "./chunk-TJV6ODRM.js";
  68. import {
  69. M
  70. } from "./chunk-CRGY2SDS.js";
  71. import "./chunk-4T5ZGMEN.js";
  72. import "./chunk-CZBRZ6SU.js";
  73. import "./chunk-VGWC3IKZ.js";
  74. import "./chunk-2H5MD622.js";
  75. import "./chunk-3RSFVUKZ.js";
  76. import "./chunk-X4SA4ELJ.js";
  77. import "./chunk-5N7JLUJJ.js";
  78. import {
  79. j as j2
  80. } from "./chunk-2ZSOO377.js";
  81. import "./chunk-ZLNEXZAN.js";
  82. import "./chunk-ZYRIJWLX.js";
  83. import "./chunk-RYY6632W.js";
  84. import "./chunk-DW42UVIT.js";
  85. import "./chunk-YAEIHDJH.js";
  86. import "./chunk-TJNOJH33.js";
  87. import "./chunk-OSHI574D.js";
  88. import "./chunk-ETGAZ7LF.js";
  89. import "./chunk-75U5LM2V.js";
  90. import {
  91. c as c2
  92. } from "./chunk-RMDDCMKS.js";
  93. import "./chunk-VCH45Q2I.js";
  94. import "./chunk-GSSTTHIT.js";
  95. import "./chunk-IM3LVQXV.js";
  96. import "./chunk-HZRKBTHJ.js";
  97. import {
  98. U
  99. } from "./chunk-DVUG3KID.js";
  100. import "./chunk-FWSQEIAR.js";
  101. import "./chunk-VEGAOVMY.js";
  102. import "./chunk-6T6G6LCQ.js";
  103. import "./chunk-YEJL5NEF.js";
  104. import {
  105. E,
  106. c
  107. } from "./chunk-PQFTYGF5.js";
  108. import "./chunk-2Z2TG5CU.js";
  109. import "./chunk-6KZ2LTDA.js";
  110. import "./chunk-U2XHEJM7.js";
  111. import "./chunk-SQOPWYIT.js";
  112. import {
  113. j
  114. } from "./chunk-V6P2MAQQ.js";
  115. import {
  116. s2 as s,
  117. s3 as s2
  118. } from "./chunk-E5O6P5I2.js";
  119. import "./chunk-SPWQ3AWG.js";
  120. import "./chunk-2TIUKVZN.js";
  121. import {
  122. r
  123. } from "./chunk-YXWMMD76.js";
  124. import "./chunk-S5KM4IGW.js";
  125. // node_modules/@arcgis/core/layers/graphics/sources/geojson/GeoJSONSourceWorker.js
  126. var O = { 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 } };
  127. var C = class {
  128. constructor() {
  129. this._queryEngine = null, this._snapshotFeatures = async (e) => {
  130. const t = await this._fetch(e);
  131. return this._createFeatures(t);
  132. };
  133. }
  134. destroy() {
  135. var _a;
  136. (_a = this._queryEngine) == null ? void 0 : _a.destroy(), this._queryEngine = this._fieldsIndex = this._createDefaultAttributes = null;
  137. }
  138. async load(e, t = {}) {
  139. this._loadOptions = { url: e.url, customParameters: e.customParameters };
  140. const i3 = [];
  141. await this._checkProjection(e.spatialReference);
  142. let r3 = null;
  143. e.url && (r3 = await this._fetch(t == null ? void 0 : t.signal));
  144. const n = L(r3, { geometryType: e.geometryType }), a3 = e.fields || n.fields || [], l = null != e.hasZ ? e.hasZ : n.hasZ, u2 = n.geometryType;
  145. let d = e.objectIdField || n.objectIdFieldName || "__OBJECTID";
  146. const p = e.spatialReference || c;
  147. let c3 = e.timeInfo;
  148. a3 === n.fields && n.unknownFields.length > 0 && i3.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 } });
  149. let y = new r2(a3).get(d);
  150. y ? ("esriFieldTypeString" !== y.type && (y.type = "esriFieldTypeOID"), y.editable = false, y.nullable = false, d = y.name) : (y = { alias: d, name: d, type: "string" === n.objectIdFieldType ? "esriFieldTypeString" : "esriFieldTypeOID", editable: false, nullable: false }, a3.unshift(y));
  151. const m2 = {};
  152. for (const o2 of a3) {
  153. if (null == o2.name && (o2.name = o2.alias), null == o2.alias && (o2.alias = o2.name), !o2.name)
  154. throw new s2("geojson-layer:invalid-field-name", "field name is missing", { field: o2 });
  155. if (!i.jsonValues.includes(o2.type))
  156. throw new s2("geojson-layer:invalid-field-type", `invalid type for field "${o2.name}"`, { field: o2 });
  157. if (o2.name !== y.name) {
  158. const e2 = M(o2);
  159. void 0 !== e2 && (m2[o2.name] = e2);
  160. }
  161. }
  162. this._fieldsIndex = new r2(a3);
  163. const f3 = this._fieldsIndex.requiredFields.indexOf(y);
  164. if (f3 > -1 && this._fieldsIndex.requiredFields.splice(f3, 1), c3) {
  165. if (c3.startTimeField) {
  166. const e2 = this._fieldsIndex.get(c3.startTimeField);
  167. e2 ? (c3.startTimeField = e2.name, e2.type = "esriFieldTypeDate") : c3.startTimeField = null;
  168. }
  169. if (c3.endTimeField) {
  170. const e2 = this._fieldsIndex.get(c3.endTimeField);
  171. e2 ? (c3.endTimeField = e2.name, e2.type = "esriFieldTypeDate") : c3.endTimeField = null;
  172. }
  173. if (c3.trackIdField) {
  174. const e2 = this._fieldsIndex.get(c3.trackIdField);
  175. e2 ? c3.trackIdField = e2.name : (c3.trackIdField = null, i3.push({ name: "geojson-layer:invalid-timeInfo-trackIdField", message: "trackIdField is missing", details: { timeInfo: c3 } }));
  176. }
  177. c3.startTimeField || c3.endTimeField || (i3.push({ name: "geojson-layer:invalid-timeInfo", message: "startTimeField and endTimeField are missing", details: { timeInfo: c3 } }), c3 = null);
  178. }
  179. const I2 = u2 ? o(u2) : null, j3 = { warnings: i3, featureErrors: [], layerDefinition: { ...O, drawingInfo: I2, templates: a(m2), extent: null, geometryType: u2, objectIdField: d, fields: a3, hasZ: !!l, timeInfo: c3 } };
  180. this._queryEngine = new Y({ fields: a3, geometryType: u2, hasM: false, hasZ: l, objectIdField: d, spatialReference: p, timeInfo: c3, featureStore: new u({ geometryType: u2, hasM: false, hasZ: l }), cacheSpatialQueries: true }), this._createDefaultAttributes = i2(m2, d);
  181. const w2 = await this._createFeatures(r3);
  182. this._objectIdGenerator = this._createObjectIdGenerator(this._queryEngine, w2);
  183. const T2 = this._normalizeFeatures(w2, j3.warnings, j3.featureErrors);
  184. if (this._queryEngine.featureStore.addMany(T2), j3.layerDefinition.extent = this._queryEngine.fullExtent, j3.layerDefinition.timeInfo) {
  185. const { start: e2, end: t2 } = this._queryEngine.timeExtent;
  186. j3.layerDefinition.timeInfo.timeExtent = [e2, t2];
  187. }
  188. return j3;
  189. }
  190. async applyEdits(e) {
  191. const { spatialReference: t, geometryType: s3 } = this._queryEngine;
  192. return await Promise.all([w(t, s3), f(e.adds, t), f(e.updates, t)]), await this._waitSnapshotComplete(), this._applyEdits(e);
  193. }
  194. async queryFeatures(e = {}, t = {}) {
  195. return await this._waitSnapshotComplete(), this._queryEngine.executeQuery(e, t.signal);
  196. }
  197. async queryFeatureCount(e = {}, t = {}) {
  198. return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForCount(e, t.signal);
  199. }
  200. async queryObjectIds(e = {}, t = {}) {
  201. return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForIds(e, t.signal);
  202. }
  203. async queryExtent(e = {}, t = {}) {
  204. return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForExtent(e, t.signal);
  205. }
  206. async querySnapping(e, t = {}) {
  207. return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForSnapping(e, t.signal);
  208. }
  209. async refresh(e) {
  210. var _a;
  211. return this._loadOptions.customParameters = e, (_a = this._snapshotTask) == null ? void 0 : _a.abort(), this._snapshotTask = j2(this._snapshotFeatures), this._snapshotTask.promise.then((e2) => {
  212. this._queryEngine.featureStore.clear(), this._objectIdGenerator = this._createObjectIdGenerator(this._queryEngine, e2);
  213. const t = this._normalizeFeatures(e2);
  214. t && this._queryEngine.featureStore.addMany(t);
  215. }, (e2) => {
  216. this._queryEngine.featureStore.clear(), j(e2) || s.getLogger("esri.layers.GeoJSONLayer").error(new s2("geojson-layer:refresh", "An error occurred during refresh", { error: e2 }));
  217. }), await this._waitSnapshotComplete(), { extent: this._queryEngine.fullExtent, timeExtent: this._queryEngine.timeExtent };
  218. }
  219. async _createFeatures(e) {
  220. const { geometryType: t, hasZ: s3, objectIdField: i3 } = this._queryEngine, n = I(e, { geometryType: t, hasZ: s3, objectIdField: i3 });
  221. if (!E(this._queryEngine.spatialReference, c))
  222. for (const a3 of n)
  223. r(a3.geometry) && (a3.geometry = nt(g(rt(a3.geometry, this._queryEngine.geometryType, this._queryEngine.hasZ, false), c, this._queryEngine.spatialReference)));
  224. return n;
  225. }
  226. async _waitSnapshotComplete() {
  227. if (this._snapshotTask && !this._snapshotTask.finished) {
  228. try {
  229. await this._snapshotTask.promise;
  230. } catch {
  231. }
  232. return this._waitSnapshotComplete();
  233. }
  234. }
  235. async _fetch(t) {
  236. const { url: s3, customParameters: i3 } = this._loadOptions, r3 = (await U(s3, { responseType: "json", query: { ...i3 }, signal: t })).data;
  237. return await T(r3), r3;
  238. }
  239. _normalizeFeatures(e, t, s3) {
  240. const { objectIdField: i3 } = this._queryEngine, r3 = [];
  241. for (const n of e) {
  242. const e2 = this._createDefaultAttributes(), a3 = m(this._fieldsIndex, e2, n.attributes, true, t);
  243. a3 ? s3 == null ? void 0 : s3.push(a3) : (this._assignObjectId(e2, n.attributes, true), n.attributes = e2, n.objectId = e2[i3], r3.push(n));
  244. }
  245. return r3;
  246. }
  247. _applyEdits(e) {
  248. const { adds: t, updates: s3, deletes: i3 } = e, r3 = { addResults: [], deleteResults: [], updateResults: [], uidToObjectId: {} };
  249. if (t && t.length && this._applyAddEdits(r3, t), s3 && s3.length && this._applyUpdateEdits(r3, s3), i3 && i3.length) {
  250. for (const e2 of i3)
  251. r3.deleteResults.push(f2(e2));
  252. this._queryEngine.featureStore.removeManyById(i3);
  253. }
  254. return { extent: this._queryEngine.fullExtent, timeExtent: this._queryEngine.timeExtent, featureEditResults: r3 };
  255. }
  256. _applyAddEdits(e, t) {
  257. var _a;
  258. const { addResults: s3 } = e, { geometryType: i3, hasM: n, hasZ: o2, objectIdField: l, spatialReference: u2, featureStore: d } = this._queryEngine, c3 = [];
  259. for (const p of t) {
  260. if (p.geometry && i3 !== c2(p.geometry)) {
  261. s3.push(a2("Incorrect geometry type."));
  262. continue;
  263. }
  264. const t2 = this._createDefaultAttributes(), n2 = m(this._fieldsIndex, t2, p.attributes);
  265. if (n2)
  266. s3.push(n2);
  267. else {
  268. if (this._assignObjectId(t2, p.attributes), p.attributes = t2, null != p.uid) {
  269. const t3 = p.attributes[l];
  270. e.uidToObjectId[p.uid] = t3;
  271. }
  272. if (r(p.geometry)) {
  273. const e2 = (_a = p.geometry.spatialReference) != null ? _a : u2;
  274. p.geometry = g(g2(p.geometry, e2), e2, u2);
  275. }
  276. c3.push(p), s3.push(f2(p.attributes[l]));
  277. }
  278. }
  279. d.addMany(tt([], c3, i3, o2, n, l));
  280. }
  281. _applyUpdateEdits({ updateResults: e }, t) {
  282. var _a;
  283. const { geometryType: s3, hasM: i3, hasZ: n, objectIdField: o2, spatialReference: l, featureStore: u2 } = this._queryEngine;
  284. for (const d of t) {
  285. const { attributes: t2, geometry: p } = d, h = t2 && t2[o2];
  286. if (null == h) {
  287. e.push(a2(`Identifier field ${o2} missing`));
  288. continue;
  289. }
  290. if (!u2.has(h)) {
  291. e.push(a2(`Feature with object id ${h} missing`));
  292. continue;
  293. }
  294. const m2 = ot(u2.getFeature(h), s3, n, i3);
  295. if (r(p)) {
  296. if (s3 !== c2(p)) {
  297. e.push(a2("Incorrect geometry type."));
  298. continue;
  299. }
  300. const t3 = (_a = p.spatialReference) != null ? _a : l;
  301. m2.geometry = g(g2(p, t3), t3, l);
  302. }
  303. if (t2) {
  304. const s4 = m(this._fieldsIndex, m2.attributes, t2);
  305. if (s4) {
  306. e.push(s4);
  307. continue;
  308. }
  309. }
  310. u2.add(X(m2, s3, n, i3, o2)), e.push(f2(h));
  311. }
  312. }
  313. _createObjectIdGenerator(e, t) {
  314. const s3 = e.fieldsIndex.get(e.objectIdField);
  315. if ("esriFieldTypeString" === s3.type)
  316. return () => s3.name + "-" + Date.now().toString(16);
  317. let i3 = Number.NEGATIVE_INFINITY;
  318. for (const r3 of t)
  319. r3.objectId && (i3 = Math.max(i3, r3.objectId));
  320. return i3 = Math.max(0, i3) + 1, () => i3++;
  321. }
  322. _assignObjectId(e, t, s3 = false) {
  323. const i3 = this._queryEngine.objectIdField;
  324. e[i3] = s3 && i3 in t ? t[i3] : this._objectIdGenerator();
  325. }
  326. async _checkProjection(e) {
  327. try {
  328. await f(c, e);
  329. } catch {
  330. throw new s2("geojson-layer", "Projection not supported");
  331. }
  332. }
  333. };
  334. export {
  335. C as default
  336. };
  337. //# sourceMappingURL=GeoJSONSourceWorker-ZQVDDZS5.js.map