From OpenStreetMap Wiki
Jump to: navigation, search

The current OSM server can hardly stand all the requests. Caches are needed. So little-osm is a start for any users that just want to read the data in their favourite application.

little-osm is an simple and primitive OSM server, aimed to be executed at anyone's home machine.

little-osm is intended as a read only server!


the README file contains partly incorrect instructions. The instructions below do work (at least on July, 11 2007)


  • Get the Openstreetmap source code
  • The little-osm codebase is under /applications/utils/little-osm/ in the main codebase
  • Get ruby, rubygems and mysql ('gem install mysql', on Debian-based distros install the packages 'rubygems libmysql-ruby mysql-server', on Mandriva install the packages ruby, mysql and ruby-mysql)
  • Get the planet.osm from somewhere. ( and put this (unzipped) file in /applications/utils/little-osm/
  • run 'mysql -u root < planet.sql' to create the table
  • run 'ruby readxml.rb'. This will take awile. If you get errors after an hour, you have a corrupt planet.osm (Bugreport to user:Imi Imi)
  • run the server with 'ruby server.rb'

What are differences?

There are some differences to the main server's map request:

  • little-osm will order the objects in any arbitrary order.
  • only nodes within the bbox are transfered. (The main OSM server also transfer nodes to line segments which have the other end in the bounding box.)
  • segments, that cross the corners are transfered as well (but not their nodes). Some segments that actually do not cross the bbox could be also transfered.

Package layout

./readxml.rb Script to convert a planet.osm into a mysql database
./planet.osm here, you have to copy the planet.osm to read in.
test/* Some unit tests.
api/ All API files reside here.

Database layout

The database in an very optimized format (for map-queries). It consist only of a single table:

 `uid` int(10) unsigned NOT NULL default '0',
 `tags` text,
 `time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
 `reference` text,
 `min` point NOT NULL,
 `max` point NOT NULL,
 KEY `Index_1` (`uid`),
 spatial (`min`),
 spatial (`max`)

(see file applications/utils/little-osm/planet.sql)

  • The uid is unique among all entries. It is the osm-id shifted by 3 bits, added 1 for segments and 2 for ways.
  • The tags are an \n - seperated list of keys and values (key1\nvalue1\nkey2\n...).
  • reference is empty for nodes, "from_id,to_id" for segments and "seg1,seg2,seg3..." for ways.
  • The other coordinates are the bounding boxes for the object. For nodes, the bounding box is always only a point.