def test_gdalinfo_8(): if test_cli_utilities.get_gdalinfo_path() is None: return "skip" try: os.remove("../gcore/data/byte.tif.aux.xml") except: pass ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + " ../gcore/data/byte.tif") if ( ret.find( "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 37 0 0 0 0 0 0 0 57 0 0 0 0 0 0 0 62 0 0 0 0 0 0 0 66 0 0 0 0 0 0 0 0 72 0 0 0 0 0 0 0 31 0 0 0 0 0 0 0 24 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1" ) != -1 ): gdaltest.post_reason("did not expect histogram.") print(ret) return "fail" ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + " -hist ../gcore/data/byte.tif") if ( ret.find( "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 37 0 0 0 0 0 0 0 57 0 0 0 0 0 0 0 62 0 0 0 0 0 0 0 66 0 0 0 0 0 0 0 0 72 0 0 0 0 0 0 0 31 0 0 0 0 0 0 0 24 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1" ) == -1 ): gdaltest.post_reason("did not get expected histogram.") print(ret) return "fail" # We will blow an exception if the file does not exist now! os.remove("../gcore/data/byte.tif.aux.xml") return "success"
def test_gdalinfo_22(): if test_cli_utilities.get_gdalinfo_path() is None: return "skip" ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + " --format GTiff", check_memleak=False) expected_strings = [ "Short Name:", "Long Name:", "Extensions:", "Mime Type:", "Help Topic:", "Supports: Create()", "Supports: CreateCopy()", "Supports: Virtual IO", "Creation Datatypes", "<CreationOptionList>", ] for expected_string in expected_strings: if ret.find(expected_string) < 0: gdaltest.post_reason("did not find %s" % expected_string) print(ret) return "fail" return "success"
def test_gdalinfo_1(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() (ret, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalinfo_path() + ' ../gcore/data/byte.tif') assert (err is None or err == ''), 'got error/warning' assert ret.find('Driver: GTiff/GeoTIFF') != -1
def test_gdalinfo_25(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' ../gdrivers/data/byte_with_xmp.tif -listmdd', check_memleak=False) assert 'Metadata domains:' in ret assert ' xml:XMP' in ret
def test_gdalinfo_12(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' --build', check_memleak=False) ret = ret.replace('\r\n', '\n') assert ret.startswith(gdal.VersionInfo('BUILD_INFO'))
def jpeg2000_8(): if gdaltest.jpeg2000_drv is None: return 'skip' # This test will cause a crash with an unpatched version of Jasper, such as the one of Ubuntu 8.04 LTS # --> "jpc_dec.c:1072: jpc_dec_tiledecode: Assertion `dec->numcomps == 3' failed." # Recent Debian/Ubuntu have the appropriate patch. # So we try to run in a subprocess first import test_cli_utilities if test_cli_utilities.get_gdalinfo_path() is not None: ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' --config GDAL_SKIP "JP2ECW JP2MRSID JP2KAK" data/3_13bit_and_1bit.jp2') if ret.find('Band 1') == -1: gdaltest.post_reason('Jasper library would need patches') return 'fail' ds = gdal.Open('data/3_13bit_and_1bit.jp2') expected_checksums = [ 64570, 57277, 56048, 61292] for i in range(4): if ds.GetRasterBand(i+1).Checksum() != expected_checksums[i]: gdaltest.post_reason('unexpected checksum (%d) for band %d' % (expected_checksums[i], i+1)) return 'fail' if ds.GetRasterBand(1).DataType != gdal.GDT_UInt16: gdaltest.post_reason('unexpected data type') return 'fail' return 'success'
def test_gdalinfo_11(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' --version', check_memleak=False) assert ret.startswith(gdal.VersionInfo('--version'))
def test_gdalinfo_6(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' ../gdrivers/data/int.img') assert ret.find('Overviews') != -1 assert ret.find('GDALRasterAttributeTable') != -1
def test_gdalinfo_5(): if test_cli_utilities.get_gdalinfo_path() is None: return "skip" try: os.remove("../gcore/data/byte.tif.aux.xml") except: pass ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + " ../gcore/data/byte.tif") if ret.find("STATISTICS_MINIMUM=74") != -1: gdaltest.post_reason("got wrong minimum.") print(ret) return "fail" ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + " -stats ../gcore/data/byte.tif") if ret.find("STATISTICS_MINIMUM=74") == -1: gdaltest.post_reason("got wrong minimum (2).") print(ret) return "fail" # We will blow an exception if the file does not exist now! os.remove("../gcore/data/byte.tif.aux.xml") return "success"
def test_gdalinfo_5(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' try: os.remove('../gcore/data/byte.tif.aux.xml') except: pass ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' ../gcore/data/byte.tif') if ret.find('STATISTICS_MINIMUM=74') != -1: gdaltest.post_reason( 'got wrong minimum.' ) print(ret) return 'fail' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -stats ../gcore/data/byte.tif') if ret.find('STATISTICS_MINIMUM=74') == -1: gdaltest.post_reason( 'got wrong minimum (2).' ) print(ret) return 'fail' # We will blow an exception if the file does not exist now! os.remove('../gcore/data/byte.tif.aux.xml') return 'success'
def test_gdalinfo_32(): if test_cli_utilities.get_gdalinfo_path() is None: return "skip" try: os.remove("../gcore/data/byte.tif.aux.xml") except: pass ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + " -json ../gcore/data/byte.tif") ret = json.loads(ret) if "" in ret["bands"][0]["metadata"]: gdaltest.post_reason("got wrong minimum.") print(ret) return "fail" ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + " -json -stats ../gcore/data/byte.tif") ret = json.loads(ret) if ret["bands"][0]["metadata"][""]["STATISTICS_MINIMUM"] != "74": gdaltest.post_reason("got wrong minimum (2).") print(ret) return "fail" # We will blow an exception if the file does not exist now! os.remove("../gcore/data/byte.tif.aux.xml") return "success"
def test_gdalinfo_8(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' try: os.remove('../gcore/data/byte.tif.aux.xml') except: pass ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' ../gcore/data/byte.tif') if ret.find('0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 37 0 0 0 0 0 0 0 57 0 0 0 0 0 0 0 62 0 0 0 0 0 0 0 66 0 0 0 0 0 0 0 0 72 0 0 0 0 0 0 0 31 0 0 0 0 0 0 0 24 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1') != -1: gdaltest.post_reason( 'did not expect histogram.' ) print(ret) return 'fail' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -hist ../gcore/data/byte.tif') if ret.find('0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 37 0 0 0 0 0 0 0 57 0 0 0 0 0 0 0 62 0 0 0 0 0 0 0 66 0 0 0 0 0 0 0 0 72 0 0 0 0 0 0 0 31 0 0 0 0 0 0 0 24 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1') == -1: gdaltest.post_reason( 'did not get expected histogram.' ) print(ret) return 'fail' # We will blow an exception if the file does not exist now! os.remove('../gcore/data/byte.tif.aux.xml') return 'success'
def test_gdalinfo_32(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' try: os.remove('../gcore/data/byte.tif.aux.xml') except: pass ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -json ../gcore/data/byte.tif') ret = json.loads(ret) if '' in ret['bands'][0]['metadata']: gdaltest.post_reason( 'got wrong minimum.' ) print(ret) return 'fail' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -json -stats ../gcore/data/byte.tif') ret = json.loads(ret) if ret['bands'][0]['metadata']['']['STATISTICS_MINIMUM'] != '74': gdaltest.post_reason( 'got wrong minimum (2).' ) print(ret) return 'fail' # We will blow an exception if the file does not exist now! os.remove('../gcore/data/byte.tif.aux.xml') return 'success'
def test_gdalinfo_35(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' try: os.remove('../gcore/data/byte.tif.aux.xml') except: pass ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -json ../gcore/data/byte.tif') ret = json.loads(ret) if 'histogram' in ret['bands'][0]: gdaltest.post_reason( 'did not expect histogram.' ) print(ret) return 'fail' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -json -hist ../gcore/data/byte.tif') ret = json.loads(ret) if ret['bands'][0]['histogram']['buckets'] != [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1 ]: gdaltest.post_reason( 'did not get expected histogram.' ) print(ret) return 'fail' # We will blow an exception if the file does not exist now! os.remove('../gcore/data/byte.tif.aux.xml') return 'success'
def test_gdalinfo_29(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -json -checksum ../gcore/data/byte.tif') ret = json.loads(ret) assert ret['bands'][0]['checksum'] == 4672
def test_gdalinfo_39(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -json ../gdrivers/data/byte_with_xmp.tif -mdd all', check_memleak=False) ret = json.loads(ret) assert 'xml:XMP' in ret['metadata']
def test_gdal_translate_27(): if test_cli_utilities.get_gdal_translate_path() is None: return "skip" if test_cli_utilities.get_gdalinfo_path() is None: return "skip" f = open("tmp/test_gdal_translate_27.asc", "wb") f.write( """ncols 2 nrows 2 xllcorner 440720.000000000000 yllcorner 3750120.000000000000 cellsize 60.000000000000 0 256 0 0""".encode( "ascii" ) ) f.close() gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + " -stats tmp/test_gdal_translate_27.asc") # Translate to an output type that accepts 256 as maximum gdaltest.runexternal( test_cli_utilities.get_gdal_translate_path() + " tmp/test_gdal_translate_27.asc tmp/test_gdal_translate_27.tif -ot UInt16" ) ds = gdal.Open("tmp/test_gdal_translate_27.tif") if ds.GetRasterBand(1).GetMetadataItem("STATISTICS_MINIMUM") is None: gdaltest.post_reason("failure") return "fail" ds = None # Translate to an output type that accepts 256 as maximum gdaltest.runexternal( test_cli_utilities.get_gdal_translate_path() + " tmp/test_gdal_translate_27.asc tmp/test_gdal_translate_27.tif -ot Float64" ) ds = gdal.Open("tmp/test_gdal_translate_27.tif") if ds.GetRasterBand(1).GetMetadataItem("STATISTICS_MINIMUM") is None: gdaltest.post_reason("failure") return "fail" ds = None # Translate to an output type that doesn't accept 256 as maximum gdaltest.runexternal( test_cli_utilities.get_gdal_translate_path() + " tmp/test_gdal_translate_27.asc tmp/test_gdal_translate_27.tif -ot Byte" ) ds = gdal.Open("tmp/test_gdal_translate_27.tif") if ds.GetRasterBand(1).GetMetadataItem("STATISTICS_MINIMUM") is not None: gdaltest.post_reason("failure") return "fail" ds = None return "success"
def test_gdalinfo_28(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() (ret, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalinfo_path() + ' -json ../gcore/data/byte.tif') ret = json.loads(ret) assert (err is None or err == ''), 'got error/warning' assert ret['driverShortName'] == 'GTiff'
def test_gdalinfo_20(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' --formats', check_memleak=False) assert 'GTiff -raster- (rw+vs): GeoTIFF' in ret
def test_gdalinfo_24(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' --locale C ../gcore/data/byte.tif', check_memleak=False) assert ret.startswith('Driver: GTiff/GeoTIFF')
def test_gdalinfo_17(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() (_, err) = gdaltest.runexternal_out_and_err( test_cli_utilities.get_gdalinfo_path() + ' --debug', check_memleak=False) assert '--debug option given without debug level' in err
def test_gdalinfo_14(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() (_, err) = gdaltest.runexternal_out_and_err( test_cli_utilities.get_gdalinfo_path() + ' --config', check_memleak=False) assert '--config option given without a key and value argument' in err
def test_gdalinfo_15(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() (_, err) = gdaltest.runexternal_out_and_err( test_cli_utilities.get_gdalinfo_path() + ' --mempreload', check_memleak=False) assert '--mempreload option given without directory path' in err
def test_gdalinfo_33(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -json ../gdrivers/data/int.img') ret = json.loads(ret) assert 'overviews' in ret['bands'][0] assert 'rat' in ret
def test_gdalinfo_26(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' ../gdrivers/data/byte_with_xmp.tif -mdd all', check_memleak=False) assert 'Metadata (xml:XMP)' in ret
def test_gdalinfo_23(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' --help-general', check_memleak=False) assert 'Generic GDAL utility command options' in ret
def test_gdalinfo_1(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() (ret, err) = gdaltest.runexternal_out_and_err( test_cli_utilities.get_gdalinfo_path() + ' ../gcore/data/byte.tif') assert (err is None or err == ''), 'got error/warning' assert ret.find('Driver: GTiff/GeoTIFF') != -1
def test_gdalinfo_10(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' ../gcore/data/byte.tif') assert ret.find('Computed Min/Max=74.000,255.000') == -1 ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -mm ../gcore/data/byte.tif') assert ret.find('Computed Min/Max=74.000,255.000') != -1
def test_gdalinfo_2(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -checksum ../gcore/data/byte.tif') if ret.find('Checksum=4672') == -1: return 'fail' return 'success'
def test_gdalinfo_2(): if test_cli_utilities.get_gdalinfo_path() is None: return "skip" ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + " -checksum ../gcore/data/byte.tif") if ret.find("Checksum=4672") == -1: return "fail" return "success"
def test_gdalinfo_18(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() (_, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalinfo_path() + ' --optfile', check_memleak=False) assert '--optfile option given without filename' in err (_, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalinfo_path() + ' --optfile /foo/bar', check_memleak=False) assert 'Unable to open optfile' in err
def test_gdalinfo_4(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' ../gdrivers/data/bug407.gif') assert ret.find('0: 255,255,255,255') != -1 ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -noct ../gdrivers/data/bug407.gif') assert ret.find('0: 255,255,255,255') == -1
def test_gdalinfo_3(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' ../gcore/data/byte.tif') assert ret.find('Metadata') != -1 ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -nomd ../gcore/data/byte.tif') assert ret.find('Metadata') == -1
def test_gdalinfo_1(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' ../gcore/data/byte.tif') if ret.find('Driver: GTiff/GeoTIFF') == -1: return 'fail' return 'success'
def test_gdalinfo_9(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' ../gdrivers/data/fake_nsif.ntf') assert ret.find('BLOCKA=010000001000000000') == -1, 'got unexpected extra MD.' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -mdd TRE ../gdrivers/data/fake_nsif.ntf') assert ret.find('BLOCKA=010000001000000000') != -1, 'did not get extra MD.'
def test_gdalinfo_27(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal( test_cli_utilities.get_gdalinfo_path() + ' ../gdrivers/data/float64.asc -oo datatype=float64', check_memleak=False) assert 'Type=Float64' in ret
def test_gdalinfo_21(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() (_, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalinfo_path() + ' --format', check_memleak=False) assert '--format option given without a format code' in err (_, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalinfo_path() + ' --format foo_bar', check_memleak=False) assert '--format option given with format' in err
def test_gdalinfo_16(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() (ret, _) = gdaltest.runexternal_out_and_err( test_cli_utilities.get_gdalinfo_path() + ' --debug on --mempreload ../gcore/data /vsimem/byte.tif', check_memleak=False) assert ret.startswith('Driver: GTiff/GeoTIFF')
def test_gdal_translate_27(): if test_cli_utilities.get_gdal_translate_path() is None: return 'skip' if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' f = open('tmp/test_gdal_translate_27.asc', 'wb') f.write("""ncols 2 nrows 2 xllcorner 440720.000000000000 yllcorner 3750120.000000000000 cellsize 60.000000000000 0 256 0 0""".encode('ascii')) f.close() gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -stats tmp/test_gdal_translate_27.asc') # Translate to an output type that accepts 256 as maximum gdaltest.runexternal( test_cli_utilities.get_gdal_translate_path() + ' tmp/test_gdal_translate_27.asc tmp/test_gdal_translate_27.tif -ot UInt16' ) ds = gdal.Open('tmp/test_gdal_translate_27.tif') if ds.GetRasterBand(1).GetMetadataItem('STATISTICS_MINIMUM') is None: gdaltest.post_reason('failure') return 'fail' ds = None # Translate to an output type that accepts 256 as maximum gdaltest.runexternal( test_cli_utilities.get_gdal_translate_path() + ' tmp/test_gdal_translate_27.asc tmp/test_gdal_translate_27.tif -ot Float64' ) ds = gdal.Open('tmp/test_gdal_translate_27.tif') if ds.GetRasterBand(1).GetMetadataItem('STATISTICS_MINIMUM') is None: gdaltest.post_reason('failure') return 'fail' ds = None # Translate to an output type that doesn't accept 256 as maximum gdaltest.runexternal( test_cli_utilities.get_gdal_translate_path() + ' tmp/test_gdal_translate_27.asc tmp/test_gdal_translate_27.tif -ot Byte' ) ds = gdal.Open('tmp/test_gdal_translate_27.tif') if ds.GetRasterBand(1).GetMetadataItem('STATISTICS_MINIMUM') is not None: gdaltest.post_reason('failure') return 'fail' ds = None return 'success'
def vrt_read_20(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' shutil.copy('data/byte.tif', 'tmp') for i in range(3): open('tmp/byte1_%d.vrt' % (i+1), 'wt').write("""<VRTDataset rasterXSize="20" rasterYSize="20"> <VRTRasterBand dataType="Byte" band="1"> <SimpleSource> <SourceFilename relativeToVRT="1">byte.tif</SourceFilename> <SourceBand>1</SourceBand> <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" /> <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" /> <DstRect xOff="0" yOff="0" xSize="20" ySize="20" /> </SimpleSource> </VRTRasterBand> </VRTDataset>""") open('tmp/byte2.vrt', 'wt').write("""<VRTDataset rasterXSize="20" rasterYSize="20"> <VRTRasterBand dataType="Byte" band="1"> <SimpleSource> <SourceFilename relativeToVRT="1">byte1_1.vrt</SourceFilename> <SourceBand>1</SourceBand> <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" /> <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" /> <DstRect xOff="0" yOff="0" xSize="20" ySize="20" /> </SimpleSource> <SimpleSource> <SourceFilename relativeToVRT="1">byte1_2.vrt</SourceFilename> <SourceBand>1</SourceBand> <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" /> <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" /> <DstRect xOff="0" yOff="0" xSize="20" ySize="20" /> </SimpleSource> <SimpleSource> <SourceFilename relativeToVRT="1">byte1_3.vrt</SourceFilename> <SourceBand>1</SourceBand> <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" /> <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" /> <DstRect xOff="0" yOff="0" xSize="20" ySize="20" /> </SimpleSource> </VRTRasterBand> </VRTDataset>""") ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -checksum tmp/byte2.vrt --config VRT_SHARED_SOURCE 0 --config GDAL_MAX_DATASET_POOL_SIZE 3') if ret.find('Checksum=4672') < 0: gdaltest.post_reason('failure') print(ret) return 'fail' os.unlink('tmp/byte.tif') os.unlink('tmp/byte1_1.vrt') os.unlink('tmp/byte1_2.vrt') os.unlink('tmp/byte1_3.vrt') os.unlink('tmp/byte2.vrt') return 'success'
def vrt_read_20(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' shutil.copy('data/byte.tif', 'tmp') for i in range(3): open('tmp/byte1_%d.vrt' % (i + 1), 'wt').write("""<VRTDataset rasterXSize="20" rasterYSize="20"> <VRTRasterBand dataType="Byte" band="1"> <SimpleSource> <SourceFilename relativeToVRT="1">byte.tif</SourceFilename> <SourceBand>1</SourceBand> <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" /> <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" /> <DstRect xOff="0" yOff="0" xSize="20" ySize="20" /> </SimpleSource> </VRTRasterBand> </VRTDataset>""") open('tmp/byte2.vrt', 'wt').write("""<VRTDataset rasterXSize="20" rasterYSize="20"> <VRTRasterBand dataType="Byte" band="1"> <SimpleSource> <SourceFilename relativeToVRT="1">byte1_1.vrt</SourceFilename> <SourceBand>1</SourceBand> <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" /> <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" /> <DstRect xOff="0" yOff="0" xSize="20" ySize="20" /> </SimpleSource> <SimpleSource> <SourceFilename relativeToVRT="1">byte1_2.vrt</SourceFilename> <SourceBand>1</SourceBand> <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" /> <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" /> <DstRect xOff="0" yOff="0" xSize="20" ySize="20" /> </SimpleSource> <SimpleSource> <SourceFilename relativeToVRT="1">byte1_3.vrt</SourceFilename> <SourceBand>1</SourceBand> <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" /> <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" /> <DstRect xOff="0" yOff="0" xSize="20" ySize="20" /> </SimpleSource> </VRTRasterBand> </VRTDataset>""") ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -checksum tmp/byte2.vrt --config VRT_SHARED_SOURCE 0 --config GDAL_MAX_DATASET_POOL_SIZE 3') if ret.find('Checksum=4672') < 0: gdaltest.post_reason('failure') print(ret) return 'fail' os.unlink('tmp/byte.tif') os.unlink('tmp/byte1_1.vrt') os.unlink('tmp/byte1_2.vrt') os.unlink('tmp/byte1_3.vrt') os.unlink('tmp/byte2.vrt') return 'success'
def test_gdalinfo_17(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' (out, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalinfo_path() + ' --debug', check_memleak=False) if err.find('--debug option given without debug level') < 0: print(err) return 'fail' return 'success'
def test_gdalinfo_24(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' --locale C ../gcore/data/byte.tif', check_memleak=False) if ret.find('Driver: GTiff/GeoTIFF') != 0: print(ret) return 'fail' return 'success'
def test_gdalinfo_26(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' ../gdrivers/data/byte_with_xmp.tif -mdd all', check_memleak=False) if ret.find('Metadata (xml:XMP)') < 0: print(ret) return 'fail' return 'success'
def test_gdalinfo_29(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' -json -checksum ../gcore/data/byte.tif') ret = json.loads(ret) if ret['bands'][0]['checksum'] != 4672: return 'fail' return 'success'
def test_gdalinfo_27(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' ../gdrivers/data/float64.asc -oo datatype=float64', check_memleak=False) if ret.find('Type=Float64') < 0: print(ret) return 'fail' return 'success'
def test_gdalinfo_23(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' --help-general', check_memleak=False) if ret.find('Generic GDAL utility command options') < 0: print(ret) return 'fail' return 'success'
def test_gdalinfo_25(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal( test_cli_utilities.get_gdalinfo_path() + ' ../gdrivers/data/gtiff/byte_with_xmp.tif -listmdd', check_memleak=False) assert 'Metadata domains:' in ret assert ' xml:XMP' in ret
def test_gdalinfo_28(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() (ret, err) = gdaltest.runexternal_out_and_err( test_cli_utilities.get_gdalinfo_path() + ' -json ../gcore/data/byte.tif') ret = json.loads(ret) assert (err is None or err == ''), 'got error/warning' assert ret['driverShortName'] == 'GTiff'
def test_gdalinfo_20(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' ret = gdaltest.runexternal(test_cli_utilities.get_gdalinfo_path() + ' --formats', check_memleak=False) if ret.find('GTiff -raster- (rw+vs): GeoTIFF') < 0: print(ret) return 'fail' return 'success'
def test_gdalinfo_39(): if test_cli_utilities.get_gdalinfo_path() is None: pytest.skip() ret = gdaltest.runexternal( test_cli_utilities.get_gdalinfo_path() + ' -json ../gdrivers/data/byte_with_xmp.tif -mdd all', check_memleak=False) ret = json.loads(ret) assert 'xml:XMP' in ret['metadata']
def test_gdalinfo_16(): if test_cli_utilities.get_gdalinfo_path() is None: return 'skip' (ret, err) = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdalinfo_path() + ' --debug on --mempreload ../gcore/data /vsimem/byte.tif', check_memleak=False) if ret.find('Driver: GTiff/GeoTIFF') != 0: print(ret) return 'fail' return 'success'