コード例 #1
0
def test_gdalbuildvrt_2():
    if test_cli_utilities.get_gdalbuildvrt_path() is None:
        pytest.skip()
    if test_cli_utilities.get_gdaltindex_path() is None:
        pytest.skip()

    try:
        os.remove('tmp/tileindex.shp')
    except OSError:
        pass
    try:
        os.remove('tmp/tileindex.dbf')
    except OSError:
        pass
    try:
        os.remove('tmp/tileindex.shx')
    except OSError:
        pass
    try:
        os.remove('tmp/mosaic.vrt')
    except OSError:
        pass

    gdaltest.runexternal(test_cli_utilities.get_gdaltindex_path() + ' tmp/tileindex.shp tmp/gdalbuildvrt1.tif tmp/gdalbuildvrt2.tif tmp/gdalbuildvrt3.tif tmp/gdalbuildvrt4.tif')

    gdaltest.runexternal(test_cli_utilities.get_gdalbuildvrt_path() + ' tmp/mosaic.vrt tmp/tileindex.shp')

    return gdalbuildvrt_check()
コード例 #2
0
ファイル: test_gdaltindex.py プロジェクト: Joe-xXx/gdal
def test_gdaltindex_3():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return 'skip'

    drv = gdal.GetDriverByName('GTiff')
    wkt = 'GEOGCS[\"WGS 72\",DATUM[\"WGS_1972\"]]'

    ds = drv.Create('tmp/gdaltindex5.tif', 10, 10, 1)
    ds.SetProjection( wkt )
    ds.SetGeoTransform( [ 47, 0.1, 0, 2, 0, -0.1 ] )
    ds = None

    (ret_stdout, ret_stderr) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' -skip_different_projection tmp/tileindex.shp tmp/gdaltindex5.tif')

    if ret_stderr.find('Warning : tmp/gdaltindex5.tif is not using the same projection system as other files in the tileindex. This may cause problems when using it in MapServer for example. Skipping it') == -1:
        print(ret_stderr)
        gdaltest.post_reason( 'got unexpected error messages.' )
        return 'fail'

    ds = ogr.Open('tmp/tileindex.shp')
    if ds.GetLayer(0).GetFeatureCount() != 4:
        return 'fail'
    ds.Destroy()

    return 'success'
コード例 #3
0
def test_gdalbuildvrt_2():
    if test_cli_utilities.get_gdalbuildvrt_path() is None:
        return "skip"
    if test_cli_utilities.get_gdaltindex_path() is None:
        return "skip"

    try:
        os.remove("tmp/tileindex.shp")
    except:
        pass
    try:
        os.remove("tmp/tileindex.dbf")
    except:
        pass
    try:
        os.remove("tmp/tileindex.shx")
    except:
        pass
    try:
        os.remove("tmp/mosaic.vrt")
    except:
        pass

    gdaltest.runexternal(
        test_cli_utilities.get_gdaltindex_path()
        + " tmp/tileindex.shp tmp/gdalbuildvrt1.tif tmp/gdalbuildvrt2.tif tmp/gdalbuildvrt3.tif tmp/gdalbuildvrt4.tif"
    )

    gdaltest.runexternal(test_cli_utilities.get_gdalbuildvrt_path() + " tmp/mosaic.vrt tmp/tileindex.shp")

    return test_gdalbuildvrt_check()
コード例 #4
0
ファイル: test_gdaltindex.py プロジェクト: ksshannon/gdal
def test_gdaltindex_3():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return 'skip'

    drv = gdal.GetDriverByName('GTiff')
    wkt = 'GEOGCS[\"WGS 72\",DATUM[\"WGS_1972\"]]'

    ds = drv.Create('tmp/gdaltindex5.tif', 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1])
    ds = None

    (_, ret_stderr) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' -skip_different_projection tmp/tileindex.shp tmp/gdaltindex5.tif')

    if ret_stderr.find('Warning : tmp/gdaltindex5.tif is not using the same projection system as other files in the tileindex.') == -1 or \
       ret_stderr.find('Use -t_srs option to set target projection system (not supported by MapServer).') == -1:
        print(ret_stderr)
        gdaltest.post_reason('got unexpected error message \n[%s]' % (ret_stderr))
        return 'fail'

    ds = ogr.Open('tmp/tileindex.shp')
    if ds.GetLayer(0).GetFeatureCount() != 4:
        return 'fail'
    ds.Destroy()

    return 'success'
