Libosmscout

From OpenStreetMap Wiki
Jump to: navigation, search

Contents

Overview

libosmscout offers applications simple, high-level interfaces to offline rendering and routing functionalities based on OpenStreetMap data, written by Tim Teulings. For details see a copy of one of his postings to the osm routing mailing list below.

It does so by preprocessing *.osm/.pbf data files and generating binary data and index files for fast access.


To get an impression of the rendering quality and routing functionality have a look at the rather old screenshots and demo video or look at the blog of the main author for current acitivity and screenshots.

The source code is licenced LGPL and is hosted at http://sourceforge.net/projects/libosmscout/

Note that libosmscout code is still in flux, this web page tries to be up to date, but mail fail so. If you have the feeling, that the documentation does not match, please try to contact the author and even better the libosmscout mailinglist.

Components

Import

This tool grabs some osm.osm/.pbf XML file and converts it to a special binary format containing the geometries.

libosmscout

This library can be used by application programmers to access the data in the aforementioned binary file, created by the importer.

libosmscout-import

This library holds the code to import *.osm and *.osm.pbf files. It is currently only used by the Import application.


libosmscout-map

libosmscout-map does all the map drawing using libosmscout as basis. libosmscout just defines an interface for the database that libosmscout-map uses, so in priciple even the local file database would be exchangeable. It does not contain any actual backend, the individual backends have their own libraries.

libosmscout-map-cairo

Cairo map drawing backend. This is the reference backend.

libosmscout-map-qt

Qt map drawing backend. Feature complete.

libosmscout-map-agg

Agg map drawing backend. Misses code for drawing external images, patterns, plate labels and symbols.

libosmscout-map-svg

SVG map drawing backend. Misses code for drawing external images, patterns, plate labels and symbols. No text support.

OSMScout

A simple map application using the Qt toolkit by Trolltech/Nokia

TravelJinni

A simple map application using the illumination toolkit.

Demos

Some example code showcasing the usage of libosmscout. These are:

DrawMapQt

An example how to use Qt to render a small area to a .png image. Common usage:

DrawMapQt <map directory> <style-file> <width> <height> <lon> <lat> <zoom> <output>

Example usage:

src/DrawMapQt ../TravelJinni/ ../TravelJinni/standard.oss.xml 640 480 7.13 50.69 10000 test.png

Usage

This is a short manual describing how to get libosmscout, libillumination and TravelJinni running.

Building TravelJinni

Dependencies

Debian, Ubuntu:

sudo apt-get install git-core subversion build-essential autoconf autotools-dev automake libtool libxml2-dev libcairo2-dev libprotobuf-dev protobuf-compiler

Moblin, Fedora:

sudo yum install git subversion gcc-c++ make autoconf automake libtool libxml2-devel cairo-devel libXext-devel

Build

The current version has a global makefile that triggers all local make files. If you want to trigger a complete Unix-toolchain based build (make, autotools, libtool, pkg-config) assure that you have extended your pkg-config lookup directories pointing to all libosmscout* top level directories (extends environment variable PKG_CONFIG_PATH) and that you have extended your library search path to include src/.libs for all libosmscout* directories (extend environment variable LD_LIBRARY_PATH):

After that simply call

make full

in the main directory. This should build everything (that is buildable because dependencies are fulfilled).

As an alternative you can use below bash script as an example how to trigger a (partial) build.

#!/bin/bash
 
# download and compile libillumination
svn co https://illumination.svn.sourceforge.net/svnroot/illumination/trunk/Illumination illumination
cd illumination/
./autogen.sh && ./configure && make
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(pwd)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/src/.libs
cd ..
 
# download libosmscout libraries, Import, TravelJinni
git clone git://libosmscout.git.sourceforge.net/gitroot/libosmscout/libosmscout
cd libosmscout
 
# compile libosmscout
# yes, once again:
cd libosmscout 
./autogen.sh && ./configure && make
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(pwd)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/src/.libs
cd ..
 
