-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GTFS-Fares v2] Add rule_priority to fare_leg_rules.txt #418
[GTFS-Fares v2] Add rule_priority to fare_leg_rules.txt #418
Conversation
Indicate fare_leg_rules handles empty in 2 ways
Add a sentence to establish a validator rule (concern: producers just adding the field header without knowing it will change the existing empty semantics)
In the following case: fare_leg_rules.txt
All fare leg rules are equally valid for the same trip, but different fare products are available. Does adding |
@westontrillium To my understanding,
Regarding how to present all candidate fares on the frontend (e.g., sorting, menus, defaults, etc.), I am inclined to leave this up to consumers to decide. Fwiw, regarding the expectations between producers and consumers about "what fares should be included in the candidate fares for presentation (sorting, menu, etc)," I've drafted the "expected outcome" section in this doc to share my thoughts. (Also curious about what you thoughts on this @npaun @halbertram @bdferris-v2 @skinkie) |
+1 to @tzujenchanmbd 's interpretation. |
I agree with @tzujenchanmbd's explanation as well. I'll add an example of when rule priority can really simplify things:
In Denver, taking the A line or an airport express bus to the airport requires an additional charge. All other travel is at regular rate. Rule priority saves us the work of exhaustively defining cases like "a local route to the airport is regular rate", "an airport route to a destination outside the airport is regular rate", and so on. |
Also +1 to @tzujenchanmbd 's interpretation. It might be worth adding stronger wording that all but the highest rule(s) will be discarded from the match set and therefore not considered for display, transfers etc. |
Additionally, do we need to make clear that this effectively makes fare_product_id a predicate where it might not be otherwise considered as one? Ie in a version of @npaun 's airport example where the special airport fares only applied to contactless, we presumably don't want to regard either of the priority 2 rules as matched unless those products have a line that matches a contactless fare_media_id. Or are there other thoughts of how it should work in those cases? |
@halbertram I would not have considered Put another way, I don't believe |
gtfs/spec/en/reference.md
Outdated
| `from_timeframe_group_id` | Foreign ID referencing `timeframes.timeframe_group_id` | Optional | Defines the timeframe for the fare validation event at the start of the fare leg.<br><br>The “start time” of the fare leg is the time at which the event is scheduled to occur. For example, the time could be the scheduled departure time of a bus at the start of a fare leg where the rider boards and validates their fare. For the rule matching semantics below, the start time is computed in local time, as determined by [Local Time Semantics](#localtimesemantics) of [timeframes.txt](#timeframestxt). The stop or station of the fare leg’s departure event should be used for timezone resolution, where appropriate.<br><br>For a fare leg rule that specifies a `from_timeframe_group_id`, that rule will match a particular leg if there exists at least one record in `timeframes.txt` where all of the following conditions are true<br>- The value of `timeframe_group_id` is equal to the `from_timeframe_group_id` value.<br>- The set of days identified by the record’s `service_id` contains the “current day” of the fare leg’s start time.<br>- The “time-of-day” of the fare leg's start time is greater than or equal to the record’s `timeframes.start_time` value and less than the `timeframes.end_time` value.<br><br>An empty `fare_leg_rules.from_timeframe_group_id` indicates that the start time of the leg does not affect the matching of this rule. | | ||
| `to_timeframe_group_id` | Foreign ID referencing `timeframes.timeframe_group_id` | Optional | Defines the timeframe for the fare validation event at the end of the fare leg.<br><br>The “end time” of the fare leg is the time at which the event is scheduled to occur. For example, the time could be the scheduled arrival time of a bus at the end of a fare leg where the rider gets off and validates their fare. For the rule matching semantics below, the end time is computed in local time, as determined by [Local Time Semantics](#localtimesemantics) of [timeframes.txt](#timeframestxt). The stop or station of the fare leg’s arrival event should be used for timezone resolution, where appropriate.<br><br>For a fare leg rule that specifies a `to_timeframe_group_id`, that rule will match a particular leg if there exists at least one record in `timeframes.txt` where all of the following conditions are true<br>- The value of `timeframe_group_id` is equal to the `to_timeframe_group_id` value.<br>- The set of days identified by the record’s `service_id` contains the “current day” of the fare leg’s end time.<br>- The “time-of-day” of the fare leg's end time is greater than or equal to the record’s `timeframes.start_time` value and less than the `timeframes.end_time` value.<br><br>An empty `fare_leg_rules.to_timeframe_group_id` indicates that the end time of the leg does not affect the matching of this rule. | | ||
| `fare_product_id` | Foreign ID referencing `fare_products.fare_product_id` | **Required** | The fare product required to travel the leg. | | ||
| `rule_priority` | Non-negative integer | Optional | Defines the order of priority in which matching rules are applied to legs, allowing certain rules to take precedence over others. When multiple entries in `fare_leg_rules.txt` match, the rule or set of rules with the highest value for `rule_priority` will be selected.<br><br>An empty value for `rule_priority` is treated as zero. If the `rule_priority` field exists, it should not have all records entirely empty. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the
rule_priority
field exists, it should not have all records entirely empty.
If a feed provider just wanted to add an empty rule_priority
column to turn off empty-value semantics for the feed, would that be acceptable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the sentence "If the rule_priority field exists, it should not have all records entirely empty.
"
0d3a8a5
Hello, We have at least one producer: Ito. They have shared their dataset in this file, which is part of a private feed. As per the GTFS amendment process, the requirements to open a vote are met. Voting ends on 2024-05-20 at 23:59:59 UTC. |
+1 from Google I can confirm that we are using this extension as well. |
+1 from Apple |
+1 from Transit |
+1 from Ito |
+1 from Interline |
The vote passed on 2024-05-20 at 23:59:59 UTC. 5 votes in favour and no votes against. The votes came from: Thanks to everyone who contributed and voted! |
Context
The
rule_priority
field is originally derived from Ito World's "override" proposal, it is used to simply represent cases when some matching rules need to take precedence over other matching rules.During the discussion of the
rule_priority
proposal, the working group identified issues regarding backward compatibility and how to align with the existing empty semantics(“anything except…”) ofnetwork_id
,from_area_id
, andto_area_id
. In the meeting on August 22nd, the working group reached a consensus on the need for a rule_priority field and the mechanism for changing empty semantics. It was agreed that this mechanism should not cause breaking changes for feed producers. After this discussion, we have also drafted this spec modeling proposal.In the meeting on September 26th, there was agreement on moving forward with Option 1 in the spec modeling proposal for changing empty semantics (
rule_priority
field existence as a trigger)Changes in this PR
rule_priority
field infare_leg_rules.txt
fare_leg_rules
file description to indicate the difference betweenrule_priority
and existing empty semanticsfare_leg_rules.network_id
,fare_leg_rules.from_area_id
,fare_leg_rules.to_area_id
field description to indicate the difference betweenrule_priority
and existing empty semanticsThis PR uses the existence of the
rule_priority
field as a trigger to change existing empty semantics.What is not included in this PR
scope
orrule_priority_scope
fieldrule_priority
infare_transfer_rules.txt
The working group agrees that we can consider introducing
rule_priority
forfare_transfer_rules
after gaining a better understanding of the mechanism behindfare_transfer_rules
.Validator rule
We noticed that producers might directly include field headers (without any values), but failed to realize this could pose in altering the existing empty semantics. Therefore, the description of
rule_priority
included the sentence "If the rule_priority field exists, it should not have all records entirely empty." When therule_priority
field exists, but all records across the files are empty, the validator will trigger a warning.For previous discussions, please see issue#383 and working group meeting minutes.
Please go through the changes and feel free to share your thoughts/questions here.