Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location Issues fix FROM #109 #127

Merged
merged 4 commits into from
Mar 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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