コード例 #5
0
ファイル: test_gdaltindex.py プロジェクト: AsgerPetersen/gdal
def test_gdaltindex_3():
    if test_cli_utilities.get_gdaltindex_path() is None:
        pytest.skip()

    drv = gdal.GetDriverByName('GTiff')
    wkt = """GEOGCS["WGS 72",
    DATUM["WGS_1972",
        SPHEROID["WGS 72",6378135,298.26],
        TOWGS84[0,0,4.5,0,0,0.554,0.2263]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]]"""

    ds = drv.Create('tmp/gdaltindex5.tif', 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1])
    ds = None

    (_, ret_stderr) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' -skip_different_projection tmp/tileindex.shp tmp/gdaltindex5.tif')

    assert (not (ret_stderr.find('Warning : tmp/gdaltindex5.tif is not using the same projection system as other files in the tileindex.') == -1 or \
       ret_stderr.find('Use -t_srs option to set target projection system (not supported by MapServer).') == -1)), \
        ('got unexpected error message \n[%s]' % (ret_stderr))

    ds = ogr.Open('tmp/tileindex.shp')
    assert ds.GetLayer(0).GetFeatureCount() == 4
    ds.Destroy()
コード例 #6
0
ファイル: test_gdaltindex.py プロジェクト: drons/gdal
def test_gdaltindex_3():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return "skip"

    drv = gdal.GetDriverByName("GTiff")
    wkt = 'GEOGCS["WGS 72",DATUM["WGS_1972"]]'

    ds = drv.Create("tmp/gdaltindex5.tif", 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1])
    ds = None

    (ret_stdout, ret_stderr) = gdaltest.runexternal_out_and_err(
        test_cli_utilities.get_gdaltindex_path() + " -skip_different_projection tmp/tileindex.shp tmp/gdaltindex5.tif"
    )

    if (
        ret_stderr.find(
            "Warning : tmp/gdaltindex5.tif is not using the same projection system as other files in the tileindex."
        )
        == -1
        or ret_stderr.find("Use -t_srs option to set target projection system (not supported by MapServer).") == -1
    ):
        print(ret_stderr)
        gdaltest.post_reason("got unexpected error message \n[%s]" % (ret_stderr))
        return "fail"

    ds = ogr.Open("tmp/tileindex.shp")
    if ds.GetLayer(0).GetFeatureCount() != 4:
        return "fail"
    ds.Destroy()

    return "success"
コード例 #7
0
ファイル: test_gdaltindex.py プロジェクト: drons/gdal
def test_gdaltindex_2():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return "skip"

    (ret_stdout, ret_stderr) = gdaltest.runexternal_out_and_err(
        test_cli_utilities.get_gdaltindex_path()
        + " tmp/tileindex.shp tmp/gdaltindex1.tif tmp/gdaltindex2.tif tmp/gdaltindex3.tif tmp/gdaltindex4.tif"
    )

    if (
        ret_stderr.find("File tmp/gdaltindex1.tif is already in tileindex. Skipping it.") == -1
        or ret_stderr.find("File tmp/gdaltindex2.tif is already in tileindex. Skipping it.") == -1
        or ret_stderr.find("File tmp/gdaltindex3.tif is already in tileindex. Skipping it.") == -1
        or ret_stderr.find("File tmp/gdaltindex4.tif is already in tileindex. Skipping it.") == -1
    ):
        print(ret_stderr)
        gdaltest.post_reason("got unexpected error messages.")
        return "fail"

    ds = ogr.Open("tmp/tileindex.shp")
    if ds.GetLayer(0).GetFeatureCount() != 4:
        return "fail"
    ds.Destroy()

    return "success"
コード例 #8
0
ファイル: test_gdaltindex.py プロジェクト: drons/gdal
def test_gdaltindex_5():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return "skip"

    drv = gdal.GetDriverByName("GTiff")

    ds = drv.Create("tmp/gdaltindex6.tif", 10, 10, 1)
    sr = osr.SpatialReference()
    sr.ImportFromEPSG(4322)
    ds.SetProjection(sr.ExportToWkt())
    ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1])
    ds = None

    for src_srs_format in [
        "",
        "-src_srs_format AUTO",
        "-src_srs_format EPSG",
        "-src_srs_format PROJ",
        "-src_srs_format WKT",
    ]:
        gdal.PushErrorHandler("CPLQuietErrorHandler")
        ogr.GetDriverByName("ESRI Shapefile").DeleteDataSource("tmp/test_gdaltindex_5.shp")
        gdal.PopErrorHandler()
        (ret_stdout, ret_stderr) = gdaltest.runexternal_out_and_err(
            test_cli_utilities.get_gdaltindex_path()
            + " -src_srs_name src_srs %s -t_srs EPSG:4326 tmp/test_gdaltindex_5.shp tmp/gdaltindex1.tif tmp/gdaltindex6.tif"
            % src_srs_format
        )

        ds = ogr.Open("tmp/test_gdaltindex_5.shp")
        lyr = ds.GetLayer(0)
        if lyr.GetFeatureCount() != 2:
            gdaltest.post_reason("got %d features, expecting 2" % ds.GetLayer(0).GetFeatureCount())
            return "fail"
        feat = lyr.GetNextFeature()
        feat = lyr.GetNextFeature()
        if src_srs_format == "-src_srs_format PROJ":
            if feat.GetField("src_srs").find("+proj=longlat +ellps=WGS72") != 0:
                gdaltest.post_reason("fail")
                feat.DumpReadable()
                return "fail"
        elif src_srs_format == "-src_srs_format WKT":
            if feat.GetField("src_srs").find('GEOGCS["WGS 72"') != 0:
                gdaltest.post_reason("fail")
                feat.DumpReadable()
                return "fail"
        else:
            if feat.GetField("src_srs") != "EPSG:4322":
                gdaltest.post_reason("fail")
                feat.DumpReadable()
                return "fail"
        ds = None

    return "success"
