Add support for storing topic (sent by iOS app).
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
@ -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');
|
||||
|
@ -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
|
||||
|
@ -19,6 +19,7 @@ CREATE TABLE "locations" (
|
||||
"velocity" INTEGER,
|
||||
"pressure" REAL,
|
||||
"connection" TEXT,
|
||||
"topic" TEXT,
|
||||
"place_id" INTEGER,
|
||||
"osm_id" INTEGER,
|
||||
"display_name" TEXT
|
||||
|
Reference in New Issue
Block a user