如何查看和收集实时GTFS数据源

3

我有使用静态GTFS文件的经验,这些文件定义了特定公共交通网络的操作模式。然而,我的城市刚刚发布了总线位置和其他网络状态更新的实时数据源。

我的问题是,在实时情况下,我应该如何查看这个数据源并将其记录到数据库中。实时数据源的链接如下:https://gtfsrt.api.translink.com.au/

3个回答

1

0

安装NuGet包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);
}

_feedMessage中,您已将GTFS实时模型反序列化以将数据持久化到数据库中。

0

我需要安装Google的协议缓冲区,然后使用协议缓冲区编译gifts-realtime.proto文件,生成可以读取API源代码的代码。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接