@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.09 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{fromValues as n,create as t}from"./aaBoundingRect.js";import{curveExtent as i}from"./curves/curveExtent.js";import{getEndpoint as r,isCoordinate as e}from"./curves/curveUtils.js";function o(n){return void 0!==n.xmin&&void 0!==n.ymin&&void 0!==n.xmax&&void 0!==n.ymax}function u(n){return void 0!==n.points}function c(n){return void 0!==n.x&&void 0!==n.y}function s(n){return void 0!==n.paths}function l(n){return void 0!==n.rings}function h(n){function t(t,i){return null==t?i:null==i?t:n(t,i)}return t}const m=h(Math.min),a=h(Math.max);function f(n,t){return s(t)?y(n,t.curvePaths??t.paths,!1,!1)??n:l(t)?y(n,t.curveRings??t.rings,!1,!1)??n:u(t)?p(n,t.points,!1,!1,!1,!1):o(t)?d(n,t):(c(t)&&(n[0]=t.x,n[1]=t.y,n[2]=t.x,n[3]=t.y),n)}function x(n){let i,r,e,o;for(n.reset(),i=e=1/0,r=o=-1/0;n.nextPath();){const t=g(n);i=Math.min(t[0],i),e=Math.min(t[1],e),r=Math.max(t[2],r),o=Math.max(t[3],o)}return t([i,e,r,o])}function g(n){let i,r,e,o;for(i=e=1/0,r=o=-1/0;n.nextPoint();)i=Math.min(n.x,i),e=Math.min(n.y,e),r=Math.max(n.x,r),o=Math.max(n.y,o);return t([i,e,r,o])}function v(n,t){return s(t)?y(n,t.curvePaths??t.paths,!0,!1)??n:l(t)?y(n,t.curveRings??t.rings,!0,!1)??n:u(t)?p(n,t.points,!0,!1,!0,!1):o(t)?d(n,t,!0,!1,!0,!1):(c(t)&&(n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.x,n[4]=t.y,n[5]=t.z),n)}function y(t,o,u,c){const s=u?3:2;if(!o.length||!o[0].length)return null;let l,h,f,x,[g,v]=r(o[0][0]),y=g,d=v;for(let p=0;p<o.length;p++){const t=o[p];for(let o=0;o<t.length;o++){const p=r(t[o]),[M,z]=p;if(g=m(g,M),v=m(v,z),y=a(y,M),d=a(d,z),u&&p.length>2){const n=p[2];l=m(l,n),h=a(h,n)}if(c&&p.length>s){const n=p[s];f=m(f,n),x=a(x,n)}const P=t[o];if(e(P)||o<1)continue;const j=r(t[o-1]),R=n(g,v,y,d);[g,v,y,d]=i(R,j,P)}}return u?c?(t[0]=g,t[1]=v,t[2]=l,t[3]=f,t[4]=y,t[5]=d,t[6]=h,t[7]=x,t.length=8,t):(t[0]=g,t[1]=v,t[2]=l,t[3]=y,t[4]=d,t[5]=h,t.length=6,t):c?(t[0]=g,t[1]=v,t[2]=f,t[3]=y,t[4]=d,t[5]=x,t.length=6,t):(t[0]=g,t[1]=v,t[2]=y,t[3]=d,t.length=4,t)}function d(n,t,i,r,e,o){const u=t.xmin,c=t.xmax,s=t.ymin,l=t.ymax;let h=t.zmin,m=t.zmax,a=t.mmin,f=t.mmax;return e?(h=h||0,m=m||0,o?(a=a||0,f=f||0,n[0]=u,n[1]=s,n[2]=h,n[3]=a,n[4]=c,n[5]=l,n[6]=m,n[7]=f,n):(n[0]=u,n[1]=s,n[2]=h,n[3]=c,n[4]=l,n[5]=m,n)):o?(a=a||0,f=f||0,n[0]=u,n[1]=s,n[2]=a,n[3]=c,n[4]=l,n[5]=f,n):(n[0]=u,n[1]=s,n[2]=c,n[3]=l,n)}function p(n,t,i,r,e,o){const u=i?3:2,c=r&&o,s=i&&e;if(!t.length||!t[0].length)return null;let l,h,f,x,[g,v]=t[0],[y,d]=t[0];for(let p=0;p<t.length;p++){const n=t[p],[i,r]=n;if(g=m(g,i),v=m(v,r),y=a(y,i),d=a(d,r),s&&n.length>2){const t=n[2];l=m(l,t),h=a(h,t)}if(c&&n.length>u){const t=n[u];f=m(l,t),x=a(h,t)}}return e?(l=l||0,h=h||0,o?(f=f||0,x=x||0,n[0]=g,n[1]=v,n[2]=l,n[3]=f,n[4]=y,n[5]=d,n[6]=h,n[7]=x,n):(n[0]=g,n[1]=v,n[2]=l,n[3]=y,n[4]=d,n[5]=h,n)):o?(f=f||0,x=x||0,n[0]=g,n[1]=v,n[2]=f,n[3]=y,n[4]=d,n[5]=x,n):(n[0]=g,n[1]=v,n[2]=y,n[3]=d,n)}export{f as getBoundsXY,v as getBoundsXYZ,x as getCursorBoundsXY,g as getCursorPathBounds,d as getExtentBounds,p as getPointsBounds,y as getRingsOrPathsBounds};