Feed custom properties while parsing osm pbf

I have a custom property and osm ids. I need to add these into the cache files while parsing. Is there any way I can add the property based on osm id?

Hi Kai,

you can have a look at this repo and also have a look at this post. Hope this helps.

Best,
Robin

boldtrn… The problem is these tags are not part of the pbf which I get from osm. These are custom tags which I get from some other content provider. I think this is similar to injecting traffic data.
I want these tags to influence the route calculation and not just sit there.
Perhaps, I need to add a custom weight as well, for it to influence route calculation.

I’ll simplify what I want to do, maybe you can suggest a different approach. I have osm IDs which I want to be preferred​ while route calculation. Maybe I could even use avoid edge weighting and tweak it a bit to prefer edges instead of avoiding.
But the first hurdle is, to get the tag loaded in the cached files and these tags are in a separate file, not in the osm pbf file.

Well, you could do this in the post processing processing step in the GraphHopper.java class and write your own Weighting, yes. You could also extend the OsmReader, there are lots of ways to do this.

Cheers,
Robin

Well, you can still use the approach in my post.
In the overloaded method applyWayTags I extract the postal code from the ReaderWay way and store them in my custom Storage postCodeMapping, but nothing prevents you to inject whatever custom logic you want and store them in whatever custom storage you want.
In your case you may want to consider to build a HashMap containing the Long osmID as a key, and your custom attributes as a value, put them in applyWayTags and finally process them in overloaded method finishedReading() prior to flushing your storage.
Good luck!

1 Like

Thanks for the detailed approach info. I’ll give it a try n come back…