3

I am using fused location provider with PRIORITY_HIGH_ACCURACY mode for location polling but sometimes it give wrong location speed like 77 m/s.Which is wrong so how can i achieve correct location speed?

Location Request:

        mLocationRequest = new LocationRequest();
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
        mLocationRequest.setInterval(6000);
        mLocationRequest.setSmallestDisplacement(80);

Get speed in Location Update

        Double lat = location.getLatitude();
        Double lon = location.getLongitude();
        float sd = (float) location.getAltitude();
//        float ac_speed = sd;
        //----- For Testing Purpose---------------//
        float ac_speed = location.getSpeed();
MIkka Marmik
  • 1,101
  • 11
  • 29
  • Some thoughts and ideas are found under [which is best way to calculate speed in android whether “manual calculation using GPS coordinates” or “location.getSpeed”?](https://stackoverflow.com/questions/21644990/which-is-best-way-to-calculate-speed-in-android-whether-manual-calculation-usin) and if those are individual erroneous values, you could calculate a median of the latest couple of speeds to filter out sudden spikes. Of course it would also introduce a small delay. Or if those locations have a bad `getAccuracy()` value you could simply ignore the speed for any "bad" locations. – Markus Kauppinen Nov 18 '16 at 15:04

1 Answers1

0

Maybe you are using network provider which provides less accuracy,hence change it to GPS provider to get accurate values.

Jayamurugan
  • 542
  • 2
  • 10
  • Already i mention that i am using fused location provider with high accuracy mode . – MIkka Marmik Nov 18 '16 at 14:50
  • Fused should handle that. Unfortunately, I could not find any solution yet. Note that GPS is not always a solution. Sometimes, WiFi is way more accurate (in a mall, for example, or when a device has flaky GPS receiver, LG G2 had that). Again, FUSED was born to handle that. It has its heuristics to *FUSE* the two locations together. I hope they fix it in the next versions of Google Play Services. – Meymann Mar 02 '17 at 15:52
  • 1
    @AlexS and I don't think anybody has plans to solve it. On GoogleMaps I have exited a tunnel and seen myself jumping 40km (feels like Dr. Who), maybe because some bus with a WiFi passed by. In my code, I have added a "trust" mechanism that forces GPS if it suspects Fused. It's not that great but better than hyper-warping my users. – Meymann Jun 28 '19 at 06:54