GTFS Realtime - missing Vehicle field containing Position

132 views
Skip to first unread message

5ra

unread,
Jul 1, 2022, 9:51:40 AM7/1/22
to GTFS-realtime
Hello,

I'm new to working with GTFS feeds so this is a newbie question and I would appreciate help.

When I parse GTFS Realtime feed from my agency, entities do not contain vehicle field. I'm interested in acquiring vehicles positions (coordinates), thus without this field I cannot do much. I am not sure if this is the case because the agency did not provide vehicle positions or because I am doing something wrong. My entity looks like this:

id: "X7C7BER01T"
is_deleted: false
trip_update {
  trip {
    trip_id: "0_26_21202_212_10264"
    start_date: "20220701"
    schedule_relationship: SCHEDULED
    route_id: "212"
  }
  stop_time_update {
    stop_sequence: 6
    arrival {
      time: 1656673397
    }
    stop_id: "205_31"
    schedule_relationship: SCHEDULED
  }
}

Is it possible that this field is not provided because this is GTFS Realtime v1.0 which has many fields listed as optional?

Bodo Minea

unread,
Jul 1, 2022, 9:53:56 AM7/1/22
to gtfs-r...@googlegroups.com
Doesn't your agency provide multiple URLs? It looks to me like you are only taking in the tripUpdates endpoint and decoding it. Usually serviceAlerts and vehiclePositions are exposed through their own separate URLs.
We cannot help you any further if you do not show your URLs and/or code and other details.

--
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/7a093df4-65db-470f-9474-7af844f96858n%40googlegroups.com.


--

5ra

unread,
Jul 1, 2022, 10:12:17 AM7/1/22
to GTFS-realtime
This is their website and for GTFS Realtime feed only one URL is provided: 
https://www.zet.hr/odredbe/datoteke-u-gtfs-formatu/669?fbclid=IwAR1HS2va6g8f1Nc3VBWuSSn89lzJVHImQNYr3BPs6tysaGZoeZwJX4_fVKI

My code looks like this:

from google.transit import gtfs_realtime_pb2
import requests

feed = gtfs_realtime_pb2.FeedMessage()
response = requests.get('https://zet.hr/gtfs-rt-protobuf')
feed.ParseFromString(response.content)

for entity in feed.entity:
     print(entity)

Bodo Minea

unread,
Jul 1, 2022, 10:37:59 AM7/1/22
to gtfs-r...@googlegroups.com
I put together a quick script that counts how many entities of each kind are in the field.

You only get trip updates from your operator, there are no vehicle positions or service alerts in the feed you provided. Trip updates tell you if the trip is running late or not or give you the updated departure time from the next stop based on the current position. So in this particular case they use the GPS positions to estimate these details but do not actually expose the details to you. 

FeedHeader {
  gtfsRealtimeVersion: '1.0',
  incrementality: 0,
  timestamp: Long { low: 1656685866, high: 0, unsigned: true }
}
Entities: 433
of which Trip Updates: 433, Service Alerts: 0, Vehicle Positions: 0

You'll have to either find another API source for the GPS positions, reverse engineer one of their apps if there's any that show the positions or estimate the position based on schedule adherence and the shapes defined in the static GTFS for the trips.

5ra

unread,
Jul 1, 2022, 11:47:46 AM7/1/22
to GTFS-realtime
Thank you very much for the answer.
I'll contact the agency to see if they plan to provide GPS positions in the future since this feed is just a test version.

Best regards,
Petra

Reply all
Reply to author
Forward
0 new messages