コード例 #9
0
def test_gdaltindex_6():
    if test_cli_utilities.get_gdaltindex_path() is None:
        pytest.skip()

    for option in ['', '-lyr_name tileindex']:
        gdal.PushErrorHandler('CPLQuietErrorHandler')
        ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource('tmp/test_gdaltindex_6.mif')
        gdal.PopErrorHandler()
        gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' -f "MapInfo File" %s tmp/test_gdaltindex_6.mif tmp/gdaltindex1.tif' % option)
        ds = ogr.Open('tmp/test_gdaltindex_6.mif')
        lyr = ds.GetLayer(0)
        assert lyr.GetFeatureCount() == 1, \
            ('got %d features, expecting 1' % lyr.GetFeatureCount())
        ds = None
コード例 #10
0
def test_gdaltindex_2():
    if test_cli_utilities.get_gdaltindex_path() is None:
        pytest.skip()

    (_, ret_stderr) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' tmp/tileindex.shp tmp/gdaltindex1.tif tmp/gdaltindex2.tif tmp/gdaltindex3.tif tmp/gdaltindex4.tif')

    assert (not (ret_stderr.find('File tmp/gdaltindex1.tif is already in tileindex. Skipping it.') == -1 or \
       ret_stderr.find('File tmp/gdaltindex2.tif is already in tileindex. Skipping it.') == -1 or \
       ret_stderr.find('File tmp/gdaltindex3.tif is already in tileindex. Skipping it.') == -1 or \
       ret_stderr.find('File tmp/gdaltindex4.tif is already in tileindex. Skipping it.') == -1)), \
        'got unexpected error messages.'

    ds = ogr.Open('tmp/tileindex.shp')
    assert ds.GetLayer(0).GetFeatureCount() == 4
    ds.Destroy()
コード例 #11
0
ファイル: test_gdaltindex.py プロジェクト: rashadkm/lib_gdal
def test_gdaltindex_6():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return 'skip'

    for option in [ '', '-lyr_name tileindex']:
        gdal.PushErrorHandler('CPLQuietErrorHandler')
        ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource('tmp/test_gdaltindex_6.mif')
        gdal.PopErrorHandler()
        (ret_stdout, ret_stderr) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' -f "MapInfo File" %s tmp/test_gdaltindex_6.mif tmp/gdaltindex1.tif' % option)
        ds = ogr.Open('tmp/test_gdaltindex_6.mif')
        lyr = ds.GetLayer(0)
        if lyr.GetFeatureCount() != 1:
            gdaltest.post_reason( 'got %d features, expecting 1' %  lyr.GetFeatureCount() )
            return 'fail'
        ds = None

    return 'success'
コード例 #12
0
ファイル: test_gdaltindex.py プロジェクト: r3n4ud/gdal
def test_gdaltindex_6():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return 'skip'

    for option in [ '', '-lyr_name tileindex']:
        gdal.PushErrorHandler('CPLQuietErrorHandler')
        ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource('tmp/test_gdaltindex_6.mif')
        gdal.PopErrorHandler()
        (ret_stdout, ret_stderr) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' -f "MapInfo File" %s tmp/test_gdaltindex_6.mif tmp/gdaltindex1.tif' % option)
        ds = ogr.Open('tmp/test_gdaltindex_6.mif')
        lyr = ds.GetLayer(0)
        if lyr.GetFeatureCount() != 1:
            gdaltest.post_reason( 'got %d features, expecting 1' %  lyr.GetFeatureCount() )
            return 'fail'
        ds = None

    return 'success'
