Esempio n. 1
0
def test_ogr_gmt_cleanup():

    if gdaltest.gmt_ds is not None:
        gdaltest.gmt_lyr = None
        gdaltest.gmt_ds = None

    gdaltest.clean_tmp()
Esempio n. 2
0
def hdf5_6():

    if gdaltest.hdf5_drv is None:
        return 'skip'

    shutil.copyfile( 'data/groups.h5', 'tmp/groups.h5' )

    ds = gdal.Open( 'HDF5:"tmp/groups.h5"://MyGroup/dset1' )
    ds.BuildOverviews( overviewlist = [2] )
    ds = None

    ds = gdal.Open( 'HDF5:"tmp/groups.h5"://MyGroup/dset1' )
    if ds.GetRasterBand(1).GetOverviewCount() != 1:
        gdaltest.post_reason( 'failed to find overview' )
        return 'fail'
    ds = None

    # confirm that it works with a different path. (#3290)

    ds = gdal.Open( 'HDF5:"data/../tmp/groups.h5"://MyGroup/dset1' )
    if ds.GetRasterBand(1).GetOverviewCount() != 1:
        gdaltest.post_reason( 'failed to find overview with alternate path' )
        return 'fail'
    ovfile = ds.GetMetadataItem('OVERVIEW_FILE','OVERVIEWS')
    if ovfile[:11] != 'data/../tmp':
        print(ovfile)
        gdaltest.post_reason( 'did not get expected OVERVIEW_FILE.' )
        return 'fail'
    ds = None


    gdaltest.clean_tmp()

    return 'success'
Esempio n. 3
0
def test_ogr_dgn_cleanup():

    if gdaltest.dgn_ds is not None:
        gdaltest.dgn_lyr = None
        gdaltest.dgn_ds = None

    gdaltest.clean_tmp()
Esempio n. 4
0
def ogr_gml_cleanup():
    if not gdaltest.have_gml_reader:
        return 'skip'

    gdaltest.clean_tmp()

    return ogr_gml_clean_files()
Esempio n. 5
0
def ogr_s57_online_3():

    if not gdaltest.download_file('http://download.osgeo.org/gdal/data/s57/enctds/GB5X01SW.001', 'GB5X01SW.001'):
        return 'skip'

    shutil.copy( 'tmp/cache/GB5X01SW.001', 'tmp/GB5X01SW.001' )
    ds = ogr.Open( 'tmp/GB5X01SW.000' )
    if ds is None:
        return 'fail'

    lyr = ds.GetLayerByName('LIGHTS')
    feat = lyr.GetFeature(542)

    if feat is None:
        gdaltest.post_reason( 'Did not get expected feature at all.' )
        return 'fail'

    if feat.rver != 2:
        gdaltest.post_reason( 'Did not get expected RVER value (%d).' % feat.rver )
        return 'fail'

    lyr = ds.GetLayerByName('BOYCAR')
    feat = lyr.GetFeature(975)
    if feat is None:
        gdaltest.post_reason( 'unexpected did not get feature id 975 '
                              'after update!' )
        return 'fail'

    feat = None

    ds = None

    gdaltest.clean_tmp()

    return 'success'
Esempio n. 6
0
def hdf5_6():

    if gdaltest.hdf5_drv is None:
        return 'skip'

    shutil.copyfile( 'data/groups.h5', 'tmp/groups.h5' )

    ds = gdal.Open( 'HDF5:"tmp/groups.h5"://MyGroup/dset1' )
    ds.BuildOverviews( overviewlist = [2] )
    ds = None

    ds = gdal.Open( 'HDF5:"tmp/groups.h5"://MyGroup/dset1' )
    if ds.GetRasterBand(1).GetOverviewCount() != 1:
        gdaltest.post_reason( 'failed to find overview' )
        return 'fail'
    ds = None

    # confirm that it works with a different path. (#3290)

    ds = gdal.Open( 'HDF5:"data/../tmp/groups.h5"://MyGroup/dset1' )
    if ds.GetRasterBand(1).GetOverviewCount() != 1:
        gdaltest.post_reason( 'failed to find overview with alternate path' )
        return 'fail'
    ovfile = ds.GetMetadataItem('OVERVIEW_FILE','OVERVIEWS')
    if ovfile[:11] != 'data/../tmp':
        print(ovfile)
        gdaltest.post_reason( 'did not get expected OVERVIEW_FILE.' )
        return 'fail'
    ds = None


    gdaltest.clean_tmp()

    return 'success'
