--- a/tripPlanner.php +++ b/tripPlanner.php @@ -1,5 +1,5 @@ <?php -include ('common.inc.php'); +include ('include/common.inc.php'); include_header("Trip Planner", "tripPlanner", true, true, true); $from = (isset($_REQUEST['from']) ? filter_var($_REQUEST['from'], FILTER_SANITIZE_STRING) : "Brigalow"); $to = (isset($_REQUEST['to']) ? filter_var($_REQUEST['to'], FILTER_SANITIZE_STRING) : "Barry"); @@ -11,6 +11,7 @@ } function tripPlanForm($errorMessage = "") { + global $date, $time, $from, $to; echo "<font color=red>$errorMessage</font>"; echo '<form action="tripPlanner.php" method="post"> @@ -61,6 +62,7 @@ echo '<li>'; processLeg($legNumber, $leg); echo "</li>"; + flush(); @ob_flush(); } echo "</ul>"; } @@ -92,7 +94,17 @@ } echo "" . staticmap($walkStepMarkers, 0, "icong", false) . "<br>\n"; foreach ($leg->steps->walkSteps as $stepNumber => $step) { - echo "Walking step " . ($stepNumber + 1) . " $step->absoluteDirection / $step->relativeDirection on $step->streetName for " . floor($step->distance) . " meters<br>\n"; + echo "Walking step " . ($stepNumber + 1) . ": "; + if ($step->relativeDirection == "CONTINUE") { + echo "Continue, "; + } else if ($step->relativeDirection) echo "Turn ".ucwords(strtolower(str_replace("_"," ",$step->relativeDirection))).", "; + echo "Go ".ucwords(strtolower($step->absoluteDirection))." on "; + if (strpos($step->streetName,"from") !== false && strpos($step->streetName,"way") !== false) { + echo "footpath"; + } else { + echo $step->streetName; + } + echo " for " . floor($step->distance) . " meters<br>\n"; } } } @@ -101,8 +113,14 @@ $fromPlace = (startsWith($from, "-") ? $from : geocode($from, false)); if ($toPlace == "" || $fromPlace == "") { $errorMessage = ""; - if ($toPlace === "") $errorMessage.= urlencode($to) . " not found.<br>\n"; - if ($fromPlace === "") $errorMessage.= urlencode($from) . " not found.<br>\n"; + if ($toPlace === "") { + $errorMessage.= urlencode($to) . " not found.<br>\n"; + trackEvent("Trip Planner","Geocoder Failed", $to); + } + if ($fromPlace === "") { + $errorMessage.= urlencode($from) . " not found.<br>\n"; + trackEvent("Trip Planner","Geocoder Failed", $from); + } tripPlanForm($errorMessage); } else { @@ -116,9 +134,12 @@ curl_setopt($ch, CURLOPT_TIMEOUT, 5); $page = curl_exec($ch); if (curl_errno($ch)) { - tripPlanForm("Trip planner temporarily unavailable: " . curl_errno($ch) . " " . curl_error($ch)); - } + tripPlanForm("Trip planner temporarily unavailable: " . curl_errno($ch) . " " . curl_error($ch) .(isDebug() ? $url : "")); + trackEvent("Trip Planner","Trip Planner Failed", $url); + } else { + trackEvent("Trip Planner","Plan Trip From", $from); + trackEvent("Trip Planner","Plan Trip To", $to); $tripplan = json_decode($page); debug(print_r($triplan, true)); echo "<h1> From: {$tripplan->plan->from->name} To: {$tripplan->plan->to->name} </h1>";