コード例 #13
0
ファイル: test_gdaltindex.py プロジェクト: r3n4ud/gdal
def test_gdaltindex_5():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return 'skip'

    drv = gdal.GetDriverByName('GTiff')
    wkt = 'GEOGCS[\"WGS 72\",DATUM[\"WGS_1972\"]]'

    ds = drv.Create('tmp/gdaltindex6.tif', 10, 10, 1)
    sr = osr.SpatialReference()
    sr.ImportFromEPSG(4322)
    ds.SetProjection( sr.ExportToWkt() )
    ds.SetGeoTransform( [ 47, 0.1, 0, 2, 0, -0.1 ] )
    ds = None

    for src_srs_format in [ '', '-src_srs_format AUTO', '-src_srs_format EPSG', '-src_srs_format PROJ', '-src_srs_format WKT']:
        gdal.PushErrorHandler('CPLQuietErrorHandler')
        ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource('tmp/test_gdaltindex_5.shp')
        gdal.PopErrorHandler()
        (ret_stdout, ret_stderr) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' -src_srs_name src_srs %s -t_srs EPSG:4326 tmp/test_gdaltindex_5.shp tmp/gdaltindex1.tif tmp/gdaltindex6.tif' % src_srs_format)

        ds = ogr.Open('tmp/test_gdaltindex_5.shp')
        lyr = ds.GetLayer(0)
        if lyr.GetFeatureCount() != 2:
            gdaltest.post_reason( 'got %d features, expecting 2' %  ds.GetLayer(0).GetFeatureCount() )
            return 'fail'
        feat = lyr.GetNextFeature()
        feat = lyr.GetNextFeature()
        if src_srs_format == '-src_srs_format PROJ':
            if feat.GetField('src_srs').find('+proj=longlat +ellps=WGS72') != 0:
                gdaltest.post_reason('fail')
                feat.DumpReadable()
                return 'fail'
        elif src_srs_format == '-src_srs_format WKT':
            if feat.GetField('src_srs').find('GEOGCS["WGS 72"') != 0:
                gdaltest.post_reason('fail')
                feat.DumpReadable()
                return 'fail'
        else:
            if feat.GetField('src_srs') != 'EPSG:4322':
                gdaltest.post_reason('fail')
                feat.DumpReadable()
                return 'fail'
        ds = None

    return 'success'
コード例 #14
0
def test_gdaltindex_6():
    if test_cli_utilities.get_gdaltindex_path() is None:
        pytest.skip()

    for option in ['', '-lyr_name tileindex']:
        gdal.PushErrorHandler('CPLQuietErrorHandler')
        ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource(
            'tmp/test_gdaltindex_6.mif')
        gdal.PopErrorHandler()
        gdaltest.runexternal_out_and_err(
            test_cli_utilities.get_gdaltindex_path() +
            ' -f "MapInfo File" %s tmp/test_gdaltindex_6.mif tmp/gdaltindex1.tif'
            % option)
        ds = ogr.Open('tmp/test_gdaltindex_6.mif')
        lyr = ds.GetLayer(0)
        assert lyr.GetFeatureCount() == 1, \
            ('got %d features, expecting 1' % lyr.GetFeatureCount())
        ds = None
コード例 #15
0
def test_gdaltindex_2():
    if test_cli_utilities.get_gdaltindex_path() is None:
        pytest.skip()

    (_, ret_stderr) = gdaltest.runexternal_out_and_err(
        test_cli_utilities.get_gdaltindex_path() +
        ' tmp/tileindex.shp tmp/gdaltindex1.tif tmp/gdaltindex2.tif tmp/gdaltindex3.tif tmp/gdaltindex4.tif'
    )

    assert (not (ret_stderr.find('File tmp/gdaltindex1.tif is already in tileindex. Skipping it.') == -1 or \
       ret_stderr.find('File tmp/gdaltindex2.tif is already in tileindex. Skipping it.') == -1 or \
       ret_stderr.find('File tmp/gdaltindex3.tif is already in tileindex. Skipping it.') == -1 or \
       ret_stderr.find('File tmp/gdaltindex4.tif is already in tileindex. Skipping it.') == -1)), \
        'got unexpected error messages.'

    ds = ogr.Open('tmp/tileindex.shp')
    assert ds.GetLayer(0).GetFeatureCount() == 4
    ds.Destroy()
コード例 #16
0
def test_gdaltindex_4():
    if test_cli_utilities.get_gdaltindex_path() is None:
        pytest.skip()

    drv = gdal.GetDriverByName('GTiff')
    wkt = 'GEOGCS[\"WGS 72\",DATUM[\"WGS_1972\"]]'

    ds = drv.Create('tmp/gdaltindex5.tif', 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1])
    ds = None

    gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' -t_srs EPSG:4326 tmp/tileindex.shp tmp/gdaltindex5.tif')

    ds = ogr.Open('tmp/tileindex.shp')
    assert ds.GetLayer(0).GetFeatureCount() == 5, \
        ('got %d features, expecting 5' % ds.GetLayer(0).GetFeatureCount())
    ds.Destroy()
