Is there a way to get Way ID's timestamp and version?

I managed to get the response to include OSM way Ids, but I’m wondering if it’s possible to get the timestamp when the ways were created and its current version number? If not, how can I possibly add this to the graph?

You can follow the same approach as for the way ID Add OSM way ID encoded value by easbar · Pull Request #2701 · graphhopper/graphhopper · GitHub, but first you need to add the version and timestamp to the tags (or add them as new fields in ReaderWay), because they are attributes (not tags) in OSM. Here:

Something like

            tags.put("attr_version", way.getInfo().getVersion());
            tags.put("attr_timestamp", way.getInfo().getTimestamp());

This should work if your OSM file uses the pbf format. Otherwise you need to adjust the XML reader accordingly.

can you give a brief explanation of the bits part in EncodedValues?

when I test it out, I got the error. I tried to StringEncodedValues for version and timestamp

java.lang.IllegalStateException: Maximum number of values reached for osm_way_version: 31

StringEncodedValue is not a good fit here, because so many different values are possible. For version I think you can just use an IntEncodedValue. Timestamp is a bit more tricky, because it is a long (64bit) value and currently there is no LongEncodedValue. If you do not need the exact (ms) value, you could try to convert this to some 32bit (int) representation. Another approach would be not using an encoded value at all, and store the timestamps outside the graph somewhere. Depending on how you like to read the timestamps this is a bit tricky right now, but will be much easier with New signature for encoded values and tag parsers by easbar · Pull Request #2740 · graphhopper/graphhopper · GitHub

1 Like

(also note that we removed StringEncodedValue support for custom models in 7.0 due to the unclear use case compared to the Int or EnumEncodedValue: remove StringEncodedValue support from custom model due to insufficie… · graphhopper/graphhopper@e63c5f3 · GitHub )

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.