How to get more accuracy by GPS_PROVIDER

喜你入骨 提交于 2019-11-29 12:44:21

Consumer GPS receivers have an acuracy of 2.5-6m in 95% of cases, you cannot improve that for moving devices.

If you stand still (by user interaction that tells start of standstill, and end-of-standstill), you can calculate the average position.
Especially when standing still GPS chips have a bit less acuracy because the doppler shift can only be used while moving.

To caluclate the accuracy of your device you should take some measures, caluclate the average position, and calculate for each measure the distance to that average position. This then should give a value between 3-6m.

You wrote, that you expect 0m distance between two location while standing still.
But this does not work with GPS. Due fluctating conditions in the troposphere, the signal delay slightly vary, causing jumping position while standing still.

You only get 0m if you have enabled a stand still filter, which iOS uses by default. There should also a possibility in Android to enable such a filter (E.g by setting distance threshold to a value higher than 0).

In the OnLocation method check the location accuracy if it's not suitable the next call to OnLocation will generally be more accurate. More accuracy requires more work. You've seen the google map display a circle around the location and possibly watched it decrease in size. The radius of the circle is based on the location accuracy witch is a property of Location.

The below method works great. I have extensively tested it while driving, biking, walking the dog, and on the Harley. It filters out going in Mcd's and having the location come up in Texas where the Mcd's wifi provider is based and those pesky off by 100m locations.

@Override
public void onLocationChanged(Location location) {


    if (!location.hasAccuracy()) {
            return;
        }
        if (location.getAccuracy() > myDesiredAccuracy) {
            return;
        }

//blah what your app does...

    isCompleted=true;

    System.out.println("onLocationChanged 1");

      // Called when a new location is found by the GPS location provider.
      if(isBetterLocation(location, loc)){
        //  Toast.makeText(getBaseContext(), "yes", Toast.LENGTH_LONG).show();
          System.out.println("onLocationChanged 2");
          gotLocation(location);
      }
      System.out.println("onLocationChanged 3");
      clearListener();
      setUserPoint();
}

Note: Sometimes you get into a dead spot where you just can't get good GPS reception. These are caused by being inside a building, power lines, line of sight, cut freeways, unmapped wifi in buildings, other devices emitting radio signals that interfere with the GPS satellite reception. Basically anything that can interfere with radio reception can interfere with GPS.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!