[josm-dev] get OsmPrimitive just by ID not knowing type

Marko Mäkelä marko.makela at iki.fi
Tue Dec 21 09:07:37 GMT 2010


On Tue, Dec 21, 2010 at 09:54:00AM +0100, Frederik Ramm wrote:
>>Is that a missing feature in JOSM or is it not possible to find an osm 
>>object at the server just knowing the id?
>
>There can be a way with ID 1, a node with ID 1, and a relation with ID 1.

In other words, the ID consists of two components: the object type and 
the type-specific ID. If you want to convert it to a single number, you 
could (for now, until a new object type is introduced) use something 
like this:

id=type + osm_id*3

where type=0 for node, 1 for way, 2 for relation

Or use

id=type | osm_id << 3

if you want some room for future expansion (3 bits = type codes 0..7)

Best regards,

	Marko



More information about the josm-dev mailing list