papyrus_ogcserver provides an easy and convenient method for embeding a Mapnik OGCServer into Pyramid applications.
papyrus_ogcserver is based on papyrus_tilecache by Éric Lemoine https://github.com/elemoine/papyrus_tilecache
Installing Papyrus in an isolated virtualenv
is recommended
papyrus_ogcserver is installed using the applications setup.py
$ python papyrus_ogcserver/setup.py install
Often you'll want to make papyrus_ogcserver a dependency of your Pyramid
application, which is done by adding papyrus_ogcserver
to the
install_requires
list defined in the Pyramid application's setup.py
file.
Embeding a Mapnik OGCServer in a Pyramid application is easy.
Edit the application's development.ini
file and, in the main section
([app:]
), set ogcserver_config
to the location of the OGCServer config
file. Example:
[app:MyApp] use = egg:MyApp ... ogcserver_config = %(here)s/ogcserver.conf
In this example the OGCServer config file is located at the same location as
the development.ini
file.
An example ogcserver.conf is included and additional information is available at the mapnik ogcserver repository https://github.com/mapnik/OGCServer regarding the ogcserver configuration file.
The map itself is constructed in one of two ways: using either a mapnik xml file or using pure python through a WMSFactory.
- 1.) To use an xml defined map edit the application's
development.ini
- file and in the main section (
[app:]
), setmapfile
to the location of the mapnik xml file. - 2.) To use a python WMSFactory edit the application's
development.ini
- file and in the main section (
[app:]
), setserver_module
to the name of the module containing the MapFactory class (without extension .py)
Now, edit the application's main file, __init__.py
, and register
papyrus_ogcserver using the Configurator.include
method:
def main(global_config, **settings): config = Configurator(settings=settings) import papyrus_ogcserver config.include(papyrus_ogcserver)
That's it! The Pyramid application now exposes a Mapnik OGCServer service at
/ogcserver
.