Mapserver: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
Brian Wilson (talk | contribs)
mNo edit summary
Line 220: Line 220:


MapLab development is on hold, see the above link. I was not really knocked out when I did have my sample site going so I probably won't bother to re-activate it. IMHO, building map files has to be the weakest link in Mapserver.
MapLab development is on hold, see the above link. I was not really knocked out when I did have my sample site going so I probably won't bother to re-activate it. IMHO, building map files has to be the weakest link in Mapserver.
== Test project: Web-based orthophoto viewer ==
===Overview===
This project will consist of a simple Web browser based orthophoto viewer that allows viewing orthophoto sets for the city of Corvallis.
Objective: to explore what it takes to build a practical browser for multiple city-wide collections of orthophotos. The major issue I expect to address is preparing the orthophoto data by mosaicking and tiling it, determining best storage format. I am hoping that mapserver already knows a fair bit about managing the tiled image files. Emphasis will be on preserving image details (ie avoiding use of lossy compression) while serving data over a typical 256K broadband connection.
Vector layers available: Streets overlay; centerline or curbs depending
on currently selected scale. Taxlots available but not normally displayed.
(Used for queries.)
Raster layers available: orthophoto sets for various years from 1936 to present.
===User interface===
Two maps are visible, a large map and a small reference map.
The reference map shows full extent with indicator of extent of large map.
Mode: zoom in, zoom out, pan <BR>
Effect of clicking on large map depends on the currently selected mode.
Zoom in: click= zoom in a fixed amount and recenter.
click-and-drag= creates an extent box and zooms to the new extent.
Zoom out: click or click-and-drag= zooms out and recenters.
Pan: click= recenter; click-and-drag= pan
Actions buttons: <br>
Full extent: zooms to full extent of map<br>
Redraw: sends command to mapserver to redraw the large map<br>
Selection list: Make a selection from a "places" list and then zoom to the place.
Wish list: (features for version 2.0)
* Search: Query the taxlots database then allow zooming to the vicinity of that taxlot. Save this feature for release 2.0 :-)
* Print: opens a popup with a map formatted for printing on 8.5x11 paper
* Download the displayed map as a jpeg or pdf file
* Two large map frames, so that two maps with same extent but orthos for different years can be compared side-by-side.
Comments:
Appearance: The Web pages should look good. The maps should conform to basic cartographic principles.
Robustness: the user interface should screen out bad data entry such as zooming in and out beyond reasonable limits or panning outside the full extent.
=== Implementation notes ===
This project will be mostly server-side oriented using php/Mapscript on Linux.
<todo>Implementation of some user-interface features will be either
javascript or flash; to be determined.</todo>
It will not be browser dependent; testing will be done on current versions of Mozilla and Firefox on Linux and Windows, and Internet Explorer on Windows.
Data storage: vector files will be ESRI shapefile format. Raster files will (probably) be tiled geotiffs prepared using fwtools.

Revision as of 22:23, 28 October 2005

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.

I have more information on my public Linux server down below, and details on setting up the server here: Mapserver on Linux

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 Kropla's 'Beginning 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. The problem is, under IIS it cannot find the _mapscript DLL. 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. Apache is great but I need it to work under IIS.

Success! IIS + Python 2.4 + HoBU

Adam Ryan passed along the secret to get Python Mapscript to work with IIS. The HoBu installer puts the DLL's in the wrong place. It puts them in C:\Python24. Following Adam's suggestion, I keep it all bundled together by moving all the DLL's and the mapscript.py* files to to Lib\site_packages\mapscript\ and then I created an empty __init__.py file there. In scripts, instead of "import mapscript" now I have to use "import mapscript.mapscript as mapscript".

Other software

PIL = Python Imaging Library<br Adam suggested I look at PIL. Have not done so yet.

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

or the MS4W Apache version, http://localhost/mapserver/Locn/park.html

Python Mapscript

As mentioned above I set up the hello.py script from 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".


Here I have a mapscript demo. http://localhost/Locn/park.py

What can I do with FWtools?

OpenEV -- this is the desktop app. FWTools also includes a bundle of command line utilitties; however, in this doc I only care about the extensions to MapServer.

Basically FWtools adds the parts for handling various vector and raster formats.

  • OGR - vector file handling
  • GDAL - raster file handling
  • PROJ4 - handling for projections
  • libtiff, libgeotiff add TIFF raster image support (including LZW)

