Skip to content

Commit

Permalink
align OACov to latest updates in specification (geopython#908)
Browse files Browse the repository at this point in the history
* align OACov to latest updates in specification
* update doc
  • Loading branch information
tomkralidis authored Feb 28, 2024
1 parent 882eb48 commit f8e3ff6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 48 deletions.
19 changes: 9 additions & 10 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,16 @@ OGC API - Coverages - Part 1: Core 1.0
Global Deterministic Prediction System sample'
>>> gdps['description']
'Global Deterministic Prediction System sample'
>>> domainset = w.coverage_domainset('gdps-temperature')
>>> domainset['generalGrid']['axisLabels']
['x', 'y']
>>> domainset['generalGrid']['gridLimits']['axisLabels']
['i', 'j']
>>> rangetype = w.coverage_rangetype('gdps-temperature')
>>> len(rangetype['field'])
>>> gdps['extent']['spatial']['grid'][0]
>>> {"cellsCount": 2400, "resolution": 0.15000000000000002 }
>>> gdps['extent']['spatial']['grid'][1]
>>> {"cellsCount": 1201, "resolution": 0.15}
>>> schema = w.collection_schema('gdps-temperature')
>>> len(schema['properties'])
1
>>> rangetype['field'][0]['definition']
'float64'
>> gdps_coverage_query = w.coverage('gdps-temperature', range_subset=[1])
>>> schema['properties']['1']['type']
'number'
>> gdps_coverage_data = w.coverage('gdps-temperature', range_subset=[1])
OGC API - Records - Part 1: Core 1.0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
13 changes: 13 additions & 0 deletions owslib/ogcapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,19 @@ def collection(self, collection_id: str) -> dict:
path = f'collections/{collection_id}'
return self._request(path=path)

def collection_schema(self, collection_id: str) -> dict:
"""
implements /collections/{collectionId}/schema
@type collection_id: string
@param collection_id: id of collection
@returns: `dict` of feature collection schema
"""

path = f'collections/{collection_id}/schema'
return self._request(path=path)

def collection_queryables(self, collection_id: str) -> dict:
"""
implements /collections/{collectionId}/queryables
Expand Down
26 changes: 0 additions & 26 deletions owslib/ogcapi/coverages.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,6 @@ def coverages(self) -> list:

return coverages_

def coverage_domainset(self, collection_id: str, **kwargs: dict) -> dict:
"""
implements /collection/{collectionId}/coverage/domainset
@type collection_id: string
@param collection_id: id of collection
@returns: coverage domainset results
"""

path = f'collections/{collection_id}/coverage/domainset'
return self._request(path=path, kwargs=kwargs)

def coverage_rangetype(self, collection_id: str, **kwargs: dict) -> dict:
"""
implements /collection/{collectionId}/coverage/rangetype
@type collection_id: string
@param collection_id: id of collection
@returns: coverage rangetype results
"""

path = f'collections/{collection_id}/coverage/rangetype'
return self._request(path=path, kwargs=kwargs)

def coverage(self, collection_id: str, **kwargs: dict) -> BinaryIO:
"""
implements /collection/{collectionId}/coverage/
Expand Down
22 changes: 10 additions & 12 deletions tests/test_ogcapi_coverages_pygeoapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ def test_ogcapi_coverages_pygeoapi():
assert gdps['id'] == 'gdps-temperature'
assert gdps['title'] == 'Global Deterministic Prediction System sample'
assert gdps['description'] == 'Global Deterministic Prediction System sample' # noqa

domainset = w.coverage_domainset('gdps-temperature')

assert domainset['generalGrid']['axisLabels'] == ['Long', 'Lat']

assert domainset['generalGrid']['gridLimits']['axisLabels'] == ['i', 'j']

rangetype = w.coverage_rangetype('gdps-temperature')
assert len(rangetype['field']) == 1
assert rangetype['field'][0]['name'] == 'Temperature [C]'
assert rangetype['field'][0]['uom']['code'] == '[C]'
assert rangetype['field'][0]['encodingInfo']['dataType'] == 'http://www.opengis.net/def/dataType/OGC/0/float64' # noqa
assert gdps['extent']['spatial']['grid'][0]['cellsCount'] == 2400
assert gdps['extent']['spatial']['grid'][0]['resolution'] == 0.15000000000000002 # noqa
assert gdps['extent']['spatial']['grid'][1]['cellsCount'] == 1201
assert gdps['extent']['spatial']['grid'][1]['resolution'] == 0.15

schema = w.collection_schema('gdps-temperature')
assert len(schema['properties']) == 1
assert schema['properties']['1']['title'] == 'Temperature [C]'
assert schema['properties']['1']['type'] == 'number'
assert schema['properties']['1']['x-ogc-unit'] == '[C]'

with pytest.raises(RuntimeError):
w.coverage('gdps-temperature', properties=[8])

0 comments on commit f8e3ff6

Please sign in to comment.