Opened 18 years ago

Closed 18 years ago

#1748 closed defect (fixed)

SHAPEPATH is neglected when rendering big raster images

Reported by: malfet@… Owned by: warmerdam
Priority: high Milestone:
Component: GDAL Support Version: unspecified
Severity: normal Keywords:
Cc:

Description

If mapserver is running on 32-bit arch and one of the layers are big raster file, that have to be rendered 
by GDAL library, SHAPEPATH is neglected when calling to GDALOpen
Please, look at following code in msDrawRasterLayerLow:

    msBuildPath3(szPath, map->mappath, map->shapepath, filename);
    f = fopen( szPath, "rb");
    if(!f) {
      memset( dd, 0, 8 );
      strcpy( szPath, filename );
    } else {
      fread(dd,8,1,f); /* read some bytes to try and identify the file */
      fclose(f);
    }
    ....
    hDS = GDALOpen(szPath, GA_ReadOnly );
fopen may return NULL, while errno will be equal to EFBIG, but SHAPEPATH will be discarded.
But functionality will again be normal, if one will check this case
    f = fopen( szPath, "rb");
    if(!f) {
      memset( dd, 0, 8 );
#ifndef USE_GDAL
      strcpy( szPath, filename );
#else
       if ( errno != EFBIG)
           strcpy( szPath, filename );
#endif
    } else {

Attachments (1)

mapserver-gdal-bigfile.patch (640 bytes ) - added by malfet@… 18 years ago.
Patch fixing bigfile problem with GDAL

Download all attachments as: .zip

Change History (2)

by malfet@…, 18 years ago

Patch fixing bigfile problem with GDAL

comment:1 by fwarmerdam, 18 years ago

Resolution: fixed
Status: newclosed
Nikita, 

I was aware of this problem, but I wasn't aware I could check for 
the EFBIG error.  I have modified the patch a bit to work on platforms
without EFBIG defined, and to be a bit more explanitory.

    /*
    ** Try to open the file, and read the first 8 bytes as a signature. 
    ** If the open fails for a reason other than "bigness" then we use
    ** the filename unaltered by path logic since it might be something
    ** very virtual.
    */
    f = fopen( szPath, "rb");
    if(!f) {
      memset( dd, 0, 8 );
#ifdef EFBIG
      if( errno != EFBIG )
          strcpy( szPath, filename );
#else
      strcpy( szPath, filename );
#endif
    } else {
      fread(dd,8,1,f); /* read some bytes to try and identify the file */
      fclose(f);
    }

I have only incorporated this patch into 4.9.  It could go into 4.8 branch 
but I'm a bit nervous about it still. 

Please reopen if you feel this should go into 4.8 branch.

Note: See TracTickets for help on using tickets.