1
0

Add support for storing topic (sent by iOS app).

This commit is contained in:
2018-06-03 17:08:55 +02:00
parent 86257709bc
commit ed255663ec
4 changed files with 11 additions and 5 deletions

View File

@ -51,11 +51,12 @@ class AbstractDatabase
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, 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, $place_id, $osm_id);
$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;
}

View File

@ -46,6 +46,7 @@ if ($data['_type'] == 'location' || $_REQUEST['debug']) {
$velocity = null;
$pressure = null;
$connection = null;
$topic = null;
//http://owntracks.org/booklet/tech/json/
if (array_key_exists('acc', $data)) $accuracy = intval($data['acc']);
@ -64,7 +65,8 @@ if ($data['_type'] == 'location' || $_REQUEST['debug']) {
if (array_key_exists('vel', $data)) $velocity = intval($data['vel']);
if (array_key_exists('p', $data)) $pressure = floatval($data['p']);
if (array_key_exists('conn', $data)) $connection = strval($data['conn']);
if (array_key_exists('topic', $data)) $connection = strval($data['topic']);
//record only if same data found at same epoch / tracker_id
if (!$sql->isEpochExisting($tracker_id, $epoch)) {
@ -84,9 +86,10 @@ if ($data['_type'] == 'location' || $_REQUEST['debug']) {
$vertical_accuracy,
$velocity,
$pressure,
$connection
$connection,
$topic
);
if ($result) {
http_response_code(200);
_log('Insert OK');

View File

@ -17,6 +17,7 @@ CREATE TABLE `locations` (
`velocity` int(11) DEFAULT NULL,
`pressure` decimal(9,6) DEFAULT NULL,
`connection` varchar(1) DEFAULT NULL,
`topic` varchar(255) DEFAULT NULL,
`place_id` int(11) DEFAULT NULL,
`osm_id` int(11) DEFAULT NULL,
`display_name` text

View File

@ -19,6 +19,7 @@ CREATE TABLE "locations" (
"velocity" INTEGER,
"pressure" REAL,
"connection" TEXT,
"topic" TEXT,
"place_id" INTEGER,
"osm_id" INTEGER,
"display_name" TEXT