Changeset 13424
- Timestamp:
- 12/21/07 08:23:54 (5 months ago)
- Files:
-
- branches/1.5/autotest/gdrivers/adrg.py (modified) (4 diffs)
- branches/1.5/gdal/frmts/adrg/adrgdataset.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.5/autotest/gdrivers/adrg.py
r12708 r13424 1 1 #!/usr/bin/env python 2 2 ############################################################################### 3 # $Id: png.py 12180 2007-09-17 20:40:27Z warmerdam$3 # $Id: adrg.py $ 4 4 # 5 5 # Project: GDAL/OGR Test Suite … … 50 50 def adrg_2(): 51 51 52 # tst = gdaltest.GDALTest( 'ADRG', 'SMALL_ADRG/ABCDEF01.GEN', 1, 62833 )53 54 # return tst.testCreateCopy()55 56 52 drv = gdal.GetDriverByName( 'ADRG' ) 57 53 srcds = gdal.Open( 'data/SMALL_ADRG/ABCDEF01.GEN' ) … … 59 55 dstds = drv.CreateCopy( 'tmp/ABCDEF01.GEN', srcds ) 60 56 57 chksum = dstds.GetRasterBand(1).Checksum() 58 59 if chksum != 62833: 60 gdaltest.post_reason('Wrong checksum') 61 return 'fail' 62 61 63 dstds = None 62 64 … … 65 67 return 'success' 66 68 67 ###############################################################################68 # Verify the geotransform, colormap, and nodata setting for test file.69 70 def png_3():71 72 ds = gdal.Open( 'data/test.png' )73 cm = ds.GetRasterBand(1).GetRasterColorTable()74 if cm.GetCount() != 16 \75 or cm.GetColorEntry(0) != (255,255,255,0) \76 or cm.GetColorEntry(1) != (255,255,208,255):77 gdaltest.post_reason( 'Wrong colormap entries' )78 return 'fail'79 80 cm = None81 82 if int(ds.GetRasterBand(1).GetNoDataValue()) != 0:83 gdaltest.post_reason( 'Wrong nodata value.' )84 return 'fail'85 86 # This geotransform test is also verifying the fix for bug 1414, as87 # the world file is in a mixture of numeric representations for the88 # numbers. (mixture of "," and "." in file)89 90 gt_expected = (700000.305, 0.38, 0.01, 4287500.695, -0.01, -0.38)91 92 gt = ds.GetGeoTransform()93 for i in range(6):94 if abs(gt[i] - gt_expected[i]) > 0.0001:95 print 'expected:', gt_expected96 print 'got:', gt97 98 gdaltest.post_reason( 'Mixed locale world file read improperly.' )99 return 'fail'100 101 return 'success'102 103 ###############################################################################104 # Test RGB mode creation and reading.105 106 def png_4():107 108 tst = gdaltest.GDALTest( 'PNG', 'rgb.ntf', 3, 21349 )109 110 return tst.testCreateCopy()111 69 112 70 ############################################################################### 113 # Test RGBA 16bit read support.71 # Cleanup procedure 114 72 115 def png_5():73 def adrg_cleanup(): 116 74 117 tst = gdaltest.GDALTest( 'PNG', 'rgba16.png', 3, 1815 ) 118 return tst.testOpen() 119 120 ############################################################################### 121 # Test RGBA 16bit mode creation and reading. 122 123 def png_6(): 124 125 tst = gdaltest.GDALTest( 'PNG', 'rgba16.png', 4, 4873 ) 126 127 return tst.testCreateCopy() 128 129 ############################################################################### 130 # Test RGB NODATA_VALUES metadata write (and read) support. 131 # This is handled via the tRNS block in PNG. 132 133 def png_7(): 134 135 drv = gdal.GetDriverByName( 'PNG' ) 136 srcds = gdal.Open( 'data/tbbn2c16.png' ) 137 138 dstds = drv.CreateCopy( 'tmp/png7.png', srcds ) 139 srcds = None 140 141 dstds = gdal.Open( 'tmp/png7.png' ) 142 md = dstds.GetMetadata() 143 dstds = None 144 145 if md['NODATA_VALUES'] != '32639 32639 32639': 146 gdaltest.post_reason( 'NODATA_VALUES wrong' ) 147 return 'fail' 148 149 dstds = None 150 151 drv.Delete( 'tmp/png7.png' ) 75 try: 76 os.remove('tmp/ABCDEF01.IMG') 77 os.remove('tmp/TRANSH01.THF') 78 except: 79 pass 152 80 153 81 return 'success' 154 82 155 83 ############################################################################### 156 84 gdaltest_list = [ 157 85 adrg_1, 158 adrg_2 ] 86 adrg_2, 87 adrg_cleanup ] 159 88 160 89 if __name__ == '__main__': branches/1.5/gdal/frmts/adrg/adrgdataset.cpp
r12833 r13424 213 213 } 214 214 CPLDebug("ADRG", "(%d,%d) -> nBlock = %d", nBlockXOff, nBlockYOff, nBlock); 215 216 if (poDS->bCreation) 217 { 218 memset(pImage, 0, 128 * 128); 219 return CE_None; 220 } 221 215 222 216 if (poDS->TILEINDEX) 223 217 { … … 1268 1262 CPLString fileName(poOpenInfo->pszFilename); 1269 1263 CPLString NAM; 1270 1264 1265 if( poOpenInfo->eAccess == GA_Update ) 1266 { 1267 CPLError( CE_Failure, CPLE_NotSupported, 1268 "The ADRG driver does not support update access to existing" 1269 " datasets.\n" ); 1270 return NULL; 1271 } 1272 1271 1273 if (EQUAL(CPLGetExtension((const char*)fileName), "thf")) 1272 1274 { … … 1370 1372 /* Initialize any PAM information. */ 1371 1373 /* -------------------------------------------------------------------- */ 1372 //poDS->SetDescription( poOpenInfo->pszFilename );1373 //poDS->TryLoadXML();1374 poDS->SetDescription( poOpenInfo->pszFilename ); 1375 poDS->TryLoadXML(); 1374 1376 1375 1377 } … … 1395 1397 1396 1398 /************************************************************************/ 1397 /* Open()*/1399 /* Create() */ 1398 1400 /************************************************************************/ 1399 1401 … … 1472 1474 1473 1475 CPLString imgFilename = CPLResetExtension(pszFilename, "IMG"); 1474 FILE* fdIMG = VSIFOpenL((const char*)imgFilename, "w b");1476 FILE* fdIMG = VSIFOpenL((const char*)imgFilename, "w+b"); 1475 1477 if (fdIMG == NULL) 1476 1478 {
