Skip to content

Commit

Permalink
Fix for issue 546
Browse files Browse the repository at this point in the history
Improve bicycle waytype classification for a bicycle=  tag on roads.
  • Loading branch information
ratrun authored and Peter committed Nov 15, 2015
1 parent 2a5d91f commit c12d251
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
Expand Up @@ -584,29 +584,33 @@ long handleBikeRelated( OSMWay way, long encoded, boolean partOfCycleRelation )
String highway = way.getTag("highway");
String trackType = way.getTag("tracktype");

// Populate bits at wayTypeMask with wayType
WayType wayType = WayType.OTHER_SMALL_WAY;
boolean isPusingSection = isPushingSection(way);
if (isPusingSection && !partOfCycleRelation || "steps".equals(highway))
wayType = WayType.PUSHING_SECTION;

// Populate unpavedBit
if ("track".equals(highway) && (trackType == null || !"grade1".equals(trackType))
|| "path".equals(highway) && surfaceTag == null
|| unpavedSurfaceTags.contains(surfaceTag))
{
encoded = setBool(encoded, K_UNPAVED, true);
}

WayType wayType;
if (roadValues.contains(highway))
wayType = WayType.ROAD;
else
wayType = WayType.OTHER_SMALL_WAY;

boolean isPushingSection = isPushingSection(way);
if (isPushingSection && !partOfCycleRelation || "steps".equals(highway))
wayType = WayType.PUSHING_SECTION;

if (way.hasTag("bicycle", intendedValues))
{
if (isPusingSection && !way.hasTag("bicycle", "designated"))
if (isPushingSection && !way.hasTag("bicycle", "designated"))
wayType = WayType.OTHER_SMALL_WAY;
else
wayType = WayType.CYCLEWAY;
if ( (wayType == WayType.OTHER_SMALL_WAY ) || (wayType == WayType.PUSHING_SECTION) )
wayType = WayType.CYCLEWAY;
} else if ("cycleway".equals(highway))
wayType = WayType.CYCLEWAY;
else if (roadValues.contains(highway))
wayType = WayType.ROAD;

return wayTypeEncoder.setValue(encoded, wayType.getValue());
}
Expand Down
Expand Up @@ -280,6 +280,24 @@ public void testHandleCommonWayTags()
assertEquals("", wayType);
assertPriority(PREFER.getValue(), way);

way.clearTags();
way.setTag("highway", "residential");
way.setTag("bicycle", "yes");
wayType = getWayTypeFromFlags(way);
assertEquals("", wayType);

way.clearTags();
way.setTag("highway", "residential");
way.setTag("bicycle", "designated");
wayType = getWayTypeFromFlags(way);
assertEquals("", wayType);

way.clearTags();
way.setTag("highway", "track");
way.setTag("bicycle", "designated");
wayType = getWayTypeFromFlags(way);
assertEquals("cycleway, unpaved", wayType);

way.clearTags();
way.setTag("highway", "cycleway");
wayType = getWayTypeFromFlags(way);
Expand Down

0 comments on commit c12d251

Please sign in to comment.