update config, fix ref (#634)
This commit is contained in:
@@ -226,9 +226,6 @@ resources:
|
||||
spatial:
|
||||
bbox: [-180,-90,180,90]
|
||||
crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
|
||||
temporal:
|
||||
begin: 1867-07-01
|
||||
end: null # or empty (either means open ended)
|
||||
providers:
|
||||
- type: record
|
||||
name: TinyDBCatalogue
|
||||
|
||||
@@ -139,9 +139,9 @@ class TinyDBCatalogueProvider(BaseProvider):
|
||||
time_begin, time_end = datetime_.split('/')
|
||||
|
||||
if time_begin != '..':
|
||||
QUERY.append("(Q.properties[self.time_field]>='{}')".format(datetime_)) # noqa
|
||||
QUERY.append("(Q.properties[self.time_field]>='{}')".format(time_begin)) # noqa
|
||||
if time_end != '..':
|
||||
QUERY.append("(Q.properties[self.time_field]<='{}')".format(datetime_)) # noqa
|
||||
QUERY.append("(Q.properties[self.time_field]<='{}')".format(time_end)) # noqa
|
||||
|
||||
else: # time instant
|
||||
LOGGER.debug('detected time instant')
|
||||
@@ -161,8 +161,8 @@ class TinyDBCatalogueProvider(BaseProvider):
|
||||
LOGGER.debug('SEARCH_STRING: {}'.format(SEARCH_STRING))
|
||||
|
||||
LOGGER.debug('querying database')
|
||||
|
||||
if len(QUERY) > 0:
|
||||
LOGGER.debug('running eval on {}'.format(SEARCH_STRING))
|
||||
results = eval(SEARCH_STRING)
|
||||
else:
|
||||
results = self.db.all()
|
||||
|
||||
@@ -53,7 +53,8 @@ def config():
|
||||
'name': 'TinyDBCatalogue',
|
||||
'type': 'feature',
|
||||
'data': path,
|
||||
'id_field': 'externalId'
|
||||
'id_field': 'externalId',
|
||||
'time_field': 'record-created'
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +82,18 @@ def test_query(config):
|
||||
assert len(results['features']) == 1
|
||||
assert results['features'][0]['id'] == '07b7ef80-6061-43fc-b874-e2800e9ae547' # noqa
|
||||
|
||||
results = p.query(datetime_='2020/..')
|
||||
assert len(results['features']) == 6
|
||||
assert results['features'][0]['id'] == '4e81a467-fc14-4fa0-a1d6-9d65336587c6' # noqa
|
||||
|
||||
results = p.query(datetime_='../2020')
|
||||
assert len(results['features']) == 4
|
||||
assert results['features'][0]['id'] == '07b7ef80-6061-43fc-b874-e2800e9ae547' # noqa
|
||||
|
||||
results = p.query(datetime_='2020-09-17/2020-12-01')
|
||||
assert len(results['features']) == 6
|
||||
assert results['features'][0]['id'] == '4e81a467-fc14-4fa0-a1d6-9d65336587c6' # noqa
|
||||
|
||||
results = p.query(bbox=[-154, 42, -52, 84])
|
||||
assert len(results['features']) == 10
|
||||
assert results['features'][0]['id'] == '07b7ef80-6061-43fc-b874-e2800e9ae547' # noqa
|
||||
|
||||
Reference in New Issue
Block a user