CITE fixes and setup (#330)
* add CITE testing setup * fix item link relations, handle invalid limit/startindex parameters * ignore all generated OpenAPI files * update config and steps * update config
This commit is contained in:
+1
-3
@@ -101,9 +101,7 @@ ENV/
|
||||
.mypy_cache/
|
||||
|
||||
# pygeoapi artifacts
|
||||
local.config.yml
|
||||
local.openapi.yml
|
||||
openapi.yml
|
||||
*.openapi.yml
|
||||
|
||||
# misc
|
||||
*.swp
|
||||
|
||||
+31
-6
@@ -343,21 +343,21 @@ class API(object):
|
||||
LOGGER.debug('Adding JSON and HTML link relations')
|
||||
collection['links'].append({
|
||||
'type': 'application/geo+json',
|
||||
'rel': 'item',
|
||||
'rel': 'items',
|
||||
'title': 'Features as GeoJSON',
|
||||
'href': '{}/collections/{}/items?f=json'.format(
|
||||
self.config['server']['url'], k)
|
||||
})
|
||||
collection['links'].append({
|
||||
'type': 'application/ld+json',
|
||||
'rel': 'item',
|
||||
'rel': 'items',
|
||||
'title': 'Features as RDF (GeoJSON-LD)',
|
||||
'href': '{}/collections/{}/items?f=jsonld'.format(
|
||||
self.config['server']['url'], k)
|
||||
})
|
||||
collection['links'].append({
|
||||
'type': 'text/html',
|
||||
'rel': 'item',
|
||||
'rel': 'items',
|
||||
'title': 'Features as HTML',
|
||||
'href': '{}/collections/{}/items?f=html'.format(
|
||||
self.config['server']['url'], k)
|
||||
@@ -495,8 +495,17 @@ class API(object):
|
||||
}
|
||||
LOGGER.error(exception)
|
||||
return headers_, 400, json.dumps(exception)
|
||||
except TypeError:
|
||||
except (TypeError) as err:
|
||||
LOGGER.warning(err)
|
||||
startindex = 0
|
||||
except ValueError as err:
|
||||
LOGGER.warning(err)
|
||||
exception = {
|
||||
'code': 'InvalidParameterValue',
|
||||
'description': 'startindex value should be an integer'
|
||||
}
|
||||
LOGGER.error(exception)
|
||||
return headers_, 400, json.dumps(exception)
|
||||
|
||||
LOGGER.debug('Processing limit parameter')
|
||||
try:
|
||||
@@ -510,8 +519,17 @@ class API(object):
|
||||
}
|
||||
LOGGER.error(exception)
|
||||
return headers_, 400, json.dumps(exception)
|
||||
except TypeError:
|
||||
except TypeError as err:
|
||||
LOGGER.warning(err)
|
||||
limit = int(self.config['server']['limit'])
|
||||
except ValueError as err:
|
||||
LOGGER.warning(err)
|
||||
exception = {
|
||||
'code': 'InvalidParameterValue',
|
||||
'description': 'limit value should be an integer'
|
||||
}
|
||||
LOGGER.error(exception)
|
||||
return headers_, 400, json.dumps(exception)
|
||||
|
||||
resulttype = args.get('resulttype') or 'results'
|
||||
|
||||
@@ -607,7 +625,14 @@ class API(object):
|
||||
|
||||
LOGGER.debug('processing property parameters')
|
||||
for k, v in args.items():
|
||||
if k not in reserved_fieldnames and k in p.fields.keys():
|
||||
if k not in reserved_fieldnames and k not in p.fields.keys():
|
||||
exception = {
|
||||
'code': 'InvalidParameterValue',
|
||||
'description': 'unknown query parameter'
|
||||
}
|
||||
LOGGER.error(exception)
|
||||
return headers_, 400, json.dumps(exception)
|
||||
elif k not in reserved_fieldnames and k in p.fields.keys():
|
||||
LOGGER.debug('Add property filter {}={}'.format(k, v))
|
||||
properties.append((k, v))
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# CITE testing for OGC API - Features
|
||||
|
||||
## Test data
|
||||
|
||||
Test data used is a subset of the [Canadian National Water Data Archive](https://www.canada.ca/en/environment-climate-change/services/water-overview/quantity/monitoring/survey/data-products-services/national-archive-hydat.html)
|
||||
as extracted from the [MSC Geomet OGC API](https://eccc-msc.github.io/open-data/msc-geomet/web-services_en/#ogc-api-features).
|
||||
|
||||
## Running
|
||||
|
||||
```bash
|
||||
# install pygeoapi as per https://pygeoapi.io/#install-in-5-minutes
|
||||
cd tests/cite/ogcapi-features
|
||||
. cite.env
|
||||
python ../../load_es_data.py ./canada-hydat-daily-mean-02hc003.json IDENTIFIER
|
||||
pygeoapi generate-openapi-document -c $PYGEOAPI_CONFIG > $PYGEOAPI_OPENAPI
|
||||
gunicorn pygeoapi.flask_app:APP -b 0.0.0.0:5001 --access-logfile '-'
|
||||
```
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,99 @@
|
||||
server:
|
||||
bind:
|
||||
host: 0.0.0.0
|
||||
port: 5001
|
||||
url: http://localhost:5001
|
||||
mimetype: application/json; charset=UTF-8
|
||||
encoding: utf-8
|
||||
language: en-US
|
||||
cors: true
|
||||
pretty_print: true
|
||||
limit: 10
|
||||
# templates: /path/to/templates
|
||||
map:
|
||||
url: https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png
|
||||
attribution: '<a href="https://wikimediafoundation.org/wiki/Maps_Terms_of_Use">Wikimedia maps</a> | Map data © <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
|
||||
|
||||
logging:
|
||||
level: ERROR
|
||||
#logfile: /tmp/pygeoapi.log
|
||||
|
||||
metadata:
|
||||
identification:
|
||||
title: pygeoapi CITE instance
|
||||
description: pygeoapi instance in support of OGC CITE compliance
|
||||
keywords:
|
||||
- geospatial
|
||||
- data
|
||||
- api
|
||||
keywords_type: theme
|
||||
terms_of_service: null
|
||||
url: https://pygeoapi.io
|
||||
license:
|
||||
name: CC-BY 4.0 license
|
||||
url: https://creativecommons.org/licenses/by/4.0/
|
||||
provider:
|
||||
name: pygeoapi
|
||||
url: https://pygeoapi.io
|
||||
contact:
|
||||
name: Tom Kralidis
|
||||
position: Senior Systems Scientist
|
||||
address: Mailing Address
|
||||
city: City
|
||||
stateorprovince: Administrative Area
|
||||
postalcode: Zip or Postal Code
|
||||
country: Country
|
||||
phone: +xx-xxx-xxx-xxxx
|
||||
fax: +xx-xxx-xxx-xxxx
|
||||
email: pygeoapi@lists.osgeo.org
|
||||
url: https://pygeoapi.io/community/
|
||||
hours: Mo-Fr 08:00-17:00
|
||||
instructions: During hours of service. Off on weekends.
|
||||
role: pointOfContact
|
||||
|
||||
datasets:
|
||||
canada-hydat-daily-mean-02hc003:
|
||||
title: Daily Mean of Water Level or Flow
|
||||
description: The daily mean is the average of all unit values for a given day.
|
||||
keywords: [Daily, Daily Mean, Water Level, Flow, Discharge]
|
||||
crs:
|
||||
- CRS84
|
||||
links:
|
||||
- type: text/html
|
||||
rel: canonical
|
||||
title: Water Level and Flow - Environment Canada
|
||||
href: https://wateroffice.ec.gc.ca
|
||||
hreflang: en-CA
|
||||
- type: text/html
|
||||
rel: canonical
|
||||
title: Niveau d'eau et débit - Environnement Canada
|
||||
href: https://wateroffice.ec.gc.ca/index_f.html
|
||||
hreflang: fr-CA
|
||||
- type: text/html
|
||||
rel: download
|
||||
title: "National water data archive: HYDAT - Canada.ca"
|
||||
href: https://www.canada.ca/en/environment-climate-change/services/water-overview/quantity/monitoring/survey/data-products-services/national-archive-hydat.html
|
||||
hreflang: en-CA
|
||||
- type: text/html
|
||||
rel: download
|
||||
title: "Archives nationales des données hydrologiques : HYDAT - Canada.ca"
|
||||
href: https://www.canada.ca/fr/environnement-changement-climatique/services/eau-apercu/volume/surveillance/releves/produits-donnees-services/archives-nationales-hydat.html
|
||||
hreflang: fr-CA
|
||||
- type: application/zip
|
||||
rel: download
|
||||
title: download data
|
||||
href: https://collaboration.cmc.ec.gc.ca/cmc/hydrometrics/www
|
||||
hreflang: en-CA
|
||||
extents:
|
||||
spatial:
|
||||
bbox: [-142, 52, -52, 84]
|
||||
crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
|
||||
temporal:
|
||||
begin: 1850-01-01
|
||||
end: null # or empty
|
||||
|
||||
provider:
|
||||
name: Elasticsearch
|
||||
data: http://localhost:9200/canada-hydat-daily-mean-02hc003/FeatureCollection
|
||||
id_field: IDENTIFIER
|
||||
time_field: DATE
|
||||
@@ -0,0 +1,2 @@
|
||||
export PYGEOAPI_CONFIG=`pwd`/cite.config.yml
|
||||
export PYGEOAPI_OPENAPI=`pwd`/cite.openapi.yml
|
||||
Reference in New Issue
Block a user