Beispiel #1
0
def mbtiles_3():

    if gdaltest.mbtiles_drv is None:
        return 'skip'

    try:
        drv = gdal.GetDriverByName('HTTP')
    except:
        drv = None

    if drv is None:
        return 'skip'

    if sys.platform == 'darwin' and gdal.GetConfigOption('TRAVIS',
                                                         None) is not None:
        print("Hangs on MacOSX Travis sometimes. Not sure why.")
        return 'skip'

    # Check that we have SQLite VFS support
    gdal.PushErrorHandler('CPLQuietErrorHandler')
    ds = ogr.GetDriverByName('SQLite').CreateDataSource('/vsimem/mbtiles_3.db')
    gdal.PopErrorHandler()
    if ds is None:
        return 'skip'
    ds = None
    gdal.Unlink('/vsimem/mbtiles_3.db')

    ds = gdal.Open(
        '/vsicurl/http://a.tiles.mapbox.com/v3/mapbox.geography-class.mbtiles')
    if ds is None:
        # Just skip. The service isn't perfectly reliable sometimes
        return 'skip'

    # long=2,lat=49 in WGS 84 --> x=222638,y=6274861 in Google Mercator
    locationInfo = ds.GetRasterBand(1).GetMetadataItem(
        'GeoPixel_222638_6274861', 'LocationInfo')
    if locationInfo is None or locationInfo.find("France") == -1:
        gdaltest.post_reason('did not get expected LocationInfo')
        print(locationInfo)
        if gdaltest.skip_on_travis():
            return 'skip'
        return 'fail'

    locationInfo2 = ds.GetRasterBand(1).GetOverview(5).GetMetadataItem(
        'GeoPixel_222638_6274861', 'LocationInfo')
    if locationInfo2 != locationInfo:
        gdaltest.post_reason('did not get expected LocationInfo on overview')
        print(locationInfo2)
        if gdaltest.skip_on_travis():
            return 'skip'
        return 'fail'

    return 'success'
Beispiel #2
0
def mbtiles_3():

    if gdaltest.mbtiles_drv is None:
        return 'skip'

    try:
        drv = gdal.GetDriverByName( 'HTTP' )
    except:
        drv = None

    if drv is None:
        return 'skip'

    if sys.platform == 'darwin' and gdal.GetConfigOption('TRAVIS', None) is not None:
        print("Hangs on MacOSX Travis sometimes. Not sure why.")
        return 'skip'

    # Check that we have SQLite VFS support
    gdal.PushErrorHandler('CPLQuietErrorHandler')
    ds = ogr.GetDriverByName('SQLite').CreateDataSource('/vsimem/mbtiles_3.db')
    gdal.PopErrorHandler()
    if ds is None:
        return 'skip'
    ds = None
    gdal.Unlink('/vsimem/mbtiles_3.db')

    ds = gdal.Open('/vsicurl/http://a.tiles.mapbox.com/v3/mapbox.geography-class.mbtiles')
    if ds is None:
        # Just skip. The service isn't perfectly reliable sometimes
        return 'skip'

    # long=2,lat=49 in WGS 84 --> x=222638,y=6274861 in Google Mercator
    locationInfo = ds.GetRasterBand(1).GetMetadataItem('GeoPixel_222638_6274861', 'LocationInfo')
    if locationInfo is None or locationInfo.find("France") == -1:
        gdaltest.post_reason('did not get expected LocationInfo')
        print(locationInfo)
        if gdaltest.skip_on_travis():
            return 'skip'
        return 'fail'

    locationInfo2 = ds.GetRasterBand(1).GetOverview(5).GetMetadataItem('GeoPixel_222638_6274861', 'LocationInfo')
    if locationInfo2 != locationInfo:
        gdaltest.post_reason('did not get expected LocationInfo on overview')
        print(locationInfo2)
        if gdaltest.skip_on_travis():
            return 'skip'
        return 'fail'


    return 'success'
Beispiel #3
0
def http_4():

    # Too unreliable
    if gdaltest.skip_on_travis():
        return 'skip'

    drv = gdal.GetDriverByName('HTTP')
    if drv is None:
        return 'skip'

    ds = gdal.Open('/vsicurl/ftp://download.osgeo.org/gdal/data/gtiff/utm.tif')
    if ds is None:
        conn = gdaltest.gdalurlopen('ftp://download.osgeo.org/gdal/data/gtiff/utm.tif', timeout=4)
        if conn is None:
            print('cannot open URL')
            return 'skip'
        try:
            conn.read()
        except:
            print('cannot read')
            return 'skip'
        conn.close()
        if sys.platform == 'darwin' and gdal.GetConfigOption('TRAVIS', None) is not None:
            print("Fails on MacOSX Travis sometimes. Not sure why.")
            return 'skip'
        gdaltest.post_reason('fail')
        return 'fail'

    filelist = ds.GetFileList()
    if '/vsicurl/ftp://download.osgeo.org/gdal/data/gtiff/utm.tif' not in filelist:
        print(filelist)
        gdaltest.post_reason('fail')
        return 'fail'

    return 'success'
