Getting vehicle descriptor

Hi guys,

I’m pretty new to TfNSW data. I could download and decode the Bus Position Feed Message using python gtfs_realtime_pb2 library.
However, the decoded feed doesn’t contain TfNSW vehicle descriptor e.g. air_conditioned, vehicle_model. This should be included according to Realtime Bus Technical Documentation.

Does anyone know why?

Hi Tara

Those fields are fairly new and aren’t part of the GTFS specification –

or GTFS-realtime specification

So the python library doesn’t cover it.

Try the protobuf file supplied although I’d have to check if it’s been updated to cover the vehicle_model (which is new to the TfNSW feed)

There’s more info about the vehicle model here:

We’ll post some more info (as I just realised that info is not enough!)

Yvonne

1 Like

Hey @tara, the .proto file you’re after is located here: https://opendata.transport.nsw.gov.au/sites/default/files/tfnsw-gtfs-realtime.proto_.txt

The section of interest is:

message TfnswVehicleDescriptor {

    // The TfnswVehicleDescriptor extends the GTFS vehicle message to provide additional vehicle attribute information to the consuming application

    optional bool air_conditioned = 1 [default = false];
    // Indicates the availability of air-conditioning on this vehicle

    optional int32 wheelchair_accessible = 2 [default = 0];
    // Indicates the number of wheel chairs that can be accommodated on this vehicle

    optional string vehicle_model = 3;
    // A the type of vehicle performing this trip

    optional bool performing_prior_trip = 4 [default = false];
    // An indicator used to display the location of vehicles that will execute this upon completion of their current trip

    optional int32 special_vehicle_attributes = 5 [default = 0];
    // Used to pass ad-hoc temporary additional vehicle attribute information, for example Christmas buses
}

extend transit_realtime.VehicleDescriptor {

    optional TfnswVehicleDescriptor tfnsw_vehicle_descriptor = 1999;
    // Assumes the TfNSW extension number will be 1999
}

As @yvonne.lee said, the TfnswVehicleDescriptor entity is an extension of the GTFS-realtime standard. You’ll need to compile your own protocol buffer bindings for Python if you want to read it. Google has some docs on this which may help.

2 Likes

Thanks @jxeeno, @yvonne.lee. I successfully compiled the protocol buffer from the .proto file you’ve given. And it can be used to grab the vehicle descriptor feed message :slight_smile:

I have removed a few lines from the .proto file for this to work though. Here are what I have removed in case someone is having the same issue and in case someone can give a clarification on this:

  • Remove this because they are duplicated which will give error ‘Multiple package definitions.’

      option java_package = "com.google.transit.realtime";
      package transit_realtime;
    
  • I’m not sure where to find au_nsw_sydney.proto and python class couldn’t be compiled because the file cant be found. So I remove this line and it works:

      import "au_nsw_sydney.proto";
    

Thanks,

2 Likes