Repository navigation
Remove EncodedValueFactory - #2551
Conversation
| // todo: not sure if this is worth it just to slightly improve the error message | ||
| private final Set<String> knownEncodedValues = new HashSet<>(Arrays.asList( | ||
| Roundabout.KEY, "car_access", "bike_access", GetOffBike.KEY, RoadClass.KEY, RoadClassLink.KEY, RoadEnvironment.KEY, | ||
| RoadAccess.KEY, MaxSpeed.KEY, MaxWeight.KEY, MaxWidth.KEY, MaxAxleLoad.KEY, MaxLength.KEY, Surface.KEY, Smoothness.KEY, | ||
| Toll.KEY, TrackType.KEY, BikeNetwork.KEY, FootNetwork.KEY, Hazmat.KEY, HazmatTunnel.KEY, HazmatWater.KEY, | ||
| Lanes.KEY, MtbRating.KEY, HikeRating.KEY, HorseRating.KEY, Country.KEY | ||
| )); |
There was a problem hiding this comment.
@karussell: If I got this right we used the DefaultEncodedValueFactory here to distinguish between 'invalid identifiers' and names of encoded values that are known to the factory, but were not added to the graph. The only purpose of this seem to be improved error messages. I replaced the hard-coded factory with a hard-coded list of encoded value names here. But actually I think we should consider removing this list. A given graphhopper instance has a list of encoded values stored in the graph. I don't think we should maintain a list of encoded values that aren't there, but could be there... At least not until we use such a list of encoded values that could be there (a registry in a way) to actually create the encoded values. Anyway, I updated this list according to: #2438 (comment).
Fixes #2438.
tldr;
Why do we need EncodedValueFactory? We don't. Should we create encoded values in two different places (TagParsers and EncodedValueFactory)? No. Should we support two different ways to initialize GraphHopper that do not even follow the same semantics? Also no.
Our current approach is to configure the GraphHopper class the same way to load graph data as we did when we imported data. This does not make much sense, and we should much rather just load the graph from disk when loading, but this is the way we do it currently. So we should do it the same way no matter if we call
init()or not,importOrLoad()orload(). Therefore, I now also build the encoding manager from the GraphHopper class' state when loading without init() (instead of reading the properties file). And since this was the only scenario where we even used EncodedValueFactory it can be removed.When
FlagEncoders are gone (#2463) and encoded values are no longer created inTagParsers (soon) we can revisit this and hopefully some day we will simply load everything from disk when usingload()...