aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgis-observation-map37
1 files changed, 34 insertions, 3 deletions
diff --git a/gis-observation-map b/gis-observation-map
index 9c478c7..4fe06cf 100755
--- a/gis-observation-map
+++ b/gis-observation-map
@@ -21,6 +21,7 @@
import argparse
import sys
import json
+import re
import requests
import configparser
from requests.exceptions import HTTPError
@@ -380,7 +381,10 @@ def getTaxonLists():
if not i in taxonLists2[d0]:
raise Exception(f'missing taxon #{i} (in {d}) from {d0}')
- return taxonLists2
+ i = getTaxonList(taxonLists, taxonLists2, 'TaxonIsRedlisted', 'Redlisted species')
+ taxonRedlistCategories = getTaxonRedlistCategories(taxonLists, i)
+
+ return taxonLists2, taxonRedlistCategories
def getTaxonList(taxonLists, taxonLists2, key, name):
i = None
@@ -402,7 +406,34 @@ def getTaxonList(taxonLists, taxonLists2, key, name):
raise Exception(f'expected list, got {type(resp)}')
taxonLists2[key] = {r['id'] for r in resp}
-taxonLists = getTaxonLists()
+ return i
+
+def getTaxonRedlistCategories(taxonLists, i):
+ taxonRedlistCategories = {}
+ r = re.compile(r'\(([A-Z][A-Z])\)\Z')
+ for t in taxonLists:
+ if 'parentId' not in t.keys() or t['parentId'] != i:
+ continue
+ name = t['name']
+ c = r.search(name)
+ if not c:
+ raise Exception(f'invalid redlist name "{name}"')
+ c = c.group(1)
+
+ resp = requests.get(
+ artDataBankenURL + f'/species-observation-system/v1/TaxonLists/{t["id"]}/Taxa',
+ headers=artDataBankenHeaders
+ )
+ resp.raise_for_status()
+ resp = resp.json()
+ if type(resp) != list:
+ raise Exception(f'expected list, got {type(resp)}')
+ for t in resp:
+ j = t['id']
+ if j in taxonRedlistCategories.keys():
+ raise Exception(f'duplicate redlist classification for taxon #{j}')
+ taxonRedlistCategories[j] = c
+ return taxonRedlistCategories
geograficsFilter = {
'geometries': geometricFilter(geometries),
@@ -410,7 +441,7 @@ geograficsFilter = {
'considerObservationAccuracy': True,
'considerDisturbanceRadius': True
}
-print(json.dumps(geograficsFilter, indent=4))
+taxonLists, taxonRedlistCategories = getTaxonLists()
exit()
topo_maps = ['Topografi 10', 'Topografi 50', 'Topografi 100']