[Gdal-dev] Bug in OGDI Driver when accessing tiles (FAILURE:
1: End of selection)
Frank Warmerdam
warmerdam at pobox.com
Tue Mar 28 10:03:20 EST 2006
Reiner Beck wrote:
> (2nd try - the first one went to gdal-dev at remotesensing.org - sorry if
> you receive this twice)
>
> Hello List,
>
> there seems to be a bug in the OGDI driver when accessing tiles which
> are directly "under" the previously fetched tile.
>
> Here's what I do:
> - The driver is a RPF dataset and the sub-dataset used is a Matrix layer.
> This is a layer with a colortable, not the RGB Image layer.
> - The error does only occur for single band access.
> - I read the image data tile by tile using the
> GDALRasterBand::RasterIO() method.
> - For example, the Image Size is 6144x3072, Tile Size is 256x256, No of
> Tiles is 24x12.
> - For internal reasons, the tiles are fetched somewhat randomly.
> - The error occurs only in case a tile is read, followed by a read to a
> tile which is directly
> under the previously read tile.
>
> Example:
> First tile to read is [3, 7]:
>
> This results in calls to:
> poBand->RasterIO(GF_Read, 768, 1792, 256, 256, poinerToMyBuffer, 256,
> 256, 1, 1, 256);
>
> and GDAL internal to
> OGDIRasterBand::EstablishAccess(768, 1792, 256, 256, 256, 256);
>
> Let's assume this works.
>
>
> Next tile to read is [3, 8]:
>
> This results in calls to:
> poBand->RasterIO(GF_Read, 768, 2048, 256, 256, poinerToMyBuffer, 256,
> 256, 1, 1, 256)
> and GDAL internal to
> OGDIRasterBand::EstablishAccess(768, 2048, 256, 256, 256, 256);
>
> In this case, the method EstablishAccess() will not call
> cln_SelectRegion() and the read will fail with an error 1 "End of
> selection". This happens in the OGDI RPF driver, function
> dyn_getNextObjectRaster(). However, I think the error is in the GDAL part.
>
>
> Workaround:
> In case the if statement in EstablishAccess() is commented out (not the
> body of the statement), it works:
> /*
> /if( poODS->nCurrentIndex == -1 / / || ABS(sWin.west -
> poODS->sCurrentBounds.west) > 0.0001 / / || ABS(sWin.east -
> poODS->sCurrentBounds.east) > 0.0001 / / || ABS(sWin.north -
> (poODS->sCurrentBounds.north - poODS->nCurrentIndex *
> poODS->sCurrentBounds.ns_res)) > dfNSTolerance / / ||
> ABS(sWin.ew_res/poODS->sCurrentBounds.ew_res - 1.0) > 0.0001/ / ||
> ABS(sWin.ns_res - poODS->sCurrentBounds.ns_res) > dfNSTolerance )/ /
> */
> Not sure if this is the best solution though ...
Reiner,
I am going to apply the following patch. I think this will avoid
resetting the window in some cases, but *will* reset it if the
"current index" isn't pointing to the first line of the window.
Could you try this and verify it fixes your problem?
diff -u -r1.20 ogdidataset.cpp
--- ogdidataset.cpp 2 Dec 2004 20:31:03 -0000 1.20
+++ ogdidataset.cpp 28 Mar 2006 15:00:25 -0000
@@ -489,7 +489,7 @@
dfNSTolerance = sWin.ns_res * 0.001;
}
- if( poODS->nCurrentIndex == -1
+ if( poODS->nCurrentIndex != 0
|| ABS(sWin.west - poODS->sCurrentBounds.west) > 0.0001
|| ABS(sWin.east - poODS->sCurrentBounds.east) > 0.0001
|| ABS(sWin.north - (poODS->sCurrentBounds.north -
poODS->nCurrentIndex * poODS->sCurrentBounds.ns_res)) > dfNSTolerance
I don't really have test scripts in place for OGDI so I am always
nervous about making changes in this old code. It seems to me there is
substantial opportunities for optimization in the OGDI driver, especially
for the common case of a program reading the whole source from top to
bottom in a bunch of 1 scanline rasterio requests.
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 OSGF, http://osgeo.org
More information about the Gdal-dev
mailing list