--- a/trip.php +++ b/trip.php @@ -1,93 +1,162 @@ '; +echo 'View Original Timetable/Map'; +echo '
' . $stopsGrouped['startTime'] . ' to ' . $stopsGrouped['endTime']; - echo '
'; - if (isset($_SESSION['lat']) && isset($_SESSION['lon'])) { - echo '' . distance($stop['stop_lat'],$stop['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away'; - } - echo bracketsMeanNewLine($tripStopTime["stop_name"]); - echo '' . $tripStopTime['arrival_time'] . '
'; - if (isset($_SESSION['lat']) && isset($_SESSION['lon'])) { - echo '' . distance($stop['stop_lat'],$stop['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away'; - } - echo bracketsMeanNewLine($tripStopTime['stop_name']); - echo ''; - flush(); @ob_flush(); - } - } - else { - // this is a duplicated line item - if ($key - 1 <= 0 || ($tripStopTimes[$key]['stop_name'] != $tripStopTimes[$key - 1]['stop_name'])) { - // first duplicate - $stopsGrouped = Array( - "name" => $tripStopTime['stop_name'], - "startTime" => $tripStopTime['arrival_time'], - "stop_ids" => Array( - $tripStopTime['stop_id'] - ) - ); - } - else { - // subsequent duplicates - $stopsGrouped["stop_ids"][] = $tripStopTime['stop_id']; - $stopsGrouped["endTime"] = $tripStopTime['arrival_time']; - } - } + if (sizeof($stopsGrouped) > 0) { + // print and empty grouped stops + // subsequent duplicates + $stopsGrouped["stop_ids"][] = $tripStopTime['stop_id']; + $stopsGrouped["endTime"] = $tripStopTime['arrival_time']; + echo ''; + echo '' . $stopsGrouped['startTime'] . ' to ' . $stopsGrouped['endTime'];
+ if (isset($_SESSION['lat']) && isset($_SESSION['lon'])) {
+ echo '
' . distance($tripStopTime['stop_lat'], $tripStopTime['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away';
+ }
+ echo '
' . $tripStopTime['arrival_time'];
+ if (isset($_SESSION['lat']) && isset($_SESSION['lon'])) {
+ echo '
' . distance($tripStopTime['stop_lat'], $tripStopTime['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away';
+ }
+ echo '