diff --git a/aws-lambda/pygeoapi-serverless-config.yml b/aws-lambda/pygeoapi-serverless-config.yml index 88e6abf..57e3ece 100644 --- a/aws-lambda/pygeoapi-serverless-config.yml +++ b/aws-lambda/pygeoapi-serverless-config.yml @@ -108,13 +108,14 @@ resources: begin: 2000-10-30T18:24:39Z end: 2007-10-30T08:57:29Z trs: http://www.opengis.net/def/uom/ISO-8601/0/Gregorian - provider: - name: CSV - data: tests/data/obs.csv - id_field: id - geometry: - x_field: long - y_field: lat + providers: + - type: feature + name: CSV + data: tests/data/obs.csv + id_field: id + geometry: + x_field: long + y_field: lat ne_110m_populated_places_simple: type: collection @@ -139,10 +140,11 @@ resources: spatial: bbox: [-180,-90,180,90] crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84 - provider: - name: Elasticsearch - data: http://localhost:9200/ne_110m_populated_places_simple - id_field: geonameid + providers: + - type: feature + name: Elasticsearch + data: http://localhost:9200/ne_110m_populated_places_simple + id_field: geonameid lakes: type: collection @@ -164,10 +166,11 @@ resources: begin: 2011-11-11 end: null # or empty trs: http://www.opengis.net/def/uom/ISO-8601/0/Gregorian - provider: - name: GeoJSON - data: tests/data/ne_110m_lakes.geojson - id_field: id + providers: + - type: feature + name: GeoJSON + data: tests/data/ne_110m_lakes.geojson + id_field: id countries: type: collection @@ -189,11 +192,12 @@ resources: temporal: begin: end: null # or empty - provider: - name: SQLiteGPKG - data: tests/data/ne_110m_admin_0_countries.sqlite - id_field: ogc_fid - table: ne_110m_admin_0_countries + providers: + - type: feature + name: SQLiteGPKG + data: tests/data/ne_110m_admin_0_countries.sqlite + id_field: ogc_fid + table: ne_110m_admin_0_countries poi: type: collection title: Portuguese point of interrest @@ -220,11 +224,12 @@ resources: temporal: begin: end: null # or empty - provider: - name: GeoPackage - data: tests/data/poi_portugal.gpkg - id_field: osm_id - table: poi_portugal + providers: + - type: feature + name: GeoPackage + data: tests/data/poi_portugal.gpkg + id_field: osm_id + table: poi_portugal hotosm_bdi_waterways: type: collection @@ -249,17 +254,18 @@ resources: temporal: begin: end: null # or empty - provider: - name: PostgreSQL - data: - host: 127.0.0.1 - dbname: test - user: postgres - password: postgres - port: 5432 - schema: public - id_field: osm_id - table: hotosm_bdi_waterways + providers: + - type: feature + name: PostgreSQL + data: + host: 127.0.0.1 + dbname: test + user: postgres + password: postgres + port: 5432 + schema: public + id_field: osm_id + table: hotosm_bdi_waterways dutch_georef_stations: type: collection @@ -284,29 +290,30 @@ resources: temporal: begin: end: null # or empty - provider: - name: OGR - data: - source_type: WFS - source: WFS:http://geodata.nationaalgeoregister.nl/rdinfo/wfs? - source_srs: EPSG:28992 - target_srs: EPSG:4326 - source_capabilities: - paging: True - - source_options: -# OGR_WFS_VERSION: 1.1.0 - OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO - - gdal_ogr_options: - EMPTY_AS_NULL: NO - GDAL_CACHEMAX: 64 - # GDAL_HTTP_PROXY: (optional proxy) - # GDAL_PROXY_AUTH: (optional auth for remote WFS) - CPL_DEBUG: NO - - id_field: gml_id - layer: rdinfo:stations + providers: + - type: feature + name: OGR + data: + source_type: WFS + source: WFS:http://geodata.nationaalgeoregister.nl/rdinfo/wfs? + source_srs: EPSG:28992 + target_srs: EPSG:4326 + source_capabilities: + paging: True + + source_options: + # OGR_WFS_VERSION: 1.1.0 + OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO + + gdal_ogr_options: + EMPTY_AS_NULL: NO + GDAL_CACHEMAX: 64 + # GDAL_HTTP_PROXY: (optional proxy) + # GDAL_PROXY_AUTH: (optional auth for remote WFS) + CPL_DEBUG: NO + + id_field: gml_id + layer: rdinfo:stations hello-world: type: process diff --git a/docker/default.config.yml b/docker/default.config.yml index 27ec088..4c8d2cb 100644 --- a/docker/default.config.yml +++ b/docker/default.config.yml @@ -119,13 +119,14 @@ resources: temporal: begin: 2000-10-30T18:24:39Z end: 2007-10-30T08:57:29Z - provider: - name: CSV - data: tests/data/obs.csv - id_field: id - geometry: - x_field: long - y_field: lat + providers: + - type: feature + name: CSV + data: tests/data/obs.csv + id_field: id + geometry: + x_field: long + y_field: lat lakes: type: collection @@ -146,10 +147,11 @@ resources: temporal: begin: 2011-11-11 end: null # or empty (either means open ended) - provider: - name: GeoJSON - data: tests/data/ne_110m_lakes.geojson - id_field: id + providers: + - type: feature + name: GeoJSON + data: tests/data/ne_110m_lakes.geojson + id_field: id countries: type: collection @@ -171,11 +173,12 @@ resources: temporal: begin: end: null # or empty - provider: - name: SQLiteGPKG - data: tests/data/ne_110m_admin_0_countries.sqlite - id_field: ogc_fid - table: ne_110m_admin_0_countries + providers: + - type: feature + name: SQLiteGPKG + data: tests/data/ne_110m_admin_0_countries.sqlite + id_field: ogc_fid + table: ne_110m_admin_0_countries dutch_georef_stations: type: collection @@ -200,29 +203,30 @@ resources: temporal: begin: end: null # or empty - provider: - name: OGR - data: - source_type: WFS - source: WFS:http://geodata.nationaalgeoregister.nl/rdinfo/wfs? - source_srs: EPSG:28992 - target_srs: EPSG:4326 - source_capabilities: - paging: True - - source_options: -# OGR_WFS_VERSION: 1.1.0 - OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO - - gdal_ogr_options: - EMPTY_AS_NULL: NO - GDAL_CACHEMAX: 64 - # GDAL_HTTP_PROXY: (optional proxy) - # GDAL_PROXY_AUTH: (optional auth for remote WFS) - CPL_DEBUG: NO - - id_field: gml_id - layer: rdinfo:stations + providers: + - type: feature + name: OGR + data: + source_type: WFS + source: WFS:http://geodata.nationaalgeoregister.nl/rdinfo/wfs? + source_srs: EPSG:28992 + target_srs: EPSG:4326 + source_capabilities: + paging: True + + source_options: + # OGR_WFS_VERSION: 1.1.0 + OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO + + gdal_ogr_options: + EMPTY_AS_NULL: NO + GDAL_CACHEMAX: 64 + # GDAL_HTTP_PROXY: (optional proxy) + # GDAL_PROXY_AUTH: (optional auth for remote WFS) + CPL_DEBUG: NO + + id_field: gml_id + layer: rdinfo:stations utah_city_locations: type: collection @@ -246,29 +250,30 @@ resources: temporal: begin: end: null # or empty - provider: - name: OGR - data: - source_type: WFS - source: WFS:http://demo.deegree.org/utah-workspace/services/wfs?TYPENAME=app:SGID93_LOCATION_UDOTMap_CityLocations - source_srs: EPSG:26912 - target_srs: EPSG:4326 - source_capabilities: - paging: True - - source_options: -# OGR_WFS_VERSION: 2.0.0 - OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO - - gdal_ogr_options: - EMPTY_AS_NULL: NO - GDAL_CACHEMAX: 64 - # GDAL_HTTP_PROXY: (optional proxy) - # GDAL_PROXY_AUTH: (optional auth for remote WFS) - CPL_DEBUG: NO - - id_field: NAME - layer: app:SGID93_LOCATION_UDOTMap_CityLocations + providers: + - type: feature + name: OGR + data: + source_type: WFS + source: WFS:http://demo.deegree.org/utah-workspace/services/wfs?TYPENAME=app:SGID93_LOCATION_UDOTMap_CityLocations + source_srs: EPSG:26912 + target_srs: EPSG:4326 + source_capabilities: + paging: True + + source_options: + # OGR_WFS_VERSION: 2.0.0 + OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO + + gdal_ogr_options: + EMPTY_AS_NULL: NO + GDAL_CACHEMAX: 64 + # GDAL_HTTP_PROXY: (optional proxy) + # GDAL_PROXY_AUTH: (optional auth for remote WFS) + CPL_DEBUG: NO + + id_field: NAME + layer: app:SGID93_LOCATION_UDOTMap_CityLocations unesco_pois_italy: type: collection @@ -291,29 +296,30 @@ resources: temporal: begin: end: null # or empty - provider: - name: OGR - data: - source_type: WFS - source: WFS:https://demo.geo-solutions.it/geoserver/wfs - source_srs: EPSG:32632 - target_srs: EPSG:4326 - source_capabilities: - paging: True - - source_options: -# OGR_WFS_VERSION: 1.1.0 - OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO - - gdal_ogr_options: - EMPTY_AS_NULL: NO - GDAL_CACHEMAX: 64 - # GDAL_HTTP_PROXY: (optional proxy) - # GDAL_PROXY_AUTH: (optional auth for remote WFS) - CPL_DEBUG: NO - - id_field: gml_id - layer: unesco:Unesco_point + providers: + - type: feature + name: OGR + data: + source_type: WFS + source: WFS:https://demo.geo-solutions.it/geoserver/wfs + source_srs: EPSG:32632 + target_srs: EPSG:4326 + source_capabilities: + paging: True + + source_options: + # OGR_WFS_VERSION: 1.1.0 + OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO + + gdal_ogr_options: + EMPTY_AS_NULL: NO + GDAL_CACHEMAX: 64 + # GDAL_HTTP_PROXY: (optional proxy) + # GDAL_PROXY_AUTH: (optional auth for remote WFS) + CPL_DEBUG: NO + + id_field: gml_id + layer: unesco:Unesco_point ogr_gpkg_poi: type: collection @@ -341,25 +347,26 @@ resources: temporal: begin: end: null # or empty - provider: - name: OGR - data: - source_type: GPKG - source: tests/data/poi_portugal.gpkg - source_srs: EPSG:4326 - target_srs: EPSG:4326 - source_capabilities: - paging: True - - gdal_ogr_options: - EMPTY_AS_NULL: NO - GDAL_CACHEMAX: 64 - # GDAL_HTTP_PROXY: (optional proxy) - # GDAL_PROXY_AUTH: (optional auth for remote WFS) - CPL_DEBUG: NO - - id_field: osm_id - layer: poi_portugal + providers: + - type: feature + name: OGR + data: + source_type: GPKG + source: tests/data/poi_portugal.gpkg + source_srs: EPSG:4326 + target_srs: EPSG:4326 + source_capabilities: + paging: True + + gdal_ogr_options: + EMPTY_AS_NULL: NO + GDAL_CACHEMAX: 64 + # GDAL_HTTP_PROXY: (optional proxy) + # GDAL_PROXY_AUTH: (optional auth for remote WFS) + CPL_DEBUG: NO + + id_field: osm_id + layer: poi_portugal ogr_geojson_lakes: type: collection @@ -380,25 +387,26 @@ resources: temporal: begin: 2011-11-11 end: null # or empty - provider: - name: OGR - data: - source_type: GeoJSON - source: tests/data/ne_110m_lakes.geojson - source_srs: EPSG:4326 - target_srs: EPSG:4326 - source_capabilities: - paging: True - - gdal_ogr_options: - EMPTY_AS_NULL: NO - GDAL_CACHEMAX: 64 - # GDAL_HTTP_PROXY: (optional proxy) - # GDAL_PROXY_AUTH: (optional auth for remote WFS) - CPL_DEBUG: NO - - id_field: id - layer: ne_110m_lakes + providers: + - type: feature + name: OGR + data: + source_type: GeoJSON + source: tests/data/ne_110m_lakes.geojson + source_srs: EPSG:4326 + target_srs: EPSG:4326 + source_capabilities: + paging: True + + gdal_ogr_options: + EMPTY_AS_NULL: NO + GDAL_CACHEMAX: 64 + # GDAL_HTTP_PROXY: (optional proxy) + # GDAL_PROXY_AUTH: (optional auth for remote WFS) + CPL_DEBUG: NO + + id_field: id + layer: ne_110m_lakes ogr_addresses_sqlite: type: collection @@ -421,26 +429,27 @@ resources: temporal: begin: end: null # or empty - provider: - name: OGR - data: - source_type: SQLite - # source: tests/data/ne_110m_admin_0_countries.sqlite - source: tests/data/dutch_addresses_4326.sqlite - source_srs: EPSG:4326 - target_srs: EPSG:4326 - source_capabilities: - paging: True - - gdal_ogr_options: - EMPTY_AS_NULL: NO - GDAL_CACHEMAX: 64 - # GDAL_HTTP_PROXY: (optional proxy) - # GDAL_PROXY_AUTH: (optional auth for remote WFS) - CPL_DEBUG: NO - - id_field: id - layer: ogrgeojson + providers: + - type: feature + name: OGR + data: + source_type: SQLite + # source: tests/data/ne_110m_admin_0_countries.sqlite + source: tests/data/dutch_addresses_4326.sqlite + source_srs: EPSG:4326 + target_srs: EPSG:4326 + source_capabilities: + paging: True + + gdal_ogr_options: + EMPTY_AS_NULL: NO + GDAL_CACHEMAX: 64 + # GDAL_HTTP_PROXY: (optional proxy) + # GDAL_PROXY_AUTH: (optional auth for remote WFS) + CPL_DEBUG: NO + + id_field: id + layer: ogrgeojson ogr_addresses_gpkg: type: collection @@ -463,25 +472,26 @@ resources: temporal: begin: end: null # or empty - provider: - name: OGR - data: - source_type: GPKG - source: tests/data/dutch_addresses_4326.gpkg - source_srs: EPSG:4326 - target_srs: EPSG:4326 - source_capabilities: - paging: True - - gdal_ogr_options: - EMPTY_AS_NULL: NO - GDAL_CACHEMAX: 64 - # GDAL_HTTP_PROXY: (optional proxy) - # GDAL_PROXY_AUTH: (optional auth for remote WFS) - CPL_DEBUG: NO - - id_field: id - layer: OGRGeoJSON + providers: + - type: feature + name: OGR + data: + source_type: GPKG + source: tests/data/dutch_addresses_4326.gpkg + source_srs: EPSG:4326 + target_srs: EPSG:4326 + source_capabilities: + paging: True + + gdal_ogr_options: + EMPTY_AS_NULL: NO + GDAL_CACHEMAX: 64 + # GDAL_HTTP_PROXY: (optional proxy) + # GDAL_PROXY_AUTH: (optional auth for remote WFS) + CPL_DEBUG: NO + + id_field: id + layer: OGRGeoJSON hello-world: type: process diff --git a/docker/examples/elastic/pygeoapi/docker.config.yml b/docker/examples/elastic/pygeoapi/docker.config.yml index c68138f..d55623e 100644 --- a/docker/examples/elastic/pygeoapi/docker.config.yml +++ b/docker/examples/elastic/pygeoapi/docker.config.yml @@ -111,13 +111,14 @@ resources: begin: 2000-10-30T18:24:39Z end: 2007-10-30T08:57:29Z trs: http://www.opengis.net/def/uom/ISO-8601/0/Gregorian - provider: - name: CSV - data: tests/data/obs.csv - id_field: id - geometry: - x_field: long - y_field: long + providers: + - type: feature + name: CSV + data: tests/data/obs.csv + id_field: id + geometry: + x_field: long + y_field: long ne_110m_populated_places_simple: type: collection @@ -142,11 +143,12 @@ resources: spatial: bbox: [-180,-90,180,90] crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84 - provider: - name: Elasticsearch - #Note elastic_search is the docker container of ES the name is defined in the docker-compose.yml - data: http://elastic_search:9200/ne_110m_populated_places_simple - id_field: geonameid + providers: + - type: feature + name: Elasticsearch + #Note elastic_search is the docker container of ES the name is defined in the docker-compose.yml + data: http://elastic_search:9200/ne_110m_populated_places_simple + id_field: geonameid lakes: type: collection @@ -168,10 +170,11 @@ resources: begin: 2011-11-11 end: null # or empty trs: http://www.opengis.net/def/uom/ISO-8601/0/Gregorian - provider: - name: GeoJSON - data: tests/data/ne_110m_lakes.geojson - id_field: id + providers: + - type: feature + name: GeoJSON + data: tests/data/ne_110m_lakes.geojson + id_field: id countries: type: collection @@ -193,11 +196,12 @@ resources: temporal: begin: end: null # or empty - provider: - name: SQLiteGPKG - data: tests/data/ne_110m_admin_0_countries.sqlite - id_field: ogc_fid - table: ne_110m_admin_0_countries + providers: + - type: feature + name: SQLiteGPKG + data: tests/data/ne_110m_admin_0_countries.sqlite + id_field: ogc_fid + table: ne_110m_admin_0_countries hello-world: type: process diff --git a/docker/examples/simple/my.config.yml b/docker/examples/simple/my.config.yml index a75deb8..0379c14 100644 --- a/docker/examples/simple/my.config.yml +++ b/docker/examples/simple/my.config.yml @@ -109,13 +109,14 @@ resources: begin: 2000-10-30T18:24:39Z end: 2007-10-30T08:57:29Z trs: http://www.opengis.net/def/uom/ISO-8601/0/Gregorian - provider: - name: CSV - data: tests/data/obs.csv - id_field: id - geometry: - x_field: long - y_field: long + providers: + - type: feature + name: CSV + data: tests/data/obs.csv + id_field: id + geometry: + x_field: long + y_field: long lakes: type: collection @@ -137,10 +138,11 @@ resources: begin: 2011-11-11 end: null # or empty trs: http://www.opengis.net/def/uom/ISO-8601/0/Gregorian - provider: - name: GeoJSON - data: tests/data/ne_110m_lakes.geojson - id_field: id + providers: + - type: feature + name: GeoJSON + data: tests/data/ne_110m_lakes.geojson + id_field: id countries: type: collection @@ -162,11 +164,12 @@ resources: temporal: begin: end: null # or empty - provider: - name: SQLiteGPKG - data: tests/data/ne_110m_admin_0_countries.sqlite - id_field: ogc_fid - table: ne_110m_admin_0_countries + providers: + - type: feature + name: SQLiteGPKG + data: tests/data/ne_110m_admin_0_countries.sqlite + id_field: ogc_fid + table: ne_110m_admin_0_countries hello-world: type: process diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index 502cbbd..83290b8 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -111,10 +111,20 @@ The ``metadata`` section provides settings for overall service metadata and desc The ``resources`` section lists 1 or more dataset collections to be published by the server. The ``resource.type`` property is required. Allowed types are: + - ``collection`` - ``process`` - ``stac-collection`` +The ``providers`` block is a list of 1..n providers with which to operate the data on. Each +provider requires a ``type`` property. Allowed types are: + +- ``feature`` + +A collection's default provider can be qualified with ``default: true`` in the provider +configuration. If ``default`` is not included, the first provider is assumed to be the +default. + .. code-block:: yaml resources: @@ -143,18 +153,20 @@ The ``resource.type`` property is required. Allowed types are: temporal: # optional begin: 2000-10-30T18:24:39Z # start datetime in RFC3339 end: 2007-10-30T08:57:29Z # end datetime in RFC3339 - provider: # required connection information + providers: # list of 1..n required connections information # provider name # see pygeoapi.plugin for supported providers # for custom built plugins, use the import path (e.g. mypackage.provider.MyProvider) # see Plugins section for more information - name: CSV - data: tests/data/obs.csv # required: the data filesystem path or URL, depending on plugin setup - id_field: id # required for vector data, the field corresponding to the ID - time_field: datetimestamp # optional field corresponding to the temporal propert of the dataset - properties: # optional: only return the following properties, in order - - stn_id - - value + - type: feature # underlying data geospatial type: (allowed values are: feature) + default: true # optional: if not specified, the first provider definition is considered the default + name: CSV + data: tests/data/obs.csv # required: the data filesystem path or URL, depending on plugin setup + id_field: id # required for vector data, the field corresponding to the ID + time_field: datetimestamp # optional field corresponding to the temporal propert of the dataset + properties: # optional: only return the following properties, in order + - stn_id + - value hello-world: # name of process type: collection # REQUIRED (collection, process, or stac-collection) diff --git a/docs/source/data-publishing/ogcapi-features.rst b/docs/source/data-publishing/ogcapi-features.rst index 027af45..b0d2b0e 100644 --- a/docs/source/data-publishing/ogcapi-features.rst +++ b/docs/source/data-publishing/ogcapi-features.rst @@ -35,13 +35,14 @@ definition. .. code-block:: yaml - provider: - name: CSV - data: tests/data/obs.csv - id_field: id - geometry: - x_field: long - y_field: lat + providers: + - type: feature + name: CSV + data: tests/data/obs.csv + id_field: id + geometry: + x_field: long + y_field: lat GeoJSON @@ -51,10 +52,11 @@ To publish a GeoJSON file, the file must be a valid GeoJSON FeatureCollection. .. code-block:: yaml - provider: - name: GeoJSON - data: tests/data/file.json - id_field: id + providers: + - type: feature + name: GeoJSON + data: tests/data/file.json + id_field: id Elasticsearch @@ -71,11 +73,12 @@ To publish an Elasticsearch index, the following are required in your index: .. code-block:: yaml - provider: - name: Elasticsearch - data: http://localhost:9200/ne_110m_populated_places_simple - id_field: geonameid - time_field: datetimefield + providers: + - type: feature + name: Elasticsearch + data: http://localhost:9200/ne_110m_populated_places_simple + id_field: geonameid + time_field: datetimefield OGR ^^^ @@ -89,10 +92,11 @@ MongoDB .. code-block:: yaml - provider: - name: MongoDB - data: mongodb://localhost:27017/testdb - collection: testplaces + providers: + - type: feature + name: MongoDB + data: mongodb://localhost:27017/testdb + collection: testplaces PostgreSQL @@ -102,17 +106,18 @@ PostgreSQL .. code-block:: yaml - provider: - name: PostgreSQL - data: - host: 127.0.0.1 - dbname: test - user: postgres - password: postgres - search_path: [osm, public] - id_field: osm_id - table: hotosm_bdi_waterways - geom_field: foo_geom + providers: + - type: feature + name: PostgreSQL + data: + host: 127.0.0.1 + dbname: test + user: postgres + password: postgres + search_path: [osm, public] + id_field: osm_id + table: hotosm_bdi_waterways + geom_field: foo_geom SQLiteGPKG @@ -124,22 +129,24 @@ SQLite file: .. code-block:: yaml - provider: - name: SQLiteGPKG - data: ./tests/data/ne_110m_admin_0_countries.sqlite - id_field: ogc_fid - table: ne_110m_admin_0_countries + providers: + - type: feature + name: SQLiteGPKG + data: ./tests/data/ne_110m_admin_0_countries.sqlite + id_field: ogc_fid + table: ne_110m_admin_0_countries GeoPackage file: .. code-block:: yaml - provider: - name: SQLiteGPKG - data: ./tests/data/poi_portugal.gpkg - id_field: osm_id - table: poi_portugal + providers: + - type: feature + name: SQLiteGPKG + data: ./tests/data/poi_portugal.gpkg + id_field: osm_id + table: poi_portugal Data access examples diff --git a/docs/source/data-publishing/stac.rst b/docs/source/data-publishing/stac.rst index 031ee99..c1860fe 100644 --- a/docs/source/data-publishing/stac.rst +++ b/docs/source/data-publishing/stac.rst @@ -18,11 +18,12 @@ to the given directory and specifying allowed file types: my-stac-resource: type: stac-collection ... - provider: - name: FileSystem - data: /Users/tomkralidis/Dev/data/gdps - file_types: - - .grib2 + providers: + - type: stac + name: FileSystem + data: /Users/tomkralidis/Dev/data/gdps + file_types: + - .grib2 .. note:: diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index d7c3b9a..c09cb2e 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -111,10 +111,11 @@ The following methods are options to connect the plugin to pygeoapi: .. code-block:: yaml - provider: - name: MyCoolData - data: /path/to/file - id_field: stn_id + providers: + - type: feature + name: MyCoolData + data: /path/to/file + id_field: stn_id **Option 2**: implement outside of pygeoapi and add to configuration (recommended) @@ -126,10 +127,11 @@ The following methods are options to connect the plugin to pygeoapi: .. code-block:: yaml - provider: - name: mycooldatapackage.mycooldata.MyCoolDataProvider - data: /path/to/file - id_field: stn_id + providers: + - type: feature + name: mycooldatapackage.mycooldata.MyCoolDataProvider + data: /path/to/file + id_field: stn_id Example: custom pygeoapi formatter ---------------------------------- diff --git a/pygeoapi-config.yml b/pygeoapi-config.yml index 74895a8..a6e5fa3 100644 --- a/pygeoapi-config.yml +++ b/pygeoapi-config.yml @@ -111,13 +111,14 @@ resources: temporal: begin: 2000-10-30T18:24:39Z end: 2007-10-30T08:57:29Z - provider: - name: CSV - data: tests/data/obs.csv - id_field: id - geometry: - x_field: long - y_field: lat + providers: + - type: feature + name: CSV + data: tests/data/obs.csv + id_field: id + geometry: + x_field: long + y_field: lat lakes: type: collection @@ -138,10 +139,11 @@ resources: temporal: begin: 2011-11-11 end: null # or empty (either means open ended) - provider: - name: GeoJSON - data: tests/data/ne_110m_lakes.geojson - id_field: id + providers: + - type: feature + name: GeoJSON + data: tests/data/ne_110m_lakes.geojson + id_field: id test-data: type: stac-collection @@ -159,14 +161,15 @@ resources: spatial: bbox: [-180,-90,180,90] crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84 - provider: - name: FileSystem - data: tests/data - file_types: - - .gpkg - - .sqlite - - .csv - - .grib2 + providers: + - type: stac + name: FileSystem + data: tests/data + file_types: + - .gpkg + - .sqlite + - .csv + - .grib2 hello-world: type: process diff --git a/pygeoapi/api.py b/pygeoapi/api.py index 7d02077..3cc9986 100644 --- a/pygeoapi/api.py +++ b/pygeoapi/api.py @@ -47,8 +47,9 @@ from pygeoapi.plugin import load_plugin, PLUGINS from pygeoapi.provider.base import ( ProviderGenericError, ProviderConnectionError, ProviderNotFoundError, ProviderQueryError, ProviderItemNotFoundError) -from pygeoapi.util import (dategetter, filter_dict_by_key_value, json_serial, - render_j2_template, TEMPLATES, to_json) +from pygeoapi.util import (dategetter, filter_dict_by_key_value, + get_provider_by_type, get_provider_default, + json_serial, render_j2_template, TEMPLATES, to_json) LOGGER = logging.getLogger(__name__) @@ -302,9 +303,12 @@ class API: LOGGER.debug('Creating collections') for k, v in collections.items(): + collection_data_type = get_provider_default( + v['providers'])['type'] + collection = {'links': []} collection['id'] = k - collection['itemType'] = 'Feature' + collection['itemType'] = collection_data_type.capitalize() collection['title'] = v['title'] collection['description'] = v['description'] collection['keywords'] = v['keywords'] @@ -346,42 +350,6 @@ class API: collection['links'].append(lnk) LOGGER.debug('Adding JSON and HTML link relations') - collection['links'].append({ - 'type': 'application/json', - 'rel': 'queryables', - 'title': 'Queryables for this collection as JSON', - 'href': '{}/collections/{}/queryables?f=json'.format( - self.config['server']['url'], k) - }) - collection['links'].append({ - 'type': 'text/html', - 'rel': 'queryables', - 'title': 'Queryables for this collection as HTML', - 'href': '{}/collections/{}/queryables?f=html'.format( - self.config['server']['url'], k) - }) - - collection['links'].append({ - 'type': 'application/geo+json', - 'rel': 'items', - 'title': 'items as GeoJSON', - 'href': '{}/collections/{}/items?f=json'.format( - self.config['server']['url'], k) - }) - collection['links'].append({ - 'type': 'application/ld+json', - 'rel': 'items', - 'title': 'items as RDF (GeoJSON-LD)', - 'href': '{}/collections/{}/items?f=jsonld'.format( - self.config['server']['url'], k) - }) - collection['links'].append({ - 'type': 'text/html', - 'rel': 'items', - 'title': 'Items as HTML', - 'href': '{}/collections/{}/items?f=html'.format( - self.config['server']['url'], k) - }) collection['links'].append({ 'type': 'application/json', 'rel': 'self' if not format_ @@ -405,6 +373,44 @@ class API: self.config['server']['url'], k) }) + if collection_data_type == 'feature': + LOGGER.debug('Adding feature based links') + collection['links'].append({ + 'type': 'application/json', + 'rel': 'queryables', + 'title': 'Queryables for this collection as JSON', + 'href': '{}/collections/{}/queryables?f=json'.format( + self.config['server']['url'], k) + }) + collection['links'].append({ + 'type': 'text/html', + 'rel': 'queryables', + 'title': 'Queryables for this collection as HTML', + 'href': '{}/collections/{}/queryables?f=html'.format( + self.config['server']['url'], k) + }) + collection['links'].append({ + 'type': 'application/geo+json', + 'rel': 'items', + 'title': 'items as GeoJSON', + 'href': '{}/collections/{}/items?f=json'.format( + self.config['server']['url'], k) + }) + collection['links'].append({ + 'type': 'application/ld+json', + 'rel': 'items', + 'title': 'items as RDF (GeoJSON-LD)', + 'href': '{}/collections/{}/items?f=jsonld'.format( + self.config['server']['url'], k) + }) + collection['links'].append({ + 'type': 'text/html', + 'rel': 'items', + 'title': 'Items as HTML', + 'href': '{}/collections/{}/items?f=html'.format( + self.config['server']['url'], k) + }) + if dataset is not None and k == dataset: fcm = collection break @@ -499,8 +505,8 @@ class API: LOGGER.debug('Creating collection queryables') LOGGER.debug('Loading provider') try: - p = load_plugin('provider', - self.config['resources'][dataset]['provider']) + p = load_plugin('provider', get_provider_by_type( + self.config['resources'][dataset]['providers'], 'feature')) except ProviderConnectionError: exception = { 'code': 'NoApplicableCode', @@ -723,8 +729,8 @@ class API: LOGGER.debug('Loading provider') try: - p = load_plugin('provider', - collections[dataset]['provider']) + p = load_plugin('provider', get_provider_by_type( + collections[dataset]['providers'], 'feature')) except ProviderConnectionError: exception = { 'code': 'NoApplicableCode', @@ -909,8 +915,9 @@ class API: content = formatter.write( data=content, options={ - 'provider_def': - collections[dataset]['provider'] + 'provider_def': get_provider_by_type( + collections[dataset]['providers'], + 'feature') } ) @@ -964,7 +971,8 @@ class API: return headers_, 400, json.dumps(exception) LOGGER.debug('Loading provider') - p = load_plugin('provider', collections[dataset]['provider']) + p = load_plugin('provider', get_provider_by_type( + collections[dataset]['providers'], 'feature')) try: LOGGER.debug('Fetching id {}'.format(identifier)) @@ -1141,7 +1149,8 @@ class API: LOGGER.debug('Loading provider') try: - p = load_plugin('provider', stac_collections[dataset]['provider']) + p = load_plugin('provider', get_provider_by_type( + stac_collections[dataset]['providers'], 'stac')) except ProviderConnectionError as err: LOGGER.error(err) exception = { diff --git a/pygeoapi/openapi.py b/pygeoapi/openapi.py index 4034a91..8a724f1 100644 --- a/pygeoapi/openapi.py +++ b/pygeoapi/openapi.py @@ -35,7 +35,8 @@ import click import yaml from pygeoapi.plugin import load_plugin -from pygeoapi.util import filter_dict_by_key_value, yaml_load +from pygeoapi.util import (filter_dict_by_key_value, get_provider_by_type, + yaml_load) LOGGER = logging.getLogger(__name__) @@ -407,7 +408,8 @@ def get_oas_30(cfg): } } - p = load_plugin('provider', collections[k]['provider']) + p = load_plugin('provider', get_provider_by_type( + collections[k]['providers'], 'feature')) if p.fields: queryables_path = '{}/queryables'.format(collection_name_path) diff --git a/pygeoapi/templates/collection.html b/pygeoapi/templates/collection.html index 3cafa71..d744d7f 100644 --- a/pygeoapi/templates/collection.html +++ b/pygeoapi/templates/collection.html @@ -19,6 +19,7 @@ {{ kw }} {% endfor %}

+ {% if data['itemType'] == 'Feature' %}

Queryables

+ {% endif %}

Links