Pass line and band space parameters properly

This commit is contained in:
Sean Gillies 2016-09-28 14:52:00 +02:00
parent 273352e2d5
commit bb3ee77086
3 changed files with 14 additions and 8 deletions

View File

@ -121,7 +121,7 @@ cdef int io_multi_ubyte(
int height,
np.uint8_t[:, :, :] buffer,
long[:] indexes,
int count) nogil
int count)
cdef int io_multi_uint16(

View File

@ -74,6 +74,7 @@ cdef bint in_dtype_range(value, dtype):
rng = infos[key](dtype)
return rng.min <= value <= rng.max
# Single band IO functions.
cdef int io_ubyte(
@ -84,10 +85,13 @@ cdef int io_ubyte(
int width,
int height,
np.uint8_t[:, :] buffer):
cdef int pixelspace = buffer.itemsize * buffer.strides[1]
cdef int linespace = buffer.itemsize * buffer.strides[0]
with nogil:
return GDALRasterIO(
band, mode, xoff, yoff, width, height,
&buffer[0, 0], buffer.shape[1], buffer.shape[0], 1, 0, 0)
&buffer[0, 0], buffer.shape[1], buffer.shape[0], 1, pixelspace,
linespace)
cdef int io_uint16(
GDALRasterBandH band,
@ -178,17 +182,21 @@ cdef int io_multi_ubyte(
int height,
np.uint8_t[:, :, :] buffer,
long[:] indexes,
int count) nogil:
int count):
cdef int i, retval=0
cdef GDALRasterBandH band
cdef int *bandmap
cdef int pixelspace = buffer.itemsize * buffer.strides[2]
cdef int linespace = buffer.itemsize * buffer.strides[1]
cdef int bandspace = buffer.itemsize * buffer.strides[0]
with nogil:
bandmap = <int *>CPLMalloc(count*sizeof(int))
for i in range(count):
bandmap[i] = indexes[i]
retval = GDALDatasetRasterIO(
hds, mode, xoff, yoff, width, height, &buffer[0, 0, 0],
buffer.shape[2], buffer.shape[1], 1, count, bandmap, 0, 0, 0)
buffer.shape[2], buffer.shape[1], 1, count, bandmap,
pixelspace, linespace, bandspace)
CPLFree(bandmap)
return retval

View File

@ -245,6 +245,7 @@ def test_reproject_view():
source = src.read(1)
window = windows.Window(100, 100, 500, 500)
# window = windows.get_data_window(source)
reduced_array = source[window.toslices()]
reduced_transform = windows.transform(window, src.transform)
@ -267,7 +268,6 @@ def test_reproject_view():
out = np.empty(src.shape, dtype=np.uint8)
reproject(
reduced_array,
out,
@ -277,9 +277,7 @@ def test_reproject_view():
dst_crs=dst_crs,
resampling=Resampling.nearest)
show(out)
assert (out > 0).sum() == 438113
assert (out > 0).sum() == 299199
def test_reproject_epsg():