Extend gpx import with custom data
This commit is contained in:
parent
8371df481d
commit
e082de4fa4
35
scripts/gpx_extensions1.xsd
Normal file
35
scripts/gpx_extensions1.xsd
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns="https://github.com/bfabiszewski/ulogger-android/1"
|
||||
targetNamespace="https://github.com/bfabiszewski/ulogger-android/1"
|
||||
elementFormDefault="qualified">
|
||||
|
||||
<xsd:element name="accuracy" type="xsd:decimal">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>Estimated horizontal accuracy of the location, radial, in meters (radius of 68% confidence).</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="speed" type="xsd:decimal">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>Speed in meters per second over ground.</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="bearing" type="degreesType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>Horizontal direction of travel of the device, in degrees.</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="provider" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>Name of the provider that generated this fix.</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:simpleType name="degreesType">
|
||||
<xsd:restriction base="xsd:decimal">
|
||||
<xsd:minInclusive value="0.0" />
|
||||
<xsd:maxExclusive value="360.0" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
</xsd:schema>
|
@ -98,11 +98,23 @@ foreach ($gpx->trk as $trk) {
|
||||
$position = new uPosition();
|
||||
foreach($trk->trkseg as $segment) {
|
||||
foreach($segment->trkpt as $point) {
|
||||
$time = isset($point->time) ? strtotime($point->time) : NULL;
|
||||
$altitude = isset($point->ele) ? $point->ele : NULL;
|
||||
$speed = NULL;
|
||||
$bearing = NULL;
|
||||
$accuracy = NULL;
|
||||
$provider = "gps";
|
||||
if (!empty($point->extensions)) {
|
||||
// parse ulogger extensions
|
||||
$ext = $point->extensions->children('ulogger', TRUE);
|
||||
if (isset($ext->speed)) { $speed = $ext->speed; }
|
||||
if (isset($ext->bearing)) { $bearing = $ext->bearing; }
|
||||
if (isset($ext->accuracy)) { $accuracy = $ext->accuracy; }
|
||||
if (isset($ext->provider)) { $provider = $ext->provider; }
|
||||
}
|
||||
$ret = $position->add($user->id, $trackId,
|
||||
(($point->time) ? strtotime($point->time) : NULL),
|
||||
$point["lat"], $point["lon"],
|
||||
(($point->ele) ? $point->ele : NULL),
|
||||
NULL, NULL, NULL, "gps", NULL, NULL);
|
||||
$time, $point["lat"], $point["lon"], $altitude,
|
||||
$speed, $bearing, $accuracy, $provider, NULL, NULL);
|
||||
if ($ret === false) {
|
||||
uUtils::exitWithError($lang["servererror"]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user