chunk-Y74D3LKQ.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. import {
  2. e,
  3. i,
  4. l as l2,
  5. n as n2
  6. } from "./chunk-PK4W65H4.js";
  7. import {
  8. g
  9. } from "./chunk-7C23ILQ4.js";
  10. import {
  11. m
  12. } from "./chunk-3LVSQLWJ.js";
  13. import {
  14. n
  15. } from "./chunk-O6VYMEIX.js";
  16. import {
  17. l
  18. } from "./chunk-X4SA4ELJ.js";
  19. import {
  20. s2 as s
  21. } from "./chunk-E5O6P5I2.js";
  22. import {
  23. r,
  24. t
  25. } from "./chunk-YXWMMD76.js";
  26. // node_modules/@arcgis/core/renderers/visualVariables/support/visualVariableUtils.js
  27. var f = s.getLogger("esri.renderers.visualVariables.support.visualVariableUtils");
  28. var p = new g();
  29. var d = Math.PI;
  30. var v = /^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i;
  31. function b(a, r2, i2) {
  32. const s2 = "visualVariables" in a && a.visualVariables ? a.visualVariables.find((e2) => "color" === e2.type) : a;
  33. if (!s2)
  34. return;
  35. if ("esri.renderers.visualVariables.ColorVariable" !== s2.declaredClass)
  36. return void f.warn("The visualVariable should be an instance of esri.renderers.visualVariables.ColorVariable");
  37. const l3 = "number" == typeof r2, o = l3 ? null : r2, c = o && o.attributes;
  38. let u = l3 ? r2 : null;
  39. const p2 = s2.field, { ipData: d2, hasExpression: v2 } = s2.cache;
  40. let b2 = s2.cache.compiledFunc;
  41. if (!p2 && !v2) {
  42. const e2 = s2.stops;
  43. return e2 && e2[0] && e2[0].color;
  44. }
  45. if ("number" != typeof u)
  46. if (v2) {
  47. if (t(i2) || t(i2.arcade))
  48. return void f.error("Use of arcade expressions requires an arcade context");
  49. const e2 = { viewingMode: i2.viewingMode, scale: i2.scale, spatialReference: i2.spatialReference }, a2 = i2.arcade.arcadeUtils, r3 = a2.getViewInfo(e2), t2 = a2.createExecContext(o, r3);
  50. if (!b2) {
  51. const e3 = a2.createSyntaxTree(s2.valueExpression);
  52. b2 = a2.createFunction(e3), s2.cache.compiledFunc = b2;
  53. }
  54. u = a2.executeFunction(b2, t2);
  55. } else
  56. c && (u = c[p2]);
  57. const h2 = s2.normalizationField, m3 = null != c && null != h2 ? parseFloat(c[h2]) : void 0;
  58. if (null != u && (!h2 || l3 || !isNaN(m3) && 0 !== m3)) {
  59. isNaN(m3) || l3 || (u /= m3);
  60. const a2 = R(u, d2);
  61. if (a2) {
  62. const r3 = a2[0], n3 = a2[1], l4 = r3 === n3 ? s2.stops[r3].color : l.blendColors(s2.stops[r3].color, s2.stops[n3].color, a2[2], r(i2) ? i2.color : void 0);
  63. return new l(l4);
  64. }
  65. }
  66. }
  67. function h(e2, a, r2) {
  68. const i2 = "visualVariables" in e2 && e2.visualVariables ? e2.visualVariables.find((e3) => "opacity" === e3.type) : e2;
  69. if (!i2)
  70. return;
  71. if ("esri.renderers.visualVariables.OpacityVariable" !== i2.declaredClass)
  72. return void f.warn("The visualVariable should be an instance of esri.renderers.visualVariables.OpacityVariable");
  73. const t2 = "number" == typeof a, s2 = t2 ? null : a, l3 = s2 && s2.attributes;
  74. let o = t2 ? a : null;
  75. const c = i2.field, { ipData: u, hasExpression: p2 } = i2.cache;
  76. let d2 = i2.cache.compiledFunc;
  77. if (!c && !p2) {
  78. const e3 = i2.stops;
  79. return e3 && e3[0] && e3[0].opacity;
  80. }
  81. if ("number" != typeof o)
  82. if (p2) {
  83. if (t(r2) || t(r2.arcade))
  84. return void f.error("Use of arcade expressions requires an arcade context");
  85. const e3 = { viewingMode: r2.viewingMode, scale: r2.scale, spatialReference: r2.spatialReference }, a2 = r2.arcade.arcadeUtils, t3 = a2.getViewInfo(e3), l4 = a2.createExecContext(s2, t3);
  86. if (!d2) {
  87. const e4 = a2.createSyntaxTree(i2.valueExpression);
  88. d2 = a2.createFunction(e4), i2.cache.compiledFunc = d2;
  89. }
  90. o = a2.executeFunction(d2, l4);
  91. } else
  92. l3 && (o = l3[c]);
  93. const v2 = i2.normalizationField, b2 = null != l3 && null != v2 ? parseFloat(l3[v2]) : void 0;
  94. if (null != o && (!v2 || t2 || !isNaN(b2) && 0 !== b2)) {
  95. isNaN(b2) || t2 || (o /= b2);
  96. const e3 = R(o, u);
  97. if (e3) {
  98. const a2 = e3[0], r3 = e3[1];
  99. if (a2 === r3)
  100. return i2.stops[a2].opacity;
  101. {
  102. const n3 = i2.stops[a2].opacity;
  103. return n3 + (i2.stops[r3].opacity - n3) * e3[2];
  104. }
  105. }
  106. }
  107. }
  108. function m2(e2, a, r2) {
  109. const i2 = "visualVariables" in e2 && e2.visualVariables ? e2.visualVariables.find((e3) => "rotation" === e3.type) : e2;
  110. if (!i2)
  111. return;
  112. if ("esri.renderers.visualVariables.RotationVariable" !== i2.declaredClass)
  113. return void f.warn("The visualVariable should be an instance of esri.renderers.visualVariables.RotationVariable");
  114. const t2 = i2.axis || "heading", s2 = "heading" === t2 && "arithmetic" === i2.rotationType ? 90 : 0, l3 = "heading" === t2 && "arithmetic" === i2.rotationType ? -1 : 1, o = "number" == typeof a ? null : a, c = o && o.attributes, u = i2.field, { hasExpression: p2 } = i2.cache;
  115. let d2 = i2.cache.compiledFunc, v2 = 0;
  116. if (!u && !p2)
  117. return v2;
  118. if (p2) {
  119. if (t(r2) || t(r2.arcade))
  120. return void f.error("Use of arcade expressions requires an arcade context");
  121. const e3 = { viewingMode: r2.viewingMode, scale: r2.scale, spatialReference: r2.spatialReference }, a2 = r2.arcade.arcadeUtils, t3 = a2.getViewInfo(e3), s3 = a2.createExecContext(o, t3);
  122. if (!d2) {
  123. const e4 = a2.createSyntaxTree(i2.valueExpression);
  124. d2 = a2.createFunction(e4), i2.cache.compiledFunc = d2;
  125. }
  126. v2 = a2.executeFunction(d2, s3);
  127. } else
  128. c && (v2 = c[u] || 0);
  129. return v2 = "number" != typeof v2 || isNaN(v2) ? null : s2 + l3 * v2, v2;
  130. }
  131. function V(e2, a, r2) {
  132. const i2 = "number" == typeof a, s2 = i2 ? null : a, l3 = s2 && s2.attributes;
  133. let c = i2 ? a : null;
  134. const { isScaleDriven: p2 } = e2.cache;
  135. let d2 = e2.cache.compiledFunc;
  136. if (p2) {
  137. const a2 = r(r2) ? r2.scale : void 0, i3 = r(r2) ? r2.view : void 0;
  138. c = null == a2 || "3d" === i3 ? x(e2) : a2;
  139. } else if (!i2)
  140. switch (e2.inputValueType) {
  141. case n2.Expression: {
  142. if (t(r2) || t(r2.arcade))
  143. return void f.error("Use of arcade expressions requires an arcade context");
  144. const a2 = { viewingMode: r2.viewingMode, scale: r2.scale, spatialReference: r2.spatialReference }, i3 = r2.arcade.arcadeUtils, t2 = i3.getViewInfo(a2), l4 = i3.createExecContext(s2, t2);
  145. if (!d2) {
  146. const a3 = i3.createSyntaxTree(e2.valueExpression);
  147. d2 = i3.createFunction(a3), e2.cache.compiledFunc = d2;
  148. }
  149. c = i3.executeFunction(d2, l4);
  150. break;
  151. }
  152. case n2.Field:
  153. l3 && (c = l3[e2.field]);
  154. break;
  155. case n2.Unknown:
  156. c = null;
  157. }
  158. if (!l2(c))
  159. return null;
  160. if (i2 || !e2.normalizationField)
  161. return c;
  162. const v2 = l3 ? parseFloat(l3[e2.normalizationField]) : null;
  163. return l2(v2) && 0 !== v2 ? c / v2 : null;
  164. }
  165. function x(e2) {
  166. let a = null, r2 = null;
  167. const i2 = e2.stops;
  168. return i2 ? (a = i2[0].value, r2 = i2[i2.length - 1].value) : (a = e2.minDataValue || 0, r2 = e2.maxDataValue || 0), (a + r2) / 2;
  169. }
  170. function y(e2, a, r2) {
  171. const i2 = "visualVariables" in e2 && e2.visualVariables ? e2.visualVariables.find((e3) => "size" === e3.type) : e2;
  172. if (!i2)
  173. return;
  174. if ("esri.renderers.visualVariables.SizeVariable" !== i2.declaredClass)
  175. return void f.warn("The visualVariable should be an instance of esri.renderers.visualVariables.SizeVariable");
  176. const n3 = M(V(i2, a, r2), i2, a, r2, i2.cache.ipData);
  177. return null == n3 || isNaN(n3) ? 0 : n3;
  178. }
  179. function w(e2, a, r2) {
  180. return null == e2 ? null : e(e2) ? y(e2, a, r2) : l2(e2) ? e2 : null;
  181. }
  182. function g2(e2, a, r2) {
  183. return l2(r2) && e2 > r2 ? r2 : l2(a) && e2 < a ? a : e2;
  184. }
  185. function z(e2, a, r2, i2) {
  186. var _a;
  187. return e2 + ((_a = w(a.minSize, r2, i2) || a.minDataValue) != null ? _a : 0);
  188. }
  189. function F(e2, a, r2) {
  190. const i2 = e2.stops;
  191. let n3 = i2 && i2.length && i2[0].size;
  192. return null == n3 && (n3 = e2.minSize), w(n3, a, r2);
  193. }
  194. function S(e2, a, r2, i2) {
  195. const n3 = (e2 - a.minDataValue) / (a.maxDataValue - a.minDataValue), s2 = w(a.minSize, r2, i2), l3 = w(a.maxSize, r2, i2), o = r(i2) ? i2.shape : void 0;
  196. if (e2 <= a.minDataValue)
  197. return s2;
  198. if (e2 >= a.maxDataValue)
  199. return l3;
  200. if (null == s2 || null == l3)
  201. return null;
  202. if ("area" === a.scaleBy && o) {
  203. const e3 = "circle" === o, a2 = e3 ? d * (s2 / 2) ** 2 : s2 * s2, r3 = a2 + n3 * ((e3 ? d * (l3 / 2) ** 2 : l3 * l3) - a2);
  204. return e3 ? 2 * Math.sqrt(r3 / d) : Math.sqrt(r3);
  205. }
  206. return s2 + n3 * (l3 - s2);
  207. }
  208. function E(e2, a, r2, i2) {
  209. const n3 = r(i2) ? i2.shape : void 0, s2 = e2 / a.minDataValue, l3 = w(a.minSize, r2, i2), o = w(a.maxSize, r2, i2);
  210. let c = null;
  211. return c = "circle" === n3 ? 2 * Math.sqrt(s2 * (l3 / 2) ** 2) : "square" === n3 || "diamond" === n3 || "image" === n3 ? Math.sqrt(s2 * l3 ** 2) : s2 * l3, g2(c, l3, o);
  212. }
  213. function U(e2, a, r2, i2, n3) {
  214. var _a, _b, _c;
  215. const [t2, s2, l3] = R(e2, n3);
  216. if (t2 === s2)
  217. return w((_a = a.stops) == null ? void 0 : _a[t2].size, r2, i2);
  218. {
  219. const e3 = w((_b = a.stops) == null ? void 0 : _b[t2].size, r2, i2);
  220. return e3 + (w((_c = a.stops) == null ? void 0 : _c[s2].size, r2, i2) - e3) * l3;
  221. }
  222. }
  223. function C(e2, a, r2, i2) {
  224. const n3 = (r(i2) && i2.resolution ? i2.resolution : 1) * m[a.valueUnit], l3 = w(a.minSize, r2, i2), o = w(a.maxSize, r2, i2), { valueRepresentation: c } = a;
  225. let u = null;
  226. return u = "area" === c ? 2 * Math.sqrt(e2 / d) / n3 : "radius" === c || "distance" === c ? 2 * e2 / n3 : e2 / n3, g2(u, l3, o);
  227. }
  228. function D(e2) {
  229. return e2;
  230. }
  231. function M(e2, a, r2, i2, n3) {
  232. switch (a.transformationType) {
  233. case i.Additive:
  234. return z(e2, a, r2, i2);
  235. case i.Constant:
  236. return F(a, r2, i2);
  237. case i.ClampedLinear:
  238. return S(e2, a, r2, i2);
  239. case i.Proportional:
  240. return E(e2, a, r2, i2);
  241. case i.Stops:
  242. return U(e2, a, r2, i2, n3);
  243. case i.RealWorldSize:
  244. return C(e2, a, r2, i2);
  245. case i.Identity:
  246. return D(e2);
  247. case i.Unknown:
  248. return null;
  249. }
  250. }
  251. function k(e2, a, r2) {
  252. const { isScaleDriven: i2 } = e2.cache;
  253. if (!(i2 && "3d" === r2 || a))
  254. return null;
  255. const n3 = { scale: a, view: r2 };
  256. let t2 = w(e2.minSize, p, n3), s2 = w(e2.maxSize, p, n3);
  257. if (null != t2 || null != s2) {
  258. if (t2 > s2) {
  259. const e3 = s2;
  260. s2 = t2, t2 = e3;
  261. }
  262. return { minSize: t2, maxSize: s2 };
  263. }
  264. }
  265. function N(e2, a, r2) {
  266. if (!e2.visualVariables)
  267. return;
  268. const i2 = [], n3 = [], t2 = [], s2 = [], l3 = [];
  269. for (const o of e2.visualVariables)
  270. switch (o.type) {
  271. case "color":
  272. n3.push(o);
  273. break;
  274. case "opacity":
  275. t2.push(o);
  276. break;
  277. case "rotation":
  278. l3.push(o);
  279. break;
  280. case "size":
  281. s2.push(o);
  282. }
  283. return n3.forEach((e3) => {
  284. const n4 = b(e3, a, r2);
  285. i2.push({ variable: e3, value: n4 });
  286. }), t2.forEach((e3) => {
  287. const n4 = h(e3, a, r2);
  288. i2.push({ variable: e3, value: n4 });
  289. }), l3.forEach((e3) => {
  290. const n4 = m2(e3, a, r2);
  291. i2.push({ variable: e3, value: n4 });
  292. }), s2.forEach((e3) => {
  293. const n4 = y(e3, a, r2);
  294. i2.push({ variable: e3, value: n4 });
  295. }), i2.filter((e3) => null != e3.value);
  296. }
  297. function R(e2, a) {
  298. if (!a)
  299. return;
  300. let r2 = 0, i2 = a.length - 1;
  301. return a.some((a2, n3) => e2 < a2 ? (i2 = n3, true) : (r2 = n3, false)), [r2, i2, (e2 - a[r2]) / (a[i2] - a[r2])];
  302. }
  303. function T(e2, a, i2) {
  304. const n3 = ["proportional", "proportional", "proportional"];
  305. for (const t2 of e2) {
  306. const e3 = t2.useSymbolValue ? "symbol-value" : y(t2, a, i2);
  307. switch (t2.axis) {
  308. case "width":
  309. n3[0] = e3;
  310. break;
  311. case "depth":
  312. n3[1] = e3;
  313. break;
  314. case "height":
  315. n3[2] = e3;
  316. break;
  317. case "width-and-depth":
  318. n3[0] = e3, n3[1] = e3;
  319. break;
  320. case "all":
  321. case void 0:
  322. case null:
  323. n3[0] = e3, n3[1] = e3, n3[2] = e3;
  324. break;
  325. default:
  326. n(t2.axis);
  327. }
  328. }
  329. return n3;
  330. }
  331. export {
  332. v,
  333. b,
  334. h,
  335. m2 as m,
  336. y,
  337. w,
  338. M,
  339. k,
  340. N,
  341. T
  342. };
  343. //# sourceMappingURL=chunk-Y74D3LKQ.js.map