I am testing an Android application that records the location (lat / long / alt). I am running the application on a Samsung GTS5830 phone running Android 2.2.1.
I read here and there that GPS altitude is often incorrect due to the fact that the earth is not completely spherical. For example, at my location, the height of the geoid is 52 meters.
I understand that this altitude will be subtracted from the “pure” GPS altitude. This would make sense for my location as:
- altitude from GPS phone: 535 m
- geoid altitude: 52 m
- altitude from phone GPS minus geoid height: 482m
- correct atlitude: 478 m
482 is close enough to the real thing for me to track elevations when hiking
- Is the above GPS altitude formula minus the geoid altitude correct?
- Is it correct to assume that the android does not affect the height of the geoid when returning the height of the GPS?
- If this is true, does it run for all versions of Android?
Here is the code I use to get the GPS coordinates:
public class HelloAndroid extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d("main", "onCreate");
setupGps();
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
LocationListener locationListener;
LocationManager lm;
void setupGps() {
Log.d("gps", "Setting up GPS...");
locationListener = new MyLocationListener();
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 20000, 5,
locationListener);
Log.d("gps",
"GPS supports altitude: "
+ lm.getProvider(LocationManager.GPS_PROVIDER)
.supportsAltitude());
Log.d("gps", "Finished setting up GPS.");
}
static class MyLocationListener implements LocationListener {
public void onLocationChanged(Location location) {
Log.d("gps", "long: " + location.getLongitude() + ", lat: "
+ location.getLatitude() + ", alt: "
+ location.getAltitude());
}
}
}
user610650
source
share