Esempio n. 7
0
def test_ogr_gmt_cleanup():

    if gdaltest.gmt_ds is not None:
        gdaltest.gmt_lyr = None
        gdaltest.gmt_ds = None

    gdaltest.clean_tmp()
Esempio n. 8
0
def ogr_s57_online_2():
    if gdaltest.s57_ds is None:
        return 'skip'

    if not gdaltest.download_file('http://download.osgeo.org/gdal/data/s57/enctds/GB5X01SW.000', 'GB5X01SW.000'):
        return 'skip'

    gdaltest.clean_tmp()
    shutil.copy( 'tmp/cache/GB5X01SW.000', 'tmp/GB5X01SW.000' )
    ds = ogr.Open( 'tmp/GB5X01SW.000' )
    if ds is None:
        return 'fail'

    lyr = ds.GetLayerByName('LIGHTS')
    feat = lyr.GetFeature(542)

    if feat is None:
        gdaltest.post_reason( 'Did not get expected feature at all.' )
        return 'fail'

    if feat.rver != 1:
        gdaltest.post_reason( 'Did not get expected RVER value (%d).' % feat.rver )
        return 'fail'

    lyr = ds.GetLayerByName('BOYCAR')
    feat = lyr.GetFeature(975)
    if feat is not None:
        gdaltest.post_reason( 'unexpected got feature id 975 before update!' )
        return 'fail'

    feat = None

    ds = None

    return 'success'
Esempio n. 9
0
def test_ogr_dgn_cleanup():

    if gdaltest.dgn_ds is not None:
        gdaltest.dgn_lyr = None
        gdaltest.dgn_ds = None

    gdaltest.clean_tmp()
Esempio n. 10
0
def test_ogr_s57_online_2():

    if not gdaltest.download_file(
            'http://download.osgeo.org/gdal/data/s57/enctds/GB5X01SW.000',
            'GB5X01SW.000'):
        pytest.skip()

    gdaltest.clean_tmp()
    shutil.copy('tmp/cache/GB5X01SW.000', 'tmp/GB5X01SW.000')
    ds = ogr.Open('tmp/GB5X01SW.000')
    assert ds is not None

    lyr = ds.GetLayerByName('LIGHTS')
    feat = lyr.GetFeature(542)

    assert feat is not None, 'Did not get expected feature at all.'

    assert feat.rver == 1, ('Did not get expected RVER value (%d).' %
                            feat.rver)

    lyr = ds.GetLayerByName('BOYCAR')
    feat = lyr.GetFeature(975)
    assert feat is None, 'unexpected got feature id 975 before update!'

    feat = None

    ds = None
Esempio n. 11
0
def test_ngw_cleanup():

    if gdaltest.ngw_drv is None:
        pytest.skip()

    if check_availability(gdaltest.ngw_test_server) == False:
        gdaltest.ngw_ds = None
        gdaltest.ngw_drv = None
        pytest.skip()

    if gdaltest.group_id is not None:
        delete_url = 'NGW:' + gdaltest.ngw_test_server + '/resource/' + gdaltest.group_id

        gdaltest.ngw_ds = None

        assert gdaltest.ngw_drv.Delete(delete_url) == gdal.CE_None, \
            'Failed to delete datasource ' + delete_url + '.'

    gdaltest.ngw_ds = None
    gdaltest.clean_tmp()

    try:
        shutil.rmtree('gdalwmscache')
    except OSError:
        pass
Esempio n. 12
0
def ogr_gml_cleanup():
    if not gdaltest.have_gml_reader:
        return 'skip'
    
    gdaltest.clean_tmp()
    
    return ogr_gml_clean_files()
