Opened 7 years ago

Closed 6 years ago

#6057 closed defect (fixed) patch for managing empty tiles

Reported by: Kurt Schwehr Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: normal Keywords:


Another Google engineer, Hideto Kazawa, found that crashes for empty tiles.

swig/python/scripts/ -z 7-21 debug.tif tmp
Generating Base Tiles:
ERROR 5: Illegal values for buffer size
ERROR 5: Illegal values for buffer size
Traceback (most recent call last):
  File "./swig/python/scripts/", line 2272, in <module>
  File "./swig/python/scripts/", line 481, in process
  File "./swig/python/scripts/", line 1282, in generate_base_tiles
    dsquery.WriteRaster(wx, wy, wxsize, wysize, data, band_list=list(range(1,self.dataBandsCount+1)))
  File "/home/schwehr/src/gdal/inst/lib/python2.7/site-packages/GDAL-2.1.0-py2.7-linux-x86_64.egg/osgeo/", line 856, in WriteRaster
    buf_pixel_space, buf_line_space, buf_band_space )
TypeError: not a string

He proposes this patch. It looks okay to me, but I could use a double check. Does this look reasonable? If there aren't any concerns, I'll go ahead and apply it to trunk.

  • swig/python/scripts/

    svn diff swig/python/scripts/ 
    12571257                if self.options.verbose:
    12581258                    print("\tReadRaster Extent: ", (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize))
     1260                if wxsize == 0 or wysize == 0:
     1261                    continue
    12601263                # Query is in 'nearest neighbour' but can be bigger in then the tilesize
    12611264                # We scale down the query to the tilesize by supplied algorithm.
    13641367                        for x in range(2*tx,2*tx+2):
    13651368                            minx, miny, maxx, maxy = self.tminmax[tz+1]
    13661369                            if x >= minx and x <= maxx and y >= miny and y <= maxy:
    1367                                 dsquerytile = gdal.Open( os.path.join( self.output, str(tz+1), str(x), "%s.%s" % (y, self.tileext)), gdal.GA_ReadOnly)
     1370                                tilefile = os.path.join(self.output, str(tz+1), str(x), "%s.%s" % (y, self.tileext))
     1371                                if not os.path.exists(tilefile):
     1372                                    continue
     1373                                dsquerytile = gdal.Open(tilefile , gdal.GA_ReadOnly)
     1374                                if dsquerytile is None:
     1375                                   continue
    13681376                                if (ty==0 and y==1) or (ty!=0 and (y % (2*ty)) != 0):
    13691377                                    tileposy = 0
    13701378                                else:

Attachments (1)

debug.tif (396.2 KB ) - added by Kurt Schwehr 7 years ago.
File that crashes -z 7-21 debug.tif tmp

Download all attachments as: .zip

Change History (6)

by Kurt Schwehr, 7 years ago

Attachment: debug.tif added

File that crashes -z 7-21 debug.tif tmp

comment:1 by Jukka Rahkonen, 7 years ago

Is this about the same thing as tickets #3596 and #5005?

in reply to:  1 comment:2 by Even Rouault, 7 years ago

Replying to jratike80:

Is this about the same thing as tickets #3596 and #5005?

Yes, same patch as #3596 is about empty/transparent content in tiles, whereas this one is about 0xX ou Xx0 tiles.

Looks good to me.

What would be most appreciated is a autotest/pyscripts/ script since we have none currently.

comment:3 by Kurt Schwehr, 7 years ago

I will try to create a test and get the test and patch in soon.

comment:4 by Even Rouault, 7 years ago

Also reported as #6106

comment:5 by Even Rouault, 6 years ago

Resolution: fixed
Status: newclosed

In 37210:

gdal2tiles: do not crash on empty tiles generation (patch by Gregory Bataille, fixes #6057, github #188)

Due to raster border approximation where the border coords is in a tile A while the border pixel is
in a tile B, neighbour of A

Note: See TracTickets for help on using tickets.