{
  "date": "2011-01-01 17:12:06+01:00"
}
# OSM Technical introduction

January 2, 2011

Enrico Zini (enrico@debian.org)

KaLUG Mapping Party, Kaohsiung, January 2, 2011

# OSM data types

The while map in OpenStreetMap is built with only 3 kind of elements:
 * Nodes;
 * Ways;
 * Relations.

The structure is simple to understand and to manipulate with software, but it
is at the same time very flexible and powerful.

## Nodes

[Nodes](http://wiki.openstreetmap.org/wiki/Data_Primitives#Node) represent one
point on the map.

They contain:

 - ID: unique among nodes
 - Latitude: [-90.0, 90.0], 7 decimal places
 - Longitude: [-180.0, 180.0], 7 decimal places
 - Tags: zero or more “key: value” pairs

Examples:

 - A point of interest
 - A part of a way

## Ways

[Ways](http://wiki.openstreetmap.org/wiki/Data_Primitives#Way) are ordered
interconnections of 2 to 2000 nodes.

They can be open or closed. Closed nodes can become areas depending on their
tags.

They contain:

 - ID: unique among ways
 - Nodes: list of node IDs
 - Tags: zero or more “key: value” pairs

Examples:

 - A road
 - A park

## Relations

[Relations](http://wiki.openstreetmap.org/wiki/Data_Primitives#Relation)
are ordered list of 0 or more nodes, ways or relations.

They are used to represent features made of multiple ways, or properties of a
group of ways.

Use them rarely and carefully!

They contain:

 - ID: unique among roles
 - Tags: same as with nodes and ways; most important tag is type
 - Members: an ordered list of primitives with associated role (where role may
   be any text).

Examples:

 - Bus routes, cycle routes, numbered highways...
 - Multipolygons (e.g. buildings with courtyards inside)
 - Routing hints

# Extracting data

Some ways to get raw OSM data:

 * The [API](http://wiki.openstreetmap.org/wiki/Protocol): standard used by most OSM software
 * The [XAPI](http://wiki.openstreetmap.org/wiki/XAPI): allows more powerful searches
 * [XML exports](http://wiki.openstreetmap.org/wiki/Planet.osm): the whole world or some region all in one file
 * [PBF](http://wiki.openstreetmap.org/wiki/PBF_Format)
   [exports](http://download.geofabrik.de/osm/) (NEW!): more efficient and faster than XML

# Some development tools

Renderers, widgets and databases:

 * [OpenLayers](http://openlayers.org/) for the web
 * [Champlain](http://wiki.openstreetmap.org/wiki/Libchamplain), a map widget for Gnome
 * [Memphis](http://trac.openstreetmap.ch/trac/memphis/) a map renderer for Gnome
 * [OSM GPS Map](http://nzjrs.github.com/osm-gps-map/) another map widget for Gtk
 * [PostGIS](http://wiki.openstreetmap.org/wiki/Postgres) allows to perform fast geospatial queries on map data imported in PostgreSQL
 * [SpatiaLite](http://wiki.openstreetmap.org/wiki/SQLite) has the same functions as PostGIS but on a smaller scale

There is a lot of software and libraries available also for
[Android](http://wiki.openstreetmap.org/wiki/Android)
or [iPhone/iPad](http://wiki.openstreetmap.org/wiki/Apple_iOS).

[CloudMade](http://cloudmade.com/) offers [a very advanced toolset for several platforms](http://developers.cloudmade.com/projects) but it is not free software.

# Development ideas

 * [Create your own map site](http://wiki.openstreetmap.org/wiki/Deploying_your_own_Slippy_Map)
 * Portable offline library of POIs

# Licensing

There is a plan for changing the license from
[CC-By-SA](http://creativecommons.org/licenses/by-sa/2.0/) to
[ODbL](http://www.opendatacommons.org/licenses/odbl/summary/).

The new license has the same features as the old one, but it fixes some
[problems](http://wiki.openstreetmap.org/wiki/Open_Data_License_FAQ#What.27s_wrong_with_the_current_licence.3F) of CC-By-SA when applied to databases.

There is a
[plan](http://wiki.openstreetmap.org/wiki/Open_Data_License/Implementation_Plan)
for migration: when you log in to OSM please remember to tell the system if you
agree to relicense your data with the new license.

There is also a [map](http://osm.informatik.uni-leipzig.de/map/?zoom=15&lat=22.68232&lon=120.30049&layers=B0) that shows what parts of the map has already been agreed for relicensing.
