Skip to content

Route through squares (area=yes) #64

Closed
MarcelloPerathoner/osrm-backend
#6

Description

@emiltin

handling square might not be trivial, and are probably mostly important for pedestrian routing. so this might be for a future version.

the thing with a square is that you can cross it in any way. unfortunately squares can have odd shapes, so it's not always possible go in a straight line from where you enter to where you leave. for example a building might be in the way if the square has a hour-glass shape.

a simple example is "Prins Jørgens Gård" is a square, tagged with highway=pedestrian, area=yes:
http://www.openstreetmap.org/?lat=55.676763&lon=12.579427&zoom=18&layers=M

if i set up a pedestrain speedprofile, which includes 'pedestrian=5', osrm will route at the edge of the square. this is will get me across the square, but in a somewhat odd fashion.

one option would be to add routes connecting all entries to the square to all others. another would be to connect all entries to a central point. perhaps these to options could be improved by checking that routes are only added if they don't cross the square boundary.

a third option would be be still route along the edge of the square, but insert the route some reasonably distance from the edge, since in reality you cant walk right at the edge of the building.

Activity

  1. emiltin commented on Feb 13, 2012

    @emiltin
    ContributorAuthor

    another idea for handling areas: find all nodes along the edge that is also part of a way with a highway=* tag, or another area. then divide this polygon using standard subdidivision algorithms. this might provide a good balance between not adding too many lines, while still providing significant a pretty good route across any type of square.

  2. DennisOSRM commented on Sep 23, 2012

    @DennisOSRM
    Collaborator

    Yes, very standard modelling.

  3. modified the milestones: 4.8.0, 6.0 on May 24, 2015
  4. changed the title [-]squares (area=yes)[/-] [+]Route through squares (area=yes)[/+] on May 24, 2015
  5. TheMarex commented on May 24, 2015

    @TheMarex
    Member

    Brain dump on how to do this:

    • This requires that we have all node locations available when processing a way
    • Add area flag to ExtractionWay
    • In ExtractorCallbacks::ProcessWay compute the visibility graph of the polygon (naive algorithm):
      • For each pair of boundary vertices check if they can be connected without intersecting the boundary
      • Add edge for pair if intersection free

    AFAIK there is an algorithm in deBerg that routes through cell centers, but I would need to look this up.

  6. lbud commented on Jun 10, 2015

    @lbud
    Member

    this would also be awesome for, say, indoor routing :)

  7. modified the milestones: 4.9.0, 4.8.0 on Aug 19, 2015
  8. modified the milestones: , 4.9.0 on Nov 17, 2015
  9. modified the milestones: 5.1.0, on Mar 9, 2016
  10. 10 remaining items

  11. daniel-j-h commented on Mar 27, 2017

    @daniel-j-h
    Member

    Yes, at least the simple approach won't do for multipolygons. Have a look at these examples in the context of area routing via creating artificial ways.

  12. joto commented on Mar 27, 2017

    @joto
    Contributor

    @daniel-j-h Note that the osmium::Area::is_multipolygon() call will only check whether the area has more than one outer ring. What you seem to be interested in is that it doesn't have any inner rings. You'd have to call num_rings() for that.

  13. emiltin commented on Jun 9, 2017

    @emiltin
    ContributorAuthor

    regarding tag combinations, we should reuse as much of the usual way processing as possible, to handle tags like access, foot, bicycle, car, surface, smoothness, construction, impassable, status, amenity, platform, railway, service, steps, etc.

    tags related to direction will not apply to squares, like oneway, *:forward and *:backward and should be ignored (and would be invalid tagging anyways). same with tags related to lanes and width.

    turn restrictions to/from a square probably doesn't apply either.

  14. sfkeller commented on Oct 8, 2017

    @sfkeller

    What is the reason that this issue about pedestrian routing through areas has such low priority?

    I'm asking because mappers obviously continue to add "virtual" ways over areas in OSM. This is unncessary and like "tagging for the router". In addition it looks weird in renderers, because such pedestrian ways can't be distinguished from "real" ones without guessing...

  15. daniel-j-h commented on Oct 9, 2017

    @daniel-j-h
    Member

    Mainly two reasons

    1. in the last two years the core dev team heavily focused on car navigation;
      and @emiltin is working on all things bike routing for his own use-case
    2. no one stepped up and wanted to implement it;
      if you have a use-case for this and see a need here we're more than happy to guide you along.
  16. emiltin commented on Oct 9, 2017

    @emiltin
    ContributorAuthor

    This is highly relevant for bicycle routing as well (which is why I opened the issue originally), since:

    1. you're allowed to bicycle on some areas
    2. you can push your bike on most areas where you're allowed to walk

    But unfortunately I don't have time to implement it.

  17. systemed commented on Oct 9, 2017

    @systemed
    Member

    FWIW, it's not "tagging for the renderer/router". That means putting incorrect information in to achieve the desired effect: for example, tagging a golf course bunker as a beach so it shows up as sand, even though it's not a beach. Adding centrelines or virtual ways is perhaps duplicate information, but it's been done since the very earliest days of OSM (on rivers).

  18. andrewharvey commented on Oct 9, 2017

    @andrewharvey

    Open question: are there other tags / combinations we have to take care of? Sample OSM!

    natural=beach for the walking profile. Beaches don't normally have a path going through them but you can walk along them.

  19. sfkeller commented on Oct 9, 2017

    @sfkeller

    @systemed: I'm talking about not-existing and misleading (sic!) footways which have been added only to enhance a router, like on this place "Helvetiaplatz, Zurich" (http://www.openstreetmap.org/way/4533221 ). There you also see that these unnecessary footways are only partially working since the route from east to west side is missing...
    capture

  20. saerdnaer commented on May 18, 2018

    @saerdnaer

    if you have a use-case for this and see a need here we're more than happy to guide you along.

    @daniel-j-h Can you give some pointers how to start implementing this issue? Which classes have to be modified? (besides #64 (comment) )

  21. daniel-j-h commented on May 18, 2018

    @daniel-j-h
    Member

    If you give the ExtractionWay here a new property maybe is_area and expose it to the profiles through the scripting environment here you can parse a way's area tag in the Lua profiles and set the attribute accordingly.

    You probably also want to expose is_closed on the osmium::Way in the scripting environment here because you only care for closed ways (=> areas).

    Once you have the attribute on the ExtractionWay and inside C++-land you can modify the ExtractorCallbacks here to compute e.g. the visibility graph and add edges.

    Hope that helps

  22. dreirund commented on Apr 23, 2025

    @dreirund

    See also #4176 and #7146.

  23. emiltin commented on Aug 12, 2026

    @emiltin
    ContributorAuthor

    nice to see this ancient issue completed 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions