private static function getStationFromHafasLocation($locationX, $locationY, $lang) { preg_match("/(.)(.*)/", $locationX, $m); $locationX = $m[1] . "." . $m[2]; preg_match("/(..)(.*)/", $locationY, $m); $locationY = $m[1] . "." . $m[2]; return stations::getStationFromLocation($locationX, $locationY, $lang); }
public static function getStationFromName($name, $lang) { //We can do a couple of things here: // * Match the name with something in the DB // * Give the name to hafas so that it returns us an ID which we can reuse - Doesn't work for external stations // * Do a hybrid mode // * match from location // * match railtime name //Let's go wih the hafas solution and get the location from it //fallback for wrong hafas information if (strtolower($name) == "brussels north" || strtolower($name) == "brussel noord" || strtolower($name) == "bruxelles nord") { return stations::getStationFromLocation(4.360854, 50.859658, $lang); } if (strtolower($name) == "vorst zuid") { return stations::getStationFromLocation(4.310025, 50.810158, $lang); } include "../includes/getUA.php"; $url = "http://hari.b-rail.be/Hafas/bin/extxml.exe"; $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent); $postdata = '<?xml version="1.0 encoding="iso-8859-1"?> <ReqC ver="1.1" prod="iRail API v1.0" lang="' . $lang . '"> <LocValReq id="stat1" maxNr="1"> <ReqLoc match="' . $name . '" type="ST"/> </LocValReq> </ReqC>'; $post = http_post_data($url, $postdata, $request_options) or die(""); $idbody = http_parse_message($post)->body; preg_match("/x=\"(.*?)\".*?y=\"(.*?)\"/si", $idbody, $matches); $x = $matches[1]; $y = $matches[2]; preg_match("/(.)(.*)/", $x, $m); $x = $m[1] . "." . $m[2]; preg_match("/(..)(.*)/", $y, $m); $y = $m[1] . "." . $m[2]; return stations::getStationFromLocation($x, $y, $lang); }