Improve myway route reconciliation using direction headsigns
--- a/include/db/route-dao.inc.php
+++ b/include/db/route-dao.inc.php
@@ -45,8 +45,8 @@
function getRouteHeadsigns($routeID) {
global $conn;
- $query = "select distinct trip_headsign,direction_id from routes join trips on trips.route_id = routes.route_id
-join stop_times on stop_times.trip_id = trips.trip_id ";
+ $query = "select distinct stops.stop_name, trip_headsign,direction_id from routes join trips on trips.route_id = routes.route_id
+join stop_times on stop_times.trip_id = trips.trip_id join stops on stop_times.stop_id = stops.stop_id where trips.route_id = :routeID and stop_times.stop_sequence = 1";
debug($query, "database");
$query = $conn->prepare($query);
$query->bindParam(":routeID", $routeID);
--- a/myway/myway_timeliness_reconcile.php
+++ b/myway/myway_timeliness_reconcile.php
@@ -19,12 +19,16 @@
foreach ($_REQUEST as $key => $value) {
if (strstr($key, "route") && !strstr($value, "Select")) {
$myway_route = str_replace("route", "", $key);
- $route_id = $value;
- $query = "update myway_routes set route_id = :route_id where myway_route = :myway_route";
+ $vparts = explode("-",$value);
+ $route_short_name = $vparts[0];
+ $trip_headsign = $vparts[1];
+ $query = "update myway_routes set route_short_name = :route_short_name, trip_headsign = :trip_headsign where myway_route = :myway_route";
debug($query, "database");
$query = $conn->prepare($query);
$query->bindParam(":myway_route", $myway_route, PDO::PARAM_STR, 5);
- $query->bindParam(":route_id", $route_id, PDO::PARAM_STR, 42);
+
+ $query->bindParam(":route_short_name", $route_short_name, PDO::PARAM_STR, 42);
+ $query->bindParam(":trip_headsign", $trip_headsign, PDO::PARAM_STR, 42);
$query->execute();
die(print_r($conn->errorInfo(), true));
}
@@ -132,8 +136,8 @@
<option>Select a from/to pair...</option>';
foreach (getRoutesByShortName($searchRouteNo) as $routeResult) {
foreach(getRouteHeadsigns($routeResult['route_id']) as $headsign ) {
- echo "<option value=\"{$routeResult['route_short_name']}{$routeResult['route_long_name']}\">
- {$routeResult['route_short_name']}{$routeResult['route_long_name']} {$headsign['trip_headsign']}</option>\n";
+ echo "<option value=\"{$routeResult['route_short_name']}-{$headsign['trip_headsign']}\">
+ {$routeResult['route_short_name']}{$routeResult['route_long_name']} - {$headsign['trip_headsign']} {$headsign['direction_id']} @ {$headsign['stop_name']} </option>\n";
}
}