From e8c6010cdfc0b8e43c3ba808caa62f66f96a725b Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Thu, 14 Feb 2019 14:21:16 +0100 Subject: [PATCH] use zipfiles --- REQUIRE | 1 + examples/bigdata.jl | 16 ++++++++++++---- test/REQUIRE | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/REQUIRE b/REQUIRE index 0d5a1898..c5bcc2e3 100644 --- a/REQUIRE +++ b/REQUIRE @@ -22,3 +22,4 @@ DataFrames RDatasets BinaryProvider StatsMakie +ZipFile diff --git a/examples/bigdata.jl b/examples/bigdata.jl index e7df81b6..4d39fce5 100644 --- a/examples/bigdata.jl +++ b/examples/bigdata.jl @@ -2,7 +2,7 @@ @cell "WorldClim visualization" [visualization, dataset, bigdata] begin # fixes for GDAL messing with LD library path and therefore using wrong curl # for downloads - using FileIO, GeometryTypes, Colors, GDAL, BinaryProvider + using FileIO, GeometryTypes, Colors, GDAL, ZipFile env = ENV["LD_LIBRARY_PATH"] #= This example requires the GDAL package, from https://github.com/JuliaGeo/GDAL.jl @@ -16,9 +16,17 @@ # set up 7zip - exe7z = BinaryProvider.gen_unpack_cmd("bla.zip", "dest").a[1] - unzip(in, out) = run(`$exe7z x -y $in -o$out`) + function unzip(input, out) + dir = ZipFile.Reader(input) + mkpath(out) + for file in dir.files + open(joinpath(out, file.name), "w") do io + Base.write(io, read(file)) + end + end + close(dir) + end # function to read the raster data from the GeoTIFF function loadf0(x) @@ -48,7 +56,6 @@ download("http://biogeo.ucdavis.edu/data/worldclim/v2.0/tif/base/wc2.0_10m_$name.zip", "$name.zip") end if !isdir(name) - #BinaryProvider.unpack("$name.zip", name) doesn't work -.- unzip("$name.zip", name) end ENV["LD_LIBRARY_PATH"] = env @@ -56,6 +63,7 @@ end # load the actual datasets! + water = load_dataset("prec") temperature = load_dataset("tmax") diff --git a/test/REQUIRE b/test/REQUIRE index 2fee1b6f..7c040b1a 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -1,2 +1,3 @@ Makie GLMakie +ZipFile