Esempio n. 13
0
def test_hdf5_6():

    shutil.copyfile('data/hdf5/groups.h5', 'tmp/groups.h5')

    ds = gdal.Open('HDF5:"tmp/groups.h5"://MyGroup/dset1')
    ds.BuildOverviews(overviewlist=[2])
    ds = None

    assert not gdaltest.is_file_open('tmp/groups.h5'), 'file still opened.'

    ds = gdal.Open('HDF5:"tmp/groups.h5"://MyGroup/dset1')
    assert ds.GetRasterBand(
        1).GetOverviewCount() == 1, 'failed to find overview'
    ds = None

    # confirm that it works with a different path. (#3290)

    ds = gdal.Open('HDF5:"data/../tmp/groups.h5"://MyGroup/dset1')
    assert ds.GetRasterBand(1).GetOverviewCount() == 1, \
        'failed to find overview with alternate path'
    ovfile = ds.GetMetadataItem('OVERVIEW_FILE', 'OVERVIEWS')
    assert ovfile[:11] == 'data/../tmp', 'did not get expected OVERVIEW_FILE.'
    ds = None

    gdaltest.clean_tmp()
Esempio n. 14
0
def idrisi_cleanup():
    gdaltest.clean_tmp()
    try:
        os.unlink('data/rgbsmall.tif.aux.xml')
        print('FIXME?: data/rgbsmall.tif.aux.xml is produced by those tests') 
    except:
        pass
    return 'success'
Esempio n. 15
0
def ogr_dgn_cleanup():

    if gdaltest.dgn_ds is not None:
        gdaltest.dgn_lyr = None
        gdaltest.dgn_ds = None

    gdaltest.clean_tmp()
    return 'success'
Esempio n. 16
0
def ogr_interlis_cleanup():

    if not gdaltest.have_ili_reader:
        return 'skip'

    gdaltest.clean_tmp()

    return 'success'
Esempio n. 17
0
def test_ogr_interlis_cleanup():

    if not gdaltest.have_ili_reader:
        pytest.skip()

    gdal.SetConfigOption('OGR_STROKE_CURVE', None)

    gdaltest.clean_tmp()
Esempio n. 18
0
def ogr_interlis_cleanup():

    if not gdaltest.have_ili_reader:
        return 'skip'

    gdaltest.clean_tmp()

    return 'success'
Esempio n. 19
0
def idrisi_cleanup():
    gdaltest.clean_tmp()
    try:
        os.unlink('data/rgbsmall.tif.aux.xml')
        print('FIXME?: data/rgbsmall.tif.aux.xml is produced by those tests')
    except:
        pass
    return 'success'
Esempio n. 20
0
def test_ogr_interlis_cleanup():

    if not gdaltest.have_ili_reader:
        pytest.skip()

    gdal.SetConfigOption('OGR_STROKE_CURVE', None)

    gdaltest.clean_tmp()
Esempio n. 21
0
def ogr_dgn_cleanup():

    if gdaltest.dgn_ds is not None:
        gdaltest.dgn_lyr = None
        gdaltest.dgn_ds = None

    gdaltest.clean_tmp()
    return 'success'
Esempio n. 22
0
def ogr_gmt_cleanup():

    if gdaltest.gmt_ds is not None:
        gdaltest.gmt_lyr = None
        gdaltest.gmt_ds = None

    gdaltest.clean_tmp()

    return 'success'
Esempio n. 23
0
def test_wms_cleanup():

    gdaltest.wms_ds = None
    gdaltest.clean_tmp()

    try:
        shutil.rmtree('gdalwmscache')
    except OSError:
        pass
Esempio n. 24
0
def ogr_gmt_cleanup():

    if gdaltest.gmt_ds is not None:
        gdaltest.gmt_lyr = None
        gdaltest.gmt_ds = None

    gdaltest.clean_tmp()

    return 'success'
