iduedu.deduplicate_across_feeds

iduedu.deduplicate_across_feeds(tables, prefixes, *, platform_tolerance=0.5, crs=None)[source]

Count once what several merged feeds publish twice. Edits tables in place.

Catalogues overlap: two versions of one feed, a national feed and a city feed of the same operator, a mirror and its original. Merged with qualified identifiers, the copies never collide – they sit side by side, and the graph gets two patterns where the city runs one. Two rules remove them, both narrow on purpose, because a wrong merge is worse than a leftover duplicate:

  • Platforms – stops rows with location_type 0 or empty, where passengers board; the graph builder makes them platform nodes, while the vehicle’s stopping place is a separate node per pattern and is not touched. Platforms of different sources within platform_tolerance metres are one platform. The default 0.5 m is measured: across 125 703 platforms of cities merged from several feeds, 63% had another source’s platform within 0.5 m (the same coordinate republished), while distinct platforms of one feed already occur 1-3 m apart. Stations, entrances, generic nodes and boarding areas are never fused, nor platforms of one source.

  • Trips – after that, a trip of one source is a copy of a trip of another when both run the same route_type through the same platforms with the same arrival and departure times (in seconds), pickup and drop-off rules and, for frequency-based trips, the same headways. The source that sorts first keeps it.

Parameters:
  • tables (dict[str, DataFrame]) – Merged tables keyed by GTFS table name without .txt, identifiers qualified as <prefix>:<id>.

  • prefixes (Sequence[str]) – The prefix of each source.

  • platform_tolerance (float) – Metres within which two sources’ platforms are one.

  • crs (Any | None) – Projected CRS in metres for the distance test; estimated when omitted.

Return type:

dict[str, int]

Returns:

{"platforms_fused": n, "trips_dropped": m}.