I am using Graphhopper 7 in a java application to perform map matching on an osm file. The map matching part works as expected. The problem is that mapped results do not include way tags that I expect. What I get in the result is an edge ID but for my use case, that is not enough.
An example of a way in the used osm file is:
way id=“236392032” version=“1” timestamp=“” uid=“1” user=“” changeset=“202212011”>
tag k=“highway” v=“primary”/>
tag k=“ref” v=“A7”/>
tag k=“oneway” v=“yes”/>
tag k=“official_name” v=“007”/>
tag k=“operator” v=“Overig”/>
tag k=“distance_marker_start” v=“3.982”/>
tag k=“distance_marker_end” v=“3.785”/>
What I need to see, next to edge ID, are the official_name and ref tags.
I get some advice to use TagParsers or EncodedValues, but could not find documentation/examples for using those…
There are two things you need here: First you need to make sure the tags you are interested in are considered during the OSM import. Then you need to setup your request such that these details are included in your response.
The “ref” tag is already included by default:
If you want the official_name (not just the name) tag as well I think you need to add similar code that does this.
Note that these tags are a bit special since there are very many possible values for these tags (unlike the highway tag for example), so they aren’t stored as EncodedValues, but rather using the KVStorage.
Do you use map matching via the /match endpoint (http)? If yes, all you need to receive the tags along the matched path is adding using the details parameter:
But note that if you modify the import code to use the official_name you need to add it also here:
where measurements is a list of Observation(com.graphhopper.util.shapes.GHPoint p )
So here is where i get confunsed again -_-, if I look at the implementation of KVStringDetails then it gets the saved value from the EdgeIteratorState which i can easily access via an EdgeMatch object… is my assumption correct?