|
| 1 | +# How to route inside pedestrian areas {#pedestrian_areas} |
| 2 | + |
| 3 | +How to route inside pedestrian areas, or over the interior of an area where you can |
| 4 | +travel freely in all directions. |
| 5 | + |
| 6 | +%OSRM can create routes crossing the interior of an area by generating virtual ways |
| 7 | +between every pair of entry points to the area. This process is called @em meshing. The |
| 8 | +generated ways follow lines of sight, avoid obstacles, and use existing nodes. An entry |
| 9 | +point is where another way connects to the perimeter of the area. |
| 10 | + |
| 11 | +This feature is still EXPERIMENTAL. |
| 12 | + |
| 13 | +## Configuration |
| 14 | + |
| 15 | +To opt-in to this feature, you must declare an algorithm to be used for area meshing. |
| 16 | +Find the place where the @ref properties are defined in your LUA profile's @ref setup |
| 17 | +function and insert this line: |
| 18 | + |
| 19 | +```lua |
| 20 | +function setup() |
| 21 | + ... |
| 22 | + return { |
| 23 | + properties = { |
| 24 | + ... |
| 25 | + area_meshing_algorithm = 'visgraph+dijkstra', -- << insert this line |
| 26 | + ... |
| 27 | + }, |
| 28 | + } |
| 29 | +end |
| 30 | +``` |
| 31 | + |
| 32 | +Note: Only the `visgraph+dijkstra` algorithm is available at present. |
| 33 | + |
| 34 | +All areas to be meshed must be registered with the @ref AreaManager. In OpenStreetMap <a |
| 35 | +href="https://wiki.openstreetmap.org/wiki/Tag:highway%3Dpedestrian#Squares_and_plazas"> |
| 36 | +areas are mapped</a> either as a closed way or as a multipolygon relation. Both flavours |
| 37 | +must be configured separately. |
| 38 | + |
| 39 | +### Meshing closed ways |
| 40 | + |
| 41 | +To mesh a closed way you must register it in your @ref process_way function. Insert |
| 42 | +following lines into your existing `process_way` function, immediately after the "quick |
| 43 | +initial test": |
| 44 | + |
| 45 | +```lua |
| 46 | +function process_way(profile, way, result, relations) |
| 47 | + ... |
| 48 | + if way:has_tag('highway', 'pedestrian') and way:has_true_tag('area') then |
| 49 | + -- register the way |
| 50 | + area_manager:way(way) |
| 51 | + return |
| 52 | + end |
| 53 | + ... |
| 54 | +end |
| 55 | +``` |
| 56 | + |
| 57 | +(Note that open ways cannot be meshed and will be ignored.) |
| 58 | + |
| 59 | +### Meshing multipolygon relations |
| 60 | + |
| 61 | +To mesh a multipolygon relation you must register it in the @ref process_relation |
| 62 | +function. The `process_relation` function is a newly introduced function that is called |
| 63 | +for every relation in the input file. You'll have to create the function like this: |
| 64 | + |
| 65 | +```lua |
| 66 | +function process_relation(profile, relation, relations) |
| 67 | + if relation:has_tag('type', 'multipolygon') and relation:has_tag('highway', 'pedestrian') then |
| 68 | + -- register the relation |
| 69 | + area_manager:relation(relation) |
| 70 | + end |
| 71 | +end |
| 72 | +``` |
| 73 | + |
| 74 | +And you must also return the `process_relation` function at the end of your profile: |
| 75 | + |
| 76 | +```lua |
| 77 | +return { |
| 78 | + setup = setup, |
| 79 | + process_way = process_way, |
| 80 | + process_node = process_node, |
| 81 | + process_relation = process_relation, -- << add this line |
| 82 | + ... |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +At this point you have a working basic configuration. Remember that you must run |
| 87 | +`osrm-extract` before your changes become effective. |
| 88 | + |
| 89 | +### Processing the generated ways |
| 90 | + |
| 91 | +While not necessary, you may want to apply further processing to the @em generated ways. |
| 92 | +The generated ways are passed to the @ref process_way function in the usual fashion. |
| 93 | +They have the same tags as the original way or relation, except: |
| 94 | + |
| 95 | +- the `area` tag is removed on ways, |
| 96 | +- the `type` tag is removed on relations, |
| 97 | +- an `osrm:virtual=yes` tag is added. |
| 98 | + |
| 99 | +You can pick generated ways like this: |
| 100 | + |
| 101 | +```lua |
| 102 | +function process_way(profile, way, result, relations) |
| 103 | + ... |
| 104 | + if way:has_key('osrm:virtual') then |
| 105 | + -- do something with the way here |
| 106 | + end |
| 107 | + ... |
| 108 | +end |
| 109 | +``` |
| 110 | + |
| 111 | +@sa AreaManager |
| 112 | +<br> A complete example profile is found in the file: [profiles/foot_area.lua](../profiles/foot_area.lua). |
| 113 | +<br> https://wiki.openstreetmap.org/wiki/Relation:multipolygon |
| 114 | +<br> https://wiki.openstreetmap.org/wiki/Key:area |
| 115 | +<br> https://wiki.openstreetmap.org/wiki/Tag:highway%3Dpedestrian#Squares_and_plazas |
0 commit comments