Misc formatting fixes like only show iOS stuff on those devices, don't show letters on nearby when have no nearby stuff
[busui.git] / tripPlanner.php
blob:a/tripPlanner.php -> blob:b/tripPlanner.php
--- 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");
@@ -92,7 +92,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";
 		}
 	}
 }
@@ -116,8 +126,9 @@
 		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 : ""));
+		
+                }
 		else {
 			$tripplan = json_decode($page);
 			debug(print_r($triplan, true));