From 2d3eaf4e18090f7aa6eaf05c879b0a53791a03cf Mon Sep 17 00:00:00 2001 From: xufanglu <3146974+likev@users.noreply.github.com> Date: Sun, 28 Apr 2024 19:20:54 +0800 Subject: [PATCH 1/2] fix read(io) to support Downloads.download of stdlib ```julia using GeoJSON, Downloads io = Downloads.download("https://its-live-data.s3.amazonaws.com/datacubes/catalog_v02.json", IOBuffer()) fc = GeoJSON.read(io) ``` --- src/io.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/io.jl b/src/io.jl index bde293c..1f84708 100644 --- a/src/io.jl +++ b/src/io.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) if lazyfc obj = JSON3.read(io, LazyFeatureCollection{ndim,numbertype}) else From 36af20586b87a27812200963a287bf87260395e7 Mon Sep 17 00:00:00 2001 From: xufanglu <3146974+likev@users.noreply.github.com> Date: Sun, 28 Apr 2024 19:26:29 +0800 Subject: [PATCH 2/2] Update README.md using Downloads instead of HTTP.jl using Downloads instead of HTTP.jl We don't need a dependency on HTTP.jl --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b498c1a..4739dff 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,12 @@ julia> write(fc) ### HTTP access -To read JSON from a URL, use HTTP.jl +To read JSON from a URL, use Downloads ```julia -julia> using GeoJSON, HTTP +julia> using GeoJSON, Downloads -julia> resp = HTTP.get("https://path/to/file.json") +julia> io = Downloads.download("https://its-live-data.s3.amazonaws.com/datacubes/catalog_v02.json", IOBuffer()) -julia> fc = GeoJSON.read(resp.body) +julia> fc = GeoJSON.read(io) ```