utils.js 3.0 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.24/esri/copyright.txt for details.
  4. */
  5. function t(t){return"function"==typeof t}function e(e,r,n,o){return t(e)?e(r,n,o):e}function r(t){return[t.r,t.g,t.b,t.a]}function n(t,e,r){const n=" /-,\n",a=t=>{let e=t.length;for(;e--;)if(!n.includes(t.charAt(e)))return!1;return!0},i=[];let c=0,l=-1;do{if(l=e.indexOf("[",c),l>=c){if(l>c){const t=e.substr(c,l-c);i.push([t,null,a(t)])}if(c=l+1,l=e.indexOf("]",c),l>=c){if(l>c){const r=t[e.substr(c,l-c)];r&&i.push([null,r,!1])}c=l+1}}}while(-1!==l);if(c<e.length-1){const t=e.substr(c);i.push([t,null,a(t)])}return t=>{let e="",n=null;for(const r of i){const[o,a,i]=r;if(o)i?n=o:(n&&(e+=n,n=null),e+=o);else{const r=t.attributes[a];r&&(n&&(e+=n,n=null),e+=r)}}return o(e,r)}}function o(t,e){switch("string"!=typeof t&&(t=String(t)),e){case"LowerCase":return t.toLowerCase();case"Allcaps":return t.toUpperCase();default:return t}}function a(t,e,r,n,o,a,i=!0){const c=e/o,l=r/a,u=Math.ceil(c/2),s=Math.ceil(l/2);for(let f=0;f<a;f++)for(let r=0;r<o;r++){const M=4*(r+(i?a-f-1:f)*o);let p=0,C=0,y=0,I=0,h=0,k=0,m=0;const d=(f+.5)*l;for(let n=Math.floor(f*l);n<(f+1)*l;n++){const o=Math.abs(d-(n+.5))/s,a=(r+.5)*c,i=o*o;for(let l=Math.floor(r*c);l<(r+1)*c;l++){let r=Math.abs(a-(l+.5))/u;const o=Math.sqrt(i+r*r);o>=-1&&o<=1&&(p=2*o*o*o-3*o*o+1,p>0&&(r=4*(l+n*e),m+=p*t[r+3],y+=p,t[r+3]<255&&(p=p*t[r+3]/250),I+=p*t[r],h+=p*t[r+1],k+=p*t[r+2],C+=p))}}n[M]=I/C,n[M+1]=h/C,n[M+2]=k/C,n[M+3]=m/y}}function i(t){return t?{r:t[0],g:t[1],b:t[2],a:t[3]/255}:{r:0,g:0,b:0,a:0}}function c(t){return t.data?.symbol}function l(t){return"CIMVectorMarker"===t.type||"CIMPictureMarker"===t.type||"CIMBarChartMarker"===t.type||"CIMCharacterMarker"===t.type||"CIMPieChartMarker"===t.type||"CIMStackedBarChartMarker"===t.type}function u(t){return"CIMGradientStroke"===t.type||"CIMPictureStroke"===t.type||"CIMSolidStroke"===t.type}function s(t){return"CIMGradientFill"===t.type||"CIMHatchFill"===t.type||"CIMPictureFill"===t.type||"CIMSolidFill"===t.type||"CIMWaterFill"===t.type}function f(t){return"CIMMarkerPlacementAlongLineRandomSize"===t.type||"CIMMarkerPlacementAlongLineSameSize"===t.type||"CIMMarkerPlacementAlongLineVariableSize"===t.type||"CIMMarkerPlacementAtExtremities"===t.type||"CIMMarkerPlacementAtMeasuredUnits"===t.type||"CIMMarkerPlacementAtRatioPositions"===t.type||"CIMMarkerPlacementOnLine"===t.type||"CIMMarkerPlacementOnVertices"===t.type}const M=t=>isNaN(t)||!t?0:t,p=t=>{if(!t)return!1;for(const e of t)switch(e.type){case"CIMGeometricEffectBuffer":case"CIMGeometricEffectOffset":return!0}return!1};function C(){return import("../../geometry/geometryEngineJSON.js")}export{o as _adjustTextCase,r as colorToArray,n as createLabelOverrideFunction,e as evaluateValueOrFunction,i as fromCIMColor,M as getValue,C as importGeometryEngine,s as isCIMFill,l as isCIMMarker,f as isCIMMarkerStrokePlacement,u as isCIMStroke,p as isGeometryEngineRequired,a as resampleHermite,c as toCIMSymbolJSON};