planarnetwork / transxchange2gtfs

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

BankHolidayOperation / DaysOfOperation only takes first value #41

Closed chadselph closed 3 years ago

chadselph commented 3 years ago

Consider the following input:

      <OperatingProfile>
        <RegularDayType>
          <DaysOfWeek>
            <Sunday />
          </DaysOfWeek>
        </RegularDayType>
        <BankHolidayOperation>
          <DaysOfOperation>
            <GoodFriday />
            <LateSummerBankHolidayNotScotland />
            <MayDay />
            <EasterMonday />
            <SpringBank />
            <OtherPublicHoliday>
              <Description>Platinum Jubilee bank holiday</Description>
              <Date>2022-06-03</Date>
            </OtherPublicHoliday>
          </DaysOfOperation>
          <DaysOfNonOperation>
            <Christmas />
            <NewYearsDay />
            <ChristmasDayHoliday />
            <BoxingDayHoliday />
            <NewYearsDayHoliday />
          </DaysOfNonOperation>
        </BankHolidayOperation>
      </OperatingProfile>

produces this OperatingProfile object:

{
  BankHolidayOperation: {
    DaysOfOperation: [ 'GoodFriday' ],
    DaysOfNonOperation: [ 'Christmas' ]
  },
  SpecialDaysOperation: { DaysOfOperation: [], DaysOfNonOperation: [] },
  RegularDayType: [ [
      0, 0, 0, 0,
      0, 0, 1
    ] ]
}

The bug is on this line which only maps over the first element. https://github.com/planarnetwork/transxchange2gtfs/blob/master/src/transxchange/TransXChangeStream.ts#L184

linusnorton commented 3 years ago

thanks @chadselph I'll take a look in the next few days

linusnorton commented 3 years ago

@chadselph this should be fixed in 1.8.5, please give it a go.