Position.altitude != Activity.Info.altitude

I'm using SDK 7.4.3, fr55 in the simulator in an app and I noticed that Position.altitude != Activity.Info.altitude.

Is this because pos is what the GPS detects and the activity altitude is from the barometer? Or a bug?

class MyApp extends App.AppBase {
    function onStart(state as Dictionary?) as Void {
		Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));
	}
    function onPosition(info as Position.Info) as Void {
        var ai = Activity.getActivityInfo();
        System.println("pos.alt: " + info.altitude + ", act.alt: " + ai.altitude);
    }
}

And I see:

pos.alt: 1235.495605, act.alt: 1263.935547
pos.alt: 1235.700806, act.alt: 1264.140747

  • pos is what the GPS detects and the activity altitude is from the barometer

    Based on the API docs, I think this is the correct explanation. It’s also somewhat intuitive that Position.Info.altitude would only be sourced from GPS, given that the Position module is related to GPS (“The Position module provides an interface for location information and positioning sensors.”)

    Position.Info.altitude:

    The elevation above mean sea level in meters (m).

    Elevation is obtained from the GPS. If no GPS is present, then no valid elevation will be returned.

    Activity.Info.altitude:

    The altitude above mean sea level in meters (m).

    Elevation is derived from the most accurate source: Barometer or GPS

  • Position.Info.altitude would only be sourced from GPS, given that the Position module is related to GPS

    Except: https://developer.garmin.com/connect-iq/api-docs/Toybox/Position/Info.html#heading-var
    If supported by the device, it provides compass orientation when stopped.

    and: https://developer.garmin.com/connect-iq/api-docs/Toybox/Position/Info.html#speed-var

    Speed is derived from the most accurate source in the following order:

    1. GPS

    2. Foot pod

    3. Accelerometer

  • That’s fair, my bad.

    Instead of “related to GPS”, I should’ve said “related to positioning sensors”, as “positioning sensors” is the exact wording that the API docs use. (I had a bad feeling about that as soon as I posted that comment tbh.)

    ”Positioning sensors” seems like it could refer to GPS, footpod (and implicitly, the newer chest straps which work like foot pods to provide speed and distance), accelerometer, and (maybe) compass.

    I guess if a compass can be a positioning sensor, so could a baro. But then again, I would guess that the Positioning permission would not apply to the baro, but it could apply to the compass. 

    To keep things simple, I probably should’ve just omitted that whole line of reasoning.

    Either way, the documentation for Position.Info.altitude explicitly states:

    The elevation above mean sea level in meters (m).

    Elevation is obtained from the GPS. If no GPS is present, then no valid elevation will be returned.

    So in this case, I don’t really have a problem with this behavior, given that it’s unambiguously documented, and given that there is a way to obtain the “activity altitude” (which can be sourced from either the baro or the GPS).

    I suppose this could be an issue if you have an app/device/situation for which Position is available but not Activity. In that case, perhaps you could use Sensor.Info.altitude:

    The altitude above mean sea level in meters (m).

    Elevation is derived from the most accurate source: Barometer or GPS in order of descending accuracy. If no GPS is present, then barometer readings will be used.