Esempio n. 25
0
def test_wms_cleanup():

    gdaltest.wms_ds = None
    gdaltest.clean_tmp()

    try:
        shutil.rmtree('gdalwmscache')
    except OSError:
        pass
Esempio n. 26
0
def test_idrisi_cleanup():
    gdaltest.clean_tmp()
    try:
        os.unlink('data/rgbsmall.tif.aux.xml')
        os.unlink('data/real.rst.aux.xml')
        os.unlink('data/frmt09.cot.aux.xml')
        os.unlink('data/byte.rst.aux.xml')
        print('FIXME?: data/rgbsmall.tif.aux.xml is produced by those tests')
    except OSError:
        pass
Esempio n. 27
0
def ogr_interlis_cleanup():

    if not gdaltest.have_ili_reader:
        return 'skip'

    gdal.SetConfigOption('OGR_STROKE_CURVE', None)

    gdaltest.clean_tmp()

    return 'success'
Esempio n. 28
0
def test_idrisi_cleanup():
    gdaltest.clean_tmp()
    try:
        os.unlink('data/rgbsmall.tif.aux.xml')
        os.unlink('data/real.rst.aux.xml')
        os.unlink('data/frmt09.cot.aux.xml')
        os.unlink('data/byte.rst.aux.xml')
        print('FIXME?: data/rgbsmall.tif.aux.xml is produced by those tests')
    except OSError:
        pass
Esempio n. 29
0
def ogr_interlis_cleanup():

    if not gdaltest.have_ili_reader:
        return 'skip'

    gdal.SetConfigOption('OGR_STROKE_CURVE', None)

    gdaltest.clean_tmp()

    return 'success'
Esempio n. 30
0
File: wms.py Progetto: ghatwala/gdal
def wms_cleanup():

    gdaltest.wms_ds = None
    gdaltest.clean_tmp()

    try:
        shutil.rmtree('gdalwmscache')
    except:
        pass

    return 'success'
Esempio n. 31
0
def test_wms_cleanup():

    gdaltest.wms_ds = None
    gdaltest.gts = None
    gdaltest.subdatasets = None
    gdaltest.clean_tmp()

    gdal.UnlinkBatch(["/vsimem/twms.xml", "/vsimem/twms.xml.aux.xml"])
    try:
        shutil.rmtree('gdalwmscache')
    except OSError:
        pass
