2006-04-11 05:00:39 +02:00
|
|
|
# $Id$
|
|
|
|
|
|
|
|
Mapnik OGC Server
|
|
|
|
-----------------
|
|
|
|
|
2006-04-13 04:39:49 +02:00
|
|
|
|
2006-04-11 05:00:39 +02:00
|
|
|
Introduction
|
|
|
|
------------
|
|
|
|
|
2006-04-13 04:39:49 +02:00
|
|
|
Mapnik provides a server package to allow the publishing of maps
|
|
|
|
through the open and standard WMS interface published by the Open Geospatial
|
|
|
|
Consortium (OGC). It is in implemented in Python, around the core C++
|
|
|
|
library.
|
2006-04-11 05:00:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
Features/Caveats
|
|
|
|
----------------
|
|
|
|
|
|
|
|
- WMS 1.1.1 and 1.3.0
|
|
|
|
- CGI/FastCGI
|
2006-04-16 21:23:37 +02:00
|
|
|
- GetCapabilities and GetMap support only (NO GetFeatureInfo)
|
2006-05-11 02:44:20 +02:00
|
|
|
- JPEG/PNG output
|
2006-04-16 21:23:37 +02:00
|
|
|
- XML/INIMAGE/BLANK error handling
|
2006-04-11 05:00:39 +02:00
|
|
|
- No real layer metadata support yet
|
2006-04-13 04:39:49 +02:00
|
|
|
- No re-projection support
|
2006-05-11 06:24:51 +02:00
|
|
|
- Needs to be able to write to tempfile.gettempdir() (most likely "/tmp")
|
2006-04-11 05:00:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
Dependencies
|
|
|
|
------------
|
|
|
|
|
|
|
|
Please properly install the following before proceeding further:
|
|
|
|
|
|
|
|
- jonpy (http://jonpy.sourceforge.net/)
|
|
|
|
- lxml (http://codespeak.net/lxml/)
|
|
|
|
- PIL (http://www.pythonware.com/products/pil)
|
|
|
|
- PROJ.4 (http://proj.maptools.org/)
|
|
|
|
|
|
|
|
|
|
|
|
Installation
|
|
|
|
------------
|
|
|
|
|
|
|
|
- Make sure you compile or re-compile Mapnik after installing PROJ.4, if this
|
|
|
|
was not done already. Mapnik includes a Python API to the PROJ.4 library
|
|
|
|
used by the ogcserver. The PROJ_INCLUDES and PROJ_LIBS parameters can
|
|
|
|
be passed to mapnik's scons build script to help with this.
|
|
|
|
|
|
|
|
You can test the availability of the PROJ.4 bindings by trying:
|
|
|
|
|
|
|
|
$ python
|
|
|
|
Python 2.3.4 (#1, Feb 22 2005, 04:09:37)
|
|
|
|
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
|
|
|
|
Type "help", "copyright", "credits" or "license" for more information.
|
|
|
|
>>> from mapnik import Projection
|
|
|
|
registered datasource : raster
|
|
|
|
registered datasource : shape
|
|
|
|
registered datasource : postgis
|
|
|
|
>>>
|
|
|
|
|
|
|
|
- The executable "ogcserver" in utils/ogcserver will work for both CGI and
|
|
|
|
FastCGI operations. Where to place it will depend on your server's
|
|
|
|
configuration and is beyond this documentation. For information on FastCGI
|
|
|
|
go to http://www.fastcgi.com/.
|
|
|
|
|
|
|
|
|
|
|
|
Configuring the server
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
- You will need to edit the ogcserver executable for now. It is a simple
|
|
|
|
Python text script.
|
|
|
|
|
|
|
|
1) Edit the path to the interpreter in the first line.
|
|
|
|
2) Edit the path to the config file if you don't like the default.
|
|
|
|
|
|
|
|
- Copy the sample configuration "ogcserver.conf" file in utils/ogcserver to
|
|
|
|
the location you specified in the previous step.
|
|
|
|
|
2006-04-13 04:39:49 +02:00
|
|
|
- Edit the configuration file to your liking, the comments within the file will
|
|
|
|
help you further. Be sure to at the very minimum edit the "module"
|
|
|
|
parameter, the server will not work without you setting it properly first.
|
2006-04-11 05:00:39 +02:00
|
|
|
|
|
|
|
|
2006-04-13 04:39:49 +02:00
|
|
|
Defining layers and styles for use by the ogcserver
|
|
|
|
---------------------------------------------------
|
2006-04-11 05:00:39 +02:00
|
|
|
|
2006-04-13 04:39:49 +02:00
|
|
|
The ogcserver obviously needs layers to publish. For now, with Mapnik, this
|
2006-04-11 05:00:39 +02:00
|
|
|
can only be done by writing code. In this case, a Python script will need to be
|
2006-04-13 04:39:49 +02:00
|
|
|
written to describe the layers and respective styles. For information on the Python
|
2006-04-11 05:00:39 +02:00
|
|
|
API, look in demo/python, or in docs/epydocs.
|
|
|
|
|
2006-04-13 04:39:49 +02:00
|
|
|
The server needs a python module, with code that looks like this:
|
|
|
|
|
2006-04-14 05:45:46 +02:00
|
|
|
from mapnik.ogcserver.WMS import BaseWMSFactory
|
2006-04-13 04:39:49 +02:00
|
|
|
|
2006-04-14 05:45:46 +02:00
|
|
|
class WMSFactory(BaseWMSFactory):
|
2006-04-11 05:00:39 +02:00
|
|
|
|
|
|
|
def __init(self):
|
2006-04-14 05:45:46 +02:00
|
|
|
BaseWMSFactory.__init__(self)
|
|
|
|
sty = Style()
|
2006-04-11 05:00:39 +02:00
|
|
|
...
|
2006-04-14 05:45:46 +02:00
|
|
|
self.register_style('stylename', sty)
|
|
|
|
|
2006-05-22 19:00:35 +02:00
|
|
|
lyr = Layer(name='layername', title='Highways', description='Highways')
|
2006-04-11 05:00:39 +02:00
|
|
|
...
|
2006-05-11 06:24:51 +02:00
|
|
|
lyr.styles.append('stylename')
|
|
|
|
self.register_layer(lyr)
|
2006-04-21 02:18:07 +02:00
|
|
|
self.finalize()
|
2006-04-14 05:45:46 +02:00
|
|
|
|
|
|
|
The rules for writing this class are:
|
|
|
|
|
|
|
|
- It MUST be called 'WMSFactory'.
|
|
|
|
- It MUST sub-class mapnik.ogcserver.WMS.BaseWMSFactory.
|
|
|
|
- The __init__ MUST call the base class'.
|
|
|
|
- Layers MUST be named with the 'name' parameter to the constructor.
|
|
|
|
- style and layer names are meant for machine readability, not human. Keep
|
|
|
|
them short and simple, without spaces or special characters.
|
2006-05-22 19:00:35 +02:00
|
|
|
- For human readable info, pass title='' and abstract='' parameters to the
|
|
|
|
Layer() call.
|
2006-04-14 05:45:46 +02:00
|
|
|
- The layers must have at least one style associated with them (a default).
|
2006-04-21 02:18:07 +02:00
|
|
|
- No Map() object is used or needed here.
|
|
|
|
- Be sure to call self.finalize() once you've registered everything! This will
|
2006-05-11 02:44:20 +02:00
|
|
|
validate everything and let you know if there's problems.
|
2006-05-11 06:24:51 +02:00
|
|
|
- Be sure to associate a default style with the layer. In the future, there
|
|
|
|
will be a mechanism to assign other non-default styles to a layer, to support
|
|
|
|
named styles through the STYLES= parameter.
|
|
|
|
|
|
|
|
To Do
|
|
|
|
-----
|
|
|
|
|
|
|
|
- Named style support.
|
|
|
|
- Improve configuration to allow for full server metadata.
|
|
|
|
- Investigate moving to cElementTree from lxml.
|
|
|
|
- Add some internal "caching" for performance improvements.
|
|
|
|
- Support GetFeatureInfo (Requires core changes).
|
|
|
|
- Switch to using C/C++ libs for image generation, instead of PIL (also
|
|
|
|
requires core changes). PIL requirement will remain for INIMAGE/BLANK
|
|
|
|
error handling.
|
2006-05-11 02:44:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
Conclusion
|
|
|
|
----------
|
|
|
|
|
|
|
|
This is the very first implementation of a WMS for Mapnik. Although inital
|
|
|
|
testing seems to suggest it works well, there may be bugs, and it lacks some
|
|
|
|
useful features. Comments, contributions, and requests for help should all be
|
|
|
|
directed to the Mapnik mailing list.
|
|
|
|
|
|
|
|
Enjoy!
|
|
|
|
J.F.
|