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

read/write locations.geojson and rework spec implementation #37

Merged
merged 12 commits into from
Sep 18, 2024

Conversation

polettif
Copy link
Collaborator

As discussed in #36, with this PR import_gtfs() can read feeds containing locations.geojson files. Changes:

  • read_files() now reads a file as json if it ends with ".geojson"
  • added dependency on jsonlite for read_json()
  • added file_ext for each file to gtfs_standard

There are no interface changes except for a slightly changed error message.

Geojson files are not validated further (except maybe what happens within read_json). It's a rather minimalistic approach to solve the issue. I hope I used the right patterns and syntax, I got a bit confused with the handling of file variables with extensions and those without, I'm not sure it's always clear what's expected.

@polettif polettif changed the title Read locations.geojson read/write locations.geojson and rework spec implementation Aug 27, 2024
@polettif
Copy link
Collaborator Author

Since there have been quite some changes and expansions with GTFS in the past few years – and it looks like there are still some underway – we reached to a limit with hard coding the specifications in get_gtfs_standards(). I implemented a method to parse the reference.md file and document which "gtfs reference types" are converted to which data.table type in the new exported gtfs_reference dataset. Parsing is done manually in inst/reference so it doesn't happen when you build the package.

gtfs_reference works similar to get_gtfs_standards() and I really tried to keep the current structure but I couldn't make it work throughout. Not least because of the new geojson files which necessitate quite some changes in reading and writing files anyway. Also file and field presence were hard coded in get_gtfs_standards() but they were not actually used anywhere in gtfsio. The same goes for enum values which were simply present as additional documented values. So I decided to deprecate get_gtfs_standards() in its current state and move all actual implementation to gtfs_reference.

So now this PR has expanded quite a bit and there are a alot of changes under the hood. There should be no changes in interfacing with gtfsio however (except if you use get_gtfs_standards() directly).

I'll try to adapt tidytransit to this state to see if there's any issues popping up there. I'm not sure how straightforward converting a json list to an sf object actually is.

@polettif
Copy link
Collaborator Author

tidytransit is ready to use the new features. There should be minimal changes to existing gtfsio workflows. Unfortunately I can't check the impact on gtfstools.

Do you see any issues with this @dhersz @rafapereirabr @mpadge?

R/import_gtfs.R Outdated Show resolved Hide resolved
Co-authored-by: mark padgham <mark.padgham@email.com>
Copy link
Collaborator

@mpadge mpadge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for putting in the great work here @polettif !!

@polettif
Copy link
Collaborator Author

@rafapereirabr Do you have any objections to merging this PR?

@rafapereirabr
Copy link
Collaborator

This all looks good to me, @polettif ! I think you're good to go and merge the PR. I would be glad to merge the PR, but I'm currently not listed as co-author of the package so I'm not sure I have the 'proper authority' to do so .

@polettif polettif merged commit 1a32a05 into master Sep 18, 2024
8 checks passed
@polettif polettif deleted the locations.geojson branch September 18, 2024 05:49
@polettif polettif mentioned this pull request Oct 7, 2024
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

Successfully merging this pull request may close these issues.

3 participants