Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme example doesn't work, argument mismatch? #19

Open
Bela0 opened this issue Apr 22, 2024 · 1 comment
Open

Readme example doesn't work, argument mismatch? #19

Bela0 opened this issue Apr 22, 2024 · 1 comment

Comments

@Bela0
Copy link

Bela0 commented Apr 22, 2024

Hello,

unfortunately I can't get the readme sample to work. Line 5 throws an error:

const raptor = RaptorAlgorithmFactory.create(trips, transfers, interchange, calendars);

Dates given in calendars cannot be parsed. Logging the arguments, calendars contains all the stops, not dates and times.

Checking the code, to my understanding loadGTFS() returns [trips, transfers, interchange, stops] while RaptorAlgorithmFactory.create() expects [trips, transfers, interchange, date].

Could you check if this is an error or if I'm misunderstanding anything?

Thank you for your work @linusnorton and @iamralpht !

Best regards!

(I tried multiple GTFS sources, e.g. the Google example feed)

@linusnorton
Copy link
Contributor

linusnorton commented Apr 22, 2024

Hi, yes, it appears the README.md is wrong. The method definition is:

public static create(
    trips: Trip[],
    transfers: TransfersByOrigin,
    interchange: Interchange,
    date?: Date
  )

Giving a date will filter any trips to ensure they are running on that date as a way of speeding up the actual journey plan.

The journey plan method definition is:

public scan(origins: StopTimes, date: number, dow: DayOfWeek)

The date there is a number (e.g. 20240422). In retrospect it is confusing to have one method accept a Date and the other use a number. It was a very, very minor performance improvement to the scan method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants