/** * Takes a JSON-LD station element and transforms it into the style of the old API */ private static function transformNewToOldStyle($newstation, $lang) { $station = new Station(); $id = str_replace("http://irail.be/stations/NMBS/", "", $newstation->{"@id"}); $station->id = "BE.NMBS." . $id; //old-style iRail ids $station->locationX = $newstation->longitude; $station->locationY = $newstation->latitude; $station->{"@id"} = $newstation->{"@id"}; if (isset($newstation->{"alternative"})) { foreach ($newstation->{"alternative"} as $alternatives) { if ($alternatives->{"@language"} == strtolower($lang)) { $station->name = $alternatives->{"@value"}; } } } $station->standardname = $newstation->name; if (!isset($station->name)) { $station->name = $station->standardname; } $station->setHID($id); return $station; }