Skip to content

Commit

Permalink
cycleway, sidewalk overlay: don't consider other side as missing on r…
Browse files Browse the repository at this point in the history
…oads where no cycleway/sidewalk is expected but one side has been specified (fixes #5716, fixes #5722)
  • Loading branch information
westnordost committed Aug 15, 2024
1 parent 821d091 commit e9046b1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,12 @@ private fun SeparateCycleway?.getColor() = when (this) {
private fun getStreetCyclewayStyle(element: Element, countryInfo: CountryInfo): PolylineStyle {
val cycleways = parseCyclewaySides(element.tags, countryInfo.isLeftHandTraffic)
val isBicycleBoulevard = parseBicycleBoulevard(element.tags) == BicycleBoulevard.YES

// not set but on road that usually has no cycleway or it is private -> do not highlight as missing
val isNoCyclewayExpected =
cycleways == null && (cyclewayTaggingNotExpected(element) || isPrivateOnFoot(element))
val isNoCyclewayExpected = lazy { cyclewayTaggingNotExpected(element) || isPrivateOnFoot(element) }

return PolylineStyle(
stroke = when {
isBicycleBoulevard -> StrokeStyle(Color.GOLD, dashed = true)
isNoCyclewayExpected -> StrokeStyle(Color.INVISIBLE)
else -> null
},
strokeLeft = if (isNoCyclewayExpected) null else cycleways?.left?.cycleway.getStyle(countryInfo),
strokeRight = if (isNoCyclewayExpected) null else cycleways?.right?.cycleway.getStyle(countryInfo)
stroke = if (isBicycleBoulevard) StrokeStyle(Color.GOLD, dashed = true) else null,
strokeLeft = cycleways?.left?.cycleway.getStyle(countryInfo, isNoCyclewayExpected),
strokeRight = cycleways?.right?.cycleway.getStyle(countryInfo, isNoCyclewayExpected)
)
}

Expand All @@ -124,7 +117,10 @@ private val cyclewayTaggingNotExpectedFilter by lazy { """
private fun cyclewayTaggingNotExpected(element: Element) =
cyclewayTaggingNotExpectedFilter.matches(element)

private fun Cycleway?.getStyle(countryInfo: CountryInfo) = when (this) {
private fun Cycleway?.getStyle(
countryInfo: CountryInfo,
isNoCyclewayExpected: Lazy<Boolean>,
): StrokeStyle = when (this) {
TRACK ->
StrokeStyle(Color.BLUE)

Expand All @@ -145,9 +141,6 @@ private fun Cycleway?.getStyle(countryInfo: CountryInfo) = when (this) {
PICTOGRAMS ->
StrokeStyle(Color.ORANGE, dashed = true)

UNKNOWN, INVALID, null, UNKNOWN_LANE, UNKNOWN_SHARED_LANE ->
StrokeStyle(Color.DATA_REQUESTED)

BUSWAY ->
StrokeStyle(Color.LIME, dashed = true)

Expand All @@ -162,6 +155,13 @@ private fun Cycleway?.getStyle(countryInfo: CountryInfo) = when (this) {

SEPARATE ->
StrokeStyle(Color.INVISIBLE)

SIDEWALK_OK ->
StrokeStyle(Color.CYAN, dashed = true)

UNKNOWN, INVALID, UNKNOWN_LANE, UNKNOWN_SHARED_LANE ->
StrokeStyle(Color.DATA_REQUESTED)

null ->
StrokeStyle(if (isNoCyclewayExpected.value) Color.INVISIBLE else Color.DATA_REQUESTED)
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,13 @@ private fun getFootwayStyle(element: Element): PolylineStyle {
}

private fun getSidewalkStyle(element: Element): PolylineStyle {
val sidewalkSides = parseSidewalkSides(element.tags)
// not set but on road that usually has no sidewalk or it is private -> do not highlight as missing
if (sidewalkSides == null) {
if (sidewalkTaggingNotExpected(element) || isPrivateOnFoot(element)) {
return PolylineStyle(StrokeStyle(Color.INVISIBLE))
}
}
val sidewalks = parseSidewalkSides(element.tags)
val isNoSidewalkExpected = lazy { sidewalkTaggingNotExpected(element) || isPrivateOnFoot(element) }

return PolylineStyle(
stroke = null,
strokeLeft = sidewalkSides?.left.style,
strokeRight = sidewalkSides?.right.style
strokeLeft = sidewalks?.left.getStyle(isNoSidewalkExpected),
strokeRight = sidewalks?.right.getStyle(isNoSidewalkExpected)
)
}

Expand All @@ -108,9 +103,10 @@ private val sidewalkTaggingNotExpectedFilter by lazy { """
private fun sidewalkTaggingNotExpected(element: Element) =
sidewalkTaggingNotExpectedFilter.matches(element)

private val Sidewalk?.style get() = StrokeStyle(when (this) {
Sidewalk.YES -> Color.SKY
Sidewalk.NO -> Color.BLACK
Sidewalk.SEPARATE -> Color.INVISIBLE
Sidewalk.INVALID, null -> Color.DATA_REQUESTED
private fun Sidewalk?.getStyle(isNoSidewalkExpected: Lazy<Boolean>) = StrokeStyle(when (this) {
Sidewalk.YES -> Color.SKY
Sidewalk.NO -> Color.BLACK
Sidewalk.SEPARATE -> Color.INVISIBLE
Sidewalk.INVALID -> Color.DATA_REQUESTED
null -> if (isNoSidewalkExpected.value) Color.INVISIBLE else Color.DATA_REQUESTED
})

0 comments on commit e9046b1

Please sign in to comment.