Vehicle Positions occupancy_status data type

已查看 93 次
跳至第一个未读帖子

Tim Hibbard

未读,
2024年3月27日 12:01:203月27日
收件人 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

未读,
2024年3月27日 13:56:293月27日
收件人 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.

回复全部
回复作者
转发
0 个新帖子