12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{getLength as t,getPathLength as n}from"../../geometry/support/coordsUtils.js";function e(n,e=!1){let o=[];if(e){for(const t of n)if(t.geometry){const n=t.geometry;o.push.apply(o,n.points)}}else o=n.map((t=>t.geometry));const l=[],i=[];let s=1/0,r=-1/0,c=0,f=0,u=0,a=0;for(const m of o){if(!m)continue;e?(l[0]=m[0],l[1]=m[1]):(l[0]=m.x,l[1]=m.y);let n=1/0,g=-1/0;for(const c of o){if(c===m)continue;if(!c)continue;e?(i[0]=c[0],i[1]=c[1]):(i[0]=c.x,i[1]=c.y);const o=t(l,i);o>0&&(o<n&&(n=o),o<s&&(s=o),o>g&&(g=o),o>r&&(r=o))}n!==1/0&&(++u,c+=n),g!==-1/0&&(++a,f+=g)}return{minDistance:s!==1/0?s:null,maxDistance:r!==-1/0?r:null,avgMinDistance:u?c/u:null,avgMaxDistance:a?f/a:null}}function o(t){let e=0,o=0,l=1/0,i=-1/0;for(const s of t){const t=s.geometry;if(t){let s=0;for(const e of t.paths){const t=n(e);t>0&&(s+=t)}s>0&&(++e,o+=s,s<l&&(l=s),s>i&&(i=s))}}return{minLength:l!==1/0?l:null,maxLength:i!==-1/0?i:null,avgLength:e?o/e:null}}function l(t){let n=0,e=0,o=1/0,l=-1/0;for(const i of t){const t=i.geometry;if(t){const i=t.extent;if(i){const t=Math.sqrt(i.width*i.height);t>0&&(++n,e+=t,t<o&&(o=t),t>l&&(l=t))}}}return{minSize:o!==1/0?o:null,maxSize:l!==-1/0?l:null,avgSize:n?e/n:null}}function i(t){const{features:n}=t;let i=null;switch(t.geometryType){case"point":i=e(n);break;case"multipoint":i=e(n,!0);break;case"polyline":i=o(n);break;case"polygon":i=l(n)}return Promise.resolve(i)}export{i as default};
|