From 01a185b5c6d8c6976ab30ec468109ef8724da301 Mon Sep 17 00:00:00 2001 From: "Begerad, Stefan" Date: Thu, 8 Sep 2022 10:26:12 +0200 Subject: [PATCH] (pbf): extend index.js --- pbf/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pbf/index.js b/pbf/index.js index 18fc3ff..e4560b3 100644 --- a/pbf/index.js +++ b/pbf/index.js @@ -12,7 +12,7 @@ async function run() { debug('run started...'); const FeedMessage = gtfsRt.FeedMessage; debug('read gtfs-rt feed from file'); - const buffer=fs.readFileSync('/tmp/vbn/gtfsr_connect.bin'); + const buffer=fs.readFileSync('./vehicle-positions'); if(buffer instanceof Buffer){ debug('buffer is instance of Buffer'); debug('read buffer and create pbf'); @@ -27,13 +27,20 @@ async function run() { } let feedCount=0; feed.entity.forEach(entity => { + debug('feed has entity at index: '+feedCount); feedCount++; const vehiclePos = entity.vehicle; if (vehiclePos) { + debug('entity has vehicle position'); const { trip, position, vehicle } = vehiclePos; if (trip && position && vehicle) { + debug('vehiclePos has either trip, position or vehicle'); + const latitude = position.latitude; + if(latitude){ + debug('position has latitude: '+latitude); + } }else{ - debug('vehiclePos misses either trip, position or vehicle'); + debug('vehiclePos misses either trip, latitude or vehicle'); } }else{ debug('entity misses vehicle');