Repository navigation
Conversation
…ives in GraphHopperTest
…cleway AND highway=path&surface=asphalt&bicycle=designated have same prio
There was a problem hiding this comment.
I don't like loosing the possibility of searching for certain priority values. I believe that we will need this soon for the first time at fixing #3219.
Therefore I suggest to define constants like this:
package com.graphhopper.routing.util;
public final class PriorityConstants {
// Private constructor to prevent instantiation
private PriorityConstants() {
}
public static final double PRIO_01 = 0.1;
public static final double PRIO_02 = 0.2;
public static final double PRIO_03 = 0.3;
public static final double PRIO_04 = 0.4;
public static final double PRIO_05 = 0.5;
public static final double PRIO_06 = 0.6;
public static final double PRIO_07 = 0.7;
public static final double PRIO_08 = 0.8;
public static final double PRIO_09 = 0.9;
public static final double PRIO_10 = 1.0;
public static final double PRIO_11 = 1.1;
public static final double PRIO_12 = 1.2;
public static final double PRIO_13 = 1.3;
public static final double PRIO_14 = 1.4;
public static final double PRIO_15 = 1.5;
}
and utilize these constants in the code instead of hard coding the double values.
There was a problem hiding this comment.
Why is searching for a certain priority value an advantage? Also I do not understand what this has to do with #3219.
IMO the missing step for fixing #3219 is that there is still no clear concept of what should get which priority and when to boost or penalize (similar to the average speed parser). But at least we now have a single if-else block which makes it easier to reason about.
But this if-else block should be further simplified and this simplification will then hopefully fix issues like #3219 (as problems like these get more or less obvious from the code).
There was a problem hiding this comment.
Why is searching for a certain priority value an advantage
This is needed to analyze how other situations are prioritized in comparison to a new one. In #3219 I think that we will need to shift some existing priority deltas by a step of 0.1 in order to be able to make use of the currently left out priority values.
And hard coding these values is ugly IMHO.
There was a problem hiding this comment.
This is needed to analyze how other situations are prioritized in comparison to a new one.
But comparing numbers is much simpler than comparing words which you need to look up (!?)
In #3219 I think that we will need to shift some existing priority deltas by a step of 0.1 in order to be able to make use of the currently left out priority values.
We could try to use 1.1 instead of 1.2 and add 0.1 if it has a lane. (Or we could even try to use residential without any boost by default.)
IMO speaking of numbers instead of SLIGHT_PREFER and PREFER is much simpler. E.g. do you know without looking how much worse BAD is compared to AVOID?
One further argument for the numbers is that we just have numbers for the priority section of custom models too.
btw: it is unclear to me why we handle tertiary and unclassified differently. Is there a reason? And shouldn't service be 0.9 instead of getting a boost by default? (but this is yet another PR I think :) )
There was a problem hiding this comment.
IMO speaking of numbers instead of SLIGHT_PREFER and PREFER is much simpler. E.g. do you know without looking how much worse BAD is compared to AVOID?
I'm not proposing to keep the class with those names, but instead define constants for the double priority values:
public static final double PRIO_01 = 0.1;
..
see above. This way you can easily search for all source code which results in a specific prio value and from the naming of the constants you can easily derive its value.
One further argument for the numbers is that we just have numbers for the priority section of custom models too.
But in Java we have the means for better readable code, which we should utilize.
Let's discuss #3219 once this PR is finished.
There was a problem hiding this comment.
I'm still not convinced that an enum gives us any advantages. If we simplify the code then all the logic will be in one place with a single & simple if-else-block or whatever simple logic. Nothing we need to search for.
But in Java we have the means for better readable code, which we should utilize.
It is definitely not better readable because a "number" as concept for priority is immediately clear and such an enum needs to be understood first, even if it just mirrors numbers.
The only advantage would be that we can find the usage which I do not see as an advantage as this shouldn't be necessary. E.g. if we know there is just a single class and a single test class then we can as well search those two files for e.g. 0.1 too.
But I doubt that this is a real problem that we have to solve.
For example when I tried to further simplify the code I found one more inconsistency which you cannot find from a "usage search" of an enum.
The inconsistency I found is: for path, track and bridleway with a good surface and when bicycle=designated we use 1.3 (VERY_NICE), but for other highways the designated will be just 1.2 (PREFER). On the other hand a highway included in pushing section set (like path) with just bicycle=yes we give a 1.2 even if a bad surface! Here is the test which makes the inconsistency obvious:
@Test
public void test() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "path");
way.setTag("bicycle", "yes");
way.setTag("surface", "ground");
assertPriorityAndSpeed(1.2, 10, way);
way = new ReaderWay(1);
way.setTag("highway", "residential");
way.setTag("bicycle", "designated");
assertPriorityAndSpeed(1.2, 18, way);
}There was a problem hiding this comment.
The only advantage would be that we can find the usage which I do not see as an advantage as this shouldn't be necessary. E.g. if we know there is just a single class and a single test class then we can as well search those two files for e.g. 0.1 too.
Currently there are more files involved, even if one limits a search to just a single profile.
I counted five: BikeCommonPriorityParser, BikePriorityParser, AbstractBikeTagParserTester, BikeTagParserTest, BikeCustomModelTest. But if you really insist on these numbers then there is nothing I can do about it, except putting it into my fork, which I don't want in order to avoid merge conflicts.
There was a problem hiding this comment.
Currently there are more files involved
Well, this will change. I plan to do this similarly to how we have it for foot and hike. Just a single parser (or later maybe even none).
But if you really insist on these numbers
I do not insist. I'm just not convinced that such an enum is a good solution in this case.
But for a moment, let's focus on the other changes: are you fine with them?
There was a problem hiding this comment.
Well, this will change. I plan to do this similarly to how we have it for foot and hike. Just a single parser (or later maybe even none).
If this is possible I agree with the change to the numeric factors in this PR. But please then assign this change some priority in your planning and create a separate PR for it.
But for a moment, let's focus on the other changes: are you fine with them?
I agree. I'm through now with all my comments. Don't get shocked by the big amount, it is not as bad as it might look at the first glance 😃
| double collect(ReaderWay way, double wayTypeSpeed, boolean bikeDesignated) { | ||
| double prio = super.collect(way, wayTypeSpeed, bikeDesignated); | ||
|
|
||
| // worse grade should not mean we prefer it because it is also less fun |
There was a problem hiding this comment.
We still should prefer tracktype=grade2, grade3, grade4 and eventually also grade5 more compared to grade1. Imagine a tracktype grade1 and parallel a highway=track with one of the other grades. From a MTB profile I would expect that the tracktype=grade1 is avoided in such a case.
There was a problem hiding this comment.
We probably need to clarify what 'mountainbike routing' means. IMO it means that
- we want to go from A to B in a short time, and
- accept more ways, ways that an mtb can access, and
- reduce the penalty on certain ways with a bad surface, and
- prefer "mtb ways".
I don't think highway=track&tracktype=grade5 should fall under requirement 4 but more 3. And at least we should not prefer a way just because the surface is worse like we currently do. This does not make sense to me because of requirement 1. But more importantly: a worse surface doesn't mean it makes more fun with a mtb (especially uphill) and we do not know the skill/preference of the person on the mtb.
So requirement 4 is tricky. IMO preferring a road because of its "mountainbikability" can be defined via mtb:scale and slightly boosting highway=path and highway=track (or not adding a penalty if there is no surface tag). And even a big value of mtb:scale does not mean we should prefer it more than e.g. mtb:scale==0 because of the same reason of why a worse surface shouldn't be preferred.
There was a problem hiding this comment.
For me it is crystal clear that 4. is the essence of a good mountainbike profile and 1. is not really a requirement. If 1. is a requirement, then I'd choose the trekking bike profile instead. But I must say that I am not a hard core mountainbike freak myself, but friends of mine are and for them this is their expectation.
I'm skeptical about AI, but as I'm not a reader of Mountainbike Forums I thought it would be interesting what the output would be. This is what I got
There was a problem hiding this comment.
Mountain biking is more of a leisure activity than a means of transportation. It's similar to planning a motorcycle ride with Kurviger.
There was a problem hiding this comment.
is the essence of a good mountainbike profile and 1. is not really a requirement
Hm, ok. Our disagreement once again shows that we really need to make more things easier to configure via a custom model and so we can have both :)
Because I want a mtb profile where the purpose is "just" to go from A to B with a mtb, so very similar to the hike profile. And then finding nice mtb spots or detours preferable for mtb is out of scope of the profile because we mostly do not have this data in OSM (and IMO only properly done with external/user data like you find in komoot).
There was a problem hiding this comment.
Mountain biking is more of a leisure activity than a means of transportation
We need to differentiate between the A-to-B routing and the planning where we find the spots and then create a nice tour with multiple via points (or a round tour) to get there. IMO the scope of the GraphHopper routing engine here can be surely be "prefer tracks and mtb-alike roads" (or for kurviger "prefer curvy roads and avoid motorways") but our aim should not be to find "nice mtb spots" on the way to our goal and do big detours because of that and accept really ugly surface (it is not fun!), because there is just no good data for this in OSM (except maybe mtb:scale and scenic).
| String highway = way.getTag("highway"); | ||
| if ("service".equals(highway) || "residential".equals(highway)) { | ||
| weightToPrioMap.put(40d, SLIGHT_AVOID); | ||
| prio *= 0.7; |
There was a problem hiding this comment.
I think the factor 0.7 is too small, I would set it to 0.9. In the old code we fixed set it to SLIGHT_AVOID (0.9). Can you please explain your reasoning behind?
| assertPriorityAndSpeed(0.9, 4, way); | ||
| way.setTag("bicycle", "designated"); | ||
| assertPriorityAndSpeed(VERY_NICE, 12, way); | ||
| assertPriorityAndSpeed(1.2, 12, way); |
There was a problem hiding this comment.
This was VERY_NICE (1.3) before. Was this change intended? What is the reasoning behind?
| // tertiary without sidewalk is roughly like primary with sidewalk | ||
| way.setTag("sidewalk", "no"); | ||
| assertPriority(PriorityCode.AVOID, way); | ||
| assertPriority(0.7, way); |
There was a problem hiding this comment.
Note: This was AVOID (0.8) before, but 0.7 is also OK.
|
|
||
| way.setTag("sidewalk", "no"); | ||
| assertPriority(PriorityCode.REACH_DESTINATION, way); | ||
| assertPriority(0.2, way); |
There was a problem hiding this comment.
Note: Was REACH_DESTINATION (0.1) before. Was this change intended?
| assertEquals(10, getSpeedFromFlags(way), 0.01); | ||
|
|
||
| way.setTag("smoothness", "bad"); | ||
| way.setTag("smoothness", "0.5"); |
There was a problem hiding this comment.
This is obviously a replace all BAD->0.5 error 😄 , please fix it back!
| assertEquals(4, getSpeedFromFlags(way), 0.01); | ||
|
|
||
| way.setTag("smoothness", "bad"); | ||
| way.setTag("smoothness", "0.5"); |
There was a problem hiding this comment.
This is obviously a replace all BAD->0.5 error 😄 , please fix it back!
| assertPriority(0.5, way); | ||
| way.setTag("cycleway", "track"); | ||
| assertPriority(PREFER, way); | ||
| assertPriority(1.3, way); |
There was a problem hiding this comment.
Was PREFER (1.2) before. 1.3 is also OK
|
|
||
| way.setTag("maxspeed", "15"); | ||
| assertPriority(BEST, way); | ||
| assertPriority(1.4, way); |
There was a problem hiding this comment.
Was 1.5 (BEST) before. Question: Does it become 1.5 for class:bicycle:touring = 3? Please add this test and make sure the result is 1.5!
There was a problem hiding this comment.
Well, this will change. I plan to do this similarly to how we have it for foot and hike. Just a single parser (or later maybe even none).
If this is possible I agree with the change to the numeric factors in this PR. But please then assign this change some priority in your planning and create a separate PR for it.
But for a moment, let's focus on the other changes: are you fine with them?
I agree. I'm through now with all my comments. Don't get shocked by the big amount, it is not as bad as it might look at the first glance 😃
|
What is the status of this PR? Did you forget about it or did I add too many comments ❓ The discussion stalled although it is a pre-requisite for fixing the annoying bug #3219. |
|
I was actually waiting for your feedback regarding the first step here: #3251 :) (but no rush required from my side) |
This PR does the following changes (via separate commits):
highway=*&cycleway=trackhighway=cyclewayhighway=path&surface=asphalt&bicycle=designatedProbably for separate PR: one question I stumbled over is: why do we always avoid the avoidHighwayTags? Shouldn't we decrease the avoidance a bit in case bicycle=yes or designated? Similar question for bike=designated for preferHighwayTags and pushingSectionsHighways. And e.g. avoiding tunnel should be done always (except if bike=designated). And at the same time we could integrate the default avoidance of track for bad surfaces for bike and rcbike.