high performance osm data manipulation with osmium - state of the map 2013

28
High Performance OSM Data Manipulation With Osmium Jochen Topf

Upload: osmfstateofthemap

Post on 22-Jun-2015

1.225 views

Category:

Technology


0 download

DESCRIPTION

*** Presented by Jochen Topf at State of the Map 2013 *** For the video of this presentation please see http://lanyrd.com/2013/sotm/scpkqw/ *** Full schedule available at http://wiki.openstreetmap.org/wiki/State_Of_The_Map_2013 Osmium is a highly flexible and performant C++ library for working with OpenStreetMap data. It helps with reading, writing, and filtering OSM data, OSM history data and OSM change files in XML or PBF format. Osmium assembles way and (multi)polygon geometries and converts them into many GIS formats such as shapefiles. It also contains code to store OSM data efficiently and much more. All of this in an easy to use C++ header-only library. Some functions are also available from Javascript to make it's use even easier. The talks shows what we have learned over the years about high- performance OSM data manipulation, the current state of Osmium and what the future might bring.

TRANSCRIPT

Page 1: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

High Performance OSM Data Manipulation With Osmium

Jochen Topf

Page 2: High Performance OSM Data Manipulation With Osmium - State of the Map 2013
Page 3: High Performance OSM Data Manipulation With Osmium - State of the Map 2013
Page 4: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

CC-BY http://www.flickr.com/photos/x1brett/4562610437/

Page 5: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Typical Problems

Slow.

Needs a lot of memory/disk space.

Doesn't work with entire planet.

Page 6: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

OSM Data

There isn't all that much data(current planet PBF: 23 GB)

But we need to store it efficiently!

Page 7: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

OSM Data

Often we can work on the datapiece by piece

Streaming

Page 8: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

C++

Page 9: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Osmium

A fast and flexible C++ libraryfor working with OSM data

Page 10: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

CC-BY http://www.flickr.com/photos/jronaldlee/4479381576/

Modular

Page 11: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Has to work withdata of entire

planet!

...or asmall extract!

Page 12: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Features

Basic OSM objects:Nodes, ways, relations, tags, ...

And operations on them.

Tag filtering

Page 13: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Input/Output

Read from: file, stdin or URL.Write to: file or stdout.

XML or PBF.Compressed or uncompressed.

OSM data (.osm) or changes (.osc).With or without history.

Page 14: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Geometry

Add node locations to ways

Assemble Multipolygons

Convert geometries to WKT, WKB, OGR, GEOS

Line length (haversine)

Page 15: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Handler

OSMfile

OSMfile Handler Writer Reader

Temp.Storage

For converter and filter

Page 16: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Example: main

#include <osmium/io/any_input.hpp>

int main(int argc, char* argv[]) {osmium::io::Reader reader(argv[1]);

NamesHandler handler;

reader.open();reader.push(handler);

}

Page 17: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Example: handler

#include <iostream>#include <osmium/handler.hpp>

struct NamesHandler : publicosmium::handler::Handler<NamesHandler> {

void node(const osmium::Node& node) {auto n = node.tags().get_value_by_key("name");

if (n) std::cout << n << std::endl; }

};

Page 18: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Statistics for61 million different tags

on 2.2 billion objects.

Runs for about two hours every day.

Needs less than 8 GB RAM.

taginfo.openstreetmap.org

Page 19: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Linux

Mac OS X

Windows

Page 20: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Osmium History

Development started October 2010

Recently started „New Osmium“

Page 21: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

The New Osmium

Object Storage/Transport

Indexes

Multithreading

(no multipolygon support yet)

The New Osmium

Page 22: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

C++11

Modern C++

Official ISO standard

Works with GCC 4.7.3, clang 3.2

Easier to write, more efficient, cleaner code

The New Osmium

Page 23: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Multithreading

Better design to take advantage of multithreading

Dynamic memory allocation is even worse than with single thread

The New Osmium

Page 24: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

osmcode.org

Osmiumand

Osmium-basedsoftware

github.com/osmcode

The New Osmium

Page 25: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Javascript

Old Osmium: osmjs

New Osmium: Working on NodeJS module

Page 26: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Status

Old Osmium: Tried and tested,In production for >2 years

New Osmium: New and untested,Not production ready yet

Page 27: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Thanks!

Page 28: High Performance OSM Data Manipulation With Osmium - State of the Map 2013

Thanks!

wiki.osm.org/wiki/Osmiumgithub.com/joto/osmium

osmcode.orggithub.com/osmcode/libosmium

Jochen [email protected]

Hackdaytomorrow!