[GTFS Fares v2] Area Set matching predicates.#483
[GTFS Fares v2] Area Set matching predicates.#483bdferris-v2 wants to merge 2 commits intogoogle:masterfrom
Conversation
gtfs/spec/en/reference.md
Outdated
|
|
||
| <br/> | ||
|
|
||
| For area set predicates in `fare_leg_rules.txt` specified below, a leg “travels through an area” if any of the stops or parent stations (if the area is not defined at the stop-level) of the leg; including departure, arrival, and intermediate stops; belongs to the specified area as defined by [stop_areas.txt](#stopareastxt). |
There was a problem hiding this comment.
For the intermediate stops, it seems they must be stops defined in stop_times rather than "geographical pass-through" stops. Could the current description cause misunderstandings? Would it be clearer to state this explicitly?
There was a problem hiding this comment.
I attempted to add explicit language. Let me know what you think.
There was a problem hiding this comment.
Looks good to me!
Just to confirm:
and intermediate stops as referenced by the trip's stop-time entries; belongs to the specified area as defined by [stop_areas.txt]
This means that entries will be included regardless of their pickup_type and drop_off_type values (e.g., value=1 - No pickup/drop_off available). Is this correct?
There was a problem hiding this comment.
Yes, I suppose that's correct.
I think we discussed this briefly in the last meeting, yes? I think it's reasonable to make the default the simple case (passes through a stop).
There was a problem hiding this comment.
Yes, got it. Just want to confirm if I correctly understand the semantics here (i.e. regardless of the pickup_type and drop_off_type values).
|
Whilst we are far along in this proposal, I recently had the following thought. It may be overly pedantic (and doesn't come with a proposed solution), but it might be worth discussing. There seems to be a bit of a variation between how eg areas are formed from stops, and how area sets are formed from areas. Stops and areas / Routes and networks
Areas and area setsarea_sets.txt defines the collections and the insertion. It's not clear where any fields that an area set might gain down the line would go. If we view the collection as 'set', then it does partially follow the above scheme, but that will cause issues once we have network sets, and sets.txt would be ambiguous. However having area_sets.txt and area_area_sets.txt doesn't seem sensible. We could find a name for an area set (in the way that we call a 'stop set' an area), possibly 'region' – but may be hard to find a word that would be appropriate in all uses of area sets. (Also would eventually have to find one for the corresponding network and trip_group cases). Or further area set level fields could go in area_set_details.txt. |
|
It seems reasonable to separate collections and insertions into collections into two files, which is consistent with the existing three cases ( |
|
Did we talk about this briefly in the Fares v2 meeting last week? Or did I just imagine talking about this? :) Agreed that the naming is awkward here. A couple options:
|
|
Last week I mentioned that Hal raised this question, but it seems we didn’t dive into the discussion. :) Currently, all similar files (e.g., Regarding naming, How does this look?
|
|
This pull request has been automatically marked as stale because of lack of recent activity. It may be closed manually after one month of inactivity. Thank you for your contributions. |
|
(Apologies, not many cycles to think about Fares v2 these days) Reflecting on this proposal and the Trip Groups proposal, I wanted to propose an alternate file naming scheme for sets:
So then we'd have:
@halbertram thoughts? |
|
I think that makes sense given the various options. |
|
I've implemented support for this feature in MOTIS (released in v2.0.71). Maybe it's obvious for others but it could help to explicitly state how to deal with stops that are assigned to more than one area (stop_areas.txt has primary key I implemented it like this:
|
|
This pull request has been automatically marked as stale because of lack of recent activity. It may be closed manually after one month of inactivity. Thank you for your contributions. |
|
not stale |
| | Field Name | Type | Presence | Description | | ||
| | ------ | ------ | ------ | ------ | | ||
| | `area_set_id` | Unique ID | **Required** | Identifies an area set. Must be unique in [area_sets.txt](#area_setstxt). | | ||
| | `area_id` | Foreign ID referencing `areas.area_id` | **Required** | Identifies an area to be included in the set. The same `area_id` may be defined in multiple area sets. | |
There was a problem hiding this comment.
| | `area_id` | Foreign ID referencing `areas.area_id` | **Required** | Identifies an area to be included in the set. The same `area_id` may be defined in multiple area sets. | |
There was a problem hiding this comment.
The name also needs to be added.
| `area_set_name` | Text | **Required** | The name of the area set. |
|
|
||
| File: **Optional** | ||
|
|
||
| Primary key (`*`) |
There was a problem hiding this comment.
| Primary key (`*`) | |
| Primary key (`area_set_id`) |
| | ------ | ------ | ------ | ------ | | ||
| | `area_set_id` | Unique ID | **Required** | Identifies an area set. Must be unique in [area_sets.txt](#area_setstxt). | | ||
| | `area_id` | Foreign ID referencing `areas.area_id` | **Required** | Identifies an area to be included in the set. The same `area_id` may be defined in multiple area sets. | | ||
|
|
There was a problem hiding this comment.
| ### area_set_elements.txt | |
| File: **Optional** | |
| Primary key (`*`) | |
| Groups collections of areas into sets. | |
| | Field Name | Type | Presence | Description | | |
| | ------ | ------ | ------ | ------ | | |
| | `area_set_id` | Foreign ID referencing `area_sets.area_set_id` | **Required** | Identifies an area set to which one or multiple `area_id`s belong. | | |
| | `area_id` | Foreign ID referencing `areas.area_id` | **Required** | Identifies an area to be included in the set. The same `area_id` may be defined in multiple area sets. | |
|
|
||
| Primary key (`*`) | ||
|
|
||
| Groups collections of areas into sets. |
There was a problem hiding this comment.
| Groups collections of areas into sets. | |
| Defines area set identifiers that apply for fare leg rules. |
| | [fare_transfer_rules.txt](#fare_transfer_rulestxt) | Optional | Fare rules for transfers between legs of travel.<br><br>Along with [fare_leg_rules.txt](#fare_leg_rulestxt), file [fare_transfer_rules.txt](#fare_transfer_rulestxt) provides a more detailed method for modeling fare structures. As such, the use of [fare_transfer_rules.txt](#fare_transfer_rulestxt) is entirely separate from files [fare_attributes.txt](#fare_attributestxt) and [fare_rules.txt](#fare_rulestxt). | | ||
| | [areas.txt](#areastxt) | Optional | Area grouping of locations. | | ||
| | [stop_areas.txt](#stop_areastxt) | Optional | Rules to assign stops to areas. | | ||
| | [area_sets.txt](#area_setstxt) | Optional | Collections of areas. | |
There was a problem hiding this comment.
| | [area_sets.txt](#area_setstxt) | Optional | Collections of areas. | | |
| | [area_sets.txt](#area_setstxt) | Optional | Collections of areas. | | |
| | [area_set_elements.txt](#area_set_elementstxt) | Optional | Rules to assign areas to area sets. | |
| - [fare\_transfer\_rules.txt](#fare_transfer_rulestxt) | ||
| - [areas.txt](#areastxt) | ||
| - [stop_areas.txt](#stop_areastxt) | ||
| - [area_sets.txt](#area_setstxt) |
There was a problem hiding this comment.
| - [area_sets.txt](#area_setstxt) | |
| - [area_sets.txt](#area_setstxt) | |
| - [area_set_elements.txt](#area_set_elementstxt) |
| | `network_id` | Foreign ID referencing `routes.network_id` or `networks.network_id`| Optional | Identifies a route network that applies for the fare leg rule.<br><br>If the `rule_priority` field does not exist AND there are no matching `fare_leg_rules.network_id` values to the `network_id` being filtered, empty `fare_leg_rules.network_id` will be matched by default.<br><br> An empty entry in `fare_leg_rules.network_id` corresponds to all networks defined in [routes.txt](#routestxt) or [networks.txt](#networkstxt) excluding the ones listed under `fare_leg_rules.network_id`<br><br> If the `rule_priority` field exists in the file, an empty `fare_leg_rules.network_id` indicates that the route network of the leg does not affect the matching of this rule. | | ||
| | `from_area_id` | Foreign ID referencing `areas.area_id` | Optional | Identifies a departure area.<br><br>If the `rule_priority` field does not exist AND there are no matching `fare_leg_rules.from_area_id` values to the `area_id` being filtered, empty `fare_leg_rules.from_area_id` will be matched by default. <br><br>An empty entry in `fare_leg_rules.from_area_id` corresponds to all areas defined in `areas.area_id` excluding the ones listed under `fare_leg_rules.from_area_id`<br><br> If the `rule_priority` field exists in the file, an empty `fare_leg_rules.from_area_id` indicates that the departure area of the leg does not affect the matching of this rule. | | ||
| | `to_area_id` | Foreign ID referencing `areas.area_id` | Optional | Identifies an arrival area.<br><br>If the `rule_priority` field does not exist AND there are no matching `fare_leg_rules.to_area_id` values to the `area_id` being filtered, empty `fare_leg_rules.to_area_id` will be matched by default.<br><br> An empty entry in `fare_leg_rules.to_area_id` corresponds to all areas defined in `areas.area_id` excluding the ones listed under `fare_leg_rules.to_area_id`<br><br>If the `rule_priority` field exists in the file, an empty `fare_leg_rules.to_area_id` indicates that the arrival area of the leg does not affect the matching of this rule. | | ||
| | `contains_area_set_id` | Foreign ID referencing `area_sets.area_set_id` | Optional | Identifies an area set containing a collection of areas.<br><br> For this rule to match, a leg must travel through each and every area of the area set. The leg may travel through additional areas not contained by the area set or through stops that are not assigned to an area at all. If not specified, this predicate does not affect the matching of this rule. | |
There was a problem hiding this comment.
@tzujenchanmbd should there also be rules of how contains_exactly_area_set_id and contains_area_set_id interact with from_area_id and to_area_id?
We resolved this in the Network Sets PR by forbidding the network_id predicate when the set predicates exist. We can do the same here.
Also, if contains_area_set_id and contains_exactly_area_set_id both exist, contains_area_set_id would have to be included in contains_exactly_area_set_id, causing a redundancy. If not, the leg rule will never be matched. Should we do the same thing we did for network sets and make them mutually exclusive as well?
There was a problem hiding this comment.
should there also be rules of how contains_exactly_area_set_id and contains_area_set_id interact with from_area_id and to_area_id?
@skalexch I think the from_area_id / to_area_id case is different from network_id?
The network_id predicate matches a single network, which is logically at odds with a network_set that represents multiple networks within the same leg rule. In contrast, from_area_id and to_area_id describe the origin and destination areas of a leg. Producers may want to define different fares for different origin–destination pairs within the same area_set (e.g., A→D vs. A→C within area set ABCD), especially when fare_leg_join_rule is used. Allowing them to be used together should provide more flexibility?
Also, if contains_area_set_id and contains_exactly_area_set_id both exist,
Agree that the interaction between contains_area_set_id and contains_exactly_area_set_id is similar to the network set case and that they should be mutually exclusive. I’ll update the suggestions accordingly.
There was a problem hiding this comment.
@tzujenchanmbd 100% agree. Let's keep the intersection with from_area_id / to_area_id but enforce mutual exclusivity between contains_area_set_id and contains_exactly_area_set_id.
There was a problem hiding this comment.
Should these be added as a primary key to this file?
Add support for matching "sets" of areas in
fare_leg_rules.txtper this proposal.