Mapserver

From Wildsong
Revision as of 00:46, 3 September 2005 by Brian Wilson (talk | contribs)
Jump to navigationJump to search

General MapServer notes

MapServer web site

MapServer is for building Web-based GIS applications.

What can I do with MapServer? It can act as a WMS. It can act as a WFS.

What is a WMS? An OGC-compliant "Web Map Server"

What is a WFS? An OGC-compliant "Web Feature Server" allows WFS clients to access feature sets from the WFS instead of entire maps.

You can combine it with other components to enhance its functionality.

Windows / Corvallis implementation

At Public Works, we live in a Windows world here, but why let that slow us down? We started off with ELLAmaps which is based on a MapServer 3. server. Now moving on to something better.

Server software

Three possibilities are FWTools, HoBu, and MS4W

FWTools 0.9.9 - Frank Warmerdam's version built on Python.
Mapserver works but I can't figure out how to enable the python mapscript; it whines about python2.3.dll being unavailable; it's there in the bin/ directory and I don't know how to install it.

HoBu supports Python, PostGIS, ArcSDE, Oracle
Python has to be installed separately. HoBu seems to have what I need and it uses the latest mapserver version (4.6.1).

Very latest versions can be found here: http://hobu.stat.iastate.edu/mapserver/build_output/

I downloaded the MSI file from python.org for Python 2.4.1 and installed it, and added the installation directory to my system environment PATH. (C:/Python) So far so good. My hello.py script (based on p. 189-190 in 'Benginging Mapserver) worked on the very first try, ta RA!

MS4W includes Apache and PHP/MapScript; but no Python support, sorry. If you want Apache, the installer actually works. For some reason the Apache binary I downloaded from Apache.org did not.

See also http://www.thesitewizard.com/archive/addcgitoapache.shtml

Okay... I now have Python Mapscript working with Apache and Windows. So I know it runs. Now if I can just get it to fire up under IIS I will be happy.


Other software

PIL = Python Imaging Library



FWTools

Installation

Download the binary and execute it.

MrSID note Installing support for MrSID plugin requires a version of LizardTech SDK which is not currently available. Oh well.

Configuration

After it's installed you have to enable the CGI portion. I did this by creating a new "Virtual Directory" called fwms, so I can access the mapserv.exe with a URL like this: http://localhost/fwms/mapserv.exe

It gives me the old familiar "No query information to decode. QUERY_STRING not set." error so I know it's executable.

Testing

Now I need to root around and find a MAP file to test it. I built a hello world and a parks map and accompanying template files.

Then I need to build an appropriate URL to test it. How about http://localhost/locn/park.html

Python Mapscript

As mentioned above I set up the hello.py script from the book Beginning Mapserver. I ran the script from the command line. To make it run as a CGI in IIS, I had to open up the Computer Management IIS interface, bring up the Properties page for my Web server, click on the Home Directory tab, go into the "Configuration..." menu, and add a mapping for the extension ".py".


Did all that. I can run a python script now, a simple one called simple_hello.py that shows system time. Now for mapscript. It gives me this:

CGI Error

The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:


Traceback (most recent call last): File "C:\mapserver\Locn\hello.py", line 3, in ? import mapscript File "C:\Python\Lib\site-packages\mapscript.py", line 4, in ? import _mapscript ImportError: DLL load failed: The specified module could not be found.

sys.path returns

['C:\\mapserver\\Locn', 
'C:\\Python\\python24.zip', 
'C:\\mapserver\\Locn', 'C:\\Python\\DLLs', 
'C:\\Python\\lib', 
'C:\\Python\\lib\\plat-win', 
'C:\\Python\\lib\\lib-tk', 
'C:\\Python', 
'C:\\Python\\lib\\site-packages'] 

When run from the command line (in cygwin) it loads the DLL just fine, so the problem is that the DLL is not found when invoked from IIS. I wonder if its perms again. That's what it seems like.

I have tried both the generic and ActiveState versions of Python 2.4.1. I think I shall try Apache.

Linux / CDS implementation

Installation

The INSTALL file has this text in it: "Visit http://mapserver.gis.umn.edu/ for full documentation and installation instructions." It took me a good 30 minutes to find any useful documentation at the UMN site!

Look in their MapServerWiki. Here is a doc on MapServerCompilation

Server

I built a special Web server to run MapServer for two reasons. First, I generally run MySQL not PostgreSQL due to the requirements of other packages that I use. I might think PostgreSQL is better than MySQL but the other packages don't support it.

Second, the current version of MapServer requires that PHP be run as a CGI instead of as a loadable Apache module. For MapServer this is not a big deal but again some of my other software packages won't work when used with the CGI version of PHP.

I use Trustix Secure Linux 2.1 on the map server. I find it to be easy to maintain and not bloated like recent versions of Redhat. The support from the Trustix team is excellent.

Relevant installed packages with TSL 2.1 include

Apache 2.0.51 -- installed from apache TSL package

PostgreSQL 7.4.5 -- installed from postgresql and postgresql-devel TSL packages

GD 2.0.27 Boutell's graphics library is not available through Trustix. The Redhat version is outdated too -- you need GD version 2. So I built it myself. I had to install the zlib-devel package to get it to compile on TSL.

PHP As mentioned above I have to build PHP 4.3.9 as a CGI -- the TSL version is a module. Building PHP required installing these TSL packages: flex,

The options I used for the PHP configure script are:

./configure \
        --with-pear \
        --with-regex=system \
        --with-zlib \
        --with-gettext \
        --with-xml \
        --with-pgsql

This is a bit minimal for me. Usually I build in a lot more features but then again, normally I load PHP as a SAPI module so it does not matter if it's a bit bulky. To run it as a CGI I want it to load as fast as possible so I leave nifty extra features like internal support for JPEG's and PNG's turned off. Maybe I should turn off XML support too...

Configuring Apache for CGI PHP

I could not find a good clear example of this -- apparently everyone uses SAPI PHP.

ADD APACHE MY CHANGES HERE!!! Projections - PROJ 4.4.8 installed from RPM for Redhat. Proj includes a library for performing respective forward and inverse transformation of cartographic data to or from cartesian data with a wide range of selectable projection functions.

Map file support -- Raster and Vector files

GDAL 1.2.3
GDAL is the "Geospatial Data Abstraction Library". GDAL is a translator library for raster geospatial data formats.

OGR The OGR library is a subcomponent of GDAL so you don't need to worry about it if you install GDAL. The OGR Simple Features Library allows MapServer users to display several types of vector data files in their native formats. For example, MapInfo Mid/Mif and TAB data do not need to be converted to ESRI shapefiles when using OGR support with MapServer.

I built the entire GDAL package with './configure; make; make install'

Building MapServer

MapServer wanted me to install Freetype but there is no TSL Freetype so I installed version 2.1.9 from source with the traditional './configure; make; make install',

The configuration I used for the actual MapServer build looks like this:

./configure \
  --prefix=/usr/local/mapserver \
  --with-httpd=/usr/sbin/httpd  \
  --with-gd=/usr/local  \
  --with-freetype       \
  --with-jpeg           \
  --with-proj           \
  --with-ogr=/usr/local/bin/gdal-config \
  --with-gdal=/usr/local/bin/gdal-config --with-wfs \
  --with-tiff \
  --with-php=../../Languages/php-4.3.9

I would like to add --with-postgis but I have not installed PostGIS yet.