You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a proposal for a new validation rule for the GTFS Validator, inspired by the GTFS specification's description of block_id. According to the spec, block_id is used to group trips operated by the same vehicle, and this implies that all trips within the same block should share the same mode of transportation. A validation rule can help ensure that vehicles are not incorrectly switching modes within a block.
Specifically, this rule would check that all trips sharing the same block_id in trips.txt reference routes with consistent route_type values in routes.txt. If a block_id is found to span multiple route_type values, a WARNING should be issued.
This enhancement aligns with how some GTFS consumers (such as Google, please see the attached screenshot) handle blocks to ensure feed quality and could prevent potential errors in downstream systems.
Proposed Rule
Rule Name: Inconsistent route_type Values in Trips Sharing a block_id
Description: Trips with the same block_id in the trips.txt file must have consistent route_type values in the routes.txt file. If trips within a block have differing route_type values, a warning needs to be issued.
Severity: WARNING
Affected Files: trips.txt routes.txt
Describe the new validation rule
routeTypeMap = {route["route_id"]: route["route_type"] for route in gtfsData["routes.txt"]}
blockRouteTypes = {}
for trip in gtfsData["trips.txt"]:
block_id = trip["block_id"]
route_id = trip["route_id"]
if block_id and route_id in routeTypeMap:
blockRouteTypes.setdefault(block_id, set()).add(routeTypeMap[route_id])
warnings = []
for block_id, route_types in blockRouteTypes.items():
if len(route_types) > 1:
warnings.append(f"Inconsistent route_types for block_id '{block_id}': {list(route_types)}")
return warnings
In this GTFS sample block_id 20090-1-161 is associated with routes 20 and 484. Route 20 is of type 1 and 484 of type 3, which should trigger the inconsistent route type warning.
Severity
WARNING
Additional context
The text was updated successfully, but these errors were encountered:
Describe the problem
This is a proposal for a new validation rule for the GTFS Validator, inspired by the GTFS specification's description of
block_id
. According to the spec,block_id
is used to group trips operated by the same vehicle, and this implies that all trips within the same block should share the same mode of transportation. A validation rule can help ensure that vehicles are not incorrectly switching modes within a block.Specifically, this rule would check that all trips sharing the same
block_id
in trips.txt reference routes with consistentroute_type
values in routes.txt. If ablock_id
is found to span multipleroute_type
values, a WARNING should be issued.This enhancement aligns with how some GTFS consumers (such as Google, please see the attached screenshot) handle blocks to ensure feed quality and could prevent potential errors in downstream systems.
Proposed Rule
Rule Name: Inconsistent route_type Values in Trips Sharing a
block_id
Description: Trips with the same
block_id
in thetrips.txt
file must have consistentroute_type
values in theroutes.txt
file. If trips within a block have differingroute_type
values, a warning needs to be issued.Severity: WARNING
Affected Files:
trips.txt
routes.txt
Describe the new validation rule
routeTypeMap = {route["route_id"]: route["route_type"] for route in gtfsData["routes.txt"]}
Sample GTFS datasets
austin_gtfs.zip
In this GTFS sample block_id 20090-1-161 is associated with routes 20 and 484. Route 20 is of type 1 and 484 of type 3, which should trigger the inconsistent route type warning.
Severity
WARNING
Additional context
The text was updated successfully, but these errors were encountered: