Home

Awesome

<p align="center"> <a href="https://access.crunchydata.com/documentation/pg_featureserv/latest/"><img width="180" height="180" src="./hugo/static/crunchy-spatial-logo.png?raw=true" /></a> </p>

pg_featureserv

.github/workflows/ci.yml

A lightweight RESTful geospatial feature server for PostGIS, written in Go. It supports the OGC API - Features REST API standard.

See also our companion project pg_tileserv.

Features

For a full list of software capabilities see FEATURES.

Documentation

Relevant Standards

Download

Builds of the latest code:

Build from Source

pg_featureserv is developed under Go 1.13. It may also work with earlier versions.

In the following, replace version <VERSION> with the pg_featureserv version are building against.

Without a Go environment

Without go installed, you can build pg_featureserv in a docker image:

In Go environment

Docker image of pg_featureserv

Build the image

make APPVERSION=<VERSION> clean docker

Run the image

To run using an image built above:

docker run --rm -dt -e DATABASE_URL=postgres://user:pass@host/dbname -p 9000:9000 pramsey/pg_featureserv:<VERSION>

Configure the service

The configuration file is automatically read from the following locations, if it exists:

To specify a configuration file directly use the --config commandline parameter. In this case configuration files in other locations are ignored.

Configuration Using Environment Variables

To set the database connection the environment variable DATABASE_URL can be used with a Postgres connection string:

export DATABASE_URL="host=localhost user=postgres"

Other parameters in the configuration file can be over-ridden in the environment. Prepend the upper-cased parameter name with PGFS_section_ to set the value. For example, to change the HTTP port and service title:

export PGFS_SERVER_HTTPPORT=8889
export PGFS_METADATA_TITLE="My PGFS"

SSL

For SSL support, a server private key and an authority certificate are needed. For testing purposes you can generate a self-signed key/cert pair using openssl:

openssl req  -nodes -new -x509  -keyout server.key -out server.crt

These are set in the configuration file:

TlsServerCertificateFile = "/path/server.crt"
TlsServerPrivateKeyFile = "/path/server.key"

Run the service

Command-line options

Troubleshooting

To get detailed information about service operation run with the --debug commandline parameter.

./pg_featureserv --debug

Debugging can also be enabled via the configuration file (Server.Debug=true), or in the environment:

export PGFS_SERVER_DEBUG=true

Requests Overview

Features are identified by a collection name and feature id pair.

The default response is in JSON/GeoJSON format. Append .html to the request path to see the UI page for the resource. In a web browser, to request a JSON response append .json to the path (which overrides the browser Accept header).

The example requests assume that the service is running locally and configured to listen on port 9000.

See API Summary for a summary of the web service API.