Added example for MongoDB data provider (#798)

* - Added missing parameters on the openapi definition of get an observations tile request

* - changed default background map to osm

* Revert "- changed default background map to osm"

This reverts commit 554c065c6699ad6c0585f5c09ce34e746d5b3dc2.

* - Added example with docker containers, for MongoDB data provider

* - attempts

* - switched to use ne_110m_populated_places_simple.geojson as data source

* - updated README

* - updated README

Co-authored-by: doublebyte1 <info@doublebyte.net>
This commit is contained in:
Jo
2021-10-18 14:21:56 +02:00
committed by GitHub
parent aa416f984f
commit 722efb0374
6 changed files with 298 additions and 0 deletions
+2
View File
@@ -5,7 +5,9 @@ This folder contains the sub-folders:
- simple
- elastic
- sensorthings
- mongo
The [simple](simple) example will run pygeoapi with Docker with your local config.
The [elastic](elastic) example demonstrates a docker compose configuration to run pygeoapi with local ElasticSearch backend.
The [mongo](mongo) example demonstrates a docker compose configuration to run pygeoapi with local MongoDB backend.
The [sensorthings](sensorthings) example demonstrates various pygeoapi implementations of SensorThings API endpoints.
+19
View File
@@ -0,0 +1,19 @@
# pygeoapi with MongoDB
These folders contain a Docker Compose configuration necessary to setup a minimal
`pygeoapi` server that uses a local MongoDB backend service. Mongo Express is also provided, for convenience.
This config is only for local development and testing.
## MongoDB
- official MongoDB: **5.0.3** on **Ubuntu Focal**
- ports **27017**
## Building and Running
These composition does not require building any images. Run the [Docker compose file](docker-compose.yml) in localhost:
```
docker-compose up
```
+80
View File
@@ -0,0 +1,80 @@
# =================================================================
#
# Authors: Joana Simoes <jo@doublebyte.net>>
#
# Copyright (c) 2021 Joana Simoes
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================
version: '3.3'
services:
pygeoapi:
image: geopython/pygeoapi:latest
container_name: pygeoapi_mongo
entrypoint:
- /mongo-entrypoint.sh
ports:
- 5000:80
volumes:
- ./pygeoapi/docker.config.yml:/pygeoapi/local.config.yml
- ./pygeoapi/mongo-entrypoint.sh:/mongo-entrypoint.sh
- ./pygeoapi/wait-for-mongo.sh:/wait-for-mongo.sh
- datavolume:/pygeoapi/tests/data
links:
- mongo
depends_on:
- mongo
mongo:
image: mongo:5.0.3
container_name: mongo
ports:
- 27017:27017
volumes:
- ./docker-entrypoint-initdb.d/add_data.sh:/docker-entrypoint-initdb.d/add_data.sh:ro
- datavolume:/pygeoapi/tests/data
environment:
MONGO_INITDB_DATABASE: pop_places
mongo-express:
image: mongo-express
restart: always
container_name: mongo_express
links:
- mongo
depends_on:
- mongo
ports:
- 8081:8081
volumes:
datavolume: {}
@@ -0,0 +1,33 @@
#!/bin/bash
# =================================================================
#
# Authors: Joana Simoes <jo@doublebyte.net>
#
# Copyright (c) 2021 Joana Simoes
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================
jq --compact-output ".features" /pygeoapi/tests/data/ne_110m_populated_places_simple.geojson > /tmp/output.geojson;
mongoimport --db pop_places -c places --file "/tmp/output.geojson" --jsonArray
@@ -0,0 +1,118 @@
# =================================================================
#
# Authors: Joana Simoes <jo@doublebyte.net>
#
# Copyright (c) 2021 Joana Simoes
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================
# Default config for base Docker Image, override via DockerVolume
# mapping with your own config.
server:
bind:
host: 0.0.0.0
port: 80
url: http://localhost:5000
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 &copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
ogc_schemas_location: /schemas.opengis.net
logging:
level: ERROR
#logfile: /tmp/pygeoapi.log
metadata:
identification:
title: pygeoapi Demo instance - running latest GitHub version
description: pygeoapi provides an API to geospatial data
keywords:
- geospatial
- data
- api
keywords_type: theme
terms_of_service: https://creativecommons.org/licenses/by/4.0/
url: https://github.com/geopython/pygeoapi
license:
name: CC-BY 4.0 license
url: https://creativecommons.org/licenses/by/4.0/
provider:
name: pygeoapi Development Team
url: https://pygeoapi.io
contact:
name: Kralidis, Tom
position: Lead Dev
address: Mailing Address
city: City
stateorprovince: Administrative Area
postalcode: Zip or Postal Code
country: Canada
phone: +xx-xxx-xxx-xxxx
fax: +xx-xxx-xxx-xxxx
email: you@example.org
url: Contact URL
hours: Hours of Service
instructions: During hours of service. Off on weekends.
role: pointOfContact
resources:
ne_110m_populated_places_simple:
type: collection
title: ne_110m_populated_places_simple
description: Populated places of the world
keywords:
- Population, places
links:
- type: text/html
rel: canonical
title: information
href: http://www.naturalearthdata.com/
hreflang: en-US
extents:
spatial:
bbox: [-180,-90,180,90]
crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
temporal:
begin: 2011-11-11
end: null # or empty (either means open ended)
providers:
- type: feature
name: MongoDB
data: mongodb://mongo:27017/pop_places
collection: places
id_field: id
hello-world:
type: process
processor:
name: HelloWorld
+46
View File
@@ -0,0 +1,46 @@
#!/bin/sh
# =================================================================
#
# Authors: Joana Simoes <jo@doublebyte.net>
#
# Copyright (c) 2021 Joana Simoes
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================
set -e
cmd="$@"
: ${MONGO_HOST:=mongo}
: ${MONGO_PORT:=27017}
until nc -z $MONGO_HOST $MONGO_PORT
do
echo "Waiting for Mongo ($MONGO_HOST:$MONGO_PORT) to start..."
sleep 0.5
done
echo "Mongo has started!"
exec $cmd