Skip to content

Commit

Permalink
add Linux/Mac and Windows tabs, editorial updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Dec 15, 2023
1 parent 02a3b55 commit f3c5bd1
Show file tree
Hide file tree
Showing 17 changed files with 224 additions and 116 deletions.
28 changes: 10 additions & 18 deletions workshop/content/docs/advanced/bridges.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: Exercise 8 - pygeoapi as a bridge to other services
title: Exercise 9 - pygeoapi as a bridge to other services
---

# Exercise 8 - pygeoapi as a bridge to other services
# Exercise 9 - 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).

Expand All @@ -15,11 +15,9 @@ a wider audience. Let's set up an API on top of an existing WFS hosted by the ci
!!! question "Update the pygeoapi configuration"

Open the pygeoapi configuration in a text editor.
Find the line:
"# START - EXERCISE 8 - WFS Proxy"
Find the line `# START - EXERCISE 8 - WFS Proxy`.

Add a new dataset section by uncommenting the lines up to
"# END - EXERCISE 8 - WFS Proxy":
Add a new dataset section by uncommenting the lines up to `# END - EXERCISE 8 - WFS Proxy`:


``` {.yaml linenums="1"}
Expand Down Expand Up @@ -97,11 +95,9 @@ We can use the pygeoapi's WMSFacade provider to publish OGC Web Map Service (WMS
!!! question "Update the pygeoapi configuration"

Open the pygeoapi configuration in a text editor.
Find the line:
"## START - EXERCISE 8 - WMS Proxy"
Find the line `## START - EXERCISE 8 - WMS Proxy`.

Add a new dataset section by uncommenting the lines up to
"## END - EXERCISE 8 - WMS Proxy":
Add a new dataset section by uncommenting the lines up to `## END - EXERCISE 8 - WMS Proxy`:

Be sure to keep the proper YAML indentation.

Expand Down Expand Up @@ -153,11 +149,9 @@ In this section we'll have a look at how to publish Catalogue Service for the We
!!! question "Update the pygeoapi configuration"

Open the pygeoapi configuration in a text editor.
Find the line:
"# START - EXERCISE 8 - CSW Proxy"
Find the line `# START - EXERCISE 8 - CSW Proxy`.

Add a new dataset section by uncommenting the lines up to
"# END - EXERCISE 8 - CSW Proxy":
Add a new dataset section by uncommenting the lines up to `# END - EXERCISE 8 - CSW Proxy`:

``` {.yaml linenums="1"}
cite_demo:
Expand Down Expand Up @@ -203,11 +197,9 @@ In this section we'll have a look at how to Publish a SensorThings API `Thing` a
!!! question "Update the pygeoapi configuration"

Open the pygeoapi configuration in a text editor.
Find the line:
"# START - EXERCISE 8 - SensorThings Proxy"
Find the line `# START - EXERCISE 8 - SensorThings Proxy`.

Add a new dataset section by uncommenting the lines up to
"# END - EXERCISE 8 - SensorThings Proxy":
Add a new dataset section by uncommenting the lines up to `# END - EXERCISE 8 - SensorThings Proxy`:

