Changeset 13434

Show
Ignore:
Timestamp:
12/21/07 13:17:20 (5 months ago)
Author:
mloskot
Message:

Port to branches/1.5: Re-fix nodata test when determining AAIGrid data type (Ticket #2107).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.5/autotest/gdrivers/aaigrid.py

    r13407 r13434  
    140140 
    141141    b = ds.GetRasterBand(1) 
    142     if b.GetNoDataValue() != -99999.123
     142    if b.GetNoDataValue() != -99999
    143143        gdaltest.post_reason( 'Grid NODATA value wrong or missing.' ) 
    144144        return 'fail' 
  • branches/1.5/autotest/gdrivers/data/nodata_float.asc

    r13407 r13434  
    44yllcorner    3750120.000000000000 
    55cellsize     60.000000000000 
    6 nodata_value -99999.123 
     6nodata_value -99999 
    77    107    123    132    115    132 
    88    115    132    107    123    148 
  • branches/1.5/gdal/frmts/aaigrid/aaigriddataset.cpp

    r13407 r13434  
    3030#include "gdal_pam.h" 
    3131#include <ctype.h> 
     32#include <limits.h> 
    3233#include "cpl_string.h" 
    3334#include "ogr_spatialref.h" 
     
    380381    char **papszTokens = NULL; 
    381382    GDALDataType eDataType = GDT_Int16; 
    382     GDALDataType eNoDataType = GDT_Int16; 
    383383 
    384384/* -------------------------------------------------------------------- */ 
     
    483483        poDS->bNoDataSet = TRUE; 
    484484        poDS->dfNoDataValue = atof(pszNoData); 
    485          
    486         if( strchr(pszNoData, '.' ) != NULL ) 
    487             eNoDataType = GDT_Float32; 
    488485    } 
    489486     
     
    535532    CPLAssert( NULL != poDS->fp ); 
    536533 
    537     /* Use type of nodata value. */ 
    538     if( poDS->bNoDataSet && eNoDataType == GDT_Float32 ) 
     534    /* Use bigger data type. */ 
     535    if( poDS->bNoDataSet 
     536        && ( SHRT_MIN > poDS->dfNoDataValue || poDS->dfNoDataValue > SHRT_MAX) ) 
    539537    { 
    540538        eDataType = GDT_Float32;