Repository navigation
Adds AbstractBidirAlgo#calcPath with restricted source/target edges. - #1665
Conversation
| * @param toInEdge the edge id of the last edge of the path. using {@link EdgeIterator.ANY_EDGE} means | ||
| * not enforcing the last edge of the path | ||
| */ | ||
| public Path calcPath(int from, int to, int fromOutEdge, int toInEdge) { |
There was a problem hiding this comment.
In principle we could also move this to the RoutingAlgorithm, but for now it was easier to implement this only for bidirectional algorithms. Not sure if we really need this for the others as well and we can add this later if needed (?)
| /** | ||
| * integer value used to indicate that any edge is accepted | ||
| */ | ||
| int ANY_EDGE = Integer.MIN_VALUE; |
There was a problem hiding this comment.
what is a bit ugly here is that EdgeIterator.Edge.isValid only checks if an edge id is positive or not. this does not allow us to have other special values like this one here. maybe we should make isValid check if ==-1 ?
There was a problem hiding this comment.
Yeah, this is a good idea. Additionally we should have a look if we use ==-1 instead of isValid call. Have created #1666
| {Algo.CH_ASTAR, Double.POSITIVE_INFINITY, true, false}, | ||
| {Algo.CH_DIJKSTRA, Double.POSITIVE_INFINITY, true, false}, | ||
| // todo: yields warnings and fails | ||
| // {Algo.LM, Double.POSITIVE_INFINITY, false, true} |
There was a problem hiding this comment.
With landmarks the test fails sometimes, maybe its the same problem as in #1557 ? Or maybe I am using bad settings (there were also some warnings about some weights being maxed out)
There was a problem hiding this comment.
This is ugly. Wasn't #1557 only for shortest weighting and shouldn't happen here?
There was a problem hiding this comment.
Hmm, I might need your help here. I guess the test for LM fails because I am getting these warnings:
com.graphhopper.routing.lm.LandmarkStorage - landmark 1 (49.40121656807996,9.705012881122817): too many delta weights were maxed out (17/82). Factor is too small 0.003551062425503072. To fix this increase maximum in config.yml: prepare.lm.weighting: fastest|maximum=363.056352875689I tried setting the maximum weight with LandmarkStorage#setMaximumWeight and also setting it to -1 (automatic determination of maximum weight), but the warnings remain. I do not really understand what the problem is here. The random graph is created within a rather small bounding box (just the size of a village): http://tools.geofabrik.de/calc/#type=geofabrik_standard&bbox=9.7,49.41,9.71,49.4&tab=1&proj=EPSG:4326&places=2
and I checked that the edge distances are all something like 100-1000m. The speeds used are all between 10 and 120 so there should not be any unusual values for the weights (I checked and they are all somewhere between 60 and 420 (one to seven minutes).
However the fromWeight here:
delta in the same method is often below DELTA_MIN, which eventually leads to the warnings I mentioned above.
What I do not understand is how fromWeight can get so large ? I would expect in such a small area no matter where the landmarks are the weights should be much smaller ?
There was a problem hiding this comment.
Thanks, will investigate! This sounds like a bug in LM code.
There was a problem hiding this comment.
Hmmh, there are a few confusing things in the code like 16 bits for the precision although we should have 18 for the "from" and 13 for the "delta", plus old comments making it hard to "re-understand" this. It will take me a bit more time before I can understand this problem here.
There was a problem hiding this comment.
Ok, thanks for taking a look! Maybe we can leave this test commented out for this PR ? The problem seems to be unrelated to the source/target edge restrictions that are new here ?
There was a problem hiding this comment.
Will let you know when I know if it is indeed unrelated. (But maybe it is related as the preparation and also parts of the algo are node based)
There was a problem hiding this comment.
I tried looking into this a bit and found failing cases also without the new feature discussed here (and also for node-based routing). See #1687
| } | ||
|
|
||
| protected void postInitFrom() { | ||
| // using a local reference is important to prevent stack overflow after calling setEdgeFilter |
There was a problem hiding this comment.
What is the problem here exactly? Is it due to the not fully initialized AbstractBidirAlgo constructor?
There was a problem hiding this comment.
Ah, no. It seems we use additionalEdgeFilter inside the method. Wouldn't it then be safer to handle this inside the method especially since it is protected?
There was a problem hiding this comment.
Hmm, I would say fillEdgesFrom/ToUsingFilter is 'sane': It sets additionalEdgeFilter to some other filter, calls fillEdges and sets additionalEdgeFilter back to the value it had before calling the method. So I do not think there is anything we can handle here ? The one thing that we must not do is using the additionalEdgeFilter reference directly in the edgeFilter object we pass into the method (because it will be modified itself). I tried making this a bit clearer in the code now.
There was a problem hiding this comment.
And should we throw an illegal arg exc if edgeFilter==additionalEdgeFilter?
There was a problem hiding this comment.
No, passing edgeFilter==additionalEdgeFilter is ok (we even do this here), the only thing that is not ok is passing a new edge filter that uses additionalEdgeFilter directly.
| // todo: | ||
| // e.g. block area is implemented using infinite weighting | ||
| // when an edge filter is used need to think about what should happen if the filter filters out the | ||
| // given in out edges etc. |
There was a problem hiding this comment.
Interesting and yes, if we do a block area and restrict the edge (with infinite weight) then we should get "connection not found".
There was a problem hiding this comment.
Yes, this is already covered. I added a test for this and removed the todo.
For #1647 I have added a new
calcPathmethod toAbstractBidirAlgothat, additionally to the from/to node ids, also takes two edge ids that are enforced as start/target edges. This allows to strictly enforce the first and last edge of a path.For now this is only supported on the low-level java API level and how to obtain the edge ids for the edges one wants to restrict is another question (?).