Skip to content

Commit

Permalink
osm.FootProfile: only consider oneway:foot by default
Browse files Browse the repository at this point in the history
  • Loading branch information
MKuranowski committed Jul 20, 2024
1 parent bca383e commit 40acaa6
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions pyroutelib3/osm/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def way_direction(self, way_tags: Mapping[str, str]) -> Tuple[bool, bool]:
backward = False

# Check against the oneway tag
oneway = way_tags.get("oneway")
oneway = self.get_active_oneway_value(way_tags)
if oneway in ("yes", "true", "1"):
forward = True
backward = False
Expand All @@ -167,6 +167,15 @@ def way_direction(self, way_tags: Mapping[str, str]) -> Tuple[bool, bool]:

return forward, backward

def get_active_oneway_value(self, tags: Mapping[str, str]) -> str:
active_value = tags.get("oneway", "")
for mode in self.access:
if mode == "access":
continue
if value := tags.get(f"restriction:{mode}"):
active_value = value
return active_value

def is_turn_restriction(self, tags: Mapping[str, str]) -> TurnRestriction:
if tags.get("type") != "restriction" or self.is_exempted(tags):
return TurnRestriction.INAPPLICABLE
Expand All @@ -184,10 +193,11 @@ def is_turn_restriction(self, tags: Mapping[str, str]) -> TurnRestriction:
return TurnRestriction.INAPPLICABLE

def get_active_restriction_value(self, tags: Mapping[str, str]) -> str:
active_value = ""
active_value = tags.get("restriction", "")
for mode in self.access:
key = f"restriction:{mode}" if mode != "access" else "restriction"
if value := tags.get(key):
if mode == "access":
continue
if value := tags.get(f"restriction:{mode}"):
active_value = value
return active_value

Expand Down Expand Up @@ -309,9 +319,8 @@ class FootProfile(NonMotorroadHighwayProfile):
FootProfile treats several tags differently to :py:class:`HighwayProfile`:
* ``public_transport=platform`` and ``railway=platform`` are treated as-if ``highway=platform``
* (TODO) ``oneway`` tags are ignored, unless on ``highway=footway``, ``highway=path``,
``highway=steps`` or ``highway=platform``. On other ways,
only ``oneway:foot`` is considered.
* ``oneway`` tags are ignored, unless on ``highway=footway``, ``highway=path``,
``highway=steps`` or ``highway=platform``. On other ways, only ``oneway:foot`` is used.
* Only ``restriction:foot`` turn restrictions are considered.
"""

Expand Down Expand Up @@ -352,5 +361,13 @@ def get_active_highway_value(self, tags: Mapping[str, str]) -> str:
return "platform"
return highway

def get_active_oneway_value(self, tags: Mapping[str, str]) -> str:
active_value = ""
if self.get_active_highway_value(tags) in ("footway", "path", "steps", "platform"):
active_value = tags.get("oneway", "")
if value := tags.get("oneway:foot", ""):
active_value = value
return active_value

def get_active_restriction_value(self, tags: Mapping[str, str]) -> str:
return tags.get("restriction:foot", "")

0 comments on commit 40acaa6

Please # to comment.