Skip to content

Commit

Permalink
improve parsing of parkings
Browse files Browse the repository at this point in the history
now parking:condition:right=no will be recognized, also without parking:lane:right=no
  • Loading branch information
matkoniecz committed May 13, 2022
1 parent 8de92cb commit 783698a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.westnordost.streetcomplete.osm.street_parking

import android.util.Log
import de.westnordost.streetcomplete.osm.street_parking.ParkingOrientation.DIAGONAL
import de.westnordost.streetcomplete.osm.street_parking.ParkingOrientation.PARALLEL
import de.westnordost.streetcomplete.osm.street_parking.ParkingOrientation.PERPENDICULAR
Expand All @@ -23,16 +24,23 @@ fun createStreetParkingSides(tags: Map<String, String>): LeftAndRightStreetParki
private fun createParkingForSide(tags: Map<String, String>, side: String?): StreetParking? {
val sideVal = if (side != null) ":$side" else ""

val parkingValue = tags["parking:lane$sideVal"] ?: return null
val parkingValue = tags["parking:lane$sideVal"]
?: return when (tags["parking:condition$sideVal"]) {
// new style tagging of parking restrictions, without parking:lane:*=no
"no_parking" -> StreetParkingProhibited
"no_standing" -> StreetStandingProhibited
"no_stopping" -> StreetStoppingProhibited
"no" -> NoStreetParking
else -> null
}

when (parkingValue) {
// old style tagging
"no_parking" -> return StreetParkingProhibited
"no_standing" -> return StreetStandingProhibited
"no_stopping" -> return StreetStoppingProhibited
"no" -> {
val parkingCondition = tags["parking:condition$sideVal"]
return when (parkingCondition) {
return when (tags["parking:condition$sideVal"]) {
// new style tagging
"no_parking" -> StreetParkingProhibited
"no_standing" -> StreetStandingProhibited
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ class StreetParkingParserKtTest {
)))
}

@Test fun `prohibited tagged without explicit lane tag`() {
assertEquals(
LeftAndRightStreetParking(StreetStandingProhibited, NoStreetParking),
createStreetParkingSides(mapOf(
"parking:condition:left" to "no_standing",
"parking:condition:right" to "no"
)))
}

@Test fun `parking separate`() {
assertEquals(
LeftAndRightStreetParking(StreetParkingSeparate, null),
Expand Down

0 comments on commit 783698a

Please sign in to comment.