Changeset 14438

Show
Ignore:
Timestamp:
05/10/08 17:14:47 (2 months ago)
Author:
rouault
Message:

Extend test suite for NITF, in particular with some tests that use gdaltest.download_file from previous commit

Files:

Legend:

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

    r14424 r14438  
    344344 
    345345############################################################################### 
     346# Test NITF file without image segment 
     347 
     348def nitf_18(): 
     349 
     350    # Shut up the warning about missing image segment 
     351    gdal.PushErrorHandler( 'CPLQuietErrorHandler' ) 
     352    # From http://www.gwg.nga.mil/ntb/baseline/software/testfile/Nitfv1_1/U_0006A.NTF 
     353    ds = gdal.Open("data/U_0006A.NTF") 
     354    gdal.PopErrorHandler() 
     355 
     356    if ds.RasterCount != 0: 
     357        return 'fail' 
     358 
     359    return 'success' 
     360 
     361############################################################################### 
     362# Test BILEVEL (C1) decompression 
     363 
     364def nitf_19(): 
     365 
     366    # From http://www.gwg.nga.mil/ntb/baseline/software/testfile/Nitfv2_0/U_1050A.NTF 
     367    tst = gdaltest.GDALTest( 'NITF', 'U_1050A.NTF', 1, 65024 ) 
     368 
     369    return tst.testOpen() 
     370 
     371 
     372############################################################################### 
     373# Test NITF file consiting only of an header 
     374 
     375def nitf_20(): 
     376 
     377    # Shut up the warning about file either corrupt or empty 
     378    gdal.PushErrorHandler( 'CPLQuietErrorHandler' ) 
     379    # From http://www.gwg.nga.mil/ntb/baseline/software/testfile/Nitfv1_1/U_0002A.NTF 
     380    ds = gdal.Open("data/U_0002A.NTF") 
     381    gdal.PopErrorHandler() 
     382 
     383    if ds is not None: 
     384        return 'fail' 
     385 
     386    return 'success' 
     387 
     388############################################################################### 
     389# Test NITF21_CGM_ANNO_Uncompressed_unmasked.ntf for bug #1313 and #1714 
     390 
     391def nitf_online_1(): 
     392 
     393    if not gdaltest.download_file('http://download.osgeo.org/gdal/data/nitf/bugs/NITF21_CGM_ANNO_Uncompressed_unmasked.ntf', 'NITF21_CGM_ANNO_Uncompressed_unmasked.ntf'): 
     394        return 'skip' 
     395 
     396    tst = gdaltest.GDALTest( 'NITF', 'tmp/cache/NITF21_CGM_ANNO_Uncompressed_unmasked.ntf', 1, 13123, filename_absolute = 1 ) 
     397 
     398    # Shut up the warning about missing image segment 
     399    gdal.PushErrorHandler( 'CPLQuietErrorHandler' ) 
     400    ret = tst.testOpen() 
     401    gdal.PopErrorHandler() 
     402 
     403    return ret 
     404 
     405############################################################################### 
     406# Test NITF file with multiple images 
     407 
     408def nitf_online_2(): 
     409 
     410    if not gdaltest.download_file('http://download.osgeo.org/gdal/data/nitf/nitf1.1/U_0001a.ntf', 'U_0001a.ntf'): 
     411        return 'skip' 
     412 
     413    ds = gdal.Open( 'tmp/cache/U_0001a.ntf' ) 
     414 
     415    md = ds.GetMetadata('SUBDATASETS') 
     416    if not md.has_key('SUBDATASET_1_NAME'): 
     417        gdaltest.post_reason( 'missing SUBDATASET_1_NAME metadata' ) 
     418        return 'fail' 
     419    ds = None 
     420 
     421    return 'success' 
     422 
     423############################################################################### 
     424# Test ARIDPCM (C2) image 
     425 
     426def nitf_online_3(): 
     427 
     428    if not gdaltest.download_file('http://download.osgeo.org/gdal/data/nitf/nitf1.1/U_0001a.ntf', 'U_0001a.ntf'): 
     429        return 'skip' 
     430 
     431    tst = gdaltest.GDALTest( 'NITF', 'NITF_IM:3:tmp/cache/U_0001a.ntf', 1, 23463, filename_absolute = 1 ) 
     432 
     433    return tst.testOpen() 
     434 
     435############################################################################### 
     436# Test Vector Quantization (VQ) (C4) file 
     437 
     438def nitf_online_4(): 
     439 
     440    if not gdaltest.download_file('http://download.osgeo.org/gdal/data/nitf/cadrg/001zc013.on1', '001zc013.on1'): 
     441        return 'skip' 
     442 
     443    tst = gdaltest.GDALTest( 'NITF', 'tmp/cache/001zc013.on1', 1, 53960, filename_absolute = 1 ) 
     444 
     445    return tst.testOpen() 
     446 
     447############################################################################### 
     448# Test Vector Quantization (VQ) (M4) file 
     449 
     450def nitf_online_5(): 
     451 
     452    if not gdaltest.download_file('http://download.osgeo.org/gdal/data/nitf/cadrg/overview.ovr', 'overview.ovr'): 
     453        return 'skip' 
     454 
     455    tst = gdaltest.GDALTest( 'NITF', 'tmp/cache/overview.ovr', 1, 60699, filename_absolute = 1 ) 
     456 
     457    return tst.testOpen() 
     458 
     459############################################################################### 
     460# Test a JPEG compressed, single blocked 2048x2048 mono image 
     461 
     462def nitf_online_6(): 
     463 
     464    if not gdaltest.download_file('http://download.osgeo.org/gdal/data/nitf/nitf2.0/U_4001b.ntf', 'U_4001b.ntf'): 
     465        return 'skip' 
     466 
     467    tst = gdaltest.GDALTest( 'NITF', 'tmp/cache/U_4001b.ntf', 1, 60030, filename_absolute = 1 ) 
     468 
     469    return tst.testOpen() 
     470 
     471 
     472############################################################################### 
     473# Test all combinations of IMODE (S,P,B,R) for an image with 6 bands whose 3 are RGB 
     474 
     475def nitf_online_7(): 
     476 
     477    files = [ 'ns3228b.nsf', 'i_3228c.ntf', 'ns3228d.nsf', 'i_3228e.ntf' ] 
     478    for file in files: 
     479        if not gdaltest.download_file('http://www.gwg.nga.mil/ntb/baseline/software/testfile/Nitfv2_1/' + file, file): 
     480            return 'skip' 
     481 
     482        ds = gdal.Open('tmp/cache/' + file) 
     483        if ds.RasterCount != 6: 
     484            return 'fail' 
     485 
     486        checksums = [ 48385, 48385, 40551, 54223, 48385, 33094 ] 
     487        colorInterpretations = [ gdal.GCI_Undefined, gdal.GCI_Undefined, gdal.GCI_RedBand, gdal.GCI_BlueBand, gdal.GCI_Undefined, gdal.GCI_GreenBand ] 
     488 
     489        for i in range(6): 
     490            if ds.GetRasterBand(i+1).Checksum() != checksums[i]: 
     491                return 'fail' 
     492            if ds.GetRasterBand(i+1).GetRasterColorInterpretation() != colorInterpretations[i]: 
     493                return 'fail' 
     494        ds = None 
     495 
     496    return 'success' 
     497 
     498############################################################################### 
     499# Test JPEG-compressed multi-block mono-band image with a data mask subheader (IC=M3, IMODE=B) 
     500 
     501def nitf_online_8(): 
     502 
     503    if not gdaltest.download_file('http://www.gwg.nga.mil/ntb/baseline/software/testfile/Nitfv2_1/ns3301j.nsf', 'ns3301j.nsf'): 
     504        return 'skip' 
     505 
     506    tst = gdaltest.GDALTest( 'NITF', 'tmp/cache/ns3301j.nsf', 1, 56861, filename_absolute = 1 ) 
     507 
     508    return tst.testOpen() 
     509 
     510 
     511############################################################################### 
     512# Test JPEG-compressed multi-block mono-band image without a data mask subheader (IC=C3, IMODE=B) 
     513 
     514def nitf_online_9(): 
     515 
     516    if not gdaltest.download_file('http://www.gwg.nga.mil/ntb/baseline/software/testfile/Nitfv2_1/ns3304a.nsf', 'ns3304a.nsf'): 
     517        return 'skip' 
     518 
     519    tst = gdaltest.GDALTest( 'NITF', 'tmp/cache/ns3304a.nsf', 1, 32419, filename_absolute = 1 ) 
     520 
     521    return tst.testOpen() 
     522 
     523 
     524############################################################################### 
    346525# Cleanup. 
    347526 
     
    382561    nitf_16, 
    383562    nitf_17, 
     563    nitf_18, 
     564    nitf_19, 
     565    nitf_20, 
     566    nitf_online_1, 
     567    nitf_online_2, 
     568    nitf_online_3, 
     569    nitf_online_4, 
     570    nitf_online_5, 
     571    nitf_online_6, 
     572    nitf_online_7, 
     573    nitf_online_8, 
     574    nitf_online_9, 
    384575    nitf_cleanup ] 
    385576