Vehicle Positions occupancy_status data type

99 views
Skip to first unread message

Tim Hibbard

unread,
Mar 27, 2024, 12:01:20 PMMar 27
to GTFS-realtime

I am wanting to clear up some confusion about how occupancy_status should be displayed in Vehicle Positions feed. The examples I see appear to be strings, but when we use a string like “STANDING_ROOM_ONLY”, our protobuf unit tests fail.

 

Which of the following examples is correct? int, string, or string without quotes?

 

INT

 

"id": "6",

          "vehicle": {

            "vehicle": {

              "id": "14312",

              "label": "95828"

            },

            "position": {

              "latitude": 33.958403,

              "longitude": -83.3722331,

              "bearing": 257

            },

            "occupancy_status": 3,

            "current_stop_sequence": 2,

            "stop_id": "155085",

            "timestamp": 1711458700,

            "trip": {

              "trip_id": "611383"

            }

          }

 

 

STRING

 

"id": "6",

          "vehicle": {

            "vehicle": {

              "id": "14312",

              "label": "95828"

            },

            "position": {

              "latitude": 33.958403,

              "longitude": -83.3722331,

              "bearing": 257

            },

            "occupancy_status": "STANDING_ROOM_ONLY",

            "current_stop_sequence": 2,

            "stop_id": "155085",

            "timestamp": 1711458700,

            "trip": {

              "trip_id": "611383"

            }

          }

 

STRING WITHOUT QUOTES

 

"id": "6",

          "vehicle": {

            "vehicle": {

              "id": "14312",

              "label": "95828"

            },

            "position": {

              "latitude": 33.958403,

              "longitude": -83.3722331,

              "bearing": 257

            },

            "occupancy_status": STANDING_ROOM_ONLY,

            "current_stop_sequence": 2,

            "stop_id": "155085",

            "timestamp": 1711458700,

            "trip": {

              "trip_id": "611383"

            }

          }

Kurt Raschke

unread,
Mar 27, 2024, 1:56:29 PMMar 27
to gtfs-r...@googlegroups.com
Tim,

What library are you using to produce Protocol Buffers output?  Protobuf implementations should be typesafe (to the extent possible in the target language) and so OccupancyStatus should be mapped to an enumerated type, in languages which have enums or a similar concept. (This is, in fact, one of the great advantages of protobufs over other formats; with a properly-functioning implementation it should be impossible to generate a schema-invalid message!)


Generally speaking, setting the occupancy_status field in a VehiclePosition message to the appropriate value from the OccupancyStatus enum should result in correct output.  (It’s also worth noting that the binary format is the canonical form of a Protocol Buffers message, and the stringified output exists only for debugging.)

-Kurt

--
You received this message because you are subscribed to the Google Groups "GTFS-realtime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gtfs-realtim...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gtfs-realtime/d6d6757c-6b3e-4151-aa08-e0abf620d784n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages