I have application that track user movement. And I store all relevant data lat/lng/alt etc.
I am trying add elevation like on runkeeper just without graphic I need just to get elevation value.
In my .h file:
@property (nonatomic) double netElevationLoss;
@property (nonatomic) double netElevationGain;
@property (nonatomic) double netElevationChange;
In my .m file:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
double elevationChange = oldLocation.altitude - newLocation.altitude;
if (elevationChange < 0)
{
netElevationLoss += fabs(elevationChange);
}
else
{
netElevationGain += elevationChange;
}
netElevationChange = netElevationGain - netElevationLoss;
...
I don't know is this correct way to calculate it.
I have tested it and alt is for example 182.53 and netElevationChange
is -182.53.
Maybe it's good but maybe I am missing something any idea what I have done wrong here?