本文整理汇总了Python中test_cli_utilities.get_gdaltindex_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_gdaltindex_path函数的具体用法?Python get_gdaltindex_path怎么用?Python get_gdaltindex_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_gdaltindex_path函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_gdaltindex_3
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"
开发者ID:drons,项目名称:gdal,代码行数:33,代码来源:test_gdaltindex.py
示例2: test_gdaltindex_2
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"
开发者ID:drons,项目名称:gdal,代码行数:25,代码来源:test_gdaltindex.py
示例3: test_gdalbuildvrt_2
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()
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:31,代码来源:test_gdalbuildvrt.py
示例4: test_gdaltindex_3
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'
开发者ID:Joe-xXx,项目名称:gdal,代码行数:25,代码来源:test_gdaltindex.py
示例5: test_gdaltindex_3
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'
开发者ID:ksshannon,项目名称:gdal,代码行数:26,代码来源:test_gdaltindex.py
示例6: test_gdaltindex_3
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()
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:26,代码来源:test_gdaltindex.py
示例7: test_gdaltindex_5
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"
开发者ID:drons,项目名称:gdal,代码行数:54,代码来源:test_gdaltindex.py
示例8: test_gdaltindex_6
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'
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:17,代码来源:test_gdaltindex.py
示例9: test_gdaltindex_5
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'
开发者ID:samalone,项目名称:gdal-ios,代码行数:45,代码来源:test_gdaltindex.py
示例10: test_gdaltindex_2
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'
开发者ID:ksshannon,项目名称:gdal,代码行数:20,代码来源:test_gdaltindex.py
示例11: test_gdaltindex_6
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"
开发者ID:drons,项目名称:gdal,代码行数:20,代码来源:test_gdaltindex.py
示例12: test_gdaltindex_4
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'
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:21,代码来源:test_gdaltindex.py
示例13: test_gdaltindex_5
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
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:40,代码来源:test_gdaltindex.py
示例14: test_gdaltindex_4
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()
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:24,代码来源:test_gdaltindex.py
示例15: test_gdaltindex_1
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'
开发者ID:ksshannon,项目名称:gdal,代码行数:82,代码来源:test_gdaltindex.py
示例16: test_gdaltindex_1
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"
开发者ID:drons,项目名称:gdal,代码行数:88,代码来源:test_gdaltindex.py
注:本文中的test_cli_utilities.get_gdaltindex_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论