Mapserver: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
mNo edit summary
Brian Wilson (talk | contribs)
 
(72 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]]
 
== 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
 
[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
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
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!
 
[http://maptools.org/ms4w 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 = [http://www.pythonware.com/products/pil/ Python Imaging Library]<br>
 
 
 
 
==== FWTools ====
 
===== Installation =====


Download the binary and execute it.
You can combine mapserver with other components to enhance its functionality.


''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.
== Implementation ==


===== Configuration =====
=== Linux ===


After it's installed you have to enable the CGI portion. I did this by
I have more information on my public Linux server down below, and details on
creating a new "Virtual Directory" called fwms, so I can access the mapserv.exe
setting up the server here: [[Mapserver on Linux]]
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."
=== Windows ===
error so I know it's executable.


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


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


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


==== Python Mapscript ====
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.


[[Image:Python extension.jpg|thumb|left]]
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.


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


<br clear=all>
==== Openlayers and Leaflet ====


Did all that. I can run a python script now, a simple one called [[simple_hello.py]] that shows system time.
Openlayers and Leaflet are obvious choices.
Now for mapscript. It gives me this:


<blockquote>
==== Geomoose ====


<h2>CGI Error</h2>
I have a separate page for it... [[Geomoose]]
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:


=== Short reviews of some MapServer apps running under Linux ===


Traceback (most recent call last):
I have sample setups of each of these on my server to try them out.
  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.
</blockquote>


sys.path returns
==== Rosa ====
['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,
Site: http://www.maptools.org/rosa/index.phtml
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.
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.
I think I shall try Apache.


== Linux / CDS implementation ==
If you install gmap, you get a copy of the Rosa applet at no extra charge.


=== Installation ===
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 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!
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.


Look in their [http://mapserver.gis.umn.edu/cgi-bin/wiki.pl MapServerWiki].
==== gmap ====
Here is a doc on [http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?MapServerCompilation MapServerCompilation]


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


I built a special Web server to run MapServer for two reasons.
I have version 4.0 installed currently.
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
This is a sample PHP/Mapscript implementation. You can turn layers
as a loadable Apache module. For MapServer this is not a big deal but again some of
on and off, you can redraw and resize the map.
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
It will use the Rosa Java applet by default but you can turn it off.
not bloated like recent versions of Redhat. The support from the Trustix team is excellent.
With my IE system, the Java app did not work. The non-Java version works fine.


Relevant installed packages with TSL 2.1 include
Easy to set up. Especially if you want a map of Canada. :-)


'''Apache 2.0.51''' -- installed from '''apache''' TSL package
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.)


'''PostgreSQL 7.4.5''' -- installed from '''postgresql'''
==== Chameleon ====
and '''postgresql-devel''' TSL packages


'''GD 2.0.27''' Boutell's graphics library is not available through Trustix.
This one is not working today. [[User:Brian Wilson|Brian Wilson]] 15:07, 7 May 2006 (PDT)
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 [http://www.php.net/ PHP] 4.3.9
Chameleon is a framework on which to hang OGC compliant services (and [http://www.mapbender.org Mapbender] is another one).
as a CGI -- the TSL version is a module. Building PHP required installing these TSL packages: '''flex''',
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.  


The options I used for the PHP configure script are:
To get Chameleon running under Linux, I had to add support for wmsclient to MapServer (Mapscript) which in turn required curl.


<pre>
"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
./configure \
        --with-pear \
        --with-regex=system \
        --with-zlib \
        --with-gettext \
        --with-xml \
        --with-pgsql
</pre>


This is a bit minimal for me. Usually I build in a lot more features but
My sample: http://mapserver.wildsong.biz/chameleon/
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
The docs for it: http://mapserver.wildsong.biz/chameleon_docs


I could not find a good clear example of this -- apparently everyone uses SAPI PHP.
Site: http://chameleon.maptools.org/index.phtml


'''ADD APACHE MY CHANGES HERE!!!
==== ELLAmaps ====
'''
Projections - [http://proj.maptools.org/ 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
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!


[http://www.gdal.org/ GDAL] 1.2.3<br>
==== Maplab ====
GDAL is the "Geospatial Data Abstraction Library".
GDAL is a translator library for [http://www.gdal.org/formats_list.html raster geospatial data formats].


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


I built the entire GDAL package with './configure; make; make install'
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.


'''Building MapServer'''
== Mapserver and SVG ==


MapServer wanted me to install [http://sourceforge.net/project/showfiles.php?group_id=3157 Freetype] but there is no TSL Freetype so I installed
Since version 4.5, mapserver has supported [[SVG]] as an output format.
version 2.1.9 from source with the traditional './configure; make; make install',
Refer to the official [http://mapserver.gis.umn.edu/docs/howto/svg-howto SVG howto] at the mapserver site.


The configuration I used for the actual MapServer build looks like this:
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.)
<pre>
./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
</pre>


I would like to add --with-postgis but I have not installed PostGIS yet.
Change IMAGETYPE PNG to IMAGETYPE SVG and the output file will be xml.
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.