Repository navigation
Identifies CH graphs by new CHProfile class instead of Weighting. - #1671
Conversation
| public BikeFlagEncoder(PMap properties) { | ||
| this((int) properties.getLong("speed_bits", 4), | ||
| properties.getLong("speed_factor", 2), | ||
| this(properties.getInt("speed_bits", 4), |
|
Thanks! Is it possible with this PR to make this part cleaner here? https://github.com/graphhopper/map-matching/blob/master/matching-core/src/main/java/com/graphhopper/matching/MapMatching.java#L116 |
Hmm, I am not sure (I do not understand this comment):
How can The important thing that changed in this PR is that |
|
Any idea why the CI build fails for open jdk 12 ?
|
Strange, can you try to remove the cache?
@michaz do you remember what the problem was and why you had to create a separate Weighting instance? |
|
Hmm, I do not get it. Disabling the cache did not help and adding gh-core as explicit dependency to tools did not help either. Somehow the wrong version of the core (that does not have I also tried changing all versions to [ERROR] Failed to execute goal on project graphhopper-web-api: Could not resolve dependencies for project com.graphhopper:graphhopper-web-api:jar:0.13-ch_profile-test: Could not find artifact com.graphhopper:graphhopper-api:jar:0.13-ch_profile-test in google-maven-central (https://maven-central.storage-download.googleapis.com/repos/central/data/) -> [Help 1]So it seems that it is trying to obtain graphhopper module artifacts from maven central instead of using the local ones from the reactor build ? |
|
Really strange. I got something that seems to works ... don't ask why though ;) |
|
Thanks! I enabled the cache again and set back the artifact versions and the build passed a second time. No idea what this was..., maybe different versions of |
Yes, it should read heading-penalty. The heading-penalty is used only in the map-matching specific entry/exit phase. As you say, not during CH routing. The entire comment is basically a complaint/note-to-self that I have to use a weighting that I don't want to route with ( Basically I thought the And if that's what your change fixes, all is fine, and the ugliness and the comment can go away, thanks a lot! |
|
Oh, by the way, this is the exact right moment to change this: In (one step of the) the customizable routing project, we will need to do exactly that: Have a fully dynamic weighting that we create on the fly, and use it on a |
|
(Or is that the idea?) :-) |
|
In the end, I think, profiles will just have names (strings):
|
Yes I agree. It is more or less like this at the moment, because For the customizable scenario I think we should keep two things in mind:
The idea here was mostly that I wanted to be able to specify u-turn costs (#1672), but sure I think its a step in the right direction for more customized stuff as well. The key thing here is that everything that needs to be known at CH preparation time must be included in the CH profile (used to be just the weighting, then edge/node-based and with #1672 also u-turn costs). |
Yes, exactly. Like a filename, almost. We already have this /car/fastest (right?) But maybe I want to do something outside that structure. Like, create a CH Graph where some parts of the graph are explicitly banned from contraction (so I can customize them). Maybe I want several of those. They would be created / programmed in my code, and I would give them a name in my code, maybe /car/fastest/withBlockableRoads so I can get at them (in other parts of my code). (Just a thought, maybe non-hierarchical names are enough in the end..)
Yes, but the responsibility for that must be "outside the framework", outside the code that just stores graphs. Because that code doesn't know what needs to be known for my flavor of CH. I basically want a layer that just stores |
# Conflicts: # core/files/changelog.txt # core/src/main/java/com/graphhopper/storage/CHGraphImpl.java # core/src/test/java/com/graphhopper/storage/GraphHopperStorageCHTest.java
# Conflicts: # reader-osm/src/test/java/com/graphhopper/GraphHopperIT.java
I think, this should be another issue and should not be done before the actual code is required. The flexible work (flex_vehicleprofile and flex_vehicleprofile2) indicates that everything can be weighting based (we do not need FlagEncoders anymore). I.e. we just use a weighting name as ID "mycar/fastest" and a base name "car/fastest" from which we extend behaviour. Customization properties are sent via a json/yaml file either through http or from the file system. |
Yes, is there anything that needs to be done for this PR ?
What do you mean with 'we do not need FlagEncoders anymore' ? Will they be removed entirely ? "car/fastest" still sounds like a |
| this.singleCHWeighting = singleCHWeighting; | ||
| public GraphBuilder setCHProfiles(List<CHProfile> chProfiles) { | ||
| if (chProfiles.size() != new HashSet<>(chProfiles).size()) { | ||
| throw new IllegalArgumentException("Duplicate CH profile: " + chProfiles); |
There was a problem hiding this comment.
The message is slightly confusing and should be "Contains duplicate CH profile:" (?)
Yes. Still conceptionally the FastestWeighting does not need CarFlagEncoder. In theory it is sufficient to have e.g. roadClassEnc, maxSpeedEnc and a few other EncodedValues that "read the properties of an endge" in the Weighting class. The "CarFlagEncoder-specific stuff" that precalculates e.g. average speed and access for car seems to be required only for performance reasons. Or maybe the otherway around: should we create a separate TruckFlagEncoder to store size and width or should we include this in CarFlagEncoder? But e.g. cargo bikes also need at least the width of an edge. And why should we force a single averageSpeedEnc for car, when in fact there could be many speeds e.g. depending on the time or if it is an electric car?
Yes, flex_vehicleprofile2 uses a recent master and has no hacks I think, but has also not all features. |
|
Ok, thanks for your explanations and I see it is difficult to find replacement for everything FlagEncoder does. To specify a CH profile I think we will eventually only need to define a weight for all edges of the base graph (in fwd&bwd direction) and give this collection of weights some name/id to retrieve the corresponding profile later. Of course for json/yaml configuration etc. specifying these weights needs to be possible on a much higher level (like 'weight=dist/speed', 'block this area', 'use this traffic information' etc.). Right now |
Yes. This is another problem: it does too many things :)
Yeah, basically it just needs two EncodedValues. (Maybe a "profile" is like a FlagEncoder: a collection of EncodedValues...) |
I was more thinking of two doubles ? I thought every edge has some 'flags', then there are encoded values to give these flags some meaning (like speed or road type), then there is Weighting that uses the encoded values to calculate a weight (just a number). For CH preparation we need this weight, why would we convert the weight (number) into an encoded value at this point ?
But isn't it more than a collection of encoded values ? It is also about how to combine the encoded values into a weight ? |
An EncodedValue transform some bits in the edge into a value. The same can be done for shortcuts. In fact the only reason we don't use EncodedValues also for the shortcut weights yet is entirely because of performance. Maybe you remember this commit: cb88018 (was reverted or not included)
It is more than that, yes. Like including relations and stuff.
Isn't this the task of the Weighting class? |
Ah ok yes you were thinking about the shortcuts, which need to store some weight (and like you said could be encoded values). I was thinking about the weights of the original/base graph edges that enter the CH preparation.
Yes, exactly. I was probably more thinking in terms of a CH profile, which is defined by the calculated weights of the edges or at least by the 'method'/weighting how these weights are calculated. This is different to a 'profile', which rather defines the properties of an edge and is needed before the weights are calculated. |
Instead of a list of
Weightings for edge/node-based preparationsGraphHopperStoragenow takes a list ofCHProfile:To get a
CHGraphfromGraphHopperStoragewe are using now:In contrast to the previous approach where the exact
Weightinginstance was used to identify aCHGraphtheCHProfilenow works like a finger-print of aCHGraphand it does not have to be the same object anymore (at least as long as theWeightingderives fromAbstractWeightingwhich provides its own equals method).Also see discussion in #1652.