MapServer CGI wrapper
Switch branches/tags
Clone or download
Pull request Compare This branch is 13 commits ahead, 3 commits behind dayne:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
Gemfile
Gemfile.lock
LICENSE.md
README.md
Rakefile
VERSION
conf.yml.default
deny.png
deny.rb
deny.xcf
deny_tile.png
deny_tile.xcf
mapwrap.rb

README.md

map-wrap

Map Wrap, a tool to handle the cgi-bin handoff for mapserver.

Some notes on the layout of the services:

data - 
  /ogc/data/bdl (big data area)  or /gluster/ogc/bdl    
configs - 
  /ogc/maps/bdl/(mapserver configs)
  /ogc/maps/bdl/map_wrap/conf.yml
map_wrap -  
  mapwrap.rb
  conf.yml

The basic flow is an incoming request for /foo, gets mapped to /token/foo and looks up in /ogc/maps/token/map_wrap/conf.yml for foo, and loads the config for "foo". So -> http://wms.alaskamapped.org/bdl -> /bdl/bdl , and looked up in /ogc/maps/bdl/map_wrap/conf.yml

Map Wrap - MapServer wrapper

A MapServer CGI wrapper that simplifies the URLs to your WMS services and provides the following features:

  • defaults SERVICE to WMS
  • defaults REQUEST to GetCapabilities
  • allows for projection optimized mapfiles
  • accepts both POST and GET requests
  • simple name alias for a map
  • ghetto list of available MapServer maps

Why is that useful?

Simpler URLs to remember and hiding of silly details. Users do not need to know, and I should not have to remember, the path to mapfiles on the local system. Avoid the extra work of having to specify ?SERVICE=WMS&REQUEST=GetCapabilities when doing a sanity check with curl.

INSTALL:

To use this wrapper script there is a bit of a setup:

  • create an user friendly alias (for your users, not you)

See apache config section below for example

  • configure the FUN_PREFIX to the prefix you choose

FUN_PREFIX = "/map"

  • point the CONFIG_FILE at the correct location (defaults to ../conf.yml)

CONFIG_FILE = "/path/to/mapwrap/conf.yml"

  • Creat the config file (see below)

  • tail -f error.log and access.log, reload apache

  • Check the output of a GetCapabilities:

curl 'http://localhost/map/example' | less

Apache Configuration

The following can be slid into appropriate Apache config section or /etc/httpd/conf.d/mapwrap.conf for a global configuration:

<Directory "/path/to/mapwrap/cgi-bin">
  AllowOverride None
  Options ExecCGI  FollowSymLinks
  AddHandler cgi-script .rb
  Order allow,deny
  Allow from all
</Directory>
# The following is the FUN_PREFIX=/map
Alias /map /path/to/mapwrap/cgi-bin/mapwrap.rb

Configuration: conf.yml

Hopefully the only part you have to maintain after you've set things up correctly. To get started just do a somple cp conf.yml.default conf.yml

mapserv: /opt/mapping_tools/bin/mapserv.svn
envsh: /opt/mapping_tools/setup.sh
maps:
  bluemarble: /www/wms/apps/mapserver/maps/bluemarble.map
  example: /www/wms/apps/mapserver/maps/bluemarble.map
  spot_pan:
    default: /www/wms/apps/mapserver/maps/spot_pan.map
    900913: /www/wms/apps/mapserver/maps/spot_pan-900913.map

The mapserv and envsh options are optional. If you have a good CGI environment with mapserv and libraries available then delete those lines.

The maps section takes a name and a path to a mapfile. If you want to have an optimized mapfile for multiple pre-projected datasets then break it apart with a default line and a line for each EPSG code you've got.

Credit where credit is due

  • @dayne - original author (late night hotel room hacking)
  • @spruceboy - man behind the WMS curtain at @gina-alaska
  • @teknofire - the super coder cleaner

Developing

If you are doing a new release you need to tag the new release. To see your options for that run rake -T to see the options.

For example a minor bug fix within a version is done by:

rake version:bump:revision

Happy Hacking