planarnetwork / transxchange2gtfs

tool to convert transxchange data into a GTFS feed
30 stars 17 forks source link

Errors for files with no origin for standard service #32

Closed GideonTargomo closed 3 years ago

GideonTargomo commented 3 years ago

Hi. I'm working with the TNDSV2.5 transit data and I'm running into a problem since it seems several files have no origin for the StandardService which results in an undefined error.

/home/gideon/.nvm/versions/node/v10.22.0/lib/node_modules/transxchange2gtfs/dist/src/transxchange/TransXChangeStream.js:101
            ServiceOrigin: service.StandardService[0].Origin[0],
                                                            ^

TypeError: Cannot read property '0' of undefined
    at TransXChangeStream.getServices (/home/gideon/.nvm/versions/node/v10.22.0/lib/node_modules/transxchange2gtfs/dist/src/transxchange/TransXChangeStream.js:101:61)
    at Array.reduce (<anonymous>)
    at TransXChangeStream._transform (/home/gideon/.nvm/versions/node/v10.22.0/lib/node_modules/transxchange2gtfs/dist/src/transxchange/TransXChangeStream.js:27:49)
    at TransXChangeStream.Transform._read (_stream_transform.js:190:10)
    at TransXChangeStream.Readable.read (_stream_readable.js:471:10)
    at flow (_stream_readable.js:974:34)
    at TransXChangeJourneyStream.pipeOnDrainFunctionResult (_stream_readable.js:778:7)
    at TransXChangeJourneyStream.emit (events.js:198:13)
    at onwriteDrain (_stream_writable.js:495:12)
    at afterWrite (_stream_writable.js:483:5)

I have attached 4 files which I have confirmed have the error and can reproduce locally (both on version 1.6.1 and 1.7.0).

FailingTransxchangeFiles.zip

I Don't know how important the origin is in these files and if it could be replaced with an empty/null value or derived from somewhere else? Maybe there could be an input parameter that allows skipping failed files but still create the output zip?

linusnorton commented 3 years ago

It's used to generate the short name of the trip. I've added some code to fall back to the route name if there is no service origin or destination

linusnorton commented 3 years ago

Release 1.7.1 should fix this issue

GideonTargomo commented 3 years ago

Thanks