Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8286271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:41:28+00:00 2026-06-08T11:41:28+00:00

Writing a GPS logging application~ I’m finding the values returned by the getSpeed() method

  • 0

Writing a GPS logging application~

I’m finding the values returned by the getSpeed() method on Locations reported by LocationManager are massively unreliable. I’m using LocationManager.GPS_PROVIDER, filtering the Locations provided through onLocationChanged for best accuracy. Even at single digit accuracy levels the speed returned is generally ridiculously high. We’re talking up to 200 mp/h (yes I know it’s logged in metres/sec) when the phone is stationary.

I’m testing the same code base on two different model Android phones, running two different OS versions, and seeing the same issues so I expect this is a code issue.

What am I missing? I’ve tried averaging locations over a window of time, to no avail. Am I going to have to work out my own speed values based on distance travelled / time? This would be disappointing.

As you will see, I’m not doing anything special – a little filtering for accuracy, even after this both AverageSpeed and _bestLocation.getSpeed() are regularly unfeasibly high, even when accuracy of the location is good.

public void onLocationChanged(Location location) {
    if (location.getAccuracy() < 25f) {
        _recentLocations.add(location);

        if (_bestLocation == null || location.getAccuracy() <= _bestLocation.getAccuracy())
            _bestLocation = location;
    }

    if ((_bestLocation != null && _bestLocation.getAccuracy() < 10f && _recentLocations.size() >= 10)
            || _recentLocations.size() >= 25)
    {
        int Count = 0;
            float TotalSpeed = 0f;
            float AverageSpeed = 0f;
            for (int i = 0; i<_recentLocations.size(); i++) {
                if (_recentLocations.get(i).hasSpeed()) {
                    Count++;
                    TotalSpeed += _recentLocations.get(i).getSpeed();
                }
            }

        if (Count > 0)
                AverageSpeed = TotalSpeed / Count;
        }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:41:29+00:00Added an answer on June 8, 2026 at 11:41 am

    I have worked on GPS hardware for more than 7 years now. The accuracy reading is also not 100% accurate.
    Manufacturers state accuracy along with the system used for measuring it.
    CEP, RMS, 2DRMS, and R95 are some of the systems.
    Read this article for more information: http://en.wikipedia.org/wiki/Circular_error_probable

    The accuracy figure does not include outliers. For example, if stated accuracy 5 meters then readings taken in good signal conditions will have maximum error of 5 meters, 95% of the time. Nothing can be said about the remaining 5% readings or about readings taken in bad signal contions. Protection against these outliers is the special sauce that makes a good location based app stand out from the rest.

    Some things you can do are:

    1. Filter out insanely high speeds. Make use of altitude as hint for being in a airplane.
    2. Correlate information from motion sensors and see if they agree with
      GPS. Motion sensor signatures will be very different in steady state
      and in motion.
    3. The typical size of a GSM/3G cell is under a kilometer in urban
      areas and 5-10 kilometers in sparsely populated areas. If the
      vehicle is moving at high speed for some time and the cell tower
      information is still the same, you know something is wrong.
    4. Does the GPS fix read north one moment and south the next that too
      at a high speed? If yes, it is most likely a GPS error.
    5. Check the number of Satellites used in GPS calculation. 12 is outstanding, 9 is healthy, 5 or less is poor, 4 is bare minimum for lat,lon + altitude
      calculation, 3 is bare minimum for lat,lon calculation. Anything less than 3 is not a valid reading. You can be much more confident about the validity of data if number of satellites is high.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an application that logs status updates (GPS locations) from devices to
I'm writing an iPhone application that uses GPS data. My problem is that the
I'm writing a method that will return true if there's a GPS sensor present
I'm writing a Quicklook generator plugin for a GPS logging file format ( .fit
I'm currently writing an app in Android that works with the GPS. At the
Writing a .NET DLL how do I find Application.ProductName ? EDIT: Obviously, importing Windows.Forms
Writing my first C# application...never touched the language before and not much of a
Writing a client application that sends images to a server via a webservice. As
I am writing a application that needs to draw a route comprised of lots
My problem actually seems rather silly... I am writing an iPhone application that uses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.