So therefore I should be able to use TIFF imagery as a background for my park map. Lets try adding the ortho layer... http://localhost/Locn/park_ortho.py

Templates

Now I want to interact with the map, that's what it's for eh??? That leads me back to working on the MapServer TEMPLATE page again.

Templates provide a way to create HTML or Javascript/HTML maps easily. The mapserver app on the server fills in the variables in a 'template' specified as part of the *.map file. Then that completed HTML is sent to your browser.

When you click on a button or on the map, mapserver is invoked again to create a new map and so on and so on.

With mapscript, a python (or php or perl or...) script is invoked instead, it processes your input and it invokes mapserver. So technically there is not a need for a template file. Your code resides on the server instead (or in addition) to living in the browser in the form of Javascript.

Using MapServer on Linux

My sample server is here: http://mapserver.wildsong.biz/ I guarantee that not everything there is working. It's a work-in-progress / testbed / under-construction site.

Short reviews of some MapServer apps running under Linux

I have sample setups of each of these on my server to try them out.

Rosa

Site: http://www.maptools.org/rosa/index.phtml

Rosa is a simple Java applet. It displays an image (GIF, JPEG or PNG) on which operations can be performed, these include single clicks, dragging a rectangle, ellipse, or polyline to define an area of interest. It can also have a toolbar and/or floating buttons with various functions attached to them. The information on the user's input will be returned through form parameters that you define.

If you install gmap, you get a copy of the Rosa applet at no extra charge.

I am thinking that Rosa's pretty mature since the last development release was 2003. There is an active discussion thread so usage and the support are still available. This could be considered a good thing (that is, it's stable and still usable).

There does not seem to be much documentation available and the Rosa portion of gmap does not work (for me). So I am going to try to get a copy going on my server and that end I will create this Rosa page.

gmap

My sample installation: http://mapserver.wildsong.biz/gmap/index.phtml
Site: http://gmap.maptools.org/

I have version 4.0 installed currently.

This is a sample PHP/Mapscript implementation. You can turn layers on and off, you can redraw and resize the map.

It will use the Rosa Java applet by default but you can turn it off. With my IE system, the Java app did not work. The non-Java version works fine.

Easy to set up. Especially if you want a map of Canada. :-)

Features: all the usual ones: select layers, a 'places' selection list, zoom in, zoom out, pan, and identify. A reference map. A list of map sizes (800x600 etc) The identify tool is set to query cities. (This is only a demo, don't be hard on it.)

ka-Map!

My demo: http://mapserver.wildsong.biz/kamap/

Site: http://ka-map.maptools.org/

ka-Map builds on gmap, and has a very simple user interface. Its claim to fame is that pan mode actually moves pixels on the screen.

I put my own Corvallis shapefiles into the demo, so you dont have to look at maps of Canada. Also to determine how hard this is to use.

It's easy to set up too.

Chameleon

I think the big point of Chameleon to create a framework on which to hang OGC compliant services (and Mapbender is another one). Since I don't really care about OGC right now (I am sufficiently confused already I am not pursuing full knowledge and understanding of Chameleon or Mapbender.

To get Chameleon running under Linux, I had to add support for wmsclient to MapServer (Mapscript) which in turn required curl.

"Running" is sort of metaphorical here. It's installed and generates no error messages but the demo does not work. I followed the installation instructions and then dozed off trying to read the documentation pages at http://chameleon.maptools.org/help/viewer.phtml

My sample: http://mapserver.wildsong.biz/chameleon/

The docs for it: http://mapserver.wildsong.biz/chameleon_docs

Site: http://chameleon.maptools.org/index.phtml

ELLAmaps

Of course there is ELLAmaps which only works with the Internet Explorer browser.

You can see it in action at Benton County GIS, Linn County GIS, and Polk county

In theory I should be able to make it run on a Linux server. I spent a few hours hand editing the server files to no avail. Really it's not worth working on it since this project is going to be retired.

Maplab

My sample site: down at the moment and I have to go get ready for the Solar Tour

Site: http://maptools.org/maplab/index.phtml

MapLab development is on hold, see the above link. I was not really knocked out when I did have my sample site going so I probably won't bother to re-activate it. IMHO, building map files has to be the weakest link in Mapserver.