Ejemplo n.º 1
0
def osr_compd_6():

    if not osr_proj4.have_proj480():
        return 'skip'

    srs = osr.SpatialReference()
    srs.SetFromUserInput(
        '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +geoidgrids=g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx +vunits=us-ft +no_defs '
    )

    if srs.Validate() != 0:
        gdaltest.post_reason('Does not validate')
        return 'fail'

    exp_wkt = """COMPD_CS["UTM Zone 11, Northern Hemisphere + Unnamed Vertical Datum",
    PROJCS["UTM Zone 11, Northern Hemisphere",
        GEOGCS["GRS 1980(IUGG, 1980)",
            DATUM["unknown",
                SPHEROID["GRS80",6378137,298.257222101],
                TOWGS84[0,0,0,0,0,0,0]],
            PRIMEM["Greenwich",0],
            UNIT["degree",0.0174532925199433]],
        PROJECTION["Transverse_Mercator"],
        PARAMETER["latitude_of_origin",0],
        PARAMETER["central_meridian",-117],
        PARAMETER["scale_factor",0.9996],
        PARAMETER["false_easting",500000],
        PARAMETER["false_northing",0],
        UNIT["Meter",1]],
    VERT_CS["Unnamed",
        VERT_DATUM["Unnamed",2005,
            EXTENSION["PROJ4_GRIDS","g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"]],
        UNIT["Foot_US",0.3048006096012192],
        AXIS["Up",UP]]]"""

    wkt = srs.ExportToPrettyWkt()

    if gdaltest.equal_srs_from_wkt(exp_wkt, wkt) == 0:
        gdaltest.post_reason('fail')
        return 'fail'
    elif exp_wkt != wkt:
        print('warning they are equivalent, but not completely the same')
        print(wkt)

    if wkt.find('g2003conus.gtx') == -1:
        gdaltest.post_reason('Did not get PROJ4_GRIDS EXTENSION node')
        return 'fail'

    exp_proj4 = '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +geoidgrids=g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx +vunits=us-ft +no_defs '
    proj4 = srs.ExportToProj4()
    if proj4 != exp_proj4:
        gdaltest.post_reason('Did not get expected proj.4 string, got:' +
                             proj4)
        return 'fail'

    return 'success'
Ejemplo n.º 2
0
def osr_compd_6():

    if not osr_proj4.have_proj480():
        return 'skip'

    srs = osr.SpatialReference()
    srs.SetFromUserInput( '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +geoidgrids=g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx +vunits=us-ft +no_defs ' )

    if srs.Validate() != 0:
        gdaltest.post_reason( 'Does not validate' )
        return 'fail'

    exp_wkt = """COMPD_CS["UTM Zone 11, Northern Hemisphere + Unnamed Vertical Datum",
    PROJCS["UTM Zone 11, Northern Hemisphere",
        GEOGCS["GRS 1980(IUGG, 1980)",
            DATUM["unknown",
                SPHEROID["GRS80",6378137,298.257222101],
                TOWGS84[0,0,0,0,0,0,0]],
            PRIMEM["Greenwich",0],
            UNIT["degree",0.0174532925199433]],
        PROJECTION["Transverse_Mercator"],
        PARAMETER["latitude_of_origin",0],
        PARAMETER["central_meridian",-117],
        PARAMETER["scale_factor",0.9996],
        PARAMETER["false_easting",500000],
        PARAMETER["false_northing",0],
        UNIT["Meter",1]],
    VERT_CS["Unnamed",
        VERT_DATUM["Unnamed",2005,
            EXTENSION["PROJ4_GRIDS","g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"]],
        UNIT["Foot_US",0.3048006096012192],
        AXIS["Up",UP]]]"""

    wkt = srs.ExportToPrettyWkt()

    if gdaltest.equal_srs_from_wkt( exp_wkt, wkt ) == 0:
        gdaltest.post_reason('fail')
        return 'fail'
    elif exp_wkt != wkt:
        print('warning they are equivalent, but not completely the same')
        print(wkt)

    if wkt.find('g2003conus.gtx') == -1:
        gdaltest.post_reason( 'Did not get PROJ4_GRIDS EXTENSION node' )
        return 'fail'

    exp_proj4 = '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +geoidgrids=g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx +vunits=us-ft +no_defs '
    proj4 = srs.ExportToProj4()
    if proj4 != exp_proj4:
        gdaltest.post_reason( 'Did not get expected proj.4 string, got:' + proj4 )
        return 'fail'

    return 'success'