43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
from . import poBaseURL
|
|
from .urlreader import UrlReader
|
|
|
|
|
|
class PoStations(UrlReader):
|
|
|
|
def __init__(self):
|
|
super().__init__(poBaseURL + 'stations.json')
|
|
|
|
def getStations(self):
|
|
print("getStations: Lade Stationen herunter...")
|
|
|
|
stations_json = self.getJsonResponse()
|
|
if stations_json is None or len(stations_json) == 0:
|
|
print("getStations: Keine Stationen erhalten")
|
|
return None
|
|
|
|
print("getStations: %d Stationen erhalten" % (len(stations_json),))
|
|
|
|
stations = []
|
|
for station_json in stations_json:
|
|
stations.append(
|
|
{
|
|
'geometry': {
|
|
'longitude': station_json['longitude'] if 'longitude' in station_json else None,
|
|
'latitude': station_json['latitude'] if 'latitude' in station_json else None,
|
|
},
|
|
'attributes': {
|
|
'uuid': station_json['uuid'],
|
|
'number': station_json['number'],
|
|
'shortname': station_json['shortname'],
|
|
'longname': station_json['longname'],
|
|
'km': station_json['km'] if 'km' in station_json else None,
|
|
'agency': station_json['agency'],
|
|
'water': station_json['water']['longname'],
|
|
},
|
|
}
|
|
)
|
|
|
|
print("getStations: %d Stationen erhalten" % (len(stations),))
|
|
|
|
return stations
|