Closed zbycz closed 4 years ago
Unfortunately, the IDs in imposm are still a mystery to me.
imho:
osm_id
value .. one of the solution is : check/set the use_single_id_space
flag ..
// SingleIDSpace mangles the overlapping node/way/relation IDs
// to be unique (nodes positive, ways negative, relations negative -1e17)
in sql
-- sql code fragment ...
-- nodes positive
WHEN (id >= 0 ) THEN 'n'|| id::text
-- ways negative
WHEN (id >= -1e17 ) AND (id < 0 ) THEN 'w'|| (abs(id))::text
-- relations negative -1e17
WHEN (id < -1e17 ) THEN 'r'|| (abs(id) -1e17)::text
and check/read the issues .. related this flag ..
imho2:
use_single_id_space
) ...IDs are inconsistent
imho3:
if you want to understand the logic of imposm3 .. then you have to check the code,
( singleIDSpace
== use_single_id_space
)
func (ww *WayWriter) wayID(id int64) int64 {
if !ww.singleIDSpace {
return id
}
return -id
}
func (rw *RelationWriter) relID(id int64) int64 {
if !rw.singleIDSpace {
return -id
}
return element.RelIDOffset - id
}
I use imposm for creating vector tiles (MVT) using the openmaptiles project.
related openmaptiles issue ( with more workaround ) : https://github.com/openmaptiles/openmaptiles/issues/303
@ImreSamu Thank you very much. You solved the mystery for me! 👍👍🎉🎉
I had two issues and mistaken them as one:
1) openmaptiles outputs OSM ids only for some layers. I have mixed it altogether, and was surprised that some ids are just sequential integers. (I guess that means that they use use_single_id_space
correctly)
2) I discovered 0X=node and 1X=way, but didnt realised that 4X are really just relations. Now it works perfectly. (They use SQL like
CASE WHEN osm_id<0 THEN -osm_id*10+4 ELSE osm_id*10+1
)
Context
I use imposm for creating vector tiles (MVT) using the openmaptiles project. My ultimate goal is to create a universal OSM browser with clickable map and rich info panel - beta here: https://osmapp.org/?id=w34633854
Unfortunately, the IDs in imposm are still a mystery to me. I found out that id starting with 0 is a node and with 1 is a way, but very often the id is a small integer which doesnt comply with this system.
Expected Behavior
The id has some system which can be decoded. For eg.
XXX0
- osm node with id XXXYYY1
- osm way with id YYYZZZ2
- osm relation with id ZZZActual Behavior
Some ids are in form of
0<nodeid>
or1<wayid>
, but some features (relations?) have ids like4<randomnumber>
. And some even have integers like123
which doesnt refer to any schema(?).Steps to Reproduce
Just see any output from imposm. Can provide steps if needed :-)
.
//ref https://github.com/openmaptiles/openmaptiles/issues/792