# compile libosmscoutimport
cd libosmscout-import
./autogen.sh && ./configure && make
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(pwd)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/src/.libs
cd ..
 
# compile libosmscoutmap
cd libosmscout-map
./autogen.sh && ./configure && make
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(pwd)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/src/.libs
cd ..
 
# compile libosmscoutmap-cairo
cd libosmscout-map-cairo
./autogen.sh && ./configure && make
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(pwd)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/src/.libs
cd ..
 
# compile TravelJinni
cd TravelJinni/
./autogen.sh && ./configure && make
cd ..
 
# compile the Import tool
cd Import/
./autogen.sh && ./configure && make
cd ..
 
cd ..

Converting OSM Data

Example:

# Create a folder for hosting the processed binary map data
mkdir -p ~/osmscout-map && cd ~/osmscout-map
 
# download a .pbf file
wget -c http://download.geofabrik.de/osm/europe/germany/niedersachsen.osm.pbf
 
# Copy over some configuration files
cp /path/to/libosmscout/Import/*.oss ./
cp /path/to/libosmscout/Import/*.ost ./
 
# run the Import tool. Pass reduced sizes to decrease memory requirements:
/path/to/libosmscout/Import/src/Import --nodesLoadSize 5000000 --waysLoadSize 500000 niedersachsen.osm.pbf

This will generate several binary data files (*.dat) and index files (*.idx). You may delete the niedersachsen.osm.pbf file now.

Run

You should run the binary file src/TravelJinni from inside the folder libosmscout/TravelJinni/, because some icon paths are still hardcoded.


If you want to convert data yourself, remember the path to the Import tool (libosmscout/Import). It is not recommended to change the path because it may not work properly.

You may also want to copy the libraries to some library path or simply make the paths permanent:

echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> ~/.bashrc
echo "export LD_LIBRARY_PATH" >> ~/.bashrc

Configuration

There are three configuration files:

.traveljinni.xml

This configuration file in your home directory is read by TravelJinni. It contains the path to your data (and map.ost) and to at least one style configuration (standard.oss.xml).

You need to set the correct paths in this file if you did not use the default path ~/.TravelJinni.

<?xml version="1.0" encoding="UTF-8"?>
<TravelJinni>
 <map dir="/home/tim/.TravelJinni/" active="true"/>
 <style file="/home/tim/.TravelJinni/standard.oss" active="true"/>
</TravelJinni>

The data directory (map dir) should contain the data files (*.dat), index files (*.idx) and map.ost (see section "Converting OSM Data").

You find the default style configuration file in the Import directory (libosmscout/Import/standard.oss).

TODO:

Postings

Blog posts

OSM routing, 2010-03-14

Hello!

I'm still looking for people interested in helping me with further development libosmscout (libosmscout.sf.net). The library steadily improves, but more people could simply get more work done faster ;-)

libosmscout is a C++ library, that implements offline map drawing and routing based on OSM data. It does this by import an existing *.osm file and generating a binary, plattform independent file based database and offering an high level API on top of this database.

The main target group of the library are people that are interested in developing applications based on OSM and that do not want to directly access available data using existing online APIs. Such applications of course also include offline navigation software but of course other, more specialized applications are possible.

Recent discussions with interested people however have shown that libosmscout has a much broader target group. Since the library consists of separate components for import, dataaccess, routing and map drawing, other usage senarios are also possible and I'm also looking for people that want to improve libosmscout in that direction:

infrastructure requirements.

share pre- and postprocessing and thus safe the developer the hassle to fiddle around with *.osm file format and generating a good textual routing description).

based map drawing

libosmscout currently depends on libxml and libcairo (, but even that could be abstracted ;-)) and thus should work on various platforms.

If you are interested take a look at libosmscout.sf.net for further details (and a video) or simply contact me.

Personal tools
Namespaces
Variants
Actions
site
Toolbox