Beispiel #4
0
def test_gdal_ls_py_6():

    drv = gdal.GetDriverByName('HTTP')
    if drv is None:
        pytest.skip()

    f = gdal.VSIFOpenL(
        '/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/release/3.1/autotest/ogr/data/poly.zip',
        'rb')
    if f is None:
        pytest.skip()
    d = gdal.VSIFReadL(1, 1, f)
    gdal.VSIFCloseL(f)
    if not d:
        pytest.skip()

    ret_str = run_gdal_ls([
        '', '-l',
        '/vsizip/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/release/3.1/autotest/ogr/data/poly.zip'
    ])

    if ret_str.find(
            '-r--r--r--  1 unknown unknown          415 2008-02-11 21:35 /vsizip/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/release/3.1/autotest/ogr/data/poly.zip/poly.PRJ'
    ) == -1:
        if gdaltest.skip_on_travis():
            # FIXME
            # Fails on Travis with dates at 1970-01-01 00:00
            # Looks like a 32/64bit issue with Python bindings of VSIStatL()
            pytest.skip()
        pytest.fail(ret_str)
Beispiel #5
0
def test_ogr_ngw_test_ogrsf():
    # FIXME: depends on previous test
    if gdaltest.ngw_ds is None:
        pytest.skip()

    if gdaltest.skip_on_travis():
        pytest.skip('skip on travis')

    url = 'NGW:' + gdaltest.ngw_test_server + '/resource/' + gdaltest.group_id

    import test_cli_utilities
    if test_cli_utilities.get_test_ogrsf_path() is None:
        pytest.skip()

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' +
                               url)
    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' +
                               url + ' -oo PAGE_SIZE=100')
    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' +
                               url + ' -oo BATCH_SIZE=5')
    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' +
                               url + ' -oo BATCH_SIZE=5 -oo PAGE_SIZE=100')
    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1
Beispiel #6
0
def test_wms_11():

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

    if gdaltest.skip_on_travis():
        pytest.skip()

    srv = 'http://onearth.jpl.nasa.gov/wms.cgi'
    if gdaltest.gdalurlopen(srv) is None:
        pytest.skip()

    name = "WMS:http://onearth.jpl.nasa.gov/wms.cgi?request=GetTileService"
    ds = gdal.Open(name)
    assert ds is not None, ('open of %s failed.' % name)

    subdatasets = ds.GetMetadata("SUBDATASETS")
    assert subdatasets, 'did not get expected subdataset count'

    ds = None

    name = subdatasets['SUBDATASET_1_NAME']
    ds = gdal.Open(name)
    assert ds is not None, ('open of %s failed.' % name)

    ds = None
Beispiel #7
0
def test_ogr_ngw_test_ogrsf():
    if gdaltest.ngw_drv is None or gdal.GetConfigOption('SKIP_SLOW') is not None:
        pytest.skip()

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

    if gdaltest.skip_on_travis():
        pytest.skip()

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

    url = 'NGW:' + gdaltest.ngw_test_server + '/resource/' + gdaltest.group_id

    import test_cli_utilities
    if test_cli_utilities.get_test_ogrsf_path() is None:
        pytest.skip()

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' + url)
    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' + url + ' -oo PAGE_SIZE=100')
    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' + url + ' -oo BATCH_SIZE=5')
    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' + url + ' -oo BATCH_SIZE=5 -oo PAGE_SIZE=100')
    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1
Beispiel #8
0
def test_wms_11():

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

    if gdaltest.skip_on_travis():
        pytest.skip()

    srv = 'http://onearth.jpl.nasa.gov/wms.cgi'
    if gdaltest.gdalurlopen(srv) is None:
        pytest.skip()

    name = "WMS:http://onearth.jpl.nasa.gov/wms.cgi?request=GetTileService"
    ds = gdal.Open(name)
    assert ds is not None, ('open of %s failed.' % name)

    subdatasets = ds.GetMetadata("SUBDATASETS")
    assert subdatasets, 'did not get expected subdataset count'

    ds = None

    name = subdatasets['SUBDATASET_1_NAME']
    ds = gdal.Open(name)
    assert ds is not None, ('open of %s failed.' % name)

    ds = None
