1function x(e,o,i,t){const l=(i-e)*Math.PI/180,n=(t-o)*Math.PI/180,d=Math.sin(l/2)*Math.sin(l/2)+Math.cos(e*Math.PI/180)*Math.cos(i*Math.PI/180)*Math.sin(n/2)*Math.sin(n/2);return 6371e3*(2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d)))}function L(e){const o=M(e);if(o.length===0)return{totalDistance:0,totalDuration:e.endDate&&e.startDate?(e.endDate-e.startDate)/1e3:void 0};const i=[...o].sort((c,u)=>c.timestamp-u.timestamp);let t=0,a=0,l=0,n=i[0].altitude||0,d=i[0].altitude||0,m=0,p=0,r=0;const g=i[0].timestamp,v=i[i.length-1].timestamp;for(let c=1;c<i.length;c++){const u=i[c-1],s=i[c],f=x(u.latitude,u.longitude,s.latitude,s.longitude);if(t+=f,u.altitude!==void 0&&s.altitude!==void 0){const h=s.altitude-u.altitude;h>0?a+=h:l+=Math.abs(h),n=Math.max(n,s.altitude),d=Math.min(d,s.altitude)}if(s.speed!==void 0&&s.speed>0)m=Math.max(m,s.speed),p+=s.speed,r++;else if(u.timestamp&&s.timestamp){const h=(s.timestamp-u.timestamp)/1e3;if(h>0){const P=f/h;m=Math.max(m,P),p+=P,r++}}}const D=v-g,S=r>0?p/r:void 0;return{totalDistance:t,totalElevationGain:a,totalElevationLoss:l,maxElevation:n,minElevation:d,maxSpeed:m,averageSpeed:S,totalDuration:D/1e3,numberOfPhotos:e.milestones.reduce((c,u)=>c+u.images.length,0),numberOfWaypoints:e.milestones.length}}function M(e){const o=[];return e.milestones.forEach(t=>{t.gpsPoint&&o.push(t.gpsPoint)}),e.gpsPoints&&e.gpsPoints.length>0&&o.push(...e.gpsPoints),e.routes.forEach(t=>{t.points&&t.points.length>0&&o.push(...t.points)}),o.filter((t,a,l)=>a===l.findIndex(n=>n.timestamp===t.timestamp&&n.latitude===t.latitude&&n.longitude===t.longitude))}function y(e){const o=L(e),i=M(e);if(i.length>0){const t=i.filter(a=>a.altitude!==void 0);if(t.length>0){const a=[...t].sort((l,n)=>(n.altitude||0)-(l.altitude||0));e.highestPoint=a[0],e.lowestPoint=a[a.length-1]}}if(i.length>0){const t=[...i].sort((a,l)=>a.timestamp-l.timestamp);e.startLocation={latitude:t[0].latitude,longitude:t[0].longitude,altitude:t[0].altitude,accuracy:t[0].accuracy,timestamp:t[0].timestamp},e.endLocation={latitude:t[t.length-1].latitude,longitude:t[t.length-1].longitude,altitude:t[t.length-1].altitude,accuracy:t[t.length-1].accuracy,timestamp:t[t.length-1].timestamp}}return{...e,statistics:o}}export{L as calculateMountainLogStatistics,y as updateMountainLogStatistics};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.