Esempio n. 32
0
def test_pam_cleanup():
    gdaltest.clean_tmp()
    if gdaltest.pam_setting != 'NULL':
        gdal.SetConfigOption('GDAL_PAM_ENABLED', gdaltest.pam_setting)
    else:
        gdal.SetConfigOption('GDAL_PAM_ENABLED', None)

    try:
        os.chmod('tmpdirreadonly', stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
        shutil.rmtree('tmpdirreadonly')
    except OSError:
        pass
    try:
        shutil.rmtree('tmppamproxydir')
    except OSError:
        pass
Esempio n. 33
0
def test_pam_cleanup():
    gdaltest.clean_tmp()
    if gdaltest.pam_setting != 'NULL':
        gdal.SetConfigOption('GDAL_PAM_ENABLED', gdaltest.pam_setting)
    else:
        gdal.SetConfigOption('GDAL_PAM_ENABLED', None)

    try:
        os.chmod('tmpdirreadonly', stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
        shutil.rmtree('tmpdirreadonly')
    except OSError:
        pass
    try:
        shutil.rmtree('tmppamproxydir')
    except OSError:
        pass
Esempio n. 34
0
def netcdf_2():

    if gdaltest.netcdf_drv is None:
        return 'skip'

    src_ds = gdal.Open('data/byte.tif')

    base_ds = gdaltest.netcdf_drv.CreateCopy('tmp/netcdf2.nc', src_ds)
    base_ds = None

    tst = gdaltest.GDALTest('NetCDF',
                            'tmp/netcdf2.nc',
                            1,
                            4672,
                            filename_absolute=1)

    wkt = """PROJCS["NAD27 / UTM zone 11N",
    GEOGCS["NAD27",
        DATUM["North_American_Datum_1927",
            SPHEROID["Clarke 1866",6378206.4,294.9786982139006,
                AUTHORITY["EPSG","7008"]],
            AUTHORITY["EPSG","6267"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4267"]],
    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["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","26711"]]"""

    result = tst.testOpen(check_prj=wkt)

    if result != 'success':
        return result

    gdaltest.clean_tmp()

    return 'success'
Esempio n. 35
0
def netcdf_2():

    if gdaltest.netcdf_drv is None:
        return 'skip'

    src_ds = gdal.Open( 'data/byte.tif' )
    
    base_ds = gdaltest.netcdf_drv.CreateCopy( 'tmp/netcdf2.nc', src_ds)
    del base_ds

    tst = gdaltest.GDALTest( 'NetCDF', 'tmp/netcdf2.nc',
                             1, 4672,
                             filename_absolute = 1 )

    wkt = """PROJCS["NAD27 / UTM zone 11N",
    GEOGCS["NAD27",
        DATUM["North_American_Datum_1927",
            SPHEROID["Clarke 1866",6378206.4,294.9786982139006,
                AUTHORITY["EPSG","7008"]],
            AUTHORITY["EPSG","6267"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4267"]],
    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["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","26711"]]"""

    result = tst.testOpen( check_prj = wkt )

    if result != 'success':
        return result

    gdaltest.clean_tmp()

    return 'success'
Esempio n. 36
0
def test_ngw_cleanup():

    if gdaltest.ngw_drv is None:
        pytest.skip()

    if gdaltest.group_id is not None:
        delete_url = 'NGW:' + gdaltest.ngw_test_server + '/resource/' + gdaltest.group_id

        gdaltest.ngw_layer = None
        gdaltest.ngw_ds = None

        assert gdaltest.ngw_drv.Delete(delete_url) == gdal.CE_None, \
            'Failed to delete datasource ' + delete_url + '.'

    gdaltest.ngw_ds = None
    gdaltest.clean_tmp()

    try:
        shutil.rmtree('gdalwmscache')
    except OSError:
        pass
Esempio n. 37
0
def startup_and_cleanup():

    gdaltest.ngw_test_server = 'https://sandbox.nextgis.com'

    if check_availability(gdaltest.ngw_test_server) == False:
        pytest.skip()

    yield

    if gdaltest.group_id is not None:
        delete_url = 'NGW:' + gdaltest.ngw_test_server + '/resource/' + gdaltest.group_id

        gdaltest.ngw_ds = None

        assert gdal.GetDriverByName('NGW').Delete(delete_url) == gdal.CE_None, \
            'Failed to delete datasource ' + delete_url + '.'

    gdaltest.ngw_ds = None
    gdaltest.clean_tmp()

    try:
        shutil.rmtree('gdalwmscache')
    except OSError:
        pass
Esempio n. 38
0
def test_hdf5_6():

    shutil.copyfile('data/groups.h5', 'tmp/groups.h5')

    ds = gdal.Open('HDF5:"tmp/groups.h5"://MyGroup/dset1')
    ds.BuildOverviews(overviewlist=[2])
    ds = None

    assert not gdaltest.is_file_open('tmp/groups.h5'), 'file still opened.'

    ds = gdal.Open('HDF5:"tmp/groups.h5"://MyGroup/dset1')
    assert ds.GetRasterBand(1).GetOverviewCount() == 1, 'failed to find overview'
    ds = None

    # confirm that it works with a different path. (#3290)

    ds = gdal.Open('HDF5:"data/../tmp/groups.h5"://MyGroup/dset1')
    assert ds.GetRasterBand(1).GetOverviewCount() == 1, \
        'failed to find overview with alternate path'
    ovfile = ds.GetMetadataItem('OVERVIEW_FILE', 'OVERVIEWS')
    assert ovfile[:11] == 'data/../tmp', 'did not get expected OVERVIEW_FILE.'
    ds = None

    gdaltest.clean_tmp()
Esempio n. 39
0
        lat_origin = sr.GetProjParm('latitude_of_origin')

        if lat_origin != 60:
            gdaltest.post_reason('Latitude of origin in %s does not match expected: %f'
                                 % (ifile, lat_origin))
            return 'fail'

    return 'success'

###############################################################################


gdaltest_list = [
    netcdf_cf_1,
    netcdf_cf_2,
    netcdf_cf_3,
    netcdf_cf_4,
    netcdf_cf_5,
    None]

if __name__ == '__main__':

    gdaltest.setup_run('netcdf_cf')

    gdaltest.run_tests(gdaltest_list)

    # make sure we cleanup
    gdaltest.clean_tmp()

    gdaltest.summarize()
Esempio n. 40
0
def pcidsk_cleanup():
    gdaltest.pcidsk_ds = None
    gdaltest.clean_tmp()
    return 'success'
Esempio n. 41
0
File: wms.py Progetto: garnertb/gdal
def wms_cleanup():

    gdaltest.wms_ds = None
    gdaltest.clean_tmp()
    
    return 'success'
Esempio n. 42
0
def ilwis_cleanup():
    gdaltest.clean_tmp()
    return 'success'
Esempio n. 43
0
def startup_and_cleanup():
    yield
    gdaltest.clean_tmp()
Esempio n. 44
0
def ers_cleanup():
    gdaltest.clean_tmp()
    return "success"
Esempio n. 45
0
def test_paux_cleanup():
    gdaltest.clean_tmp()
    gdal.Unlink('/vsimem/byte.tif.tst.aux.xml')
Esempio n. 46
0
def test_ilwis_cleanup():
    gdaltest.clean_tmp()
Esempio n. 47
0
def gif_cleanup():
    gdaltest.clean_tmp()
    return 'success'
Esempio n. 48
0
def paux_cleanup():
    gdaltest.clean_tmp()
    return 'success'
Esempio n. 49
0
#SetMetadata() not supported
#gdaltest_list.append( (ut.testSetMetadata, item[0]) )

# Others we do for each pixel type.
for item in init_list:
    ut = gdaltest.GDALTest('netcdf',
                           item[0],
                           item[1],
                           item[2],
                           options=item[4])
    if ut is None:
        print('GTiff tests skipped')
    gdaltest_list.append((ut.testCreateCopy, item[0]))
    gdaltest_list.append((ut.testCreate, item[0]))
    gdaltest_list.append((ut.testSetNoDataValue, item[0]))

###############################################################################
#  other tests

if __name__ == '__main__':

    gdaltest.setup_run('netcdf')

    gdaltest.run_tests(gdaltest_list)

    #make sure we cleanup
    gdaltest.clean_tmp()

    gdaltest.summarize()
Esempio n. 50
0
def test_pcidsk_cleanup():
    gdaltest.pcidsk_ds = None
    gdaltest.clean_tmp()
Esempio n. 51
0
def paux_cleanup():
    gdaltest.clean_tmp()
    return 'success'
Esempio n. 52
0
File: paux.py Progetto: hdfeos/gdal
def paux_cleanup():
    gdaltest.clean_tmp()
    gdal.Unlink('/vsimem/byte.tif.tst.aux.xml')
    return 'success'
Esempio n. 53
0
def pcidsk_cleanup():
    gdaltest.pcidsk_ds = None
    gdaltest.clean_tmp()
    return 'success'
Esempio n. 54
0
def test_ilwis_cleanup():
    gdaltest.clean_tmp()
Esempio n. 55
0
def test_gif_cleanup():
    gdaltest.clean_tmp()
Esempio n. 56
0
def gif_cleanup():
    gdaltest.clean_tmp()
    return 'success'
Esempio n. 57
0
def test_pcidsk_cleanup():
    gdaltest.pcidsk_ds = None
    gdaltest.clean_tmp()
Esempio n. 58
0
def idrisi_cleanup():
    gdaltest.clean_tmp()
    return 'success'
Esempio n. 59
0
def idrisi_cleanup():
    gdaltest.clean_tmp()
    return 'success'