Beispiel #9
0
def test_http_4():

    # Too unreliable
    if gdaltest.skip_on_travis():
        pytest.skip()

    drv = gdal.GetDriverByName('HTTP')
    if drv is None:
        pytest.skip()

    ds = gdal.Open('/vsicurl/ftp://download.osgeo.org/gdal/data/gtiff/utm.tif')
    if ds is None:
        conn = gdaltest.gdalurlopen(
            'ftp://download.osgeo.org/gdal/data/gtiff/utm.tif', timeout=4)
        if conn is None:
            pytest.skip('cannot open URL')
        try:
            conn.read()
        except:
            pytest.skip('cannot read')
        conn.close()
        if sys.platform == 'darwin' and gdal.GetConfigOption('TRAVIS',
                                                             None) is not None:
            pytest.skip("Fails on MacOSX Travis sometimes. Not sure why.")
        pytest.fail()

    filelist = ds.GetFileList()
    assert '/vsicurl/ftp://download.osgeo.org/gdal/data/gtiff/utm.tif' in filelist
Beispiel #10
0
def wms_11():

    if gdaltest.wms_drv is None:
        return 'skip'

    if gdaltest.skip_on_travis():
        return 'skip'

    srv = 'http://onearth.jpl.nasa.gov/wms.cgi'
    if gdaltest.gdalurlopen(srv) is None:
        return 'skip'

    name = "WMS:http://onearth.jpl.nasa.gov/wms.cgi?request=GetTileService"
    ds = gdal.Open(name)
    if ds is None:
        gdaltest.post_reason('open of %s failed.' % name)
        return 'fail'

    subdatasets = ds.GetMetadata("SUBDATASETS")
    if not subdatasets:
        gdaltest.post_reason('did not get expected subdataset count')
        print(subdatasets)
        return 'fail'

    ds = None

    name = subdatasets['SUBDATASET_1_NAME']
    ds = gdal.Open(name)
    if ds is None:
        gdaltest.post_reason('open of %s failed.' % name)
        return 'fail'

    ds = None

    return 'success'
Beispiel #11
0
def test_gdal_ls_py_6():

    drv = gdal.GetDriverByName('HTTP')
    if drv is None:
        return 'skip'

    f = gdal.VSIFOpenL('/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/master/autotest/ogr/data/poly.zip', 'rb')
    if f is None:
        return 'skip'
    d = gdal.VSIFReadL(1, 1, f)
    gdal.VSIFCloseL(f)
    if not d:
        return 'skip'

    ret, ret_str = run_gdal_ls(['', '-l', '/vsizip/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/master/autotest/ogr/data/poly.zip'])

    if ret != 'success':
        return ret

    if ret_str.find('-r--r--r--  1 unknown unknown          415 2008-02-11 21:35 /vsizip/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/master/autotest/ogr/data/poly.zip/poly.PRJ') == -1:
        print(ret_str)
        if gdaltest.skip_on_travis():
            # FIXME
            # Fails on Travis with dates at 1970-01-01 00:00
            # Looks like a 32/64bit issue with Python bindings of VSIStatL()
            return 'skip'
        return 'fail'

    return 'success'
Beispiel #12
0
def test_http_4():

    # Too unreliable
    if gdaltest.skip_on_travis():
        pytest.skip()

    drv = gdal.GetDriverByName('HTTP')
    if drv is None:
        pytest.skip()

    ds = gdal.Open('/vsicurl/ftp://download.osgeo.org/gdal/data/gtiff/utm.tif')
    if ds is None:
        conn = gdaltest.gdalurlopen('ftp://download.osgeo.org/gdal/data/gtiff/utm.tif', timeout=4)
        if conn is None:
            pytest.skip('cannot open URL')
        try:
            conn.read()
        except:
            pytest.skip('cannot read')
        conn.close()
        if sys.platform == 'darwin' and gdal.GetConfigOption('TRAVIS', None) is not None:
            pytest.skip("Fails on MacOSX Travis sometimes. Not sure why.")
        pytest.fail()

    filelist = ds.GetFileList()
    assert '/vsicurl/ftp://download.osgeo.org/gdal/data/gtiff/utm.tif' in filelist
Beispiel #13
0
def ogr_mysql_22():

    # On Travis fails with
    # ERROR 1: MySQL error message:Field 'SHAPE' doesn't have a default value Description: INSERT INTO `tablewithoutspatialindex` (`name`) VALUES ('name')
    # FIXME
    if gdaltest.skip_on_travis():
        return 'skip'

    if gdaltest.mysql_ds is None:
        return 'skip'

    layer = gdaltest.mysql_ds.CreateLayer(
        'tablewithoutspatialindex',
        geom_type=ogr.wkbPoint,
        options=['SPATIAL_INDEX=NO', 'ENGINE=MyISAM'])
    ogrtest.quick_create_layer_def(layer, [('name', ogr.OFTString)])
    dst_feat = ogr.Feature(feature_def=layer.GetLayerDefn())
    dst_feat.SetField('name', 'name')

    layer.CreateFeature(dst_feat)

    dst_feat.Destroy()

    layer.ResetReading()
    feat = layer.GetNextFeature()
    if feat is None:
        return 'fail'

    return 'success'
