-
Notifications
You must be signed in to change notification settings - Fork 10
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
fix read(io) to support Downloads.download of stdlib #90
base: main
Are you sure you want to change the base?
Conversation
```julia using GeoJSON, Downloads io = Downloads.download("https://its-live-data.s3.amazonaws.com/datacubes/catalog_v02.json", IOBuffer()) fc = GeoJSON.read(io) ```
using Downloads instead of HTTP.jl We don't need a dependency on HTTP.jl
@@ -11,6 +11,7 @@ Read GeoJSON to a GeoInterface.jl compatible object. | |||
- `numbertype::DataType=Float32`: Use Float64 when the precision is required. | |||
""" | |||
function read(io; lazyfc=false, ndim=2, numbertype=Float32) | |||
eof(io) && seekstart(io) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
This also applies to strings and Vector{UInt8} as written now, so the code should be abstracted out somewhere else. Perhaps a separate dispatch of read
for ::IO
objects? CI is failing for this reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also needs some explanatory comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it common to do such a thing? I've never seen it. It seems more up to the caller that the IOBuffer should not be at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it common to do such a thing? I've never seen it. It seems more up to the caller that the IOBuffer should not be at the end.
It's common to download GeoJSON data from web links when using GeoMakie
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree, I meant specifically the seekstart
. That seems like it is not the responsibility of that function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it is the responsibility of the caller to ensure the IO is in the usable status.
But check eof
and seekstart
will made GeoJSON.jl be user-friendly for beginners, especially for those who are unfamiliar with input/output streams.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I appreciate the effort for user-friendliness, but am afraid that then users will expect other functions reading streams do the same, and possibly end up more confused. To keep the example simple it is also fine to just use Downloads.download("https://its-live-data.s3.amazonaws.com/datacubes/catalog_v02.json")
to get a temp file path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can providing an seekstart bool argument and/or code example to facilitate this usage scenario.
using Downloads instead of HTTP.jl
We don't need a dependency on HTTP.jl