``` {.yaml linenums="1"}
toronto_bikes:
Expand Down
35 changes: 24 additions & 11 deletions workshop/content/docs/advanced/cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,36 @@ A [Docker image](https://hub.docker.com/r/geopython/pygeoapi) is available for p

<div class="termy">
```bash
docker run -p 5000:80 https://hub.docker.com/r/geopython/pygeoapi:latest
docker run -p 5000:80 geopython/pygeoapi:latest
```
</div>

!!! question "Review the pygeoapi docker file"
!!! question "Review the pygeoapi Dockerfile"

Notice in the [pygeoapi docker file](https://github.com/geopython/pygeoapi/Dockerfile) how the open api file is generated as part of the docker startup script.
Notice in the [pygeoapi Dockerfile](https://github.com/geopython/pygeoapi/Dockerfile) how the open api file is generated as part of the Docker startup script.

In a typical configuration one would override the default pygeoapi configuration file in the image with a customized one and include the data folder
In a typical configuration one would override the default pygeoapi configuration file in the image with a customized one and include the data folder:

!!! example "using custom configuration"

=== "Linux/Mac"

<div class="termy">
```bash
docker run -p 5000:80 \
-v $(pwd)/pygeoapi-config.yml:/pygeoapi/local.config.yml \
-v $(pwd)/geodata:/geodata https://hub.docker.com/r/geopython/pygeoapi:latest
```
</div>

=== "Windows"

<div class="termy">
```bash
docker run -p 5000:80 -v ${pwd}/pygeoapi-config.yml:/pygeoapi/local.config.yml -v ${pwd}/geodata:/geodata https://hub.docker.com/r/geopython/pygeoapi:latest
```
</div>

<div class="termy">
```bash
docker run -p 5000:80 \
-v $(pwd)/pygeoapi-config.yml:/pygeoapi/local.config.yml \
-v $(pwd)/geodata:/geodata https://hub.docker.com/r/geopython/pygeoapi:latest
```
</div>

Alternatively, you can build a fresh Docker image including both the configuration and data for the service.

Expand Down
3 changes: 1 addition & 2 deletions workshop/content/docs/advanced/crs.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ in CRSs like `http://www.opengis.net/def/crs/EPSG/0/4258` (ETRS89 latitude, long
!!! question "Add CRS to a pygeoapi configuration"

Open the pygeoapi configuration file in a text editor.
Find the line:
"# START - EXERCISE 2 - firenze-terrains"
Find the line `# START - EXERCISE 2 - firenze-terrain`

Update the dataset section with CRS support by replacing it with the snippet below:

Expand Down
17 changes: 17 additions & 0 deletions workshop/content/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ Exercises are indicated as follows:

A section marked like this indicates that you can try out the exercise.

!!! example "Example exercise with tabs"

A section marked like this indicates that you can try out the exercise and choose your environment (Linux/Mac or Windows).

=== "Linux/Mac"
<div class="termy">
```bash
docker run -p 5000:80 -v $(pwd)/default.config.yml:/pygeoapi/local.config.yml geopython/pygeoapi:latest
```
</div>
=== "Windows"
<div class="termy">
```bash
docker run -p 5000:80 -v ${pwd}/default.config.yml:/pygeoapi/local.config.yml geopython/pygeoapi:latest
```
</div>

Also you will notice tips and notes sections within the text:

!!! tip
Expand Down
2 changes: 1 addition & 1 deletion workshop/content/docs/publishing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ through the following exercises:
- [Exercise 6 - Metadata via OGC API - Records](ogcapi-records.md)
- [Exercise 7 - Environmental data via OGC API - Environmental Data Retrieval](ogcapi-edr.md)
- [Exercise 8 - Functions via OGC API - Processes](ogcapi-processes.md)
- [Exercise 9 - Functions via OGC API - Processes](ogcapi-processes.md)
- [Exercise 9 - pygeoapi as a bridge to other services](../advanced/bridges.md)
2 changes: 2 additions & 0 deletions workshop/content/docs/publishing/ogcapi-coverages.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ unzip 53.zip
```
</div>

If you do not have curl installed, copy the URL above to your web browser and save locally.

You can now add `53_ED1_G.tif` to pygeoapi:

!!! question "Update the pygeoapi configuration"
Expand Down
15 changes: 13 additions & 2 deletions workshop/content/docs/publishing/ogcapi-edr.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,22 @@ Let's try publishing some ICOADS data via the EDR xarray plugin. The sample ICOA

Save the configuration and restart Docker Compose. Navigate to <http://localhost:5000/collections> to evaluate whether the new dataset has been published.

At first glance, the `icoads-sst` collection appears as a normal OGC API - Coverages collection. Let's look a bit closer at the colleciton description:
At first glance, the `icoads-sst` collection appears as a normal OGC API - Coverages collection. Let's look a bit closer at the collection description:

# Client access

Currently there is no support for EDR in common tooling. The example below provides a generic workflow using the [Python requests library](https://requests.readthedocs.io):
!!! question "Interact with OGC API - Environmental Data Retrieval via Python requests"

If you do not have Python installed, consider running this exercise in a Docker container. See the [Setup Chapter](../setup.md#using-docker-for-python-clients).

<div class="termy">
```bash
pip3 install requests
```
</div>


Currently there is limited client support for EDR. The example below provides a generic workflow using the [Python requests library](https://requests.readthedocs.io):

<div class="termy">
```python
Expand Down
12 changes: 5 additions & 7 deletions workshop/content/docs/publishing/ogcapi-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ Let's add the file `workshop/exercises/data/osm_places_kosovo.gpkg`:
!!! question "Update the pygeoapi configuration"