Beispiel #14
0
def test_gdal_ls_py_6():

    try:
        drv = gdal.GetDriverByName( 'HTTP' )
    except:
        drv = None

    if drv is None:
        return 'skip'

    f = gdal.VSIFOpenL('/vsicurl/http://svn.osgeo.org/gdal/trunk/autotest/ogr/data/poly.zip', 'rb')
    if f is None:
        return 'skip'
    d = gdal.VSIFReadL(1,1,f)
    gdal.VSIFCloseL(f)
    if len(d) == 0:
        return 'skip'

    ret, ret_str = run_gdal_ls(['', '-l', '/vsizip/vsicurl/http://svn.osgeo.org/gdal/trunk/autotest/ogr/data/poly.zip'])

    if ret != 'success':
        return ret

    if ret_str.find('-r--r--r--  1 unknown unknown          415 2008-02-11 21:35 /vsizip/vsicurl/http://svn.osgeo.org/gdal/trunk/autotest/ogr/data/poly.zip/poly.PRJ') == -1:
        print(ret_str)
        if gdaltest.skip_on_travis():
            # FIXME
            # Fails on Travis with dates at 1970-01-01 00:00
            # Looks like a 32/64bit issue with Python bindings of VSIStatL()
            return 'skip'
        return 'fail'

    return 'success'
Beispiel #15
0
def ogr_mysql_22():

    # On Travis fails with
    # ERROR 1: MySQL error message:Field 'SHAPE' doesn't have a default value Description: INSERT INTO `tablewithoutspatialindex` (`name`) VALUES ('name')
    # FIXME
    if gdaltest.skip_on_travis():
        return 'skip'

    if gdaltest.mysql_ds is None:
        return 'skip'

    layer = gdaltest.mysql_ds.CreateLayer('tablewithoutspatialindex', geom_type = ogr.wkbPoint,
                                          options = [ 'SPATIAL_INDEX=NO', 'ENGINE=MyISAM' ] )
    ogrtest.quick_create_layer_def( layer, [ ('name', ogr.OFTString) ] )
    dst_feat = ogr.Feature( feature_def = layer.GetLayerDefn() )
    dst_feat.SetField( 'name', 'name' )

    layer.CreateFeature( dst_feat )

    dst_feat.Destroy()

    layer.ResetReading()
    feat = layer.GetNextFeature()
    if feat is None:
        return 'fail'

    return 'success'
Beispiel #16
0
def test_ogr_ngw_test_ogrsf():
    if gdaltest.ngw_drv is None or gdal.GetConfigOption('SKIP_SLOW') is not None:
        pytest.skip()

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

    if gdaltest.skip_on_travis():
        pytest.skip()

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

    url = 'NGW:' + gdaltest.ngw_test_server + '/resource/' + gdaltest.group_id

    import test_cli_utilities
    if test_cli_utilities.get_test_ogrsf_path() is None:
        pytest.skip()

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' + url)
    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' + url + ' -oo PAGE_SIZE=100')
    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' + url + ' -oo BATCH_SIZE=5')
    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' + url + ' -oo BATCH_SIZE=5 -oo PAGE_SIZE=100')
    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1
Beispiel #17
0
def test_ogr_ngw_test_ogrsf():
    if gdaltest.ngw_drv is None or gdal.GetConfigOption(
            'SKIP_SLOW') is not None:
        pytest.skip()

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

    if gdaltest.skip_on_travis():
        pytest.skip()

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

    ds_resource_id = gdaltest.ngw_ds.GetMetadataItem('id', '')
    url = 'NGW:' + gdaltest.ngw_test_server + '/resource/' + ds_resource_id

    import test_cli_utilities
    if test_cli_utilities.get_test_ogrsf_path() is None:
        pytest.skip()

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' +
                               url)

    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1
Beispiel #18
0
def test_gdal_ls_py_6():

    try:
        drv = gdal.GetDriverByName('HTTP')
    except:
        drv = None

    if drv is None:
        return 'skip'

    f = gdal.VSIFOpenL('/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/master/autotest/ogr/data/poly.zip', 'rb')
    if f is None:
        return 'skip'
    d = gdal.VSIFReadL(1, 1, f)
    gdal.VSIFCloseL(f)
    if len(d) == 0:
        return 'skip'

    ret, ret_str = run_gdal_ls(['', '-l', '/vsizip/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/master/autotest/ogr/data/poly.zip'])

    if ret != 'success':
        return ret

    if ret_str.find('-r--r--r--  1 unknown unknown          415 2008-02-11 21:35 /vsizip/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/master/autotest/ogr/data/poly.zip/poly.PRJ') == -1:
        print(ret_str)
        if gdaltest.skip_on_travis():
            # FIXME
            # Fails on Travis with dates at 1970-01-01 00:00
            # Looks like a 32/64bit issue with Python bindings of VSIStatL()
            return 'skip'
        return 'fail'

    return 'success'
