Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

7 lines
2.1 KiB

// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define(["exports"],function(y){function C(a,d,h,f,b,g){g=b?g?4:3:g?3:2;let k=h,l=h+g,r=0,m=0,n=h=0,c=0;for(let e=0,p=f-1;e<p;e++,k+=g,l+=g){f=d[k];const u=d[k+1],v=d[k+2],t=d[l],x=d[l+1],w=d[l+2];let q=f*x-t*u;n+=q;r+=(f+t)*q;m+=(u+x)*q;b&&(q=f*w-t*v,h+=(v+w)*q,c+=q);f<a[0]&&(a[0]=f);f>a[1]&&(a[1]=f);u<a[2]&&(a[2]=u);u>a[3]&&(a[3]=u);b&&(v<a[4]&&(a[4]=v),v>a[5]&&(a[5]=v))}0<n&&(n*=-1);0<c&&(c*=-1);if(!n)return null;a=[r,m,.5*n];b&&(a[3]=h,a[4]=.5*c);return a}function z(a,d,h,f,b){b=f?b?4:3:b?3:2;
let g=d,k=d+b,l=0,r=0,m=0,n=0;for(let u=0,v=h-1;u<v;u++,g+=b,k+=b){var c=a[g];const t=a[g+1],x=a[g+2],w=a[k],q=a[k+1],A=a[k+2];if(f){var e=w-c;var p=q-t;const B=A-x;e=Math.sqrt(e*e+p*p+B*B)}else e=w-c,p=q-t,e=Math.sqrt(e*e+p*p);e&&(l+=e,f?(c=[c+.5*(w-c),t+.5*(q-t),x+.5*(A-x)],r+=e*c[0],m+=e*c[1],n+=e*c[2]):(c=[c+.5*(w-c),t+.5*(q-t)],r+=e*c[0],m+=e*c[1]))}return 0<l?f?[r/l,m/l,n/l]:[r/l,m/l]:0<h?f?[a[d],a[d+1],a[d+2]]:[a[d],a[d+1]]:null}y.getCentroidOptimizedGeometry=function(a,d,h,f){if(!d?.lengths.length)return null;
a.lengths.length&&(a.lengths.length=0);a.coords.length&&(a.coords.length=0);const b=a.coords,g=[],k=h?[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY]:[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY],{lengths:l,coords:r}=d;var m=h?f?4:3:f?3:2;let n=0;for(const c of l){const e=C(k,r,n,c,h,f);e&&g.push(e);n+=c*m}g.sort((c,e)=>{let p=c[2]-e[2];0===
p&&h&&(p=c[4]-e[4]);return p});g.length&&(m=6*g[0][2],b[0]=g[0][0]/m,b[1]=g[0][1]/m,h&&(m=6*g[0][4],b[2]=0!==m?g[0][3]/m:0),b[0]<k[0]||b[0]>k[1]||b[1]<k[2]||b[1]>k[3]||h&&(b[2]<k[4]||b[2]>k[5]))&&(b.length=0);if(!b.length)if(d=d.lengths[0]?z(r,0,l[0],h,f):null)b[0]=d[0],b[1]=d[1],h&&2<d.length&&(b[2]=d[2]);else return null;return a};y.lineCentroid=z;Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});