Skip to content

Simple graph creator for the CHConstructor of the ToureNPlaner and other software at the fmi Stuttgart

Notifications You must be signed in to change notification settings

fmi-alg/OsmGraphCreator

Repository files navigation

OsmGraphCreator

The OsmGraphCreator is a command line utility to extract roads from an OpenStreetMap data set.

Setup

Clone

git clone --recursive <url>

Dependencies

  • cmake
  • google protobuf
  • zlib
  • libicu-dev
  • libcppunit-dev
  • crypto++
  • ragel
  • cgal

Building

    mkdir build
    cd build
    cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=TRUE -DCONFIG_CREATOR_COPY_TAGS=OFF ../
    make

Set CONFIG_CREATOR_COPY_TAGS=ON to get tags for each node and edge in the stringCarryOver field. The format is the same as the tag key defined in by the Overpass-Turbo-JSON.

Docker

A Dockerfile can be found in the folder docker.

Usage

The project currently builds a single executable located in the creator folder of your build folder.

./creator -g fmitext -t distance -c ../../data/configs/car.cfg -o mygraph.txt mygraph.osm.pbf

Configuration

The creator needs a configuration file to map edge types to maximum driving speed which is used if an edge does not have a maxspeed tag. Sample configuration file can be found in the folder data/configs. Note that only configured edge types are part of the graph. The configuration file format is quite simple:

<osm highway keys' value>
<our own edge id>
<maximum driving speed in km/h>

See the file all.cfg for an example with almost all edge types.

Edge weights

The edge weight is selected by the -t option with the following options:

  • distance calculates the distance in $[\frac{m}{distance\ multiplier}]$
  • time calculates travel time based on edge type in $[\frac{s}{time\ multiplier}]$
  • time calculates travel time based on maxspeed tag and edge type in $[\frac{s}{time\ multiplier}]$

The time multiplier and distance multiplier allow weights to be scaled according to the needs of the user. By default distance is measured in meters and time in centiseconds.

Advanced options

The creator has some advanced options to process large graphs.

Connected components: Splitting the graph into its connected components is possible using the following options:

  • -cc split graph into connected components
  • -ccs NUM drops all connected components that are smaller than NUM

Selecting a subset of the data: A subset of the input can be selected using the `-b' option.

File Formats

The creator supports multiple output formats which are described in the following. See the readers folder for examples.

Text Formats

The format of text graphs is always

METADATA
NODES
EDGES

Metadata

This information is common to all text formats. It is the header of the files.

Id : <unsigned integer>
Timestamp : <UNIX timestamp>
Type: <type of the graph>
Revision: <unsigned integer>
<number of nodes as unsigned integer>
<number of edges as unsigned integer>

fmitext

The fmitext graph is of type standard.

Node format:

NODE_ID OSM_ID LAT LON ELEVATION [TAGS]
<uint32_t> <int64_t> <double> <double> <uint16_t> [<JSON>]

Edge format:

SOURCE_NODE_ID TARGET_NODE_ID WEIGHT TYPE [TAGS]
<uint32_t> <uint32_t> <int32_t> <int32_t> [<JSON>]

The interpretation of the WEIGHT depends on the selected options. See the options -dm, -tm and -t.

fmimaxspeedtext

The fmimaxspeedtext graph is of type maxspeed.

Node format:

NODE_ID OSM_ID LAT LON ELEVATION [TAG_STRING_SIZE TAG_STRING]
<uint32_t> <int64_t> <double> <double> <uint16_t> [<uint16_t> <CHARS>]

Edge format:

SOURCE_NODE_ID TARGET_NODE_ID WEIGHT TYPE MAXSPEED [TAG_STRING_SIZE TAG_STRING]
<uint32_t> <uint32_t> <int32_t> <int32_t> <int32_t> [<uint16_t> <CHARS>]

The interpretation of the WEIGHT depends on the selected options. The MAXSPEED field is in km/h. See the options -dm, -tm and -t.

Examples

# travel time as edge weight
# edge speed from maxspeed tag
# only roads available to cars
# split into connected components, but drop all with less than 1024 nodes
# use files bremen, hamburg and saarland from Geofabrik (you have to download these yourself)
# write resulting files to compound directory
/creator -g fmimaxspeedtext -t time -ccs 1024 -c ../../../../data/configs/car.cfg -o compound/ bremen-latest.osm.pbf hamburg-latest.osm.pbf saarland-latest.osm.pbf

About

Simple graph creator for the CHConstructor of the ToureNPlaner and other software at the fmi Stuttgart

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •