diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2023-09-28 02:40:00 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2023-09-28 12:33:07 +0200 |
commit | 7e07889c392ddc4bdeb296c4271363fb99fdae7f (patch) | |
tree | 51ec3cd3dc7e8696618443952cb3b707885e9a2d | |
parent | 9583fb67f02d7480022db6aaed345d179246abc2 (diff) |
Add options --since and --until to filter by start/end date.
-rwxr-xr-x | gis-observation-map | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gis-observation-map b/gis-observation-map index ec6a020..dad58a9 100755 --- a/gis-observation-map +++ b/gis-observation-map @@ -25,6 +25,7 @@ import re import requests import configparser import tempfile +from datetime import datetime from requests.exceptions import HTTPError from xdg import xdg_config_home from pathlib import Path @@ -100,6 +101,10 @@ parser.add_argument('--style', default=config['QGIS']['style'], type=ePath, help='QGIS Layer Style File (*.qml) to apply to the observation layer (default: %(default)s)') parser.add_argument('--data-provider', nargs='*', default=[], help='Data provider identifier (for instance "Artportalen,MVM")') +parser.add_argument('--since', + help='Start date for observations, in ISO 8601 format') +parser.add_argument('--until', + help='End date for observations, in ISO 8601 format') args = parser.parse_args() @@ -138,6 +143,12 @@ if len(args.geometry) == 0 and len(args.point) == 0: if len(args.point) > 0 and (args.margin is None or args.margin <= 0): parser.error("--point requires positive --margin") +for k in ['since', 'until']: + v = getattr(args, k, None) + if v is not None: + d = datetime.fromisoformat(v) + setattr(args, k, d.isoformat()) + if projectInstance is not None: if len(args.geometry) > 1: sourceGroup = layerTreeRoot.addGroup('Source geometry') @@ -720,6 +731,14 @@ if args.data_provider is not None: 'ids': mapDataProviders(args.data_provider) } +if args.since is not None or args.until is not None: + searchFilter['date'] = { + # https://github.com/biodiversitydata-se/SOS/blob/master/Docs/SearchFilter.md#date-filter + 'startDate': args.since, + 'endDate': args.until, + 'dateFilterType': 'OverlappingStartDateAndEndDate' + } + getObservations(taxonLists, taxonRedlistCategories, searchFilter) topo_maps = ['Topografi 10', 'Topografi 50', 'Topografi 100'] |