Skip to content

fix: Define defaults for VehiclePosition occupancy percentage and status#248

Closed
barbeau wants to merge 1 commit intogoogle:masterfrom
MobilityData:fix-occupancy-defaults
Closed

fix: Define defaults for VehiclePosition occupancy percentage and status#248
barbeau wants to merge 1 commit intogoogle:masterfrom
MobilityData:fix-occupancy-defaults

Conversation

@barbeau
Copy link
Contributor

@barbeau barbeau commented Sep 24, 2020

As discussed in #247, default values aren't currently defined for VehiclePosition.occupancy_percentage and VehiclePosition.occupancy_status.

This pull request adds defaults for VehiclePosition.occupancy_percentage and VehiclePosition.occupancy_status so erroneous defaults aren't read by GTFS-realtime consumers.

TODO:

Fixes #247

@barbeau barbeau added the GTFS Realtime Issues and Pull Requests that focus on GTFS Realtime label Sep 24, 2020
@google-cla google-cla bot added the cla: yes label Sep 24, 2020
@skinkie
Copy link
Contributor

skinkie commented Sep 24, 2020

Could you elaborate why this optional value needs an initialisation? If I would parse this feed without the value present, it would be just "not available".

@barbeau
Copy link
Contributor Author

barbeau commented Sep 24, 2020

@skinkie Could you read #247 and let me know if you still have questions? I explained it there.

@skinkie
Copy link
Contributor

skinkie commented Sep 24, 2020

@skinkie Could you read #247 and let me know if you still have questions? I explained it there.

I have only active experience with C, Java and Python parsing, both obviously all support NULL, null and None, but that is not my point here. When I want to check for a stopTimeUpdate, I first have to ensure stopTimeUpdate.hasDeparture() for which languages are optional values in GTFS-RT not supporting this hasAttribute method?

@barbeau
Copy link
Contributor Author

barbeau commented Sep 24, 2020

I first have to ensure stopTimeUpdate.hasDeparture(). for which languages are optional values in GTFS-RT not supporting this hasAttribute method?

Yes, that's the issue here. We can't guarantee that all protobuf consuming software include methods like hasX(), in which case you'd just need to read the value directly. And if you read the value directly for an optional value that doesn't have an explicit default set in the .proto, you get the "default default" defined in the protobuf docs.

Here's one example for C# - MobilityData/gtfs-realtime-bindings#52.

You can see this actually applies to other optional GTFS-realtime fields as well that we could fix, including bearing, speed, and vehicle stop status.

@barbeau
Copy link
Contributor Author

barbeau commented Sep 24, 2020

I should also mention that this change will help developers new to protobufs that don't know they need to call hasX() before reading the value.

@skinkie
Copy link
Contributor

skinkie commented Sep 24, 2020

I first have to ensure stopTimeUpdate.hasDeparture(). for which languages are optional values in GTFS-RT not supporting this hasAttribute method?

Yes, that's the issue here. We can't guarantee that all protobuf consuming software include methods like hasX(), in which case you'd just need to read the value directly. And if you read the value directly for an optional value that doesn't have an explicit default set in the .proto, you get the "default default" defined in the protobuf docs.

How is that binding handling a missing Departure or Arrival then technically (kind of the basics when using GTFS-RT)? I honestly think this should not be solved by default values, rather the binding generator for C# should be fixed.

@darylweinberg
Copy link

darylweinberg commented Sep 24, 2020 via email

@jxeeno
Copy link
Contributor

jxeeno commented Sep 25, 2020

Yeah, I think I'm on the same page as @skinkie on this one. Even though it's not explicitly supported by proto2, it's implicitly a requirement for the bindings to support expressing optional values as null-like or have a hasX() in order for delay/time in GTFS-R to be interpreted in any meaningful way.

@barbeau
Copy link
Contributor Author

barbeau commented Sep 28, 2020

@skinkie @jxeeno Thanks for the feedback. Could you elaborate on the downside to defining defaults in the gtfs-realtime.proto file? What do you see as the main drawbacks?

jakehoare added a commit to jakehoare/transit that referenced this pull request Feb 6, 2021
The idea behind this proposal is that for the user, the occupancy of a vehicle several stops away (at its VehiclePosition) may be difficult to act upon, because occupancy will change by the time the vehicle arrives at the stop where the user intends to board.

This new field allows agencies to provide expected occupancy for future stops.
It is left open for agencies to decide how to calculate these occupancies, they may use any model provided it uses realtime data.

There is no prohibition on providing data for past stops or for the last stop, although such data is not useful for the use case described.

The natural place in GTFS for these occupancies is in TripUpdate.StopTimeUpdate - they are analogous to StopTimeEvents. One drawback is that the name StopTimeUpdate is potentially then slightly misleading because its data is not just about timing.

If google#248 is adopted, that default would apply here as well.
@gcamp
Copy link
Contributor

gcamp commented May 19, 2021

I agree that generally there are workaround in the implementation to achieve the same behaviour. However since there's nothing in the spec that mention what is the actual default, we have a vendor that insist that they can not include the occupancy_status value if the occupancy is EMPTY (the first value of the enum which is the default if no default is specifically defined).

Adding a default value would clear that ambiguity.

@stale
Copy link

stale bot commented Aug 21, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issues and Pull Requests that have remained inactive for 30 calendar days or more. label Aug 21, 2021
@stale
Copy link

stale bot commented Aug 28, 2021

This pull request has been closed due to inactivity. Pull requests can always be reopened after they have been closed. See the Specification Amendment Process.

@stale stale bot closed this Aug 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GTFS Realtime Issues and Pull Requests that focus on GTFS Realtime Status: Stale Issues and Pull Requests that have remained inactive for 30 calendar days or more.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VehiclePosition OccupancyStatus and occupancy_percentage return incorrect default values

5 participants