diff options
Diffstat (limited to 'getpositions.php')
-rwxr-xr-x | getpositions.php | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/getpositions.php b/getpositions.php index 9a3acc1..578c5b5 100755 --- a/getpositions.php +++ b/getpositions.php @@ -2,6 +2,7 @@ /* phpTrackme * * Copyright(C) 2013 Bartek Fabiszewski (www.fabiszewski.net) + * Copyright(C) 2014 Mark Campbell-Smith (campbellsmith.me) * * This is free software; you can redistribute it and/or modify it under * the terms of the GNU Library General Public License as published by @@ -36,16 +37,16 @@ function haversine_distance($lat1, $lon1, $lat2, $lon2) { if ($userid) { if ($trackid) { // get all track data - $query = $mysqli->prepare("SELECT positions.ID,positions.Latitude,positions.Longitude,positions.Altitude,positions.Speed,positions.Angle,positions.DateOccurred,positions.Comments,users.username,trips.Name,trips.ID FROM positions LEFT JOIN users ON (positions.FK_Users_ID=users.ID) LEFT JOIN trips ON (positions.FK_Trips_ID=trips.ID) WHERE positions.FK_Users_ID=? AND positions.FK_Trips_ID=? ORDER BY positions.DateOccurred"); + $query = $mysqli->prepare("SELECT positions.ID,positions.Latitude,positions.Longitude,positions.Pace,positions.DateAdded,positions.TotalDistance,positions.TotalTime,positions.EventType,users.username,trips.Name,trips.ID FROM positions LEFT JOIN users ON (positions.FK_Users_ID=users.ID) LEFT JOIN trips ON (positions.FK_Trips_ID=trips.ID) WHERE positions.FK_Users_ID=? AND positions.FK_Trips_ID=? ORDER BY positions.DateAdded"); $query->bind_param('ii', $userid, $trackid); } else { // get data only for latest point - $query = $mysqli->prepare("SELECT positions.ID,positions.Latitude,positions.Longitude,positions.Altitude,positions.Speed,positions.Angle,positions.DateOccurred,positions.Comments,users.username,trips.Name,trips.ID FROM positions LEFT JOIN users ON (positions.FK_Users_ID=users.ID) LEFT JOIN trips ON (positions.FK_Trips_ID=trips.ID) WHERE positions.FK_Users_ID=? ORDER BY positions.DateOccurred DESC LIMIT 1"); + $query = $mysqli->prepare("SELECT positions.ID,positions.Latitude,positions.Longitude,positions.Pace,positions.DateAdded,positions.TotalDistance,positions.TotalTime,positions.EventType,users.username,trips.Name,trips.ID FROM positions LEFT JOIN users ON (positions.FK_Users_ID=users.ID) LEFT JOIN trips ON (positions.FK_Trips_ID=trips.ID) WHERE positions.FK_Users_ID=? ORDER BY positions.DateAdded DESC LIMIT 1"); $query->bind_param('i', $userid); } $query->execute(); - $query->bind_result($positionid,$latitude,$longitude,$altitude,$speed,$angle,$dateoccured,$comments,$username,$trackname,$trackid); + $query->bind_result($positionid,$latitude,$longitude,$pace,$dateadded,$totaldistance,$totaltime,$eventtype,$username,$trackname,$trackid); header("Content-type: text/xml"); $xml = new XMLWriter(); @@ -59,11 +60,12 @@ if ($userid) { $xml->writeAttribute("id", $positionid); $xml->writeElement("latitude", $latitude); $xml->writeElement("longitude", $longitude); - $xml->writeElement("altitude", ($altitude)?round($altitude):$altitude); - $xml->writeElement("speed", $speed); - $xml->writeElement("angle", $angle); - $xml->writeElement("dateoccured", $dateoccured); - $xml->writeElement("comments", $comments); + $xml->writeElement("pace", $pace); + $xml->writeElement("dateadded", $dateadded); + $xml->writeElement("TotalDistance", $totaldistance); + $xml->writeElement("TotalTime", $totaltime); + $xml->writeElement("EventType", $eventtype); + $xml->writeElement("username", $username); $xml->writeElement("trackid", $trackid); $xml->writeElement("trackname", $trackname); @@ -71,8 +73,8 @@ if ($userid) { $prev_latitude = $latitude; $prev_longitude = $longitude; $xml->writeElement("distance", round($distance)); - $seconds = (isset($prev_dateoccured))?(strtotime($dateoccured)-strtotime($prev_dateoccured)):0; - $prev_dateoccured = $dateoccured; + $seconds = (isset($prev_dateadded))?(strtotime($dateadded)-strtotime($prev_dateadded)):0; + $prev_dateadded = $dateadded; $xml->writeElement("seconds", $seconds); $xml->endElement(); } |