Skip to content

Commit

Permalink
Slightly increase bicycle priority classification on "good" highway=t…
Browse files Browse the repository at this point in the history
…rack
  • Loading branch information
ratrun committed Jun 14, 2024
1 parent 1fad178 commit 51213c0
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public abstract class BikeCommonPriorityParser implements TagParser {
int avoidSpeedLimit;
EnumEncodedValue<RouteNetwork> bikeRouteEnc;
Map<RouteNetwork, Integer> routeMap = new HashMap<>();
protected final Set<String> goodSurface = new HashSet<>(List.of("paved", "asphalt", "concrete"));

// This is the specific bicycle class
private String classBicycleKey;
Expand Down Expand Up @@ -153,8 +154,11 @@ private PriorityCode convertClassValueToPriority(String tagvalue) {
*/
void collect(ReaderWay way, double wayTypeSpeed, TreeMap<Double, PriorityCode> weightToPrioMap) {
String highway = way.getTag("highway");
boolean isTracTypeGrade1 = way.getTag("tracktype", "").equals("grade1");
boolean isGoodSurface = goodSurface.contains(way.getTag("surface",""));
if (isDesignated(way)) {
if ("path".equals(highway))
if ("path".equals(highway) ||
("track".equals(highway) && (isTracTypeGrade1 || isGoodSurface )))
weightToPrioMap.put(100d, VERY_NICE);
else
weightToPrioMap.put(100d, PREFER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ void collect(ReaderWay way, double wayTypeSpeed, TreeMap<Double, PriorityCode> w
String highway = way.getTag("highway");
if ("track".equals(highway)) {
String trackType = way.getTag("tracktype");
if ("grade1".equals(trackType))
weightToPrioMap.put(50d, UNCHANGED);
boolean isGoodSurface = goodSurface.contains(way.getTag("surface",""));
if ("grade1".equals(trackType) || isGoodSurface)
weightToPrioMap.put(50d, SLIGHT_PREFER);
else if (trackType == null)
weightToPrioMap.put(90d, PREFER);
else if (trackType.startsWith("grade"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ void collect(ReaderWay way, double wayTypeSpeed, TreeMap<Double, PriorityCode> w
if ("service".equals(highway) || "residential".equals(highway)) {
weightToPrioMap.put(40d, SLIGHT_AVOID);
} else if ("track".equals(highway)) {
boolean isGoodSurface = goodSurface.contains(way.getTag("surface",""));
String trackType = way.getTag("tracktype");
if ("grade1".equals(trackType))
weightToPrioMap.put(110d, PREFER);
if ("grade1".equals(trackType) || isGoodSurface )
weightToPrioMap.put(110d, VERY_NICE);
else if (trackType == null || trackType.startsWith("grade"))
weightToPrioMap.put(110d, AVOID_MORE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ public void testSpeedAndPriority() {
way.setTag("surface", "paved");
assertPriorityAndSpeed(PREFER, 18, way);

way.clearTags();
way.setTag("highway", "track");
way.setTag("bicycle", "designated");
way.setTag("segregated","no");
assertPriorityAndSpeed(PREFER, 12, way);
way.setTag("surface", "asphalt");
assertPriorityAndSpeed(VERY_NICE, cyclewaySpeed, way);
way.setTag("tracktype","grade1");
assertPriorityAndSpeed(VERY_NICE, cyclewaySpeed, way);
way.removeTag("surface");
assertPriorityAndSpeed(VERY_NICE, cyclewaySpeed, way);

way.clearTags();
way.setTag("highway", "path");
assertPriorityAndSpeed(SLIGHT_AVOID, PUSHING_SECTION_SPEED, way);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ public void testSpeedAndPriority() {
way.setTag("highway", "track");
assertPriorityAndSpeed(PREFER, 18, way);

// test speed for allowed pushing section types
way.setTag("highway", "track");
way.setTag("bicycle", "yes");
assertPriorityAndSpeed(PREFER, 18, way);

way.setTag("highway", "track");
way.setTag("bicycle", "yes");
way.setTag("tracktype", "grade3");
assertPriorityAndSpeed(VERY_NICE, 12, way);
way.setTag("tracktype", "grade1");
assertPriorityAndSpeed(SLIGHT_PREFER, 18, way);

way.setTag("surface", "paved");
assertPriorityAndSpeed(VERY_NICE, 18, way);
assertPriorityAndSpeed(SLIGHT_PREFER, 18, way);

way.clearTags();
way.setTag("highway", "path");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ public void testService() {
assertPriorityAndSpeed(SLIGHT_AVOID, 4, way);
}

@Test
public void testTrack() {
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "track");
way.setTag("bicycle", "designated");
way.setTag("segregated","no");
assertPriorityAndSpeed(AVOID_MORE, 2, way);
way.setTag("surface", "asphalt");
assertPriorityAndSpeed(VERY_NICE, 20, way);
way.setTag("tracktype","grade1");
assertPriorityAndSpeed(VERY_NICE, 20, way);
}

@Test
@Override
public void testSacScale() {
Expand Down Expand Up @@ -208,7 +221,7 @@ public void testHandleWayTagsInfluencedByRelation() {

// Now we assume bicycle=yes, and paved
osmWay.setTag("tracktype", "grade1");
assertPriorityAndSpeed(PREFER, 20, osmWay, osmRel);
assertPriorityAndSpeed(VERY_NICE, 20, osmWay, osmRel);

// Now we assume bicycle=yes, and unpaved as part of a cycle relation
osmWay.setTag("tracktype", "grade2");
Expand Down

0 comments on commit 51213c0

Please sign in to comment.