Repository navigation
Description
As mentioned by @karussell, the DataFlagEncoder contains too much information right now.
The single purpose FlagEncoders are too limited and do not store all necessary information but have topic specific code.
The DataFlagEncoder stores everything (or could) but also collects code of too many purposes with on&off switches. We need kind of a builder mechanism for the DataFlagEncoder
My proposal would be to use a plugin mechanism. We have the DataFlagEncoder, that on it's own does not do anything, it is just a container for MicroFlagEncoder/FlagEncoderPlugins. Every MicroFlagEncoder handles a single purpose, maybe handling truck attributes or even finer grained, handling one MicroFlagEncoder for each of the attributes width, height, weight. We might also create a MicroFlagEncoder for the MaxSpeed. Not everyone wants to save speed, maybe for foot routing, one does not care about speed and could disable saving it.
How this would work:
Every MicroFlagEncoder has acceptWay, handleWayTags, and a way to extract the stored data. Maybe we keep the extraction part generic, similar to the ConfigMap.get. In the GenericWeighting we could do something like:
if(encoder.supports(MaxSpeedMicroFlagEncoder.class))
double maxSpeed = encoder.get(MaxSpeedMicroFlagEncoder.class)).getDouble("max_speed", -1);
We might be even able to skip the supports part, by defining, if the value is not supported we also return the requested default value, in the above case -1. This would lead to cleaner code, but adds some "magic".
This would also require a building mechanism. The best would be to be able to define the properties that should be saved in the config. We read the config and initialize the required MicroFlagEncoders.
Activity
karussell commentedon Apr 23, 2017
Yes, this seems to be a bigger task. Instead of car or bike centric it should be more feature centric. E.g. reading height or maxspeed could be nice for trucks but also for cargo bikes.
We can create more issues in the following new project regarding this topic: https://github.com/graphhopper/graphhopper/projects/2
karussell commentedon Sep 10, 2018
Closing in favor of issue #1447 and follow up issues