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
Currently we cannot avoid edge extraction required for stuff like in #904. Also the path class does too much and after #1091 will do a bit more. @boldtrn maybe you can also think about a good API approach how you would write #1091 if you would implement it from scratch to find a better solution.
Furthermore I'm currently trying to refactor a bigger portion of the code to make the DataFlagEncoder obsolete and replace it by 'bit-range' objects (which could be shared between encoders or we could even live completely without encoders - just encoding manager, weighting and a few properties). But while doing this the Path class turns out to depend on the FlagEncoder which should not be and instead it should rely on the EncodingManager, which isn't easily possible as the Algorithm objects only know the weighting. Hence a further reason to refactor this class.
Maybe the end result could be something like:
ShortestPathTreetree = algo.createTree(request);
List<String> propertiesToExtract = Arrays.asList("times", "distances", "instructions", "surface", "highway");
PathDetailspathDetails = tree.extract(encodingManager, propertiesToExtract);
// then support methods like getDistance& getDistances, getTime&getTimes, getInstructions(), getEdges, getNodes// and some more generic ones like: getDetails("surface"), getDetails("highway"), ...// TODO what about the path merging? Maybe we should call the extract step after all trees are merged?
@boldtrn maybe you can also think about a good API approach how you would write #1091 if you would implement it from scratch to find a better solution.
Sure :). I always feel like the Path class could be threaded with a chain of responsibilty pattern, like a PipeLine that enriches the object itself. But we could still keep the Visitor pattern (forEveryEdge) to actually process the edges. Haven't thought this through though, there might be some pitfalls here.
Maybe the end result could be something like
I think this should be possible. We could probably do the same for instructions and maybe a couple more things?
For #1112 we would also benefit from this refactoring. But separating SPT and extract is not sufficient. Instead we would need to be able to store "scalar" values that we 'already have' in the Path class like weight (or time or transfers or ticket costs or toll costs) and return this directly so that there is an actual speed up if no geometry and no instructions were requested.
For some implementations of RoutingAlgorithm e.g. for AlternativeRoute we call extract as part of the implementation and so a second call of extract should not fail (as it does now)
Activity
boldtrn commentedon Jul 14, 2017
Sure :). I always feel like the Path class could be threaded with a chain of responsibilty pattern, like a PipeLine that enriches the object itself. But we could still keep the Visitor pattern (
forEveryEdge) to actually process the edges. Haven't thought this through though, there might be some pitfalls here.I think this should be possible. We could probably do the same for instructions and maybe a couple more things?
karussell commentedon May 12, 2018
For #1112 we would also benefit from this refactoring. But separating SPT and extract is not sufficient. Instead we would need to be able to store "scalar" values that we 'already have' in the Path class like weight (or time or transfers or ticket costs or toll costs) and return this directly so that there is an actual speed up if no geometry and no instructions were requested.
For some implementations of RoutingAlgorithm e.g. for AlternativeRoute we call
extractas part of the implementation and so a second call ofextractshould not fail (as it does now)