private function RouteDestination($data) { if ($data == "") { throw new Exception("Invalid Params passed", 02); } $sql = sprintf("SELECT * FROM tblJourneyDestination INNER JOIN tblLocation ON ( tblJourneyDestination.Location = tblLocation.Location ) WHERE UniqueJourneyIdentifier = '%s'", mysql_real_escape_string($data)); $results = DataHelper::LoadTableFromSql($sql); $resultJson = json_encode($results); $this->send_json_output($resultJson); exit; }
private function NearestStop($data) { list($lat, $long, $dist) = explode(',', $data, 3); if ($lat == "" || $long == "" || $dist == "") { throw new Exception("Invalid Params passed", 02); } list($lat, $long, $dist) = explode(',', $data, 3); if ($lat == "" || $long == "" || $dist == "") { throw new Exception("Invalid Params passed", 02); } $sql = sprintf("SELECT \n StopID, \n StopName, \n\t\t\tStopReference,\n (3963.191 * \n ACOS( \n ( \n SIN( \n PI( ) * '%1\$F' /180 \n ) * \n SIN( \n PI( ) * StopLat /180 \n ) \n ) + \n ( \n COS( \n PI( ) * '%1\$F' /180 \n ) * \n COS( \n PI( ) * StopLat /180 \n ) * \n COS( \n PI( ) * StopLong /180 - PI( ) * '%2\$F' /180 \n ) \n )\n ) )\n AS distance \n FROM tblStop \n WHERE \n (3963.191 * \n ACOS( \n ( \n SIN( \n PI( ) * '%1\$F' /180 \n ) * \n SIN( \n PI( ) * StopLat /180 \n ) \n ) + \n ( \n COS( \n PI( ) * '%1\$F' /180 \n ) * \n COS( \n PI( ) * StopLat /180 \n ) * \n COS( \n PI( ) * StopLong /180 - PI( ) * '%2\$F' /180 \n ) \n )\n )) < %3\$d ORDER BY distance LIMIT 0 , 30", mysql_real_escape_string($lat), mysql_real_escape_string($long), mysql_real_escape_string($dist)); $results = DataHelper::LoadTableFromSql($sql); $resultJson = json_encode($results); $this->send_json_output($resultJson); exit; }