Created: 2011-07-17 00:04
Updated: 2017-07-04 07:52


A simple wrapper around MapServer ( to enable

  • MapServer map files to be written in JSON and stored in CouchDB
  • MapServer to be managed and run in an Erlang OTP supervision process
  • GDAL CouchDB OGR driver to serve GeoJSON directly from CouchDB as a WFS or rendered through WMS

MapServer is an Open Source platform for publishing spatial data and interactive mapping applications to the web.


  1. Couchbase trunk (I used the preview branch and set up rake / ruby using RVM)

(currently GeoCouch uses couch_file:flush which isn't in couchdb trunk yet)

GDAL OGR couchdb driver can perform client side filtering, however in ogrcouchdbtablelayer if couchdb isn't present then the error is written to stderr which causes MapServer to raise an error.

  1. GDAL trunk

  1. MapServer trunk with CouchDB wrapper

browse here

Configure as follows

./configure --with-wms --with-wfs --with-wcs --with-gdal --with-ogr --with-proj --with-couchdb

  1. Configuration

Edit config/couchmaps.ini and copy to local.d and add couchmaps ebin files to path


mkdir $COUCH_HOME/build/lib/couchdb/plugins/couchmaps/ebin

and copy beam files there.

note: currently map files are writting to tmp, but this can be override with a mapserver section in the ini file



tmp = /myothertmp

  1. Populate database

ogr2ogr -f couchdb -lco "UPDATE_PERMISSIONS=ALL" "couchdb:http://localhost:8000" bcpos_trails.shp

  1. Create a database called mapserver

Add sample mapserver map

curl -X PUT --data-binary http://localhost:8000/mapserver/_mapserv/

this will convert the in mapfile format to JSON.

Note you can lock down http client browsing of with a redirect in couchdb that will not affect server operation.

  1. Test WFS GetCapabilities


  1. Test WFS GetFeature

if using geocouch, then test directly first

curl "http://host:8000/bcpos_trails/_design/ogr_spatial/_spatial/spatial?bbox=-180,-90,180,90"


curl "http://host:8000/mapserver/_mapserv/"

The geojson data in CouchDB (step 6) is now returned as GML

  1. Test WMS GetMap


and open up the returned geotiff to see a rendering of the geojson data in (6).

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more