Beispiel #19
0
def vsifile_2():

    ret = vsifile_generic('tmp/vsifile_2.bin')
    if ret != 'success' and gdaltest.skip_on_travis():
        # FIXME
        # Fails on Travis with 17592186044423 (which is 0x10 00 00 00 00 07 instead of 7) at line 63
        # Looks like a 32/64bit issue with Python bindings of VSIStatL()
        return 'skip'
    return ret
Beispiel #20
0
def vsifile_2():

    ret = vsifile_generic('tmp/vsifile_2.bin')
    if ret != 'success' and gdaltest.skip_on_travis():
        # FIXME
        # Fails on Travis with 17592186044423 (which is 0x10 00 00 00 00 07 instead of 7) at line 63
        # Looks like a 32/64bit issue with Python bindings of VSIStatL()
        return 'skip'
    return ret
Beispiel #21
0
def test_gdal_ls_py_4():
    ret_str = run_gdal_ls(['', '-l', '/vsizip/../ogr/data/poly.zip'])

    if ret_str.find('-r--r--r--  1 unknown unknown          415 2008-02-11 21:35 /vsizip/../ogr/data/poly.zip/poly.PRJ') == -1:
        if gdaltest.skip_on_travis():
            # FIXME
            # Fails on Travis with dates at 1970-01-01 00:00
            # Looks like a 32/64bit issue with Python bindings of VSIStatL()
            pytest.skip()
        pytest.fail(ret_str)
Beispiel #22
0
def ogr_gft_read():
    if ogrtest.gft_drv is None:
        return 'skip'

    table_id = '15eIgEVTUNlC649ODphJVHXeb4nsOb49WJUlnhw'

    old_auth = gdal.GetConfigOption('GFT_AUTH', None)
    old_access = gdal.GetConfigOption('GFT_ACCESS_TOKEN', None)
    old_refresh = gdal.GetConfigOption('GFT_REFRESH_TOKEN', None)
    gdal.SetConfigOption('GFT_AUTH', None)
    gdal.SetConfigOption('GFT_ACCESS_TOKEN', None)
    gdal.SetConfigOption('GFT_REFRESH_TOKEN', None)
    ds = ogr.Open('GFT:tables=' + table_id)
    gdal.SetConfigOption('GFT_AUTH', old_auth)
    gdal.SetConfigOption('GFT_ACCESS_TOKEN', old_access)
    gdal.SetConfigOption('GFT_REFRESH_TOKEN', old_refresh)
    if ds is None:
        return 'fail'

    lyr = ds.GetLayer(0)
    if lyr is None:
        return 'fail'

    lyr.SetSpatialFilterRect(67, 31.5, 67.5, 32)
    lyr.SetAttributeFilter("'Attack on' = 'ENEMY'")

    count = lyr.GetFeatureCount()
    if count == 0:
        gdaltest.post_reason('did not get expected feature count')
        print(count)
        if gdaltest.skip_on_travis() or gdal.GetConfigOption(
                'APPVEYOR') is not None:
            ogrtest.gft_drv = None
            return 'skip'
        return 'fail'

    sql_lyr = ds.ExecuteSQL(
        "SELECT Latitude, Longitude FROM " + table_id +
        " WHERE ST_INTERSECTS('Latitude', RECTANGLE(LATLNG(31.5,67.0), LATLNG(32.0,67.5))) AND 'Attack on' = 'ENEMY'"
    )
    if sql_lyr is None:
        gdaltest.post_reason('SQL request failed')
        return 'fail'
    sql_lyr_count = sql_lyr.GetFeatureCount()
    ds.ReleaseResultSet(sql_lyr)

    if sql_lyr_count != count:
        gdaltest.post_reason(
            'did not get expected feature count. Got %d, expected %d' %
            (sql_lyr_count, count))
        return 'fail'

    return 'success'
def test_gdal_ls_py_4():
    ret_str = run_gdal_ls(['', '-l', '/vsizip/../ogr/data/shp/poly.zip'])

    if ret_str.find(
            '-r--r--r--  1 unknown unknown          415 2008-02-11 21:35 /vsizip/../ogr/data/shp/poly.zip/poly.PRJ'
    ) == -1:
        if gdaltest.skip_on_travis():
            # FIXME
            # Fails on Travis with dates at 1970-01-01 00:00
            # Looks like a 32/64bit issue with Python bindings of VSIStatL()
            pytest.skip()
        pytest.fail(ret_str)
