User:Marl/route segments filters draft

From OpenStreetMap Wiki
Jump to navigation Jump to search

Concept

... (as from the current proposal) ...

While adding a route segment to a route, members can be filtered. This is useful if one and the same segment fits into many routes, just with a few differences, depending on the actual use.

Examples for route filtering:

  • Most bus routes use the same ways most of the time for both route directions, even in urban areas. But there are some one-way roads (including dual-carriageway roads and roundabouts) that break the whole thing. Instead of duplicating the set of ways and maintaining them separately, one set can be used.
  • A common set of bus stops (platforms and stop positions) is used as part of several bus routes. However, some of these stops are skipped by some of the routes. Instead of splitting the segments at every stop that is not serviced by all lines, these special stops are just marked and used or filtered out by the actual bus routes, as needed.
  • A set of ways shared by hiking and cycle routes (such as Thames Path, NCN4 and Jubilee Walk along the Thames in London). At some places, the footways Thames Path and Jubilee Walk deviate slightly from the Cycle route NCN6. The common parts of these routes could be maintained together, instead of repairing all route relations separately when editing the ways they are using.

Route Segment Relation Membership

Members of a route segment are usually added in the same way they would be added to the actual routes. However, filter criteria can be appended to the membership role name.

A filter criteria consists at least of an operator ("only", "with" or "no") and a dimension. Values or a value range after the dimension are optional.

Typical dimensions are:

  • "direction", "dir": allows the route to be shared between directions. Because different route definitions use different names for directions, there is a set of common directions:
    • forward/backward,fo/ba: following the route according to the order (or reverse order) of way memberships; useful for public transport routes that are already ordered
    • from/to, fr/to: towards the "from" tag of the route or towards the "to" tag of the route.
    • clockwise/counter-clockwise, cl/co: useful for more or less circular routes
    • north/east/south/west, no/ea/so/we: Compass directions; useful for routes that have no fixed or well-known order way ordering or from/to definitions.
  • "level": giving a service level (roughly linked to importance) to members.
    • The basic level is 0. It is used for members that are usually when travelling along a route.
    • When defining an ordinary route based on a segment containing levels, the levels are ignored. In my example, a "stop_level_-10" member would be included into the main route just with the role "stop".
    • When defining a higher level route, such an express route, the route segment would be included with a role name "level_10", meaning that members with a non-matching level attribute will not be considered to be part of the route.
    • This can also be used for ways leading to stop positions that are used by certain levels only.
      • The way leading to the level 0 stop would be included with 'level_-9'.
      • The straight way bypassing the special way would be included with 'level_10-'.
    • An idea of defined levels:
      • Railway:
        • Local trains: 0 (In Germany: RB, MEr, etc.)
        • Express trains: 10 (In Germany: RE, ME, ...)
        • ???: 20 (in Germany: IC, EC, ...)
        • ???: 30 (in Germany: ICE, in France: TGV, in Belgium: Thalys)
      • Buses:
        • Ordinary buses: 0
        • Express buses: 10
        • Buses between cities that serve less stops that normal express buses (or other special, such as airport express buses, with only a few stops along shared bus routes): 20
        • International bus services: 30
      • Hiking/Cycling (unfortunately, this does not support the individual inclusion of optional parts):
        • The longest variant: 0
        • The most frequently used variant (if shorter than the longest one): 10
        • A short variant, using all offered shortcuts: 20
  • type: The route type defines route details. Typical values are
    • "foot"
    • "bicycle"
    • "bus"
    • "tram"

The full membership role syntax is: Role Membership name: <Actual Role>{_<Filter Expression>}... Filter Expression: one of

  • <operator>_<dimension>
  • <operator>_<dimension>_<value>
  • <operator>_<dimension>_[<minvalue>]-[maxvalue]

Operator: one of

  • "_only": This member is by default not used for relations using this route segment. It will be included only if the dimension is explicitly requested when using the segment and only if given values match the requested value.
  • "_with": This member is by default used for relations using this route segments. It is also used if the presence of the dimension is requested by a route using this segment.
  • "_no": This member is by default used for relations using this route segments, except if the dimension is explicitly requested when using the segment and (if given) values match the requested value.

Adding a Segment to a Route

when adding a segment to a route, the relation membership role is "segment", or "reverse_segment", optionally followed by filter expressions.

If the membership role is "segment", the members of the segment relation will be handled exactly like members of the actual route, in the order of appearance in the segment. If the role is "reverse_segment", the membership order is reversed, so the set of ways can be used for a public transport route in the opposite direction. This also works for stop positions, as long as the exact stop positions are unknown or filtered correctly.

This filter syntax is very similar to the segment. Obviously, the operators' meanings must be defined differently, so they can be read intuitively:

  • "only": requests a specific dimension to be mentioned for segment members to be used. If the dimension is followed by a value or a range and the segment membership role also has got a value or range defined, the both values or ranges must match. Ranges match when they overlap (have at least one common value).
  • "with": requests a specific dimension not to be excluded by matching "no" filter expressions in the segment membership role. If values or ranges are given on both sides, they must match for the "no" expression to exclude the member.
  • "no": reqests a specific dimension not to be mentioned for segment members to be used. If values or ranges are given on both sides, they must match for the member not to be used. This is the exact opposite of "only".

Example: A mainly common set of ways can be imported into a bus route using "segment_no_dir_ba". When including the same set of ways into the opposite bus route, the route relation membership of the segment would be "reverse_segment_no_dir_fo". This would make sure that all parts of the segment that are not labelled "backward" would be added to the forward route, in their correct order. The backward route would use all parts that are not explicitly labelled "forward", in the order needed for that route.