From a8f656405d5f475a6b0bef7c1fcaa6d0e07fb2a9 Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Wed, 27 Oct 2021 20:37:06 -0400 Subject: [PATCH] implement base EDR provider --- pygeoapi/provider/base_edr.py | 85 +++++++++++++++++++++++++++++++++ pygeoapi/provider/xarray_edr.py | 14 ++---- 2 files changed, 88 insertions(+), 11 deletions(-) create mode 100644 pygeoapi/provider/base_edr.py diff --git a/pygeoapi/provider/base_edr.py b/pygeoapi/provider/base_edr.py new file mode 100644 index 0000000..1849b87 --- /dev/null +++ b/pygeoapi/provider/base_edr.py @@ -0,0 +1,85 @@ +# ================================================================= +# +# Authors: Tom Kralidis +# +# Copyright (c) 2021 Tom Kralidis +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, +# copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following +# conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +# ================================================================= + +import logging + +from pygeoapi.provider.base import BaseProvider + +LOGGER = logging.getLogger(__name__) + + +class BaseEDRProvider(BaseProvider): + """Base EDR Provider""" + + def __init__(self, provider_def): + """ + Initialize object + + :param provider_def: provider definition + + :returns: pygeoapi.provider.base_edr.BaseEDRProvider + """ + + super().__init__(provider_def) + + self.instances = [] + + def get_instance(self, instance): + """ + Validate instance identifier + + :returns: `bool` of whether instance is valid + """ + + return NotImplementedError() + + def get_query_types(self): + """ + Provide supported query types + + :returns: `list` of EDR query types + """ + + return NotImplementedError() + + def query(self, **kwargs): + """ + Extract data from collection collection + + :param query_type: query type + :param wkt: `shapely.geometry` WKT geometry + :param datetime_: temporal (datestamp or extent) + :param select_properties: list of parameters + :param z: vertical level(s) + :param format_: data format of output + + :returns: coverage data as `dict` of CoverageJSON or native format + """ + + return NotImplementedError() diff --git a/pygeoapi/provider/xarray_edr.py b/pygeoapi/provider/xarray_edr.py index d8e5d0c..6fb0cae 100644 --- a/pygeoapi/provider/xarray_edr.py +++ b/pygeoapi/provider/xarray_edr.py @@ -30,12 +30,13 @@ import logging from pygeoapi.provider.base import ProviderNoDataError +from pygeoapi.provider.base_edr import BaseEDRProvider from pygeoapi.provider.xarray_ import _to_datetime_string, XarrayProvider LOGGER = logging.getLogger(__name__) -class XarrayEDRProvider(XarrayProvider): +class XarrayEDRProvider(BaseEDRProvider, XarrayProvider): """EDR Provider""" def __init__(self, provider_def): @@ -47,8 +48,8 @@ class XarrayEDRProvider(XarrayProvider): :returns: pygeoapi.provider.rasterio_.RasterioProvider """ + BaseEDRProvider.__init__(self, provider_def) XarrayProvider.__init__(self, provider_def) - self.instances = [] def get_fields(self): """ @@ -59,15 +60,6 @@ class XarrayEDRProvider(XarrayProvider): return self.get_coverage_rangetype() - def get_instance(self, instance): - """ - Validate instance identifier - - :returns: `bool` of whether instance is valid - """ - - return NotImplementedError() - def get_query_types(self): """ Provide supported query types