Skip to content

Commit 8f56b68

Browse files
committed
Increase priority level by one step in case of scenic=yes tag.
Triggered by graphhopper#571.
1 parent e81fce3 commit 8f56b68

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

core/src/main/java/com/graphhopper/routing/util/BikeCommonFlagEncoder.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,13 @@ void collect( OSMWay way, TreeMap<Double, Integer> weightToPrioMap )
573573
if (classBicycle != null)
574574
weightToPrioMap.put(100d, convertClassValueToPriority(classBicycle).getValue());
575575
}
576+
577+
if (way.hasTag("scenic", "yes"))
578+
{
579+
if (weightToPrioMap.lastEntry().getValue() < BEST.getValue() )
580+
// Increase the prio by one step
581+
weightToPrioMap.put(110d, weightToPrioMap.lastEntry().getValue() + 1);
582+
}
576583
}
577584

578585
/**

core/src/test/java/com/graphhopper/routing/util/BikeFlagEncoderTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public void testGetSpeed()
5050
assertEquals(18, encoder.getSpeed(way));
5151
assertPriority(REACH_DEST.getValue(), way);
5252

53+
way.setTag("scenic", "yes");
54+
assertEquals(18, encoder.getSpeed(way));
55+
assertPriority(AVOID_IF_POSSIBLE.getValue(), way);
56+
5357
// Pushing section !! This is fine as we obey the law!
5458
way.clearTags();
5559
way.setTag("highway", "footway");
@@ -517,6 +521,10 @@ public void testClassBicycle()
517521
way.setTag("highway", "tertiary");
518522
way.setTag("class:bicycle", "3");
519523
assertPriority(BEST.getValue(), way);
524+
// Test that priority cannot get better than best
525+
way.setTag("scenic", "yes");
526+
assertPriority(BEST.getValue(), way);
527+
way.setTag("scenic", "no");
520528
way.setTag("class:bicycle", "2");
521529
assertPriority(VERY_NICE.getValue(), way);
522530
way.setTag("class:bicycle", "1");

0 commit comments

Comments
 (0)