chunk-SKKBVHTF.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. import {
  2. d
  3. } from "./chunk-DLMAGHHC.js";
  4. import {
  5. e
  6. } from "./chunk-CRHRHOXH.js";
  7. import {
  8. i,
  9. u
  10. } from "./chunk-4T5ZGMEN.js";
  11. import {
  12. l
  13. } from "./chunk-X4SA4ELJ.js";
  14. import {
  15. U
  16. } from "./chunk-DVUG3KID.js";
  17. import {
  18. j
  19. } from "./chunk-V6P2MAQQ.js";
  20. import {
  21. s2 as s,
  22. s3 as s2
  23. } from "./chunk-E5O6P5I2.js";
  24. import {
  25. c
  26. } from "./chunk-SPWQ3AWG.js";
  27. import {
  28. r,
  29. t
  30. } from "./chunk-YXWMMD76.js";
  31. // node_modules/@arcgis/core/renderers/support/DictionaryLoader.js
  32. var h = "esri.renderers.support.DictionaryLoader";
  33. var y = { type: "CIMSimpleLineCallout", lineSymbol: { type: "CIMLineSymbol", symbolLayers: [{ type: "CIMSolidStroke", width: 0.5, color: [0, 0, 0, 255] }] } };
  34. var u2 = class {
  35. constructor(e2, t2, s3) {
  36. this.config = null, this.fieldMap = null, this.url = null, this._ongoingRequests = /* @__PURE__ */ new Map(), this._symbolCache = new e(100), this._dictionaryPromise = null, this.url = e2, this.config = t2, this.fieldMap = s3;
  37. }
  38. getSymbolFields() {
  39. return this._symbolFields;
  40. }
  41. async getSymbolAsync(t2, s3) {
  42. let o;
  43. this._dictionaryPromise || (this._dictionaryPromise = this.fetchResources(s3));
  44. try {
  45. o = await this._dictionaryPromise;
  46. } catch (g2) {
  47. if (j(g2))
  48. return this._dictionaryPromise = null, null;
  49. }
  50. const i2 = {};
  51. if (this.fieldMap)
  52. for (const e2 of this._symbolFields) {
  53. const s4 = this.fieldMap[e2];
  54. if (s4 && null != t2.attributes[s4]) {
  55. const o2 = "" + t2.attributes[s4];
  56. i2[e2] = o2;
  57. } else
  58. i2[e2] = "";
  59. }
  60. const n = o == null ? void 0 : o(i2, s3);
  61. if (!n || "string" != typeof n)
  62. return null;
  63. const c2 = c(n).toString(), m = this._symbolCache.get(c2);
  64. if (m)
  65. return m.catch(() => {
  66. this._symbolCache.pop(c2);
  67. }), m;
  68. const f = n.split(";"), h2 = [], y2 = [];
  69. for (const r2 of f)
  70. if (r2)
  71. if (r2.includes("po:")) {
  72. const t3 = r2.substr(3).split("|");
  73. if (3 === t3.length) {
  74. const s4 = t3[0], o2 = t3[1];
  75. let i3 = t3[2];
  76. if ("DashTemplate" === o2)
  77. i3 = i3.split(" ").map((e2) => Number(e2));
  78. else if ("Color" === o2) {
  79. const t4 = new l(i3).toRgba();
  80. i3 = [t4[0], t4[1], t4[2], 255 * t4[3]];
  81. } else
  82. i3 = Number(i3);
  83. y2.push({ primitiveName: s4, propertyName: o2, value: i3 });
  84. }
  85. } else if (r2.includes("|")) {
  86. for (const e2 of r2.split("|"))
  87. if (this._itemNames.has(e2)) {
  88. h2.push(e2);
  89. break;
  90. }
  91. } else
  92. this._itemNames.has(r2) && h2.push(r2);
  93. const u3 = !r(t2.geometry) || !t2.geometry.hasZ && "point" === t2.geometry.type, p2 = this._cimPartsToCIMSymbol(h2, y2, u3, s3);
  94. return this._symbolCache.put(c2, p2, 1), p2;
  95. }
  96. async fetchResources(e2) {
  97. if (this._dictionaryPromise)
  98. return this._dictionaryPromise;
  99. if (!this.url)
  100. return void s.getLogger(h).error("no valid URL!");
  101. const i2 = U(this.url + "/resources/styles/dictionary-info.json", { responseType: "json", query: { f: "json" }, signal: r(e2) ? e2.signal : null }), [{ data: l2 }] = await Promise.all([i2, i()]);
  102. if (!l2)
  103. throw this._dictionaryPromise = null, new s2("esri.renderers.DictionaryRenderer", "Bad dictionary data!");
  104. const a = l2.expression, f = l2.authoringInfo;
  105. this._refSymbolUrlTemplate = this.url + "/" + l2.cimRefTemplateUrl, this._itemNames = new Set(l2.itemsNames), this._symbolFields = f.symbol;
  106. const y2 = {};
  107. if (this.config) {
  108. const e3 = this.config;
  109. for (const t2 in e3)
  110. y2[t2] = e3[t2];
  111. }
  112. if (f.configuration)
  113. for (const t2 of f.configuration)
  114. y2.hasOwnProperty(t2.name) || (y2[t2.name] = t2.value);
  115. const u3 = [];
  116. if (r(e2) && e2.fields && this.fieldMap)
  117. for (const t2 of this._symbolFields) {
  118. const s3 = this.fieldMap[t2], o = e2.fields.filter((e3) => e3.name === s3);
  119. o.length > 0 && u3.push({ ...o[0], name: t2 });
  120. }
  121. const p2 = u(a, r(e2) ? e2.spatialReference : null, u3, y2).then((e3) => {
  122. const t2 = { scale: 0 };
  123. return (s3, o) => {
  124. if (t(e3))
  125. return null;
  126. const i3 = e3.repurposeFeature({ geometry: null, attributes: s3 });
  127. return t2.scale = r(o) ? o.scale : void 0, e3.evaluate({ $feature: i3, $view: t2 });
  128. };
  129. }).catch((e3) => (s.getLogger(h).error("Creating dictinoary expression failed:", e3), null));
  130. return this._dictionaryPromise = p2, p2;
  131. }
  132. async _cimPartsToCIMSymbol(e2, t2, s3, o) {
  133. const i2 = new Array(e2.length);
  134. for (let l2 = 0; l2 < e2.length; l2++)
  135. i2[l2] = this._getSymbolPart(e2[l2], o);
  136. const r2 = await Promise.all(i2), n = this.fieldMap;
  137. if (n)
  138. for (const l2 of r2)
  139. p(l2, n);
  140. return new d({ data: this._combineSymbolParts(r2, t2, s3) });
  141. }
  142. async _getSymbolPart(e2, s3) {
  143. if (this._ongoingRequests.has(e2))
  144. return this._ongoingRequests.get(e2).then((e3) => e3.data);
  145. const o = this._refSymbolUrlTemplate.replace(/\{itemName\}/gi, e2), i2 = U(o, { responseType: "json", query: { f: "json" }, ...s3 });
  146. this._ongoingRequests.set(e2, i2);
  147. try {
  148. return (await i2).data;
  149. } catch (r2) {
  150. throw this._ongoingRequests.delete(e2), r2;
  151. }
  152. }
  153. _combineSymbolParts(e2, t2, s3) {
  154. if (!e2 || 0 === e2.length)
  155. return null;
  156. const o = { ...e2[0] };
  157. if (e2.length > 1) {
  158. o.symbolLayers = [];
  159. for (const t3 of e2) {
  160. const e3 = t3;
  161. o.symbolLayers.unshift(...e3.symbolLayers);
  162. }
  163. }
  164. return s3 && (o.callout = y), { type: "CIMSymbolReference", symbol: o, primitiveOverrides: t2 };
  165. }
  166. };
  167. function p(e2, t2) {
  168. if (!e2)
  169. return;
  170. const s3 = e2.symbolLayers;
  171. if (!s3)
  172. return;
  173. let o = s3.length;
  174. for (; o--; ) {
  175. const e3 = s3[o];
  176. if (e3 && false !== e3.enable && "CIMVectorMarker" === e3.type)
  177. g(e3, t2);
  178. }
  179. }
  180. function g(e2, t2) {
  181. const s3 = e2.markerGraphics;
  182. if (s3)
  183. for (const o of s3) {
  184. if (!o)
  185. continue;
  186. const e3 = o.symbol;
  187. if (e3)
  188. switch (e3.type) {
  189. case "CIMPointSymbol":
  190. case "CIMLineSymbol":
  191. case "CIMPolygonSymbol":
  192. p(e3, t2);
  193. break;
  194. case "CIMTextSymbol":
  195. e3.fieldMap = t2;
  196. }
  197. }
  198. }
  199. export {
  200. u2 as u
  201. };
  202. //# sourceMappingURL=chunk-SKKBVHTF.js.map