-
Notifications
You must be signed in to change notification settings - Fork 28
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
[tech] Easier hello world #739
Comments
I think that would be a very nice API ❤️. Note that this is only about the GTFS API, maybe something similar for NTFS and the rest of the public API. |
It's a nice API, yes. At first sight, I would put it in 'polish' category, so my question for working on it is: what is the expected gain on that? |
yes I agree the gain would be quite minimal, it can maybe bring some reusers and lower the step to use For |
After discussion with @woshilapin:
|
no parsing from reader? |
The first one named |
what is |
it's uggly but it's an artifact since the |
closes #739 hide the `Configuration` needed to read GTFS to have easier hello world and an api closer to the ntfs module. Also add a `gtfs::read` method that detect if the GTFS is a zip or not (like `ntfs::read`). now the canonimal way to read a gtfs is: ```rust let model = transit_model::gtfs::read("path to a zip or directory")?; ``` For better control there is also: ```rust let model = transit_model::gtfs::read_from_path("path to a directory")?; ``` ```rust let model = transit_model::gtfs::read_from_zip("path to a zip")?; ``` or even a `gtfs::from_read` method that takes a reader (cf doc). When a configuration is need a `Reader` struct is needed ```rust let conf = gtfs::Configuration { read_as_line: true, ..Default::default() }; let model = transit_model::gtfs::Reader::new(conf).from(input_dir)?; ```
The current API to load a model (from a GTFS or NTFS) is honestly quite straightforward and easy. I think we can still improve it a bit and I think a very neat library example can ease adoption.
For the moment to load a
Model
from a GTFS (and I think it can be applied to the other format) you need to do:I think here the
gtfs::Configuration::default()
could be hidden.Moreover in most uses of
gtfs
(like all transit_model's executables) the model is initialized like:since it's a common use, it could be done for the users.
To ease the canonical way to create a model I think we can:
Pseudo code for this
First the usage:
The easiest
or directly
and with a custom config
And the gtfs module
What do you think about this? Do you think it is worth it? Any better ideas on the naming?
The text was updated successfully, but these errors were encountered: