Changeset 14448
- Timestamp:
- 05/11/08 13:47:47 (2 months ago)
- Files:
-
- trunk/autotest/gdrivers/nitf.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/autotest/gdrivers/nitf.py
r14446 r14448 63 63 return tst.testCreateCopy() 64 64 65 65 66 ############################################################################### 66 67 # Test direction creation of an NITF file. 67 68 68 def nitf_4(): 69 def nitf_create(creation_options): 70 69 71 drv = gdal.GetDriverByName( 'NITF' ) 70 ds = drv.Create( 'tmp/test_4.ntf', 200, 100, 3, gdal.GDT_Byte, 71 [ 'ICORDS=G' ] ) 72 73 try: 74 os.remove( 'tmp/test_create.ntf' ) 75 except: 76 pass 77 78 ds = drv.Create( 'tmp/test_create.ntf', 200, 100, 3, gdal.GDT_Byte, 79 creation_options ) 72 80 ds.SetGeoTransform( (100, 0.1, 0.0, 30.0, 0.0, -0.1 ) ) 73 81 … … 89 97 90 98 ############################################################################### 91 # Verify previous file 92 93 def nitf_5(): 94 ds = gdal.Open( 'tmp/test_4.ntf' ) 99 # Test direction creation of an non-compressed NITF file. 100 101 def nitf_4(): 102 103 return nitf_create([ 'ICORDS=G' ]) 104 105 106 ############################################################################### 107 # Verify created file 108 109 def nitf_check_created_file(checksum1, checksum2, checksum3): 110 ds = gdal.Open( 'tmp/test_create.ntf' ) 95 111 96 112 chksum = ds.GetRasterBand(1).Checksum() 97 chksum_expect = 32498113 chksum_expect = checksum1 98 114 if chksum != chksum_expect: 99 115 gdaltest.post_reason( 'Did not get expected chksum for band 1' ) … … 102 118 103 119 chksum = ds.GetRasterBand(2).Checksum() 104 chksum_expect = 42602120 chksum_expect = checksum2 105 121 if chksum != chksum_expect: 106 122 gdaltest.post_reason( 'Did not get expected chksum for band 2' ) … … 109 125 110 126 chksum = ds.GetRasterBand(3).Checksum() 111 chksum_expect = 38982127 chksum_expect = checksum3 112 128 if chksum != chksum_expect: 113 129 gdaltest.post_reason( 'Did not get expected chksum for band 3' ) … … 141 157 142 158 return 'success' 159 160 ############################################################################### 161 # Verify file created by nitf_4() 162 163 def nitf_5(): 164 165 return nitf_check_created_file(32498, 42602, 38982) 143 166 144 167 ############################################################################### … … 483 506 return tst.testCreateCopy() 484 507 508 ############################################################################### 509 # Test Create() with IC=NC compression, and multi-blocks 510 511 def nitf_27(): 512 513 if nitf_create([ 'ICORDS=G', 'IC=NC', 'BLOCKXSIZE=10', 'BLOCKYSIZE=10' ]) != 'success': 514 return 'fail' 515 516 return nitf_check_created_file(32498, 42602, 38982) 517 518 519 ############################################################################### 520 # Test Create() with IC=C8 compression 521 522 def nitf_28(): 523 try: 524 jp2ecw_drv = gdal.GetDriverByName( 'JP2ECW' ) 525 except: 526 return 'skip' 527 528 if nitf_create([ 'ICORDS=G', 'IC=C8' ]) != 'success': 529 return 'fail' 530 531 return nitf_check_created_file(32398, 42502, 38882) 532 533 ############################################################################### 534 # Test Create() with a LUT 535 536 def nitf_29(): 537 538 drv = gdal.GetDriverByName( 'NITF' ) 539 540 ds = drv.Create( 'tmp/test_29.ntf', 1, 1, 1, gdal.GDT_Byte, 541 [ 'IREP=RGB/LUT', 'LUT_SIZE=128' ] ) 542 543 ct = gdal.ColorTable() 544 ct.SetColorEntry( 0, (255,255,255,255) ) 545 ct.SetColorEntry( 1, (255,255,0,255) ) 546 ct.SetColorEntry( 2, (255,0,255,255) ) 547 ct.SetColorEntry( 3, (0,255,255,255) ) 548 549 ds.GetRasterBand( 1 ).SetRasterColorTable( ct ) 550 551 ds = None 552 553 ds = gdal.Open( 'tmp/test_29.ntf' ) 554 555 ct = ds.GetRasterBand( 1 ).GetRasterColorTable() 556 if ct.GetCount() != 129 or \ 557 ct.GetColorEntry(0) != (255,255,255,255) or \ 558 ct.GetColorEntry(1) != (255,255,0,255) or \ 559 ct.GetColorEntry(2) != (255,0,255,255) or \ 560 ct.GetColorEntry(3) != (0,255,255,255): 561 gdaltest.post_reason( 'Wrong color table entry.' ) 562 return 'fail' 563 564 ds = None 565 566 return 'success' 485 567 486 568 ############################################################################### … … 673 755 def nitf_cleanup(): 674 756 try: 675 gdal.GetDriverByName('NITF').Delete( 'tmp/test_ 4.ntf' )757 gdal.GetDriverByName('NITF').Delete( 'tmp/test_create.ntf' ) 676 758 except: 677 759 pass … … 684 766 try: 685 767 gdal.GetDriverByName('NITF').Delete( 'tmp/test_13.ntf' ) 768 except: 769 pass 770 771 try: 772 gdal.GetDriverByName('NITF').Delete( 'tmp/test_29.ntf' ) 686 773 except: 687 774 pass … … 716 803 nitf_25, 717 804 nitf_26, 805 nitf_27, 806 nitf_28, 807 nitf_29, 718 808 nitf_online_1, 719 809 nitf_online_2,
