erlaube Fehlende latitude/longitude für History

This commit is contained in:
Patrick Haßel 2025-09-27 15:29:01 +02:00
parent 4691e5b79f
commit f3c5e73df1
2 changed files with 10 additions and 12 deletions

View File

@ -19,25 +19,18 @@ class PoStations(UrlReader):
stations = [] stations = []
for station_json in stations_json: for station_json in stations_json:
if 'longitude' not in station_json or 'latitude' not in station_json:
print("getStations: WARN: Station hat fehlende Koordinaten: %s" % (station_json['longname'],))
continue
if 'km' not in station_json:
print("getStations: WARN: Station hat fehlende km: %s" % (station_json['longname'],))
continue
stations.append( stations.append(
{ {
'geometry': { 'geometry': {
'longitude': station_json['longitude'], 'longitude': station_json['longitude'] if 'longitude' in station_json else None,
'latitude': station_json['latitude'], 'latitude': station_json['latitude'] if 'latitude' in station_json else None,
}, },
'attributes': { 'attributes': {
'uuid': station_json['uuid'], 'uuid': station_json['uuid'],
'number': station_json['number'], 'number': station_json['number'],
'shortname': station_json['shortname'], 'shortname': station_json['shortname'],
'longname': station_json['longname'], 'longname': station_json['longname'],
'km': station_json['km'], 'km': station_json['km'] if 'km' in station_json else None,
'agency': station_json['agency'], 'agency': station_json['agency'],
'water': station_json['water']['longname'], 'water': station_json['water']['longname'],
}, },

View File

@ -33,12 +33,17 @@ class PoQgsStations(PoStations):
for station in stations: for station in stations:
feature = self._getFeatureForStation(station) feature = self._getFeatureForStation(station)
if feature is not None:
features.append(feature) features.append(feature)
print("getStationsFeatures: %d Features erzeugt" % (len(features),)) print("getStationsFeatures: %d Features erzeugt" % (len(features),))
return features return features
def _getFeatureForStation(self, station) -> QgsFeature: def _getFeatureForStation(self, station) -> None | QgsFeature:
if station['geometry']['longitude'] is None or station['geometry']['latitude'] is None:
print("_getFeatureForStation: WARN: Station hat fehlende Koordinaten: %s" % (station['attributes']['shortname'],))
return None
feature = QgsFeature(self.fields) feature = QgsFeature(self.fields)
longitude = station['geometry']['longitude'] longitude = station['geometry']['longitude']