--- a/stop.php
+++ b/stop.php
@@ -16,8 +16,9 @@
limitations under the License.
*/
include ('include/common.inc.php');
-if ($stopid)
+if (isset($stopid)) {
$stop = getStop($stopid);
+}
/* if ($stopcode != "" && $stop[5] != $stopcode) {
$url = $APIurl . "/json/stopcodesearch?q=" . $stopcode;
$stopsearch = json_decode(getPage($url));
@@ -85,7 +86,7 @@
echo '
';
+echo '';
echo $stopLinks;
if (sizeof($stops) > 0) {
trackEvent("View Stops", "View Combined Stops", $stop["stop_name"], $stop["stop_id"]);
@@ -102,7 +103,7 @@
timeSettings();
-echo '';
+echo '
';
echo '
';
if (sizeof($allStopsTrips) > 0) {
sktimesort($allStopsTrips, "arrival_time", true);
@@ -140,6 +141,30 @@
if (sizeof($trips) == 0) {
echo "- No trips in the near future.
";
} else {
+ if (isset($labs)) {
+// ETA calculation
+
+ $tripETA = Array();
+ // max/min delay instead of stddev?
+ $query = $query = "select 'lol', avg(timing_delta), stddev(timing_delta), count(*) from myway_timingdeltas where extract(hour from time) between ".date("H", $earlierTime)." and ".date("H", $laterTime);
+ //select 'lol', stop_id,extract(hour from time), avg(timing_delta), stddev(timing_delta), count(*) from myway_timingdeltas where stop_id = '5501' group by stop_id, extract(hour from time) order by extract(hour from time)
+ $query = $conn->prepare($query);
+ $query->execute();
+ if (!$query) {
+ databaseError($conn->errorInfo());
+ return Array();
+ }
+ $ETAparams = Array();
+ foreach ($query->fetchAll() as $row) {
+ $ETAparams[$row[0]] = Array("avg"=> $row[1], "stddev"=>floor($row[2]),"count"=>$row[3]);
+ };
+ //print_r($ETAparams);
+ foreach ($trips as $trip) {
+ $tripETA[$trip['trip_id']] = date("H:i",strtotime($trip['arrival_time']." - ".(floor($ETAparams['lol']['stddev']))." seconds"))." to ".
+ date("H:i",strtotime($trip['arrival_time']." + ".(floor($ETAparams['lol']['stddev']))." seconds"));
+ }
+ //print_r($tripETA);
+}
foreach ($trips as $trip) {
if (
isset($filterHasStop) && (getTripHasStop($trip['trip_id'], $filterHasStop) == 1)
@@ -151,6 +176,9 @@
$destination = getTripDestination($trip['trip_id']);
echo '' . $trip['route_short_name'] . " towards " . $destination['stop_name'] . "
";
$viaPoints = viaPointNames($trip['trip_id'], $trip['stop_sequence']);
+if (isset($labs)) {
+ echo '
ETA: ' . $tripETA[$trip['trip_id']] . '';
+ }
if ($viaPoints != "")
echo '
Via: ' . $viaPoints . '';
if (sizeof($tripStopNumbers) > 0) {
@@ -173,7 +201,7 @@
}
}
echo '
';
-echo '';
+echo '
';
include_footer();
?>