-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from doublebyte1/dev-051223
Added Bridge section that shows how to proxy OWS and other services in pygeoapi
- Loading branch information
Showing
6 changed files
with
156 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: <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! | ||
|
||
## Publishing CSW as OGC API - Records | ||
|
||
TODO | ||
|
||
## Publishing SensorThings API as OGC API - Features | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters