Import only extensions from ulogger namespace

This commit is contained in:
Bartek Fabiszewski 2017-08-01 19:41:48 +02:00
parent 4a4081cff1
commit 853c1ded66

View File

@ -99,7 +99,7 @@ foreach ($gpx->trk as $trk) {
foreach($trk->trkseg as $segment) { foreach($trk->trkseg as $segment) {
foreach($segment->trkpt as $point) { foreach($segment->trkpt as $point) {
$time = isset($point->time) ? strtotime($point->time) : NULL; $time = isset($point->time) ? strtotime($point->time) : NULL;
$altitude = isset($point->ele) ? $point->ele : NULL; $altitude = isset($point->ele) ? (double) $point->ele : NULL;
$speed = NULL; $speed = NULL;
$bearing = NULL; $bearing = NULL;
$accuracy = NULL; $accuracy = NULL;
@ -107,13 +107,13 @@ foreach ($gpx->trk as $trk) {
if (!empty($point->extensions)) { if (!empty($point->extensions)) {
// parse ulogger extensions // parse ulogger extensions
$ext = $point->extensions->children('ulogger', TRUE); $ext = $point->extensions->children('ulogger', TRUE);
if (isset($ext->speed)) { $speed = $ext->speed; } if (count($ext->speed)) { $speed = (double) $ext->speed; }
if (isset($ext->bearing)) { $bearing = $ext->bearing; } if (count($ext->bearing)) { $bearing = (double) $ext->bearing; }
if (isset($ext->accuracy)) { $accuracy = $ext->accuracy; } if (count($ext->accuracy)) { $accuracy = (int) $ext->accuracy; }
if (isset($ext->provider)) { $provider = $ext->provider; } if (count($ext->provider)) { $provider = (string) $ext->provider; }
} }
$ret = $position->add($user->id, $trackId, $ret = $position->add($user->id, $trackId,
$time, $point["lat"], $point["lon"], $altitude, $time, (double) $point["lat"], (double) $point["lon"], $altitude,
$speed, $bearing, $accuracy, $provider, NULL, NULL); $speed, $bearing, $accuracy, $provider, NULL, NULL);
if ($ret === false) { if ($ret === false) {
uUtils::exitWithError($lang["servererror"]); uUtils::exitWithError($lang["servererror"]);