Im Making an iOS App for Mountain Climbers to get the Height from SeaLevel , Currently Im stuck here. Im using iOS Barometer to get the details , but it only gives Pressure,Relative altitude and timestamp . is there a calculation to get the height from sea level ? I'm using following way to get the values. I'm using CMAltimeter
NSNumberFormatter *formatter = [[NSNumberFormatter alloc]init];
formatter.maximumFractionDigits = 2;
formatter.minimumIntegerDigits = 1;
NSNumber *timestamp = [NSNumber numberWithDouble:altitudeData.timestamp];
NSString *timeInterval = [NSString stringWithFormat:@"%@", [formatter stringFromNumber:timestamp]];
NSString *altitude = [NSString stringWithFormat:@"%@", [formatter stringFromNumber:altitudeData.relativeAltitude]];
NSString *pressure = [NSString stringWithFormat:@"%@", [formatter stringFromNumber:altitudeData.pressure]];
self.label1.text = [NSString stringWithFormat:@"Time Interval: \n%@", timeInterval];
self.label2.text = [NSString stringWithFormat:@"Relative Altitude: \n%@", altitude];
self.label3.text = [NSString stringWithFormat:@"Air Pressure: \n%@", pressure];
Keep in my that this will only work with iPhone 6 and above since only they have built in barometer. The formula you want is called hypsometric formula.
P0 is sea-level pressure in hPa
P is atmospheric pressure in hPa
T is temperature in C
h is altitude in meters
#include <math.h>
h = ((pow(p0/p,1/5.257)-1)*(t+273.15))/0.0065;