Changeset 19310


Ignore:
Timestamp:
Apr 4, 2010 11:01:58 AM (6 years ago)
Author:
rouault
Message:

Test reading NITF with ICORDS=U (UTM MGRS)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autotest/gdrivers/nitf.py

    r19304 r19310  
    3636import struct
    3737import shutil
     38from sys import version_info
    3839
    3940sys.path.append( '../pymod' )
     
    14171418
    14181419    if gt != (100000.0, 10.0, 0.0, 5000000.0, 0.0, -10.0):
     1420        gdaltest.post_reason('did not get expected geotransform')
     1421        print(gt)
     1422        return 'fail'
     1423
     1424    return 'success'
     1425
     1426###############################################################################
     1427# Test reading UTM MGRS
     1428
     1429def nitf_53():
     1430
     1431    ds = gdal.GetDriverByName('NITF').Create('tmp/nitf53.ntf', 2, 2, options = ['ICORDS=N'])
     1432    ds = None
     1433
     1434    f = open('tmp/nitf53.ntf', 'rb+')
     1435
     1436    # Patch ICORDS and IGEOLO
     1437    f.seek(775)
     1438    if version_info >= (3,0,0):
     1439        exec("f.write(b'U')")
     1440        exec("f.write(b'31UBQ1000040000')")
     1441        exec("f.write(b'31UBQ2000040000')")
     1442        exec("f.write(b'31UBQ2000030000')")
     1443        exec("f.write(b'31UBQ1000030000')")
     1444    else:
     1445        f.write('U')
     1446        f.write('31UBQ1000040000')
     1447        f.write('31UBQ2000040000')
     1448        f.write('31UBQ2000030000')
     1449        f.write('31UBQ1000030000')
     1450
     1451    f.close()
     1452
     1453    ds = gdal.Open('tmp/nitf53.ntf')
     1454    wkt = ds.GetProjectionRef()
     1455    gt = ds.GetGeoTransform()
     1456    ds = None
     1457
     1458    if wkt != """PROJCS["UTM Zone 31, Northern Hemisphere",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]""":
     1459        gdaltest.post_reason('did not get expected SRS')
     1460        print(wkt)
     1461        return 'fail'
     1462
     1463    if gt != (205000.0, 10000.0, 0.0, 5445000.0, 0.0, -10000.0):
    14191464        gdaltest.post_reason('did not get expected geotransform')
    14201465        print(gt)
     
    21012146    try:
    21022147        gdal.GetDriverByName('NITF').Delete( 'tmp/nitf52.ntf' )
     2148    except:
     2149        pass
     2150
     2151    try:
     2152        gdal.GetDriverByName('NITF').Delete( 'tmp/nitf53.ntf' )
    21032153    except:
    21042154        pass
     
    21652215    nitf_51,
    21662216    nitf_52,
     2217    nitf_53,
    21672218    nitf_online_1,
    21682219    nitf_online_2,
Note: See TracChangeset for help on using the changeset viewer.