Deutsche Bahn Reisezentren dataset → SPOI data model

Deutsche Bahn Reisezentren: http://data.deutschebahn.com/dataset/data-reisezentren

SPOI: http://sdi4apps.eu/spoi



'; // click to start transformation -> reload page echo 'Start'; echo '
(this may take a while)

'; // should start the transformation? - get method if (IsSet($_GET['transform'])){ $status=$_GET['transform']; if($status == "start"){ transform(); } } // end of html document echo ' '; // download and transform data - main function transform(){ // download data // ----------------- CHANGE FILENAME ACCORDING TO A NEWEST AVAILABLE VERSION http://data.deutschebahn.com/dataset/data-reisezentren ------------------------------ file_put_contents("DB-Bahnhoefe.csv", fopen("http://download-data.deutschebahn.com/static/datasets/reisezentren/VSRz201609.csv", 'r')); // filesize of downloaded csv $filesize = filesize("VSRz201609.csv"); echo "Csv file size: ".format_size($filesize)."
"; // create rdf $soubor = fopen("Reisezentren.rdf", "w"); // write head of rdf fwrite($soubor, '\r\n"); fwrite($soubor, ''); fwrite($soubor, "\r\n"); $csv = fopen("VSRz201609.csv", "r"); $headCSV = true; // memory usage echo 'Memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB
"; while (($data = fgetcsv($csv, 1000, ";")) !== FALSE) { if($headCSV) { $headCSV = false; continue; } fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '.$data[1].''); fwrite($soubor, "\r\n"); $lat1 = substr($data[30], 0, 2); $lat2 = substr($data[30], 2); $lat = $lat1.'.'.$lat2; if(strlen($data[31])== 7){ $long1 = substr($data[31], 0, 1); $long2 = substr($data[31], 1); $long = $long1.'.'.$long2; } else{ $long1 = substr($data[31], 0, 2); $long2 = substr($data[31], 2); $long = $long1.'.'.$long2; } fwrite($soubor, ' POINT('.$long.' '.$lat.')'); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' SPOI (http://sdi4apps.eu/spoi)'); fwrite($soubor, "\r\n"); fwrite($soubor, ' '.$data[4].' '.$data[5].' '.$data[6].''); fwrite($soubor, "\r\n"); fwrite($soubor, ' '.$data[1].''); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); $date = getdate(); fwrite($soubor, ' '.$date['year']."-".$date['mon']."-".$date['mday'].''); fwrite($soubor, "\r\n"); fwrite($soubor, ' '); fwrite($soubor, "\r\n"); } fwrite($soubor, "
"); fclose($soubor); fclose($csv); // delete csv //unlink('VSRz201609.csv'); // link to download rdf echo 'Download RDF file'; // filesize of rdf $filesize = filesize("Reisezentren.rdf"); echo " (".format_size($filesize).")
"; } // filesize function function format_size($size) { $sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"); if ($size == 0) { return('n/a'); } else { return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]); } } ?>