Skip to content

Commit

Permalink
Location Issues fix FROM Path-Check#109 (Path-Check#127)
Browse files Browse the repository at this point in the history
* remove motiontracker requirement; adjust location params; backfill stationary points

* Remove Additional Stop Location Recording

Co-authored-by: Safe Path <safepath@dhcp-18-20-198-64.dyn.mit.edu>
  • Loading branch information
2 people authored and jgrainger-745 committed Apr 1, 2020
1 parent 63b26bf commit 00b920e
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions app/services/LocationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import PushNotification from "react-native-push-notification";

var instanceCount = 0;
var lastPointCount = 0;
var locationInterval = 60000 * 5; // Time (in milliseconds) between location information polls. E.g. 60000*5 = 5 minutes
// DEBUG: Reduce Time intervall for faster debugging
// var locationInterval = 5000;

function saveLocation(location) {
// Persist this location data in our local storage of time/lat/lon values
Expand Down Expand Up @@ -38,6 +41,15 @@ function saveLocation(location) {
}
}

// Backfill the stationary points, if available
if (curated.length >= 1) {
var lastLocationArray = curated[curated.length - 1];
var lastTS = lastLocationArray["time"];
for (; lastTS < unixtimeUTC - locationInterval; lastTS += locationInterval) {
curated.push(JSON.parse(JSON.stringify(lastLocationArray)));
}
}

// Save the location using the current lat-lon and the
// calculated UTC time (maybe a few milliseconds off from
// when the GPS data was collected, but that's unimportant
Expand Down Expand Up @@ -77,30 +89,23 @@ export default class LocationServices {
// PushNotificationIOS.requestPermissions();
BackgroundGeolocation.configure({
desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
stationaryRadius: 50,
distanceFilter: 50,
stationaryRadius: 5,
distanceFilter: 5,
notificationTitle: 'Private Kit Enabled',
notificationText: 'Private Kit is securely storing your GPS coordinates once every five minutes on this device.',
debug: false, // when true, it beeps every time a loc is read
startOnBoot: false,
startOnBoot: true,
stopOnTerminate: false,
locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER,
locationProvider: BackgroundGeolocation.DISTANCE_FILTER_PROVIDER,

// DEBUG: Use these to get a faster output
/*interval: 2000,
fastestInterval: 2000, // Time (in milliseconds) between location information polls. E.g. 60000*5 = 5 minutes
activitiesInterval: 2000,*/

interval: 20000,
fastestInterval: 60000 * 5, // Time (in milliseconds) between location information polls. E.g. 60000*5 = 5 minutes
activitiesInterval: 20000,
interval: locationInterval,
fastestInterval: locationInterval,
activitiesInterval: locationInterval,

activityType: "AutomotiveNavigation",
pauseLocationUpdates: false,
saveBatteryOnBackground: true,
stopOnStillActivity: false,
postTemplate: {
lat: '@latitude',
lon: '@longitude',
foo: 'bar' // you can also add your own properties
}
});

BackgroundGeolocation.on('location', (location) => {
Expand Down

0 comments on commit 00b920e

Please sign in to comment.