Pandora: Current development: Pandora GIS Backend

From Pandora FMS Wiki
Jump to: navigation, search

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

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

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

1.2 Instalation and Setup

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

1.2.1 Instal a Debian system

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

1.2.2 Install needed packages

PostGIS: (PostgreSQL + PostGIS).

# aptitude install postgresql-postgis
# aptitude install osm2pgsql

1.2.3 Get the osm data files

The snapshot of the OpenStretMap database

$ wget

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

$ wget

And the coastlines:

$ wget
$ wget
$ wget

1.2.4 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 

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

1.2.6 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

1.2.7 Render the tiles with Mapnik

$ wget
$ tar -jxtarvf mapnik-0.6.1.tar.bz2
$ cd mapnik-0.6.1
$ python scons/
$ sudo python scons/ install
$ sudo ldconfig
$ cd ..
$ svn export
$ cd mapnik
$ ./ --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 (editing this file to adjust some settings like the bounding box maybe it's needed)

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

1.2.8 Tile Server

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

1.3 References

Several interesting references used to prepare the backend.

1.3.1 Mapnik

1.3.2 OpenStreetMap

1.3.3 OS Geo

The Open Source Geospatial Foundation

1.3.4 PostgreSQL