0 ? 'data-collapsed="true"' : "") . '>
0 ? 'data-collapsed="true"' : "") . '>
Option #' . ($itineraryNumber + 1) . ": " . floor($itinerary->duration / 60000) . " minutes (".formatTime($itinerary->startTime)." to ".formatTime($itinerary->endTime).")
";
echo "Walking time: " . floor($itinerary->walkTime / 60000) . " minutes (" . floor($itinerary->walkDistance) . " meters)
\n";
echo "Transit time: " . floor($itinerary->transitTime / 60000) . " minutes
\n";
echo "Waiting time: " . floor($itinerary->waitingTime / 60000) . " minutes
\n";
@@ -58,6 +62,7 @@
echo '
';
processLeg($legNumber, $leg);
echo "";
+ flush(); @ob_flush();
}
echo "";
}
@@ -89,7 +94,17 @@
}
echo "" . staticmap($walkStepMarkers, 0, "icong", false) . "
\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
\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
\n";
}
}
}
@@ -98,28 +113,17 @@
$fromPlace = (startsWith($from, "-") ? $from : geocode($from, false));
if ($toPlace == "" || $fromPlace == "") {
$errorMessage = "";
- if ($toPlace === "") $errorMessage.= urlencode($to) . " not found.
\n";
- if ($fromPlace === "") $errorMessage.= urlencode($from) . " not found.
\n";
+ if ($toPlace === "") {
+ $errorMessage.= urlencode($to) . " not found.
\n";
+ trackEvent("Trip Planner","Geocoder Failed", $to);
+ }
+ if ($fromPlace === "") {
+ $errorMessage.= urlencode($from) . " not found.
\n";
+ trackEvent("Trip Planner","Geocoder Failed", $from);
+ }
tripPlanForm($errorMessage);
}
else {
- if (isMetricsOn()) {
- // Create a new Instance of the tracker
- $owa = new owa_php();
- // Set the ID of the site being tracked
- $owa->setSiteId($owaSiteID);
- // Create a new event object
- $event = $owa->makeEvent();
- // Set the Event Type, in this case a "video_play"
- $event->setEventType('view_trip_plan');
- // Set a property
- $event->set('from', $from);
- $event->set('to', $to);
- $event->set('time', $time);
- $event->set('date', $date);
- // Track the event
- $owa->trackEvent($event);
- }
$url = $otpAPIurl . "ws/plan?date=" . urlencode($_REQUEST['date']) . "&time=" . urlencode($_REQUEST['time']) . "&mode=TRANSIT%2CWALK&optimize=QUICK&maxWalkDistance=840&wheelchair=false&toPlace=$toPlace&fromPlace=$fromPlace&intermediatePlaces=";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@@ -127,16 +131,19 @@
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Accept: application/json"
));
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$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 "
From: {$tripplan->plan->from->name} To: {$tripplan->plan->to->name}
";
- echo "
At: {$tripplan->plan->date}
";
+ echo "
At: ".formatTime($tripplan->plan->date)."
";
if (is_array($tripplan->plan->itineraries->itinerary)) {
echo '
';
foreach ($tripplan->plan->itineraries->itinerary as $itineraryNumber => $itinerary) {