Matching engine E.2.2

Name matching

The name rule (name, one of the matching rules) matches a source stop to an OSM element with exactly the same name. It catches stops that the reference rules could not match, for example because the OSM element has no uic_ref.

flowchart TB A["Unmatched source stop"] --> Z{"Has a name?"} Z -->|"no"| X["No match"] Z -->|"yes"| K["Look up OSM elements with that<br/>name, uic_name or gtfs:name"] K --> S{"How many<br/>candidates?"} S -->|"none"| X S -->|"one"| L1{"Within the profile's<br/>name distance?"} S -->|"several"| D{"One with local_ref =<br/>platform code?"} D -->|"yes"| L2{"Within the profile's<br/>name distance?"} D -->|"no"| X L1 -->|"yes"| M1["Match: name_one_osm"] L2 -->|"yes"| M2["Match: name_local_ref"] L1 -->|"no"| X L2 -->|"no"| X

How it works

For each unmatched source stop with a non-empty name, the rule looks up the OSM elements whose name, uic_name or gtfs:name tag is exactly that string: case, accents and abbreviations must agree. The rule does not normalize names, so St. and Sankt, or a name with and without a municipality prefix, are different names. Stations and pair partners are excluded, as for every rule.

  • One candidate: it is chosen, as name_one_osm, unless an identifier already linked part of the stop's station: the one element left is then not the stop by elimination, and only the platform code decides, as below (E2.1).
  • Several candidates: the first whose local_ref equals the stop's platform code, ignoring case, is chosen, as name_local_ref. Without such a candidate, or when the stop has no platform code, the stop stays unmatched.
  • Distance limit: the chosen candidate must lie within the profile's name_match_max_distance: 1000 m in the default profile, because the same name can occur in several towns. The Swiss profile sets no limit.
Dataset Name field Record field Platform code
ATLAS designationOfficial SourceStop.name SourceStop.platform_code (designation)
OSM name, uic_name, gtfs:name tags OsmNode.name, OsmNode.uic_name, tags['gtfs:name'] OsmNode.local_ref

Stops still unmatched go on to the GTFS route rule and the distance rules.

Name aliases in the Swiss profile

The OSM name index lists an element under each of its name tags. The Swiss profile sets preserve_name_alias_multiplicity, which keeps an element listed once per tag, even when name and uic_name hold the same value. Such an element then counts as two candidates for that name, so the name rule can only choose it through a matching platform code; otherwise a later rule can match it, such as the group rule as uic_name_group_distance. The generic profile lists each distinct name once.

Code

File Role
src/osm_public_transport_matcher/core/predicates/name_matching.py NamePredicate
src/osm_public_transport_matcher/core/state.py OsmState.from_records() builds the name index