MemorySourceWorker-O22FX6GJ.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. import {
  2. n,
  3. t as t2
  4. } from "./chunk-YDZD6ESX.js";
  5. import {
  6. a as a2,
  7. f as f2,
  8. g as g2,
  9. m,
  10. w
  11. } from "./chunk-XHRYELNQ.js";
  12. import {
  13. a,
  14. l as l2,
  15. u as u2
  16. } from "./chunk-4D6PVVFX.js";
  17. import {
  18. u
  19. } from "./chunk-5FHVUYVE.js";
  20. import {
  21. Y
  22. } from "./chunk-NP2BYFXT.js";
  23. import "./chunk-6H5PP7QI.js";
  24. import "./chunk-HSPVIAVJ.js";
  25. import "./chunk-XIEPNAEI.js";
  26. import {
  27. f,
  28. g
  29. } from "./chunk-M5BTTMP6.js";
  30. import "./chunk-WQJRLXWG.js";
  31. import "./chunk-ETWBEEKL.js";
  32. import "./chunk-XZA4MVET.js";
  33. import "./chunk-4GGRJYTB.js";
  34. import "./chunk-D5GG5NVO.js";
  35. import "./chunk-USORKAIZ.js";
  36. import "./chunk-Q34L5KZA.js";
  37. import "./chunk-ROWZMUVJ.js";
  38. import "./chunk-7IKYLNB5.js";
  39. import "./chunk-P4UZNLD5.js";
  40. import {
  41. Q,
  42. W,
  43. ee
  44. } from "./chunk-FYNVVMWY.js";
  45. import "./chunk-Q52DVFYK.js";
  46. import "./chunk-HBMVUVZX.js";
  47. import "./chunk-QOV6ITMI.js";
  48. import "./chunk-DH2OBAUC.js";
  49. import "./chunk-TNLRDNTC.js";
  50. import "./chunk-KUXNUNAI.js";
  51. import {
  52. d
  53. } from "./chunk-KMAHKQ2G.js";
  54. import "./chunk-522WBHUO.js";
  55. import "./chunk-WNCU6BFU.js";
  56. import {
  57. i
  58. } from "./chunk-F6A2QQ26.js";
  59. import "./chunk-EOSZHC5H.js";
  60. import "./chunk-C43UE3Z5.js";
  61. import "./chunk-NE3ESGA6.js";
  62. import "./chunk-YIS6BAC3.js";
  63. import "./chunk-7XXXCK2A.js";
  64. import "./chunk-7ZIDBK7B.js";
  65. import {
  66. P
  67. } from "./chunk-WZQZRKNH.js";
  68. import "./chunk-LRDX4TO7.js";
  69. import "./chunk-WDLTDV2L.js";
  70. import "./chunk-TERAW6FT.js";
  71. import "./chunk-N2663GRX.js";
  72. import "./chunk-O4FY3ITT.js";
  73. import "./chunk-JXW4QTJA.js";
  74. import "./chunk-UXF37FQ4.js";
  75. import "./chunk-ZOEK6QHJ.js";
  76. import "./chunk-XNLG7T2T.js";
  77. import "./chunk-IR4PV7VK.js";
  78. import {
  79. l,
  80. v
  81. } from "./chunk-2Z6LERTI.js";
  82. import "./chunk-OWVBLVP3.js";
  83. import "./chunk-MXB2XLKV.js";
  84. import "./chunk-ALDCDSPV.js";
  85. import "./chunk-DT6EAZQ5.js";
  86. import "./chunk-HNOZUNJ4.js";
  87. import "./chunk-VNFRAYHO.js";
  88. import "./chunk-R5IG2D6H.js";
  89. import "./chunk-VBRY5KJM.js";
  90. import "./chunk-PDKDCAAD.js";
  91. import "./chunk-ECW2QABR.js";
  92. import "./chunk-GCDJLKH4.js";
  93. import {
  94. c
  95. } from "./chunk-MRJEICT6.js";
  96. import "./chunk-Y3WMVFTW.js";
  97. import "./chunk-SAS7RONY.js";
  98. import "./chunk-WSRBH7BF.js";
  99. import "./chunk-IHXECKQQ.js";
  100. import "./chunk-ULGDPLM2.js";
  101. import {
  102. s3 as s
  103. } from "./chunk-EMJ4ZSM2.js";
  104. import "./chunk-IKP3YN53.js";
  105. import {
  106. r,
  107. t
  108. } from "./chunk-GZT4BVFP.js";
  109. import "./chunk-A5ICIBVI.js";
  110. // node_modules/@arcgis/core/layers/graphics/sources/support/MemorySourceWorker.js
  111. var R = c;
  112. var q = { xmin: -180, ymin: -90, xmax: 180, ymax: 90, spatialReference: c };
  113. var D = { 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 } };
  114. function O(e) {
  115. return l(e) ? e.z != null : !!e.hasZ;
  116. }
  117. function w2(e) {
  118. return l(e) ? e.m != null : !!e.hasM;
  119. }
  120. var S = class {
  121. constructor() {
  122. this._queryEngine = null, this._nextObjectId = null;
  123. }
  124. destroy() {
  125. this._queryEngine && this._queryEngine && this._queryEngine.destroy(), this._queryEngine = this._fieldsIndex = this._createDefaultAttributes = null;
  126. }
  127. async load(t3) {
  128. const i2 = [], { features: s2 } = t3, r2 = this._inferLayerProperties(s2, t3.fields), n2 = t3.fields || [], a3 = t3.hasM != null ? t3.hasM : r2.hasM, o = t3.hasZ != null ? t3.hasZ : r2.hasZ, l3 = !t3.spatialReference && !r2.spatialReference, y = l3 ? R : t3.spatialReference || r2.spatialReference, I = l3 ? q : null, b = t3.geometryType || r2.geometryType, F = !b;
  129. let j = t3.objectIdField || r2.objectIdField, _ = t3.timeInfo;
  130. if (!F && (l3 && i2.push({ name: "feature-layer:spatial-reference-not-found", message: "Spatial reference not provided or found in features. Defaults to WGS84" }), !b))
  131. throw new s("feature-layer:missing-property", "geometryType not set and couldn't be inferred from the provided features");
  132. if (!j)
  133. throw new s("feature-layer:missing-property", "objectIdField not set and couldn't be found in the provided fields");
  134. if (r2.objectIdField && j !== r2.objectIdField && (i2.push({ name: "feature-layer:duplicated-oid-field", message: `Provided objectIdField "${j}" doesn't match the field name "${r2.objectIdField}", found in the provided fields` }), j = r2.objectIdField), j && !r2.objectIdField) {
  135. let e = null;
  136. n2.some((t4) => t4.name === j && (e = t4, true)) ? (e.type = "esriFieldTypeOID", e.editable = false, e.nullable = false) : n2.unshift({ alias: j, name: j, type: "esriFieldTypeOID", editable: false, nullable: false });
  137. }
  138. for (const u3 of n2) {
  139. if (u3.name == null && (u3.name = u3.alias), u3.alias == null && (u3.alias = u3.name), !u3.name)
  140. throw new s("feature-layer:invalid-field-name", "field name is missing", { field: u3 });
  141. if (u3.name === j && (u3.type = "esriFieldTypeOID"), !i.jsonValues.includes(u3.type))
  142. throw new s("feature-layer:invalid-field-type", `invalid type for field "${u3.name}"`, { field: u3 });
  143. }
  144. const O2 = {};
  145. for (const e of n2)
  146. if (e.type !== "esriFieldTypeOID" && e.type !== "esriFieldTypeGlobalID") {
  147. const t4 = P(e);
  148. t4 !== void 0 && (O2[e.name] = t4);
  149. }
  150. if (this._fieldsIndex = new d(n2), this._createDefaultAttributes = a(O2, j), _) {
  151. if (_.startTimeField) {
  152. const e = this._fieldsIndex.get(_.startTimeField);
  153. e ? (_.startTimeField = e.name, e.type = "esriFieldTypeDate") : _.startTimeField = null;
  154. }
  155. if (_.endTimeField) {
  156. const e = this._fieldsIndex.get(_.endTimeField);
  157. e ? (_.endTimeField = e.name, e.type = "esriFieldTypeDate") : _.endTimeField = null;
  158. }
  159. if (_.trackIdField) {
  160. const e = this._fieldsIndex.get(_.trackIdField);
  161. e ? _.trackIdField = e.name : (_.trackIdField = null, i2.push({ name: "feature-layer:invalid-timeInfo-trackIdField", message: "trackIdField is missing", details: { timeInfo: _ } }));
  162. }
  163. _.startTimeField || _.endTimeField || (i2.push({ name: "feature-layer:invalid-timeInfo", message: "startTimeField and endTimeField are missing or invalid", details: { timeInfo: _ } }), _ = null);
  164. }
  165. const w3 = { warnings: i2, featureErrors: [], layerDefinition: { ...D, drawingInfo: u2(b), templates: l2(O2), extent: I, geometryType: b, objectIdField: j, fields: n2, hasZ: !!o, hasM: !!a3, timeInfo: _ }, assignedObjectIds: {} };
  166. if (this._queryEngine = new Y({ fields: n2, geometryType: b, hasM: a3, hasZ: o, objectIdField: j, spatialReference: y, featureStore: new u({ geometryType: b, hasM: a3, hasZ: o }), timeInfo: _, cacheSpatialQueries: true }), !s2 || !s2.length)
  167. return this._nextObjectId = t2, w3;
  168. const S2 = n(j, s2);
  169. return this._nextObjectId = S2 + 1, await f(s2, y), this._loadInitialFeatures(w3, s2);
  170. }
  171. async applyEdits(e) {
  172. const { spatialReference: t3, geometryType: i2 } = this._queryEngine;
  173. return await Promise.all([w(t3, i2), f(e.adds, t3), f(e.updates, t3)]), this._applyEdits(e);
  174. }
  175. queryFeatures(e, t3 = {}) {
  176. return this._queryEngine.executeQuery(e, t3.signal);
  177. }
  178. queryFeatureCount(e, t3 = {}) {
  179. return this._queryEngine.executeQueryForCount(e, t3.signal);
  180. }
  181. queryObjectIds(e, t3 = {}) {
  182. return this._queryEngine.executeQueryForIds(e, t3.signal);
  183. }
  184. queryExtent(e, t3 = {}) {
  185. return this._queryEngine.executeQueryForExtent(e, t3.signal);
  186. }
  187. querySnapping(e, t3 = {}) {
  188. return this._queryEngine.executeQueryForSnapping(e, t3.signal);
  189. }
  190. _inferLayerProperties(e, i2) {
  191. let r2, n2, a3 = null, o = null, l3 = null;
  192. for (const u3 of e) {
  193. const e2 = u3.geometry;
  194. if (!t(e2) && (a3 || (a3 = v(e2)), o || (o = e2.spatialReference), r2 == null && (r2 = O(e2)), n2 == null && (n2 = w2(e2)), a3 && o && r2 != null && n2 != null))
  195. break;
  196. }
  197. if (i2 && i2.length) {
  198. let e2 = null;
  199. i2.some((t3) => {
  200. const i3 = t3.type === "esriFieldTypeOID", s2 = !t3.type && t3.name && t3.name.toLowerCase() === "objectid";
  201. return e2 = t3, i3 || s2;
  202. }) && (l3 = e2.name);
  203. }
  204. return { geometryType: a3, spatialReference: o, objectIdField: l3, hasM: n2, hasZ: r2 };
  205. }
  206. _loadInitialFeatures(e, t3) {
  207. const { geometryType: r2, hasM: n2, hasZ: o, objectIdField: l3, spatialReference: u3, featureStore: d2 } = this._queryEngine, p = [];
  208. for (const a3 of t3) {
  209. if (a3.uid != null && (e.assignedObjectIds[a3.uid] = -1), a3.geometry && r2 !== v(a3.geometry)) {
  210. e.featureErrors.push(a2("Incorrect geometry type."));
  211. continue;
  212. }
  213. const t4 = this._createDefaultAttributes(), n3 = m(this._fieldsIndex, t4, a3.attributes, true, e.warnings);
  214. n3 ? e.featureErrors.push(n3) : (this._assignObjectId(t4, a3.attributes, true), a3.attributes = t4, a3.uid != null && (e.assignedObjectIds[a3.uid] = a3.attributes[l3]), r(a3.geometry) && (a3.geometry = g(a3.geometry, a3.geometry.spatialReference, u3)), p.push(a3));
  215. }
  216. if (d2.addMany(W([], p, r2, o, n2, l3)), e.layerDefinition.extent = this._queryEngine.fullExtent, e.layerDefinition.timeInfo) {
  217. const { start: t4, end: i2 } = this._queryEngine.timeExtent;
  218. e.layerDefinition.timeInfo.timeExtent = [t4, i2];
  219. }
  220. return e;
  221. }
  222. _applyEdits(e) {
  223. const { adds: t3, updates: i2, deletes: s2 } = e, r2 = { addResults: [], deleteResults: [], updateResults: [], uidToObjectId: {} };
  224. if (t3 && t3.length && this._applyAddEdits(r2, t3), i2 && i2.length && this._applyUpdateEdits(r2, i2), s2 && s2.length) {
  225. for (const e2 of s2)
  226. r2.deleteResults.push(f2(e2));
  227. this._queryEngine.featureStore.removeManyById(s2);
  228. }
  229. return { fullExtent: this._queryEngine.fullExtent, featureEditResults: r2 };
  230. }
  231. _applyAddEdits(e, t3) {
  232. const { addResults: r2 } = e, { geometryType: n2, hasM: o, hasZ: l3, objectIdField: u3, spatialReference: d2, featureStore: p } = this._queryEngine, f3 = [];
  233. for (const a3 of t3) {
  234. if (a3.geometry && n2 !== v(a3.geometry)) {
  235. r2.push(a2("Incorrect geometry type."));
  236. continue;
  237. }
  238. const t4 = this._createDefaultAttributes(), o2 = m(this._fieldsIndex, t4, a3.attributes);
  239. if (o2)
  240. r2.push(o2);
  241. else {
  242. if (this._assignObjectId(t4, a3.attributes), a3.attributes = t4, a3.uid != null) {
  243. const t5 = a3.attributes[u3];
  244. e.uidToObjectId[a3.uid] = t5;
  245. }
  246. r(a3.geometry) && (a3.geometry = g(g2(a3.geometry, d2), a3.geometry.spatialReference, d2)), f3.push(a3), r2.push(f2(a3.attributes[u3]));
  247. }
  248. }
  249. p.addMany(W([], f3, n2, l3, o, u3));
  250. }
  251. _applyUpdateEdits({ updateResults: e }, t3) {
  252. const { geometryType: r2, hasM: n2, hasZ: a3, objectIdField: u3, spatialReference: d2, featureStore: p } = this._queryEngine;
  253. for (const f3 of t3) {
  254. const { attributes: t4, geometry: c2 } = f3, m2 = t4 && t4[u3];
  255. if (m2 == null) {
  256. e.push(a2(`Identifier field ${u3} missing`));
  257. continue;
  258. }
  259. if (!p.has(m2)) {
  260. e.push(a2(`Feature with object id ${m2} missing`));
  261. continue;
  262. }
  263. const h = ee(p.getFeature(m2), r2, a3, n2);
  264. if (r(c2)) {
  265. if (r2 !== v(c2)) {
  266. e.push(a2("Incorrect geometry type."));
  267. continue;
  268. }
  269. h.geometry = g(g2(c2, d2), c2.spatialReference, d2);
  270. }
  271. if (t4) {
  272. const i2 = m(this._fieldsIndex, h.attributes, t4);
  273. if (i2) {
  274. e.push(i2);
  275. continue;
  276. }
  277. }
  278. p.add(Q(h, r2, a3, n2, u3)), e.push(f2(m2));
  279. }
  280. }
  281. _assignObjectId(e, t3, i2 = false) {
  282. const s2 = this._queryEngine.objectIdField;
  283. i2 && t3 && isFinite(t3[s2]) ? e[s2] = t3[s2] : e[s2] = this._nextObjectId++;
  284. }
  285. };
  286. export {
  287. S as default
  288. };
  289. //# sourceMappingURL=MemorySourceWorker-O22FX6GJ.js.map