Giter Site home page Giter Site logo

to do list about gtfstools HOT 6 CLOSED

ipeagit avatar ipeagit commented on June 7, 2024
to do list

from gtfstools.

Comments (6)

mpadge avatar mpadge commented on June 7, 2024 1

@dhersz i'm restructing gtfsrouter to use lots of your great stuff. There is one function which used to live within my extract_gtfs() function which has now been replaced by gtfsio::import_gtfs(), and which is still needed, but would maybe be better living here. It is pure C++, and does one of the items listed above:

  • implement set_times_to_seconds().

It works just like these two lines - a single line call that is way faster than any R functions to do this. Let me know and i'll happily PR here.

from gtfstools.

dhersz avatar dhersz commented on June 7, 2024 1

Hi @mpadge. This is so good, many thanks!

Just some backstory behind set_times_to_seconds(): I currently use a string_to_seconds() functions I wrote based on tidytransit::hms_to_seconds() (or something along these lines) to convert the time inside functions that require such conversion, such as get_trip_duration(). Your function is certainly much faster than the one I use right now, so I'll gladly start using it instead.

Now, I wanted to have set_times_to_seconds() to save some time when repeatedly calculating the duration of trips, or something like this, because right now get_trip_duration() will always create two new columns arrival_time_secs and departure_time_secs via string_to_seconds() when making such calculations. Therefore, the purpose of set_times_to_seconds() would be to create such columns beforehand, so the user would only need to make this conversion once, instead of every single time they wanted to calculate durations or speeds (hence requiring a check inside get_trip_duration() to see if these columns already exist).

Because your function is so much faster than string_to_seconds(), which was written purely in R, perhaps set_times_to_seconds() as I first thought of it is not as important right now. So to answer your question, I'd keep rcpp_time_to_seconds() as a internal function right now and add a wrapper (set_times_to_seconds()) later.

from gtfstools.

dhersz avatar dhersz commented on June 7, 2024

note to self: write tests as you write functions

from gtfstools.

rafapereirabr avatar rafapereirabr commented on June 7, 2024

I think this would be a great contribution, @mpadge .

from gtfstools.

mpadge avatar mpadge commented on June 7, 2024

Great! It's currently just an internal function that calls directly to the C++ code, so we'll just need to work out whether you might actually want it as some kind of exported and R-wrapped function? I can get a PR together in the meantime regardless, initially with just the internal C++ code, and we can work out where the two lines of R code go:

stop_times [, arrival_time := rcpp_time_to_seconds (arrival_time)]
stop_times [, departure_time := rcpp_time_to_seconds (departure_time)]

from gtfstools.

dhersz avatar dhersz commented on June 7, 2024

Closing this in favor of individual issues.

from gtfstools.

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.