コード例 #17
0
def test_gdaltindex_2():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return 'skip'

    (ret_stdout, ret_stderr) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' tmp/tileindex.shp tmp/gdaltindex1.tif tmp/gdaltindex2.tif tmp/gdaltindex3.tif tmp/gdaltindex4.tif')

    if ret_stderr.find('File tmp/gdaltindex1.tif is already in tileindex. Skipping it.') == -1 or \
       ret_stderr.find('File tmp/gdaltindex2.tif is already in tileindex. Skipping it.') == -1 or \
       ret_stderr.find('File tmp/gdaltindex3.tif is already in tileindex. Skipping it.') == -1 or \
       ret_stderr.find('File tmp/gdaltindex4.tif is already in tileindex. Skipping it.') == -1:
        print(ret_stderr)
        gdaltest.post_reason( 'got unexpected error messages.' )
        return 'fail'

    ds = ogr.Open('tmp/tileindex.shp')
    if ds.GetLayer(0).GetFeatureCount() != 4:
        return 'fail'
    ds.Destroy()

    return 'success'
コード例 #18
0
ファイル: test_gdaltindex.py プロジェクト: drons/gdal
def test_gdaltindex_6():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return "skip"

    for option in ["", "-lyr_name tileindex"]:
        gdal.PushErrorHandler("CPLQuietErrorHandler")
        ogr.GetDriverByName("ESRI Shapefile").DeleteDataSource("tmp/test_gdaltindex_6.mif")
        gdal.PopErrorHandler()
        (ret_stdout, ret_stderr) = gdaltest.runexternal_out_and_err(
            test_cli_utilities.get_gdaltindex_path()
            + ' -f "MapInfo File" %s tmp/test_gdaltindex_6.mif tmp/gdaltindex1.tif' % option
        )
        ds = ogr.Open("tmp/test_gdaltindex_6.mif")
        lyr = ds.GetLayer(0)
        if lyr.GetFeatureCount() != 1:
            gdaltest.post_reason("got %d features, expecting 1" % lyr.GetFeatureCount())
            return "fail"
        ds = None

    return "success"
コード例 #19
0
def test_gdaltindex_4():
    if test_cli_utilities.get_gdaltindex_path() is None:
        pytest.skip()

    drv = gdal.GetDriverByName('GTiff')
    wkt = 'GEOGCS[\"WGS 72\",DATUM[\"WGS_1972\"]]'

    ds = drv.Create('tmp/gdaltindex5.tif', 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1])
    ds = None

    gdaltest.runexternal_out_and_err(
        test_cli_utilities.get_gdaltindex_path() +
        ' -t_srs EPSG:4326 tmp/tileindex.shp tmp/gdaltindex5.tif')

    ds = ogr.Open('tmp/tileindex.shp')
    assert ds.GetLayer(0).GetFeatureCount() == 5, \
        ('got %d features, expecting 5' % ds.GetLayer(0).GetFeatureCount())
    ds.Destroy()
コード例 #20
0
ファイル: test_gdaltindex.py プロジェクト: ksshannon/gdal
def test_gdaltindex_2():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return 'skip'

    (_, ret_stderr) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' tmp/tileindex.shp tmp/gdaltindex1.tif tmp/gdaltindex2.tif tmp/gdaltindex3.tif tmp/gdaltindex4.tif')

    if ret_stderr.find('File tmp/gdaltindex1.tif is already in tileindex. Skipping it.') == -1 or \
       ret_stderr.find('File tmp/gdaltindex2.tif is already in tileindex. Skipping it.') == -1 or \
       ret_stderr.find('File tmp/gdaltindex3.tif is already in tileindex. Skipping it.') == -1 or \
       ret_stderr.find('File tmp/gdaltindex4.tif is already in tileindex. Skipping it.') == -1:
        print(ret_stderr)
        gdaltest.post_reason('got unexpected error messages.')
        return 'fail'

    ds = ogr.Open('tmp/tileindex.shp')
    if ds.GetLayer(0).GetFeatureCount() != 4:
        return 'fail'
    ds.Destroy()

    return 'success'
