<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Hi Even,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Thank you, now I get it, and that would work well I think.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Would the next step be for me to prepare a PR based on this?</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Kind regards, Alex</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Even Rouault <even.rouault@spatialys.com><br>
<b>Sent:</b> 06 July 2025 23:13<br>
<b>To:</b> Alex Hagen-Zanker <alexhighviz@hotmail.com>; gdal-dev@lists.osgeo.org <gdal-dev@lists.osgeo.org><br>
<b>Subject:</b> Re: [gdal-dev] Random Raster Driver</font>
<div> </div>
</div>
<div>Alex,<br>
<blockquote type="cite">
<div class="x_elementToProof" style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I am not sure if I understand your suggestion correctly. Are you suggesting to change the behaviour or VRT DerivedRasterBand in general so that its IRasterIO would only work on block boundaries? That seems quite drastic to me.
</div>
</blockquote>
<p>No, my suggestion was to do that only when one of the random pixel functions is used.<br>
</p>
<blockquote type="cite">
<div class="x_elementToProof" style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I think there would be a few more minor adaptations necessary for VRTDerivedRasterBand so that it can accept that there are zero source layers for the pixel function.
<br>
</div>
</blockquote>
Yes<br>
<blockquote type="cite">
<div class="x_elementToProof" style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Looking at VRTDerivedRasterband I was surprised that it implements IRasterIO rather than IReadBlock.</div>
</blockquote>
<p>The base class VRTSourcedRasterBand has a IReadBlock() method that forwards to IRasterIO(). That way you get both the caching effect if block based reading is done and goes through IReadBlock(), or if VRTDerivedRasterBand::IRasterIO() is directly called,
it is short circuited.</p>
<blockquote type="cite">
<div class="x_elementToProof" style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
If you indeed meant to restrict IRasterIO to block boundaries in general, would it be a consideration to implement it as IReadBlock and use default behaviour for IRasterIO? From my understanding that would change the way the caching works, as it would cache
the results of the pixel function rather than the input to the pixel function. It would also allow RasterIO to still be used as it currently is.</div>
</blockquote>
<p>basically what I'm suggesting is something along those lines:</p>
<p>CPLErr VRTDerivedRasterBand::IRasterIO(.... )<br>
{<br>
if( use_one_of_the_random_functions )<br>
return GDALRasterBand::IRasterIO( ... ); // force base method to IReadBlock(), which will go to VRTSourcedRasterBand::IReadBlock() which will call us again, but on block boundaries<br>
<br>
rest of the method mostly unchanged. You'll need to pass the nXOff and nYOff arguments as arguments of the random pixel functions, around lines 1580-1590</p>
<p>}<br>
</p>
<p>Even</p>
<br>
<pre class="x_moz-signature" cols="72">--
<a class="x_moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</div>
</body>
</html>