Open the pygeoapi configuration file in a text editor.
Find the line:
"# START - EXERCISE 2 - osm_places"
Find the line `# START - EXERCISE 2 - osm_places`.

Add a new dataset section by uncommenting the lines up to
"# END - EXERCISE 2 - osm_places":
Add a new dataset section by uncommenting the lines up to `# END - EXERCISE 2 - osm_places`:

``` {.yaml linenums="1"}
osm_places-vec:
Expand Down Expand Up @@ -107,7 +105,7 @@ docker-compose up
```
</div>

This configuration snippet, enables publishing greater_hyderabad_municipal_corporation_ward_boundaries.geojson as OGC API - Features:
This configuration snippet, enables publishing the file `greater_hyderabad_municipal_corporation_ward_boundaries.geojson` as OGC API - Features:

``` {.yaml linenums="1"}
greater_hyderabad_municipal_corporation_ward_boundaries:
Expand Down Expand Up @@ -194,7 +192,7 @@ QGIS is one of the first GIS Desktop clients which added support for OGC API - F

!!! tip

Install and activate the `QGIS Network Logger` extension. It will display HTTP traffic within QGIS and is a valuable tool in debugging failing connections.
Activate the `Debugging/Development Tools Panel` (right click anywhere on the toolbar icons and select). It will display HTTP traffic within QGIS and is a valuable tool in debugging failing connections.

!!! note

Expand Down Expand Up @@ -241,7 +239,7 @@ QGIS is one of the first GIS Desktop clients which added support for OGC API - F
```
</div>

Then start a Python console session with: `python` (stop the session by typing `exit()`).
Then start a Python console session with: `python3` (stop the session by typing `exit()`).

<div class="termy">
```python
Expand Down
2 changes: 1 addition & 1 deletion workshop/content/docs/publishing/ogcapi-maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In this section we'll be exposing a Geopackage file available at `workshop/exerc

!!! question "Interact with OGC API - Maps via MapScript"

Open the pygeoapi configuration file in a text editor. Find the line: "# START - EXERCISE 5 - Maps".
Open the pygeoapi configuration file in a text editor. Find the line `# START - EXERCISE 5 - Maps`.

Uncomment section related to #airports.

Expand Down
36 changes: 35 additions & 1 deletion workshop/content/docs/publishing/ogcapi-records.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,40 @@ python3 load_tinydb_records.py xml catalogue.tinydb
```
</div>

If you do not have curl installed, copy the URL above to your web browser and save locally.

If you do not have Python installed, you can the loader by using the OWSLib Docker container. See the [Setup Chapter](../setup.md#using-docker-for-python-clients).

!!! example "Using the OWSLib Docker container to load metadata"

=== "Linux/Mac"
<div class="termy">
```bash
cd workshop/exercises
docker run -it --rm --network=host --name owslib -v $(pwd)/data:/data python:3.10-slim /bin/bash
pip3 install owslib
apt-get update -y && apt-get install curl -y
curl -O https://raw.githubusercontent.com/geopython/pygeoapi/master/tests/load_tinydb_records.py
python3 load_tinydb_records.py /data/records/xml /data/records/catalogue.tinydb
```
</div>

=== "Windows"
<div class="termy">
```bash
cd workshop/exercises
docker run -it --rm --network=host --name owslib -v $(pwd)/data:/data python:3.10-slim /bin/bash
pip3 install owslib
apt-get update -y && apt-get install curl -y
curl -O https://raw.githubusercontent.com/geopython/pygeoapi/master/tests/load_tinydb_records.py
python3 load_tinydb_records.py /data/records/xml /data/records/catalogue.tinydb
```
</div>


Navigate to <http://localhost:5000/collections/example_catalogue> to evaluate whether the new metadata has been published
to the collection.

## 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).
Expand Down Expand Up @@ -129,7 +163,7 @@ QGIS supports OGC API - Records via the [MetaSearch plugin](https://docs.qgis.or
```
</div>