コード例 #21
0
def test_gdaltindex_4():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return 'skip'

    drv = gdal.GetDriverByName('GTiff')
    wkt = 'GEOGCS[\"WGS 72\",DATUM[\"WGS_1972\"]]'

    ds = drv.Create('tmp/gdaltindex5.tif', 10, 10, 1)
    ds.SetProjection( wkt )
    ds.SetGeoTransform( [ 47, 0.1, 0, 2, 0, -0.1 ] )
    ds = None

    (ret_stdout, ret_stderr) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' -t_srs EPSG:4326 tmp/tileindex.shp tmp/gdaltindex5.tif')

    ds = ogr.Open('tmp/tileindex.shp')
    if ds.GetLayer(0).GetFeatureCount() != 5:
        gdaltest.post_reason( 'got %d features, expecting 5' %  ds.GetLayer(0).GetFeatureCount() )
        return 'fail'
    ds.Destroy()

    return 'success'
コード例 #22
0
ファイル: test_gdaltindex.py プロジェクト: AsgerPetersen/gdal
def test_gdaltindex_5():
    if test_cli_utilities.get_gdaltindex_path() is None:
        pytest.skip()

    drv = gdal.GetDriverByName('GTiff')

    ds = drv.Create('tmp/gdaltindex6.tif', 10, 10, 1)
    sr = osr.SpatialReference()
    sr.ImportFromEPSG(4322)
    ds.SetProjection(sr.ExportToWkt())
    ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1])
    ds = None

    for src_srs_format in ['', '-src_srs_format AUTO', '-src_srs_format EPSG', '-src_srs_format PROJ', '-src_srs_format WKT']:
        gdal.PushErrorHandler('CPLQuietErrorHandler')
        ogr.GetDriverByName('ESRI Shapefile').DeleteDataSource('tmp/test_gdaltindex_5.shp')
        gdal.PopErrorHandler()
        gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' -src_srs_name src_srs %s -t_srs EPSG:4326 tmp/test_gdaltindex_5.shp tmp/gdaltindex1.tif tmp/gdaltindex6.tif' % src_srs_format)

        ds = ogr.Open('tmp/test_gdaltindex_5.shp')
        lyr = ds.GetLayer(0)
        assert lyr.GetFeatureCount() == 2, \
            ('got %d features, expecting 2' % ds.GetLayer(0).GetFeatureCount())
        feat = lyr.GetNextFeature()
        feat = lyr.GetNextFeature()
        if src_srs_format == '-src_srs_format PROJ':
            if feat.GetField('src_srs').find('+proj=longlat +ellps=WGS72') != 0:
                feat.DumpReadable()
                pytest.fail()
        elif src_srs_format == '-src_srs_format WKT':
            #if feat.GetField('src_srs').find('GEOGCS["WGS 72"') != 0:
            # Full definition too long...
            if feat.GetField('src_srs') is not None:
                feat.DumpReadable()
                pytest.fail()
        else:
            if feat.GetField('src_srs') != 'EPSG:4322':
                feat.DumpReadable()
                pytest.fail()
        ds = None
コード例 #23
0
def test_gdaltindex_3():
    if test_cli_utilities.get_gdaltindex_path() is None:
        pytest.skip()

    drv = gdal.GetDriverByName('GTiff')
    wkt = 'GEOGCS[\"WGS 72\",DATUM[\"WGS_1972\"]]'

    ds = drv.Create('tmp/gdaltindex5.tif', 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1])
    ds = None

    (_, ret_stderr) = gdaltest.runexternal_out_and_err(
        test_cli_utilities.get_gdaltindex_path() +
        ' -skip_different_projection tmp/tileindex.shp tmp/gdaltindex5.tif')

    assert (not (ret_stderr.find('Warning : tmp/gdaltindex5.tif is not using the same projection system as other files in the tileindex.') == -1 or \
       ret_stderr.find('Use -t_srs option to set target projection system (not supported by MapServer).') == -1)), \
        ('got unexpected error message \n[%s]' % (ret_stderr))

    ds = ogr.Open('tmp/tileindex.shp')
    assert ds.GetLayer(0).GetFeatureCount() == 4
    ds.Destroy()
コード例 #24
0
ファイル: test_gdaltindex.py プロジェクト: AsgerPetersen/gdal
def test_gdaltindex_4():
    if test_cli_utilities.get_gdaltindex_path() is None:
        pytest.skip()

    drv = gdal.GetDriverByName('GTiff')
    wkt = """GEOGCS["WGS 72",
    DATUM["WGS_1972",
        SPHEROID["WGS 72",6378135,298.26],
        TOWGS84[0,0,4.5,0,0,0.554,0.2263]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]]"""


    ds = drv.Create('tmp/gdaltindex5.tif', 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1])
    ds = None

    gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' -t_srs EPSG:4326 tmp/tileindex.shp tmp/gdaltindex5.tif')

    ds = ogr.Open('tmp/tileindex.shp')
    assert ds.GetLayer(0).GetFeatureCount() == 5, \
        ('got %d features, expecting 5' % ds.GetLayer(0).GetFeatureCount())
    ds.Destroy()
