This folder contains docker files for building and running a mapserver setup for Planwise. Though the staging instance in http://planwise-maps-stg.instedd.org can be used for development, it is suggested to run them locally in order to be able to visualise calculated unsatisfied demand rasters.
Run mapserver containers
Use the supplied
docker-compose -f mapserver/docker-compose.yml up
This will start a mapserver container and a mapcache container, mapped to ports 5001 and 5002 respectively. Both will use the config files from the
mapserver folder and the data from the
data folder, mounted as volumes.
Mapcache will receive all tile requests from browser clients in
WMS. Though mapcache can also accept requests in the more used
gmaps formats, it only supports dimensions in WMS. The service is configured to accept a
DATAFILE dimension, which is used to determine the source raster so clients can request a specific unsatisfied demand raster.
Mapcache will forward all requests to Mapserver in WMS format as well, and cache the requested tiles locally on disk at
/tmp. Mapserver is configured to respond both in tile mode and
WMS, and accepts the
DATAFILE query param to change the source raster.
To query mapcache in WMS format the root URL should be
LAYER, and setting
DATAFILE. For example:
To bypass mapcache and query mapserver in tile mode:
Mapserver can also be installed locally on OSX, via
brew install mapserver. If that doesn't work, try using the following homebrew tap:
brew tap osgeo/osge4mac.
Download geotiff files form worldpop.org.uk and place them in the
To add overviews to the tiff file, which yields a noticeable performance improvement:
gdaladdo KEN_popmap15_v2b.tif -r average 2 4 8 16 32 64
To create a tiled tif, which does not show much improvement:
gdal_translate -co TILED=YES KEN_popmap15_v2b.tif KEN_popmap15_v2b.tiled.tif
To create a tile index from the geotiff, use the custom python script:
The generation of a map may be tested using the
mapserv utility directly:
$ mapserv -nh "QUERY_STRING=map=planwise.map&mode=map" > test.png
This can be run both from inside the docker container or the locally installed mapserver. Just set the full path to
planwise.map on the query string if needed, and ensure the data file is reachable.