chunk-IY6TL5XB.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. import {
  2. b
  3. } from "./chunk-PHAKVYRM.js";
  4. import {
  5. s as s2
  6. } from "./chunk-22KBQSDB.js";
  7. import {
  8. i
  9. } from "./chunk-QU433TMZ.js";
  10. import {
  11. a,
  12. m
  13. } from "./chunk-IEU3AM37.js";
  14. import {
  15. G
  16. } from "./chunk-ECY35CJI.js";
  17. import {
  18. o
  19. } from "./chunk-4T5ZGMEN.js";
  20. import {
  21. n
  22. } from "./chunk-IM3LVQXV.js";
  23. import {
  24. s2 as s
  25. } from "./chunk-E5O6P5I2.js";
  26. import {
  27. has
  28. } from "./chunk-SPWQ3AWG.js";
  29. import {
  30. e,
  31. r,
  32. t
  33. } from "./chunk-YXWMMD76.js";
  34. // node_modules/@arcgis/core/views/2d/arcade/callExpressionWithCursor.js
  35. function a2(a3, t2, o3) {
  36. if (t(a3))
  37. return null;
  38. const u2 = t2.readArcadeFeature();
  39. try {
  40. return a3.evaluate({ ...o3, $feature: u2 });
  41. } catch (n2) {
  42. return s.getLogger("esri.views.2d.support.arcadeOnDemand").warn("Feature arcade evaluation failed:", n2), null;
  43. }
  44. }
  45. // node_modules/@arcgis/core/views/2d/layers/features/Store2D.js
  46. var o2 = import("./labelFormatUtils-QBH7I42E.js");
  47. var c = class {
  48. constructor(e2, s3) {
  49. this._canCacheExpressionValue = false, this._sourceInfo = e2, this._storage = s3, this._bitsets = { computed: s3.getBitset(s3.createBitset()) };
  50. }
  51. get storage() {
  52. return this._storage;
  53. }
  54. invalidate() {
  55. this._bitsets.computed.clear();
  56. }
  57. async updateSchema(r3, a3) {
  58. const o3 = m(this._schema, a3);
  59. if (this._schema = a3, !a3 || t(o3) || !a(o3, "attributes"))
  60. return;
  61. has("esri-2d-update-debug") && console.debug("Applying Update - Store:", o3), this._bitsets.computed.clear(), r3.targets[a3.name] = true;
  62. const c3 = a3.attributes, n2 = [], p = [];
  63. for (const e2 in c3) {
  64. const s3 = c3[e2];
  65. switch (s3.type) {
  66. case "field":
  67. break;
  68. case "expression":
  69. n2.push(this._createArcadeComputedField(s3));
  70. break;
  71. case "label-expression":
  72. n2.push(this._createLabelArcadeComputedField(s3));
  73. break;
  74. case "statistic":
  75. p.push(s3);
  76. }
  77. }
  78. this._computedFields = await Promise.all(n2), this._canCacheExpressionValue = !this._computedFields.some((e2) => "expression" === e2.type && r(e2.expression) && e2.expression.referencesScale()), this._statisticFields = p;
  79. }
  80. setComputedAttributes(e2, s3, t2, i2) {
  81. const r3 = this._bitsets.computed;
  82. if (!this._canCacheExpressionValue || !r3.has(t2)) {
  83. r3.set(t2);
  84. for (const r4 of this._computedFields) {
  85. const a3 = this._evaluateField(s3, r4, i2);
  86. switch (r4.resultType) {
  87. case "numeric":
  88. e2.setComputedNumericAtIndex(t2, r4.fieldIndex, a3);
  89. break;
  90. case "string":
  91. e2.setComputedStringAtIndex(t2, r4.fieldIndex, a3);
  92. }
  93. }
  94. }
  95. }
  96. async _createArcadeComputedField(e2) {
  97. const s3 = this._sourceInfo.spatialReference, t2 = this._sourceInfo.fieldsIndex;
  98. return { ...e2, expression: await o(e2.valueExpression, s3, t2) };
  99. }
  100. async _createLabelArcadeComputedField(e2) {
  101. const s3 = this._sourceInfo.spatialReference, t2 = this._sourceInfo.fieldsIndex, { createLabelFunction: i2 } = await o2, r3 = await i2(e2.label, t2, s3);
  102. return { ...e2, builder: r3 };
  103. }
  104. _evaluateField(e2, s3, t2) {
  105. switch (s3.type) {
  106. case "label-expression": {
  107. const t3 = e2.readArcadeFeature();
  108. return s3.builder.evaluate(t3) || "";
  109. }
  110. case "expression": {
  111. const { expression: i2 } = s3;
  112. return a2(i2, e2, { $view: { scale: t2 } });
  113. }
  114. }
  115. }
  116. };
  117. // node_modules/@arcgis/core/views/2d/layers/features/support/FeatureSetReaderPBFIndirect.js
  118. var r2 = class extends b {
  119. constructor(r3, t2) {
  120. super(b.createInstance(), r3.fullSchema()), this._currentIndex = -1, this._reader = r3, this._indices = t2;
  121. }
  122. static from(e2, t2) {
  123. return new r2(e2.copy(), t2);
  124. }
  125. get hasNext() {
  126. return this._currentIndex + 1 < this._indices.length;
  127. }
  128. getSize() {
  129. return this._indices.length;
  130. }
  131. getCursor() {
  132. return this.copy();
  133. }
  134. copy() {
  135. const e2 = new r2(this._reader.copy(), this._indices);
  136. return e2._currentIndex = this._currentIndex, e2;
  137. }
  138. next() {
  139. for (; this._nextIndex() && !this._reader._getExists(); )
  140. ;
  141. return this._currentIndex < this._indices.length;
  142. }
  143. _nextIndex() {
  144. return ++this._currentIndex < this._indices.length && (this._reader.setIndex(this._indices[this._currentIndex]), true);
  145. }
  146. setArcadeSpatialReference(e2) {
  147. this._reader.setArcadeSpatialReference(e2);
  148. }
  149. attachStorage(e2) {
  150. this._reader.attachStorage(e2);
  151. }
  152. get geometryType() {
  153. return this._reader.geometryType;
  154. }
  155. get hasFeatures() {
  156. return this._reader.hasFeatures;
  157. }
  158. get exceededTransferLimit() {
  159. return this._reader.exceededTransferLimit;
  160. }
  161. get hasZ() {
  162. return this._reader.hasZ;
  163. }
  164. get hasM() {
  165. return this._reader.hasM;
  166. }
  167. getStorage() {
  168. return this._reader.getStorage();
  169. }
  170. getComputedNumeric(e2) {
  171. return this._reader.getComputedNumericAtIndex(0);
  172. }
  173. setComputedNumeric(e2, r3) {
  174. return this._reader.setComputedNumericAtIndex(r3, 0);
  175. }
  176. getComputedString(e2) {
  177. return this._reader.getComputedStringAtIndex(0);
  178. }
  179. setComputedString(e2, r3) {
  180. return this._reader.setComputedStringAtIndex(0, r3);
  181. }
  182. getComputedNumericAtIndex(e2) {
  183. return this._reader.getComputedNumericAtIndex(e2);
  184. }
  185. setComputedNumericAtIndex(e2, r3) {
  186. this._reader.setComputedNumericAtIndex(e2, r3);
  187. }
  188. getComputedStringAtIndex(e2) {
  189. return this._reader.getComputedStringAtIndex(e2);
  190. }
  191. setComputedStringAtIndex(e2, r3) {
  192. return this._reader.setComputedStringAtIndex(e2, r3);
  193. }
  194. transform(e2, r3, t2, d) {
  195. const a3 = this.copy();
  196. return a3._reader = this._reader.transform(e2, r3, t2, d), a3;
  197. }
  198. readAttribute(e2, r3 = false) {
  199. return this._reader.readAttribute(e2, r3);
  200. }
  201. readAttributes() {
  202. return this._reader.readAttributes();
  203. }
  204. joinAttributes(e2) {
  205. return this._reader.joinAttributes(e2);
  206. }
  207. readArcadeFeature() {
  208. return this._reader.readArcadeFeature();
  209. }
  210. geometry() {
  211. return this._reader.geometry();
  212. }
  213. field(e2) {
  214. return this.readAttribute(e2, true);
  215. }
  216. hasField(e2) {
  217. return this._reader.hasField(e2);
  218. }
  219. setField(e2, r3) {
  220. return this._reader.setField(e2, r3);
  221. }
  222. keys() {
  223. return this._reader.keys();
  224. }
  225. castToText(e2 = false) {
  226. return this._reader.castToText(e2);
  227. }
  228. getQuantizationTransform() {
  229. return this._reader.getQuantizationTransform();
  230. }
  231. getFieldNames() {
  232. return this._reader.getFieldNames();
  233. }
  234. getAttributeHash() {
  235. return this._reader.getAttributeHash();
  236. }
  237. getObjectId() {
  238. return this._reader.getObjectId();
  239. }
  240. getDisplayId() {
  241. return this._reader.getDisplayId();
  242. }
  243. setDisplayId(e2) {
  244. return this._reader.setDisplayId(e2);
  245. }
  246. getGroupId() {
  247. return this._reader.getGroupId();
  248. }
  249. setGroupId(e2) {
  250. return this._reader.setGroupId(e2);
  251. }
  252. getXHydrated() {
  253. return this._reader.getXHydrated();
  254. }
  255. getYHydrated() {
  256. return this._reader.getYHydrated();
  257. }
  258. getX() {
  259. return this._reader.getX();
  260. }
  261. getY() {
  262. return this._reader.getY();
  263. }
  264. setIndex(e2) {
  265. return this._reader.setIndex(e2);
  266. }
  267. getIndex() {
  268. return this._reader.getIndex();
  269. }
  270. readLegacyFeature() {
  271. return this._reader.readLegacyFeature();
  272. }
  273. readOptimizedFeature() {
  274. return this._reader.readOptimizedFeature();
  275. }
  276. readLegacyPointGeometry() {
  277. return this._reader.readLegacyPointGeometry();
  278. }
  279. readLegacyGeometry() {
  280. return this._reader.readLegacyGeometry();
  281. }
  282. readLegacyCentroid() {
  283. return this._reader.readLegacyCentroid();
  284. }
  285. readGeometryArea() {
  286. return this._reader.readGeometryArea();
  287. }
  288. readUnquantizedGeometry() {
  289. return this._reader.readUnquantizedGeometry();
  290. }
  291. readHydratedGeometry() {
  292. return this._reader.readHydratedGeometry();
  293. }
  294. readGeometry() {
  295. return this._reader.readGeometry();
  296. }
  297. readCentroid() {
  298. return this._reader.readCentroid();
  299. }
  300. _readAttribute(e2, r3) {
  301. throw new Error("Error: Should not be called. Underlying _reader should be used instead");
  302. }
  303. _readAttributes() {
  304. throw new Error("Error: Should not be called. Underlying _reader should be used instead");
  305. }
  306. };
  307. // node_modules/@arcgis/core/views/2d/layers/features/FeatureStore2D.js
  308. function h(t2, e2) {
  309. return t2 << 16 | e2;
  310. }
  311. function c2(t2) {
  312. return (4294901760 & t2) >>> 16;
  313. }
  314. function I(t2) {
  315. return 65535 & t2;
  316. }
  317. var u = { getObjectId: (t2) => t2.getObjectId(), getAttributes: (t2) => t2.readAttributes(), getAttribute: (t2, e2) => t2.readAttribute(e2), cloneWithGeometry: (t2, e2) => t2, getGeometry: (t2) => t2.readHydratedGeometry(), getCentroid: (t2, e2) => t2.readCentroid() };
  318. var l = class extends c {
  319. constructor(s3, a3, r3) {
  320. super(s3, a3), this.featureAdapter = u, this.events = new n(), this._featureSetsByInstance = /* @__PURE__ */ new Map(), this._objectIdToDisplayId = /* @__PURE__ */ new Map(), this._spatialIndexInvalid = true, this._indexSearchCache = new s2(50), this._index = i(9, (t2) => ({ minX: this._storage.getXMin(t2), minY: this._storage.getYMin(t2), maxX: this._storage.getXMax(t2), maxY: this._storage.getYMax(t2) })), this.mode = r3;
  321. }
  322. get storeStatistics() {
  323. let t2 = 0, e2 = 0, s3 = 0;
  324. return this.forEach((a3) => {
  325. const r3 = a3.readGeometry();
  326. r3 && (e2 += r3.isPoint ? 1 : r3.lengths.reduce((t3, e3) => t3 + e3, 0), s3 += r3.isPoint ? 1 : r3.lengths.length, t2 += 1);
  327. }), { featureCount: t2, vertexCount: e2, ringCount: s3 };
  328. }
  329. hasInstance(t2) {
  330. return this._featureSetsByInstance.has(t2);
  331. }
  332. onTileData(t2, e2) {
  333. if (t(e2.addOrUpdate))
  334. return e2;
  335. if (e2.addOrUpdate.attachStorage(this._storage), "snapshot" === this.mode) {
  336. const s3 = e2.addOrUpdate.getCursor();
  337. for (; s3.next(); ) {
  338. const e3 = s3.getDisplayId();
  339. this.setComputedAttributes(this._storage, s3, e3, t2.scale);
  340. }
  341. return e2;
  342. }
  343. this._featureSetsByInstance.set(e2.addOrUpdate.instance, e2.addOrUpdate);
  344. const a3 = e2.addOrUpdate.getCursor();
  345. for (; a3.next(); )
  346. this._insertFeature(a3, t2.scale);
  347. return this._spatialIndexInvalid = true, this.events.emit("changed"), e2;
  348. }
  349. search(t2) {
  350. this._rebuildIndex();
  351. const e2 = t2.id, s3 = this._indexSearchCache.find((t3) => t3.tileId === e2);
  352. if (r(s3))
  353. return s3.readers;
  354. const r3 = /* @__PURE__ */ new Map(), n2 = this._searchIndex(t2.bounds), i2 = [];
  355. for (const a3 of n2) {
  356. const t3 = this._storage.getInstanceId(a3), e3 = c2(t3), s4 = I(t3);
  357. r3.has(e3) || r3.set(e3, []);
  358. r3.get(e3).push(s4);
  359. }
  360. return r3.forEach((t3, e3) => {
  361. const s4 = this._featureSetsByInstance.get(e3);
  362. i2.push(r2.from(s4, t3));
  363. }), this._indexSearchCache.enqueue({ tileId: e2, readers: i2 }), i2;
  364. }
  365. insert(t2) {
  366. var _a;
  367. const e2 = t2.getCursor(), s3 = this._storage;
  368. for (; e2.next(); ) {
  369. const t3 = h(e2.instance, e2.getIndex()), a3 = e2.getObjectId(), r3 = (_a = this._objectIdToDisplayId.get(a3)) != null ? _a : this._storage.createDisplayId();
  370. e2.setDisplayId(r3), s3.setInstanceId(r3, t3), this._objectIdToDisplayId.set(a3, r3);
  371. }
  372. this._featureSetsByInstance.set(t2.instance, t2), this._spatialIndexInvalid = true;
  373. }
  374. remove(t2) {
  375. const e2 = this._objectIdToDisplayId.get(t2);
  376. if (!e2)
  377. return;
  378. const s3 = this._storage.getInstanceId(e2), a3 = I(s3), r3 = c2(s3), n2 = this._featureSetsByInstance.get(r3);
  379. this._objectIdToDisplayId.delete(t2), this._storage.releaseDisplayId(e2), n2.removeAtIndex(a3), n2.isEmpty && this._featureSetsByInstance.delete(r3), this._spatialIndexInvalid = true;
  380. }
  381. toArray() {
  382. const t2 = new Array();
  383. return this.forEach((e2) => t2.push(e2)), t2;
  384. }
  385. forEach(t2) {
  386. this._objectIdToDisplayId.forEach((e2) => {
  387. const s3 = this._storage.getInstanceId(e2), a3 = this._lookupFeature(s3);
  388. t2(a3);
  389. });
  390. }
  391. forEachUnsafe(t2) {
  392. this._objectIdToDisplayId.forEach((e2) => {
  393. const s3 = this._storage.getInstanceId(e2), a3 = c2(s3), r3 = I(s3), n2 = this._getFeatureSet(a3);
  394. n2.setIndex(r3), t2(n2);
  395. });
  396. }
  397. forEachInBounds(t2, e2) {
  398. const s3 = this._searchIndex(t2);
  399. for (const a3 of s3) {
  400. const t3 = this.lookupFeatureByDisplayId(a3, this._storage);
  401. e2(e(t3));
  402. }
  403. }
  404. forEachBounds(t2, e2, s3) {
  405. this._rebuildIndex();
  406. const a3 = [0, 0, 0, 0];
  407. for (const r3 of t2) {
  408. if (!r3.readGeometry())
  409. continue;
  410. const t3 = r3.getDisplayId();
  411. a3[0] = this._storage.getXMin(t3), a3[1] = this._storage.getYMin(t3), a3[2] = this._storage.getXMax(t3), a3[3] = this._storage.getYMax(t3), e2(G(s3, a3));
  412. }
  413. }
  414. sweepFeatures(t2, e2, s3) {
  415. this._spatialIndexInvalid = true, this._objectIdToDisplayId.forEach((a3, r3) => {
  416. t2.has(a3) || (e2.releaseDisplayId(a3), s3 && s3.unsetAttributeData(a3), this._objectIdToDisplayId.delete(r3));
  417. }), this.events.emit("changed");
  418. }
  419. sweepFeatureSets(t2) {
  420. this._spatialIndexInvalid = true, this._featureSetsByInstance.forEach((e2, s3) => {
  421. t2.has(s3) || this._featureSetsByInstance.delete(s3);
  422. });
  423. }
  424. lookupObjectId(t2, e2) {
  425. const a3 = this.lookupFeatureByDisplayId(t2, e2);
  426. return t(a3) ? null : a3.getObjectId();
  427. }
  428. lookupDisplayId(t2) {
  429. return this._objectIdToDisplayId.get(t2);
  430. }
  431. lookupFeatureByDisplayId(t2, e2) {
  432. const s3 = e2.getInstanceId(t2);
  433. return this._lookupFeature(s3);
  434. }
  435. lookupByDisplayIdUnsafe(t2) {
  436. const e2 = this._storage.getInstanceId(t2), s3 = c2(e2), a3 = I(e2), r3 = this._getFeatureSet(s3);
  437. return r3 ? (r3.setIndex(a3), r3) : null;
  438. }
  439. _insertFeature(t2, e2) {
  440. const s3 = this._storage, a3 = t2.getObjectId(), r3 = h(t2.instance, t2.getIndex());
  441. s3.getInstanceId(t2.getDisplayId());
  442. let n2 = this._objectIdToDisplayId.get(a3);
  443. n2 || (n2 = s3.createDisplayId(), this._objectIdToDisplayId.set(a3, n2), this._spatialIndexInvalid = true), t2.setDisplayId(n2), s3.setInstanceId(n2, r3), this.setComputedAttributes(s3, t2, n2, e2);
  444. }
  445. _searchIndex(t2) {
  446. this._rebuildIndex();
  447. const e2 = { minX: t2[0], minY: t2[1], maxX: t2[2], maxY: t2[3] };
  448. return this._index.search(e2);
  449. }
  450. _rebuildIndex() {
  451. if (!this._spatialIndexInvalid)
  452. return;
  453. const t2 = [];
  454. "snapshot" === this.mode ? this._featureSetsByInstance.forEach((e2) => {
  455. const s3 = e2.getCursor();
  456. for (; s3.next(); ) {
  457. const e3 = s3.getDisplayId();
  458. this._storage.setBounds(e3, s3) && t2.push(e3);
  459. }
  460. }) : this._objectIdToDisplayId.forEach((e2) => {
  461. const s3 = this._storage.getInstanceId(e2);
  462. this._storage.setBounds(e2, this._lookupFeature(s3)) && t2.push(e2);
  463. }), this._index.clear(), this._index.load(t2), this._indexSearchCache.clear(), this._spatialIndexInvalid = false;
  464. }
  465. _lookupFeature(t2) {
  466. const e2 = c2(t2), s3 = this._getFeatureSet(e2);
  467. if (!s3)
  468. return null;
  469. const a3 = s3.getCursor(), r3 = I(t2);
  470. return a3.setIndex(r3), a3;
  471. }
  472. _getFeatureSet(t2) {
  473. return this._featureSetsByInstance.get(t2);
  474. }
  475. };
  476. export {
  477. c,
  478. r2 as r,
  479. u,
  480. l
  481. };
  482. //# sourceMappingURL=chunk-IY6TL5XB.js.map