Skip to content

Commit

Permalink
Postgis provider support (#72)
Browse files Browse the repository at this point in the history
* 	new file:   docker/Dockerfile
Dockerfile for pygeoapi

* testing postgis on travis

* testing 9.6

* install postgis as package

* create database

* postgis dataset - travis

* missing path

* 	modified:   tests/data/hotosm_bdi_waterways.sql.gz

Change in name of dataset

* postgresql code

* 	modified:   pygeoapi/provider/postgresql.py
update with origin

* Postgresql working provider, typo in geopackage

* update to travis. Change on gpkg

* missing dep (psycopg2)

* pytest

* problem with operator in travis

* ProviderConnectionError implementation

* postgresql with schema support

* Changes requested by @tomkralidis

* missing pygeoapi-config.yml

* delete openapi.yml

deleted openapi.yml
  • Loading branch information
Jorge Samuel Mendes de Jesus authored and tomkralidis committed Nov 16, 2018
1 parent 30d09fb commit c621b21
Show file tree
Hide file tree
Showing 11 changed files with 419 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Expand Up @@ -8,10 +8,17 @@ python:

services:
- elasticsearch
- postgresql

addons:
postgresql: 9.6


before_install:
- sudo apt-get -qq update
- sudo apt-get install -y libsqlite3-mod-spatialite pandoc devscripts
- sudo apt-get install -y postgresql-9.6-postgis-2.4


install:
- pip install -r requirements.txt
Expand All @@ -25,6 +32,9 @@ before_script:
- sleep 20
- python tests/load_es_data.py tests/data/ne_110m_populated_places_simple.geojson
- pygeoapi generate-openapi-document -c pygeoapi-config.yml > pygeoapi-openapi.yml
- psql -U postgres -c 'create database test'
- psql -U postgres -d test -c 'create extension postgis'
- gunzip < tests/data/hotosm_bdi_waterways.sql.gz | psql -U postgres test

script:
- pytest --cov=pygeoapi
Expand Down
26 changes: 26 additions & 0 deletions docker/Dockerfile
@@ -0,0 +1,26 @@
FROM frolvlad/alpine-python3

RUN apk update && apk add --no-cache \
git \
python3-dev \
libffi \
libffi-dev \
musl-dev \
gcc \
openssl-dev \
g++


RUN git clone https://github.com/geopython/pygeoapi.git

ENV PYGEOAPI_CONFIG=/pygeoapi/local.yml

WORKDIR /pygeoapi
RUN pip3 install -r requirements.txt
RUN pip3 install -r requirements-dev.txt
RUN pip3 install -e .
RUN cp pygeoapi-config.yml local.yml
#export PYGEOAPI_CONFIG=`pwd`/local.yml

ENTRYPOINT ["/usr/bin/python3", "/pygeoapi/pygeoapi/app.py"]

35 changes: 35 additions & 0 deletions pygeoapi-config.yml
Expand Up @@ -190,4 +190,39 @@ datasets:
data: tests/data/poi_portugal.gpkg
id_field: osm_id
table: poi_portugal

hotosm_bdi_waterways:
title: Waterways of Burundi
description: Waterways of Burundi, Africa. Dataset timestamp 1st Sep 2018 - Humanitarian OpenStreetMap Team (HOT)
keywords:
- Burundi
- Waterways
- Africa
- OSM
- HOT
crs:
- CRS84
links:
- type: text/html
rel: canonical
title: information
href: https://data.humdata.org/dataset/hotosm_bdi_waterways
hreflang: en-US
extents:
spatial:
bbox: [28.9845376683957 -4.48174334765485,30.866396969019 -2.3096796]
temporal:
begin: None
end: now # 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

1 change: 1 addition & 0 deletions pygeoapi/provider/__init__.py
Expand Up @@ -37,6 +37,7 @@
'Elasticsearch': 'pygeoapi.provider.elasticsearch_.ElasticsearchProvider',
'GeoJSON': 'pygeoapi.provider.geojson.GeoJSONProvider',
'GeoPackage': 'pygeoapi.provider.geopackage.GeoPackageProvider',
'PostgreSQL': 'pygeoapi.provider.postgresql.PostgreSQLProvider',
'SQLite': 'pygeoapi.provider.sqlite.SQLiteProvider'
}

Expand Down
3 changes: 1 addition & 2 deletions pygeoapi/provider/geopackage.py
Expand Up @@ -97,8 +97,7 @@ def __response_feature_collection(self):

def __response_feature_hits(self, hits):
"""Assembles GeoJSON/Feature number
e,g: http://localhost:5000/poi/items?
limit=1&resulttype=hits
e,g: http://localhost:5000/collections/poi/items?resulttype=hits
:returns: GeoJSON FeaturesCollection
"""
Expand Down

0 comments on commit c621b21

Please sign in to comment.