//--------------------------------------------------------------------- public T this[int row, int column] { set { byte[] bytes = toBytes(value); // TODO: The logic below is a crude write-one-pixel at a // time approach. But hey, it works. Eventually, we need // to use the block-sized buffer of the base class for // performance. The trick is that we need will likely be // filling more than one block at a time (if raster XSize // > BlockXSize). How? Multiple buffers in the base class? // Or multiple buffers at this class level? Gdal.CPLErr result = gdalBand.RasterIO(Gdal.RWFlag.Write, column - 1, row - 1, bytes.Length, 1, bytes, bytes.Length, 1, PixelType.GDALType, 0, // pixelSpace 0); // lineSpace // Will the call above work for a partial block? e.g., // raster's XSize does not divide evenly by BlockXSize if (result != Gdal.CPLErr.None) { throw new System.ApplicationException(); } // TODO: define a Landis.Raster.Exception class // TODO: maybe create a function to create a // Landis.Raster.Exception, and fills it in // with info from CPLGetLastError[No|Type|Msg] } }
//--------------------------------------------------------------------- public T this[int row, int column] { get { int index; BlockLocation desiredBlockLoc = GetBlockLocation(row, column, out index); if (desiredBlockLoc != currentBlockLoc) { Gdal.CPLErr result = gdalBand.RasterIO(Gdal.RWFlag.Read, column - 1, row - 1, BlockXSize, BlockYSize, buffer, BlockXSize, BlockYSize, PixelType.GDALType, 0, // pixelSpace 0); // lineSpace // Will the call above work for a partial block? e.g., // raster's XSize does not divide evenly by BlockXSize if (result != Gdal.CPLErr.None) { throw new System.ApplicationException(); } // TODO: define a Landis.Raster.Exception class // TODO: maybe create a function to create a // Landis.Raster.Exception, and fills it in // with info from CPLGetLastError[No|Type|Msg] currentBlockLoc = desiredBlockLoc; } return(fromBytes(buffer, index));; } }