calculating distance using GPS point cloud - android

I have an android application in which I am trying to caltulate the distance travelled using coordinates provided by the GPS. I am currently using the method which calculates the lenght of the arc between two points on the globe.
public void onLocationChanged(Location location)
{
Location loc= new Location("");
loc.setLatitude(prev_latitude);
loc.setLongitude(prev_longitude);
distance+=location.distanceTo(loc);
...
}
Also, once this is done, the prev_{latitude,longitude} are set to the current latitude/longitude.
The obtained distance of the arc is then added to the accumulated distance (last line of the code).
Now, this method works fine if the GPS reception is good enough and we have sufficient accuracy. As soon as the accuracy of the acquired coordinates becomes worse, the points start to deviate from the real location and all this error gets integrated into the total distance.
Is there a function in android or a separate java library that automatically filters the error and fits the right points/track to a set of raw GPS measurements and thus obtains an accurate estimate of the distance traveled?
How would one go about this problem if such a library does not exist?
See the picture below for reference. The method provided in Android and is being used now is shown by the blue line. It calculates distances separately between subsequent coordinates. Because of the error, the distance is not correct. The actual path is shown in red.

you asked two questions:
the answer to the first: No there is no built in filtering for bad GPS location, you have to do that yourself.
the 2)
filtering depens on the applications need: whether for vehicles only, or also for pedestrians.
depending on your app needs, you can development your own filtering algorithm.
For vehicles, a simple approach is to ignore all locations with a location.speed under some threshold. (GPS jumps at low speeds).
Further you may look at the location.gethoriconatlAccuracy and ignore the location if the minimum accuracy threshold (which you define) is not reached.

Related

is there some algorithm for save a finest route gps android

When we save coordinates gps in android , We know the gps is not precise
for example , Here the blue point is the real coordinates, the red points is the gps gets in several attempts
this is (not a real ) route, after we drawn the lines if you have (driven/walking/moved)
this is (other fake ) route which is much more fine,
is there some algorithm/code for get this result ?
As you said - you will get different readings even if the GPS is static, due to GPS errors, but that's not the whole story: When you move relatively slow, you're also getting those erros. There are few things you can do about it:
Filter out "bad" readings - when you get a location from the GPS, you also get the location's accuracy. Decide a threshold, say 20m and ignore any readings with worse accuracy.
Filter out close readings - If the distance between the current location and the previous location is smaller than some threshold (I'd suggest 10 - 20m) - ignore the current location and wait for the next one.
You can also use your device's sensors (like the accelerometer) to decide if your device is moving or not. You can see a code example here.

Jumps in location on using fused location api

I am tracking rider's location(bike rider) and calculating total distance travelled per session by him. I have used fused location api only (no GPS). There are times when I am getting jumps in location and due to these jumps extra distance is added,hence results in overall wrong distance. Please help me in finding these wrong latitude and longitudes. Is there any good filter which can be easily implemented in Android or any good method for the same?
Distance measurement on raw GPS data will always be noisy, because the underlying data is often inaccurate. These jumps are due to inaccurate location measurements. To achieve, accurate distance measurements, you can need to filter the noise in the data.
Some useful filtering techniques that you can explore are:
Smoothening location data using Kalman filters - see tutorial
Snapping to road with Google maps snap-to-roads API, or OSRM match service.
If you are looking for an end-to-end solution that gives accurate location data and distance measurements, you can also try the HyperTrack SDK for Android or iOS. You can read about how they filter locations to improve accuracy on their blog. (Disclaimer: I work at HyperTrack.)
Location isn't exact. Even with GPS it isn't. Fused location can be off by hundreds of meters. If you're standing still every few minutes you'll get one reading that's just really off. Sometimes I walk from my kitchen to the bathroom and it thinks I've gone a quarter mile. If you look at the accuracy it returns, remember that there's a 2/3 chance you're within that distance. There's still a 33% chance that you're nowhere within that radius.
You're going to have to accept inaccuracy. There are a few ideas you can do though
1)Ignore all updates unless they travel at least some minimum distance. Adding in all those little amounts will add a lot of inaccuracy quickly.
2)Require at least 2 updates near a new location before accepting that as the new location.
But if you're using network location for short movements- you're going to have a difficult time of it.
Go to Settings -> Location -> Mode.
And make sure the mode is set to Device only.
This will stops the jump

How to Get latitude & longitude when get turn in Android

