else { $startBuses=explode(",",getBusesForStopWithFrequency($startStop)); $endBuses=explode(",",getBusesForStopWithFrequency($endStop)); //print_r($startBuses); //print_r($endBuses); // for now pick the first entry as the bus number but we need to do some optimization on choosing the buses based on their frequency, the stop number etc //$arrCommonBuses=getCommonBuses($startBuses,$endBuses,$showOnlyIndirectRoutes); // print_r($arrCommonBuses); //echo getJunctionsForIndirectBuses($arrCommonBuses,$startStop,$endStop,$startDistance,$endDistance); $status= getJunctionsForIndirectBusesRevamp2($startStop,$endStop,$startBuses,$endBuses,$startDistance,$endDistance,$showOnlyIndirectRoutes); //echo "normal status".$status."<br/>"; // this should not be the case now but just for the sake of eror handling if($status=="404" || $status=="405") { //need to do it again with the majestic|hebbal|silkboard //echo "hhhh"; /* $strRoute='<Routes>'; $strRoute=$strRoute.'<Route>'; $strRoute=$strRoute.'<IsDirectRoute>N</IsDirectRoute>'; $strRoute=$strRoute.'<ErrorCode>40</ErrorCode>'; $strRoute=$strRoute.'</Route>'; $strRoute=$strRoute.'</Routes>'; echo $strRoute; */
function getBusRoutesForRendering($log, $startStop, $endStop, $startOffsetDistance, $endOffsetDistance, $showOnlyIndirectRoutes) { //go to the database //find the route information which is error code, depot name1,depot name2, indirect route, startdepotdistance, endDepotDistance,junction1, junction2 //routetype : direct or indirect //construct a route string and return to the caling function. //ifshowonlyINdirectBuses then find only the indirect route else try to find the direct first, if not then indirect //return the xml. $startBuses = explode(",", getBusesForStopWithFrequency($startStop)); $endBuses = explode(",", getBusesForStopWithFrequency($endStop)); //print_r($startBuses); //print_r($endBuses); // for now pick the first entry as the bus number but we need to do some optimization on choosing the buses based on their frequency, the stop number etc //$arrCommonBuses=getCommonBuses($startBuses,$endBuses,$showOnlyIndirectRoutes); // print_r($arrCommonBuses); //echo getJunctionsForIndirectBuses($arrCommonBuses,$startStop,$endStop,$startDistance,$endDistance); //I guess pass the log in this function also to print the log message $status = getJunctionsForIndirectBusesRevamp2($log, $startStop, $endStop, $startBuses, $endBuses, $startOffsetDistance, $endOffsetDistance, $showOnlyIndirectRoutes); if ($status == "404" || $status == "405") { $arrRows = array(); $arrDirectRows = array(); //I am assuming that for the given source and end there is only one type of depot error code. So it can be either 7,8,9,10 but not both //check the database for the error code and output $sql = "Select * from depotBusRoutes where SourceStartStop='" . $startStop . "' and DestinationEndStop='" . $endStop . "'"; $result = mysql_query($sql); $rowsnum = mysql_num_rows($result); if ($rowsnum == 0) { //check in the other database if the data is present over there $sqlDirect = "Select * from directDepotBusRoutes where StartStop='" . $startStop . "' and EndStop='" . $endStop . "'"; $resultDirect = mysql_query($sqlDirect); $rowsnumDirect = mysql_num_rows($resultDirect); if ($rowsnumDirect == 0) { return exceptionalCondition($startStop, $endStop); } else { //this will take care of 6,7,8 //echo "Total Routes".$rowsnum; for ($i = 0; $i < $rowsnumDirect; $i++) { $rowDirect = mysql_fetch_object($resultDirect); // print_r($row)."<br/>"; if ($rowDirect->DepotErrorCode == "411") { $strRoute = '<Routes>'; $strRoute = $strRoute . '<Route>'; $strRoute = $strRoute . '<IsDirectRoute>N</IsDirectRoute>'; $strRoute = $strRoute . '<ErrorCode>411</ErrorCode>'; $strRoute = $strRoute . '<StartStop>' . $startStop . '</StartStop>'; $strRoute = $strRoute . '<EndStop>' . $endStop . '</EndStop>'; $strRoute = $strRoute . '</Route>'; $strRoute = $strRoute . '</Routes>'; // $log->LogDebug("[".$mediaType."] The result status is 411 between ".$startStop." and ".$endStop); return $strRoute; } else { if ($rowDirect->DepotErrorCode == "6" || $rowDirect->DepotErrorCode == "7" || $rowDirect->DepotErrorCode == "8") { //$log->LogDebug("[".$mediaType."] The result status is ".$rowDirect->DepotErrorCode." between ".$startStop." and ".$endStop); array_push($arrDirectRows, $rowDirect); // print_r($arrDirectRows); } else { echo "something is really wrong 678"; } } } //add the print //this is the case which will come if somehow the errorcode1 is missed as it was happening before. the errorcode 6 is //same as errorcode 1 but these cases are normally getting missed out initially if ($arrDirectRows[0]->DepotErrorCode == "6") { //print_r($arrDirectRows); //basically this is a special case of 1. With the addition that it is not getting caught in the //revamp2 function $routeString = ''; $routeString .= "<Routes>"; for ($i = 0; $i < sizeof($arrDirectRows); $i++) { $routeString .= '<Route>'; $routeString .= '<IsDirectRoute>N</IsDirectRoute>'; $routeString .= "<ErrorCode>" . $arrDirectRows[$i]->DepotErrorCode . "</ErrorCode>"; $routeString .= "<RouteDetails>"; $routeString .= "<StartStop>" . $arrDirectRows[$i]->StartStop . "</StartStop>"; if ($arrDirectRows[$i]->DistanceBetweenDepotAndStartStop < 0.5) { $routeString .= "<StartBuses>WD</StartBuses>"; } else { $routeString .= "<StartBuses>" . $arrDirectRows[$i]->BusesBetweenStartStopAndDepot . "</StartBuses>"; } $routeString .= "<FirstJunction>" . $arrDirectRows[$i]->DepotNameString . "</FirstJunction>"; $routeString .= "<DistanceBetweenJunction>0</DistanceBetweenJunction>"; $routeString .= "<SecondJunction>" . $arrDirectRows[$i]->DepotNameString . "</SecondJunction>"; $routeString .= "<EndBuses>" . $arrDirectRows[$i]->BusesBetweenEndStopAndDepot . "</EndBuses>"; // list($depotName,$lat,$lon)=explode(":",$arrDirectRows[$i]->IndirectFirstJunction); // $distanceBetweenStartStopAndDepot=distanceBetweenStops($arrDirectRows[$i]->SourceStartStop,$depotName); // // $routeString.="<DistanceBetweenDepotAndStop>".$distanceBetweenStartStopAndDepot."</DistanceBetweenDepotAndStop>"; // if($distanceBetweenStartStopAndDepot<.5) // { // $routeString.="<BusesStartStopAndDepot>WD</BusesStartStopAndDepot>"; // } // else // { // $routeString.="<BusesStartStopAndDepot>".$arrDirectRows[0]->IndirectStartBuses."</BusesStartStopAndDepot>"; // } $routeString .= "<EndStop>" . $arrDirectRows[$i]->EndStop . "</EndStop>"; // $distanceBetweenEndStopAndDepot=distanceBetweenStops($arrDirectRows[0]->DestinationEndStop,$depotName); // if($distanceBetweenEndStopAndDepot<.5) // { // $routeString.="<BusesEndStopAndDepot>WD</BusesEndStopAndDepot>"; // } // else // { // $routeString.="<BusesEndStopAndDepot>".$arrDirectRows[0]->IndirectEndBuses."</BusesEndStopAndDepot>"; // } // $routeString.="<DistanceBetweenDepotAndStartStop>".$distanceBetweenStartStopAndDepot."</DistanceBetweenDepotAndStartStop>"; // $routeString.="<DistanceBetweenDepotAndEndStop>".$distanceBetweenEndStopAndDepot."</DistanceBetweenDepotAndEndStop>"; $totalRouteDistance = floatval($arrDirectRows[$i]->TotalRouteDistance) + $startOffsetDistance + $endOffsetDistance; $routeString .= "<TotalRouteDistance>" . $totalRouteDistance . "</TotalRouteDistance>"; $routeString .= "<UseDepot>1</UseDepot>"; $routeString .= "</RouteDetails>"; $routeString .= "</Route>"; } $routeString .= "</Routes>"; return $routeString; } else { if ($arrDirectRows[0]->DepotErrorCode == "7" || $arrDirectRows[0]->DepotErrorCode == "8") { $depotNameStringArray = explode(":", $arrDirectRows[0]->DepotNameString); $routeString = ''; //echo $routeString; $totalDistance = $startOffsetDistance + $endOffsetDistance + floatval($arrDirectRows[0]->TotalRouteDistance); $routeInfoString = "There is no direct or indirect bus available between " . $arrDirectRows[0]->StartStop . " and " . $arrDirectRows[0]->EndStop . " We have tried to find a route that takes you to a stop where you can find a bus to your destination. However you might have to travel little offroute to reach to the intermediate stop"; $routeString .= "<Routes>"; $routeString .= "<Route>"; $routeString .= "<IsDirectRoute>N</IsDirectRoute>"; $routeString .= "<DepotErrorCode>" . $arrDirectRows[0]->DepotErrorCode . "</DepotErrorCode>"; $routeString .= "<RouteInfo>" . $routeInfoString . "</RouteInfo>"; $routeString .= "<RouteDetails>"; $routeString .= "<StartStop>" . htmlentities($arrDirectRows[0]->StartStop) . "</StartStop>"; $routeString .= "<EndStop>" . htmlentities($arrDirectRows[0]->EndStop) . "</EndStop>"; $routeString .= "<Depot>" . $arrDirectRows[0]->DepotNameString . "</Depot>"; $routeString .= "<DepotBuses>" . getBusesForStopWithFrequency($depotNameStringArray[0]) . "</DepotBuses>"; $routeString .= "<BusesBetweenStartStopAndDepot>" . $arrDirectRows[0]->BusesBetweenStartStopAndDepot . "</BusesBetweenStartStopAndDepot>"; $routeString .= "<BusesBetweenEndStopAndDepot>" . $arrDirectRows[0]->BusesBetweenEndStopAndDepot . "</BusesBetweenEndStopAndDepot>"; $routeString .= "<DistanceBetweenDepotAndStartStop>" . $arrDirectRows[0]->DistanceBetweenDepotAndStartStop . "</DistanceBetweenDepotAndStartStop>"; $routeString .= "<DistanceBetweenDepotAndEndStop>" . $arrDirectRows[0]->DistanceBetweenDepotAndEndStop . "</DistanceBetweenDepotAndEndStop>"; $routeString .= "<TotalRouteDistance>" . $totalDistance . "</TotalRouteDistance>"; $routeString .= "<UseDepot>1</UseDepot>"; $routeString .= "</RouteDetails>"; $routeString .= "</Route>"; $routeString .= "</Routes>"; return $routeString; } } } } else { for ($i = 0; $i < $rowsnum; $i++) { $row = mysql_fetch_object($result); if ($row->DepotErrorCode == "411") { $strRoute = '<Routes>'; $strRoute = $strRoute . '<Route>'; $strRoute = $strRoute . '<IsDirectRoute>N</IsDirectRoute>'; $strRoute = $strRoute . '<ErrorCode>411</ErrorCode>'; $strRoute = $strRoute . '<StartStop>' . $startStop . '</StartStop>'; $strRoute = $strRoute . '<EndStop>' . $endStop . '</EndStop>'; $strRoute = $strRoute . '</Route>'; $strRoute = $strRoute . '</Routes>'; //$log->LogDebug("[".$mediaType."] The result status is 411 between ".$startStop." and ".$endStop); return $strRoute; } else { if ($row->DepotErrorCode == "10" || $row->DepotErrorCode == "9") { //$log->LogDebug("[".$mediaType."] The result status is ".$row->DepotErrorCode." between ".$startStop." and ".$endStop); array_push($arrRows, $row); } else { echo "something is really wrong 910"; } } } if ($arrRows[0]->DepotErrorCode == "10" || $arrRows[0]->DepotErrorCode == "9") { $routeString = ''; $routeString .= "<Routes>"; //$routeString.="<DepotErrorCode>".$arrRows[0]->DepotErrorCode."</DepotErrorCode>"; // $routeString.="<RouteInfo>There is no direct or indirect bus available between".$arrRows[0]->SourceStartStop." and ".$arrRows[0]->DestinationEndStop.". We have tried to find a route that takes you to a stop where you can find a bus to your destination. However you might have to travel little offroute to reach to the intermediate stop</RouteInfo>"; // $routeString.="<SourceStartStop>".$arrRows[0]->SourceStartStop."</SourceStartStop>"; // $routeString.="<DestinationEndStop>".$arrRows[0]->DestinationEndStop."</DestinationEndStop>"; // $routeString.="<DepotRouteDetails>"; // list($depotName,$lat,$lon,$buses)=explode(":",$arrRows[0]->DepotNameString); // $routeString.="<DepotName>".$depotName.":".$lat.":".$lon."</DepotName>"; // $routeString.="<BusesBetweenStopAndDepot>".$arrRows[0]->BusesBetweenStopAndDepot."</BusesBetweenStopAndDepot>"; // $routeString.="<DistanceBetweenDepotAndStop>".$arrRows[0]->DistanceBetweenDepotAndStop."</DistanceBetweenDepotAndStop>"; // $routeString.="<IndirectRoutes>"; for ($i = 0; $i < sizeof($arrRows); $i++) { $routeString .= "<Route>"; $routeString .= "<IsDirectRoute>N</IsDirectRoute>"; $routeString .= "<ErrorCode>" . $arrRows[0]->DepotErrorCode . "</ErrorCode>"; $routeString .= "<RouteInfo>There is no direct or indirect bus available between " . $arrRows[0]->SourceStartStop . " and " . $arrRows[0]->DestinationEndStop . ". We have tried to find a route that takes you to a stop where you can find a bus to your destination. However you might have to travel little offroute to reach to the intermediate stop</RouteInfo>"; $routeString .= "<RouteDetails>"; $routeString .= "<SourceStartStop>" . $arrRows[0]->SourceStartStop . "</SourceStartStop>"; $routeString .= "<DestinationEndStop>" . $arrRows[0]->DestinationEndStop . "</DestinationEndStop>"; //$routeString.="<DepotRouteDetails>"; list($depotName, $lat, $lon, $buses) = explode(":", $arrRows[0]->DepotNameString); $routeString .= "<DepotName>" . $depotName . ":" . $lat . ":" . $lon . "</DepotName>"; $routeString .= "<BusesBetweenStopAndDepot>" . $arrRows[0]->BusesBetweenStopAndDepot . "</BusesBetweenStopAndDepot>"; $routeString .= "<DistanceBetweenDepotAndStop>" . $arrRows[0]->DistanceBetweenDepotAndStop . "</DistanceBetweenDepotAndStop>"; $routeString .= "<IndirectRoutes>"; $routeString .= "<IndirectRouteErrorCode>" . $arrRows[$i]->IndirectRouteErrorCode . "</IndirectRouteErrorCode>"; $routeString .= "<StartStop>" . $arrRows[$i]->IndirectStartStop . "</StartStop>"; if ($arrRows[0]->DepotErrorCode == "10") { $routeString .= "<StartBuses>" . $arrRows[$i]->IndirectStartBuses . "</StartBuses>"; } else { $routeString .= "<StartBuses>" . $arrRows[$i]->IndirectEndBuses . "</StartBuses>"; } $routeString .= "<FirstJunction>" . $arrRows[$i]->IndirectFirstJunction . "</FirstJunction>"; $routeString .= "<DistanceBetweenJunction>" . $arrRows[$i]->IndirectDistanceBetweenJunction . "</DistanceBetweenJunction>"; $routeString .= "<SecondJunction>" . $arrRows[$i]->IndirectSecondJunction . "</SecondJunction>"; if ($arrRows[0]->DepotErrorCode == "10") { $routeString .= "<EndBuses>" . $arrRows[$i]->IndirectEndBuses . "</EndBuses>"; } else { $routeString .= "<EndBuses>" . $arrRows[$i]->IndirectStartBuses . "</EndBuses>"; } $routeString .= "<EndStop>" . $arrRows[$i]->IndirectEndStop . "</EndStop>"; $routeString .= "<TotalIndirectRouteDistance>" . $arrRows[$i]->IndirectTotalIndirectRouteDistance . "</TotalIndirectRouteDistance>"; $routeString .= "</IndirectRoutes>"; $routeString .= "<TotalRouteDistance>" . $arrRows[$i]->IndirectTotalRouteDistance . "</TotalRouteDistance>"; $routeString .= "<UseDepot>1</UseDepot>"; $routeString .= "</RouteDetails>"; $routeString .= "</Route>"; } //$routeString.="</IndirectRoutes>"; //$routeString.="</DepotRouteDetails>"; $routeString .= "</Routes>"; return $routeString; } } } return $status; }
function getData($startStop, $endStop, $startDistance, $endDistance) { //$showOnlyIndirectRoutes=$_GET['onlyIndirectRoutes']; // find out the buses that pass through these stops $checkString = findDistanceBetweenSourceDestination($startStop, $endStop); $arr = array(); $arr = explode(":", $checkString); //print_r($arr); if ($arr[4] < 0.7) { $strRoute = ''; $routeDetails = htmlentities($startStop) . ":" . $arr[0] . ":" . $arr[1] . ":" . htmlentities($endStop) . ":" . $arr[2] . ":" . $arr[3] . ":" . $arr[4]; //$st='sdsd'; $strRoute = '<Routes>'; $strRoute = $strRoute . '<Route>'; $strRoute = $strRoute . '<IsDirectRoute>N</IsDirectRoute>'; $strRoute = $strRoute . '<ErrorCode>5</ErrorCode>'; $strRoute = $strRoute . '<RouteDetails>' . $routeDetails . '</RouteDetails>'; $strRoute = $strRoute . '</Route>'; $strRoute = $strRoute . '</Routes>'; return $strRoute; //echo "The distance is walkable"; } else { $startBuses = explode(",", getBusesForStopWithFrequency($startStop)); $endBuses = explode(",", getBusesForStopWithFrequency($endStop)); //removed the use of the showdirect buses form the helper $status = getJunctionsForIndirectBusesRevamp2($startStop, $endStop, $startBuses, $endBuses, $startDistance, $endDistance, 0); //echo "normal status".$status."<br/>"; // this should not be the case now but just for the sake of eror handling if ($status == "404" || $status == "405") { list($endStopDepotName, $endStopDepotDistance) = explode(":", getDepotName($endStop)); list($startStopDepotName, $startStopDepotDistance) = explode(":", getDepotName($startStop)); $totalDistanceForCase1 = 10000; $totalDistanceForCase2 = 10000; if ($startStopDepotDistance < (double) 7) { //find direct bus between start stop and start depot + distance $startStopStartDepotCommonBuses = getBusesCommonBetweenTwoStops($startStop, $startStopDepotName); if (sizeof($startStopStartDepotCommonBuses) > 0) { $startStopStartDepotDistance = $startStopDepotDistance; $startDepotEndStopCommonBuses = getBusesCommonBetweenTwoStops($startStopDepotName, $endStop); //print_r($startDepotEndStopCommonBuses); //echo sizeof($startDepotEndStopCommonBuses); if (sizeof($startDepotEndStopCommonBuses) > 0) { $startDepotEndStopDistance = distanceBetweenStops($startStopDepotName, $endStop); $totalDistanceForCase1 = $startDistance + $startStopStartDepotDistance + $startDepotEndStopDistance + $endDistance; $routeInfoString = "There is no direct or indirect bus availalble between " . $startStop . " and " . $endStop . " We have tried to find a route that takes you to a stop where you can find a bus to your destination. However you might have to travel little offroute to reach to the intermediate stop"; $strRoute1 = '<Routes>'; $strRoute1 = $strRoute1 . '<Route>'; $strRoute1 = $strRoute1 . '<IsDirectRoute>N</IsDirectRoute>'; $strRoute1 = $strRoute1 . '<ErrorCode>7</ErrorCode>'; $strRoute1 = $strRoute1 . "<RouteInfo>" . $routeInfoString . "</RouteInfo>"; $routeDetail = "<StartStop>" . htmlentities($startStop) . "</StartStop>"; $routeDetail = $routeDetail . "<EndStop>" . htmlentities($endStop) . "</EndStop>"; $routeDetail = $routeDetail . "<Depot>" . htmlentities($startStopDepotName) . ":" . getLatitudeLongitude($startStopDepotName) . "</Depot>"; $routeDetail = $routeDetail . "<BusesStartStopAndDepot>" . implode(",", $startStopStartDepotCommonBuses) . "</BusesStartStopAndDepot>"; $routeDetail = $routeDetail . "<BusesEndStopAndDepot>" . implode(",", $startDepotEndStopCommonBuses) . "</BusesEndStopAndDepot>"; $routeDetail = $routeDetail . "<DistanceBetweenDepotAndStartStop>" . $startStopStartDepotDistance . "</DistanceBetweenDepotAndStartStop>"; $routeDetail = $routeDetail . "<DistanceBetweenDepotAndEndStop>" . $startDepotEndStopDistance . "</DistanceBetweenDepotAndEndStop>"; $routeDetail = $routeDetail . "<TotalRouteDistance>" . $totalDistanceForCase1 . "</TotalRouteDistance>"; $routeDetail = $routeDetail . "<UseDepot>1</UseDepot>"; $strRoute1 = $strRoute1 . '<RouteDetails>' . $routeDetail . '</RouteDetails>'; $strRoute1 = $strRoute1 . '</Route>'; $strRoute1 = $strRoute1 . '</Routes>'; // echo $strRoute1; } } } // check if the detour is from the endpoint side //2. possible to have startStop->EndDepot->endpoint using Bus1, Bus2 if ($endStopDepotDistance < (double) 7) { //echo "second case"; //find the direct bus between start stop and end depot +distance $startStopEndDepotCommonBuses = getBusesCommonBetweenTwoStops($startStop, $endStopDepotName); //print_r($startStopEndDepotCommonBuses); if (sizeof($startStopEndDepotCommonBuses) > 0) { //echo "first condifition"; $startStopEndDepotDistance = distanceBetweenStops($startStop, $endStopDepotName); $endDepotEndStopCommonBuses = getBusesCommonBetweenTwoStops($endStopDepotName, $endStop); if (sizeof($endDepotEndStopCommonBuses) > 0) { //find the direct bus between end depot and the end stop + distnace $endDepotEndStopDistance = $endStopDepotDistance; $totalDistanceForCase2 = $startDistance + $startStopEndDepotDistance + $endDepotEndStopDistance + $endDistance; $routeInfoString = "There is no direct or indirect bus availalble between " . $startStop . " and " . $endStop . ". We have tried to find a route that takes you to a stop where you can find a bus to your destination. However you might have to travel little offroute to reach to the intermediate stop"; $strRoute2 = '<Routes>'; $strRoute2 = $strRoute2 . '<Route>'; $strRoute2 = $strRoute2 . '<IsDirectRoute>N</IsDirectRoute>'; $strRoute2 = $strRoute2 . '<ErrorCode>8</ErrorCode>'; $strRoute1 = $strRoute1 . "<RouteInfo>" . $routeInfoString . "</RouteInfo>"; $routeDetail = "<StartStop>" . htmlentities($startStop) . "</StartStop>"; $routeDetail = $routeDetail . "<EndStop>" . htmlentities($endStop) . "</EndStop>"; $routeDetail = $routeDetail . "<Depot>" . htmlentities($endStopDepotName) . ":" . getLatitudeLongitude($endStopDepotName) . "</Depot>"; $routeDetail = $routeDetail . "<BusesStartStopAndDepot>" . implode(",", $startStopEndDepotCommonBuses) . "</BusesStartStopAndDepot>"; $routeDetail = $routeDetail . "<BusesEndStopAndDepot>" . implode(",", $endDepotEndStopCommonBuses) . "</BusesEndStopAndDepot>"; $routeDetail = $routeDetail . "<DistanceBetweenDepotAndStartStop>" . $startStopEndDepotDistance . "</DistanceBetweenDepotAndStartStop>"; $routeDetail = $routeDetail . "<DistanceBetweenDepotAndEndStop>" . $endDepotEndStopDistance . "</DistanceBetweenDepotAndEndStop>"; $routeDetail = $routeDetail . "<TotalRouteDistance>" . $totalDistanceForCase2 . "</TotalRouteDistance>"; $routeDetail = $routeDetail . "<UseDepot>1</UseDepot>"; $strRoute2 = $strRoute2 . '<RouteDetails>' . $routeDetail . '</RouteDetails>'; $strRoute2 = $strRoute2 . '</Route>'; $strRoute2 = $strRoute2 . '</Routes>'; // echo $strRoute2; } } } if ($totalDistanceForCase1 < 10000 && $totalDistanceForCase2 < 10000) { if ($totalDistanceForCase1 > $totalDistanceForCase2) { return $strRoute2; } else { return $strRoute1; } } else { if ($totalDistanceForCase1 == 10000 && $totalDistanceForCase2 == 10000) { if ($startStopDepotDistance < (double) 7 && $endStopDepotDistance < (double) 7) { //find the direct bus between start stop and end depot +distance $startStopStartDepotCommonBuses = getBusesCommonBetweenTwoStops($startStop, $startStopDepotName); //print_r($startStopStartDepotCommonBuses); $endDepotEndStopCommonBuses = getBusesCommonBetweenTwoStops($endStopDepotName, $endStop); //print_r($endDepotEndStopCommonBuses); if (sizeof($startStopStartDepotCommonBuses) > 0 && sizeof($endDepotEndStopCommonBuses) > 0) { //echo "hhh"; //get the buses between the two depots $busesForStartDepot = explode(",", getBusesForStopWithFrequency($startStopDepotName)); $busesForEndDepot = explode(",", getBusesForStopWithFrequency($endStopDepotName)); $startStopOffsetDistance = $startDistance; $endStopOffsetDistance = $endDistance; $startStopStartDepotCommonBusesString = implode(",", $startStopStartDepotCommonBuses); $endDepotEndStopCommonBusesString = implode(",", $endDepotEndStopCommonBuses); $interDepotStatus = getJunctionsForInterDepotTravel($startStop, $endStop, $startStopDepotName, $endStopDepotName, $busesForStartDepot, $busesForEndDepot, $startStopOffsetDistance, $endStopOffsetDistance, $startStopStartDepotCommonBusesString, $endDepotEndStopCommonBusesString, $startStopDepotDistance, $endStopDepotDistance, 0); //need to add the bus info between the startstop and depot+last depot and end point if ($interDepotStatus == "409" || $interDepotStatus == "410") { // buses not found between the depots using a single or no hop $strRoute = '<Routes>'; $strRoute = $strRoute . '<Route>'; $strRoute = $strRoute . '<IsDirectRoute>N</IsDirectRoute>'; $strRoute = $strRoute . '<ErrorCode>' . $interDepotStatus . '</ErrorCode>'; $strRoute = $strRoute . '</Route>'; $strRoute = $strRoute . '</Routes>'; return $strRoute; } else { $strRoute = $interDepotStatus; return $strRoute; } } } else { //the depots are too far away $strRoute = '<Routes>'; $strRoute = $strRoute . '<Route>'; $strRoute = $strRoute . '<IsDirectRoute>N</IsDirectRoute>'; $strRoute = $strRoute . '<ErrorCode>411</ErrorCode>'; $strRoute = $strRoute . '</Route>'; $strRoute = $strRoute . '</Routes>'; return $strRoute; } } } } else { return $status; } } //echo "<sample>hhhh</sample>"; }