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

Christoph Wagner freemaps.osm at googlemail.com
Tue Dec 21 09:34:48 GMT 2010


Am 21.12.2010 10:07, schrieb Marko Mäkelä:
> 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)
> 

Thanks for your ideas. I didn't recognize until now, that there could be the same IDs for different types.
Wouldn't it be usefull to have methods to build such a standard osm number where the type is encoded and methods to choose the right OsmPrimitive at reconstruction?

It's not a big thing, I think.

Thanks
Christoph

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openstreetmap.org/pipermail/josm-dev/attachments/20101221/1ece169f/attachment.pgp>


More information about the josm-dev mailing list