Cleanup.
This commit is contained in:
@ -56,33 +56,6 @@ class AbstractDatabase
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addLocation(
|
|
||||||
int $accuracy = null,
|
|
||||||
int $altitude = null,
|
|
||||||
int $battery_level = null,
|
|
||||||
int $heading = null,
|
|
||||||
string $description = null,
|
|
||||||
string $event = null,
|
|
||||||
float $latitude,
|
|
||||||
float $longitude,
|
|
||||||
int $radius = null,
|
|
||||||
string $trig = null,
|
|
||||||
string $tracker_id = null,
|
|
||||||
int $epoch,
|
|
||||||
int $vertical_accuracy = null,
|
|
||||||
int $velocity = null,
|
|
||||||
float $pressure = null,
|
|
||||||
string $connection = null,
|
|
||||||
string $topic = null,
|
|
||||||
int $place_id = null,
|
|
||||||
int $osm_id = null
|
|
||||||
): bool {
|
|
||||||
$sql = 'INSERT INTO ' . $this->prefix . 'locations (accuracy, altitude, battery_level, heading, description, event, latitude, longitude, radius, trig, tracker_id, epoch, vertical_accuracy, velocity, pressure, connection, topic, place_id, osm_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
|
||||||
$params = array($accuracy, $altitude, $battery_level, $heading, $description, $event, $latitude, $longitude, $radius, $trig, $tracker_id, $epoch, $vertical_accuracy, $velocity, $pressure, $connection, $topic, $place_id, $osm_id);
|
|
||||||
$result = $this->execute($sql, $params);
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMarkers(int $time_from, int $time_to, int $min_accuracy = 1000): array
|
public function getMarkers(int $time_from, int $time_to, int $min_accuracy = 1000): array
|
||||||
{
|
{
|
||||||
$sql = 'SELECT * FROM ' . $this->prefix . 'locations WHERE epoch >= ? AND epoch <= ? AND accuracy < ? AND altitude >=0 ORDER BY tracker_id, epoch ASC';
|
$sql = 'SELECT * FROM ' . $this->prefix . 'locations WHERE epoch >= ? AND epoch <= ? AND accuracy < ? AND altitude >=0 ORDER BY tracker_id, epoch ASC';
|
||||||
|
@ -11,6 +11,7 @@ use \pcrov\JsonReader\JsonReader;
|
|||||||
use \pcrov\JsonReader\InputStream\Stream;
|
use \pcrov\JsonReader\InputStream\Stream;
|
||||||
use \OwntracksRecorder\Database\MySql;
|
use \OwntracksRecorder\Database\MySql;
|
||||||
use \OwntracksRecorder\Database\SQLite;
|
use \OwntracksRecorder\Database\SQLite;
|
||||||
|
use \OwntracksRecorder\RecordType\Location;
|
||||||
|
|
||||||
$fs = filesize($INPUT_FILE);
|
$fs = filesize($INPUT_FILE);
|
||||||
$fp = fopen($INPUT_FILE, 'rb');
|
$fp = fopen($INPUT_FILE, 'rb');
|
||||||
@ -49,50 +50,19 @@ do {
|
|||||||
|
|
||||||
#print_r($data);
|
#print_r($data);
|
||||||
|
|
||||||
$accuracy = null;
|
$loc = new Location();
|
||||||
$altitude = null;
|
$loc->connection = 'i'; // i = imported
|
||||||
$battery_level = null;
|
|
||||||
$heading = null;
|
|
||||||
$description = null;
|
|
||||||
$event = null;
|
|
||||||
$latitude = null;
|
|
||||||
$longitude = null;
|
|
||||||
$radius = null;
|
|
||||||
$trig = null;
|
|
||||||
$tracker_id = null;
|
|
||||||
$epoch = null;
|
|
||||||
$vertical_accuracy = null;
|
|
||||||
$velocity = null;
|
|
||||||
$pressure = null;
|
|
||||||
$connection = 'i'; // i = imported
|
|
||||||
|
|
||||||
if (array_key_exists('accuracy', $data)) $accuracy = intval($data['accuracy']);
|
if (array_key_exists('accuracy', $data)) $loc->accuracy = intval($data['accuracy']);
|
||||||
if (array_key_exists('altitude', $data)) $altitude = intval($data['altitude']);
|
if (array_key_exists('altitude', $data)) $loc->altitude = intval($data['altitude']);
|
||||||
if (array_key_exists('heading', $data)) $heading = intval($data['heading']);
|
if (array_key_exists('heading', $data)) $loc->heading = intval($data['heading']);
|
||||||
$latitude = floatval($data['latitudeE7']) / 1e7;
|
$loc->latitude = floatval($data['latitudeE7']) / 1e7;
|
||||||
$longitude = floatval($data['longitudeE7']) / 1e7;
|
$loc->longitude = floatval($data['longitudeE7']) / 1e7;
|
||||||
$epoch = (int)floor(intval($data['timestampMs']) / 1000);
|
$loc->epoch = (int)floor(intval($data['timestampMs']) / 1000);
|
||||||
if (array_key_exists('verticalAccuracy', $data)) $vertical_accuracy = intval($data['verticalAccuracy']);
|
if (array_key_exists('verticalAccuracy', $data)) $loc->vertical_accuracy = intval($data['verticalAccuracy']);
|
||||||
if (array_key_exists('velocity', $data)) $velocity = intval(floatval($data['velocity'])*3.6); // metres per second to km/h
|
if (array_key_exists('velocity', $data)) $loc->velocity = intval(floatval($data['velocity'])*3.6); // metres per second to km/h
|
||||||
|
|
||||||
$sql->addLocation(
|
$sql->addRecord($loc);
|
||||||
$accuracy,
|
|
||||||
$altitude,
|
|
||||||
$battery_level,
|
|
||||||
$heading,
|
|
||||||
$description,
|
|
||||||
$event,
|
|
||||||
$latitude,
|
|
||||||
$longitude,
|
|
||||||
$radius,
|
|
||||||
$trig,
|
|
||||||
$TRACKER_ID,
|
|
||||||
$epoch,
|
|
||||||
$vertical_accuracy,
|
|
||||||
$velocity,
|
|
||||||
$pressure,
|
|
||||||
$connection
|
|
||||||
);
|
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
if ($i%2000 == 0) {
|
if ($i%2000 == 0) {
|
||||||
|
Reference in New Issue
Block a user