diff --git a/pomodules/po_stations.py b/pomodules/po_stations.py index 32fe3d9..d1009bc 100644 --- a/pomodules/po_stations.py +++ b/pomodules/po_stations.py @@ -19,25 +19,18 @@ class PoStations(UrlReader): stations = [] 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( { 'geometry': { - 'longitude': station_json['longitude'], - 'latitude': station_json['latitude'], + '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'], + 'km': station_json['km'] if 'km' in station_json else None, 'agency': station_json['agency'], 'water': station_json['water']['longname'], }, diff --git a/pomodules/po_stations_qgs.py b/pomodules/po_stations_qgs.py index 8da8646..53d1759 100644 --- a/pomodules/po_stations_qgs.py +++ b/pomodules/po_stations_qgs.py @@ -33,12 +33,17 @@ class PoQgsStations(PoStations): for station in stations: feature = self._getFeatureForStation(station) - features.append(feature) + if feature is not None: + features.append(feature) print("getStationsFeatures: %d Features erzeugt" % (len(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) longitude = station['geometry']['longitude']