Open lnicola opened 1 month ago
I think we should avoid implementing our own Grid type with iterators and so on. It is to complex and beyond the scope of the crate (my opinion).
The Buffer
I know that writing is more complex. If the data is not in C order it needs to be transformed because GDAL uses C order and i think there is no way around it. We could think of a trait for writing that has a &[T] and provides x and y size instead of using the Buffer struct to avoid a copy if you have data already in the perfect shape. I never used GDALRasterIOEx with spacing so there may be more options if the data does not have the correct shape.
It is to complex and beyond the scope of the crate (my opinion).
Just this API, I swear, just this API and we're done :laughing:. But seriously, we should at least store the actual block size in the buffer so it's easy to access.
I never used GDALRasterIOEx with spacing so there may be more options if the data does not have the correct shape.
I think it supports setting cell (e.g. for pixels with padding) and line strides, plus an initial offset by pointing it to the middle of the buffer.
This bit me in #556 and probably before: it you read a block at the right or bottom edges of a band, it might be incomplete. In #556 I assumed we'd get a block of smaller dimensions, but GDAL does something different: you get a full block, but only the top-left data is valid (and the extra borders are ignored when writing).
This is hinted at in the GDAL docs:
We could offer a
pixels
(cells. etc.) iterator that only returns the in-bounds values, or we could go full-in onndarray
(see also #569).