Opened 15 years ago

Closed 7 years ago

#1234 closed enhancement (wontfix)

Proposal: add Get[XY]Start() methods to GDALRasterBlock

Reported by: danmitchell@… Owned by: warmerdam
Priority: highest Milestone:
Component: default Version: unspecified
Severity: minor Keywords:
Cc: Mateusz Łoskot

Description (last modified by Mateusz Łoskot)

I'm developing an application that operates on rasters at the block level and it would be very convenient if each GDALRasterBlock could return its starting pixel. This information can obviously be calculated and stored apart from the block (as I'm currently doing), but it would be nice if each block took care of this itself. If no one objects, I'd appreciate changes similar to the following.

--- gdal_priv.h	2006-05-24 17:25:33.000000000 -0500
+++ gdal_priv.h	2006-07-11 20:31:37.000000000 -0500
@@ -355,6 +355,9 @@
        
     int                 nXSize;
     int                 nYSize;
+
+    int                 nXStart;
+    int                 nYStart;
     
     void                *pData;
 
@@ -382,6 +385,8 @@
     int         GetYOff() { return nYOff; }
     int         GetXSize() { return nXSize; }
     int         GetYSize() { return nYSize; }
+    int         GetXStart() { return nXStart; }
+    int         GetYStart() { return nYStart; }
     int         GetDirty() { return bDirty; }
     int         GetLockCount() { return nLockCount; }
 
--- gdalrasterblock.cpp	2006-02-07 13:07:08.000000000 -0600
+++ gdalrasterblock.cpp	2006-07-11 20:32:35.000000000 -0500
@@ -262,6 +262,9 @@
 
     nXOff = nXOffIn;
     nYOff = nYOffIn;
+
+    nXStart = nXOff * nXSize;
+    nYStart = nYOff * nYSize;
 }
 
 /************************************************************************/

D.

Change History (2)

comment:1 Changed 12 years ago by Mateusz Łoskot

Cc: Mateusz Łoskot added
Description: modified (diff)

If this idea is considered for inclusion at all, I think there is no need to cache the block pixel offset value. I'd also suggest to rename the proposed functions to follow naming convention of GetXOff and GetYOff but indicating pixel level offset:

int GetXPixelOff() { return nXOff * nXSize; }
int GetYPixelOff() { return nYOff * nYSize; }

comment:2 Changed 7 years ago by Even Rouault

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.