Then start a Python console session with: `python` (stop the session by typing `exit()`).
Then start a Python console session with: `python3` (stop the session by typing `exit()`).

<div class="termy">
```python
Expand Down
52 changes: 35 additions & 17 deletions workshop/content/docs/publishing/ogcapi-tiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,39 @@ include, but are not limited to:
* [QGIS](https://www.qgistutorials.com/en/docs/creating_basemaps_with_qtiles.html)
* [tippecanoe](https://github.com/mapbox/tippecanoe)

For this exercise, you will publish a vector dataset of the [greater hyderabad municipal corporation ward boundaries](https://livingatlas-dcdev.opendata.arcgis.com/datasets/a090c89d52f1498f96a82e97b8bfb83e_0/about), from the location below:
For this exercise, you will publish a vector dataset of the [greater Hyderabad municipal corporation ward boundaries](https://livingatlas-dcdev.opendata.arcgis.com/datasets/a090c89d52f1498f96a82e97b8bfb83e_0/about), from the location below:

* data: `workshop/exercises/data/greater_hyderabad_municipal_corporation_ward_Boundaries.geojson`

Let's generate the tiles as the first step using tippecanoe:

<div class="termy">
```bash
cd workshop/exercises
docker run -it --rm -v ${PWD}/data:/data emotionalcities/tippecanoe \
tippecanoe --output-to-directory=/data/tiles/ --force --maximum-zoom=16 --drop-densest-as-needed --extend-zooms-if-still-dropping --no-tile-compression /data/greater_hyderabad_municipal_corporation_ward_Boundaries.geojson
```
</div>
!!! example "Using tippecanoe to generate vector tiles"

=== "Linux/Mac"

<div class="termy">
```bash
cd workshop/exercises
docker run -it --rm -v $(pwd)/data:/data emotionalcities/tippecanoe \
tippecanoe --output-to-directory=/data/tiles/ --force --maximum-zoom=16 --drop-densest-as-needed --extend-zooms-if-still-dropping --no-tile-compression /data/greater_hyderabad_municipal_corporation_ward_Boundaries.geojson
```
</div>
=== "Windows"

<div class="termy">
```bash
cd workshop/exercises
docker run -it --rm -v ${pwd}/data:/data emotionalcities/tippecanoe tippecanoe --output-to-directory=/data/tiles/ --force --maximum-zoom=16 --drop-densest-as-needed --extend-zooms-if-still-dropping --no-tile-compression /data/greater_hyderabad_municipal_corporation_ward_Boundaries.geojson
```
</div>

!!! question "Update the pygeoapi configuration"

Open the pygeoapi configuration in a text editor. Add a new dataset section as follows:

``` {.yaml linenums="1"}
Hyderabad:
hyderabad:
type: collection
title: Greater Hyderabad Municipal Corporation ward boundaries
description: The city ward boundaries represent the administrative and electoral boundary areas of the city. It plays a great role in planning of the city, for each council of the municipal corporation.
Expand Down Expand Up @@ -102,8 +115,8 @@ Save the file and restart Docker Compose. Navigate to <http://localhost:5000/col

Additional check for the following tile specific endpoints in the `Hyderabad` collection:

