Browse Source

ignore points with a terrible accuracy

pull/5/head
Aaron Parecki 8 years ago
parent
commit
eca6cb13e3
2 changed files with 20 additions and 12 deletions
  1. +12
    -7
      compass/app/Http/Controllers/Api.php
  2. +8
    -5
      compass/app/Jobs/TripComplete.php

+ 12
- 7
compass/app/Http/Controllers/Api.php View File

@ -69,13 +69,18 @@ class Api extends BaseController
$events[] = $rec; $events[] = $rec;
} else { } else {
#$record->date->format('U.u'); #$record->date->format('U.u');
$locations[] = $record->data;
$props = $record->data->properties;
$date = $record->date;
$date->setTimeZone(new DateTimeZone($tz));
$props->timestamp = $date->format('c');
$props->unixtime = (int)$date->format('U');
$properties[] = $props;
// Ignore super inaccurate locations
if(!property_exists($record->data->properties, 'horizontal_accuracy')
|| $record->data->properties->horizontal_accuracy <= 5000) {
$locations[] = $record->data;
$props = $record->data->properties;
$date = $record->date;
$date->setTimeZone(new DateTimeZone($tz));
$props->timestamp = $date->format('c');
$props->unixtime = (int)$date->format('U');
$properties[] = $props;
}
} }
} }

+ 8
- 5
compass/app/Jobs/TripComplete.php View File

@ -46,11 +46,14 @@ class TripComplete extends Job implements SelfHandling, ShouldQueue
foreach($results as $id=>$record) { foreach($results as $id=>$record) {
// Don't include app action tracking data // Don't include app action tracking data
if(!property_exists($record->data->properties, 'action')) { if(!property_exists($record->data->properties, 'action')) {
$record->data->properties = array_filter((array)$record->data->properties, function($k){
// Remove some of the app-specific tracking keys from each record
return !in_array($k, ['locations_in_payload','desired_accuracy','significant_change','pauses','deferred']);
}, ARRAY_FILTER_USE_KEY);
$features[] = $record->data;
// Ignore locations with accuracy worse than 5000m
if(property_exists($record->data->properties, 'horizontal_accuracy') && $record->data->properties->horizontal_accuracy <= 5000) {
$record->data->properties = array_filter((array)$record->data->properties, function($k){
// Remove some of the app-specific tracking keys from each record
return !in_array($k, ['locations_in_payload','desired_accuracy','significant_change','pauses','deferred']);
}, ARRAY_FILTER_USE_KEY);
$features[] = $record->data;
}
} }
} }

Loading…
Cancel
Save