Giter VIP home page Giter VIP logo

Comments (3)

mpadge avatar mpadge commented on July 30, 2024

This is how the current code works, stepping inside each function:

devtools::load_all (".", export_all = TRUE)
#> Loading gtfsrouter
gtfs <- extract_gtfs ("vbb.zip")
#> ▶ Unzipping GTFS archive
#> ✔ Unzipped GTFS archive
#> ▶ Extracting GTFS feed✔ Extracted GTFS feed 
#> ▶ Converting stop times to seconds✔ Converted stop times to seconds 
#> ▶ Converting transfer times to seconds✔ Converted transfer times to seconds
gtfs <- gtfs_timetable (gtfs)
#> Day not specified; extracting timetable for Monday
stn <- "Berlin, Rohrdammbrücke"
start_time <- 3600
end_time <- start_time + 600

#x <- gtfs_isochrone (gtfs, from = stn, start_time = start_time, end_time = end_time)
# code from gtfs_isochrone function:
from <- stn
from_is_id <- FALSE

gtfs_cp <- data.table::copy (gtfs)
start_time <- convert_time (start_time)
end_time <- convert_time (end_time)
gtfs_cp$timetable <- gtfs_cp$timetable [departure_time >= start_time, ]
start_stns <- station_name_to_ids (from, gtfs_cp, from_is_id)
start_stns
#> [1]   492 27286 28339

#isotrips <- get_isotrips (gtfs_cp, start_stns, start_time, end_time)
# code from get_isotrips function:
stns <- rcpp_csa_isochrone (gtfs$timetable, gtfs$transfers,
                            nrow (gtfs$stop_ids), nrow (gtfs$trip_ids),
                            start_stns, start_time, end_time)
stns
#> [[1]]
#> [1] 27286 27287 28819 27345 27346 27347 33326 33328 33330
#> 
#> [[2]]
#> [1] 25933 25933 25933 25933 25933 25933 50413 50413 50413
#> 
#> [[3]]
#> [1] 27286 27287 28819 27345 27346 27347 27348 27293 27294
#> 
#> [[4]]
#> [1] 25933 25933 25933 25933 25933 25933 25933 46653 46653
#> 
#> [[5]]
#> [1] 27286 27287 28819 27345 28559 29453 30470 28844 29376
#> 
#> [[6]]
#> [1] 25933 25933 25933 25933 45673 45673 45673 45673 45673
#> 
#> [[7]]
#> [1] 27286 27287 28819 27345 27346 27347 27348 27293 27319
#> 
#> [[8]]
#> [1] 25933 25933 25933 25933 25933 25933 25933 46653 25933
#> 
#> [[9]]
#> [1] 20820

Created on 2020-06-22 by the reprex package (v0.3.0)

So most of the work happens in the C++ function rcpp_csa_isochrone, which returns paired lists of vectors denoting (stations along each route, corresponding trip numbers). (There is an additional item, here [[9]], which records the start time in seconds.) This C++ code would thus need to be modified to add the arrival time at each of those sequences of stations. The stations are ultimately stored here:
https://github.com/ATFutures/gtfs-router/blob/c7ba288609aaa28a4c826c2272544f73ee0bb6ff/src/csa-isochrone.cpp#L160-L161

With those values of prev_stn constructed here:
https://github.com/ATFutures/gtfs-router/blob/c7ba288609aaa28a4c826c2272544f73ee0bb6ff/src/csa-isochrone.cpp#L122-L123
... alongside equivalent values for prev_time. So all that we'd need to do would be to add an additional output vector for prev_time alongisde prev_stn, and then append that to the result as you suggest. Not sure how your C++ skills are @AlexandraKapp? Let me know if you feel up for the challenge, otherwise i'm happy to address it.

from gtfsrouter.

AlexandraKapp avatar AlexandraKapp commented on July 30, 2024

Thanks for looking into it! I'm afraid I cannot really offer C++ skills - so that would probably take me a bit to get into that.

from gtfsrouter.

mpadge avatar mpadge commented on July 30, 2024

No worries - I'll be happy to get on to it, after #14 is done.

from gtfsrouter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.