UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 3.88 kB
import{isSome as t,isNone as e}from"../../../../core/maybe.js";import{getMetersPerUnitForSR as r}from"../../../../core/unitUtils.js";import{o as n,r as o,n as i}from"../../../../chunks/mat4.js";import{c as s}from"../../../../chunks/mat4f64.js";import{d as u,O as a}from"../../../../chunks/vec3f64.js";import{s as m}from"../../../../chunks/vec4.js";import{d as l,O as c}from"../../../../chunks/vec4f64.js";import{projectPoint as f}from"../../../../geometry/projection.js";import{width as p,depth as h,height as g}from"../../../../geometry/support/aaBoundingBox.js";import{create as y}from"../../../../geometry/support/aaBoundingRect.js";import{ringsCentroid as d}from"../../../../geometry/support/centroid.js";import{getPointOnPath as x,getPathLength as j}from"../../../../geometry/support/coordsUtils.js";import{makeDehydratedPoint as b}from"../../../../layers/graphics/dehydratedFeatures.js";import{isHydratedGeometry as v,clonePoint as w}from"../../../../layers/graphics/hydratedFeatures.js";import{VertexAttribute as z}from"../../webgl-engine/lib/VertexAttribute.js";function A(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(M(t),e,!0);case"mesh":return P(t.origin,e,!1)}else switch(t.type){case"extent":return P(R(t),e,!0);case"polygon":return P(F(t),e,!0);case"polyline":return P(M(t),e,!0)}}function M(t){const e=t.paths[0];if(!e||0===e.length)return null;const r=x(e,j(e)/2);return b(r[0],r[1],r[2],t.spatialReference)}function R(t){return b(.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 F(t){const e=t.rings[0];if(!e||0===e.length)return null;const r=d(t.rings,!!t.hasZ);return b(r[0],r[1],r[2],t.spatialReference)}function P(t,e,r){const n=r?t:w(t);return e&&t?f(t,n,e)?n:null:n}function k(t,e,r,n=0){if(t){e||(e=y());const o=t;let i=.5*o.width*(r-1),s=.5*o.height*(r-1);return o.width<1e-7*o.height?i+=s/20:o.height<1e-7*o.width&&(s+=i/20),m(e,o.xmin-i-n,o.ymin-s-n,o.xmax+i+n,o.ymax+s+n),e}return null}function U(t,e){for(let r=0;r<t.geometries.length;++r){const n=t.geometries[r].getMutableAttribute(z.AUXPOS1);n&&n.data[3]!==e&&(n.data[3]=e,t.geometryVertexAttrsUpdated(t.geometries[r]))}}function B(e,r){const n=l(c);return t(e)&&(n[0]=e[0],n[1]=e[1],n[2]=e[2]),t(r)?n[3]=r:t(e)&&e.length>3&&(n[3]=e[3]),n}function D(e,r,n,o,i,s=[0,0,0,0]){for(let u=0;u<3;++u)t(e)&&null!=e[u]?s[u]=e[u]:t(n)&&null!=n[u]?s[u]=n[u]:s[u]=i[u];return t(r)?s[3]=r:t(o)?s[3]=o:s[3]=i[3],s}function I(t=a,r,n,o=1){const i=new Array(3);if(e(r)||e(n))i[0]=1,i[1]=1,i[2]=1;else{let e,o=0;for(let s=2;s>=0;s--){const u=t[s];let a;const m=null!=u,l=0===s&&!e&&!m,c=n[s];"symbol-value"===u||l?a=0!==c?r[s]/c:1:m&&"proportional"!==u&&isFinite(u)&&(a=0!==c?u/c:1),null!=a&&(i[s]=a,e=a,o=Math.max(o,Math.abs(a)))}for(let t=2;t>=0;t--)null==i[t]?i[t]=e:0===i[t]&&(i[t]=.001*o)}for(let e=2;e>=0;e--)i[e]/=o;return u(i)}function O(t){return null!=t.isPrimitive}function S(t){return V(O(t)?[t.width,t.depth,t.height]:t)?null:"Symbol sizes may not be negative values"}function V(t){if(Array.isArray(t)){for(const e of t)if(!V(e))return!1;return!0}return null==t||t>=0}function G(t,e,r,u=s()){const a=t||0,m=e||0,l=r||0;return 0!==a&&n(u,u,-a/180*Math.PI),0!==m&&o(u,u,m/180*Math.PI),0!==l&&i(u,u,l/180*Math.PI),u}function X(t,e,n){if(null!=n.minDemResolution)return n.minDemResolution;const o=r(e),i=p(t)*o,s=h(t)*o,u=g(t)*(e.isGeographic?1:o);return 0===i&&0===s&&0===u?n.minDemResolutionForPoints:.01*Math.max(i,s,u)}export{A as computeCentroid,G as computeObjectRotation,I as computeObjectScale,X as demResolutionForBoundingBox,k as enlargeExtent,V as isValidSize,B as mixinColorAndOpacity,D as overrideColor,U as updateVertexAttributeAuxpos1w,S as validateSymbolLayerSize};