Mapserver: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
Brian Wilson (talk | contribs)
 
(60 intermediate revisions by the same user not shown)
Line 1: Line 1:
== General MapServer notes ==
== General MapServer notes ==


[http://mapserver.gis.umn.edu/ MapServer web site]
Current release is 7.0.4
 
Link to the official [http://mapserver.org/ MapServer web site]


MapServer is for building Web-based GIS applications.
MapServer is for building Web-based GIS applications.


What can I do with MapServer?
=== What can I do with MapServer? ===
It can act as a WMS.
 
It can act as a WFS.
* It can act as a WMS.
* It can act as a WFS.
* It does '''not''' act as a WFS-T, so you can't edit data. The workaround is to use [http://mapserver.org/tinyows/index.html TinyOWS].


What is a WMS?  An OGC-compliant "Web Map Server"
What is a WMS?  An OGC-compliant "Web Map Server"
Line 14: Line 18:
feature sets from the WFS instead of entire maps.
feature sets from the WFS instead of entire maps.


You can combine it with other components to enhance its functionality.
WFS-T "T" means transactions and that means writing data back to the server. TinyOWS is tightly tied to [[PostGIS]]
 
You can combine mapserver with other components to enhance its functionality.
 
== Implementation ==
 
=== Linux ===
 
I have more information on my public Linux server down below, and details on
setting up the server here: [[Mapserver on Linux]]
 
=== Windows ===
 
When I installed Mapserver on City of Corvallis Windows servers I made these notes: [[Mapserver on Windows]] This server is currently behind a firewall. (links on the Windows page only work on my desktop machine there.)
 
== Using MapServer on Linux ==
 
=== Mapserver applications ===


[[Mapserver on Linux]]
A mapserver app is the collection of files necessary to create an interactive site. Mapserver by itself takes input in the form of spatial data and a .MAP file, and turns out an image file containing a map.


== Windows / Corvallis implementation ==
Creating an application requires assorted template and html and javascript files to 'wrap around' mapserver and present the maps and a user interface to allow panning, zooming, querying and so forth.


At Public Works, we live in a Windows world here, but why let that slow us down?
You can craft an application from scratch but a more sensible approach is to hang your data files on an existing applications. Here are some little reviews on a few of the more popular free applications for mapserver.
We started off with ELLAmaps which is based on a MapServer 3. server.
Now moving on to something better.


=== Server software ===
==== Openlayers and Leaflet ====


Three possibilities are FWTools, HoBu, and MS4W
Openlayers and Leaflet are obvious choices.


[http://fwtools.maptools.org/windows-main.html FWTools 0.9.9] - Frank Warmerdam's version built on Python.<br>Mapserver works but I can't figure
==== Geomoose ====
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.


[http://hobu.stat.iastate.edu/mapserver/ HoBu] supports Python, PostGIS, ArcSDE, Oracle<br>Python has to be installed separately. HoBu seems to have what I need and
I have a separate page for it... [[Geomoose]]
it uses the latest mapserver version (4.6.1).


Very latest versions can be found here:
=== Short reviews of some MapServer apps running under Linux ===
http://hobu.stat.iastate.edu/mapserver/build_output/


I downloaded the MSI file from python.org for Python 2.4.1 and installed it,
I have sample setups of each of these on my server to try them out.
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!


[http://maptools.org/ms4w MS4W] includes Apache and PHP/MapScript; but
==== Rosa ====
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
Site: http://www.maptools.org/rosa/index.phtml


Okay... I now have Python Mapscript working with Apache and Windows.
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.
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 ====
If you install gmap, you get a copy of the Rosa applet at no extra charge.


Adam Ryan passed along the secret to get Python Mapscript to work with IIS.
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).
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 ====
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.


PIL = [http://www.pythonware.com/products/pil/ Python Imaging Library]<br
==== gmap ====
Adam suggested I look at PIL. Have not done so yet.


==== FWTools ====
My sample installation: http://mapserver.wildsong.biz/gmap/index.phtml<br>
Site: http://gmap.maptools.org/


===== Installation =====
I have version 4.0 installed currently.


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


''MrSID note'' Installing support for [http://fwtools.maptools.org/mrsid.html MrSID plugin] requires a version of [http://developer.lizardtech.com/ LizardTech SDK] which is not currently available. Oh well.
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.


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


After it's installed you have to enable the CGI portion. I did this by
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.)
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."
==== Chameleon ====
error so I know it's executable.


===== Testing =====
This one is not working today. [[User:Brian Wilson|Brian Wilson]] 15:07, 7 May 2006 (PDT)


Now I need to root around and find a MAP file to test it. I built a hello world
Chameleon is a framework on which to hang OGC compliant services (and [http://www.mapbender.org Mapbender] is another one).
and a parks map and accompanying template files.
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.  


Then I need to build an appropriate URL to test it. How about
To get Chameleon running under Linux, I had to add support for wmsclient to MapServer (Mapscript) which in turn required curl.
http://localhost/locn/park.html


or the MS4W Apache version, http://localhost/mapserver/Locn/park.html
"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


==== Python Mapscript ====
My sample: http://mapserver.wildsong.biz/chameleon/


[[Image:Python extension.jpg|thumb|left]]
The docs for it: http://mapserver.wildsong.biz/chameleon_docs


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".  
Site: http://chameleon.maptools.org/index.phtml


<br clear=all>
==== ELLAmaps ====


Here I have a mapscript demo. http://localhost/Locn/park.py
I used to have a section here all about ELLAmaps. I leave this note here out of nostalgia.
It was used in Benton county for years. It only worked with Internet Explorer!


==== What can I do with FWtools? ====
==== Maplab ====


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.
Site: http://maptools.org/maplab/index.phtml


Basically FWtools adds the parts for handling various vector and raster formats.
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.


* OGR - vector file handling
== Mapserver and SVG ==
* 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
Since version 4.5, mapserver has supported [[SVG]] as an output format.
Refer to the official [http://mapserver.gis.umn.edu/docs/howto/svg-howto SVG howto] at the mapserver site.


==== Templates ====
As with the other output formats, pretty much all you need do to use it is to specify the file type as SVG in the MAP file. (Of course, support for svg has to be built  into mapserver.)


Now I want to interact with the map, that's what it's for eh???
Change IMAGETYPE PNG to IMAGETYPE SVG and the output file will be xml.
That leads me back to working on the [[MapServer TEMPLATE]] page again.
That's about it.

Latest revision as of 18:35, 18 September 2017

General MapServer notes

Current release is 7.0.4

Link to the official 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.
  • It does not act as a WFS-T, so you can't edit data. The workaround is to use TinyOWS.

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.

WFS-T "T" means transactions and that means writing data back to the server. TinyOWS is tightly tied to PostGIS

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

Implementation

Linux

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

Windows

When I installed Mapserver on City of Corvallis Windows servers I made these notes: Mapserver on Windows This server is currently behind a firewall. (links on the Windows page only work on my desktop machine there.)

Using MapServer on Linux

Mapserver applications

A mapserver app is the collection of files necessary to create an interactive site. Mapserver by itself takes input in the form of spatial data and a .MAP file, and turns out an image file containing a map.

Creating an application requires assorted template and html and javascript files to 'wrap around' mapserver and present the maps and a user interface to allow panning, zooming, querying and so forth.

You can craft an application from scratch but a more sensible approach is to hang your data files on an existing applications. Here are some little reviews on a few of the more popular free applications for mapserver.

Openlayers and Leaflet

Openlayers and Leaflet are obvious choices.

Geomoose

I have a separate page for it... Geomoose

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.)

Chameleon

This one is not working today. Brian Wilson 15:07, 7 May 2006 (PDT)

Chameleon is 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

I used to have a section here all about ELLAmaps. I leave this note here out of nostalgia. It was used in Benton county for years. It only worked with Internet Explorer!

Maplab

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.

Mapserver and SVG

Since version 4.5, mapserver has supported SVG as an output format. Refer to the official SVG howto at the mapserver site.

As with the other output formats, pretty much all you need do to use it is to specify the file type as SVG in the MAP file. (Of course, support for svg has to be built into mapserver.)

Change IMAGETYPE PNG to IMAGETYPE SVG and the output file will be xml. That's about it.