diff --git a/workshop/content/docs/advanced/bridges.md b/workshop/content/docs/advanced/bridges.md new file mode 100644 index 00000000..7606250e --- /dev/null +++ b/workshop/content/docs/advanced/bridges.md @@ -0,0 +1,147 @@ +--- +title: pygeoapi as a Bridge to Other Services +--- + +# pygeoapi as a Bridge to Other Services + +In this section we explore how pygeoapi can be used as a facade, or a bridge, to re-publish web services with different interfaces. These bridges can help [organisations migrating from OWS to OGC API](https://ogcapi-workshop.ogc.org/transition-and-migration/). + +## Publishing WFS as OGC API - Features + +A powerful use case for pygeoapi is to provide an OGC API - Features interface over existing Web Feature Service (WFS) +or ESRI FeatureServer endpoints. In this scenario, you lower the barrier and increase the usability of existing services to +a wider audience. Let's set up an API on top of an existing WFS hosted by the city of Florence. + +!!! question "Update the pygeoapi configuration" + + Open the pygeoapi configuration in a text editor. + Find the line: + "# START - EXERCISE 2 - Proxy" + + Add a new dataset section by uncommenting the lines up to + "# END - EXERCISE 2 - Proxy": + + + ``` {.yaml linenums="1"} + suol_epicentri_storici: + type: collection + title: Epicenters of the main historical earthquakes + description: Location of the epicenters of the main historical earthquakes in the territory of the Metropolitan City of Florence classified by year and intensity + keywords: + - earthquakes + links: + - type: text/xml + rel: canonical + title: Epicenters of the main historical earthquakes + href: http://pubblicazioni.cittametropolitana.fi.it/geoserver/territorio/wfs?request=getCapabilities&service=WFS&version=2.0.0 + hreflang: it + extents: + spatial: + bbox: [10.94, 43.52, 11.65, 44.17] + crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84 + providers: + - type: feature + name: OGR + data: + source_type: WFS + source: WFS:http://pubblicazioni.cittametropolitana.fi.it/geoserver/territorio/wfs? + source_capabilities: + paging: True + source_options: + OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO + gdal_ogr_options: + EMPTY_AS_NULL: NO + GDAL_CACHEMAX: 64 + CPL_DEBUG: NO + id_field: cpti_id + crs: + - http://www.opengis.net/def/crs/OGC/1.3/CRS84 + - http://www.opengis.net/def/crs/EPSG/0/4258 + - http://www.opengis.net/def/crs/EPSG/0/3857 + - http://www.opengis.net/def/crs/EPSG/0/3003 + storage_crs: http://www.opengis.net/def/crs/EPSG/0/3003 + title_field: d + layer: territorio:suol_epicentri_storici + ``` + +Save the file and restart Docker Compose. Navigate to `http://localhost:5000/collections` +to evaluate whether the new dataset has been published. + +Note these important configuration slices under `providers`: + +* We use the pygeoapi [OGR Provider](https://docs.pygeoapi.io/en/latest/data-publishing/ogcapi-features.html#ogr). +This is the most versatile backend of pygeoapi for supporting numerous formats. Using the GDAL/OGR library (Python bindings) allows pygeoapi to connect to [around 80+ Vector Formats](https://gdal.org/drivers/vector). +We could have used the `OGR` Provider instead of the `SQLiteGPKG` Provider above in the `osm_places-vec` exercise above. + +* `storage_crs` denotes the CRS (Coordinate Reference System) in which the dataset is stored (default is CRS84, i.e. 'longitude, latitude') +* `crs` is an array of CRSs that can be specified for the Features to be returned (`crs=` parameter), or for their bounding box (`bbox-crs=` parameter). Default is also CRS84. + +CRS support effectively allows pygeoapi to *reproject* the data from its storage CRS (here EPSG:3003) +according to [OGC API - Features - Part 2: Coordinate Reference Systems by Reference](https://docs.opengeospatial.org/is/18-058r1/18-058r1.html). +The Advanced section of this workshop will further [elaborate pygeoapi CRS support](../advanced/crs.md). + + +## Publishing WMS as OGC API - Maps + +We can use the pygeoapi's WMSFacade provider as a bridge to serve an OGC WMS via OGC API - Maps. + +We can use the MapServer demo server at: + +!!! note + + Feel free to use a WMS of your choice as you wish! + +!!! question "Update the pygeoapi configuration" + + Open the pygeoapi configuration file in a text editor. + + Find the line: "# START - EXERCISE 5 - Maps". + + Uncomment or paste the configuration snippet below until the line that reads "## END - EXERCISE 5 - Maps". Be sure to keep the proper YAML indentation. + + ``` {.yaml linenums="1"} + wms-facade-demo: + type: collection + title: WMS Facade demo + description: WMS Facade demo + keywords: + - WMS facade + links: + - type: text/html + rel: canonical + title: MapServer + href: https://mapserver.org + hreflang: en + extents: + spatial: + bbox: [-180,-90,180,90] + crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84 + providers: + - type: map + name: WMSFacade + data: https://demo.mapserver.org/cgi-bin/msautotest + options: + layer: world_latlong + style: default + format: + name: png + mimetype: image/png + ``` + +Run the following requests in your web browser: + +- default map: [http://localhost:5000/collections/wms-facade-demo/map?f=png](http://localhost:5000/collections/wms-facade-demo/map?f=png) +- specific width/height: [http://localhost:5000/collections/wms-facade-demo/map?f=png&width=800&height=600](http://localhost:5000/collections/wms-facade-demo/map?f=png&width=800&height=600) +- specific area of interest (bbox of Canada): [http://localhost:5000/collections/wms-facade-demo/map?f=png&width=800&height=600](http://localhost:5000/collections/wms-facade-demo/map?f=png&bbox=-142,42,-52,84) + +!!! tip + + Try with your own bbox and width/height values! + +## Publishing CSW as OGC API - Records + +TODO + +## Publishing SensorThings API as OGC API - Features + +TODO \ No newline at end of file diff --git a/workshop/content/docs/advanced/index.md b/workshop/content/docs/advanced/index.md index 0ca26840..1de78318 100644 --- a/workshop/content/docs/advanced/index.md +++ b/workshop/content/docs/advanced/index.md @@ -16,3 +16,4 @@ focused on extending pygeoapi via custom development and deployment. - [Semantic Web and Linked Data](semantic-web-linked-data.md) - [Cloud deployment](cloud.md) - [INSPIRE support](inspire.md) +- [pygeoapi as a Bridge to Other Services](bridges.md) diff --git a/workshop/content/docs/publishing/ogcapi-features.md b/workshop/content/docs/publishing/ogcapi-features.md index a398f518..09806612 100644 --- a/workshop/content/docs/publishing/ogcapi-features.md +++ b/workshop/content/docs/publishing/ogcapi-features.md @@ -86,77 +86,7 @@ title *"Places in Kosovo 2023"* has been published. ## pygeoapi as a WFS proxy -A powerful use case for pygeoapi is to provide an OGC API - Features interface over existing Web Feature Service (WFS) -or ESRI FeatureServer endpoints. In this scenario, you lower the barrier and increase the usability of existing services to -a wider audience. Let's set up an API on top of an existing WFS hosted by the city of Florence. - -!!! question "Update the pygeoapi configuration" - - Open the pygeoapi configuration in a text editor. - Find the line: - "# START - EXERCISE 2 - Proxy" - - Add a new dataset section by uncommenting the lines up to - "# END - EXERCISE 2 - Proxy": - - - ``` {.yaml linenums="1"} - suol_epicentri_storici: - type: collection - title: Epicenters of the main historical earthquakes - description: Location of the epicenters of the main historical earthquakes in the territory of the Metropolitan City of Florence classified by year and intensity - keywords: - - earthquakes - links: - - type: text/xml - rel: canonical - title: Epicenters of the main historical earthquakes - href: http://pubblicazioni.cittametropolitana.fi.it/geoserver/territorio/wfs?request=getCapabilities&service=WFS&version=2.0.0 - hreflang: it - extents: - spatial: - bbox: [10.94, 43.52, 11.65, 44.17] - crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84 - providers: - - type: feature - name: OGR - data: - source_type: WFS - source: WFS:http://pubblicazioni.cittametropolitana.fi.it/geoserver/territorio/wfs? - source_capabilities: - paging: True - source_options: - OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO - gdal_ogr_options: - EMPTY_AS_NULL: NO - GDAL_CACHEMAX: 64 - CPL_DEBUG: NO - id_field: cpti_id - crs: - - http://www.opengis.net/def/crs/OGC/1.3/CRS84 - - http://www.opengis.net/def/crs/EPSG/0/4258 - - http://www.opengis.net/def/crs/EPSG/0/3857 - - http://www.opengis.net/def/crs/EPSG/0/3003 - storage_crs: http://www.opengis.net/def/crs/EPSG/0/3003 - title_field: d - layer: territorio:suol_epicentri_storici - ``` - -Save the file and restart Docker Compose. Navigate to `http://localhost:5000/collections` -to evaluate whether the new dataset has been published. - -Note these important configuration slices under `providers`: - -* We use the pygeoapi [OGR Provider](https://docs.pygeoapi.io/en/latest/data-publishing/ogcapi-features.html#ogr). -This is the most versatile backend of pygeoapi for supporting numerous formats. Using the GDAL/OGR library (Python bindings) allows pygeoapi to connect to [around 80+ Vector Formats](https://gdal.org/drivers/vector). -We could have used the `OGR` Provider instead of the `SQLiteGPKG` Provider above in the `osm_places-vec` exercise above. - -* `storage_crs` denotes the CRS (Coordinate Reference System) in which the dataset is stored (default is CRS84, i.e. 'longitude, latitude') -* `crs` is an array of CRSs that can be specified for the Features to be returned (`crs=` parameter), or for their bounding box (`bbox-crs=` parameter). Default is also CRS84. - -CRS support effectively allows pygeoapi to *reproject* the data from its storage CRS (here EPSG:3003) -according to [OGC API - Features - Part 2: Coordinate Reference Systems by Reference](https://docs.opengeospatial.org/is/18-058r1/18-058r1.html). -The Advanced section of this workshop will further [elaborate pygeoapi CRS support](../advanced/crs.md). +You can check the "pygeoapi as a Bridge to Other Services" section to learn how to [publish WFS as OGC API - Features](../../advanced/bridges/#publishing-wfs-as-ogc-api-features). ## Client access diff --git a/workshop/content/docs/publishing/ogcapi-maps.md b/workshop/content/docs/publishing/ogcapi-maps.md index 88737bb6..b4d13bac 100644 --- a/workshop/content/docs/publishing/ogcapi-maps.md +++ b/workshop/content/docs/publishing/ogcapi-maps.md @@ -17,62 +17,9 @@ pygeoapi supports the OGC API - Maps draft specification, using [MapServer MapSc See [the official documentation](https://docs.pygeoapi.io/en/latest/data-publishing/ogcapi-maps.html) for more information on supported map backends -## Serve a WMS via OGC API - Maps +## pygeoapi as a WMS proxy -Let's use pygeoapi's WMSFacade provider as a bridge to serve an OGC WMS via OGC API - Maps. - -We can use the MapServer demo server at https://demo.mapserver.org/cgi-bin/msautotest - -!!! note - - Feel free to use a WMS of your choice as you wish! - -!!! question "Update the pygeoapi configuration" - - Open the pygeoapi configuration file in a text editor. - - Find the line: "# START - EXERCISE 5 - Maps". - - Uncomment or paste the configuration snippet below until the line that reads "## END - EXERCISE 5 - Maps". Be sure to keep the proper YAML indentation. - - ``` {.yaml linenums="1"} - wms-facade-demo: - type: collection - title: WMS Facade demo - description: WMS Facade demo - keywords: - - WMS facade - links: - - type: text/html - rel: canonical - title: MapServer - href: https://mapserver.org - hreflang: en - extents: - spatial: - bbox: [-180,-90,180,90] - crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84 - providers: - - type: map - name: WMSFacade - data: https://demo.mapserver.org/cgi-bin/msautotest - options: - layer: world_latlong - style: default - format: - name: png - mimetype: image/png - ``` - -Run the following requests in your web browser: - -- default map: [http://localhost:5000/collections/wms-facade-demo/map?f=png](http://localhost:5000/collections/wms-facade-demo/map?f=png) -- specific width/height: [http://localhost:5000/collections/wms-facade-demo/map?f=png&width=800&height=600](http://localhost:5000/collections/wms-facade-demo/map?f=png&width=800&height=600) -- specific area of interest (bbox of Canada): [http://localhost:5000/collections/wms-facade-demo/map?f=png&width=800&height=600](http://localhost:5000/collections/wms-facade-demo/map?f=png&bbox=-142,42,-52,84) - -!!! tip - - Try with your own bbox and width/height values! +You can check the "pygeoapi as a Bridge to Other Services" section to learn how to [publish WMS as OGC API - Maps](../../advanced/bridges/#publishing-wms-as-ogc-api-maps). ## Client access diff --git a/workshop/content/docs/publishing/ogcapi-records.md b/workshop/content/docs/publishing/ogcapi-records.md index 970806bb..31f83fb1 100644 --- a/workshop/content/docs/publishing/ogcapi-records.md +++ b/workshop/content/docs/publishing/ogcapi-records.md @@ -89,6 +89,10 @@ python3 load_tinydb_records.py xml catalogue.tinydb ``` +## pygeoapi as a CSW proxy + +You can check the "pygeoapi as a Bridge to Other Services" section to learn how to [publish CSW as OGC API - Records](../../advanced/bridges/#publishing-csw-as-ogc-api-records). + ## Client access ### QGIS diff --git a/workshop/content/mkdocs.yml b/workshop/content/mkdocs.yml index 22226562..454aebd5 100644 --- a/workshop/content/mkdocs.yml +++ b/workshop/content/mkdocs.yml @@ -29,6 +29,7 @@ nav: - Semantic Web and Linked Data: advanced/semantic-web-linked-data.md - Cloud deployment: advanced/cloud.md - INSPIRE support: advanced/inspire.md + - pygeoapi as a Bridge to Other Services: advanced/bridges.md - Conclusion: conclusion.md use_directory_urls: true