コード例 #25
0
ファイル: test_gdaltindex.py プロジェクト: ksshannon/gdal
def test_gdaltindex_1():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return 'skip'

    try:
        os.remove('tmp/tileindex.shp')
    except OSError:
        pass
    try:
        os.remove('tmp/tileindex.dbf')
    except OSError:
        pass
    try:
        os.remove('tmp/tileindex.shx')
    except OSError:
        pass
    try:
        os.remove('tmp/tileindex.prj')
    except OSError:
        pass

    drv = gdal.GetDriverByName('GTiff')
    wkt = '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\"]]'

    ds = drv.Create('tmp/gdaltindex1.tif', 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([49, 0.1, 0, 2, 0, -0.1])
    ds = None

    ds = drv.Create('tmp/gdaltindex2.tif', 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([49, 0.1, 0, 3, 0, -0.1])
    ds = None

    ds = drv.Create('tmp/gdaltindex3.tif', 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([48, 0.1, 0, 2, 0, -0.1])
    ds = None

    ds = drv.Create('tmp/gdaltindex4.tif', 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([48, 0.1, 0, 3, 0, -0.1])
    ds = None

    (_, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' tmp/tileindex.shp tmp/gdaltindex1.tif tmp/gdaltindex2.tif')
    if not (err is None or err == ''):
        gdaltest.post_reason('got error/warning')
        print(err)
        return 'fail'

    (ret_stdout, ret_stderr) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' tmp/tileindex.shp tmp/gdaltindex3.tif tmp/gdaltindex4.tif')

    ds = ogr.Open('tmp/tileindex.shp')
    if ds.GetLayer(0).GetFeatureCount() != 4:
        gdaltest.post_reason('fail')
        print(ret_stdout)
        print(ret_stderr)
        print(ds.GetLayer(0).GetFeatureCount())
        return 'fail'
    tileindex_wkt = ds.GetLayer(0).GetSpatialRef().ExportToWkt()
    if tileindex_wkt.find('WGS_1984') == -1:
        gdaltest.post_reason('fail')
        print(ret_stdout)
        print(ret_stderr)
        print(tileindex_wkt)
        return 'fail'

    expected_wkts = ['POLYGON ((49 2,50 2,50 1,49 1,49 2))',
                     'POLYGON ((49 3,50 3,50 2,49 2,49 3))',
                     'POLYGON ((48 2,49 2,49 1,48 1,48 2))',
                     'POLYGON ((48 3,49 3,49 2,48 2,48 3))']
    i = 0
    feat = ds.GetLayer(0).GetNextFeature()
    while feat is not None:
        if feat.GetGeometryRef().ExportToWkt() != expected_wkts[i]:
            print('i=%d, wkt=%s' % (i, feat.GetGeometryRef().ExportToWkt()))
            return 'fail'
        i = i + 1
        feat = ds.GetLayer(0).GetNextFeature()
    ds.Destroy()

    return 'success'
コード例 #26
0
ファイル: test_gdaltindex.py プロジェクト: drons/gdal
def test_gdaltindex_1():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return "skip"

    try:
        os.remove("tmp/tileindex.shp")
    except:
        pass
    try:
        os.remove("tmp/tileindex.dbf")
    except:
        pass
    try:
        os.remove("tmp/tileindex.shx")
    except:
        pass
    try:
        os.remove("tmp/tileindex.prj")
    except:
        pass

    drv = gdal.GetDriverByName("GTiff")
    wkt = '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"]]'

    ds = drv.Create("tmp/gdaltindex1.tif", 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([49, 0.1, 0, 2, 0, -0.1])
    ds = None

    ds = drv.Create("tmp/gdaltindex2.tif", 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([49, 0.1, 0, 3, 0, -0.1])
    ds = None

    ds = drv.Create("tmp/gdaltindex3.tif", 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([48, 0.1, 0, 2, 0, -0.1])
    ds = None

    ds = drv.Create("tmp/gdaltindex4.tif", 10, 10, 1)
    ds.SetProjection(wkt)
    ds.SetGeoTransform([48, 0.1, 0, 3, 0, -0.1])
    ds = None

    (out, err) = gdaltest.runexternal_out_and_err(
        test_cli_utilities.get_gdaltindex_path() + " tmp/tileindex.shp tmp/gdaltindex1.tif tmp/gdaltindex2.tif"
    )
    if not (err is None or err == ""):
        gdaltest.post_reason("got error/warning")
        print(err)
        return "fail"

    (ret_stdout, ret_stderr) = gdaltest.runexternal_out_and_err(
        test_cli_utilities.get_gdaltindex_path() + " tmp/tileindex.shp tmp/gdaltindex3.tif tmp/gdaltindex4.tif"
    )

    ds = ogr.Open("tmp/tileindex.shp")
    if ds.GetLayer(0).GetFeatureCount() != 4:
        gdaltest.post_reason("fail")
        print(ret_stdout)
        print(ret_stderr)
        print(ds.GetLayer(0).GetFeatureCount())
        return "fail"
    tileindex_wkt = ds.GetLayer(0).GetSpatialRef().ExportToWkt()
    if tileindex_wkt.find("GCS_WGS_1984") == -1:
        gdaltest.post_reason("fail")
        print(ret_stdout)
        print(ret_stderr)
        print(tileindex_wkt)
        return "fail"

    expected_wkts = [
        "POLYGON ((49 2,50 2,50 1,49 1,49 2))",
        "POLYGON ((49 3,50 3,50 2,49 2,49 3))",
        "POLYGON ((48 2,49 2,49 1,48 1,48 2))",
        "POLYGON ((48 3,49 3,49 2,48 2,48 3))",
    ]
    i = 0
    feat = ds.GetLayer(0).GetNextFeature()
    while feat is not None:
        if feat.GetGeometryRef().ExportToWkt() != expected_wkts[i]:
            print("i=%d, wkt=%s" % (i, feat.GetGeometryRef().ExportToWkt()))
            return "fail"
        i = i + 1
        feat = ds.GetLayer(0).GetNextFeature()
    ds.Destroy()

    return "success"
コード例 #27
0
def test_gdaltindex_1():
    if test_cli_utilities.get_gdaltindex_path() is None:
        return 'skip'

    try:
        os.remove('tmp/tileindex.shp')
    except:
        pass
    try:
        os.remove('tmp/tileindex.dbf')
    except:
        pass
    try:
        os.remove('tmp/tileindex.shx')
    except:
        pass
    try:
        os.remove('tmp/tileindex.prj')
    except:
        pass

    drv = gdal.GetDriverByName('GTiff')
    wkt = '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\"]]'

    ds = drv.Create('tmp/gdaltindex1.tif', 10, 10, 1)
    ds.SetProjection( wkt )
    ds.SetGeoTransform( [ 49, 0.1, 0, 2, 0, -0.1 ] )
    ds = None

    ds = drv.Create('tmp/gdaltindex2.tif', 10, 10, 1)
    ds.SetProjection( wkt )
    ds.SetGeoTransform( [ 49, 0.1, 0, 3, 0, -0.1 ] )
    ds = None

    ds = drv.Create('tmp/gdaltindex3.tif', 10, 10, 1)
    ds.SetProjection( wkt )
    ds.SetGeoTransform( [ 48, 0.1, 0, 2, 0, -0.1 ] )
    ds = None

    ds = drv.Create('tmp/gdaltindex4.tif', 10, 10, 1)
    ds.SetProjection( wkt )
    ds.SetGeoTransform( [ 48, 0.1, 0, 3, 0, -0.1 ] )
    ds = None

    (out, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdaltindex_path() + ' tmp/tileindex.shp tmp/gdaltindex1.tif tmp/gdaltindex2.tif')
    if not (err is None or err == '') :
        gdaltest.post_reason('got error/warning')
        print(err)
        return 'fail'
    gdaltest.runexternal(test_cli_utilities.get_gdaltindex_path() + ' tmp/tileindex.shp tmp/gdaltindex3.tif tmp/gdaltindex4.tif')

    ds = ogr.Open('tmp/tileindex.shp')
    if ds.GetLayer(0).GetFeatureCount() != 4:
        return 'fail'
    tileindex_wkt = ds.GetLayer(0).GetSpatialRef().ExportToWkt()
    if tileindex_wkt.find('GCS_WGS_1984') == -1:
        return 'fail'

    expected_wkts =['POLYGON ((49 2,50 2,50 1,49 1,49 2))',
                    'POLYGON ((49 3,50 3,50 2,49 2,49 3))',
                    'POLYGON ((48 2,49 2,49 1,48 1,48 2))',
                    'POLYGON ((48 3,49 3,49 2,48 2,48 3))' ]
    i = 0
    feat = ds.GetLayer(0).GetNextFeature()
    while feat is not None:
        if feat.GetGeometryRef().ExportToWkt() != expected_wkts[i]:
            print('i=%d, wkt=%s' % (i, feat.GetGeometryRef().ExportToWkt()))
            return 'fail'
        i = i + 1
        feat = ds.GetLayer(0).GetNextFeature()
    ds.Destroy()

    return 'success'