[Gdal-dev] Re: Dataset.i - ReadRaster/WriteRaster
Tamas Szekeres
szekerest at gmail.com
Wed Nov 15 17:34:19 EST 2006
Frank,
It seems to be compelling to implement this kind of functions. I have
already seen a WriteRaster implementation in Dataset.i but it's a bit
unfriendly for the C# interface.
It must be noted that I had to pull out the WriteRaster/ReadRaster
implementation of band.i for C# because of the following reasons:
1. The default argument handling was not suitable for the C# binding.
The default implementation in band.i highly diverges from the original
GDALRasterIO concept.
2. The default implementation of ReadRaster alters the GDALRasterIO
allocation scheme, since it attepts to pass a newly allocated memory
to C# which is difficult to support safely.
(I would have to set up some kind of callback mechanism so as to support it)
I did not want to alter the original implementation in band.i because
I am not aware of the backward incompatible effects for the other
bindings. For C# the following simple implementation was sufficient:
%extend GDALRasterBandShadow
{
%apply (void *buffer_ptr) {void *buffer};
CPLErr ReadRaster(int xOff, int yOff, int xSize, int ySize, void* buffer,
int buf_xSize, int buf_ySize, GDALDataType buf_type,
int pixelSpace, int lineSpace) {
return GDALRasterIO( self, GF_Read, xOff, yOff, xSize, ySize,
buffer, buf_xSize, buf_ySize, buf_type, pixelSpace, lineSpace );
}
CPLErr WriteRaster(int xOff, int yOff, int xSize, int ySize, void* buffer,
int buf_xSize, int buf_ySize, GDALDataType buf_type,
int pixelSpace, int lineSpace) {
return GDALRasterIO( self, GF_Write, xOff, yOff, xSize, ySize,
buffer, buf_xSize, buf_ySize, buf_type, pixelSpace, lineSpace );
}
%clear void *buffer;
}
To support ReadRaster/WriteRaster for the dataset I would also suggest
to keep the original behaviour of GDALDatasetRasterIO method by not
altering the memory allocation mechanism and not bringing in esoteric
default value handling.
However I would support some extra code to give default implementation
for some of the unspecified arguments like the current WriteRaster
code. And all of the bindings will have to implement the typemaps for
'void * pData' and 'int *panBandMap'.
And certainly I can add the common part of the implementation into
dataset.i if needed but it will be an overload of the current
WriteRaster function if it should be kept.
Best Regards,
Tamas
2006/11/16, Frank Warmerdam <warmerdam at pobox.com>:
> Tamas,
>
> I am now trying to primarily run with the next generation swig bindings.
> In doing so I have discovered that the ReadRaster() method was never
> implemented in Dataset.i. Also, though WriteRaster was done, it does not
> seem to work the same as in Band.i. Since you have recently dealing with
> these methods at the Band level, would you be willing to do the same for the
> Dataset?
>
> Currently the lack of these is breaking the tiff_write.py autotest script.
> If you can implement it, I'll give it a try. If you don't have time to
> address this let me know, and I'll find some other solution. I took a
> brief run at it, but got confused.
>
> Best regards,
> --
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush | President OSGeo, http://osgeo.org
>
>
More information about the Gdal-dev
mailing list