chunk-GRBROWI6.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. import {
  2. e,
  3. i,
  4. l as l2,
  5. n as n2
  6. } from "./chunk-5NKYXKIA.js";
  7. import {
  8. g
  9. } from "./chunk-RZFGRBD7.js";
  10. import {
  11. n
  12. } from "./chunk-H2KDMZTR.js";
  13. import {
  14. l
  15. } from "./chunk-7XXXCK2A.js";
  16. import {
  17. m
  18. } from "./chunk-FONIFA5N.js";
  19. import {
  20. s
  21. } from "./chunk-EMJ4ZSM2.js";
  22. import {
  23. r,
  24. t
  25. } from "./chunk-GZT4BVFP.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) => e2.type === "color") : a;
  33. if (!s2)
  34. return;
  35. if (s2.declaredClass !== "esri.renderers.visualVariables.ColorVariable")
  36. return void f.warn("The visualVariable should be an instance of esri.renderers.visualVariables.ColorVariable");
  37. const o = typeof r2 == "number", l3 = o ? null : r2, c = l3 && l3.attributes;
  38. let u = o ? 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 (typeof u != "number")
  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(l3, 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 = c ? parseFloat(c[h2]) : void 0;
  58. if (u != null && (!h2 || o || !isNaN(m3) && m3 !== 0)) {
  59. isNaN(m3) || o || (u /= m3);
  60. const a2 = R(u, d2);
  61. if (a2) {
  62. const r3 = a2[0], n3 = a2[1], o2 = 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(o2);
  64. }
  65. }
  66. }
  67. function h(e2, a, r2) {
  68. const i2 = "visualVariables" in e2 && e2.visualVariables ? e2.visualVariables.find((e3) => e3.type === "opacity") : e2;
  69. if (!i2)
  70. return;
  71. if (i2.declaredClass !== "esri.renderers.visualVariables.OpacityVariable")
  72. return void f.warn("The visualVariable should be an instance of esri.renderers.visualVariables.OpacityVariable");
  73. const t2 = typeof a == "number", s2 = t2 ? null : a, o = s2 && s2.attributes;
  74. let l3 = 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 (typeof l3 != "number")
  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), o2 = 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. l3 = a2.executeFunction(d2, o2);
  91. } else
  92. o && (l3 = o[c]);
  93. const v2 = i2.normalizationField, b2 = o ? parseFloat(o[v2]) : void 0;
  94. if (l3 != null && (!v2 || t2 || !isNaN(b2) && b2 !== 0)) {
  95. isNaN(b2) || t2 || (l3 /= b2);
  96. const e3 = R(l3, 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) => e3.type === "rotation") : e2;
  110. if (!i2)
  111. return;
  112. if (i2.declaredClass !== "esri.renderers.visualVariables.RotationVariable")
  113. return void f.warn("The visualVariable should be an instance of esri.renderers.visualVariables.RotationVariable");
  114. const t2 = i2.axis || "heading", s2 = t2 === "heading" && i2.rotationType === "arithmetic" ? 90 : 0, o = t2 === "heading" && i2.rotationType === "arithmetic" ? -1 : 1, l3 = typeof a == "number" ? null : a, c = l3 && l3.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(l3, 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 = typeof v2 != "number" || isNaN(v2) ? null : s2 + o * v2, v2;
  130. }
  131. function V(e2, a, r2) {
  132. const i2 = typeof a == "number", s2 = i2 ? null : a, o = 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 = a2 == null || i3 === "3d" ? 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), o2 = 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, o2);
  150. break;
  151. }
  152. case n2.Field:
  153. o && (c = o[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 = o ? parseFloat(o[e2.normalizationField]) : null;
  163. return l2(v2) && v2 !== 0 ? 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) => e3.type === "size") : e2;
  172. if (!i2)
  173. return;
  174. if (i2.declaredClass !== "esri.renderers.visualVariables.SizeVariable")
  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 n3 == null || isNaN(n3) ? 0 : n3;
  178. }
  179. function w(e2, a, r2) {
  180. return e2 == null ? 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. return e2 + (w(a.minSize, r2, i2) || a.minDataValue);
  187. }
  188. function F(e2, a, r2) {
  189. const i2 = e2.stops;
  190. let n3 = i2 && i2.length && i2[0].size;
  191. return n3 == null && (n3 = e2.minSize), w(n3, a, r2);
  192. }
  193. function S(e2, a, r2, i2) {
  194. const n3 = (e2 - a.minDataValue) / (a.maxDataValue - a.minDataValue), s2 = w(a.minSize, r2, i2), o = w(a.maxSize, r2, i2), l3 = r(i2) ? i2.shape : void 0;
  195. if (e2 <= a.minDataValue)
  196. return s2;
  197. if (e2 >= a.maxDataValue)
  198. return o;
  199. if (a.scaleBy === "area" && l3) {
  200. const e3 = l3 === "circle", a2 = e3 ? d * (s2 / 2) ** 2 : s2 * s2, r3 = a2 + n3 * ((e3 ? d * (o / 2) ** 2 : o * o) - a2);
  201. return e3 ? 2 * Math.sqrt(r3 / d) : Math.sqrt(r3);
  202. }
  203. return s2 + n3 * (o - s2);
  204. }
  205. function E(e2, a, r2, i2) {
  206. const n3 = r(i2) ? i2.shape : void 0, s2 = e2 / a.minDataValue, o = w(a.minSize, r2, i2), l3 = w(a.maxSize, r2, i2);
  207. let c = null;
  208. return c = n3 === "circle" ? 2 * Math.sqrt(s2 * (o / 2) ** 2) : n3 === "square" || n3 === "diamond" || n3 === "image" ? Math.sqrt(s2 * o ** 2) : s2 * o, g2(c, o, l3);
  209. }
  210. function U(e2, a, r2, i2, n3) {
  211. const [t2, s2, o] = R(e2, n3);
  212. if (t2 === s2)
  213. return w(a.stops[t2].size, r2, i2);
  214. {
  215. const e3 = w(a.stops[t2].size, r2, i2);
  216. return e3 + (w(a.stops[s2].size, r2, i2) - e3) * o;
  217. }
  218. }
  219. function C(e2, a, r2, i2) {
  220. const n3 = (r(i2) && i2.resolution ? i2.resolution : 1) * m[a.valueUnit], o = w(a.minSize, r2, i2), l3 = w(a.maxSize, r2, i2), { valueRepresentation: c } = a;
  221. let u = null;
  222. return u = c === "area" ? 2 * Math.sqrt(e2 / d) / n3 : c === "radius" || c === "distance" ? 2 * e2 / n3 : e2 / n3, g2(u, o, l3);
  223. }
  224. function D(e2) {
  225. return e2;
  226. }
  227. function M(e2, a, r2, i2, n3) {
  228. switch (a.transformationType) {
  229. case i.Additive:
  230. return z(e2, a, r2, i2);
  231. case i.Constant:
  232. return F(a, r2, i2);
  233. case i.ClampedLinear:
  234. return S(e2, a, r2, i2);
  235. case i.Proportional:
  236. return E(e2, a, r2, i2);
  237. case i.Stops:
  238. return U(e2, a, r2, i2, n3);
  239. case i.RealWorldSize:
  240. return C(e2, a, r2, i2);
  241. case i.Identity:
  242. return D(e2);
  243. case i.Unknown:
  244. return null;
  245. }
  246. }
  247. function k(e2, a, r2) {
  248. const { isScaleDriven: i2 } = e2.cache;
  249. if (!(i2 && r2 === "3d" || a))
  250. return null;
  251. const n3 = { scale: a, view: r2 };
  252. let t2 = w(e2.minSize, p, n3), s2 = w(e2.maxSize, p, n3);
  253. if (t2 != null || s2 != null) {
  254. if (t2 > s2) {
  255. const e3 = s2;
  256. s2 = t2, t2 = e3;
  257. }
  258. return { minSize: t2, maxSize: s2 };
  259. }
  260. }
  261. function N(e2, a, r2) {
  262. if (!e2.visualVariables)
  263. return;
  264. const i2 = [], n3 = [], t2 = [], s2 = [], o = [];
  265. for (const l3 of e2.visualVariables)
  266. switch (l3.type) {
  267. case "color":
  268. n3.push(l3);
  269. break;
  270. case "opacity":
  271. t2.push(l3);
  272. break;
  273. case "rotation":
  274. o.push(l3);
  275. break;
  276. case "size":
  277. s2.push(l3);
  278. }
  279. return n3.forEach((e3) => {
  280. const n4 = b(e3, a, r2);
  281. i2.push({ variable: e3, value: n4 });
  282. }), t2.forEach((e3) => {
  283. const n4 = h(e3, a, r2);
  284. i2.push({ variable: e3, value: n4 });
  285. }), o.forEach((e3) => {
  286. const n4 = m2(e3, a, r2);
  287. i2.push({ variable: e3, value: n4 });
  288. }), s2.forEach((e3) => {
  289. const n4 = y(e3, a, r2);
  290. i2.push({ variable: e3, value: n4 });
  291. }), i2.filter((e3) => e3.value != null);
  292. }
  293. function R(e2, a) {
  294. if (!a)
  295. return;
  296. let r2 = 0, i2 = a.length - 1;
  297. return a.some((a2, n3) => e2 < a2 ? (i2 = n3, true) : (r2 = n3, false)), [r2, i2, (e2 - a[r2]) / (a[i2] - a[r2])];
  298. }
  299. function T(e2, a, i2) {
  300. const n3 = ["proportional", "proportional", "proportional"];
  301. for (const t2 of e2) {
  302. const e3 = t2.useSymbolValue ? "symbol-value" : y(t2, a, i2);
  303. switch (t2.axis) {
  304. case "width":
  305. n3[0] = e3;
  306. break;
  307. case "depth":
  308. n3[1] = e3;
  309. break;
  310. case "height":
  311. n3[2] = e3;
  312. break;
  313. case "width-and-depth":
  314. n3[0] = e3, n3[1] = e3;
  315. break;
  316. case "all":
  317. case void 0:
  318. case null:
  319. n3[0] = e3, n3[1] = e3, n3[2] = e3;
  320. break;
  321. default:
  322. n(t2.axis);
  323. }
  324. }
  325. return n3;
  326. }
  327. export {
  328. v,
  329. b,
  330. h,
  331. m2 as m,
  332. y,
  333. w,
  334. M,
  335. k,
  336. N,
  337. T
  338. };
  339. //# sourceMappingURL=chunk-GRBROWI6.js.map