I have an application recording data from the CMAltimeter startRelativeAltitudeUpdatesToQueue: block. Recording is fine but some data are odd. Here is the very simple snippet i use for recording.
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[self.altitude startRelativeAltitudeUpdatesToQueue:queue withHandler:^(CMAltitudeData *altitudeData, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^ {
NSLog(@"Altitude: %f", altitudeData.relativeAltitude.floatValue);
});
}];
Recording is done while walking in a city and i got some following odd values. As you can see it's like i drop in free fall from +7 meters to -225 meters. As stated in the documentation Altitude is relative to the first altitude record wich is zero.
Does one to explain if something wrong with my comprehension how CMAltimeter works ? Or is this a bug ?
Thanks
2014-10-03 09:09:02.669 XXXXXXXXX[1811:13772492] altitude: 9.252784729003906
2014-10-03 09:09:02.669 XXXXXXXXX[1811:13772492] altitude: 9.252784729003906
2014-10-03 09:09:02.669 XXXXXXXXX[1811:13772492] altitude: 8.666885375976562
2014-10-03 09:09:02.669 XXXXXXXXX[1811:13772492] altitude: 7.081024169921875
2014-10-03 09:09:02.669 XXXXXXXXX[1811:13772492] altitude: -28.24831390380859
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -61.20027160644531
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -28.24831390380859
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -40.86483764648438
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -40.86483764648438
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -40.86483764648438
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -45.53067016601562
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -53.98106384277344
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -64.6231689453125
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -53.98106384277344
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -28.13791656494141
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -28.13791656494141
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -92.41580200195312
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -146.3153533935547
2014-10-03 09:09:02.670 XXXXXXXXX[1811:13772492] altitude: -160.0170745849609
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -181.5329132080078
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -181.5329132080078
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -181.5329132080078
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -199.3322296142578
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -193.2239837646484
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -199.3322296142578
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -209.9459381103516
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -209.9459381103516
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -187.6910858154297
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -187.6910858154297
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -197.9417877197266
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -201.6117706298828
2014-10-03 09:09:02.671 XXXXXXXXX[1811:13772492] altitude: -201.6117706298828
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -201.6117706298828
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -225.4467010498047
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -225.4467010498047
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -225.4467010498047
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -190.1396331787109
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -190.1396331787109
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -220.1163177490234
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -220.1163177490234
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -217.6054229736328
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -216.1069793701172
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -216.1069793701172
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -216.1069793701172
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -220.0596771240234
2014-10-03 09:09:02.672 XXXXXXXXX[1811:13772492] altitude: -208.4894256591797
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -208.4894256591797
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -181.7436370849609
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -120.3368835449219
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -37.50768280029297
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -37.50768280029297
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -37.50768280029297
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -35.98821258544922
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -35.98821258544922
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -33.94368743896484
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -33.94368743896484
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -25.50093841552734
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -25.50093841552734
2014-10-03 09:09:02.673 XXXXXXXXX[1811:13772492] altitude: -25.50093841552734
2014-10-03 09:09:02.674 XXXXXXXXX[1811:13772492] altitude: -51.27220153808594
2014-10-03 09:09:02.674 XXXXXXXXX[1811:13772492] altitude: -16.14826202392578
2014-10-03 09:09:02.674 XXXXXXXXX[1811:13772492] altitude: 2.517410278320312
2014-10-03 09:09:02.674 XXXXXXXXX[1811:13772492] altitude: 3.932975769042969
2014-10-03 09:09:02.674 XXXXXXXXX[1811:13772492] altitude: 4.590446472167969
2014-10-03 09:09:02.674 XXXXXXXXX[1811:13772492] altitude: 6.611000061035156
2014-10-03 09:09:02.674 XXXXXXXXX[1811:13772492] altitude: 6.611000061035156
2014-10-03 09:09:02.674 XXXXXXXXX[1811:13772492] altitude: 5.907508850097656
Your results are most likely due to a small bug in your code:
NSLog(@"Altitude: %f", altitudeData.relativeAltitude.floatValue);
should be:
NSLog(@"Altitude: %f", altitudeData.relativeAltitude.doubleValue);
the formatter '%f' expects a double value.