You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will be a big refactoring task that we will have to split into several smaller issues. We can keep a list of related issues here and also discuss the general direction this should be going here.
replace the FlagEncoder parameters from the weighting constructors with references to the encoded values they need. For example instead of receiving a FlagEncoder and calling encoder.getAverageSpeedEnc(), the FastestWeighting should receive the speed encoded value (and encoded values it needs besides this of course). -> Remove FlagEncoder #2611 and 15426ef
For FastestWeighting we also need to replace encoder.isMotorVehicle()/HGV() with some boolean constructor parameters representing these values (or just a PMap). Maybe we should take these parameters from the weighting string, i.e. something like weighting: fastest|is_motor_vehicle=true. Or we skip this intermediate step and replace FastestWeighting (and the others) with CustomWeighting directly. -> see Remove FlagEncoder #2611, this is done in DefaultWeightingFactory now.
One problem is that we have literally thousands of usages of GHUtility#setSpeed(..., encoder, ...) that we will have to replace with something similar that uses the speed/access encoded values directly. I did some unfinished work in this direction some time ago here: 9715c81. -> Remove FlagEncoder #2611
Not all the issues we mentioned here are fixed, but flag encoders are almost gone since #2611 :)
The only place they remain now is in config.yml/Graphhopper.java. For example graph.flag_encoders=car,bike does two things now:
It creates VehicleEncodedValues for car and bike, which just means that the car_access, car_average_speed, car_turn_cost, bike_access, bike_average_speed and bike_priority encoded values are added to the graph / encoding manager.
It enables the Car/BikeTagParsers, which require above encoded values.
We also have graph.encoded_values which is very similar: For example graph.encoded_values=road_environment adds the road_environment encoded value and enables the OSMRoadEnvironment parser. The fundamental difference between graph.flag_encoders and graph.encoded_values is that the 'flag_encoders' add multiple encoded values via VehicleEncodedValuesFactory and a single parser via VehicleTagParserFactory that writes these encoded values, while for each entry in graph.encoded_values there will be a single encoded value added via EncodedValuesFactory and an according single parser via TagParserFactory.
I don't think this 'minor' difference deserves an extra config option and two extra factories. Let alone it should definitely no longer be called graph.flag_encoders.
Activity
otbutz commentedon Nov 17, 2021
IMHO #2460
easbar commentedon Nov 17, 2021
Yes, everything related to access and access flags is related. Just not sure if this is required to remove the FlagEncoders (or vice versa).
otbutz commentedon Nov 18, 2021
Removing FlagEncoders requires #2460 to be solved but we can implement it without removing FlagEncoders. At least that is my understanding of it.
The benefit is that users can perform proper truck routing without touching the code :)
easbar commentedon Jun 13, 2022
I think we are getting there :) What we probably should do next is:
encoder.getMaxSpeed()withspeedEnc.getMaxValue()or similar. This would be an improvement by itself, because we no longer have to keep the max value synchronized between the vehicle tag parsers and the flag encoders. -> Use actual speed maximum rather than flagEncoder#getMaxSpeed() for weighting.getMinWeight() #2614, Rename getMin/MaxInt -> getMin/MaxStorableInt, getMaxSetValueOrMax -> getMaxOrMaxStorable #2616, Remove FlagEncoder#getMaxSpeed() #2619FlagEncoderparameters from the weighting constructors with references to the encoded values they need. For example instead of receiving aFlagEncoderand callingencoder.getAverageSpeedEnc(), theFastestWeightingshould receive the speed encoded value (and encoded values it needs besides this of course). -> Remove FlagEncoder #2611 and 15426efFastestWeightingwe also need to replaceencoder.isMotorVehicle()/HGV()with some boolean constructor parameters representing these values (or just a PMap). Maybe we should take these parameters from the weighting string, i.e. something likeweighting: fastest|is_motor_vehicle=true. Or we skip this intermediate step and replace FastestWeighting (and the others) with CustomWeighting directly. -> see Remove FlagEncoder #2611, this is done in DefaultWeightingFactory now.GHUtility#setSpeed(..., encoder, ...)that we will have to replace with something similar that uses the speed/access encoded values directly. I did some unfinished work in this direction some time ago here: 9715c81. -> Remove FlagEncoder #2611easbar commentedon Jul 4, 2022
Not all the issues we mentioned here are fixed, but flag encoders are almost gone since #2611 :)
The only place they remain now is in
config.yml/Graphhopper.java. For examplegraph.flag_encoders=car,bikedoes two things now:It creates
VehicleEncodedValuesfor car and bike, which just means that thecar_access,car_average_speed,car_turn_cost,bike_access,bike_average_speedandbike_priorityencoded values are added to the graph / encoding manager.It enables the
Car/BikeTagParsers, which require above encoded values.We also have
graph.encoded_valueswhich is very similar: For examplegraph.encoded_values=road_environmentadds theroad_environmentencoded value and enables theOSMRoadEnvironmentparser. The fundamental difference betweengraph.flag_encodersandgraph.encoded_valuesis that the 'flag_encoders' add multiple encoded values via VehicleEncodedValuesFactory and a single parser via VehicleTagParserFactory that writes these encoded values, while for each entry ingraph.encoded_valuesthere will be a single encoded value added via EncodedValuesFactory and an according single parser via TagParserFactory.I don't think this 'minor' difference deserves an extra config option and two extra factories. Let alone it should definitely no longer be called
graph.flag_encoders.easbar commentedon Jul 4, 2022
Another list taken from here: #2561 (comment):
TagParserBundleOSMParsers (acceptWay method)[-]Remove FlagEncoder[/-][+]Remove "FlagEncoder" concept[/+]karussell commentedon May 15, 2024
This should be fixed now.