/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{getMetersPerUnitForSR as e,getMetersPerVerticalUnitForSR as n,convertUnit as t}from"../../../core/units.js";function l(t,l){if(null==t||null==l)return null;const{samples:a,spatialReference:s}=t,{distance:v,elevation:r}=l,u=e(s),c=n(s),m=a.length,p=new Array(m);for(let e=0;e<m;++e){const n=a[e],t=n.sampledZ,l=n.coordinate;p[e]={x:l[0],y:l[1],z:t,distance:i(n.distance,u,v),elevation:o(t,c,r)}}return p}function a(t,l){if(null==t||null==l||null==t.statistics||null==t.spatialReference)return null;const{distance:a,elevation:s}=l,{statistics:v,spatialReference:r}=t,u=e(r),c=n(r);return{maxDistance:i(v.maxDistance,u,a),minElevation:o(v.minElevation,c,s),maxElevation:o(v.maxElevation,c,s),avgElevation:o(v.avgElevation,c,s),elevationGain:o(v.elevationGain,c,s),elevationLoss:o(v.elevationLoss,c,s),maxPositiveSlope:v.maxPositiveSlope,maxNegativeSlope:v.maxNegativeSlope,avgPositiveSlope:v.avgPositiveSlope,avgNegativeSlope:v.avgNegativeSlope}}function i(e,n,l){return null==e?null:t(e*n,"meters",l)}function o(e,n,l){return null==e?null:t(e*n,"meters",l)}export{l as convertSamples,a as convertStatistics};