I work on application of distance calculator in which I want to calculate total distance traveled. I got some tutorial in which location get periodically. I know how to get location periodically but I want take location(i.e latitude & longitude) when user get turn while traveling.
So I want to know how to user got turn with device so that location should get acquire.For simplicity see the following image in which I want get location of point A,B,C,D,E,F,G,H,I.
Any Further suggestion for distance calculation will appreciate.Thank You.
You can retrieve new location coordinates in a pretty fast rate (for example every second). So use the getBearing()-method every second and then I think you will be able to get every turn if you do a constant comparison with the previous values!
You could also try to calculate a mean bearing-value for the last couple measurements so that you do not exceed your threshold so quickly and identify many corners that you do not want to identify... (these false positives depend on the quality of the GPS and also for example on the environment, because GPS is easily influenced by buildings etc.)
For calculating the distance, it's not necessary to specifically detect turns in the user's way. With LocationManager you can get locations e.g. every seconds. Just sum up the distances between those locations and you're done.
It makes no difference to the distance if you've only position E and F or if you've got 3 extra locations under way.
It may happen that you miss the exact corner, but the LocationManager can provide locations pretty fast, so that's no big problem and the GPS positioning isn't that exact anyway.
Calculating the distance between two Locations
To calculate the distance between two Location objects, use Location.distanceTo() which will give you the distance in meters.

How to track distance via GPS on Android?

How would I go about tracking the distance a user travels? I don't necessarily care about storing waypoints, although that may be necessary to calculate distance anyway.
So far, I am creating a LocationManager and regsitering an onLocationChanged listener, and then calculating the raw distance between two points when the listener fires.
The problem here is that if I leave the app sit still on a desk for 10, 15 minutes, it will say I have traveled .5 miles. How should I go about checking for accuracy and determining which points to use?
Or, even better - is there an SDK or .jar I can just include in my project and call their functions to make this whole thing easier?
Thank you for your time.
I am not an Android programmer but have implemented this functionality in my own embedded processor with far less processing capability than anything that runs Andriod.
This is nothing to do with the accuracy of a fix as determined by the GPS. If you have a stationary GPS receiver with "perfect" visibility of the sky and plot its reported position over time then you will see it wander around the true location, moving some metres an any direction. If you accumulate the distance travelled, in very small steps, around the true position you will end up with the distance travelled apparently taking you to the moon and back.
You need to set a movement threshold that is greater than the position accuracy of your GPS fix, and then only add in the distance travelled when you are sure that you have moved from the point at which you added in the last movement step.
You can call getAccuracy() on the Location object it gives you to check the accuracy. If your app needs to be real accurate, you can only count values with a high accuracy.
You can also call getProviders() on the LocationManager to check to see if you're getting coordinates from wifi, gps, or both, and ask the user to use their gps if it's not currently turned on so that you get more accurate points.

how to get the most accurate location using GPS and AGPS with given time in android?

I have a below requirement.
Find location of user from GPS and AGPS. (we are going to use Samsung Galaxy ACE mobile phone)
Note: For every transaction first location will be the reference location for the next activities.
Below are the constraint which has to be considered while solving this problem.
user should be within 10meter range of the reference location. meaning (Reference location - current location) <= 10meter (distance calculation by Locaiton class API).
Location has to found in the given period of time.
let say 20-25sec for finding each locaiton. the time can be extended to max 35sec.
My user is always be outside of the Shop while taking the reference location and then inside for all the other activities.
What I am doing
find the reference location with accuracy of 30m with 25sec of time. store this in static variable.
find the location for next actiivty and calculate the difference. if difference >=10m tell user to perform that activity again.
My Queries
Is this possible with such fine accuracy in the distance with given Time and place?
How google calculate this distance?
Does google finds the location with such accuracy? or what is the accuracy of Google Map using GPS? for e.g. at given particular time and location given by the Google MAP by GPS how much it is accurate? like if i am standing near to my BANK then what is difference between co-ordinates on the google map on the server and the co-ordinate given by google map through GPS on mobile phone.
I have did enough experiment on this problem and finally came here for help.
i did the observation by doing variation in timing, place, accuracy. still need to find one final solution. as we have to answer the client whether it is possible or not?
The GPS can provide most accurate match but only outdoors. It is possible to achieve such accuracy but not guaranteed.
There are formulates for finding distance between two points on a sphere. However, for rough approximations euclidean distance can be tried.
The location and its accuracy depends on client side GPS. Google just reads it.

Categories

Resources