Beispiel #24
0
def ogr_gft_read():
    if ogrtest.gft_drv is None:
        return "skip"

    table_id = "15eIgEVTUNlC649ODphJVHXeb4nsOb49WJUlnhw"

    old_auth = gdal.GetConfigOption("GFT_AUTH", None)
    old_access = gdal.GetConfigOption("GFT_ACCESS_TOKEN", None)
    old_refresh = gdal.GetConfigOption("GFT_REFRESH_TOKEN", None)
    gdal.SetConfigOption("GFT_AUTH", None)
    gdal.SetConfigOption("GFT_ACCESS_TOKEN", None)
    gdal.SetConfigOption("GFT_REFRESH_TOKEN", None)
    ds = ogr.Open("GFT:tables=" + table_id)
    gdal.SetConfigOption("GFT_AUTH", old_auth)
    gdal.SetConfigOption("GFT_ACCESS_TOKEN", old_access)
    gdal.SetConfigOption("GFT_REFRESH_TOKEN", old_refresh)
    if ds is None:
        return "fail"

    lyr = ds.GetLayer(0)
    if lyr is None:
        return "fail"

    lyr.SetSpatialFilterRect(67, 31.5, 67.5, 32)
    lyr.SetAttributeFilter("'Attack on' = 'ENEMY'")

    count = lyr.GetFeatureCount()
    if count == 0:
        gdaltest.post_reason("did not get expected feature count")
        print(count)
        if gdaltest.skip_on_travis() or gdal.GetConfigOption("APPVEYOR") is not None:
            ogrtest.gft_drv = None
            return "skip"
        return "fail"

    sql_lyr = ds.ExecuteSQL(
        "SELECT Latitude, Longitude FROM "
        + table_id
        + " WHERE ST_INTERSECTS('Latitude', RECTANGLE(LATLNG(31.5,67.0), LATLNG(32.0,67.5))) AND 'Attack on' = 'ENEMY'"
    )
    if sql_lyr is None:
        gdaltest.post_reason("SQL request failed")
        return "fail"
    sql_lyr_count = sql_lyr.GetFeatureCount()
    ds.ReleaseResultSet(sql_lyr)

    if sql_lyr_count != count:
        gdaltest.post_reason("did not get expected feature count. Got %d, expected %d" % (sql_lyr_count, count))
        return "fail"

    return "success"
Beispiel #25
0
def ogr_gft_read():
    if ogrtest.gft_drv is None:
        return 'skip'

    old_auth = gdal.GetConfigOption('GFT_AUTH', None)
    old_email = gdal.GetConfigOption('GFT_EMAIL', None)
    old_password = gdal.GetConfigOption('GFT_PASSWORD', None)
    gdal.SetConfigOption('GFT_AUTH', None)
    gdal.SetConfigOption('GFT_EMAIL', None)
    gdal.SetConfigOption('GFT_PASSWORD', None)
    ds = ogr.Open('GFT:tables=224453')
    gdal.SetConfigOption('GFT_AUTH', old_auth)
    gdal.SetConfigOption('GFT_EMAIL', old_email)
    gdal.SetConfigOption('GFT_PASSWORD', old_password)
    if ds is None:
        return 'fail'

    lyr = ds.GetLayer(0)
    if lyr is None:
        return 'fail'

    lyr.SetSpatialFilterRect(67, 31.5, 67.5, 32)
    lyr.SetAttributeFilter("'Attack on' = 'ENEMY'")

    count = lyr.GetFeatureCount()
    if count == 0:
        gdaltest.post_reason('did not get expected feature count')
        print(count)
        if gdaltest.skip_on_travis():
            ogrtest.gft_drv = None
            return 'skip'
        return 'fail'

    sql_lyr = ds.ExecuteSQL(
        "SELECT Latitude, Longitude FROM 224453 WHERE ST_INTERSECTS('Latitude', RECTANGLE(LATLNG(31.5,67.0), LATLNG(32.0,67.5))) AND 'Attack on' = 'ENEMY'"
    )
    if sql_lyr is None:
        gdaltest.post_reason('SQL request failed')
        return 'fail'
    sql_lyr_count = sql_lyr.GetFeatureCount()
    ds.ReleaseResultSet(sql_lyr)

    if sql_lyr_count != count:
        gdaltest.post_reason(
            'did not get expected feature count. Got %d, expected %d' %
            (sql_lyr_count, count))
        return 'fail'

    return 'success'
Beispiel #26
0
def test_http_4():
    # Too unreliable
    if gdaltest.skip_on_travis():
        pytest.skip()

    url = 'ftp://download.osgeo.org/gdal/data/gtiff/utm.tif'
    ds = gdal.Open('/vsicurl/' + url)
    if ds is None:
        skip_if_unreachable(url, try_read=True)
        if sys.platform == 'darwin' and gdal.GetConfigOption('TRAVIS', None) is not None:
            pytest.skip("Fails on MacOSX Travis sometimes. Not sure why.")
        pytest.fail()

    filelist = ds.GetFileList()
    assert '/vsicurl/ftp://download.osgeo.org/gdal/data/gtiff/utm.tif' in filelist
Beispiel #27
0
def test_gdal_ls_py_4():
    (ret, ret_str) = run_gdal_ls(['', '-l', '/vsizip/../ogr/data/poly.zip'])

    if ret != 'success':
        return ret

    if ret_str.find('-r--r--r--  1 unknown unknown          415 2008-02-11 21:35 /vsizip/../ogr/data/poly.zip/poly.PRJ') == -1:
        print(ret_str)
        if gdaltest.skip_on_travis():
            # FIXME
            # Fails on Travis with dates at 1970-01-01 00:00
            # Looks like a 32/64bit issue with Python bindings of VSIStatL()
            return 'skip'
        return 'fail'

    return 'success'
Beispiel #28
0
def test_gdal_ls_py_4():
    (ret, ret_str) = run_gdal_ls(['', '-l', '/vsizip/../ogr/data/poly.zip'])

    if ret != 'success':
        return ret

    if ret_str.find('-r--r--r--  1 unknown unknown          415 2008-02-11 21:35 /vsizip/../ogr/data/poly.zip/poly.PRJ') == -1:
        print(ret_str)
        if gdaltest.skip_on_travis():
            # FIXME
            # Fails on Travis with dates at 1970-01-01 00:00
            # Looks like a 32/64bit issue with Python bindings of VSIStatL()
            return 'skip'
        return 'fail'

    return 'success'
Beispiel #29
0
def test_ogr_carto_test_ogrsf():
    if ogrtest.carto_drv is None or gdal.GetConfigOption('SKIP_SLOW') is not None:
        pytest.skip()

    if gdaltest.skip_on_travis():
        pytest.skip()

    ogrtest.carto_test_server = 'https://gdalautotest2.carto.com'

    if gdaltest.gdalurlopen(ogrtest.carto_test_server) is None:
        ogrtest.carto_drv = None
        pytest.skip('cannot open %s' % ogrtest.carto_test_server)

    import test_cli_utilities
    if test_cli_utilities.get_test_ogrsf_path() is None:
        pytest.skip()

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' --config CARTO_HTTPS NO --config CARTO_PAGE_SIZE 300 -ro "CARTO:gdalautotest2 tables=tm_world_borders_simpl_0_3"')

    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1
Beispiel #30
0
def test_ogr_gft_read():
    if ogrtest.gft_drv is None:
        pytest.skip()

    table_id = '15eIgEVTUNlC649ODphJVHXeb4nsOb49WJUlnhw'

    old_auth = gdal.GetConfigOption('GFT_AUTH', None)
    old_access = gdal.GetConfigOption('GFT_ACCESS_TOKEN', None)
    old_refresh = gdal.GetConfigOption('GFT_REFRESH_TOKEN', None)
    gdal.SetConfigOption('GFT_AUTH', None)
    gdal.SetConfigOption('GFT_ACCESS_TOKEN', None)
    gdal.SetConfigOption('GFT_REFRESH_TOKEN', None)
    ds = ogr.Open('GFT:tables=' + table_id)
    gdal.SetConfigOption('GFT_AUTH', old_auth)
    gdal.SetConfigOption('GFT_ACCESS_TOKEN', old_access)
    gdal.SetConfigOption('GFT_REFRESH_TOKEN', old_refresh)
    assert ds is not None

    lyr = ds.GetLayer(0)
    assert lyr is not None

    lyr.SetSpatialFilterRect(67, 31.5, 67.5, 32)
    lyr.SetAttributeFilter("'Attack on' = 'ENEMY'")

    count = lyr.GetFeatureCount()
    if count == 0:
        print(count)
        if gdaltest.skip_on_travis() or gdal.GetConfigOption('APPVEYOR') is not None:
            ogrtest.gft_drv = None
            pytest.skip()
        pytest.fail('did not get expected feature count')

    sql_lyr = ds.ExecuteSQL("SELECT Latitude, Longitude FROM " + table_id + " WHERE ST_INTERSECTS('Latitude', RECTANGLE(LATLNG(31.5,67.0), LATLNG(32.0,67.5))) AND 'Attack on' = 'ENEMY'")
    assert sql_lyr is not None, 'SQL request failed'
    sql_lyr_count = sql_lyr.GetFeatureCount()
    ds.ReleaseResultSet(sql_lyr)

    assert sql_lyr_count == count, \
        ('did not get expected feature count. Got %d, expected %d' % (sql_lyr_count, count))
Beispiel #31
0
def test_visoss_real_test():

    if not gdaltest.built_against_curl():
        pytest.skip()

    if gdaltest.skip_on_travis():
        pytest.skip()

    # ERROR 1: The OSS Access Key Id you provided does not exist in our records.
    gdal.ErrorReset()
    with gdaltest.error_handler():
        f = open_for_read('/vsioss/foo/bar.baz')
    if f is not None or gdal.VSIGetLastErrorMsg() == '':
        if f is not None:
            gdal.VSIFCloseL(f)
        if gdal.GetConfigOption('APPVEYOR') is not None:
            return
        pytest.fail(gdal.VSIGetLastErrorMsg())

    gdal.ErrorReset()
    with gdaltest.error_handler():
        f = open_for_read('/vsioss_streaming/foo/bar.baz')
    assert f is None and gdal.VSIGetLastErrorMsg() != ''
