Improved www.ttss.krakow.pl
Jacek Kowalski
2020-08-30 4bf9a457844e360187dc2b37bf164a3b3a58e73a
commit | author | age
ced309 1 <?php
JK 2 if(php_sapi_name() !== 'cli') die();
3
cbce8b 4 function fetchStops($url) {
JK 5     $json = file_get_contents($url);
6     $elements = json_decode($json, 1);
7     $stops = [];
8     foreach($elements['stops'] as $element) {
9         if($element['category'] == 'other') continue;
10         $stops[$element['shortName']] = $element['name'];
11     }
12     asort($stops);
13     return $stops;
ced309 14 }
JK 15
cbce8b 16 function printStops($stops, $prefix) {
JK 17     foreach($stops as $id => $stop) {
18         echo '  \''.$prefix.str_pad($id."'", 5, ' ', STR_PAD_RIGHT).' => '.var_export($stop, TRUE).','."\n";
19     }
20 }
21
22 $stops_tram = fetchStops('http://www.ttss.krakow.pl/internetservice/geoserviceDispatcher/services/stopinfo/stops?left=-648000000&bottom=-324000000&right=648000000&top=324000000');
23 $stops_bus = fetchStops('http://91.223.13.70/internetservice/geoserviceDispatcher/services/stopinfo/stops?left=-648000000&bottom=-324000000&right=648000000&top=324000000');
f7c4c3 24
JK 25 echo '<?php'."\n";
26 echo '$stops = array ('."\n";
cbce8b 27 printStops($stops_tram, 't');
JK 28 echo "\n";
29 printStops($stops_bus, 'b');
f7c4c3 30 echo ');'."\n";