[OSM-dev] Is YOUR code 64 bit proof?

Frederik Ramm frederik at remote.org
Thu Dec 27 13:55:31 GMT 2012


Hi,

    another 62 million nodes and we'll have IDs of more than 2^31-1 
which means than software using a simple, 32-bit, signed integer will 
not be able to process the data any longer.

If you're using C or similar compiled languages and have used as simple 
"int" for your IDs, it is likely that node IDs above 2**31-1 will appear 
as large negative numbers, and node IDs above 2**32 will appear as 1, 2, 
3 etc.

Needless to say, this, if undetected, is likely to cause all sorts of 
strange effects.

The quick fix is to switch from signed to unsigned integers which would 
give you a little more breathing room; but you lose the ability to 
process files with negative IDs like those created by JOSM when you add 
new objects. The better fix is to switch to real 64bit integers at least 
for node IDs; of course this might increase your memory requirement if 
you're keeping a lot of nodes around.

(If you are using Osmium then you can patch it by changing the 
osm_object_id_t from int32_t to int64_t in include/osmium/osm/types.hpp.)

I've commited to SVN a couple of files with large node IDs so that you 
can quickly check your own programs or those you're using:

http://svn.openstreetmap.org/misc/64bit_testdata/

There's a README there.

Happy testing,
Frederik

-- 
Frederik Ramm  ##  eMail frederik at remote.org  ##  N49°00'09" E008°23'33"



More information about the dev mailing list