• Stars
    star
    451
  • Rank 96,588 (Top 2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lightweight RESTful Geospatial Feature Server for PostGIS in Go

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

  • Implements the OGC API - Features standard.
    • Standard query parameters: limit, bbox, bbox-crs, property filtering, sortby, crs
    • Query parameters filter and filter-crs allow CQL filtering, with spatial support
    • Extended query parameters: offset, properties, transform, precision, groupby
  • Data responses 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)
    • Filters are executed in the database, and use indexes where defined
  • Uses PostGIS to provide geospatial functionality:
    • Spatial filtering
    • 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
    • HTTP and HTTPS support

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:

  • Download or clone this repository into $GOPATH/src/github.com/CrunchyData/pg_featureserv
  • Run the following command in pg_featureserv/:
    make APPVERSION=<VERSION> clean build-in-docker

In Go environment

  • 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 creates a pg_featureserv executable in the application directory

  • (Optional) Run the unit tests using make test

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:

  • In the system configuration directory, at /etc/pg_featureserv.toml
  • Relative to the directory from which the program is run, ./config/pg_featureserv.toml
  • In a root volume at /config/pg_featureserv.toml

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

  • Change 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 configuration 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

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.

More Repositories

1

postgres-operator

Production PostgreSQL for Kubernetes, from high availability Postgres clusters to full-scale database-as-a-service.
Go
3,884
star
2

crunchy-containers

Containers for Managing PostgreSQL on Kubernetes by Crunchy Data
Shell
1,011
star
3

pg_tileserv

A very thin PostGIS-only tile server in Go. Takes in HTTP tile requests, executes SQL, returns MVT tiles.
Go
858
star
4

pgmonitor

PostgreSQL Monitoring, Metrics Collection and Alerting Resources from Crunchy Data
PLpgSQL
568
star
5

crunchy-proxy

PostgreSQL Connection Proxy by Crunchy Data (beta)
Go
413
star
6

pg_eventserv

Small golang server to push PgSQL listen/notify events into websockets
Go
200
star
7

postgres-operator-examples

Examples for deploying applications with PGO, the Postgres Operator from Crunchy Data
Handlebars
184
star
8

pgCompare

pgCompare – a straightforward utility crafted to simplify the data comparison process, providing a robust solution for comparing data across various database platforms.
Java
79
star
9

postgresql-prometheus-adapter

Remote storage adapter enabling Prometheus to use PostgreSQL as a long-term store for time-series metrics.
Go
75
star
10

Postgres-AI-Tutorial

Python
58
star
11

pgnodemx

A PostgreSQL extension that provides SQL functions to allow capture of node OS metrics via SQL queries.
C
47
star
12

pgstigcheck-inspec

PostgreSQL STIG Compliance Testing Solution using InSpec
Ruby
41
star
13

crunchy-postgresql-manager

PostgreSQL-as-a-Service Management Utility. Superseded by Crunchy Container Suite: https://github.com/CrunchyData/crunchy-containers
HTML
36
star
14

pgbouncer_fdw

PostgreSQL Foreign Data Wrapper to Connect to pgbouncer
PLpgSQL
32
star
15

crunchy_check_access

Functions and views to facilitate PostgreSQL object access inspection
PLpgSQL
27
star
16

bridge-cli

CLI for Crunchy Bridge
Crystal
23
star
17

postgres-operator-client

Go
14
star
18

pgo-osb

Open Service Broker Implementation Based on the Crunchy PostgreSQL Operator
Go
13
star
19

crunchy-demo-data

Demo Data that is used in Crunchy Data Demos and Workshop that can be freely redistributed
HTML
13
star
20

crunchy-katacoda

Shell
10
star
21

openshift-postgres-cartridge

OpenShift V2 PG cartridge
Shell
8
star
22

backup-scripts

High Performance PostgreSQL Tools
Shell
8
star
23

crunchy-watch

A PostgreSQL Automated Failover Container
Go
8
star
24

pgSimload

pgSimload, a versatile CLI tool to create activity on PostgreSQL server(s) and/or test HA in Crunchy Postgres or Crunchy Postgres for Kubernetes
Go
7
star
25

terraform-provider-crunchybridge

Go
6
star
26

exporter2perfdata

Go
5
star
27

pgseccomp

C
5
star
28

pg_goggles

pg_goggles provides better scaled and summarized views into PostgreSQL's cryptic internal counters.
4
star
29

openshift-postgres-rls-cartridge

Shell
3
star
30

nixpkgs

Nix
3
star
31

crunchy-bridge-operator

Go
3
star
32

crunchy-hugo-theme

Theme used for Crunchy Data generated documentation
JavaScript
3
star
33

skybridge2

Go
2
star
34

postgres-ci-cd-demo

Python
2
star
35

crunchy-bridge-for-analytics-examples

1
star
36

os-pg-testing

Shell
1
star
37

pgmonitor-extension

PLpgSQL
1
star
38

postgres-realtime-demo

Python
1
star
39

doc-content-guide

1
star
40

spatial-suite-rest-demo

Python
1
star
41

crystal-keyring

Keyring implementation for Crystal
Crystal
1
star
42

crunchy-docs

TypeScript
1
star
43

crunchy-postgresql-manager-openshift

CPM Openshift version
HTML
1
star
44

homebrew-brew

homebrew tap
Ruby
1
star
45

spatial-suite-demo-webapp

JavaScript
1
star