Changeset 11144

Show
Ignore:
Timestamp:
04/01/07 16:08:20 (2 years ago)
Author:
mloskot
Message:

Added tests related to Ticket #1000.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/autotest/gdrivers/hfa.py

    r11109 r11144  
    102102     
    103103############################################################################### 
    104 # Verify we can read suspicious int data
    105  
    106 def hfa_int_read(): 
     104# Verify we can read metadata of int.img
     105 
     106def hfa_int_stats_1(): 
    107107 
    108108    ds = gdal.Open('data/int.img') 
     
    141141 
    142142############################################################################### 
    143 # Verify we can read suspicious int data statistics
    144  
    145 def hfa_int_stats(): 
     143# Verify we can read band statistics of int.img
     144 
     145def hfa_int_stats_2(): 
    146146 
    147147    ds = gdal.Open('data/int.img') 
     
    170170 
    171171############################################################################### 
    172 # Verify we can read suspicious int data
    173  
    174 def hfa_float_read(): 
     172# Verify we can read metadata of float.img
     173 
     174def hfa_float_stats_1(): 
    175175 
    176176    ds = gdal.Open('data/float.img') 
     
    217217 
    218218############################################################################### 
    219 # Verify we can read suspicious float data statistics
    220  
    221 def hfa_float_stats(): 
     219# Verify we can read band statistics of float.img
     220 
     221def hfa_float_stats_2(): 
    222222 
    223223    ds = gdal.Open('data/float.img') 
     
    245245    return 'success' 
    246246 
     247############################################################################### 
     248# Verify we can read image data. 
     249 
     250def hfa_int_read(): 
     251 
     252    ds = gdal.Open('data/int.img') 
     253    band = ds.GetRasterBand(1) 
     254    cs = band.Checksum() 
     255    data = band.ReadRaster(100, 100, 1, 1) 
     256    ds = None 
     257 
     258    if cs != 6691: 
     259        gdaltest.post_reason( 'Checksum value is wrong.' ) 
     260        return 'fail' 
     261 
     262    return 'success' 
     263 
     264############################################################################### 
     265# Verify we can read image data. 
     266 
     267def hfa_float_read(): 
     268 
     269    ds = gdal.Open('data/float.img') 
     270    band = ds.GetRasterBand(1) 
     271    cs = band.Checksum() 
     272    data = band.ReadRaster(100, 100, 1, 1) 
     273    ds = None 
     274 
     275    if cs != 23529: 
     276        gdaltest.post_reason( 'Checksum value is wrong.' ) 
     277        return 'fail' 
     278 
     279    # Read raw data into tuple of float numbers 
     280    import struct 
     281    value = struct.unpack('f' * 1, data)[0] 
     282 
     283    if abs(value - 41.021659851074219) > 0.0001: 
     284        gdaltest.post_reason( 'Pixel value is wrong.' ) 
     285        return 'fail' 
     286 
     287    return 'success' 
     288  
    247289############################################################################### 
    248290# 
     
    251293    hfa_histread, 
    252294    hfa_histwrite, 
     295    hfa_int_stats_1, 
     296    hfa_int_stats_2, 
     297    hfa_float_stats_1, 
     298    hfa_float_stats_2, 
    253299    hfa_int_read, 
    254     hfa_int_stats, 
    255     hfa_float_read, 
    256     hfa_float_stats ] 
     300    hfa_float_read] 
    257301 
    258302if __name__ == '__main__':