SharpMap 0.9 + gdal

Topics: Data Access, SharpMap v0.9 / v1.x
Sep 18, 2007 at 4:31 PM
Hi guys,

I need to use some raster data (MrSids) in my web application. I downloaded this morning the source code with the codeplex-client and tried to compile the solution in the trunk-folder. After that, I took the dlls in the Trunk/sharpmap.Extension/bin/debug folder and all other dlls from the fwtools v. 1.3.5 and copied all in the /Bin of my application.
Then an error occured:

Access window out of range in RasterIO(). Requested
(7594,460) of size 1724x3520 on raster of 5870x5870.
Beschreibung: Unbehandelte Ausnahme beim Ausführen der aktuellen Webanforderung. Überprüfen Sie die Stapelüberwachung, um weitere Informationen über diesen Fehler anzuzeigen und festzustellen, wo der Fehler im Code verursacht wurde.

Ausnahmedetails: System.ApplicationException: Access window out of range in RasterIO(). Requested
(7594,460) of size 1724x3520 on raster of 5870x5870.

Quellfehler:

Zeile 233:
Zeile 234: //band.ReadRaster(x1, y1, x1width, y1height, buffer, size.Width, size.Height, (int)GT.HorizontalPixelResolution, (int)GT.VerticalPixelResolution);
Zeile 235: band.ReadRaster(x1, y1, x1width, y1height, buffer, size.Width, size.Height, 0, 0);
Zeile 236:
Zeile 237: int p_indx = 0;


Quelldatei: C:\SharpMap\Trunk\SharpMap.Extensions\Layers\GdalRasterLayer.cs Zeile: 235

Stapelüberwachung:

[ApplicationException: Access window out of range in RasterIO(). Requested
(7594,460) of size 1724x3520 on raster of 5870x5870.]
OSGeo.GDAL.Band.ReadRaster(Int32 xOff, Int32 yOff, Int32 xSize, Int32 ySize, IntPtr buffer, Int32 bufxSize, Int32 bufySize, DataType buf_type, Int32 pixelSpace, Int32 lineSpace) +113
OSGeo.GDAL.Band.ReadRaster(Int32 xOff, Int32 yOff, Int32 xSize, Int32 ySize, Byte[] buffer, Int32 bufxSize, Int32 bufySize, Int32 pixelSpace, Int32 lineSpace) +150
SharpMap.Layers.GdalRasterLayer.GetPreview(Dataset dataset, Size size, Graphics g, BoundingBox bbox) in C:\SharpMap\Trunk\SharpMap.Extensions\Layers\GdalRasterLayer.cs:235
SharpMap.Layers.GdalRasterLayer.Render(Graphics g, Map map) in C:\SharpMap\Trunk\SharpMap.Extensions\Layers\GdalRasterLayer.cs:91
SharpMap.Map.GetMap() in C:\SharpMap\Trunk\SharpMap\Map\Map.cs:157
MapHandler.ProcessRequest(HttpContext context) in c:\Inetpub\wwwroot\sharpmap\MapHandler.ashx:60
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

My question now is:
Is the way I used for compiling SharpMap coorect? If not, how is the correct way ? Are the versions of the fwtools OK?
THanks for your advice
MArtin
Sep 18, 2007 at 8:55 PM
This error and many other issues with the gdal raster layer are fixed with this patch. http://www.codeplex.com/SharpMap/Project/FileDownload.aspx?DownloadId=17120
Joel
Sep 21, 2007 at 7:49 AM
Joel, thanks for your answer.
Unfortuneatly, this patch doesn't help.
This error only appaers, when my map contains parts of two neighboured orthos (MrSid). The message is allways the same, but the numbers are changing, depending on the bbox of the map. In my opinion, Sharpmap or gdal are trying to read some pixels "outside" the sid:
Access window out of range in RasterIO(). Requested (5198,2957) of size 673x2913 on raster of 5870x5870.
The first pair of numbers (5198,2957) looks like a coordinate, the second like the size of the requested part of the sid an the last pair is the size of the sid. IF you add the y-coordinate (2957) and the width of the part (2913), you'll get 5870; adding the x-coordinate (5198) and the height (673), the result will be 5871 - that's one pixel outside the ortho.
Do you have an idea, how I can solve this error?
Dec 12, 2007 at 1:45 PM
Hi all

I applied the patch mention by joel4370 and now I get another exception:
System.AccessVolationException
occured in System.Drawing.dll
Attempted to read or write protected memory. ...

In file GdalRasterLayer.cs line 888: g.DrawImage(bitmap, new System.Drawing.Point((int)Math.Round(dblLocX), (int)Math.Round(dblLocY)));

Any solution?

Ian