Skip to content

osmontrouge/pg_featureserv

 
 

Repository files navigation

pg_featureserv

Travis Build Status

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

Features

  • Implements the OGC API - Features standard.
    • Supports standard request parameters limit, bbox, property filtering
    • Extended parameters include offset, properties, orderBy, transform, precision
  • Data reponses are formatted in JSON and GeoJSON
  • Provides a simple HTML user interface, with web maps to view spatial data
  • Uses the power of PostgreSQL to reduce the amount of code and to make data definition easy and familiar.
    • Feature collections are defined by database objects (tables and views)
  • Uses PostGIS to provide geospatial functionality:
    • Transforming geometry data into the output coordinate system
    • Marshalling feature data into GeoJSON
  • Full-featured HTTP support
    • CORS support with configurable Allowed Origins
    • GZIP response encoding

For a full list of software capabilities see FEATURES.

Documentation

Download

Builds of the latest code:

Building from Source

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

  • Ensure the Go compiler is installed
  • Download or clone this repository into $GOPATH/src/github.com/CrunchyData/pg_featureserv
  • To build the executable, run the following commands:
cd $GOPATH/src/github.com/CrunchyData/pg_featureserv/
go build
  • This should create a pg_featureserv executable in the application directory

Configuring the service

  • Set the environment variable DATABASE_URL with a Postgres connection string
    • Example: export DATABASE_URL="host=localhost user=postgres"
  • Edit the configuration file pg_featureserv.toml, located in ./config, /config, or /etc

Running the service

  • If not already done, move to the application directory:
    • cd $GOPATH/src/github.com/CrunchyData/pg_featureserv
  • Start the server:
    • ./pg_featureserv
  • Open the service home page in a browser:
    • http:/localhost:9000/home.html

Command-line options

  • -? - show command usage
  • --config file.toml - specify configuaration file to use
  • --debug - set logging level to TRACE (can also be set in config file)
  • --devel - run in development mode (e.g. HTML templates reloaded every query)
  • --test - run in test mode, with an internal catalog of tables and data
  • --version - display the version number

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.

About

Lightweight RESTful Geospatial Feature Server for PostGIS in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 98.1%
  • Other 1.9%