- tile links in <http://localhost:5000/collections/Hyderabad/tiles>
- tile metadata in <http://localhost:5000/collections/Hyderabad/tiles/WorldCRS84Quad/metadata>
- tile links in <http://localhost:5000/collections/hyderabad/tiles>
- tile metadata in <http://localhost:5000/collections/hyderabad/tiles/WorldCRS84Quad/metadata>

![TileSet](../assets/images/vtiles-hyderabad.png)

Expand Down Expand Up @@ -185,10 +198,10 @@ QGIS supports OGC API Vector Tiles via the [Vector Tiles Layer](https://docs.qgi

Before entering QGIS, access your pygeoapi installation page on the browser and follow these steps.

- access the collection page of the tiles dataset: <http://localhost:5000/collections/Hyderabad>
- navigate to the tiles page by clicking on `tiles`: <http://localhost:5000/collections/Hyderabad/tiles>
- click in `Tiles metadata in tilejson format`: `http://localhost:5000/collections/Cycle/Hyderabad/WorldCRS84Quad/metadata>
- note the URL in `tiles`: `http://localhost:5000/collections/Hyderabad/tiles/WorldCRS84Quad/{tileMatrix}/{tileRow}/{tileCol}?f=mvt` and of the values of minZoom and maxZoom
- access the collection page of the tiles dataset: <http://localhost:5000/collections/hyderabad>
- navigate to the tiles page by clicking on `tiles`: <http://localhost:5000/collections/hyderabad/tiles>
- click in `Tiles metadata in tilejson format`: <http://localhost:5000/collections/Cycle/hyderabad/WorldCRS84Quad/metadata>
- note the URL in `tiles`: `http://localhost:5000/collections/hyderabad/tiles/WorldCRS84Quad/{tileMatrix}/{tileRow}/{tileCol}?f=mvt` and of the values of minZoom and maxZoom

Follow these steps to connect to a service and access vector tiles:

Expand Down Expand Up @@ -259,7 +272,7 @@ QGIS supports OGC API Vector Tiles via the [Vector Tiles Layer](https://docs.qgi
interactive: true,
vectorTileLayerStyles: vectorTileStyling,
};
var pbfURL='http://localhost:5000/collections/Hyderabad/tiles/WorldCRS84Quad/{z}/{x}/{y}?f=mvt';
var pbfURL='http://localhost:5000/collections/hyderabad/tiles/WorldCRS84Quad/{z}/{x}/{y}?f=mvt';
var pbfLayer=L.vectorGrid.protobuf(pbfURL,mapVectorTileOptions).on('click',function(e) {
console.log(e.layer);
L.DomEvent.stop(e);
Expand All @@ -274,7 +287,7 @@ QGIS supports OGC API Vector Tiles via the [Vector Tiles Layer](https://docs.qgi
!!! tip
Try adding a [different pygeoapi vector tiles layer](https://demo.pygeoapi.io/master/collections/lakes/tiles/WorldCRS84Quad/metadata) by updating the code in `workshop/exercises/html/vector-tiles.html`.

If you want to render the tiles from the [elasticSearch example](#publish-vector-tiles-from-elasticsearch), you can check out the code from [this](https://github.com/doublebyte1/vtiles-example/blob/ogcapi-ws/demo-oat.htm) repository:
If you want to render the tiles from the [Elasticsearch example](#publish-vector-tiles-from-elasticsearch), you can check out the code from [this](https://github.com/doublebyte1/vtiles-example/blob/ogcapi-ws/demo-oat.htm) repository:
<div class="termy">
```bash
git clone -b ogcapi-ws https://github.com/doublebyte1/vtiles-example.git
Expand All @@ -283,6 +296,11 @@ QGIS supports OGC API Vector Tiles via the [Vector Tiles Layer](https://docs.qgi

![](../assets/images/leaflet-hyderabad2.png){ width=100% }

!!! tip

See the [official LeafletJS documentation](https://leafletjs.com/reference.html)


### OpenLayers

[OpenLayers](https://openlayers.org) is a popular JavaScript library to add interactive maps to websites. OpenLayers natively supports OGC API - Tiles.
Expand Down
Loading

0 comments on commit f3c5bd1

Please sign in to comment.