Hi,
I am new with the GTFS-realtime world as my local transit system (STM - Société de transport de Montréal) just opened their feed yesterday!
I have some problem with my program and I'm not sure if the problem is from my code or the feed.
And here is my code :
var GtfsRealtimeBindings = require('gtfs-realtime-bindings');
var request = require('request');
var requestSettings = {
method: 'POST',
encoding: null,
headers: {
'apikey': 'MYAPIKEY'
}
};
request(requestSettings, function (error, response, body) {
if (!error) {
var feed = GtfsRealtimeBindings.FeedMessage.decode(body);
console.log(feed);
feed.entity.forEach(function(entity) {
if (entity.trip_update) {
console.log(entity.trip_update);
}
});
}
});
When I run the code I get the following error :
/mnt/b/Users/Félix/Documents/Atelier web/stm-gtfs-realtime/node_modules/protobufjs/ProtoBuf.js:1987
throw(e);
^
Error: Missing at least one required field for Message .transit_realtime.FeedMessage: header
at ...
I also run the GTFS-realtime validator and got the following error :
- E003 GTFS-rt trip_id does not exist in GTFS data and does not have schedule_relationship of ADDED
- E004 GTFS-rt route_id does not exist in GTFS data
- E039 FULL_DATASET feeds should not include entity.is_deleted
- W009 schedule_relationship not populated
The goal of my project is to convert the feed into JSON to use it in a web application. If you know a quick and easy way to do this, please let me know!
Thanks :-)