@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 4.33 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{getMetersPerUnitForSR as t}from"../../../../core/unitUtils.js";import{rotateZ as e,rotateX as r,rotateY as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as o,fromArray as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as l}from"../../../../chunks/vec42.js";import{clone as u,ONES as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPoint as c}from"../../../../geometry/projectionUtils.js";import{width as m,depth as p,height as f}from"../../../../geometry/support/aaBoundingBox.js";import{create as h}from"../../../../geometry/support/aaBoundingRect.js";import{ringsCentroid as y}from"../../../../geometry/support/centroid.js";import{getPointOnPath as x,getPathLength as g}from"../../../../geometry/support/coordsUtils.js";import{vertexSpaceOriginToPoint as d}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{makeDehydratedPoint as j}from"../../../../layers/graphics/dehydratedPoint.js";import{isHydratedGeometry as v,clonePoint as z}from"../../../../layers/graphics/hydratedFeatures.js";function b(t,e){if("point"===t.type)return P(t,e,!1);if(v(t))switch(t.type){case"extent":return P(t.center,e,!1);case"polygon":return P(t.centroid,e,!1);case"polyline":return P(w(t),e,!0);case"mesh":return P(d(t.vertexSpace,t.spatialReference)??t.extent.center,e,!1);case"multipoint":return}else switch(t.type){case"extent":return P(M(t),e,!0);case"polygon":return P(R(t),e,!0);case"polyline":return P(w(t),e,!0);case"multipoint":return}}function w(t){const e=t.paths[0];if(!e||0===e.length)return null;const r=x(e,g(e)/2);return j(r[0],r[1],r[2],t.spatialReference)}function M(t){return j(.5*(t.xmax+t.xmin),.5*(t.ymax+t.ymin),null!=t.zmin&&null!=t.zmax&&isFinite(t.zmin)&&isFinite(t.zmax)?.5*(t.zmax+t.zmin):void 0,t.spatialReference)}function R(t){const e=t.rings[0];if(!e||0===e.length)return null;const r=y(t.rings,!!t.hasZ);return j(r[0],r[1],r[2],t.spatialReference)}function P(t,e,r){const n=r?t:z(t);return e&&t?c(t,n,e)?n:null:n}function F(t){if(!t)return 0;switch(t.type){case"point":return t.z;case"extent":return t.zmax;case"polygon":return t.hasZ?t.rings.reduce(((t,e)=>e.reduce(((t,e)=>Math.max(t,e[2])),t)),-1/0):void 0;case"polyline":return t.hasZ?t.paths.reduce(((t,e)=>e.reduce(((t,e)=>Math.max(t,e[2])),t)),-1/0):void 0;case"mesh":return t.extent.zmax;case"multipoint":return}}function S(t,e,r,n=0){if(t){e||(e=h());const i=t;let o=.5*i.width*(r-1),s=.5*i.height*(r-1);return i.width<1e-7*i.height?o+=s/20:i.height<1e-7*i.width&&(s+=o/20),l(e,i.xmin-o-n,i.ymin-s-n,i.xmax+o+n,i.ymax+s+n),e}return null}function U(t,e,r=null){const n=u(a);return null!=t&&(n[0]=t[0],n[1]=t[1],n[2]=t[2]),null!=e?n[3]=e:null!=t&&t.length>3&&(n[3]=t[3]),r&&(n[0]*=r,n[1]*=r,n[2]*=r,n[3]*=r),n}function A(t,e,r,n,i,o){for(let s=0;s<3;++s)o[s]=null!=t?.[s]?t[s]:null!=r?.[s]?r[s]:i[s];return o[3]=null!=e?e:null!=n?n:i[3],o}function B(t=o,e,r,n=1){const i=new Array(3);if(null==e||null==r)i[0]=1,i[1]=1,i[2]=1;else{let n,o=0;for(let s=2;s>=0;s--){const l=t[s],u=null!=l,a=0===s&&!n&&!u,c=r[s];let m;"symbol-value"===l||a?m=0!==c?e[s]/c:1:u&&"proportional"!==l&&isFinite(l)&&(m=0!==c?l/c:1),null!=m&&(i[s]=m,n=m,o=Math.max(o,Math.abs(m)))}for(let t=2;t>=0;t--)null==i[t]?i[t]=n:0===i[t]&&(i[t]=.001*o)}for(let o=2;o>=0;o--)i[o]/=n;return s(i)}function D(t){return null!=t.isPrimitive}function I(t){return Z(D(t)?[t.width,t.depth,t.height]:t)?null:"Symbol sizes may not be negative values"}function Z(t){const e=t=>null==t||t>=0;return Array.isArray(t)?t.every(e):e(t)}function k(t,o,s,l=i()){return t&&e(l,l,-t/180*Math.PI),o&&r(l,l,o/180*Math.PI),s&&n(l,l,s/180*Math.PI),l}function E(e,r,n){if(null!=n.minDemResolution)return n.minDemResolution;const i=t(r),o=m(e)*i,s=p(e)*i,l=f(e)*(r.isGeographic?1:i);return 0===o&&0===s&&0===l?n.minDemResolutionForPoints:.01*Math.max(o,s,l)}export{b as computeCentroid,F as computeMaxZ,k as computeObjectRotation,B as computeObjectScale,E as demResolutionForBoundingBox,S as enlargeExtent,Z as isValidSize,U as mixinColorAndOpacity,A as overrideColor,I as validateSymbolLayerSize};