[mapserver-commits] r12752 - trunk/mapserver/mapcache/src
svn at osgeo.org
svn at osgeo.org
Fri Nov 4 09:32:24 EDT 2011
Author: tbonfort
Date: 2011-11-04 06:32:24 -0700 (Fri, 04 Nov 2011)
New Revision: 12752
Modified:
trunk/mapserver/mapcache/src/cache_tiff.c
Log:
fix offset calculation for seeder usage of tiff cache
Modified: trunk/mapserver/mapcache/src/cache_tiff.c
===================================================================
--- trunk/mapserver/mapcache/src/cache_tiff.c 2011-11-04 10:34:00 UTC (rev 12751)
+++ trunk/mapserver/mapcache/src/cache_tiff.c 2011-11-04 13:32:24 UTC (rev 12752)
@@ -247,9 +247,21 @@
#endif
int tiff_offx, tiff_offy; /* the x and y offset of the tile inside the tiff image */
int tiff_off; /* the index of the tile inside the list of tiles of the tiff image */
- tiff_offx = tile->x % dcache->count_x;
- tiff_offy = dcache->count_y - tile->y % dcache->count_y - 1;
- tiff_off = tiff_offy * dcache->count_x + tiff_offx;
+
+ mapcache_grid_level *level = tile->grid_link->grid->levels[tile->z];
+ int ntilesx = MAPCACHE_MIN(dcache->count_x, level->maxx);
+ int ntilesy = MAPCACHE_MIN(dcache->count_y, level->maxy);
+
+ /* x offset of the tile along a row */
+ tiff_offx = tile->x % ntilesx;
+
+ /*
+ * y offset of the requested row. we inverse it as the rows are ordered
+ * from top to bottom, whereas the tile y is bottom to top
+ */
+ tiff_offy = ntilesy - (tile->y % ntilesy) -1;
+ tiff_off = tiff_offy * ntilesx + tiff_offx;
+
toff_t *offsets=NULL, *sizes=NULL;
TIFFGetField( hTIFF, TIFFTAG_TILEOFFSETS, &offsets );
TIFFGetField( hTIFF, TIFFTAG_TILEBYTECOUNTS, &sizes );
More information about the mapserver-commits
mailing list