Android get exact height above NN - android

How do i get the actual (accurate ~1m) height of my location?
Ive tried registering a LocationListener, receiving the Altitude, but that does not work fine or even accurate. Im around 400m above NN and it displays 7m.
As result: GPS is not a good height-provider as i assume.
Do you have any ideas how to obtain this height?

Presumably you requested a LocationManager, not a LocationListener, and getAltitude() to obtain your height.
GPS/GNSS is not as good at altitude as it is at longitude and latitude, but for a reasonable fix you should be within 10m of the correct altitude. Note that altitude is adjusted for the geoid ( http://en.wikipedia.org/wiki/Geoid ) and the datum ( http://en.wikipedia.org/wiki/Datum_(geodesy) ) in use, which can alter your reported height compared to what you are expecting.
But you may be getting your location provided by a location provider that isn't actually GPS - it could be cell tower based, or due to dead reckoning or WiFi locationing. Or perhaps the android phone you are using just has a bad GPS integreation design that is messing with your accuracy.
I would recommend downloading a test application such as GPS Test ( see https://market.android.com/details?id=com.chartcross.gpstest&hl=en ) which will show you if you have a fix, and what altitude is actually being reported by your GPS. The third box on the bottom of the GPS Test app shows altitude, heading and velocity values for each fix.

If you have a GPS, barometer, and data connection, you can send the GPS location to one of several weather APIs to get the local barometer setting (p0). If p1 is the value from the pressure sensor then SensorManager.getAltitude(p0, p1) will give you a very accurate altitude.
I don't think the altitude will have 1 meter accuracy, but it is about as accurate as you can hope for.
This SO question/answer discuses weather APIs:
Sealevel Pressure and Temperature Calculation

Related

How does Apple or Android calculate speed in devices?

There are any documentation for this? I've checked many formulas and algorithms but didn't find an explicit definition how they get the speed provided in Geolocation object.
The GPS chipset provides the current velocity to the system along with the current location.
The chipset may compute the velocity by comparing location over time and correcting for the curvature of the Earth at the current location, or from the Doppler shift of the received satellite signals.
Whichever method is used, the operating system doesn’t need to do any processing to get the speed. The velocity data is provided along with location and altitude data directly from the GPS chip (actually chips in many newer devices support both GPS and GLONASS, but which system is used is not visible to the user).
Physics.org has a simple explanation of how GPS works
Wherever you are on the planet, at least four GPS satellites are ‘visible’ at any time. Each one transmits information about its position and the current time at regular intervals. These signals, travelling at the speed of light, are intercepted by your GPS receiver, which calculates how far away each satellite is based on how long it took for the messages to arrive.
Once it has information on how far away at least three satellites are, your GPS receiver can pinpoint your location using a process called trilateration.
But you can search for more detailed explanations of the mathematics and physics involved.
It basically scans your location (i.e. your latitude and longitude) and compares with the last check. Using euclidian distance, it can get the distance in the period of time. With the time (for example, if it scans your location every 2 seconds), it can easily estimate your speed by doing Speed = Distance/2.

Check if the device is STILL (Not Moving) to ignore onlocation changed events in Android

Hi i am working on a real time location tracking application where i have used Fused Location provider Api. I was able to get the location updates when the device is moving. But i was also able to get the location updates even if the device is stationary on a table when i am indoor. So I have calculated the distance between the last location and the current location triggered in Onlocationchanged event and checked whether the distance is less than 30 metres, to know the device is actually moving. But sometimes the distance i get is greater than 400 metres (indoor/Device is Stationary). How Can i ignore the onlocationchange event when i am indoor? Any suggestions are appreciated.Thanks in advance.
Unfortunately I don't believe there's much you can do about it.
The reason you see those updates with great changes it's because indoors, you won't get a GPS lock, so the device is relying on cell tower and WiFi hotspot triangulation to determine your location, and something around 200m to 1km is the best you'll get with this kind of technology.
A possible attempt to hack-around it would be to:
check the source and precision of the location update
use the activity recognition API to guess if the device really moved
but both are a hack, around the technology limitation and might not be as reliable.

LocationClient Accuracy incorrect

I implemented the new LocationClient into my app, but doing a test run I noticed the readings are incorrect.
I was driving outside without GPS. WLAN on. Thus location accuracy can only be what used to be NETWORK.
I set the LocationClient to LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY; and update interval to 15 sec.
When I get the data I evaluate the Location with getAccuracy() and getTime(). Both values can not be trusted.
I get an accuracy of 25 to 50m, sometimes up to 100 meters, typical for WIFI locations. However, once I left home, the location reported (with getAccuray() < 100) had nothing much to do with my current location (actual accuracy >800m). It resembled best the cell tower location. Location was never updated in the hour I was traveling, thus always pointing to the same cell tower (incidently I always was in that area although traveling about 3 km).
Doing further tests I noticed that location and accuracy did not change for at least a minute after I turned wifi off. I was walking, so accelerator should be triggered. Again, location was way off to where I was, but accuracy still reported < 30m. After about 1-2 Minutes, the location was then reported with accuracy >800 m which was correct.
I can live with bad accuracy, but I need to know that.
Time is always updated to latest time also while the actual reading is older. This also seems a bug, someone already raised an issue at google for that.
Summarized it means I can not use that functionality. I get old readings reported as current and accuracy which does not match the reading.
Test where done on a Nexus 4. Phone was connected to an UMTS (3G) cell.
Are these known issues? Is there a way to work around it (getting the correct accuracy), or do I have to use the "old" LocationManager?

Does Location#distanceTo(Location) take Location#getAccuracy() into account?

I want to write a LocationListener that takes the most accurate and precise recent location as its location. I'm intending to use this code in my LocationListener:
#Override
public void onLocationChanged(Location location) {
if(location.distanceTo(mLocation)>location.getAccuracy()){
mLocation = location;
}
}
What I intend this to do is update the location if the user's old location is outside the circle of "possible locations" that the new location indicates. So, for example, if our last measurement was a GPS signal and the new one is a cell tower, and the old location was in range of the cell tower, we don't update; on the other hand, if the cell tower is sufficiently distant, we know the user has moved and record that.
However, the distanceTo(Location) function states it returns the approximate distance in metres between locations. Does it already take the accuracy into account? Will it give me a precise enough figure to let me use in this way?
Short answer is no, Location.distanceTo(Location) does not take Location.getAccuracy() value into account when measuring distance.
Here's the actual code from the Android platform that is used to calculate distance for Location.distanceTo(Location):
https://github.com/android/platform_frameworks_base/blob/master/location/java/android/location/Location.java#L272
It uses Vincenty's Inverse Formula (http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf - Section 4) based on the given latitude and longitude (accuracy not considered).
As to whether your method of updating the "true" user location will be "precise enough", it really depends on GPS sensitivity, accuracy, and precision, which can vary significantly from device to device.
The accuracy estimate value from Location.getAccuracy() can also vary widely depending on the OEM, and typically devices I've seen overestimate accuracy (i.e., the device gives an accuracy value greater than the true accuracy) more than underestimate accuracy.
You might want to check out an app I created "GPS Benchmark" (http://www.gpsbenchmark.com/) which helps quickly benchmark location provider accuracy (GPS and Network) on Android devices, as well as "estimated accuracy" accuracy. I also co-authored a paper on this topic (http://journals.cambridge.org/repo_A82eaJIy) based on GPS benchmarking results from some Java ME devices, and most of the material is also relevant to Android.

Getting wrong location in LocationManager

I get totally wrong location when using the LocationManager with the Network provider. I get a Location out in the sea outside Africa, the accuracy is around 2000. My Google Maps is showing the accurate position.
Does anyone have a idea about what the problem can be? It is the same when I use the getLastKnownLocation().
The network location provider is extremely inaccurate. Usually if you are connected to WiFi, you can get within 100 meters, but on cell towers, 2000 meters is pretty normal. There's not really a problem, persay.
If Google Maps is able to get an accurate location with GPS turned off, then it is likely due to some very advanced location management that they do. But 2000 meters with Network Location, unfortunately, is normal in all of my test cases.
EDIT:
It is to say that the value of location.getAccuracy() is around 2000 (not a value in meters).
When getAccuracy() returns a value of 2000, it means meters. Here's what The Docs say about getAccuracy():
Returns the accuracy of the fix in meters. If hasAccuracy() is false, 0.0 is returned.
But it returns a float value, and while it doesn't display the unit, it is still meters.

Categories

Resources