From f3c5e73df186bc030ee585aa631e2841443cc433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Sat, 27 Sep 2025 15:29:01 +0200 Subject: [PATCH] =?UTF-8?q?erlaube=20Fehlende=20latitude/longitude=20f?= =?UTF-8?q?=C3=BCr=20History?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pomodules/po_stations.py | 13 +++---------- pomodules/po_stations_qgs.py | 9 +++++++-- 2 files changed, 10 insertions(+), 12 deletions(-) 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']