diff options
-rwxr-xr-x | gis-observation-map | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/gis-observation-map b/gis-observation-map index 026746b..22dc39e 100755 --- a/gis-observation-map +++ b/gis-observation-map @@ -566,14 +566,14 @@ def getTaxonLists(): # https://github.com/biodiversitydata-se/SOS/blob/master/Src/SOS.lib/Resources/TaxonLists.json # https://artfakta.se/artinformation/taxa - getTaxonList(taxonLists, taxonLists2, 'ProtectedByLaw', 'Protected by law species') - getTaxonList(taxonLists, taxonLists2, 'TaxonIsSignalSpecie', 'Signal species') + i1 = getTaxonList(taxonLists, taxonLists2, 'ProtectedByLaw', 'Protected by law species') + i2 = getTaxonList(taxonLists, taxonLists2, 'TaxonIsSignalSpecie', 'Signal species') #getTaxonList(taxonLists, taxonLists2, 'TaxonIsInvasive', 'Invasive species') #getTaxonList(taxonLists, taxonLists2, 'TaxonIsInvasiveInSweden', 'Invasive species in Sweden') #getTaxonList(taxonLists, taxonLists2, 'TaxonIsInvasiveEuRegulation', 'EU regulation 1143/2014') - getTaxonList(taxonLists, taxonLists2, 'Natura2000HabitatsDirective', 'Habitats directive species') + i8 = getTaxonList(taxonLists, taxonLists2, 'Natura2000HabitatsDirective', 'Habitats directive species') getTaxonList(taxonLists, taxonLists2, 'Natura2000HabitatsDirectiveArticle2', 'Habitats directive Annex 2') getTaxonList(taxonLists, taxonLists2, 'Natura2000HabitatsDirectiveArticle2PrioritySpecie', 'Habitats directive Annex 2, priority species') getTaxonList(taxonLists, taxonLists2, 'Natura2000HabitatsDirectiveArticle4', 'Habitats directive Annex 4') @@ -598,7 +598,7 @@ def getTaxonLists(): if i not in taxonLists2['Natura2000HabitatsDirectiveArticle2']: raise Exception(f'missing taxon #{i} (in Natura2000HabitatsDirectiveArticle2PrioritySpecie) from Natura2000HabitatsDirectiveArticle2') - getTaxonList(taxonLists, taxonLists2, 'BirdDirective', 'Birds Directive') + i13 = getTaxonList(taxonLists, taxonLists2, 'BirdDirective', 'Birds Directive') getTaxonList(taxonLists, taxonLists2, 'BirdDirectiveArticle1', 'Birds directive - Annex 1') getTaxonList(taxonLists, taxonLists2, 'BirdDirectiveArticle2', 'Birds directive - Annex 2') getTaxonList(taxonLists, taxonLists2, 'TaxonIsPriorityBird', 'Priority birds') @@ -613,10 +613,13 @@ def getTaxonLists(): if i not in taxonLists2[d0]: raise Exception(f'missing taxon #{i} (in {d}) from {d0}') - i = getTaxonList(taxonLists, taxonLists2, 'TaxonIsRedlisted', 'Redlisted species') - taxonRedlistCategories = getTaxonRedlistCategories(taxonLists, i) + i7 = getTaxonList(taxonLists, taxonLists2, 'TaxonIsRedlisted', 'Redlisted species') + taxonRedlistCategories = getTaxonRedlistCategories(taxonLists, i7) - return taxonLists2, taxonRedlistCategories + i18 = getTaxonList(taxonLists, None, None, 'Swedish forest agency nature conservation species') + + taxonListIds = [i1, i2, i7, i8, i13, i18] + return taxonLists2, taxonRedlistCategories, taxonListIds def getTaxonList(taxonLists, taxonLists2, key, name): i = None @@ -628,15 +631,16 @@ def getTaxonList(taxonLists, taxonLists2, key, name): if i is None: raise Exception(f'no result found for taxon list "{name}"') - resp = requests.get( - artDataBankenURL + f'/species-observation-system/v1/TaxonLists/{i}/Taxa', - headers=artDataBankenHeaders - ) - resp.raise_for_status() - resp = resp.json() - if type(resp) != list: - raise Exception(f'expected list, got {type(resp)}') - taxonLists2[key] = {r['id'] for r in resp} + if taxonLists2 is not None and key is not None: + resp = requests.get( + artDataBankenURL + f'/species-observation-system/v1/TaxonLists/{i}/Taxa', + headers=artDataBankenHeaders + ) + resp.raise_for_status() + resp = resp.json() + if type(resp) != list: + raise Exception(f'expected list, got {type(resp)}') + taxonLists2[key] = {r['id'] for r in resp} return i @@ -673,7 +677,7 @@ geographicsFilter = { 'considerObservationAccuracy': True, 'considerDisturbanceRadius': False } -taxonLists, taxonRedlistCategories = getTaxonLists() +taxonLists, taxonRedlistCategories, taxonListIds = getTaxonLists() # https://github.com/biodiversitydata-se/SOS/blob/master/Docs/SearchFilter.md searchFilter = { @@ -785,7 +789,7 @@ searchFilter['taxon'] = { 'ids': list(map(lambda k: kingdomIds[k], ['Fungi', 'Plantae'])), 'includeUnderlyingTaxa': True, # https://github.com/biodiversitydata-se/SOS/blob/master/Docs/SearchFilter.md#taxon-lists - 'taxonListIds': [1, 2, 7, 8, 13, 18], + 'taxonListIds': taxonListIds, 'taxonListOperator': 'Filter' } |