react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

motionChange event, location is not precise

Open iamdperez opened this issue 2 years ago • 4 comments

Your Environment

  • Plugin version: 4.12.1
  • Platform: iOS
  • OS version: 16
  • Device manufacturer / model:
  • React Native version (react-native -v): 0.68.2
  • Plugin config
BackgroundGeolocation.ready({
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
      distanceFilter: 30,
      stopTimeout: 5,
      debug: false,
      logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
      logMaxDays: 10,
      stopOnTerminate: false,
      startOnBoot: true,
      url: `${API_URL}`,
      showsBackgroundLocationIndicator: true,
      disableLocationAuthorizationAlert: true,
      maxDaysToPersist: 2,
      maxRecordsToPersist: 1500,
      heartbeatInterval: 60 * 20, // 20 mins 
      preventSuspend: true,
      foregroundService: true,
      disableElasticity: false,
      elasticityMultiplier: 5,
      stopOnStationary: false,
      disableMotionActivityUpdates: false,
      disableProviderChangeRecord: false,
      useSignificantChangesOnly: false,
      headers: {
        'x-app-secret': envVariables.APP_SECRET_HEADER,
      },
      locationAuthorizationRequest: 'Always',
    })

Expected Behavior

image (1) The red markers show you the motion change event when the devices stop moving and the green one when the devices start moving. Here I'm marking the precision/accuracy is fine (perfect actually).

Actual Behavior

image

As you can see the green markers are for the motion change event (when the device starts moving), but almost all the time those, are wrong based on the rest of the trace, we understand that it takes time to start tracking again after the devices stop completed for a while. Still, those locations are really far, and then they start monitoring fine with usual.

Steps to Reproduce

  1. Setup the project with the library
  2. Permission Allowed: - Access Fine location always - Motion Activity - Update in the background
  3. Just tracking the device

We know we can use the accuracy to filter those positions/locations const ingorePosition = location.coords.accuracy > x; But we don't want to lose those movement events. For now, we only have that issue with the motion event, the rest of the time the behavior of the library is perfect.

Any comments or suggestions we can do to improve this?

iamdperez avatar Jul 07 '23 15:07 iamdperez

It can and will happen that a periodic poor-accuracy location will be recorded, particularly when the device is indoors (GPS only work outdoors with a clear view of the satellites in space). It's up to you to filter these out as desired. See location.coords.accuracy.

christocracy avatar Jul 07 '23 15:07 christocracy

The plugin does its best to achieve the highest possible motionchange location by first sampling up to 5 locations before settling on the best possible. It's up to the laws of physics in the environment where the device is currently.

christocracy avatar Jul 07 '23 15:07 christocracy

Do you think it can be possible (not now maybe in future updates) to set in the configuration something like: maximumAccuracyBeforeSendLocation: 100 100 mts, 500mts, etc... or a flag in the location object to determine if the location was taken using GPS, cellular, or wifi?

{
   "timestamp":     [Date],     
   "event":         [String],    
   "is_moving":     [Boolean], 
   "uuid":          [String],   
   "coords": {
       "latitude":  [Double],
       "longitude": [Double],
       "accuracy":  [Double],
       "speed":     [Double],
       "heading":   [Double],
       "altitude":  [Double]
       "ellipsoidal_altitude":  [Double]
   },
   "activity": {
       "type": [still|on_foot|walking|running|in_vehicle|on_bicycle],
       "confidence": [0-100%]
   },
   "battery": {
       "level": [Double],
       "is_charging": [Boolean]
   },
   "odometer": [Double/meters]
   "source": "GPS",  //// <===== WIFI, CELULLAR, GPS
}

@christocracy

iamdperez avatar Jul 07 '23 15:07 iamdperez

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar May 17 '24 01:05 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 31 '24 01:05 github-actions[bot]