Jumps in location on using fused location api - android

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

Related

FusedLocationProviderClient giving noisy location data

I have been using the FusedLocationProviderClient (FLP) and testing it's accuray.
I keep getting systematic erratic readings. I suspect it's location fixes provided by cell towers, but they are far too noisy. Does anyone else have this problem?
If so, how can it be fixed?
I'm not sure if I have to implement a filter outside of it, I don't necessarily want to, I believe the FLP is smarter than I, or at least the team of engineers who implemented it are.
Here is an image of data when I was stationary during the sampling period.
Update
So beyond adding high accuracy priority on the location request, I had to manually filter Location objects on their accuracy property location.getAccuracy(). Some locations like the ones in the picture above were around 1km away from true location and they would occur every so often adding a lot of noise to running calculations like distance travelled etc...

Fetch accurate intermediate Location points in background and calculate Distance of Starting and ending locations in Android

There may be similar questions regarding this topic,But I need your thoughts and suggestions on some specific requirement.
Here is my need -
We are developing one app which tracks User's trip.
The app will start collecting the location of that user in background,When user 'Starts' his trip from App.Background Service will be fetching locations on the basis of user's movement in specific time duration.
When User 'Stops' his trip from App,We are calculating distance traveled by user with help of all recorded locations(With Google Distance calculating API).
The App works fine in ideal case.
But main challenge is -
In some scenarios,We are not able to fetch exact and precise location of User. Scenarios affecting is - No internet,Data plan with 2g/3g,some specific areas where GPS is not returning accurate data etc.
Incorrect data of lat-long causes incorrect Trip distance and route.Which is main problem with the App.
Please,any one can suggest the best alternative/Suggestion for this?
P.S. - We have tried GPS,Network,FusedLocationProvider.
EDIT 2 --
We have implemented logic on basis of accuracy and distances.Got nearer points. And just came across one useful api from Google that corrects some location points which are distracted from actual Roads. Posting here for reference of others...
Snap to Roads Api from Google
this is a complicated topic.
One consideration you have to take. Android Oreo limits background services and that what you want to achieve won't work.
I would do is this (and it is the recommendation from Google)
When someone starts the trip (the user is aware of it), you must launch a on going notification with a foreground service , don't rely on background services anymore. Check the feature "Start Activity" in Google Fit App.
As for not having signal, or accurate GPS, well... it is a geographical problem!, there is nothing you could do. Or, maybe you can, using the LocationProvider.
FusedLocationProvider is fused within every app that requests locations updates.
Read this out, and see if that helps you.
https://developer.android.com/guide/topics/location/strategies.html
Try to mix GPS and Accelerometer
If you detect that GPS stopped working, turn on accelerometer. If GPS is turned on again, calculate distance again with it. This way you can have route with GPS parts and accelerometer ones. The bigger GPS parts, the more accurate data will be
How to get more accuracy by GPS_PROVIDER
Basically if the accuracy of a location isn't acceptable throw it away. The next one will be better.

LocationProvider - Detecting highly inaccurate/incorrect locations

So I know you can use getAccuracy() to find the accuracy of a location but if you set up a cut off for the accuracy, can you prevent recording down one of those locations where it's hugely off mark of where the user is? Like if the user is still, most location updates cluster around his area but occasionally the location provider will hiccup and report the location as somewhere miles away.
Do these locations simply appear as "accurate" with getAccuracy? Or would they turn up as some insanely high getAccuracy() result? Programming a cut off point is easy enough but I was wondering if I would have to code extra checks such as if a location is way too different from the previous ones then it's a wayward one.
Accuracy is not the only deciding factor here. You should also look at the age of the location, and the provider if you get it (the Google Play Services location doesn't tell you, but the original Android LocationManager does).
In fact, Google has some useful sample code for maintaining a current best estimate. I have used a variation of this to filter out wild jumps in incoming location data. Essentially a location is not even reported if it doesn't pass this gate.

GPS tracking within vehicle in android

I am in need to develop an android app where the device will track the distance traveled while the user is in a moving vehicle. I am getting the GPS values at small interval so that I can retrieve the distance and sum them up. But the problem I am facing is, while the user is in the vehicle, the device is not getting a clear view of the sky. Hence, the GPS device cannot get values as frequently as I desire. Thus, the result produced contains huge fluctuations. I tried using the network provider, but that is even worse in this scenario.
It would be very much helpful if anyone can suggest me a solution to this problem.
Just put the receiver onto the inner side of the windshield, like all navigation systems do. This should give an acuracy of about 3-6m. (when SBAS correction is available in your location) or up to 10m if not.
If the receiver is not state of the art (combined GPS + GLONASS or BEIDOU) then you will have problem in cities, especially in urban canyons with location jumps up to 30m.
This is normal. To get correct result for a GPS application within a city you need advanced algorithms. Just summing up the distance between two consecutive locations is to primitive, this never works well. Distance calculation by GPS has be answered some times her at SO. Use the search engine, to get more info at that topic.
Of course, set the device to GPS provider only, with maximum precision.

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.

Categories

Resources