Conversation
|
Could we use this to lazily wrap a tile server? |
|
Main problem might be, that a Tile Server has color values and not actual array values. But this might work for wrapping a tile server and giving the RGB values from the pngs. This would currently expect a function that would from a given tile position return a matrix of the data in this position. So we could have a function that reads the data from the tile server. The interface we are aiming for currently is this: using ArchGDAL
function geturl(east, north)
baseurl = "https://download.geoservice.dlr.de/FNF50/files"
xsym, xval = if east < 180
'W',180-east
else
'E', east-180
end
ysym, yval = if north < 90
'S', 90-north
else
'N', north-90
end
xpadround = xsym * lpad(Int(round(xval, RoundDown, digits=-1)), 3, "0")
ypadround = ysym * lpad(Int(round(yval, RoundDown, digits=-1)), 2, "0")
xpad = xsym * lpad(xval, 3, "0")
ypad = ysym * lpad(yval, 2,"0")
tdm = "TDM_FNF_20_" * ypad * xpad
join([baseurl, ypad, xpadround, tdm, tdm * "_cog.tif"], "/")
end
function gettile(east, north)
response = HTTP.head(geturl(1,1), status_exception=false)
if response.status == 200
ArchGDAL.readraster("/vsicurl/"*geturl(east, north))[:,:]::Matrix{UInt8}
else
fill(UInt8(3), (2001,2001))
end
end
A = DiskArrays.TiledDiskArray{UInt8,2}(gettile, (360,180), (2001,2001)) |
| chunk_indices = findchunk.(chunks.chunks, I) | ||
| data_offset = OffsetArray(data, map(i -> first(i) - 1, I)...) | ||
| foreach(CartesianIndices(chunk_indices)) do ci | ||
| @show ci |
| foreach(CartesianIndices(chunk_indices)) do ci | ||
| @show ci | ||
| chunkindex = ChunkIndex(ci; offset=true) | ||
| @show chunkindex |
| tilefunction | ||
| tilenum | ||
| tilesizes |
There was a problem hiding this comment.
Can you use this definition instead:
struct TiledDiskArray{T,N,F} <: AbstractChunkTiledDiskArray{T,N}
tilefunction::F
tilenum::NTuple{N,Int}
tilesizes::NTuple{N,Int}
endThere was a problem hiding this comment.
Might be worth having the tile definition be GridChunks instead - for example the Copernicus DEM has irregular sizes
There was a problem hiding this comment.
Do you have a link to that?
There was a problem hiding this comment.
| struct TiledDiskArray{T,N} <: AbstractChunkTiledDiskArray{T,N} | ||
| tilefunction | ||
| tilenum | ||
| tilesizes |
There was a problem hiding this comment.
Is tilesizes just tilesize? What does the pluralisation mean?
Add a TiledDiskArray type which handles a collection of tiles that lay in the same grid with a predictable pattern .