Pandora:Current development:Pandora GIS Backend

From Pandora FMS Wiki

Jump to: navigation, search

Contents

Pandora FMS GIS Backend

The Pandora FMS GIS features require some extra infrastructure this is an appendix to explain a bit this backend and a possible implementation.

Map Server Architecture

The architecture used is based on a Mapnik + OpenStreetMap map server.

Basically the only need from Pandora FMS point of view is a web server serving the tiles that form the map (we will call this the tile server).

The main components of the architecture and the work flow it's defined in the following diagram.

Image:Pandoar_GIS_backend_architecture.svg

So there is the OpenStretMaps information that it's loaded on a PostgreSQL with the PostGIS extensions using the osm2pgsql utility.

Once the data is loaded on the spacial database, a tile renderer (in this case Mapnik) is used to render the tiles and prepare them on the folder structure needed for the tile server to serve them (the web server can serve the tiles as static images).

Instalation and Setup

This is a possible way to install all and prepare all the environment to work with Pandora FMS.

Instal a Debian system

This is suposed to be used on a Debian Linux, so first step. Install Debian

Install needed packages

PostGIS: (PostgreSQL + PostGIS).

# aptitude install postgresql-postgis
# aptitude install osm2pgsql


Get the osm data files

The snapshot of the OpenStretMap database

$ wget http://planet.openstreetmap.org/planet-latest.osm.bz2

It's also possible to get smaller regional files from Cloudmade like:

$ wget http://downloads.cloudmade.com/europe/spain/spain.osm.bz2

And the coastlines:

$ wget http://tile.openstreetmap.org/world_boundaries-spherical.tgz
$ wget http://tile.openstreetmap.org/processed_p.tar.bz2
$ wget http://tile.openstreetmap.org/shoreline_300.tar.bz2

Setup the PostGIS database

As the postgres user setup the database:

$ createuser pandora_gis
$ createdb -E UTF8 -O pandora_gis gis_db
$ createlang -U pandora_gis plpgsql gis_db

$ psql -U pandora_gis -f /usr/share/pgsql/contrib/postgis.sql gis_db
$ psql -U pandora_gis -f /usr/share/pgsql/contrib/spatial_ref_sys.sql gis_db

$ psql -U pandora_gis -d gis_db -f 

Load the data into the database

Uncompress the database file.

$ bzip2 -d planet-latest.osm.bz2

Load the uncompressed database file with osm2pgsql:

$ osm2pgsql --slim -H localhost -U pandora_gis -d gis_Db ./planet-latest.osm

Now all the information is on the database, with this and the coastlines previously downloaded Mapnik can render the tiles.

Prepare the world boundaries

$ tar zxvf world_boundaries-spherical.tgz
$ tar -jxvf processed_p.tar.bz2
$ mv coastlines/* world_boundaries/
$ rmdir coastlines
$ mv shoreline_300.tar.bz2 world_boundaries/
$ cd world_boundaries
$ tar -jxvf shoreline_300.tar.bz2

Render the tiles with Mapnik

$ wget http://download.berlios.de/mapnik/mapnik-0.6.1.tar.bz2
$ tar -jxtarvf mapnik-0.6.1.tar.bz2
$ cd mapnik-0.6.1
$ python scons/scons.py
$ sudo python scons/scons.py install
$ sudo ldconfig
$ cd ..
$ svn export http://svn.openstreetmap.org/applications/rendering/mapnik
$ cd mapnik
$ ./generate_xml.py --host localhost --user pandora_gis --dbname gis_db --symbols ./symbols/ --world_boundaries ../world_boundaries/ --port 5432 --password 'secret_password'

Take one of the XMLs among the templates and personalize it they are more or less self explanatory (they can also be used out of the box) and then you can call the generate_tiles.py (editing this file to adjust some settings like the bounding box maybe it's needed)

$ MAPNIK_MAP_FILE="osm.xml" MAPNIK_TILE_DIR="tiles/" ./generate_tiles.py

Tile Server

Move the directory structure generated by Mapnik to the Tile Server (a web server for static files).

References

Several interesting references used to prepare the backend.

Mapnik

OpenStreetMap

OS Geo

The Open Source Geospatial Foundation

PostgreSQL