LocationProvider - Detecting highly inaccurate/incorrect locations - android

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.

Related

FusedLocationProvider gives wrong location sometimes

I am using FusedLocationProviderClient to get location updates in a foreground service. On testing and observing for few days, I found wrong locations which was far away from my actual location by around 4 kms similar to this, but the LocationResult had an accuracy of 24 meters. How is this even possible?
It can be eliminated if the accuracy was around 4 kms. This behavior does not occur very often but occurs atleast once in 4 among 10 devices. It becomes a problem when I calculate distance traveled.
I can tell it's not a cached location because I used to turn off and on Location Services everyday. (As per docs, turning off Location Services clears cache location.)
Any idea why it's giving wrong location and how to eliminate it? And also clearing cache locations without turning off Location Services?
FusedLocationProvider CAN give incorrect results like that when gps connectivity for device is down(or insufficient satellites are in "view" to provide accurate data). It will use the nearest cell tower/location data provided by the wifi router(google tracks this automatically) giving WILDLY incorrect results in places where google doesn't have a strong location mapping presence - which is anywhere outside an urban center.
You have imho two options:
Use the non googleplay based solution based on location service - this has an option for ignoring non-gps location data(wifi/cellular).
LocationManager locationManager = (LocationManager)
getApplicationContext().getSystemService(LOCATION_SERVICE);
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_Provider);
You can even specify the number of satellites required for acceptable data so you can get REALLY accurate location data. You will lose information when the gps doesn't receive coordinates (like indoors), but in exchange will have less "noise" from incorrectly mapped location, as per your requirement.
Use a "snap to roads" API. There is a free version using open street map data called Project OSRM(Open Source Routing Machine) that provides a backend when hosted (locally or in cloud) using docker or building source yourself (details in link).
curl "http://127.0.0.1:5000/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true"
This request will return a location that is "snapped" to the nearest road. There are various options such as giving priority to highways etc. You can then discard the points that are not on the "path" that the user was previously on as rapidly shifting to a road 4km away and then coming back again is not likely.

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.

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

Android - how I can I achieve location accuracy in Google Map

I am self learning Android programming at the moment. I was about to write app that will display my location on map without using GPS.
I have tried using NETWORK_PROVIDER and found that my accuracy is constantly at 2000 even in city area with a lot of wifi around the area.
I would like to know how could other map application (e.g. GoogleMap) is able to achieve high accuracy without using GPS.
They use GPS. Or they lie about their accuracy. Ever seen the big blue circle around your position in Google Maps? That means they think you're somewhere in that circle, and are guessing about actual position.
The only way to get accuracy is to use GPS/GLONASS signals. A-GPS can help to fix position quickly because it provides info about which satellites are in view from your phone cell position (your device don't spend time trying to get signals from satellites not in view).
The 'High accuracy' mode is just a lie from Google to know your position all the time to monetize you in perverse ways
If you are using the network provider to fetch the location they are not very accurate. SO its not a good idea to fetch the accuracy of your position using
network provider. Its best to use GPS to get the location updates. You can use GetAccuracy() method of Location class and see for the value it returns.
Let Say if getAccuracy() retruns 25 then you can leave this value wait for another gps value which is more accurate.

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