Environmental data retrieval API query parser
Project description
Environmental Data Retrieval Query Parser
The OGC API Environmental Data Retrieval query parser makes it easy to parse and use the API query.
install
pip install edr-query-parser
Usage
EDR Collection Name Example
edr_query = EDRQueryParser('https://somewhere.com/collections/my_collection/position?parameter-name=param1,param2&coords=POINT(57.819 '
'-3.966)&datetime=2019-09-07T15:50-04:00/2019-09-07T15:50-05:00&f=geoJSON&crs=crs86&z=500/400')
select = 'SELECT * FROM ' + edr_query.collection_name
print(select)
EDR coords Example
from edr_query_parser import EDRQueryParser
edr_query = EDRQueryParser('https://somewhere.com/collections/my_collection/position?coords=POINT(57.819 '
'-3.966)&datetime=2019-09-07T15:50-04:00/2019-09-07T15:50-05:00¶meter-name=parameter1,'
'parameter2&f=geoJSON&crs=crs86&z=all')
select = 'SELECT * FROM observations'
if edr_query.coords.is_set:
if edr_query.coords.coords_type == 'Point':
select += ' WHERE NEAREST_NEIGHBOUR(' + str(edr_query.coords.coordinates[0]) + ',' + str(edr_query.coords.coordinates[0]) + ')'
print(select)
EDR datetime Example
from edr_query_parser import EDRQueryParser
edr_query = EDRQueryParser('https://somewhere.com/collections/my_collection/position?coords=POINT(57.819 '
'-3.966)&datetime=2019-09-07T15:50-04:00/2019-09-07T15:50-05:00¶meter-name=parameter1,'
'parameter2&f=geoJSON&crs=crs86&z=all')
select = 'SELECT * FROM observations'
if edr_query.datetime.is_set:
if edr_query.datetime.is_interval:
select += ' date BETWEEN ' + str(edr_query.datetime.interval_from.timestamp()) + ' AND ' + str(edr_query.datetime.interval_to.timestamp())
else:
select += ' date = ' + str(edr_query.datetime.exact.timestamp()) + ')'
print(select)
EDR parameter-name Example
from edr_query_parser import EDRQueryParser
edr_query = EDRQueryParser('https://somewhere.com/collections/my_collection/position?coords=POINT(57.819 '
'-3.966)&datetime=2019-09-07T15:50-04:00/2019-09-07T15:50-05:00¶meter-name=parameter1,'
'parameter2&f=geoJSON&crs=crs86&z=all')
select = 'SELECT ' + ','.join(edr_query.parameter_name.list) + ' FROM observations'
print(select)
EDR z Parameter Example
from edr_query_parser import EDRQueryParser
edr_query = EDRQueryParser('https://somewhere.com/collections/my_collection/position?coords=POINT(57.819 '
'-3.966)&datetime=2019-09-07T15:50-04:00/2019-09-07T15:50-05:00¶meter-name=parameter1,'
'parameter2&f=geoJSON&crs=crs86&z=all')
select = 'SELECT * FROM observations'
if edr_query.z.is_set:
if edr_query.z.is_interval:
select += ' height BETWEEN ' + str(edr_query.z.interval_from) + ' AND ' + str(edr_query.z.interval_to)
if edr_query.z.is_list:
select += ' height IN (' + ','.join(map(str, edr_query.z.list)) + ')'
print(select)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
edr query parser-1.0.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for edr_query_parser-1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 466924748f99ff46940528024576ffe66eee9ec1c2569e67401a6d7ffa10fe59 |
|
MD5 | 71a9d9e3847900afee6f746dacdc6aa8 |
|
BLAKE2b-256 | 173f4e3a36d1cf2b67ae5287c4a15d5e258a182c8fe45cea80f475247ca763d0 |