Search code examples
androidgpsaltitude

Vertical Accuracy in android GPS


I am working with GPS related app. I need to get vertical accuracy but it always gets fix 11.0000. I need it to be dynamic as lat and lng. I have used getAccuracy but it results in horizontal accuracy.

@Override
public void onLocationChanged(Location location) {
    if (location != null) {
        lat = location.getLatitude();
        lon = location.getLongitude();
        Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault());
        address = mailOb.getAddress(geoCoder, lat, lon);

        if (!meterFootFlag) {
            diameter = Math.round(location.getAccuracy()) + " m.";
            altitude = Math.round(location.getAltitude()) + " m.";

        } else {
            diameter = Math.round(location.getAccuracy() * 3.28084) + " ft.";
            altitude = Math.round(location.getAltitude() * 3.28084) + " ft.";
        }

        if (diameter.contains("+"))
            diameter.replace("+", "");
        else if (altitude.contains("+"))
            altitude.replace("+", "");
    } else {
        lat = 0.0;
        lon = 0.0;

        if (!meterFootFlag) {
            altitude = 0.0 + " m.";
            diameter = 0.0 + " m.";

        } else {
            altitude = 0.0 + " ft.";
            diameter = 0.0 + " ft.";
        }
    }
    mlocManager.removeUpdates(MySettings.this);
    pDialog.dismiss();
}

How can I get vertical accuracy?

Thanks in advance


Solution

  • Android does not provide the vertical accuracy.
    Vertical accuracy usually is 2-3 times worse then horizontal accuracy.

    A simple solution: use the androids accuracy for both horizontal and vertical.

    advanced solution 1: find out what android uses as total accuracy (it could be a radial error of an error-sphere, including lat,long and altitude)

    try to find out a conversion factor, e.g take accuracy and multiply *2,5

    Another solution, look at iphone horizontal and vert accuracy, and compare to that of android. find out an average conversion factor from acc to vert acc.

    Solution 3: think why you need vertical accuracy at all. why do you need that?

    hints:examples from my iphone4: when iphone shows 30m hor, i have 57vert, 10hor: 15-20vert, 5 hor: 10vert