[OSM-dev] Lite OSM backend

Lars Aronsson lars at aronsson.se
Fri Sep 8 13:58:06 BST 2006


Dean Earley wrote:

> I'm currently using SQLite (2.8) as a binary backend but... The 
> 3GB XML generates a 3.8GB database file WITHOUT indexes on the 
> node positions.

Last week I compiled some statistics about the geographical 
distribution of the nodes in planet.osm and published on my wiki 
user page, http://wiki.openstreetmap.org/index.php/User:LA2

I decided to use the 6x8 degree zones defined for UTM, the 
Universal Transversal Mercator coordinate system, as explained on 
http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system

I think it could be a useful project in itself to split the 
planet.osm into small files, one for each UTM zone.  Steve could 
still generate the large planet.osm and someone else could take on 
to split it into zones.  Users could download the kind they want.

Parsing the planet.osm file format is a separate issue, but once 
you have the latitude and longitude in two variables, the 
following Perl code can be used to determine the UTM zone:

    my @zones = split ("", "ABCDEFGHJKLMNPQRSTUVWXYZ");
    my $latzone = $zones[int(($lat + 96.0) / 8)];
    my $lonzone = 1 + int(($lon + 180.0) / 6);
    $lonzone = 60 if ($lonzone > 60); # exactly 180.0
    # Exception for Norway: 32V is extended west
    $lonzone = 32
	if ($lonzone == 31 && $latzone eq "V" && $lon > 4.5);
    # Exception for Svalbard: 32X, 34X, 36X don't exist
    $lonzone = 1 + 2 * int(($lon + 183.0) / 12)
	if ($latzone eq "X" && $lon > 0.0 && $lon < 42.0);
    print "$lonzone$latzone\n";

This will print the zone, e.g. 33V for most of Sweden or 31U for 
Paris and eastern London.  I suggest filenames like 33V.osm


-- 
  Lars Aronsson (lars at aronsson.se)
  Aronsson Datateknik - http://aronsson.se




More information about the dev mailing list