5

Google provides the fused location provider API to obtain location co-ordinates. According to the documentation, the API internally polls location data from different providers (GPS, Wifi, Cellular networks) and provides the best location. But, in High Accuracy mode, I have collected the below information. In this test GPS is always ON.

Latitude: 12.8560136
Longitude: 80.1997696
User Activity: IN VEHICLE
Speed: 21.810165 mph
Altitude: -83.0 
Accuracy: 12.0 

When I see this point in map, the points are not in the road. They are slightly away from the road. Other points with the same accuracy are plotted in the road.When I full zoom and see, some of the points are slightly away from the traveled road path.

I want the accurate information. It points must be in the road path.

I have used the Fused Location API to get the location information.

mGoogleApiClient = new GoogleApiClient.Builder(mContext)
            .addApi(LocationServices.API).addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).build();

Share your suggestion. If I use the Location manager will it solve my problem. And also I need to consume less battery only. Fused API guarantees that it consumes only less power and more efficient.

And also Fused Location API has below issues,

  1. Not able to get the satellite count.
  2. Is always returning the FUSED provider. Not exactly gives which provider(GPS or Network) returns the Location information.
  3. Your never notified when both the provider is unavailable . It will not return any value when none of the provider is available. To check the provider availability we need to separately register with Location manager. which consumes more power.

Please help me on this. Thanks in advance.

M Vignesh
  • 1,586
  • 2
  • 18
  • 55
  • I do sat locks with a locationmager gpsstatus listener and locations with the fused provider. It works nicely. I have the code out there https://github.com/danny117/MapMover. I just put up a button when gps is disabled. http://stackoverflow.com/questions/24804652/gpsstatus-switch-between-gps-event-started-and-gps-event-stopped/24812401#24812401 – danny117 Jan 16 '15 at 19:56

2 Answers2

0

You won't beat the fused provider accuracy or power use with a straight up location provider.

The fused location provider reports speed as meters per second and accuracy in meters. The example point you have is accurate to 12 meters. A US lane is defined as 3.7m. With 12m of accuracy you could be off by 12/3.7=3.25 lanes in any direction. I can't say this enough. If you want accuracy you have to check the accuracy of the location.

How to get more accuracy by GPS_PROVIDER

LatLng and distance between returning incorrect values on newer phones

can't find the exact current location in android

Android Maps GPS outlier

Fused Location Provider unexpected behavior

Adjust your program to handle the accuracy of the point. For example assume the point is correct shade a circle around the point with a radius = the accuracy in the location.

Community
  • 1
  • 1
danny117
  • 5,581
  • 1
  • 26
  • 35
  • Actually I think this may be an issue with the FusedLocationAPI. When I am working with Loaction Manager API the same accuracy location data is plotted in the same road path. But when using Fused API is slightly away. – M Vignesh Feb 02 '15 at 07:50
  • You made two passes on the road or both at once? Me I just throw away anything that doesn't meet my criteria for accuracy another location that is more accurate eventually comes in. – danny117 Feb 02 '15 at 16:11
  • I am also defined my criteria for accuracy less than 50. Same path same time two days. First day have tested the fused api. Second day I have tested the Location Manager. – M Vignesh Feb 03 '15 at 05:30
  • I think you are wrong in saying you won't beat it's accuracy. I have conducted multiple tests into the accuracy of the `fused location provider` and the `android location provider` and can say that the `android location provider` gives more accurate results. – StuStirling Feb 22 '16 at 11:13
  • I have a zillion hours testing these while I was test driving cars. http://stackoverflow.com/questions/23889834/cant-find-the-exact-current-location-in-android/24063973#24063973 Accuracy you check the accuracy. – danny117 Feb 23 '16 at 15:37
0

Location data from GPS and other providers cannot be guaranteed to lie on the road. These sensors do not have the requisite mapping context to snap raw location signals to roads. To achieve this with raw data, you can use a snap to roads API. Mapping providers like Google Maps and OSM have ways to do this:

If you are looking for an end-to-end solution that gives you location data on the road, you can also try the HyperTrack SDK for Android, which collects and processes location data to improve its accuracy. (Disclaimer: I work at HyperTrack.)

Also, to answer your other question, FusedLocationProviderApi does not expose the satellite count and provider information. To get the provider info, you can set up a GpsStatus.Listener class. This can be used in parallel to the fused provider in your app to check if the device has a GPS fix. You can use the following code snippet to set this up:

public class GPSStatusListener implements GpsStatus.Listener {

    private LocationManager locationManager;
    private boolean gpsFix;

    public GPSStatusListener(LocationManager locationManager) {
        this.locationManager = locationManager;
    }

    @Override
    public void onGpsStatusChanged(int changeType) {
        if (locationManager != null) {
            try {
                GpsStatus status = locationManager.getGpsStatus(null);

                switch (changeType) {
                    case GpsStatus.GPS_EVENT_FIRST_FIX: // Received first fix
                        gpsFix = true;
                        break;

                    case GpsStatus.GPS_EVENT_SATELLITE_STATUS: // Check if satellites are in fix
                        for (GpsSatellite sat : status.getSatellites()) {
                            if (sat.usedInFix()) {
                                gpsFix = true;
                                break;
                            } else {
                                gpsFix = false;
                            }
                        }

                        break;

                    case GpsStatus.GPS_EVENT_STARTED: // GPS turned on
                        gpsFix = false;
                        break;

                    case GpsStatus.GPS_EVENT_STOPPED: // GPS turned off
                        gpsFix = false;
                        break;

                    default:
                        gpsFix = false;
                        return;
                }
            } catch (Exception e){
                // Handle exception
            }
        }
    }

    public String getProvider() {
        if (gpsFix) {
            return "gps";
        } else {
            return "non_gps";
        }
    }
}
arjunattam
  • 2,679
  • 18
  • 24