Commit c055e5c7 authored by Andres Käver's avatar Andres Käver
Browse files

first location fix

parent b0b13225
Pipeline #823 passed with stages
in 1 minute and 30 seconds
......@@ -37,21 +37,24 @@ namespace BLL.App.Services
var gpsSession = await UOW.GpsSessions.FirstOrDefaultAsync(gpsLocation.GpsSessionId, gpsLocation.AppUserId);
var lastLocation = await UOW.GpsLocations.LastInSessionAsync(gpsSession.Id);
// calculate the metrics
var distance = getDistance(gpsLocation, lastLocation);
var vertical = getVerticalDistance(gpsLocation, lastLocation);
gpsSession.Distance += distance;
if (vertical < 0)
if (lastLocation != null)
{
gpsSession.Descent += Math.Abs(vertical);
} else if (vertical > 0)
{
gpsSession.Descent += vertical;
}
// calculate the metrics
var distance = getDistance(gpsLocation, lastLocation);
var vertical = getVerticalDistance(gpsLocation, lastLocation);
gpsSession.Distance += distance;
if (vertical < 0)
{
gpsSession.Descent += Math.Abs(vertical);
} else if (vertical > 0)
{
gpsSession.Descent += vertical;
}
gpsSession.Duration = (gpsSession.RecordedAt - lastLocation.RecordedAt).TotalSeconds;
gpsSession.Duration = (gpsSession.RecordedAt - lastLocation.RecordedAt).TotalSeconds;
await UOW.GpsSessions.UpdateAsync(gpsSession);
await UOW.GpsSessions.UpdateAsync(gpsSession);
}
return base.Add(gpsLocation);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment