MemorySourceWorker-6VFACWO6.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. import {
  2. n,
  3. t as t2
  4. } from "./chunk-V4I7Q273.js";
  5. import {
  6. a as a2,
  7. f as f2,
  8. g as g2,
  9. m,
  10. w
  11. } from "./chunk-QR6V6X5R.js";
  12. import {
  13. a,
  14. i as i2,
  15. o
  16. } from "./chunk-A6WD5XTM.js";
  17. import {
  18. u
  19. } from "./chunk-RDOYANC4.js";
  20. import {
  21. Y
  22. } from "./chunk-FSIQKOJP.js";
  23. import "./chunk-OQSZOHTF.js";
  24. import "./chunk-OP2HNSVZ.js";
  25. import "./chunk-UVQJ7AVD.js";
  26. import "./chunk-DMVKVC5I.js";
  27. import "./chunk-Y7BZ6TKQ.js";
  28. import {
  29. f,
  30. g
  31. } from "./chunk-VEJPYAE4.js";
  32. import "./chunk-4GGDRIJK.js";
  33. import "./chunk-D5UVUJIX.js";
  34. import "./chunk-PZ7XDUL6.js";
  35. import "./chunk-ULSPZIPE.js";
  36. import "./chunk-UMUHMVL4.js";
  37. import "./chunk-FZSI6IGI.js";
  38. import "./chunk-B5O7N7PM.js";
  39. import "./chunk-KOKTANE6.js";
  40. import "./chunk-OKUFE7TO.js";
  41. import {
  42. X,
  43. ot,
  44. tt
  45. } from "./chunk-JKFWEHNK.js";
  46. import "./chunk-IIAN3QNN.js";
  47. import "./chunk-P24XEEHY.js";
  48. import "./chunk-WOXHUQGM.js";
  49. import "./chunk-FMPQIGFA.js";
  50. import "./chunk-EDHROVWI.js";
  51. import "./chunk-3IRT3YKJ.js";
  52. import "./chunk-SAJAEMIJ.js";
  53. import "./chunk-ZSW35JPD.js";
  54. import {
  55. r as r2
  56. } from "./chunk-JLSNMUQJ.js";
  57. import "./chunk-ECY35CJI.js";
  58. import "./chunk-PT62335L.js";
  59. import {
  60. i
  61. } from "./chunk-QEWF7QPH.js";
  62. import "./chunk-FNA5GLRW.js";
  63. import "./chunk-MCWCB5IY.js";
  64. import "./chunk-TJV6ODRM.js";
  65. import {
  66. M
  67. } from "./chunk-CRGY2SDS.js";
  68. import "./chunk-4T5ZGMEN.js";
  69. import "./chunk-CZBRZ6SU.js";
  70. import "./chunk-VGWC3IKZ.js";
  71. import "./chunk-2H5MD622.js";
  72. import "./chunk-3RSFVUKZ.js";
  73. import "./chunk-X4SA4ELJ.js";
  74. import "./chunk-5N7JLUJJ.js";
  75. import "./chunk-ZLNEXZAN.js";
  76. import "./chunk-ZYRIJWLX.js";
  77. import "./chunk-RYY6632W.js";
  78. import "./chunk-DW42UVIT.js";
  79. import "./chunk-YAEIHDJH.js";
  80. import "./chunk-TJNOJH33.js";
  81. import "./chunk-OSHI574D.js";
  82. import "./chunk-ETGAZ7LF.js";
  83. import "./chunk-75U5LM2V.js";
  84. import {
  85. c as c2,
  86. s as s2
  87. } from "./chunk-RMDDCMKS.js";
  88. import "./chunk-VCH45Q2I.js";
  89. import "./chunk-GSSTTHIT.js";
  90. import "./chunk-IM3LVQXV.js";
  91. import "./chunk-HZRKBTHJ.js";
  92. import "./chunk-DVUG3KID.js";
  93. import "./chunk-FWSQEIAR.js";
  94. import "./chunk-VEGAOVMY.js";
  95. import "./chunk-6T6G6LCQ.js";
  96. import "./chunk-YEJL5NEF.js";
  97. import {
  98. c
  99. } from "./chunk-PQFTYGF5.js";
  100. import "./chunk-2Z2TG5CU.js";
  101. import "./chunk-6KZ2LTDA.js";
  102. import "./chunk-U2XHEJM7.js";
  103. import "./chunk-SQOPWYIT.js";
  104. import "./chunk-V6P2MAQQ.js";
  105. import {
  106. s3 as s
  107. } from "./chunk-E5O6P5I2.js";
  108. import "./chunk-SPWQ3AWG.js";
  109. import "./chunk-2TIUKVZN.js";
  110. import {
  111. r,
  112. t
  113. } from "./chunk-YXWMMD76.js";
  114. import "./chunk-S5KM4IGW.js";
  115. // node_modules/@arcgis/core/layers/graphics/sources/support/MemorySourceWorker.js
  116. var R = c;
  117. var q = { xmin: -180, ymin: -90, xmax: 180, ymax: 90, spatialReference: c };
  118. 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 } };
  119. function O(e) {
  120. return s2(e) ? null != e.z : !!e.hasZ;
  121. }
  122. function w2(e) {
  123. return s2(e) ? null != e.m : !!e.hasM;
  124. }
  125. var S = class {
  126. constructor() {
  127. this._queryEngine = null, this._nextObjectId = null;
  128. }
  129. destroy() {
  130. this._queryEngine && this._queryEngine && this._queryEngine.destroy(), this._queryEngine = this._fieldsIndex = this._createDefaultAttributes = null;
  131. }
  132. async load(t3) {
  133. const i3 = [], { features: s3 } = t3, r3 = this._inferLayerProperties(s3, t3.fields), n2 = t3.fields || [], a3 = null != t3.hasM ? t3.hasM : r3.hasM, o2 = null != t3.hasZ ? t3.hasZ : r3.hasZ, l = !t3.spatialReference && !r3.spatialReference, y = l ? R : t3.spatialReference || r3.spatialReference, I = l ? q : null, b = t3.geometryType || r3.geometryType, F = !b;
  134. let j = t3.objectIdField || r3.objectIdField, _ = t3.timeInfo;
  135. if (!F && (l && i3.push({ name: "feature-layer:spatial-reference-not-found", message: "Spatial reference not provided or found in features. Defaults to WGS84" }), !b))
  136. throw new s("feature-layer:missing-property", "geometryType not set and couldn't be inferred from the provided features");
  137. if (!j)
  138. throw new s("feature-layer:missing-property", "objectIdField not set and couldn't be found in the provided fields");
  139. if (r3.objectIdField && j !== r3.objectIdField && (i3.push({ name: "feature-layer:duplicated-oid-field", message: `Provided objectIdField "${j}" doesn't match the field name "${r3.objectIdField}", found in the provided fields` }), j = r3.objectIdField), j && !r3.objectIdField) {
  140. let e = null;
  141. 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 });
  142. }
  143. for (const u2 of n2) {
  144. if (null == u2.name && (u2.name = u2.alias), null == u2.alias && (u2.alias = u2.name), !u2.name)
  145. throw new s("feature-layer:invalid-field-name", "field name is missing", { field: u2 });
  146. if (u2.name === j && (u2.type = "esriFieldTypeOID"), !i.jsonValues.includes(u2.type))
  147. throw new s("feature-layer:invalid-field-type", `invalid type for field "${u2.name}"`, { field: u2 });
  148. }
  149. const O2 = {};
  150. for (const e of n2)
  151. if ("esriFieldTypeOID" !== e.type && "esriFieldTypeGlobalID" !== e.type) {
  152. const t4 = M(e);
  153. void 0 !== t4 && (O2[e.name] = t4);
  154. }
  155. if (this._fieldsIndex = new r2(n2), this._createDefaultAttributes = i2(O2, j), _) {
  156. if (_.startTimeField) {
  157. const e = this._fieldsIndex.get(_.startTimeField);
  158. e ? (_.startTimeField = e.name, e.type = "esriFieldTypeDate") : _.startTimeField = null;
  159. }
  160. if (_.endTimeField) {
  161. const e = this._fieldsIndex.get(_.endTimeField);
  162. e ? (_.endTimeField = e.name, e.type = "esriFieldTypeDate") : _.endTimeField = null;
  163. }
  164. if (_.trackIdField) {
  165. const e = this._fieldsIndex.get(_.trackIdField);
  166. e ? _.trackIdField = e.name : (_.trackIdField = null, i3.push({ name: "feature-layer:invalid-timeInfo-trackIdField", message: "trackIdField is missing", details: { timeInfo: _ } }));
  167. }
  168. _.startTimeField || _.endTimeField || (i3.push({ name: "feature-layer:invalid-timeInfo", message: "startTimeField and endTimeField are missing or invalid", details: { timeInfo: _ } }), _ = null);
  169. }
  170. const w3 = { warnings: i3, featureErrors: [], layerDefinition: { ...D, drawingInfo: o(b), templates: a(O2), extent: I, geometryType: b, objectIdField: j, fields: n2, hasZ: !!o2, hasM: !!a3, timeInfo: _ }, assignedObjectIds: {} };
  171. if (this._queryEngine = new Y({ fields: n2, geometryType: b, hasM: a3, hasZ: o2, objectIdField: j, spatialReference: y, featureStore: new u({ geometryType: b, hasM: a3, hasZ: o2 }), timeInfo: _, cacheSpatialQueries: true }), !s3 || !s3.length)
  172. return this._nextObjectId = t2, w3;
  173. const S2 = n(j, s3);
  174. return this._nextObjectId = S2 + 1, await f(s3, y), this._loadInitialFeatures(w3, s3);
  175. }
  176. async applyEdits(e) {
  177. const { spatialReference: t3, geometryType: i3 } = this._queryEngine;
  178. return await Promise.all([w(t3, i3), f(e.adds, t3), f(e.updates, t3)]), this._applyEdits(e);
  179. }
  180. queryFeatures(e, t3 = {}) {
  181. return this._queryEngine.executeQuery(e, t3.signal);
  182. }
  183. queryFeatureCount(e, t3 = {}) {
  184. return this._queryEngine.executeQueryForCount(e, t3.signal);
  185. }
  186. queryObjectIds(e, t3 = {}) {
  187. return this._queryEngine.executeQueryForIds(e, t3.signal);
  188. }
  189. queryExtent(e, t3 = {}) {
  190. return this._queryEngine.executeQueryForExtent(e, t3.signal);
  191. }
  192. querySnapping(e, t3 = {}) {
  193. return this._queryEngine.executeQueryForSnapping(e, t3.signal);
  194. }
  195. _inferLayerProperties(e, i3) {
  196. let r3, n2, a3 = null, o2 = null, l = null;
  197. for (const u2 of e) {
  198. const e2 = u2.geometry;
  199. if (!t(e2) && (a3 || (a3 = c2(e2)), o2 || (o2 = e2.spatialReference), null == r3 && (r3 = O(e2)), null == n2 && (n2 = w2(e2)), a3 && o2 && null != r3 && null != n2))
  200. break;
  201. }
  202. if (i3 && i3.length) {
  203. let e2 = null;
  204. i3.some((t3) => {
  205. const i4 = "esriFieldTypeOID" === t3.type, s3 = !t3.type && t3.name && "objectid" === t3.name.toLowerCase();
  206. return e2 = t3, i4 || s3;
  207. }) && (l = e2.name);
  208. }
  209. return { geometryType: a3, spatialReference: o2, objectIdField: l, hasM: n2, hasZ: r3 };
  210. }
  211. _loadInitialFeatures(e, t3) {
  212. const { geometryType: r3, hasM: n2, hasZ: o2, objectIdField: l, spatialReference: u2, featureStore: d } = this._queryEngine, p = [];
  213. for (const a3 of t3) {
  214. if (null != a3.uid && (e.assignedObjectIds[a3.uid] = -1), a3.geometry && r3 !== c2(a3.geometry)) {
  215. e.featureErrors.push(a2("Incorrect geometry type."));
  216. continue;
  217. }
  218. const t4 = this._createDefaultAttributes(), n3 = m(this._fieldsIndex, t4, a3.attributes, true, e.warnings);
  219. n3 ? e.featureErrors.push(n3) : (this._assignObjectId(t4, a3.attributes, true), a3.attributes = t4, null != a3.uid && (e.assignedObjectIds[a3.uid] = a3.attributes[l]), r(a3.geometry) && (a3.geometry = g(a3.geometry, a3.geometry.spatialReference, u2)), p.push(a3));
  220. }
  221. if (d.addMany(tt([], p, r3, o2, n2, l)), e.layerDefinition.extent = this._queryEngine.fullExtent, e.layerDefinition.timeInfo) {
  222. const { start: t4, end: i3 } = this._queryEngine.timeExtent;
  223. e.layerDefinition.timeInfo.timeExtent = [t4, i3];
  224. }
  225. return e;
  226. }
  227. _applyEdits(e) {
  228. const { adds: t3, updates: i3, deletes: s3 } = e, r3 = { addResults: [], deleteResults: [], updateResults: [], uidToObjectId: {} };
  229. if (t3 && t3.length && this._applyAddEdits(r3, t3), i3 && i3.length && this._applyUpdateEdits(r3, i3), s3 && s3.length) {
  230. for (const e2 of s3)
  231. r3.deleteResults.push(f2(e2));
  232. this._queryEngine.featureStore.removeManyById(s3);
  233. }
  234. return { fullExtent: this._queryEngine.fullExtent, featureEditResults: r3 };
  235. }
  236. _applyAddEdits(e, t3) {
  237. var _a;
  238. const { addResults: r3 } = e, { geometryType: n2, hasM: o2, hasZ: l, objectIdField: u2, spatialReference: d, featureStore: p } = this._queryEngine, f3 = [];
  239. for (const a3 of t3) {
  240. if (a3.geometry && n2 !== c2(a3.geometry)) {
  241. r3.push(a2("Incorrect geometry type."));
  242. continue;
  243. }
  244. const t4 = this._createDefaultAttributes(), o3 = m(this._fieldsIndex, t4, a3.attributes);
  245. if (o3)
  246. r3.push(o3);
  247. else {
  248. if (this._assignObjectId(t4, a3.attributes), a3.attributes = t4, null != a3.uid) {
  249. const t5 = a3.attributes[u2];
  250. e.uidToObjectId[a3.uid] = t5;
  251. }
  252. if (r(a3.geometry)) {
  253. const e2 = (_a = a3.geometry.spatialReference) != null ? _a : d;
  254. a3.geometry = g(g2(a3.geometry, e2), e2, d);
  255. }
  256. f3.push(a3), r3.push(f2(a3.attributes[u2]));
  257. }
  258. }
  259. p.addMany(tt([], f3, n2, l, o2, u2));
  260. }
  261. _applyUpdateEdits({ updateResults: e }, t3) {
  262. var _a;
  263. const { geometryType: r3, hasM: n2, hasZ: a3, objectIdField: u2, spatialReference: d, featureStore: p } = this._queryEngine;
  264. for (const f3 of t3) {
  265. const { attributes: t4, geometry: c3 } = f3, m2 = t4 && t4[u2];
  266. if (null == m2) {
  267. e.push(a2(`Identifier field ${u2} missing`));
  268. continue;
  269. }
  270. if (!p.has(m2)) {
  271. e.push(a2(`Feature with object id ${m2} missing`));
  272. continue;
  273. }
  274. const h = ot(p.getFeature(m2), r3, a3, n2);
  275. if (r(c3)) {
  276. if (r3 !== c2(c3)) {
  277. e.push(a2("Incorrect geometry type."));
  278. continue;
  279. }
  280. const t5 = (_a = c3.spatialReference) != null ? _a : d;
  281. h.geometry = g(g2(c3, t5), t5, d);
  282. }
  283. if (t4) {
  284. const i3 = m(this._fieldsIndex, h.attributes, t4);
  285. if (i3) {
  286. e.push(i3);
  287. continue;
  288. }
  289. }
  290. p.add(X(h, r3, a3, n2, u2)), e.push(f2(m2));
  291. }
  292. }
  293. _assignObjectId(e, t3, i3 = false) {
  294. const s3 = this._queryEngine.objectIdField;
  295. i3 && t3 && isFinite(t3[s3]) ? e[s3] = t3[s3] : e[s3] = this._nextObjectId++;
  296. }
  297. };
  298. export {
  299. S as default
  300. };
  301. //# sourceMappingURL=MemorySourceWorker-6VFACWO6.js.map