Beispiel #32
0
def test_basic_test_17_part_2():

    # For some odd reason, this fails on the Travis CI targets after unrelated
    # changes (https://travis-ci.com/github/OSGeo/gdal/jobs/501940381)
    if gdaltest.skip_on_travis():
        pytest.skip()

    from osgeo import ogr

    for _ in range(2):
        ogr.UseExceptions()
        gdal.UseExceptions()
        flag = False
        try:
            ogr.DontUseExceptions()
            gdal.DontUseExceptions()
            flag = True
        except:
            gdal.DontUseExceptions()
            ogr.DontUseExceptions()
        assert not flag, 'expected failure'
        assert not gdal.GetUseExceptions()
        assert not ogr.GetUseExceptions()
Beispiel #33
0
def test_visoss_real_test():

    if not gdaltest.built_against_curl():
        pytest.skip()

    if gdaltest.skip_on_travis():
        pytest.skip()

    # ERROR 1: The OSS Access Key Id you provided does not exist in our records.
    gdal.ErrorReset()
    with gdaltest.error_handler():
        f = open_for_read('/vsioss/foo/bar.baz')
    if f is not None or gdal.VSIGetLastErrorMsg() == '':
        if f is not None:
            gdal.VSIFCloseL(f)
        if gdal.GetConfigOption('APPVEYOR') is not None:
            return
        pytest.fail(gdal.VSIGetLastErrorMsg())

    gdal.ErrorReset()
    with gdaltest.error_handler():
        f = open_for_read('/vsioss_streaming/foo/bar.baz')
    assert f is None and gdal.VSIGetLastErrorMsg() != ''
Beispiel #34
0
def test_ogr_ngw_test_ogrsf():
    if gdaltest.ngw_drv is None or gdal.GetConfigOption('SKIP_SLOW') is not None:
        pytest.skip()

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

    if gdaltest.skip_on_travis():
        pytest.skip()

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

    ds_resource_id = gdaltest.ngw_ds.GetMetadataItem('id', '')
    url = 'NGW:' + gdaltest.ngw_test_server + '/resource/' + ds_resource_id

    import test_cli_utilities
    if test_cli_utilities.get_test_ogrsf_path() is None:
        pytest.skip()

    ret = gdaltest.runexternal(test_cli_utilities.get_test_ogrsf_path() + ' ' + url)

    assert ret.find('INFO') != -1 and ret.find('ERROR') == -1
Beispiel #35
0
    if feat.GetField('EAS_ID') != 168:
        gdaltest.post_reason('did not get expected feature')
        feat.DumpReadable()
        return 'fail'

    return 'success'

###############################################################################
# ogr_couchdb_changeLayer

def ogr_couchdb_changeLayer():
    ogrtest.couchdb_test_layer = 'poly_nongeojson'
    return 'success'

# CouchDB tests fail in unreliable ways on Travis
if gdaltest.skip_on_travis():
    gdaltest_list = []
else:
    gdaltest_list = [ 
    ogr_couchdb_init,
    ogr_couchdb_GetFeatureCount,
    ogr_couchdb_GetNextFeature,
    ogr_couchdb_GetFeature,
    ogr_couchdb_GetSpatialRef,
    ogr_couchdb_GetExtent,
    ogr_couchdb_SetSpatialFilter,
    ogr_couchdb_SetAttributeFilter,
    ogr_couchdb_ExecuteSQLStats,
    ogr_couchdb_RowLayer,
    ogr_couchdb_changeLayer,
    ogr_couchdb_GetFeatureCount,
Beispiel #36
0
        return 'fail'

    lyr.SetSpatialFilterRect( -104.9847,39.7392,-104.9847,39.7392 )

    feat = lyr.GetNextFeature()
    if feat is None:
        gdaltest.post_reason('did not get expected feature')
        return 'fail'
    if feat.GetField('NAME') != 'Colorado':
        gdaltest.post_reason('did not get expected feature')
        feat.DumpReadable()
        return 'fail'

    return 'success'

if gdaltest.skip_on_travis():
    gdaltest_list = []
else:
    gdaltest_list = [
    ogr_cloudant_init,
    ogr_cloudant_GetFeatureCount,
    ogr_cloudant_GetNextFeature,
    ogr_cloudant_GetSpatialRef,
    ogr_cloudant_GetExtent,
    ogr_cloudant_SetSpatialFilter
    ]

if __name__ == '__main__':

    gdaltest.setup_run( 'ogr_cloudant' )