MapServer

From Amahi Wiki
Jump to: navigation, search

INCOMPLETE... work in progress


Intro

MapServer is a web-based mapping platform, power many large enterprise mapping requirements. It runs as a CGI or through its various API hooks in Python, PHP, Ruby and more. A simple configuration file defines how your spatial data will be accessed and rendered. A basic web templating system is also included for easy testing through basic HTML.

Learn more about MapServer at mapserver.org. MapServer is an OSGeo project.

Installing

These are the long form notes for getting MapServer running in Amahi. Soon this will become a one-click installer package from the HDA interface.

Packages

Install MapServer package using the yum installer, also include the proj library support files (epsg) and some basic fonts for playing with:

yum install mapserver epsg bistream-vera-fonts

The process discovers about 12 other packages that fulfill its dependencies. Overall install takes about 16MB of space. Here's a list of the other packages it installs.

cfitsio.i386 0:3.130-3.fc9                fftw2.i386 0:2.1.5-16.fc9    
gdal.i386 0:1.5.3-1.fc9                    geos.i386 0:2.2.3-1.fc7         
grass-libs.i386 0:6.3.0-6.fc9           hdf5.i386 0:1.8.1-1.fc9      
libdap.i386 0:3.7.10-2.fc9               libgeotiff.i386 0:1.2.5-2.fc9   
librx.i386 0:1.5-10.fc9                      netcdf.i386 0:3.6.3-1.fc9    
ogdi.i386 0:3.2.0-0.11.beta2.fc9    proj.i386 0:4.5.0-4.fc9

Files

The rpm -ql mapserver command will list all the installed files from the MapServer package. The main executable is located at:

/usr/sbin/mapserv

And test files from:

/usr/share/doc/mapserver-5.2.2/tests

Are set up automatically by the HDA installer, into the MapServer Amahi web app:

/var/hda/web-apps/mapserver/html/test

These don't do anything with the web interface at all yet, though from the command line you can test that MapServer is installed okay by doing the following:

cd /var/hda/web-apps/mapserver/html/tests
shp2img -m test.map -o testoutput.png

Then you should be able to view the output through your Amahi MapServer service at: http://mapserver/tests/testoutput.png

It ain't pretty, but is a simple test the developers use.

Server Setup

As part of the installation the mapserv CGI file will get put in its own folder for Amahi and the httpd conf.d file is edited to allow the CGI to be executed.

mkdir /var/hda/web-apps/mapserver/cgi-bin
cp /usr/sbin/mapserv /var/hda/web-apps/mapserver/cgi-bin
chown  -R apache.apache /var/hda/web-apps/mapserver/cgi-bin

This section is added to the middle of the file /etc/httpd/conf.d/1026-mapserver.conf:

       Alias /tmp /var/hda/web-apps/mapserver/tmp
       Alias /etc /var/hda/web-apps/mapserver/etc   
       ScriptAlias /cgi-bin /var/hda/web-apps/mapserver/cgi-bin
       <Directory "/var/hda/web-apps/mapserver/cgi-bin">
               Options +ExecCGI
       </Directory>

After this, running /etc/init.d/httpd reload may be necessary if you are doing it manually.

Now you should be able to test that the mapserv CGI executes by going to: http://mapserver/cgi-bin/mapserver. The response should be:

No query information to decode. QUERY_STRING is set, but empty.

Also we create a temporary folder for holding our map images and a folder for common settings files:

cd /var/hda/web-apps/mapserver
mkdir tmp etc
cp -r /usr/share/doc/mapserver-5.2.2/fonts etc
cp -r /usr/share/doc/mapserver-5.2.2/symbols etc
cp -r /usr/share/doc/mapserver-5.2.2/tests/symbols.txt etc/symbols
chown -R apache.apache tmp etc


Now, onto more useful stuff, building a sample application.

A Sample Application

The package will install a demo application based on the Global Mapping project mentioned in Web Mapping Illustrated by Tyler Mitchell. :-)

cd /var/hda/web-apps/mapserver/html
wget http://spatialguru.com/maps/apps/global.tar.gz


.... more to come...