diff --git a/src/downloader.jl b/src/downloader.jl index bcea7c5b..b69277f7 100644 --- a/src/downloader.jl +++ b/src/downloader.jl @@ -44,6 +44,8 @@ function unique_filename(url) return string(hash(url)) end +file_ending(provider::TileProviders.Provider) = ".some_unknown_image_format" + function download_tile_data(dl::PathDownloader, provider::AbstractProvider, url) unique_name = unique_filename(url) path = joinpath(dl.cache_dir, unique_name * file_ending(provider)) diff --git a/src/tiles.jl b/src/tiles.jl index cda9e0e9..9d7b87a4 100644 --- a/src/tiles.jl +++ b/src/tiles.jl @@ -108,6 +108,12 @@ function load_tile_data(::AbstractProvider, downloaded::AbstractVector{UInt8}) return FileIO.load(format) # this works because we have ImageIO loaded end +function load_tile_data(::AbstractProvider, downloaded::String) + io = IOBuffer(read(downloaded)) + format = FileIO.query(io) # this interrogates the magic bits to see what file format it is (JPEG, PNG, etc) + return FileIO.load(format) # this works because we have ImageIO loaded +end + function Base.wait(tiles::TileCache; timeout=50) # wait for all tiles to get downloaded items = lock(tiles.tile_queue) do