cordova-background-geolocation-services icon indicating copy to clipboard operation
cordova-background-geolocation-services copied to clipboard

Coordinates retrieved from plugin are not always accurate.

Open Stepo45 opened this issue 9 years ago • 17 comments

Hello,

thx for your plugin. I have a problem with cofiguration, track isn't smooth, is there some recommended configuration for running or driving? The location updates data are very inaccurate.

My current config is:

desiredAccuracy: 0, distanceFilter: 0, interval: 9000, fastestInterval: 5000, useActivityDetection: true

Thx for your answer.

Stepo45 avatar Jun 14 '16 15:06 Stepo45

I don't have any control over which GPS points get sent back via the Native API's. GPS inaccuracies can be caused by a bunch of different things, including your location.

Can you elaborate on what you mean by "track isnt smooth".

What platform are you using (Android / iOS) ? What are the accuracy readings that you get back in the location passed back through the location update callback?

pmwisdom avatar Jun 14 '16 17:06 pmwisdom

Hi, below is a screenshot of my previous tracking. I think you see whats going on. (I was driving accross the "yellow" road (Hodoninska) towards the blue marker, and this is how my route got tracked. Tested on Android (on more devices with same, or similar unaccurate results).

Accuracy readings coming in a while.

screenshot_2016-06-14-19-32-54

Stepo45 avatar Jun 14 '16 17:06 Stepo45

If its device agnostic I'd like to say its probably that your hitting an area with bad GPS, but the accuracy readings will tell us if its the plugins problem or the GPS's problem.

pmwisdom avatar Jun 14 '16 17:06 pmwisdom

Accuracy: unfortunately, I didn't store accuracy in this tracking. But currently, while moving around the building, I'm getting various numbers from 5 to 95. Maybe I should give it a try once again, and make a few kilometer driving to check it. I'm in a location with standard GPS signal, other applications are tracking my movement well.

Stepo45 avatar Jun 14 '16 18:06 Stepo45

OK, I made a test drive around a block, which gave me a bit better (but still not accurate) results, and the accuracy was like 6 (average). The highest number I received was 109.43, lowest was 5.

Stepo45 avatar Jun 14 '16 18:06 Stepo45

The other applications your using might also be throwing away GPS positions with low accuracy (higher accuracy numbers mean less accurate). If you get coordinates back over 70 accuracy I would throw them away.

On android especially, the coordinates you get passed back are out of my hands, that is up to the device and android Location libraries, the configuration you have is the most accurate you can go on android.

The most important being :

desiredAccuracy: 0

Which translates to give me the most accurate results and put all the power you can into the GPS.

pmwisdom avatar Jun 14 '16 18:06 pmwisdom

Yes, that's good idea to throw the inaccurate coordinates away. I'll try this right away and post you the results.

Stepo45 avatar Jun 14 '16 18:06 Stepo45

OK, I was able to get better results, by some tweaking of result coordinates data set. I'm not displaying inaccurate results, and moreover, I'm checking the distance between two adjacent coordinates. If they're too far away, I will not display the second one. Haven't you thought about implementing "Location.distanceBetween()" inside the plugin? (you'll not send coordinate, which is too far away from the previous one).

Stepo45 avatar Jun 14 '16 19:06 Stepo45

I'm glad you were able to get better results!

There isn't really a reason to implement that in the native code since you can do so just as easily via JavaScript and everyone has different requirements from the plugin. I want to leave the plugin as open and broad as possible.

I would implement it if there was a good enough reason of why it couldn't / would be harder to do via JavaScript.

pmwisdom avatar Jun 14 '16 20:06 pmwisdom

Hi pmwisdom and Stepo45 , I have the same problem when tracking, specially with android. Stepo45 can you show how you are checking the distance between two adjacent coordinates? The program that I am developing is Cordova base and it should support all the functionality same for both iOS and Android. With iOS sometimes is it good and sometimes it is not working good. I have attached the same track with different result on iOS. here is my configure: desiredAccuracy: 0, distanceFilter: 3, debug: true, interval: 1000, fastestInterval: 1000, useActivityDetection: true

sample2

sepideh68 avatar Jun 14 '16 20:06 sepideh68

@sepideh68 Its very simple. You can use the formula in this stack overflow.

http://stackoverflow.com/questions/27928/calculate-distance-between-two-latitude-longitude-points-haversine-formula

pmwisdom avatar Jun 15 '16 00:06 pmwisdom

@pmwisdom I am receiving almost accurate coordinates on iOS but it is not working on android. Is it because of config I am using?! If so why it is working good on iOS?! I am developing my app with ionic. here is the code I have put on ionic.Platform.ready function:

 ionic.Platform.ready(function(){
 cordova.plugins.backgroundMode.enable();
cordova.plugins.backgroundMode.onactivate = function () {
bgLocationServices.start();
$scope.isBackground = true;
           }
     cordova.plugins.backgroundMode.ondeactivate = function () {
    bgLocationServices.stop();  
    $scope.isBackground = false;
            }
    navigator.geolocation.getCurrentPosition(function(p){}); // it is required
    bgLocationServices =  window.plugins.backgroundLocationServices;

    //Congfigure Plugin
    bgLocationServices.configure({
               //Both
                 desiredAccuracy:      0, 
                 distanceFilter:       0, 
                 debug:                false, 
                 interval:             2000, 
                 fastestInterval:      1000, 
                 useActivityDetection: false,
                 notificationTitle: '', // customize the title of the notification
                 notificationText: '', //customize the text of the notification     
            });

    bgLocationServices.registerForLocationUpdates(function(location) {
        if($scope.started){
        var position = encapsulateLocation(location);
        showPosition2(position);
            }
      }

sepideh68 avatar Jun 20 '16 15:06 sepideh68

@sepideh68 Please fix your styling and be more specific. Show me some coordinates on android vs iOS.

Also why are you using the cordova backgroundMode plugin? It might be unwise to do so with this plugin since it starts another service in the background.

pmwisdom avatar Jun 20 '16 16:06 pmwisdom

@pmwisdom I am using cordova backgroundMode plugin to enable tracking when background is activate and user started the geolocation. Does it have conflict with your plugin?! BTW I want to collect Gyro and Accelerometer data even if user is on backgroundMode. Here is the result of same route:

randroid riphone

sepideh68 avatar Jun 20 '16 16:06 sepideh68

@sepideh68 My plugin has the effect of keeping your app alive for however long you are tracking with it, so you don't need the background mode plugin. I don't know if its causing conflict but I would remove it.

Also, try starting the background plugin before you transition to the background, and before the will resign callback.

pmwisdom avatar Jun 20 '16 17:06 pmwisdom

@pmwisdom Because ios does not compile the app when I add the plugin to work?

help me.. @sepideh68

srsarcasmo avatar Feb 15 '17 20:02 srsarcasmo

@srsarcasmo This is a completely unrelated issue. Please do not spam the other issues.

pmwisdom avatar Feb 15 '17 20:02 pmwisdom