aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2023-09-29 00:29:27 +0200
committerGuilhem Moulin <guilhem@fripost.org>2023-09-29 00:39:24 +0200
commit9f17020f0d821fc8005f659f1dd49b5e08804431 (patch)
tree14996f6e0323b89165a20402af4e10106942ac34
parentfda794e9741df6a15969ca1335284f3426dd317b (diff)
Handle the case where no observations are found.
Artdatabanken returns an empty response in that case (Content-Length: 0), but we need a valid GeoJSON file without any features. Unfortunately QGIS appears unable to load such files though, due to the ‘|subset=’ filter which references unknown fields.
-rwxr-xr-xgis-observation-map5
1 files changed, 4 insertions, 1 deletions
diff --git a/gis-observation-map b/gis-observation-map
index 91abd1e..966d438 100755
--- a/gis-observation-map
+++ b/gis-observation-map
@@ -427,7 +427,10 @@ def getObservations(taxonLists, taxonRedlistCategories, searchFilter):
)
resp.raise_for_status()
- obs = resp.json()
+ if resp.text == '':
+ obs = { 'crs': 'EPSG:4326', 'type': 'FeatureCollection', 'features': [] }
+ else:
+ obs = resp.json()
# https://www.rfc-editor.org/rfc/rfc7946
if obs is None or type(obs) != dict or 'type' not in obs.keys():