Reputation: 955
I have experience using the static GTFS files which define the operating model for a specific public transport network. However my city has just release a real time feed for the bus locations and other status updates for the network.
My question is, how should I view this feed in real time and record the feed into a database. The link to the real time feed is as follows: https://gtfsrt.api.translink.com.au/
Upvotes: 3
Views: 1141
Reputation: 664
Install Nugget Package Google.Protobuf
PM> Install-Package Google.Protobuf -Version 3.4.1
private FeedMessage _feedMessage;
using (MemoryStream protobufMemoryStream = new MemoryStream())
using (Stream protobufStream = await _httpClient.GetStreamAsync("", "http://gtfs.ovapi.nl/new/vehiclePositions.pb"))
{
protobufStream.CopyTo(protobufMemoryStream);
protobufMemoryStream.Position = 0;
_feedMessage = Serializer.Deserialize<FeedMessage>(protobufMemoryStream);
}
In _feedMessage you have deserialize GTFS RealTime Model to persist data into database.
Upvotes: 0
Reputation: 7887
The GTFS-realtime spec now includes code samples for parsing GTFS-realtime data in a variety of languages:
https://developers.google.com/transit/gtfs-realtime/code-samples
It's a good place to start when it comes to parsing GTFS-realtime data in your favorite language.
Upvotes: 1
Reputation: 955
I needed to install google's protocol buffer, then compile the gifts-realtime.proto with the protocol buffer to generate code which can then read the API source.
Upvotes: 0