I am trying to use https://github.com/dcodeIO/ProtoBuf.js to parse triments gtfs data.
Here is the code I have so far, it parses the .proto file correctly and creates the builder and has all the expected properties and methods, it throws an error when I try to decode any data with it.
Error: Data must be corrupt: Buffer overrun
the proto file is from https://developers.google.com/transit/gtfs-realtime/gtfs-realtime-proto
var ProtoBuf = require('protobufjs')
, request = require('request')
var transit = ProtoBuf.protoFromFile('gtfs-realtime.proto').build('transit_realtime')
request('http://developer.trimet.org/ws/V1/FeedSpecAlerts/?appID=618F30BB3062F39AF24AED9EC', parse)
function parse(err, res, body) {
try {
console.log(transit.FeedMessage.decode(res.body))
} catch(e) {
console.log(e)
}
}
Thanks to Brian Ferris I able to parse the first part of the header gtfs_realtime_version: "1" but the parser fails on the next component (the time stamp uint64)
Thanks to
This does not answer your issue but you can get RT feed in text using url like http://developer.trimet.org/ws/V1/FeedSpecAlerts/appid/618F30BB3062F39AF24AED9EC/text/true
Also have a look at node-gtfs module.