From ce9b1a70d6d8dfd9c457c1e1b3c373df9293eeaa Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 9 Jan 2024 14:48:02 +0100 Subject: [PATCH] Rename VRTTI driver to GTI --- apps/gdaladdo.cpp | 9 +- apps/gdaltindex_bin.cpp | 2 +- apps/gdaltindex_lib.cpp | 24 +- autotest/gdrivers/{vrttileindex.py => gti.py} | 434 +++++++++--------- autotest/slow_tests/raster.py | 2 +- autotest/utilities/test_gdaladdo.py | 6 +- autotest/utilities/test_gdaltindex_lib.py | 26 +- .../drivers/raster/{vrtti.rst => gti.rst} | 78 ++-- doc/source/drivers/raster/index.rst | 2 +- doc/source/drivers/raster/vrt.rst | 2 +- doc/source/programs/gdalbuildvrt.rst | 2 +- doc/source/programs/gdaltindex.rst | 40 +- frmts/drivers.ini | 2 +- frmts/gdalallregister.cpp | 2 +- frmts/vrt/CMakeLists.txt | 4 +- .../data/{gdalvrtti.xsd => gdaltileindex.xsd} | 8 +- ...exdataset.cpp => gdaltileindexdataset.cpp} | 405 ++++++++-------- frmts/vrt/vrt_priv.h | 10 +- frmts/vrt/vrtdataset.h | 4 +- gcore/gdal_frmts.h | 2 +- ogr/ogrsf_frmts/gpkg/ogrgeopackagedriver.cpp | 4 +- swig/include/python/gdal_python.i | 10 +- 22 files changed, 538 insertions(+), 540 deletions(-) rename autotest/gdrivers/{vrttileindex.py => gti.py} (86%) rename doc/source/drivers/raster/{vrtti.rst => gti.rst} (86%) rename frmts/vrt/data/{gdalvrtti.xsd => gdaltileindex.xsd} (98%) rename frmts/vrt/{vrttileindexdataset.cpp => gdaltileindexdataset.cpp} (91%) diff --git a/apps/gdaladdo.cpp b/apps/gdaladdo.cpp index 0fdd7c44cd25..c29a35df8c3d 100644 --- a/apps/gdaladdo.cpp +++ b/apps/gdaladdo.cpp @@ -296,7 +296,7 @@ static bool PartialRefreshFromSourceTimestamp( return false; } - std::vector regions; + std::vector regions; double dfTotalPixels = 0; @@ -357,7 +357,7 @@ static bool PartialRefreshFromSourceTimestamp( } dfTotalPixels += static_cast(nXSize) * nYSize; - VRTTISourceDesc region; + GTISourceDesc region; region.osFilename = poSource->GetSourceDatasetName(); region.nDstXOff = nXOff; region.nDstYOff = nYOff; @@ -369,10 +369,9 @@ static bool PartialRefreshFromSourceTimestamp( } } } - else if (auto poVRTTIDS = GDALDatasetCastToVRTTIDataset(poDS)) + else if (auto poGTIDS = GDALDatasetCastToGTIDataset(poDS)) { - regions = - VRTTIGetSourcesMoreRecentThan(poVRTTIDS, sStatVRTOvr.st_mtime); + regions = GTIGetSourcesMoreRecentThan(poGTIDS, sStatVRTOvr.st_mtime); for (const auto ®ion : regions) { dfTotalPixels += diff --git a/apps/gdaltindex_bin.cpp b/apps/gdaltindex_bin.cpp index f5f8352c9400..dd1f56814fb3 100644 --- a/apps/gdaltindex_bin.cpp +++ b/apps/gdaltindex_bin.cpp @@ -52,7 +52,7 @@ static void Usage(bool bIsError, const char *pszErrorMsg) " [-src_srs_name field_name] [-src_srs_format " "{AUTO|WKT|EPSG|PROJ}]\n" " [-lyr_name ]\n" - " [-vrtti_filename ]\n" + " [-gti_filename ]\n" " [-tr ] [-te " "]\n" " [-ot ] [-bandcount ] [-nodata " diff --git a/apps/gdaltindex_lib.cpp b/apps/gdaltindex_lib.cpp index 255c62c6a547..f5c58fc7488f 100644 --- a/apps/gdaltindex_lib.cpp +++ b/apps/gdaltindex_lib.cpp @@ -92,7 +92,7 @@ struct GDALTileIndexOptions std::string osDataType{}; bool bMaskBand = false; std::vector aosMetadata{}; - std::string osVRTTIFilename{}; + std::string osGTIFilename{}; bool bRecursive = false; double dfMinPixelSize = std::numeric_limits::quiet_NaN(); double dfMaxPixelSize = std::numeric_limits::quiet_NaN(); @@ -538,16 +538,16 @@ GDALDatasetH GDALTileIndex(const char *pszDest, int nSrcCount, } } - if (!psOptions->osVRTTIFilename.empty()) + if (!psOptions->osGTIFilename.empty()) { if (!psOptions->aosMetadata.empty()) { CPLError(CE_Failure, CPLE_NotSupported, - "-mo is not supported when -vrtti_filename is used"); + "-mo is not supported when -gti_filename is used"); return nullptr; } CPLXMLNode *psRoot = - CPLCreateXMLNode(nullptr, CXT_Element, "VRTTileIndexDataset"); + CPLCreateXMLNode(nullptr, CXT_Element, "GDALTileIndexDataset"); CPLCreateXMLElementAndValue(psRoot, "IndexDataset", pszDest); CPLCreateXMLElementAndValue(psRoot, "IndexLayer", poLayer->GetName()); CPLCreateXMLElementAndValue(psRoot, "LocationField", @@ -648,8 +648,8 @@ GDALDatasetH GDALTileIndex(const char *pszDest, int nSrcCount, { CPLCreateXMLElementAndValue(psRoot, "MaskBand", "true"); } - int res = CPLSerializeXMLTreeToFile(psRoot, - psOptions->osVRTTIFilename.c_str()); + int res = + CPLSerializeXMLTreeToFile(psRoot, psOptions->osGTIFilename.c_str()); CPLDestroyXMLNode(psRoot); if (!res) return nullptr; @@ -778,12 +778,12 @@ GDALDatasetH GDALTileIndex(const char *pszDest, int nSrcCount, CPLFree(pszCurrentPath); } - const bool bIsVRTTIContext = + const bool bIsGTIContext = !std::isnan(psOptions->xres) || !std::isnan(psOptions->xmin) || !psOptions->osBandCount.empty() || !psOptions->osNodata.empty() || !psOptions->osColorInterp.empty() || !psOptions->osDataType.empty() || psOptions->bMaskBand || !psOptions->aosMetadata.empty() || - !psOptions->osVRTTIFilename.empty(); + !psOptions->osGTIFilename.empty(); /* -------------------------------------------------------------------- */ /* loop over GDAL files, processing. */ @@ -931,7 +931,7 @@ GDALDatasetH GDALTileIndex(const char *pszDest, int nSrcCount, } } } - else if (bIsVRTTIContext && !oAlreadyExistingSRS.IsEmpty() && + else if (bIsGTIContext && !oAlreadyExistingSRS.IsEmpty() && (poSrcSRS == nullptr || !poSrcSRS->IsSame(&oAlreadyExistingSRS))) { @@ -939,7 +939,7 @@ GDALDatasetH GDALTileIndex(const char *pszDest, int nSrcCount, CE_Failure, CPLE_AppDefined, "%s is not using the same projection system " "as other files in the tileindex. This is not compatible of " - "VRTTI use. Use -t_srs option to reproject tile extents " + "GTI use. Use -t_srs option to reproject tile extents " "to a common SRS.", osSrcFilename.c_str()); return nullptr; @@ -1288,10 +1288,10 @@ GDALTileIndexOptionsNew(char **papszArgv, { psOptions->bMaskBand = true; } - else if (EQUAL(papszArgv[iArg], "-vrtti_filename")) + else if (EQUAL(papszArgv[iArg], "-gti_filename")) { CHECK_HAS_ENOUGH_ADDITIONAL_ARGS(1); - psOptions->osVRTTIFilename = papszArgv[++iArg]; + psOptions->osGTIFilename = papszArgv[++iArg]; } else if (EQUAL(papszArgv[iArg], "-overwrite")) { diff --git a/autotest/gdrivers/vrttileindex.py b/autotest/gdrivers/gti.py similarity index 86% rename from autotest/gdrivers/vrttileindex.py rename to autotest/gdrivers/gti.py index 6d6ccb0687a7..20f928fdce5c 100755 --- a/autotest/gdrivers/vrttileindex.py +++ b/autotest/gdrivers/gti.py @@ -3,7 +3,7 @@ # $Id$ # # Project: GDAL/OGR Test Suite -# Purpose: Test VRTTileIndexDataset support. +# Purpose: Test GDALTileIndexDataset support. # Author: Even Rouault # ############################################################################### @@ -38,7 +38,7 @@ from osgeo import gdal, ogr -pytestmark = [pytest.mark.require_driver("VRTTI"), pytest.mark.require_driver("GPKG")] +pytestmark = [pytest.mark.require_driver("GTI"), pytest.mark.require_driver("GPKG")] def create_basic_tileindex( @@ -113,9 +113,9 @@ def check_basic( assert vrt_ds.GetMetadata_Dict() == expected_md -def test_vrttileindex_no_metadata(tmp_vsimem): +def test_gti_no_metadata(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, _ = create_basic_tileindex(index_filename, src_ds) @@ -146,9 +146,9 @@ def test_vrttileindex_no_metadata(tmp_vsimem): assert vrt_ds.GetRasterBand(1).GetOverview(0) is None -def test_vrttileindex_custom_metadata(tmp_vsimem): +def test_gti_custom_metadata(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -162,9 +162,9 @@ def test_vrttileindex_custom_metadata(tmp_vsimem): assert vrt_ds.GetRasterBand(1).GetBlockSize() == [2, 4] -def test_vrttileindex_cannot_open_index(tmp_vsimem): +def test_gti_cannot_open_index(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") f = gdal.VSIFOpenL(index_filename, "wb+") assert f gdal.VSIFTruncateL(f, 100) @@ -174,9 +174,9 @@ def test_vrttileindex_cannot_open_index(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_several_layers(tmp_vsimem): +def test_gti_several_layers(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, _ = create_basic_tileindex(index_filename, src_ds) @@ -192,10 +192,10 @@ def test_vrttileindex_several_layers(tmp_vsimem): with pytest.raises( Exception, match="has more than one layer. LAYER open option must be defined" ): - gdal.Open("VRTTI:" + index_filename) + gdal.Open("GTI:" + index_filename) assert ( - gdal.OpenEx("VRTTI:" + index_filename, open_options=["LAYER=index"]) is not None + gdal.OpenEx("GTI:" + index_filename, open_options=["LAYER=index"]) is not None ) index_ds = ogr.Open(index_filename, update=1) @@ -209,11 +209,11 @@ def test_vrttileindex_several_layers(tmp_vsimem): ) -def test_vrttileindex_no_metadata_several_layers_wrong_TILE_INDEX_LAYER( +def test_gti_no_metadata_several_layers_wrong_TILE_INDEX_LAYER( tmp_vsimem, ): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, _ = create_basic_tileindex(index_filename, src_ds) @@ -225,18 +225,18 @@ def test_vrttileindex_no_metadata_several_layers_wrong_TILE_INDEX_LAYER( gdal.Open(index_filename) -def test_vrttileindex_no_layer(tmp_vsimem): +def test_gti_no_layer(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") ogr.GetDriverByName("GPKG").CreateDataSource(index_filename) with pytest.raises(Exception, match="has no vector layer"): gdal.Open(index_filename, gdal.GA_Update) -def test_vrttileindex_no_feature(tmp_vsimem): +def test_gti_no_feature(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds = ogr.GetDriverByName("GPKG").CreateDataSource(index_filename) lyr = index_ds.CreateLayer("index") lyr.CreateField(ogr.FieldDefn("location")) @@ -246,9 +246,9 @@ def test_vrttileindex_no_feature(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_location_wrong_type(tmp_vsimem): +def test_gti_location_wrong_type(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds = ogr.GetDriverByName("GPKG").CreateDataSource(index_filename) lyr = index_ds.CreateLayer("index") lyr.CreateField(ogr.FieldDefn("location", ogr.OFTInteger)) @@ -258,9 +258,9 @@ def test_vrttileindex_location_wrong_type(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_prototype_tile(tmp_vsimem): +def test_gti_wrong_prototype_tile(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds = ogr.GetDriverByName("GPKG").CreateDataSource(index_filename) lyr = index_ds.CreateLayer("index") lyr.CreateField(ogr.FieldDefn("location")) @@ -273,9 +273,9 @@ def test_vrttileindex_wrong_prototype_tile(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_prototype_tile_no_gt(tmp_vsimem): +def test_gti_prototype_tile_no_gt(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") protods_filename = str(tmp_vsimem / "protods_filename.tif") ds = gdal.GetDriverByName("GTiff").Create(protods_filename, 1, 1) del ds @@ -291,9 +291,9 @@ def test_vrttileindex_prototype_tile_no_gt(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_prototype_tile_wrong_gt_3rd_value(tmp_vsimem): +def test_gti_prototype_tile_wrong_gt_3rd_value(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") protods_filename = str(tmp_vsimem / "protods_filename.tif") ds = gdal.GetDriverByName("GTiff").Create(protods_filename, 1, 1) del ds @@ -312,9 +312,9 @@ def test_vrttileindex_prototype_tile_wrong_gt_3rd_value(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_prototype_tile_wrong_gt_5th_value(tmp_vsimem): +def test_gti_prototype_tile_wrong_gt_5th_value(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") protods_filename = str(tmp_vsimem / "protods_filename.tif") ds = gdal.GetDriverByName("GTiff").Create(protods_filename, 1, 1) del ds @@ -333,9 +333,9 @@ def test_vrttileindex_prototype_tile_wrong_gt_5th_value(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_prototype_tile_wrong_gt_6th_value(tmp_vsimem): +def test_gti_prototype_tile_wrong_gt_6th_value(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") protods_filename = str(tmp_vsimem / "protods_filename.tif") ds = gdal.GetDriverByName("GTiff").Create(protods_filename, 1, 1) del ds @@ -354,9 +354,9 @@ def test_vrttileindex_prototype_tile_wrong_gt_6th_value(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_no_extent(tmp_vsimem): +def test_gti_no_extent(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") protods_filename = str(tmp_vsimem / "protods_filename.tif") ds = gdal.GetDriverByName("GTiff").Create(protods_filename, 1, 1) ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) @@ -373,9 +373,9 @@ def test_vrttileindex_no_extent(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_too_big_x(tmp_vsimem): +def test_gti_too_big_x(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") protods_filename = str(tmp_vsimem / "protods_filename.tif") ds = gdal.GetDriverByName("GTiff").Create(protods_filename, 1, 1) ds.SetGeoTransform([0, 1e-30, 0, 0, 0, -1]) @@ -393,9 +393,9 @@ def test_vrttileindex_too_big_x(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_too_big_y(tmp_vsimem): +def test_gti_too_big_y(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") protods_filename = str(tmp_vsimem / "protods_filename.tif") ds = gdal.GetDriverByName("GTiff").Create(protods_filename, 1, 1) ds.SetGeoTransform([0, 1, 0, 0, 0, -1e-30]) @@ -413,9 +413,9 @@ def test_vrttileindex_too_big_y(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_location_field_missing(tmp_vsimem): +def test_gti_location_field_missing(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") # Missing LOCATION_FIELD and non-default location field name src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) @@ -428,9 +428,9 @@ def test_vrttileindex_location_field_missing(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_location_field_set(tmp_vsimem): +def test_gti_location_field_set(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") # LOCATION_FIELD set src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) @@ -445,9 +445,9 @@ def test_vrttileindex_location_field_set(tmp_vsimem): @pytest.mark.parametrize("missing_item", ["RESX", "RESY"]) -def test_vrttileindex_resx_resy(tmp_vsimem, missing_item): +def test_gti_resx_resy(tmp_vsimem, missing_item): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -478,9 +478,9 @@ def test_vrttileindex_resx_resy(tmp_vsimem, missing_item): @pytest.mark.parametrize("missing_item", [None, "XSIZE", "YSIZE", "GEOTRANSFORM"]) -def test_vrttileindex_width_height_geotransform(tmp_vsimem, missing_item): +def test_gti_width_height_geotransform(tmp_vsimem, missing_item): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -508,9 +508,9 @@ def test_vrttileindex_width_height_geotransform(tmp_vsimem, missing_item): gdal.Open(index_filename) -def test_vrttileindex_wrong_width(tmp_vsimem): +def test_gti_wrong_width(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -524,9 +524,9 @@ def test_vrttileindex_wrong_width(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_height(tmp_vsimem): +def test_gti_wrong_height(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -540,9 +540,9 @@ def test_vrttileindex_wrong_height(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_blockxsize(tmp_vsimem): +def test_gti_wrong_blockxsize(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -553,9 +553,9 @@ def test_vrttileindex_wrong_blockxsize(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_blockysize(tmp_vsimem): +def test_gti_wrong_blockysize(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -566,9 +566,9 @@ def test_vrttileindex_wrong_blockysize(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_blockxsize_blockysize(tmp_vsimem): +def test_gti_wrong_blockxsize_blockysize(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -580,9 +580,9 @@ def test_vrttileindex_wrong_blockxsize_blockysize(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_gt(tmp_vsimem): +def test_gti_wrong_gt(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -598,9 +598,9 @@ def test_vrttileindex_wrong_gt(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_gt_3rd_term(tmp_vsimem): +def test_gti_wrong_gt_3rd_term(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -613,9 +613,9 @@ def test_vrttileindex_wrong_gt_3rd_term(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_gt_5th_term(tmp_vsimem): +def test_gti_wrong_gt_5th_term(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -628,9 +628,9 @@ def test_vrttileindex_wrong_gt_5th_term(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_gt_6th_term(tmp_vsimem): +def test_gti_wrong_gt_6th_term(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -644,9 +644,9 @@ def test_vrttileindex_wrong_gt_6th_term(tmp_vsimem): @pytest.mark.parametrize("missing_item", [None, "MINX", "MINY", "MAXX", "MAXY"]) -def test_vrttileindex_minx_miny_maxx_maxy(tmp_vsimem, missing_item): +def test_gti_minx_miny_maxx_maxy(tmp_vsimem, missing_item): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -688,9 +688,9 @@ def test_vrttileindex_minx_miny_maxx_maxy(tmp_vsimem, missing_item): gdal.Open(index_filename) -def test_vrttileindex_wrong_resx(tmp_vsimem): +def test_gti_wrong_resx(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -702,9 +702,9 @@ def test_vrttileindex_wrong_resx(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_resy(tmp_vsimem): +def test_gti_wrong_resy(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -716,9 +716,9 @@ def test_vrttileindex_wrong_resy(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_minx(tmp_vsimem): +def test_gti_wrong_minx(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -736,9 +736,9 @@ def test_vrttileindex_wrong_minx(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_miny(tmp_vsimem): +def test_gti_wrong_miny(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -756,9 +756,9 @@ def test_vrttileindex_wrong_miny(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_resx_wrt_min_max_xy(tmp_vsimem): +def test_gti_wrong_resx_wrt_min_max_xy(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -775,9 +775,9 @@ def test_vrttileindex_wrong_resx_wrt_min_max_xy(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_wrong_resy_wrt_min_max_xy(tmp_vsimem): +def test_gti_wrong_resy_wrt_min_max_xy(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -794,9 +794,9 @@ def test_vrttileindex_wrong_resy_wrt_min_max_xy(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_invalid_srs(tmp_vsimem): +def test_gti_invalid_srs(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -807,9 +807,9 @@ def test_vrttileindex_invalid_srs(tmp_vsimem): gdal.Open(index_filename) -def test_vrttileindex_valid_srs(tmp_vsimem): +def test_gti_valid_srs(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -820,9 +820,9 @@ def test_vrttileindex_valid_srs(tmp_vsimem): assert ds.GetSpatialRef().GetAuthorityCode(None) == "4267" -def test_vrttileindex_invalid_band_count(tmp_vsimem): +def test_gti_invalid_band_count(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -854,9 +854,9 @@ def test_vrttileindex_invalid_band_count(tmp_vsimem): ), ], ) -def test_vrttileindex_inconsistent_number_of_values(tmp_vsimem, md, error_msg): +def test_gti_inconsistent_number_of_values(tmp_vsimem, md, error_msg): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -889,9 +889,9 @@ def test_vrttileindex_inconsistent_number_of_values(tmp_vsimem, md, error_msg): ), ], ) -def test_vrttileindex_valid_nodata(tmp_vsimem, md, expected_nodata): +def test_gti_valid_nodata(tmp_vsimem, md, expected_nodata): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -921,9 +921,9 @@ def test_vrttileindex_valid_nodata(tmp_vsimem, md, expected_nodata): ), ], ) -def test_vrttileindex_invalid_nodata(tmp_vsimem, md, error_msg): +def test_gti_invalid_nodata(tmp_vsimem, md, error_msg): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -949,9 +949,9 @@ def test_vrttileindex_invalid_nodata(tmp_vsimem, md, error_msg): ), ], ) -def test_vrttileindex_invalid_data_type(tmp_vsimem, md, error_msg): +def test_gti_invalid_data_type(tmp_vsimem, md, error_msg): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -980,9 +980,9 @@ def test_vrttileindex_invalid_data_type(tmp_vsimem, md, error_msg): ), ], ) -def test_vrttileindex_invalid_color_interpretation(tmp_vsimem, md, error_msg): +def test_gti_invalid_color_interpretation(tmp_vsimem, md, error_msg): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -994,9 +994,9 @@ def test_vrttileindex_invalid_color_interpretation(tmp_vsimem, md, error_msg): gdal.Open(index_filename) -def test_vrttileindex_no_metadata_rgb(tmp_vsimem): +def test_gti_no_metadata_rgb(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "small_world.tif")) index_ds, _ = create_basic_tileindex(index_filename, src_ds) @@ -1006,9 +1006,9 @@ def test_vrttileindex_no_metadata_rgb(tmp_vsimem): check_basic(vrt_ds, src_ds) -def test_vrttileindex_rgb_left_right(tmp_vsimem): +def test_gti_rgb_left_right(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open("data/small_world.tif") @@ -1047,11 +1047,11 @@ def test_vrttileindex_rgb_left_right(tmp_vsimem): assert ( vrt_ds.GetRasterBand(1).GetMetadataItem("Pixel_0_0", "LocationInfo") - == "/vsimem/test_vrttileindex_rgb_left_right/left.tif" + == "/vsimem/test_gti_rgb_left_right/left.tif" ) -def test_vrttileindex_overlapping_sources(tmp_vsimem): +def test_gti_overlapping_sources(tmp_vsimem): filename1 = str(tmp_vsimem / "one.tif") ds = gdal.GetDriverByName("GTiff").Create(filename1, 1, 1) @@ -1066,7 +1066,7 @@ def test_vrttileindex_overlapping_sources(tmp_vsimem): del ds # No sorting field: feature with max FID has the priority - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds, _ = create_basic_tileindex( index_filename, [gdal.Open(filename1), gdal.Open(filename2)] ) @@ -1076,7 +1076,7 @@ def test_vrttileindex_overlapping_sources(tmp_vsimem): assert vrt_ds.GetRasterBand(1).Checksum() == 2 # Test unsupported sort_field_type = OFTBinary - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [None, None] index_ds, _ = create_basic_tileindex( index_filename, @@ -1091,7 +1091,7 @@ def test_vrttileindex_overlapping_sources(tmp_vsimem): gdal.Open(index_filename) # Test non existent SORT_FIELD - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [None, None] index_ds, lyr = create_basic_tileindex(index_filename, gdal.Open(filename1)) lyr.SetMetadataItem("SORT_FIELD", "non_existing") @@ -1101,7 +1101,7 @@ def test_vrttileindex_overlapping_sources(tmp_vsimem): gdal.Open(index_filename) # Test sort_field_type = OFTString - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = ["2", "1"] index_ds, _ = create_basic_tileindex( index_filename, @@ -1129,7 +1129,7 @@ def test_vrttileindex_overlapping_sources(tmp_vsimem): assert vrt_ds.GetRasterBand(1).Checksum() == 1, sort_values # Test sort_field_type = OFTString - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = ["1", "1"] index_ds, _ = create_basic_tileindex( index_filename, @@ -1144,7 +1144,7 @@ def test_vrttileindex_overlapping_sources(tmp_vsimem): assert vrt_ds.GetRasterBand(1).Checksum() == 2, sort_values # Test sort_field_type = OFTInteger - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [2, 1] index_ds, _ = create_basic_tileindex( index_filename, @@ -1172,7 +1172,7 @@ def test_vrttileindex_overlapping_sources(tmp_vsimem): assert vrt_ds.GetRasterBand(1).Checksum() == 1, sort_values # Test sort_field_type = OFTInteger64 - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [1234567890123 + 2, 1234567890123 + 1] index_ds, _ = create_basic_tileindex( index_filename, @@ -1200,7 +1200,7 @@ def test_vrttileindex_overlapping_sources(tmp_vsimem): assert vrt_ds.GetRasterBand(1).Checksum() == 1, sort_values # Test sort_field_type = OFTReal - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [2.5, 1.5] index_ds, _ = create_basic_tileindex( index_filename, @@ -1228,7 +1228,7 @@ def test_vrttileindex_overlapping_sources(tmp_vsimem): assert vrt_ds.GetRasterBand(1).Checksum() == 1, sort_values # Test sort_field_type = OFTDate - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") for sort_values in [ ["2023-01-01", "2022-12-31"], ["2023-02-01", "2023-01-31"], @@ -1260,7 +1260,7 @@ def test_vrttileindex_overlapping_sources(tmp_vsimem): assert vrt_ds.GetRasterBand(1).Checksum() == 1, sort_values # Test sort_field_type = OFTDateTime - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") for sort_values in [ ["2023-01-01T00:00:00", "2022-12-31T23:59:59"], ["2023-02-01T00:00:00", "2023-01-31T23:59:59"], @@ -1295,7 +1295,7 @@ def test_vrttileindex_overlapping_sources(tmp_vsimem): assert vrt_ds.GetRasterBand(1).Checksum() == 1, sort_values # Test SORT_FIELD_ASC=NO - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds, lyr = create_basic_tileindex( index_filename, [gdal.Open(filename1), gdal.Open(filename2)], @@ -1310,9 +1310,9 @@ def test_vrttileindex_overlapping_sources(tmp_vsimem): assert vrt_ds.GetRasterBand(1).Checksum() == 2, sort_values -def test_vrttileindex_no_source(tmp_vsimem): +def test_gti_no_source(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds, lyr = create_basic_tileindex(index_filename, []) lyr.SetMetadataItem("XSIZE", "2") lyr.SetMetadataItem("YSIZE", "3") @@ -1351,9 +1351,9 @@ def test_vrttileindex_no_source(tmp_vsimem): ) -def test_vrttileindex_invalid_source(tmp_vsimem): +def test_gti_invalid_source(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds = ogr.GetDriverByName("GPKG").CreateDataSource(index_filename) lyr = index_ds.CreateLayer("index", geom_type=ogr.wkbPolygon) lyr.CreateField(ogr.FieldDefn("location")) @@ -1382,7 +1382,7 @@ def test_vrttileindex_invalid_source(tmp_vsimem): vrt_ds.ReadRaster() -def test_vrttileindex_source_relative_location(tmp_vsimem): +def test_gti_source_relative_location(tmp_vsimem): tile_filename = str(tmp_vsimem / "tile.tif") ds = gdal.GetDriverByName("GTiff").Create(tile_filename, 1, 1) @@ -1390,7 +1390,7 @@ def test_vrttileindex_source_relative_location(tmp_vsimem): ds.GetRasterBand(1).Fill(255) del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds = ogr.GetDriverByName("GPKG").CreateDataSource(index_filename) lyr = index_ds.CreateLayer("index", geom_type=ogr.wkbPolygon) lyr.CreateField(ogr.FieldDefn("location")) @@ -1411,14 +1411,14 @@ def test_vrttileindex_source_relative_location(tmp_vsimem): assert vrt_ds.ReadRaster() == b"\xFF" -def test_vrttileindex_source_lacks_bands(tmp_vsimem): +def test_gti_source_lacks_bands(tmp_vsimem): tile_filename = str(tmp_vsimem / "tile.tif") ds = gdal.GetDriverByName("GTiff").Create(tile_filename, 1, 1) ds.SetGeoTransform([10, 1, 0, 20, 0, -1]) del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds = ogr.GetDriverByName("GPKG").CreateDataSource(index_filename) lyr = index_ds.CreateLayer("index", geom_type=ogr.wkbPolygon) lyr.CreateField(ogr.FieldDefn("location")) @@ -1440,14 +1440,14 @@ def test_vrttileindex_source_lacks_bands(tmp_vsimem): vrt_ds.ReadRaster() -def test_vrttileindex_source_lacks_bands_and_relative_location(tmp_vsimem): +def test_gti_source_lacks_bands_and_relative_location(tmp_vsimem): tile_filename = str(tmp_vsimem / "tile.tif") ds = gdal.GetDriverByName("GTiff").Create(tile_filename, 1, 1) ds.SetGeoTransform([10, 1, 0, 20, 0, -1]) del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds = ogr.GetDriverByName("GPKG").CreateDataSource(index_filename) lyr = index_ds.CreateLayer("index", geom_type=ogr.wkbPolygon) lyr.CreateField(ogr.FieldDefn("location")) @@ -1470,9 +1470,9 @@ def test_vrttileindex_source_lacks_bands_and_relative_location(tmp_vsimem): @pytest.mark.require_driver("netCDF") -def test_vrttileindex_source_netcdf_subdataset_absolute(tmp_path): +def test_gti_source_netcdf_subdataset_absolute(tmp_path): - index_filename = str(tmp_path / "index.vrt.gpkg") + index_filename = str(tmp_path / "index.gti.gpkg") src_ds = gdal.Open( 'netCDF:"' + os.path.join(os.getcwd(), "data", "netcdf", "byte.nc") + '":Band1' ) @@ -1483,11 +1483,11 @@ def test_vrttileindex_source_netcdf_subdataset_absolute(tmp_path): @pytest.mark.require_driver("netCDF") -def test_vrttileindex_source_netcdf_subdataset_relative(tmp_path): +def test_gti_source_netcdf_subdataset_relative(tmp_path): tmp_netcdf_filename = str(tmp_path / "byte.nc") shutil.copy("data/netcdf/byte.nc", tmp_netcdf_filename) - index_filename = str(tmp_path / "index.vrt.gpkg") + index_filename = str(tmp_path / "index.gti.gpkg") cwd = os.getcwd() try: os.chdir(tmp_path) @@ -1500,7 +1500,7 @@ def test_vrttileindex_source_netcdf_subdataset_relative(tmp_path): assert gdal.Open(index_filename) is not None -def test_vrttileindex_single_source_nodata_same_as_vrt(tmp_vsimem): +def test_gti_single_source_nodata_same_as_vrt(tmp_vsimem): filename1 = str(tmp_vsimem / "one.tif") ds = gdal.GetDriverByName("GTiff").Create(filename1, 3, 1, 3) @@ -1513,7 +1513,7 @@ def test_vrttileindex_single_source_nodata_same_as_vrt(tmp_vsimem): ds.GetRasterBand(3).SetNoDataValue(1) del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds, lyr = create_basic_tileindex(index_filename, gdal.Open(filename1)) lyr.SetMetadataItem("NODATA", "1") del index_ds @@ -1522,11 +1522,11 @@ def test_vrttileindex_single_source_nodata_same_as_vrt(tmp_vsimem): assert vrt_ds.ReadRaster() == b"\x01\x02\x01" + b"\x01\x03\x01" + b"\x01\x04\x01" assert ( vrt_ds.GetRasterBand(1).GetMetadataItem("Pixel_0_0", "LocationInfo") - == "/vsimem/test_vrttileindex_single_source_nodata_same_as_vrt/one.tif" + == "/vsimem/test_gti_single_source_nodata_same_as_vrt/one.tif" ) -def test_vrttileindex_overlapping_sources_nodata(tmp_vsimem): +def test_gti_overlapping_sources_nodata(tmp_vsimem): filename1 = str(tmp_vsimem / "one.tif") ds = gdal.GetDriverByName("GTiff").Create(filename1, 3, 1) @@ -1542,7 +1542,7 @@ def test_vrttileindex_overlapping_sources_nodata(tmp_vsimem): ds.GetRasterBand(1).SetNoDataValue(3) del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [1, 2] index_ds, lyr = create_basic_tileindex( index_filename, @@ -1559,11 +1559,11 @@ def test_vrttileindex_overlapping_sources_nodata(tmp_vsimem): assert ( vrt_ds.GetRasterBand(1).GetMetadataItem("Pixel_0_0", "LocationInfo") - == "/vsimem/test_vrttileindex_overlapping_sources_nodata/one.tif/vsimem/test_vrttileindex_overlapping_sources_nodata/two.tif" + == "/vsimem/test_gti_overlapping_sources_nodata/one.tif/vsimem/test_gti_overlapping_sources_nodata/two.tif" ) -def test_vrttileindex_on_the_fly_rgb_color_table_expansion(tmp_vsimem): +def test_gti_on_the_fly_rgb_color_table_expansion(tmp_vsimem): tile_filename = str(tmp_vsimem / "color_table.tif") tile_ds = gdal.GetDriverByName("GTiff").Create(tile_filename, 1, 1) @@ -1573,7 +1573,7 @@ def test_vrttileindex_on_the_fly_rgb_color_table_expansion(tmp_vsimem): assert tile_ds.GetRasterBand(1).SetRasterColorTable(ct) == gdal.CE_None tile_ds = None - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds, lyr = create_basic_tileindex(index_filename, gdal.Open(tile_filename)) lyr.SetMetadataItem("BAND_COUNT", "3") lyr.SetMetadataItem("COLOR_INTERPRETATION", "Red,Green,Blue") @@ -1585,7 +1585,7 @@ def test_vrttileindex_on_the_fly_rgb_color_table_expansion(tmp_vsimem): assert vrt_ds.GetRasterBand(3).ReadRaster() == b"\x03" -def test_vrttileindex_on_the_fly_rgba_color_table_expansion(tmp_vsimem): +def test_gti_on_the_fly_rgba_color_table_expansion(tmp_vsimem): tile_filename = str(tmp_vsimem / "color_table.tif") tile_ds = gdal.GetDriverByName("GTiff").Create(tile_filename, 1, 1) @@ -1595,7 +1595,7 @@ def test_vrttileindex_on_the_fly_rgba_color_table_expansion(tmp_vsimem): assert tile_ds.GetRasterBand(1).SetRasterColorTable(ct) == gdal.CE_None tile_ds = None - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds, lyr = create_basic_tileindex(index_filename, gdal.Open(tile_filename)) lyr.SetMetadataItem("BAND_COUNT", "4") lyr.SetMetadataItem("COLOR_INTERPRETATION", "Red,Green,Blue,Alpha") @@ -1608,9 +1608,9 @@ def test_vrttileindex_on_the_fly_rgba_color_table_expansion(tmp_vsimem): assert vrt_ds.GetRasterBand(4).ReadRaster() == b"\xFF" -def test_vrttileindex_on_the_fly_warping(tmp_vsimem): +def test_gti_on_the_fly_warping(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) warped_ds = gdal.Warp("", src_ds, format="VRT", dstSRS="EPSG:4267") @@ -1660,7 +1660,7 @@ def test_vrttileindex_on_the_fly_warping(tmp_vsimem): assert vrt_ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1) == b"\xFE" -def test_vrttileindex_single_source_alpha_no_dest_nodata(tmp_vsimem): +def test_gti_single_source_alpha_no_dest_nodata(tmp_vsimem): filename1 = str(tmp_vsimem / "one.tif") ds = gdal.GetDriverByName("GTiff").Create(filename1, 2, 1, 2) @@ -1670,7 +1670,7 @@ def test_vrttileindex_single_source_alpha_no_dest_nodata(tmp_vsimem): ds.GetRasterBand(2).WriteRaster(0, 0, 2, 1, b"\xFF\x00") del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds, _ = create_basic_tileindex(index_filename, gdal.Open(filename1)) del index_ds @@ -1684,7 +1684,7 @@ def test_vrttileindex_single_source_alpha_no_dest_nodata(tmp_vsimem): assert vrt_ds.GetRasterBand(2).ReadRaster() == b"\xFF\x00" -def test_vrttileindex_overlapping_opaque_sources(tmp_vsimem): +def test_gti_overlapping_opaque_sources(tmp_vsimem): filename1 = str(tmp_vsimem / "one.tif") ds = gdal.GetDriverByName("GTiff").Create(filename1, 1, 1, 1) @@ -1698,7 +1698,7 @@ def test_vrttileindex_overlapping_opaque_sources(tmp_vsimem): ds.GetRasterBand(1).WriteRaster(0, 0, 1, 1, b"\x02") del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [1, 2] index_ds, _ = create_basic_tileindex( index_filename, @@ -1715,11 +1715,11 @@ def test_vrttileindex_overlapping_opaque_sources(tmp_vsimem): assert ( vrt_ds.GetRasterBand(1).GetMetadataItem("Pixel_0_0", "LocationInfo") - == "/vsimem/test_vrttileindex_overlapping_opaque_sources/two.tif" + == "/vsimem/test_gti_overlapping_opaque_sources/two.tif" ) -def test_vrttileindex_overlapping_sources_alpha_2x1(tmp_vsimem): +def test_gti_overlapping_sources_alpha_2x1(tmp_vsimem): filename1 = str(tmp_vsimem / "one.tif") ds = gdal.GetDriverByName("GTiff").Create(filename1, 2, 1, 2) @@ -1737,7 +1737,7 @@ def test_vrttileindex_overlapping_sources_alpha_2x1(tmp_vsimem): ds.GetRasterBand(2).WriteRaster(0, 0, 2, 1, b"\x00\xFE") del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [1, 2] index_ds, _ = create_basic_tileindex( index_filename, @@ -1775,7 +1775,7 @@ def test_vrttileindex_overlapping_sources_alpha_2x1(tmp_vsimem): ) -def test_vrttileindex_overlapping_sources_alpha_1x2(tmp_vsimem): +def test_gti_overlapping_sources_alpha_1x2(tmp_vsimem): filename1 = str(tmp_vsimem / "one.tif") ds = gdal.GetDriverByName("GTiff").Create(filename1, 1, 2, 2) @@ -1793,7 +1793,7 @@ def test_vrttileindex_overlapping_sources_alpha_1x2(tmp_vsimem): ds.GetRasterBand(2).WriteRaster(0, 0, 1, 2, b"\x00\xFE") del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [1, 2] index_ds, _ = create_basic_tileindex( index_filename, @@ -1827,7 +1827,7 @@ def test_vrttileindex_overlapping_sources_alpha_1x2(tmp_vsimem): ) -def test_vrttileindex_overlapping_sources_alpha_sse2_optim(tmp_vsimem): +def test_gti_overlapping_sources_alpha_sse2_optim(tmp_vsimem): filename1 = str(tmp_vsimem / "one.tif") ds = gdal.GetDriverByName("GTiff").Create(filename1, 17, 1, 2) @@ -1869,7 +1869,7 @@ def test_vrttileindex_overlapping_sources_alpha_sse2_optim(tmp_vsimem): ) del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [1, 2] index_ds, _ = create_basic_tileindex( index_filename, @@ -1892,7 +1892,7 @@ def test_vrttileindex_overlapping_sources_alpha_sse2_optim(tmp_vsimem): ) -def test_vrttileindex_mix_rgb_rgba(tmp_vsimem): +def test_gti_mix_rgb_rgba(tmp_vsimem): filename1 = str(tmp_vsimem / "rgba.tif") ds = gdal.GetDriverByName("GTiff").Create(filename1, 2, 1, 4) @@ -1912,7 +1912,7 @@ def test_vrttileindex_mix_rgb_rgba(tmp_vsimem): ds.GetRasterBand(3).WriteRaster(0, 0, 2, 1, b"\x0C\x0D") del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [1, 2] index_ds, _ = create_basic_tileindex( index_filename, @@ -1931,7 +1931,7 @@ def test_vrttileindex_mix_rgb_rgba(tmp_vsimem): assert vrt_ds.GetRasterBand(4).ReadRaster() == b"\xFF\xFF" assert vrt_ds.ReadRaster() == b"\x07\x08" + b"\x0A\x0B" + b"\x0C\x0D" + b"\xFF\xFF" - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [2, 1] index_ds, _ = create_basic_tileindex( index_filename, @@ -1951,7 +1951,7 @@ def test_vrttileindex_mix_rgb_rgba(tmp_vsimem): assert vrt_ds.ReadRaster() == b"\x01\x08" + b"\x03\x0B" + b"\x05\x0D" + b"\xFE\xFF" -def test_vrttileindex_overlapping_sources_mask_band(tmp_vsimem): +def test_gti_overlapping_sources_mask_band(tmp_vsimem): filename1 = str(tmp_vsimem / "one.tif") ds = gdal.GetDriverByName("GTiff").Create(filename1, 2, 1) @@ -1969,7 +1969,7 @@ def test_vrttileindex_overlapping_sources_mask_band(tmp_vsimem): ds.GetRasterBand(1).GetMaskBand().WriteRaster(0, 0, 2, 1, b"\x00\xFE") del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") sort_values = [1, 2] index_ds, _ = create_basic_tileindex( index_filename, @@ -2002,9 +2002,9 @@ def test_vrttileindex_overlapping_sources_mask_band(tmp_vsimem): ) == (255, 254) -def test_vrttileindex_mask_band_explicit(tmp_vsimem): +def test_gti_mask_band_explicit(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -2019,7 +2019,7 @@ def test_vrttileindex_mask_band_explicit(tmp_vsimem): assert vrt_ds.GetRasterBand(1).GetMaskBand().ReadRaster() == b"\xFF" * (20 * 20) -def test_vrttileindex_flushcache(tmp_vsimem): +def test_gti_flushcache(tmp_vsimem): filename1 = str(tmp_vsimem / "one.tif") ds = gdal.GetDriverByName("GTiff").Create(filename1, 1, 1, 1) @@ -2027,7 +2027,7 @@ def test_vrttileindex_flushcache(tmp_vsimem): ds.GetRasterBand(1).WriteRaster(0, 0, 1, 1, b"\x01") del ds - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") index_ds, _ = create_basic_tileindex( index_filename, gdal.Open(filename1), @@ -2051,9 +2051,9 @@ def test_vrttileindex_flushcache(tmp_vsimem): assert vrt_ds.GetRasterBand(1).ReadRaster() == b"\x02" -def test_vrttileindex_ovr_factor(tmp_vsimem): +def test_gti_ovr_factor(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -2089,9 +2089,9 @@ def test_vrttileindex_ovr_factor(tmp_vsimem): ) == src_ds.ReadRaster(buf_xsize=10, buf_ysize=10) -def test_vrttileindex_ovr_factor_invalid(tmp_vsimem): +def test_gti_ovr_factor_invalid(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -2103,9 +2103,9 @@ def test_vrttileindex_ovr_factor_invalid(tmp_vsimem): assert vrt_ds.GetRasterBand(1).GetOverviewCount() == 0 -def test_vrttileindex_ovr_ds_name(tmp_vsimem): +def test_gti_ovr_ds_name(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -2117,9 +2117,9 @@ def test_vrttileindex_ovr_ds_name(tmp_vsimem): assert vrt_ds.GetRasterBand(1).GetOverviewCount() == 0 -def test_vrttileindex_ovr_lyr_name(tmp_vsimem): +def test_gti_ovr_lyr_name(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -2131,9 +2131,9 @@ def test_vrttileindex_ovr_lyr_name(tmp_vsimem): assert vrt_ds.GetRasterBand(1).GetOverviewCount() == 0 -def test_vrttileindex_external_ovr(tmp_vsimem): +def test_gti_external_ovr(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, _ = create_basic_tileindex(index_filename, src_ds) @@ -2149,9 +2149,9 @@ def test_vrttileindex_external_ovr(tmp_vsimem): ) == src_ds.ReadRaster(buf_xsize=10, buf_ysize=10, resample_alg=gdal.GRIORA_Cubic) -def test_vrttileindex_dataset_metadata(tmp_vsimem): +def test_gti_dataset_metadata(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -2192,9 +2192,9 @@ def test_vrttileindex_dataset_metadata(tmp_vsimem): del vrt_ds -def test_vrttileindex_band_metadata(tmp_vsimem): +def test_gti_band_metadata(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) @@ -2283,31 +2283,31 @@ def test_vrttileindex_band_metadata(tmp_vsimem): } -def test_vrttileindex_connection_prefix(tmp_vsimem): +def test_gti_connection_prefix(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, _ = create_basic_tileindex(index_filename, src_ds) del index_ds - vrt_ds = gdal.Open(f"VRTTI:{index_filename}") + vrt_ds = gdal.Open(f"GTI:{index_filename}") check_basic(vrt_ds, src_ds) del vrt_ds -def test_vrttileindex_xml(tmp_vsimem): +def test_gti_xml(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, _ = create_basic_tileindex(index_filename, src_ds) del index_ds xml_filename = str(tmp_vsimem / "index.xml") - xml_content = f""" + xml_content = f""" {index_filename} -""" +""" vrt_ds = gdal.Open(xml_content) check_basic(vrt_ds, src_ds) @@ -2335,14 +2335,14 @@ def test_vrttileindex_xml(tmp_vsimem): } del vrt_ds - xml_content = f""" + xml_content = f""" {index_filename} invalid -""" +""" with pytest.raises(Exception, match="failed to prepare SQL"): gdal.Open(xml_content) - xml_content = f""" + xml_content = f""" {index_filename} 60 60 @@ -2359,7 +2359,7 @@ def test_vrttileindex_xml(tmp_vsimem): cat -""" +""" vrt_ds = gdal.Open(xml_content) band = vrt_ds.GetRasterBand(1) @@ -2375,79 +2375,79 @@ def test_vrttileindex_xml(tmp_vsimem): assert band.GetDefaultRAT() is not None del vrt_ds - xml_content = f""" + xml_content = f""" {index_filename} 60 60 -""" +""" with pytest.raises(Exception, match="band attribute missing on Band element"): gdal.Open(xml_content) - xml_content = f""" + xml_content = f""" {index_filename} 60 60 -""" +""" with pytest.raises(Exception, match="Invalid band number"): gdal.Open(xml_content) - xml_content = f""" + xml_content = f""" {index_filename} 60 60 -""" +""" with pytest.raises(Exception, match="Invalid band number: found 2, expected 1"): gdal.Open(xml_content) - xml_content = f""" + xml_content = f""" {index_filename} 60 60 2 -""" +""" with pytest.raises( Exception, match="Inconsistent BandCount with actual number of Band elements" ): gdal.Open(xml_content) - xml_content = f""" + xml_content = f""" {index_filename} 2 -""" +""" vrt_ds = gdal.Open(xml_content) assert vrt_ds.GetRasterBand(1).GetOverviewCount() == 1 assert vrt_ds.GetRasterBand(1).GetOverview(0).XSize == 10 del vrt_ds - xml_content = f""" + xml_content = f""" {index_filename} {index_filename} -""" +""" vrt_ds = gdal.Open(xml_content) assert vrt_ds.GetRasterBand(1).GetOverviewCount() == 1 assert vrt_ds.GetRasterBand(1).GetOverview(0).XSize == 20 del vrt_ds - xml_content = f""" + xml_content = f""" {index_filename} index -""" +""" vrt_ds = gdal.Open(xml_content) assert vrt_ds.GetRasterBand(1).GetOverviewCount() == 1 assert vrt_ds.GetRasterBand(1).GetOverview(0).XSize == 20 del vrt_ds - xml_content = f""" + xml_content = f""" {index_filename} index @@ -2455,13 +2455,13 @@ def test_vrttileindex_xml(tmp_vsimem): 2 -""" +""" vrt_ds = gdal.Open(xml_content) assert vrt_ds.GetRasterBand(1).GetOverviewCount() == 1 assert vrt_ds.GetRasterBand(1).GetOverview(0).XSize == 10 del vrt_ds - xml_content = """""" + xml_content = """""" with gdaltest.tempfile(xml_filename, xml_content): with pytest.raises( Exception, - match="Missing VRTTileIndexDataset root element", + match="Missing GDALTileIndexDataset root element", ): gdal.Open(xml_filename) - xml_content = """""" + xml_content = """""" with pytest.raises( Exception, match="Missing IndexDataset element", ): gdal.Open(xml_content) - xml_content = """ + xml_content = """ i_do_not_exist -""" +""" with pytest.raises( Exception, match="i_do_not_exist", ): gdal.Open(xml_content) - xml_content = f""" + xml_content = f""" {index_filename} i_do_not_exist -""" +""" with pytest.raises( Exception, match="i_do_not_exist", ): gdal.Open(xml_content) - xml_content = f""" + xml_content = f""" {index_filename} -""" +""" with pytest.raises( Exception, match="At least one of Dataset, Layer or Factor element must be present as an Overview child", ): gdal.Open(xml_content) - xml_content = f""" + xml_content = f""" {index_filename} i_do_not_exist -""" +""" vrt_ds = gdal.Open(xml_content) with pytest.raises(Exception, match="i_do_not_exist"): assert vrt_ds.GetRasterBand(1).GetOverviewCount() == 0 - xml_content = f""" + xml_content = f""" {index_filename} i_do_not_exist -""" +""" vrt_ds = gdal.Open(xml_content) with pytest.raises(Exception, match="i_do_not_exist"): assert vrt_ds.GetRasterBand(1).GetOverviewCount() == 0 -def test_vrttileindex_open_options(tmp_vsimem): +def test_gti_open_options(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, _ = create_basic_tileindex(index_filename, src_ds) @@ -2555,14 +2555,14 @@ def test_vrttileindex_open_options(tmp_vsimem): ) -def test_vrttileindex_xml_vrtti_embedded(tmp_vsimem): +def test_gti_xml_vrtti_embedded(tmp_vsimem): - index_filename = str(tmp_vsimem / "index.vrt.gpkg") + index_filename = str(tmp_vsimem / "index.gti.gpkg") src_ds = gdal.Open(os.path.join(os.getcwd(), "data", "byte.tif")) index_ds, lyr = create_basic_tileindex(index_filename, src_ds) - xml_content = """ + xml_content = """ 60 60 location @@ -2578,9 +2578,9 @@ def test_vrttileindex_xml_vrtti_embedded(tmp_vsimem): cat -""" +""" - lyr.SetMetadata([xml_content], "xml:VRTTI") + lyr.SetMetadata([xml_content], "xml:GTI") del index_ds vrt_ds = gdal.Open(index_filename) diff --git a/autotest/slow_tests/raster.py b/autotest/slow_tests/raster.py index 210d730e8976..c96198b55f33 100644 --- a/autotest/slow_tests/raster.py +++ b/autotest/slow_tests/raster.py @@ -178,7 +178,7 @@ def test_translate_vrtti(tmp_path): del tile_ds print("Creating tile index...") - tileindex = str(tmp_path / "tileindex.vrt.gpkg") + tileindex = str(tmp_path / "tileindex.gti.gpkg") ds = ogr.GetDriverByName("GPKG").CreateDataSource(tileindex) lyr = ds.CreateLayer("index", geom_type=ogr.wkbPolygon, srs=srs) lyr.CreateField(ogr.FieldDefn("location", ogr.OFTString)) diff --git a/autotest/utilities/test_gdaladdo.py b/autotest/utilities/test_gdaladdo.py index a36af5ef62ba..29f23085d3a8 100755 --- a/autotest/utilities/test_gdaladdo.py +++ b/autotest/utilities/test_gdaladdo.py @@ -378,11 +378,11 @@ def test_gdaladdo_reuse_previous_resampling_and_levels( ############################################################################### -# Test --partial-refresh-from-source-timestamp with VRTTI dataset +# Test --partial-refresh-from-source-timestamp with GTI dataset @pytest.mark.require_driver("GPKG") -def test_gdaladdo_partial_refresh_from_source_timestamp_vrtti(gdaladdo_path, tmp_path): +def test_gdaladdo_partial_refresh_from_source_timestamp_gti(gdaladdo_path, tmp_path): left_tif = str(tmp_path / "left.tif") right_tif = str(tmp_path / "right.tif") @@ -391,7 +391,7 @@ def test_gdaladdo_partial_refresh_from_source_timestamp_vrtti(gdaladdo_path, tmp gdal.Translate(right_tif, "../gcore/data/byte.tif", options="-srcwin 10 0 10 20") source_ds = [gdal.Open(left_tif), gdal.Open(right_tif)] - tmp_vrt = str(tmp_path / "test.vrt.gpkg") + tmp_vrt = str(tmp_path / "test.gti.gpkg") index_ds = ogr.GetDriverByName("GPKG").CreateDataSource(tmp_vrt) lyr = index_ds.CreateLayer("index", srs=source_ds[0].GetSpatialRef()) lyr.CreateField(ogr.FieldDefn("location")) diff --git a/autotest/utilities/test_gdaltindex_lib.py b/autotest/utilities/test_gdaltindex_lib.py index fedd2a778d3f..ee3d59525b4b 100644 --- a/autotest/utilities/test_gdaltindex_lib.py +++ b/autotest/utilities/test_gdaltindex_lib.py @@ -264,14 +264,14 @@ def test_gdaltindex_lib_overwrite(tmp_path, four_tiles): ############################################################################### -# Test VRTTI related options +# Test GTI related options @pytest.mark.require_driver("GPKG") -@pytest.mark.require_driver("VRTTI") -def test_gdaltindex_lib_vrtti_non_xml(tmp_path, four_tiles): +@pytest.mark.require_driver("GTI") +def test_gdaltindex_lib_gti_non_xml(tmp_path, four_tiles): - index_filename = str(tmp_path / "test_gdaltindex_lib_vrtti_non_xml.vrt.gpkg") + index_filename = str(tmp_path / "test_gdaltindex_lib_gti_non_xml.gti.gpkg") gdal.TileIndex( index_filename, @@ -312,21 +312,21 @@ def test_gdaltindex_lib_vrtti_non_xml(tmp_path, four_tiles): ############################################################################### -# Test VRTTI related options +# Test GTI related options @pytest.mark.require_driver("GPKG") -@pytest.mark.require_driver("VRTTI") -def test_gdaltindex_lib_vrtti_xml(tmp_path, four_tiles): +@pytest.mark.require_driver("GTI") +def test_gdaltindex_lib_gti_xml(tmp_path, four_tiles): - index_filename = str(tmp_path / "test_gdaltindex_lib_vrtti_non_xml.vrt.gpkg") - vrtti_filename = str(tmp_path / "test_gdaltindex_lib_vrtti_non_xml.vrtti") + index_filename = str(tmp_path / "test_gdaltindex_lib_gti_non_xml.gti.gpkg") + gti_filename = str(tmp_path / "test_gdaltindex_lib_gti_non_xml.gti") gdal.TileIndex( index_filename, four_tiles, layerName="tileindex", - vrttiFilename=vrtti_filename, + gtiFilename=gti_filename, xRes=60, yRes=60, outputBounds=[0, 1, 2, 3], @@ -335,8 +335,8 @@ def test_gdaltindex_lib_vrtti_xml(tmp_path, four_tiles): mask=True, ) - xml = open(vrtti_filename, "rb").read().decode("UTF-8") - assert "test_gdaltindex_lib_vrtti_non_xml.vrt.gpkg" in xml + xml = open(gti_filename, "rb").read().decode("UTF-8") + assert "test_gdaltindex_lib_gti_non_xml.gti.gpkg" in xml assert "tileindex" in xml assert "location" in xml assert "60" in xml @@ -351,7 +351,7 @@ def test_gdaltindex_lib_vrtti_xml(tmp_path, four_tiles): ) assert "true" in xml - ds = gdal.Open(vrtti_filename) + ds = gdal.Open(gti_filename) assert ds.GetGeoTransform() == (0.0, 60.0, 0.0, 3.0, 0.0, -60.0) assert ds.RasterCount == 1 assert ds.GetRasterBand(1).GetNoDataValue() == 0 diff --git a/doc/source/drivers/raster/vrtti.rst b/doc/source/drivers/raster/gti.rst similarity index 86% rename from doc/source/drivers/raster/vrtti.rst rename to doc/source/drivers/raster/gti.rst index 313fa4cee448..e389918e07c8 100644 --- a/doc/source/drivers/raster/vrtti.rst +++ b/doc/source/drivers/raster/gti.rst @@ -1,19 +1,19 @@ -.. _raster.vrtti: +.. _raster.gti: ================================================================================ -VRTTI -- GDAL Virtual Raster Tile Index +GTI -- GDAL Raster Tile Index ================================================================================ .. versionadded:: 3.9 -.. shortname:: VRTTI +.. shortname:: GTI .. built_in_by_default:: Introduction ------------ -The VRTTI driver is a driver that allows to handle catalogs with a large +The GTI driver is a driver that allows to handle catalogs with a large number of raster files (called "tiles" in the rest of this document, even if a regular tiling is not required by the driver), and build a virtual mosaic from them. Each tile may be in any GDAL supported raster format, and be a file @@ -26,52 +26,52 @@ driver with the following main differences: * The tiles are listed as features of any GDAL supported vector format. Use of formats with efficient spatial filtering is recommended, such as :ref:`GeoPackage `, :ref:`FlatGeoBuf ` or - :ref:`PostGIS `. The VRTTI driver can thus use a larger number of + :ref:`PostGIS `. The GTI driver can thus use a larger number of tiles than the VRT driver (hundreds of thousands or more), provided the underlying vector format is efficient. -* The tiles may have different SRS. The VRTTI driver is capable of on-the-fly +* The tiles may have different SRS. The GTI driver is capable of on-the-fly reprojection -* The VRTTI driver offers control on the order in which tiles are composited, +* The GTI driver offers control on the order in which tiles are composited, when they overlap (z-order) -* The VRTTI driver honours the mask/alpha band when compositing together +* The GTI driver honours the mask/alpha band when compositing together overlapping tiles. -* Contrary to the VRT driver, the VRTTI driver does not enable to alter +* Contrary to the VRT driver, the GTI driver does not enable to alter characteristics of referenced tiles, such as their georeferencing, nodata value, etc. If such behavior is desired, the tiles must be for example wrapped - individually in a VRT file before being referenced in the VRTTI index. + individually in a VRT file before being referenced in the GTI index. Connection strings ------------------ -The VRTTI driver accepts different types of connection strings: +The GTI driver accepts different types of connection strings: -* a vector file in GeoPackage format with a ``.vrt.gpkg`` extension, or in - FlatGeoBuf format with a ``.vrt.fgb`` extension, meeting the minimum requirements - for a VRTTI compatible tile index, detailed later. +* a vector file in GeoPackage format with a ``.gti.gpkg`` extension, or in + FlatGeoBuf format with a ``.gti.fgb`` extension, meeting the minimum requirements + for a GTI compatible tile index, detailed later. - For example: ``tileindex.vrt.gpkg`` + For example: ``tileindex.gti.gpkg`` * any vector file in a GDAL supported format, with its filename (or connection - string prefixed with ``VRTTI:`` + string prefixed with ``GTI:`` - For example: ``VRTTI:tileindex.shp`` or ``VRTTI:PG:database=my_db schema=tileindex`` + For example: ``GTI:tileindex.shp`` or ``GTI:PG:database=my_db schema=tileindex`` -* a XML file, following the below VRTTI XML format, generally with the - recommended ``.vrtti`` extension, referencing a vector file. Using such +* a XML file, following the below GTI XML format, generally with the + recommended ``.gti`` extension, referencing a vector file. Using such XML file may be more practical for tile indexes not stored in a file, or if some additional metadata must be defined at the dataset or band level of the virtual mosaic. - For example: ``tileindex.vrtti`` + For example: ``tileindex.gti`` Tile index requirements ----------------------- -The minimum requirements for a VRTTI compatible tile index is to be a +The minimum requirements for a GTI compatible tile index is to be a vector format supported by GDAL, with a geometry column storing polygons with the extent of the tiles, and an attribute field of type string, storing the path to each tile. The default name for this attribute field is ``location``. @@ -191,8 +191,8 @@ PostGIS, ...), the following layer metadata items may be set: * ``OVERVIEW__DATASET=`` where idx is an integer index starting at 0. Name of the dataset to use as the first overview level. This may be a - raster dataset (for example a GeoTIFF file, or another VRTTI dataset). - This may also be a vector dataset with a VRTTI compatible layer, potentially + raster dataset (for example a GeoTIFF file, or another GTI dataset). + This may also be a vector dataset with a GTI compatible layer, potentially specified with ``OVERVIEW__LAYER``. * ``OVERVIEW__OPEN_OPTIONS=[,key2=value2]...`` where idx is an integer index starting at 0. @@ -216,7 +216,7 @@ PostGIS, ...), the following layer metadata items may be set: specified to point to another tile index. All overviews *must* have exactly the same extent as the full resolution -virtual mosaic. The VRTTI driver does not check that, and if that condition is +virtual mosaic. The GTI driver does not check that, and if that condition is not met, subsampled pixel request will lead to incorrect result. In addition to those layer metadata items, the dataset-level metadata item @@ -224,14 +224,14 @@ In addition to those layer metadata items, the dataset-level metadata item which one should be used as the tile index layer. Alternatively to setting those metadata items individually, the corresponding -information can be grouped together in a VRTTI XML document, attached in the -``xml:VRTTI`` metadata domain of the layer (for drivers that support alternate +information can be grouped together in a GTI XML document, attached in the +``xml:GTI`` metadata domain of the layer (for drivers that support alternate metadata domains such as GeoPackage) -VRTTI XML format +GTI XML format ---------------- -A `XML schema of the GDAL VRTTI format `_ +A `XML schema of the GDAL GTI format `_ is available. The following artificial example contains all potential elements and attributes. @@ -240,8 +240,8 @@ mentioned in the previous section. .. code-block:: xml - - PG:dbname=my_db + + PG:dbname=my_db my_layer pub_date >= '2023/12/01' pub_date @@ -312,8 +312,8 @@ mentioned in the previous section. some.tif - - other.vrt.gpkg + + other.gti.gpkg other_layer 0 @@ -323,10 +323,10 @@ mentioned in the previous section. - + -At the VRTTileIndexDataset level, the elements specific to VRTTI XML are: +At the GDALTileIndexDataset level, the elements specific to GTI XML are: * ``Filter``: value of a SQL WHERE clause, used to select a subset of the features of the index. @@ -337,20 +337,20 @@ At the VRTTileIndexDataset level, the elements specific to VRTTI XML are: * ``Metadata``: defines dataset-level metadata. You can refer to the documentation of the :ref:`VRT ` driver for its syntax. -At the Band level, the elements specific to VRTTI XML are: Description, +At the Band level, the elements specific to GTI XML are: Description, Offset, Scale, UnitType, ColorTable, CategoryNames, GDALRasterAttributeTable, Metadata. You can refer to the documentation of the :ref:`VRT ` driver for their syntax and semantics. -How to build a VRTTI comptatible index ? +How to build a GTI comptatible index ? ---------------------------------------- The :ref:`gdaltindex` program may be used to generate both a vector tile index, -and optionally a wrapping .vrtti XML file. +and optionally a wrapping .gti XML file. -A VRTTI comptatible index may also be created by any programmatic means, provided +A GTI comptatible index may also be created by any programmatic means, provided the above format specifications are met. @@ -358,7 +358,7 @@ Open options ------------ The following open options are available. Most of them can be -also defined as layer metadata items or in the .vrtti XML file +also defined as layer metadata items or in the .gti XML file - .. oo:: LAYER diff --git a/doc/source/drivers/raster/index.rst b/doc/source/drivers/raster/index.rst index 426311e960dc..e9230e34d44e 100644 --- a/doc/source/drivers/raster/index.rst +++ b/doc/source/drivers/raster/index.rst @@ -81,6 +81,7 @@ Raster drivers gsbg gsc gta + gti gtiff gxf hdf4 @@ -179,7 +180,6 @@ Raster drivers usgsdem vicar vrt - vrtti wcs webp wms diff --git a/doc/source/drivers/raster/vrt.rst b/doc/source/drivers/raster/vrt.rst index d46d47e0b21d..8b3333304e81 100644 --- a/doc/source/drivers/raster/vrt.rst +++ b/doc/source/drivers/raster/vrt.rst @@ -21,7 +21,7 @@ The VRT format can also describe :ref:`gdal_vrttut_warped` and :ref:`gdal_vrttut_pansharpen` For mosaic with a very large number of tiles (tens of thousands or mores), -the :ref:`VRTTI ` driver may be used starting with GDAL 3.9. +the :ref:`GTI ` driver may be used starting with GDAL 3.9. An example of a simple .vrt file referring to a 512x512 dataset with one band loaded from :file:`utm.tif` might look like this: diff --git a/doc/source/programs/gdalbuildvrt.rst b/doc/source/programs/gdalbuildvrt.rst index 48afa0bc909a..d008a5eb9ab5 100644 --- a/doc/source/programs/gdalbuildvrt.rst +++ b/doc/source/programs/gdalbuildvrt.rst @@ -45,7 +45,7 @@ entries in the tile index will be added to the VRT. Starting with GDAL 3.9, for virtual mosaic with a very large number of tiles (typically hundreds of thousands of tiles, or more), it is advised to use the :ref:`gdaltindex` utility to generate a tile index compatible of the - :ref:`VRTTI ` driver. + :ref:`GTI ` driver. With -separate, each files goes into a separate band in the VRT dataset. Otherwise, the files are considered as tiles of a larger mosaic and the VRT file has as many bands as one diff --git a/doc/source/programs/gdaltindex.rst b/doc/source/programs/gdaltindex.rst index cb7fb1afdcea..a5707a16852c 100644 --- a/doc/source/programs/gdaltindex.rst +++ b/doc/source/programs/gdaltindex.rst @@ -22,7 +22,7 @@ Synopsis [-skip_different_projection] [-t_srs ] [-src_srs_name ] [-src_srs_format {AUTO|WKT|EPSG|PROJ}] [-lyr_name ] - [-vrtti_filename ] + [-gti_filename ] [-tr ] [-te ] [-ot ] [-bandcount ] [-nodata [,...]] [-colorinterp [,...]] [-mask] @@ -36,7 +36,7 @@ Description This program creates an OGR-supported dataset with a record for each input raster file, an attribute containing the filename, and a polygon geometry outlining the raster. This output is suitable for use with `MapServer `__ as a raster -tileindex, or as input for the :ref:`VRTTI ` driver. +tileindex, or as input for the :ref:`GTI ` driver. .. program:: gdaltindex @@ -144,39 +144,39 @@ tileindex, or as input for the :ref:`VRTTI ` driver. might also be used to recursve down to sub-directories. -Options specific to use by the GDAL VRTTI driver +Options specific to use by the GDAL GTI driver ------------------------------------------------ gdaltindex can be used to generate a tile index suitable for use by the -:ref:`VRTTI ` driver. There are two possibilities: +:ref:`GTI ` driver. There are two possibilities: - either use directly a vector tile index generated by gdaltindex as the input - of the VRTTI driver + of the GTI driver -- or generate a small XML .vrtti wrapper file, for easier use with non-file-based +- or generate a small XML .gti wrapper file, for easier use with non-file-based formats such as databases, or for vector formats that do not support setting layer metadata items. Formats that support layer metadata are for example GeoPackage (``-f GPKG``), FlatGeoBuf (``-f FlatGeoBuf``) or PostGIS (``-f PG``) -Setting :option:`-tr` and :option:`-ot` is recommended to avoid the VRTTI +Setting :option:`-tr` and :option:`-ot` is recommended to avoid the GTI driver to have to deduce them by opening the first tile in the index. If the tiles have nodata or mask band, :option:`-nodata` and :option:`-mask` should also be set. -In a VRTTI context, the extent of all tiles referenced in the tile index must +In a GTI context, the extent of all tiles referenced in the tile index must be expressed in a single SRS. Consequently, if input tiles may have different SRS, either :option:`-t_srs` or :option:`-skip_different_projection` should be specified. -.. option:: -vrtti_filename +.. option:: -gti_filename .. versionadded:: 3.9 Filename of the XML Virtual Tile Index file to generate, that can be used - as an input for the GDAL VRTTI / Virtual Raster Tile Index driver. + as an input for the GDAL GTI / Virtual Raster Tile Index driver. This can be useful when writing the tile index in a vector format that does not support writing layer metadata items. @@ -186,7 +186,7 @@ specified. Target resolution in SRS unit per pixel. - Written in the XML Virtutual Tile Index if :option:`-vrtti_filename` + Written in the XML Virtutual Tile Index if :option:`-gti_filename` is specified, or as ``RESX`` and ``RESY`` layer metadata items for formats that support layer metadata. @@ -196,7 +196,7 @@ specified. Target extent in SRS unit. - Written in the XML Virtutual Tile Index if :option:`-vrtti_filename` + Written in the XML Virtutual Tile Index if :option:`-gti_filename` is specified, or as ``MINX``, ``MINY``, ``MAXX`` and ``MAXY`` layer metadata items for formats that support layer metadata. @@ -208,7 +208,7 @@ specified. ``Int16``, ``UInt32``, ``Int32``, ``UInt64``, ``Int64``, ``Float32``, ``Float64``, ``CInt16``, ``CInt32``, ``CFloat32`` or ``CFloat64`` - Written in the XML Virtutual Tile Index if :option:`-vrtti_filename` + Written in the XML Virtutual Tile Index if :option:`-gti_filename` is specified, or as ``DATA_TYPE`` layer metadata item for formats that support layer metadata. @@ -218,7 +218,7 @@ specified. Number of bands of the tiles of the tile index. - Written in the XML Virtutual Tile Index if :option:`-vrtti_filename` + Written in the XML Virtutual Tile Index if :option:`-gti_filename` is specified, or as ``BAND_COUNT`` layer metadata item for formats that support layer metadata. @@ -235,7 +235,7 @@ specified. Nodata value of the tiles of the tile index. - Written in the XML Virtutual Tile Index if :option:`-vrtti_filename` + Written in the XML Virtutual Tile Index if :option:`-gti_filename` is specified, or as ``NODATA`` layer metadata item for formats that support layer metadata. @@ -246,7 +246,7 @@ specified. Color interpretation of of the tiles of the tile index: ``red``, ``green``, ``blue``, ``alpha``, ``gray``, ``undefined``. - Written in the XML Virtutual Tile Index if :option:`-vrtti_filename` + Written in the XML Virtutual Tile Index if :option:`-gti_filename` is specified, or as ``COLOR_INTERPRETATION`` layer metadata item for formats that support layer metadata. @@ -256,7 +256,7 @@ specified. Whether tiles in the tile index have a mask band. - Written in the XML Virtutual Tile Index if :option:`-vrtti_filename` + Written in the XML Virtutual Tile Index if :option:`-gti_filename` is specified, or as ``MASK_BAND`` layer metadata item for formats that support layer metadata. @@ -268,7 +268,7 @@ specified. metadata. This option may be repeated. - .. note:: This option cannot be used together :option:`-vrtti_filename` + .. note:: This option cannot be used together :option:`-gti_filename` .. option:: -fetch_md @@ -315,11 +315,11 @@ Examples gdaltindex -t_srs EPSG:4326 -src_srs_name src_srs tile_index_mixed_srs.shp *.tif - Make a tile index from files listed in a text file, with metadata suitable - for use by the GDAL VRTTI / Virtual Raster Tile Index driver. + for use by the GDAL GTI / Virtual Raster Tile Index driver. :: - gdaltindex tile_index.vrt.gpkg -datatype Byte -tr 60 60 -colorinterp Red,Green,Blue --optfile my_list.txt + gdaltindex tile_index.gti.gpkg -datatype Byte -tr 60 60 -colorinterp Red,Green,Blue --optfile my_list.txt C API ----- diff --git a/frmts/drivers.ini b/frmts/drivers.ini index 06e69303af0c..01cce7154ea0 100644 --- a/frmts/drivers.ini +++ b/frmts/drivers.ini @@ -12,7 +12,7 @@ [order] VRT -VRTTI +GTI Derived GTiff COG diff --git a/frmts/gdalallregister.cpp b/frmts/gdalallregister.cpp index 4510ebf10827..0e1b73b85fc2 100644 --- a/frmts/gdalallregister.cpp +++ b/frmts/gdalallregister.cpp @@ -323,7 +323,7 @@ void CPL_STDCALL GDALAllRegister() #ifdef FRMT_vrt GDALRegister_VRT(); - GDALRegister_VRTTI(); + GDALRegister_GTI(); GDALRegister_Derived(); #endif diff --git a/frmts/vrt/CMakeLists.txt b/frmts/vrt/CMakeLists.txt index 4f35a8baca61..ba770561f569 100644 --- a/frmts/vrt/CMakeLists.txt +++ b/frmts/vrt/CMakeLists.txt @@ -15,14 +15,14 @@ add_gdal_driver( pixelfunctions.cpp vrtpansharpened.cpp vrtmultidim.cpp - vrttileindexdataset.cpp + gdaltileindexdataset.cpp STRONG_CXX_WFLAGS) gdal_standard_includes(gdal_vrt) target_include_directories(gdal_vrt PRIVATE ${GDAL_RASTER_FORMAT_SOURCE_DIR}/raw) set(GDAL_DATA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/gdalvrt.xsd - ${CMAKE_CURRENT_SOURCE_DIR}/data/gdalvrtti.xsd + ${CMAKE_CURRENT_SOURCE_DIR}/data/gdaltileindex.xsd ) set_property( TARGET ${GDAL_LIB_TARGET_NAME} diff --git a/frmts/vrt/data/gdalvrtti.xsd b/frmts/vrt/data/gdaltileindex.xsd similarity index 98% rename from frmts/vrt/data/gdalvrtti.xsd rename to frmts/vrt/data/gdaltileindex.xsd index e8d314021b3f..7e0d38a35599 100644 --- a/frmts/vrt/data/gdalvrtti.xsd +++ b/frmts/vrt/data/gdaltileindex.xsd @@ -4,7 +4,7 @@ * $Id$ * * Project: GDAL/OGR - * Purpose: XML Schema for GDAL VRTTI files. + * Purpose: XML Schema for GDAL GTI files. * Author: Even Rouault, * ********************************************************************** @@ -30,12 +30,12 @@ ****************************************************************************/ --> - + - - + + diff --git a/frmts/vrt/vrttileindexdataset.cpp b/frmts/vrt/gdaltileindexdataset.cpp similarity index 91% rename from frmts/vrt/vrttileindexdataset.cpp rename to frmts/vrt/gdaltileindexdataset.cpp index 82380458c0b1..e80365c34ab6 100644 --- a/frmts/vrt/vrttileindexdataset.cpp +++ b/frmts/vrt/gdaltileindexdataset.cpp @@ -62,7 +62,7 @@ constexpr int GT_TOPLEFT_Y = 3; constexpr int GT_ROTATION_PARAM2 = 4; constexpr int GT_NS_RES = 5; -constexpr const char *VRTTI_PREFIX = "VRTTI:"; +constexpr const char *GTI_PREFIX = "GTI:"; constexpr const char *MD_DS_TILE_INDEX_LAYER = "TILE_INDEX_LAYER"; @@ -116,31 +116,31 @@ constexpr const char *const MD_BAND_UNITTYPE = "UNITTYPE"; constexpr const char *const apszReservedBandItems[] = { MD_BAND_OFFSET, MD_BAND_SCALE, MD_BAND_UNITTYPE}; -constexpr const char *VRTTI_XML_BANDCOUNT = "BandCount"; -constexpr const char *VRTTI_XML_DATATYPE = "DataType"; -constexpr const char *VRTTI_XML_NODATAVALUE = "NoDataValue"; -constexpr const char *VRTTI_XML_COLORINTERP = "ColorInterp"; -constexpr const char *VRTTI_XML_LOCATIONFIELD = "LocationField"; -constexpr const char *VRTTI_XML_SORTFIELD = "SortField"; -constexpr const char *VRTTI_XML_SORTFIELDASC = "SortFieldAsc"; -constexpr const char *VRTTI_XML_MASKBAND = "MaskBand"; -constexpr const char *VRTTI_XML_OVERVIEW_ELEMENT = "Overview"; -constexpr const char *VRTTI_XML_OVERVIEW_DATASET = "Dataset"; -constexpr const char *VRTTI_XML_OVERVIEW_LAYER = "Layer"; -constexpr const char *VRTTI_XML_OVERVIEW_FACTOR = "Factor"; - -constexpr const char *VRTTI_XML_BAND_ELEMENT = "Band"; -constexpr const char *VRTTI_XML_BAND_NUMBER = "band"; -constexpr const char *VRTTI_XML_BAND_DATATYPE = "dataType"; -constexpr const char *VRTTI_XML_BAND_DESCRIPTION = "Description"; -constexpr const char *VRTTI_XML_BAND_OFFSET = "Offset"; -constexpr const char *VRTTI_XML_BAND_SCALE = "Scale"; -constexpr const char *VRTTI_XML_BAND_NODATAVALUE = "NoDataValue"; -constexpr const char *VRTTI_XML_BAND_UNITTYPE = "UnitType"; -constexpr const char *VRTTI_XML_BAND_COLORINTERP = "ColorInterp"; -constexpr const char *VRTTI_XML_CATEGORYNAMES = "CategoryNames"; -constexpr const char *VRTTI_XML_COLORTABLE = "ColorTable"; -constexpr const char *VRTTI_XML_RAT = "GDALRasterAttributeTable"; +constexpr const char *GTI_XML_BANDCOUNT = "BandCount"; +constexpr const char *GTI_XML_DATATYPE = "DataType"; +constexpr const char *GTI_XML_NODATAVALUE = "NoDataValue"; +constexpr const char *GTI_XML_COLORINTERP = "ColorInterp"; +constexpr const char *GTI_XML_LOCATIONFIELD = "LocationField"; +constexpr const char *GTI_XML_SORTFIELD = "SortField"; +constexpr const char *GTI_XML_SORTFIELDASC = "SortFieldAsc"; +constexpr const char *GTI_XML_MASKBAND = "MaskBand"; +constexpr const char *GTI_XML_OVERVIEW_ELEMENT = "Overview"; +constexpr const char *GTI_XML_OVERVIEW_DATASET = "Dataset"; +constexpr const char *GTI_XML_OVERVIEW_LAYER = "Layer"; +constexpr const char *GTI_XML_OVERVIEW_FACTOR = "Factor"; + +constexpr const char *GTI_XML_BAND_ELEMENT = "Band"; +constexpr const char *GTI_XML_BAND_NUMBER = "band"; +constexpr const char *GTI_XML_BAND_DATATYPE = "dataType"; +constexpr const char *GTI_XML_BAND_DESCRIPTION = "Description"; +constexpr const char *GTI_XML_BAND_OFFSET = "Offset"; +constexpr const char *GTI_XML_BAND_SCALE = "Scale"; +constexpr const char *GTI_XML_BAND_NODATAVALUE = "NoDataValue"; +constexpr const char *GTI_XML_BAND_UNITTYPE = "UnitType"; +constexpr const char *GTI_XML_BAND_COLORINTERP = "ColorInterp"; +constexpr const char *GTI_XML_CATEGORYNAMES = "CategoryNames"; +constexpr const char *GTI_XML_COLORTABLE = "ColorTable"; +constexpr const char *GTI_XML_RAT = "GDALRasterAttributeTable"; /************************************************************************/ /* ENDS_WITH_CI() */ @@ -152,13 +152,13 @@ static inline bool ENDS_WITH_CI(const char *a, const char *b) } /************************************************************************/ -/* VRTTileIndexDataset */ +/* GDALTileIndexDataset */ /************************************************************************/ -class VRTTileIndexBand; -class VRTTileIndexDataset final : public GDALPamDataset +class GDALTileIndexBand; +class GDALTileIndexDataset final : public GDALPamDataset { - friend class VRTTileIndexBand; + friend class GDALTileIndexBand; CPLXMLTreeCloser m_psXMLTree{nullptr}; bool m_bXMLUpdatable = false; @@ -171,7 +171,7 @@ class VRTTileIndexDataset final : public GDALPamDataset OGRSpatialReference m_oSRS{}; lru11::Cache> m_oMapSharedSources{ 500}; - std::unique_ptr m_poMaskBand{}; + std::unique_ptr m_poMaskBand{}; bool m_bSameDataType = true; bool m_bSameNoData = true; double m_dfLastMinXFilter = std::numeric_limits::quiet_NaN(); @@ -216,11 +216,11 @@ class VRTTileIndexDataset final : public GDALPamDataset bool TileIndexSupportsEditingLayerMetadata() const; - CPL_DISALLOW_COPY_ASSIGN(VRTTileIndexDataset) + CPL_DISALLOW_COPY_ASSIGN(GDALTileIndexDataset) public: - VRTTileIndexDataset(); - ~VRTTileIndexDataset() override; + GDALTileIndexDataset(); + ~GDALTileIndexDataset() override; bool Open(GDALOpenInfo *poOpenInfo); @@ -244,18 +244,18 @@ class VRTTileIndexDataset final : public GDALPamDataset void LoadOverviews(); - std::vector GetSourcesMoreRecentThan(int64_t mTime); + std::vector GetSourcesMoreRecentThan(int64_t mTime); }; /************************************************************************/ -/* VRTTileIndexBand */ +/* GDALTileIndexBand */ /************************************************************************/ -class VRTTileIndexBand final : public GDALPamRasterBand +class GDALTileIndexBand final : public GDALPamRasterBand { - friend class VRTTileIndexDataset; + friend class GDALTileIndexDataset; - VRTTileIndexDataset *m_poDS = nullptr; + GDALTileIndexDataset *m_poDS = nullptr; bool m_bNoDataValueSet = false; double m_dfNoDataValue = 0; GDALColorInterp m_eColorInterp = GCI_Undefined; @@ -267,11 +267,11 @@ class VRTTileIndexBand final : public GDALPamRasterBand std::unique_ptr m_poColorTable{}; std::unique_ptr m_poRAT{}; - CPL_DISALLOW_COPY_ASSIGN(VRTTileIndexBand) + CPL_DISALLOW_COPY_ASSIGN(GDALTileIndexBand) public: - VRTTileIndexBand(VRTTileIndexDataset *poDSIn, int nBandIn, GDALDataType eDT, - int nBlockXSizeIn, int nBlockYSizeIn); + GDALTileIndexBand(GDALTileIndexDataset *poDSIn, int nBandIn, + GDALDataType eDT, int nBlockXSizeIn, int nBlockYSizeIn); double GetNoDataValue(int *pbHasNoData) override { @@ -381,10 +381,10 @@ static inline bool IsSameNaNAware(double a, double b) } /************************************************************************/ -/* VRTTileIndexDataset() */ +/* GDALTileIndexDataset() */ /************************************************************************/ -VRTTileIndexDataset::VRTTileIndexDataset() +GDALTileIndexDataset::GDALTileIndexDataset() : m_osUniqueHandle(CPLSPrintf("%p", this)) { } @@ -398,7 +398,7 @@ static std::string GetAbsoluteFileName(const char *pszTileName, { if (CPLIsFilenameRelative(pszTileName) && !STARTS_WITH(pszTileName, "GetPathComponent().empty()) @@ -427,25 +427,25 @@ static std::string GetAbsoluteFileName(const char *pszTileName, /* Open() */ /************************************************************************/ -bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) +bool GDALTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) { eAccess = poOpenInfo->eAccess; CPLXMLNode *psRoot = nullptr; const char *pszIndexDataset = poOpenInfo->pszFilename; - if (STARTS_WITH(poOpenInfo->pszFilename, VRTTI_PREFIX)) + if (STARTS_WITH(poOpenInfo->pszFilename, GTI_PREFIX)) { - pszIndexDataset = poOpenInfo->pszFilename + strlen(VRTTI_PREFIX); + pszIndexDataset = poOpenInfo->pszFilename + strlen(GTI_PREFIX); } - else if (STARTS_WITH(poOpenInfo->pszFilename, "pszFilename, "pszFilename)); if (m_psXMLTree == nullptr) return false; } else if (strstr(reinterpret_cast(poOpenInfo->pabyHeader), - "pszFilename)); if (m_psXMLTree == nullptr) @@ -455,11 +455,11 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) if (m_psXMLTree) { - psRoot = CPLGetXMLNode(m_psXMLTree.get(), "=VRTTileIndexDataset"); + psRoot = CPLGetXMLNode(m_psXMLTree.get(), "=GDALTileIndexDataset"); if (psRoot == nullptr) { CPLError(CE_Failure, CPLE_AppDefined, - "Missing VRTTileIndexDataset root element."); + "Missing GDALTileIndexDataset root element."); return false; } @@ -545,7 +545,7 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) } else { - if (STARTS_WITH(poOpenInfo->pszFilename, VRTTI_PREFIX)) + if (STARTS_WITH(poOpenInfo->pszFilename, GTI_PREFIX)) { CPLError(CE_Failure, CPLE_AppDefined, "%s has more than one layer. LAYER open option " @@ -572,21 +572,21 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) return false; } - // Try to get the metadata from an embedded xml:VRTTI domain + // Try to get the metadata from an embedded xml:GTI domain if (!m_psXMLTree) { - char **papszMD = m_poLayer->GetMetadata("xml:VRTTI"); + char **papszMD = m_poLayer->GetMetadata("xml:GTI"); if (papszMD && papszMD[0]) { m_psXMLTree.reset(CPLParseXMLString(papszMD[0])); if (m_psXMLTree == nullptr) return false; - psRoot = CPLGetXMLNode(m_psXMLTree.get(), "=VRTTileIndexDataset"); + psRoot = CPLGetXMLNode(m_psXMLTree.get(), "=GDALTileIndexDataset"); if (psRoot == nullptr) { CPLError(CE_Failure, CPLE_AppDefined, - "Missing VRTTileIndexDataset root element."); + "Missing GDALTileIndexDataset root element."); return false; } } @@ -601,21 +601,21 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) return pszVal; if (EQUAL(pszItem, MD_BAND_COUNT)) - pszItem = VRTTI_XML_BANDCOUNT; + pszItem = GTI_XML_BANDCOUNT; else if (EQUAL(pszItem, MD_DATA_TYPE)) - pszItem = VRTTI_XML_DATATYPE; + pszItem = GTI_XML_DATATYPE; else if (EQUAL(pszItem, MD_NODATA)) - pszItem = VRTTI_XML_NODATAVALUE; + pszItem = GTI_XML_NODATAVALUE; else if (EQUAL(pszItem, MD_COLOR_INTERPRETATION)) - pszItem = VRTTI_XML_COLORINTERP; + pszItem = GTI_XML_COLORINTERP; else if (EQUAL(pszItem, MD_LOCATION_FIELD)) - pszItem = VRTTI_XML_LOCATIONFIELD; + pszItem = GTI_XML_LOCATIONFIELD; else if (EQUAL(pszItem, MD_SORT_FIELD)) - pszItem = VRTTI_XML_SORTFIELD; + pszItem = GTI_XML_SORTFIELD; else if (EQUAL(pszItem, MD_SORT_FIELD_ASC)) - pszItem = VRTTI_XML_SORTFIELDASC; + pszItem = GTI_XML_SORTFIELDASC; else if (EQUAL(pszItem, MD_MASK_BAND)) - pszItem = VRTTI_XML_MASKBAND; + pszItem = GTI_XML_MASKBAND; pszVal = CPLGetXMLValue(psRoot, pszItem, nullptr); if (pszVal) return pszVal; @@ -776,15 +776,15 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) psIter = psIter->psNext) { if (psIter->eType == CXT_Element && - strcmp(psIter->pszValue, VRTTI_XML_BAND_ELEMENT) == 0) + strcmp(psIter->pszValue, GTI_XML_BAND_ELEMENT) == 0) { const char *pszBand = - CPLGetXMLValue(psIter, VRTTI_XML_BAND_NUMBER, nullptr); + CPLGetXMLValue(psIter, GTI_XML_BAND_NUMBER, nullptr); if (!pszBand) { CPLError(CE_Failure, CPLE_AppDefined, "%s attribute missing on %s element", - VRTTI_XML_BAND_NUMBER, VRTTI_XML_BAND_ELEMENT); + GTI_XML_BAND_NUMBER, GTI_XML_BAND_ELEMENT); return false; } const int nBand = atoi(pszBand); @@ -819,7 +819,7 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) { CPLError(CE_Failure, CPLE_AppDefined, "Inconsistent %s with actual number of %s elements", - VRTTI_XML_BANDCOUNT, VRTTI_XML_BAND_ELEMENT); + GTI_XML_BANDCOUNT, GTI_XML_BAND_ELEMENT); return false; } } @@ -1389,14 +1389,14 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) nRasterYSize = static_cast(std::ceil(nRasterYSize / dfOvrFactor)); } - VRTTileIndexBand *poFirstBand = nullptr; + GDALTileIndexBand *poFirstBand = nullptr; for (int i = 0; i < nBandCount; ++i) { GDALDataType eDataType = aeDataTypes[i]; if (!apoXMLNodeBands.empty()) { - const char *pszVal = CPLGetXMLValue( - apoXMLNodeBands[i], VRTTI_XML_BAND_DATATYPE, nullptr); + const char *pszVal = CPLGetXMLValue(apoXMLNodeBands[i], + GTI_XML_BAND_DATATYPE, nullptr); if (pszVal) { eDataType = GDALGetDataTypeByName(pszVal); @@ -1404,7 +1404,7 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) return false; } } - auto poBandUniquePtr = std::make_unique( + auto poBandUniquePtr = std::make_unique( this, i + 1, eDataType, nBlockXSize, nBlockYSize); auto poBand = poBandUniquePtr.get(); SetBand(i + 1, poBandUniquePtr.release()); @@ -1418,7 +1418,7 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) if (!apoXMLNodeBands.empty()) { const char *pszVal = CPLGetXMLValue( - apoXMLNodeBands[i], VRTTI_XML_BAND_DESCRIPTION, nullptr); + apoXMLNodeBands[i], GTI_XML_BAND_DESCRIPTION, nullptr); if (pszVal) { poBand->GDALRasterBand::SetDescription(pszVal); @@ -1433,7 +1433,7 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) if (!apoXMLNodeBands.empty()) { const char *pszVal = CPLGetXMLValue( - apoXMLNodeBands[i], VRTTI_XML_BAND_NODATAVALUE, nullptr); + apoXMLNodeBands[i], GTI_XML_BAND_NODATAVALUE, nullptr); if (pszVal) { poBand->m_bNoDataValueSet = true; @@ -1454,7 +1454,7 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) if (!apoXMLNodeBands.empty()) { const char *pszVal = CPLGetXMLValue( - apoXMLNodeBands[i], VRTTI_XML_BAND_COLORINTERP, nullptr); + apoXMLNodeBands[i], GTI_XML_BAND_COLORINTERP, nullptr); if (pszVal) { poBand->m_eColorInterp = @@ -1469,8 +1469,8 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) } if (!apoXMLNodeBands.empty()) { - const char *pszVal = CPLGetXMLValue(apoXMLNodeBands[i], - VRTTI_XML_BAND_SCALE, nullptr); + const char *pszVal = + CPLGetXMLValue(apoXMLNodeBands[i], GTI_XML_BAND_SCALE, nullptr); if (pszVal) { poBand->m_dfScale = CPLAtof(pszVal); @@ -1485,7 +1485,7 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) if (!apoXMLNodeBands.empty()) { const char *pszVal = CPLGetXMLValue(apoXMLNodeBands[i], - VRTTI_XML_BAND_OFFSET, nullptr); + GTI_XML_BAND_OFFSET, nullptr); if (pszVal) { poBand->m_dfOffset = CPLAtof(pszVal); @@ -1499,8 +1499,8 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) } if (!apoXMLNodeBands.empty()) { - const char *pszVal = CPLGetXMLValue( - apoXMLNodeBands[i], VRTTI_XML_BAND_UNITTYPE, nullptr); + const char *pszVal = CPLGetXMLValue(apoXMLNodeBands[i], + GTI_XML_BAND_UNITTYPE, nullptr); if (pszVal) { poBand->m_osUnit = pszVal; @@ -1513,20 +1513,20 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) poBand->oMDMD.XMLInit(psBandNode, TRUE); if (const CPLXMLNode *psCategoryNames = - CPLGetXMLNode(psBandNode, VRTTI_XML_CATEGORYNAMES)) + CPLGetXMLNode(psBandNode, GTI_XML_CATEGORYNAMES)) { poBand->m_aosCategoryNames = VRTParseCategoryNames(psCategoryNames); } if (const CPLXMLNode *psColorTable = - CPLGetXMLNode(psBandNode, VRTTI_XML_COLORTABLE)) + CPLGetXMLNode(psBandNode, GTI_XML_COLORTABLE)) { poBand->m_poColorTable = VRTParseColorTable(psColorTable); } if (const CPLXMLNode *psRAT = - CPLGetXMLNode(psBandNode, VRTTI_XML_RAT)) + CPLGetXMLNode(psBandNode, GTI_XML_RAT)) { poBand->m_poRAT = std::make_unique(); @@ -1540,7 +1540,7 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) bHasMaskBand = CPLTestBool(pszMaskBand); if (bHasMaskBand) { - m_poMaskBand = std::make_unique( + m_poMaskBand = std::make_unique( this, 0, GDT_Byte, nBlockXSize, nBlockYSize); } @@ -1552,23 +1552,22 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) psIter = psIter->psNext) { if (psIter->eType == CXT_Element && - strcmp(psIter->pszValue, VRTTI_XML_OVERVIEW_ELEMENT) == 0) + strcmp(psIter->pszValue, GTI_XML_OVERVIEW_ELEMENT) == 0) { const char *pszDataset = CPLGetXMLValue( - psIter, VRTTI_XML_OVERVIEW_DATASET, nullptr); - const char *pszLayer = CPLGetXMLValue( - psIter, VRTTI_XML_OVERVIEW_LAYER, nullptr); + psIter, GTI_XML_OVERVIEW_DATASET, nullptr); + const char *pszLayer = + CPLGetXMLValue(psIter, GTI_XML_OVERVIEW_LAYER, nullptr); const char *pszFactor = CPLGetXMLValue( - psIter, VRTTI_XML_OVERVIEW_FACTOR, nullptr); + psIter, GTI_XML_OVERVIEW_FACTOR, nullptr); if (!pszDataset && !pszLayer && !pszFactor) { - CPLError(CE_Failure, CPLE_AppDefined, - "At least one of %s, %s or %s element " - "must be present as an %s child", - VRTTI_XML_OVERVIEW_DATASET, - VRTTI_XML_OVERVIEW_LAYER, - VRTTI_XML_OVERVIEW_FACTOR, - VRTTI_XML_OVERVIEW_ELEMENT); + CPLError( + CE_Failure, CPLE_AppDefined, + "At least one of %s, %s or %s element " + "must be present as an %s child", + GTI_XML_OVERVIEW_DATASET, GTI_XML_OVERVIEW_LAYER, + GTI_XML_OVERVIEW_FACTOR, GTI_XML_OVERVIEW_ELEMENT); return false; } m_aoOverviewDescriptor.emplace_back( @@ -1703,8 +1702,8 @@ bool VRTTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) /* GetMetadataItem() */ /************************************************************************/ -const char *VRTTileIndexDataset::GetMetadataItem(const char *pszName, - const char *pszDomain) +const char *GDALTileIndexDataset::GetMetadataItem(const char *pszName, + const char *pszDomain) { if (pszName && pszDomain && EQUAL(pszDomain, "__DEBUG__")) { @@ -1724,7 +1723,7 @@ const char *VRTTileIndexDataset::GetMetadataItem(const char *pszName, /* TileIndexSupportsEditingLayerMetadata() */ /************************************************************************/ -bool VRTTileIndexDataset::TileIndexSupportsEditingLayerMetadata() const +bool GDALTileIndexDataset::TileIndexSupportsEditingLayerMetadata() const { return eAccess == GA_Update && m_poVectorDS->GetDriver() && EQUAL(m_poVectorDS->GetDriver()->GetDescription(), "GPKG"); @@ -1734,9 +1733,9 @@ bool VRTTileIndexDataset::TileIndexSupportsEditingLayerMetadata() const /* SetMetadataItem() */ /************************************************************************/ -CPLErr VRTTileIndexDataset::SetMetadataItem(const char *pszName, - const char *pszValue, - const char *pszDomain) +CPLErr GDALTileIndexDataset::SetMetadataItem(const char *pszName, + const char *pszValue, + const char *pszDomain) { if (m_bXMLUpdatable) { @@ -1758,7 +1757,7 @@ CPLErr VRTTileIndexDataset::SetMetadataItem(const char *pszName, /* SetMetadata() */ /************************************************************************/ -CPLErr VRTTileIndexDataset::SetMetadata(char **papszMD, const char *pszDomain) +CPLErr GDALTileIndexDataset::SetMetadata(char **papszMD, const char *pszDomain) { if (m_bXMLUpdatable) { @@ -1810,60 +1809,60 @@ CPLErr VRTTileIndexDataset::SetMetadata(char **papszMD, const char *pszDomain) } /************************************************************************/ -/* VRTTileIndexDatasetIdentify() */ +/* GDALTileIndexDatasetIdentify() */ /************************************************************************/ -static int VRTTileIndexDatasetIdentify(GDALOpenInfo *poOpenInfo) +static int GDALTileIndexDatasetIdentify(GDALOpenInfo *poOpenInfo) { - if (STARTS_WITH(poOpenInfo->pszFilename, VRTTI_PREFIX)) + if (STARTS_WITH(poOpenInfo->pszFilename, GTI_PREFIX)) return true; - if (STARTS_WITH(poOpenInfo->pszFilename, "pszFilename, "nHeaderBytes > 0 && (poOpenInfo->nOpenFlags & GDAL_OF_RASTER) != 0 && (strstr(reinterpret_cast(poOpenInfo->pabyHeader), - "pszFilename, ".vrt.gpkg") || - ENDS_WITH_CI(poOpenInfo->pszFilename, ".vrt.fgb") || - ENDS_WITH_CI(poOpenInfo->pszFilename, ".vrt.parquet")); + "pszFilename, ".gti.gpkg") || + ENDS_WITH_CI(poOpenInfo->pszFilename, ".gti.fgb") || + ENDS_WITH_CI(poOpenInfo->pszFilename, ".gti.parquet")); } /************************************************************************/ -/* VRTTileIndexDatasetOpen() */ +/* GDALTileIndexDatasetOpen() */ /************************************************************************/ -static GDALDataset *VRTTileIndexDatasetOpen(GDALOpenInfo *poOpenInfo) +static GDALDataset *GDALTileIndexDatasetOpen(GDALOpenInfo *poOpenInfo) { - if (!VRTTileIndexDatasetIdentify(poOpenInfo)) + if (!GDALTileIndexDatasetIdentify(poOpenInfo)) return nullptr; - auto poDS = std::make_unique(); + auto poDS = std::make_unique(); if (!poDS->Open(poOpenInfo)) return nullptr; return poDS.release(); } /************************************************************************/ -/* ~VRTTileIndexDataset() */ +/* ~GDALTileIndexDataset() */ /************************************************************************/ -VRTTileIndexDataset::~VRTTileIndexDataset() +GDALTileIndexDataset::~GDALTileIndexDataset() { - VRTTileIndexDataset::FlushCache(true); + GDALTileIndexDataset::FlushCache(true); } /************************************************************************/ /* FlushCache() */ /************************************************************************/ -CPLErr VRTTileIndexDataset::FlushCache(bool bAtClosing) +CPLErr GDALTileIndexDataset::FlushCache(bool bAtClosing) { CPLErr eErr = CE_None; if (bAtClosing && m_bXMLModified) { CPLXMLNode *psRoot = - CPLGetXMLNode(m_psXMLTree.get(), "=VRTTileIndexDataset"); + CPLGetXMLNode(m_psXMLTree.get(), "=GDALTileIndexDataset"); // Suppress existing dataset metadata while (true) @@ -1879,16 +1878,16 @@ CPLErr VRTTileIndexDataset::FlushCache(bool bAtClosing) CPLAddXMLChild(psRoot, psMD); // Update existing band metadata - if (CPLGetXMLNode(psRoot, VRTTI_XML_BAND_ELEMENT)) + if (CPLGetXMLNode(psRoot, GTI_XML_BAND_ELEMENT)) { for (CPLXMLNode *psIter = psRoot->psChild; psIter; psIter = psIter->psNext) { if (psIter->eType == CXT_Element && - strcmp(psIter->pszValue, VRTTI_XML_BAND_ELEMENT)) + strcmp(psIter->pszValue, GTI_XML_BAND_ELEMENT)) { const char *pszBand = - CPLGetXMLValue(psIter, VRTTI_XML_BAND_NUMBER, nullptr); + CPLGetXMLValue(psIter, GTI_XML_BAND_NUMBER, nullptr); if (pszBand) { const int nBand = atoi(pszBand); @@ -1903,7 +1902,7 @@ CPLErr VRTTileIndexDataset::FlushCache(bool bAtClosing) CPLRemoveXMLChild(psIter, psExistingMetadata); } - auto poBand = cpl::down_cast( + auto poBand = cpl::down_cast( papoBands[nBand - 1]); if (CPLXMLNode *psMD = poBand->oMDMD.Serialize()) CPLAddXMLChild(psIter, psMD); @@ -1920,7 +1919,7 @@ CPLErr VRTTileIndexDataset::FlushCache(bool bAtClosing) for (int i = 1; i <= nBands; ++i) { auto poBand = - cpl::down_cast(papoBands[i - 1]); + cpl::down_cast(papoBands[i - 1]); auto psMD = poBand->oMDMD.Serialize(); if (psMD) bHasBandMD = true; @@ -1931,43 +1930,43 @@ CPLErr VRTTileIndexDataset::FlushCache(bool bAtClosing) for (int i = 1; i <= nBands; ++i) { auto poBand = - cpl::down_cast(papoBands[i - 1]); + cpl::down_cast(papoBands[i - 1]); - CPLXMLNode *psBand = CPLCreateXMLNode( - psRoot, CXT_Element, VRTTI_XML_BAND_ELEMENT); - CPLAddXMLAttributeAndValue(psBand, VRTTI_XML_BAND_NUMBER, + CPLXMLNode *psBand = CPLCreateXMLNode(psRoot, CXT_Element, + GTI_XML_BAND_ELEMENT); + CPLAddXMLAttributeAndValue(psBand, GTI_XML_BAND_NUMBER, CPLSPrintf("%d", i)); CPLAddXMLAttributeAndValue( - psBand, VRTTI_XML_BAND_DATATYPE, + psBand, GTI_XML_BAND_DATATYPE, GDALGetDataTypeName(poBand->GetRasterDataType())); const char *pszDescription = poBand->GetDescription(); if (pszDescription && pszDescription[0]) - CPLSetXMLValue(psBand, VRTTI_XML_BAND_DESCRIPTION, + CPLSetXMLValue(psBand, GTI_XML_BAND_DESCRIPTION, pszDescription); const auto eColorInterp = poBand->GetColorInterpretation(); if (eColorInterp != GCI_Undefined) CPLSetXMLValue( - psBand, VRTTI_XML_BAND_COLORINTERP, + psBand, GTI_XML_BAND_COLORINTERP, GDALGetColorInterpretationName(eColorInterp)); if (!std::isnan(poBand->m_dfOffset)) - CPLSetXMLValue(psBand, VRTTI_XML_BAND_OFFSET, + CPLSetXMLValue(psBand, GTI_XML_BAND_OFFSET, CPLSPrintf("%.16g", poBand->m_dfOffset)); if (!std::isnan(poBand->m_dfScale)) - CPLSetXMLValue(psBand, VRTTI_XML_BAND_SCALE, + CPLSetXMLValue(psBand, GTI_XML_BAND_SCALE, CPLSPrintf("%.16g", poBand->m_dfScale)); if (!poBand->m_osUnit.empty()) - CPLSetXMLValue(psBand, VRTTI_XML_BAND_UNITTYPE, + CPLSetXMLValue(psBand, GTI_XML_BAND_UNITTYPE, poBand->m_osUnit.c_str()); if (poBand->m_bNoDataValueSet) { CPLSetXMLValue( - psBand, VRTTI_XML_BAND_NODATAVALUE, + psBand, GTI_XML_BAND_NODATAVALUE, VRTSerializeNoData(poBand->m_dfNoDataValue, poBand->GetRasterDataType(), 18) .c_str()); @@ -1999,7 +1998,7 @@ CPLErr VRTTileIndexDataset::FlushCache(bool bAtClosing) /* LoadOverviews() */ /************************************************************************/ -void VRTTileIndexDataset::LoadOverviews() +void GDALTileIndexDataset::LoadOverviews() { if (m_apoOverviews.empty() && !m_aoOverviewDescriptor.empty()) { @@ -2042,7 +2041,7 @@ void VRTTileIndexDataset::LoadOverviews() /* GetOverviewCount() */ /************************************************************************/ -int VRTTileIndexBand::GetOverviewCount() +int GDALTileIndexBand::GetOverviewCount() { const int nPAMOverviews = GDALPamRasterBand::GetOverviewCount(); if (nPAMOverviews) @@ -2056,7 +2055,7 @@ int VRTTileIndexBand::GetOverviewCount() /* GetOverview() */ /************************************************************************/ -GDALRasterBand *VRTTileIndexBand::GetOverview(int iOvr) +GDALRasterBand *GDALTileIndexBand::GetOverview(int iOvr) { if (iOvr < 0 || iOvr >= GetOverviewCount()) return nullptr; @@ -2082,7 +2081,7 @@ GDALRasterBand *VRTTileIndexBand::GetOverview(int iOvr) /* GetGeoTransform() */ /************************************************************************/ -CPLErr VRTTileIndexDataset::GetGeoTransform(double *padfGeoTransform) +CPLErr GDALTileIndexDataset::GetGeoTransform(double *padfGeoTransform) { memcpy(padfGeoTransform, m_adfGeoTransform.data(), 6 * sizeof(double)); return CE_None; @@ -2092,18 +2091,18 @@ CPLErr VRTTileIndexDataset::GetGeoTransform(double *padfGeoTransform) /* GetSpatialRef() */ /************************************************************************/ -const OGRSpatialReference *VRTTileIndexDataset::GetSpatialRef() const +const OGRSpatialReference *GDALTileIndexDataset::GetSpatialRef() const { return m_oSRS.IsEmpty() ? nullptr : &m_oSRS; } /************************************************************************/ -/* VRTTileIndexBand() */ +/* GDALTileIndexBand() */ /************************************************************************/ -VRTTileIndexBand::VRTTileIndexBand(VRTTileIndexDataset *poDSIn, int nBandIn, - GDALDataType eDT, int nBlockXSizeIn, - int nBlockYSizeIn) +GDALTileIndexBand::GDALTileIndexBand(GDALTileIndexDataset *poDSIn, int nBandIn, + GDALDataType eDT, int nBlockXSizeIn, + int nBlockYSizeIn) { m_poDS = poDSIn; nBand = nBandIn; @@ -2118,8 +2117,8 @@ VRTTileIndexBand::VRTTileIndexBand(VRTTileIndexDataset *poDSIn, int nBandIn, /* IReadBlock() */ /************************************************************************/ -CPLErr VRTTileIndexBand::IReadBlock(int nBlockXOff, int nBlockYOff, - void *pImage) +CPLErr GDALTileIndexBand::IReadBlock(int nBlockXOff, int nBlockYOff, + void *pImage) { const int nPixelSize = GDALGetDataTypeSizeBytes(eDataType); @@ -2141,12 +2140,12 @@ CPLErr VRTTileIndexBand::IReadBlock(int nBlockXOff, int nBlockYOff, /* IRasterIO() */ /************************************************************************/ -CPLErr VRTTileIndexBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, - int nXSize, int nYSize, void *pData, - int nBufXSize, int nBufYSize, - GDALDataType eBufType, GSpacing nPixelSpace, - GSpacing nLineSpace, - GDALRasterIOExtraArg *psExtraArg) +CPLErr GDALTileIndexBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, + int nXSize, int nYSize, void *pData, + int nBufXSize, int nBufYSize, + GDALDataType eBufType, GSpacing nPixelSpace, + GSpacing nLineSpace, + GDALRasterIOExtraArg *psExtraArg) { int anBand[] = {nBand}; @@ -2159,7 +2158,7 @@ CPLErr VRTTileIndexBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, /* GetMetadataDomainList() */ /************************************************************************/ -char **VRTTileIndexBand::GetMetadataDomainList() +char **GDALTileIndexBand::GetMetadataDomainList() { return CSLAddString(GDALRasterBand::GetMetadataDomainList(), "LocationInfo"); @@ -2169,8 +2168,8 @@ char **VRTTileIndexBand::GetMetadataDomainList() /* GetMetadataItem() */ /************************************************************************/ -const char *VRTTileIndexBand::GetMetadataItem(const char *pszName, - const char *pszDomain) +const char *GDALTileIndexBand::GetMetadataItem(const char *pszName, + const char *pszDomain) { /* ==================================================================== */ @@ -2232,7 +2231,7 @@ const char *VRTTileIndexBand::GetMetadataItem(const char *pszName, if (!m_poDS->m_aoSourceDesc.empty()) { const auto AddSource = - [&](const VRTTileIndexDataset::SourceDesc &oSourceDesc) + [&](const GDALTileIndexDataset::SourceDesc &oSourceDesc) { m_osLastLocationInfo += ""; char *const pszXMLEscaped = @@ -2269,9 +2268,9 @@ const char *VRTTileIndexBand::GetMetadataItem(const char *pszName, /* SetMetadataItem() */ /************************************************************************/ -CPLErr VRTTileIndexBand::SetMetadataItem(const char *pszName, - const char *pszValue, - const char *pszDomain) +CPLErr GDALTileIndexBand::SetMetadataItem(const char *pszName, + const char *pszValue, + const char *pszDomain) { if (nBand > 0 && m_poDS->m_bXMLUpdatable) { @@ -2294,7 +2293,7 @@ CPLErr VRTTileIndexBand::SetMetadataItem(const char *pszName, /* SetMetadata() */ /************************************************************************/ -CPLErr VRTTileIndexBand::SetMetadata(char **papszMD, const char *pszDomain) +CPLErr GDALTileIndexBand::SetMetadata(char **papszMD, const char *pszDomain) { if (nBand > 0 && m_poDS->m_bXMLUpdatable) { @@ -2428,20 +2427,20 @@ static bool GetSrcDstWin(const double adfTileGT[6], int nTileXSize, } /************************************************************************/ -/* GDALDatasetCastToVRTTIDataset() */ +/* GDALDatasetCastToGTIDataset() */ /************************************************************************/ -VRTTileIndexDataset *GDALDatasetCastToVRTTIDataset(GDALDataset *poDS) +GDALTileIndexDataset *GDALDatasetCastToGTIDataset(GDALDataset *poDS) { - return dynamic_cast(poDS); + return dynamic_cast(poDS); } /************************************************************************/ -/* VRTTIGetSourcesMoreRecentThan() */ +/* GTIGetSourcesMoreRecentThan() */ /************************************************************************/ -std::vector -VRTTIGetSourcesMoreRecentThan(VRTTileIndexDataset *poDS, int64_t mTime) +std::vector +GTIGetSourcesMoreRecentThan(GDALTileIndexDataset *poDS, int64_t mTime) { return poDS->GetSourcesMoreRecentThan(mTime); } @@ -2450,10 +2449,10 @@ VRTTIGetSourcesMoreRecentThan(VRTTileIndexDataset *poDS, int64_t mTime) /* GetSourcesMoreRecentThan() */ /************************************************************************/ -std::vector -VRTTileIndexDataset::GetSourcesMoreRecentThan(int64_t mTime) +std::vector +GDALTileIndexDataset::GetSourcesMoreRecentThan(int64_t mTime) { - std::vector oRes; + std::vector oRes; m_poLayer->SetSpatialFilter(nullptr); for (auto &&poFeature : m_poLayer) @@ -2512,7 +2511,7 @@ VRTTileIndexDataset::GetSourcesMoreRecentThan(int64_t mTime) } constexpr double EPS = 1e-8; - VRTTISourceDesc oSourceDesc; + GTISourceDesc oSourceDesc; oSourceDesc.osFilename = osTileName; oSourceDesc.nDstXOff = static_cast(dfXOff + EPS); oSourceDesc.nDstYOff = static_cast(dfYOff + EPS); @@ -2528,8 +2527,8 @@ VRTTileIndexDataset::GetSourcesMoreRecentThan(int64_t mTime) /* GetSourceDesc() */ /************************************************************************/ -bool VRTTileIndexDataset::GetSourceDesc(const std::string &osTileName, - SourceDesc &oSourceDesc) +bool GDALTileIndexDataset::GetSourceDesc(const std::string &osTileName, + SourceDesc &oSourceDesc) { std::shared_ptr poTileDS; if (!m_oMapSharedSources.tryGet(osTileName, poTileDS)) @@ -2780,8 +2779,8 @@ bool VRTTileIndexDataset::GetSourceDesc(const std::string &osTileName, /* CollectSources() */ /************************************************************************/ -bool VRTTileIndexDataset::CollectSources(double dfXOff, double dfYOff, - double dfXSize, double dfYSize) +bool GDALTileIndexDataset::CollectSources(double dfXOff, double dfYOff, + double dfXSize, double dfYSize) { const double dfMinX = m_adfGeoTransform[GT_TOPLEFT_X] + dfXOff * m_adfGeoTransform[GT_WE_RES]; @@ -2906,7 +2905,7 @@ bool VRTTileIndexDataset::CollectSources(double dfXOff, double dfYOff, /* SortSourceDesc() */ /************************************************************************/ -void VRTTileIndexDataset::SortSourceDesc() +void GDALTileIndexDataset::SortSourceDesc() { const auto eFieldType = m_nSortFieldIndex >= 0 ? m_poLayer->GetLayerDefn() @@ -3079,8 +3078,8 @@ CompositeSrcWithMaskIntoDest(const int nOutXSize, const int nOutYSize, /************************************************************************/ // Must be called after CollectSources() -bool VRTTileIndexDataset::NeedInitBuffer(int nBandCount, - const int *panBandMap) const +bool GDALTileIndexDataset::NeedInitBuffer(int nBandCount, + const int *panBandMap) const { bool bNeedInitBuffer = true; // If the last source (that is the most prioritary one) covers at least @@ -3113,11 +3112,11 @@ bool VRTTileIndexDataset::NeedInitBuffer(int nBandCount, /* InitBuffer() */ /************************************************************************/ -void VRTTileIndexDataset::InitBuffer(void *pData, int nBufXSize, int nBufYSize, - GDALDataType eBufType, int nBandCount, - const int *panBandMap, - GSpacing nPixelSpace, GSpacing nLineSpace, - GSpacing nBandSpace) const +void GDALTileIndexDataset::InitBuffer(void *pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, int nBandCount, + const int *panBandMap, + GSpacing nPixelSpace, GSpacing nLineSpace, + GSpacing nBandSpace) const { const int nBufTypeSize = GDALGetDataTypeSizeBytes(eBufType); if (m_bSameNoData && nBandCount > 1 && @@ -3132,7 +3131,7 @@ void VRTTileIndexDataset::InitBuffer(void *pData, int nBufXSize, int nBufYSize, auto poVRTBand = nBandNr == 0 ? m_poMaskBand.get() - : cpl::down_cast(papoBands[nBandNr - 1]); + : cpl::down_cast(papoBands[nBandNr - 1]); const double dfNoData = poVRTBand->m_dfNoDataValue; if (dfNoData == 0.0) { @@ -3153,7 +3152,7 @@ void VRTTileIndexDataset::InitBuffer(void *pData, int nBufXSize, int nBufYSize, { const int nBandNr = panBandMap[i]; auto poVRTBand = nBandNr == 0 ? m_poMaskBand.get() - : cpl::down_cast( + : cpl::down_cast( papoBands[nBandNr - 1]); GByte *pabyBandData = static_cast(pData) + i * nBandSpace; if (nPixelSpace == nBufTypeSize && @@ -3195,13 +3194,13 @@ void VRTTileIndexDataset::InitBuffer(void *pData, int nBufXSize, int nBufYSize, /* IRasterIO() */ /************************************************************************/ -CPLErr VRTTileIndexDataset::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, - int nXSize, int nYSize, void *pData, - int nBufXSize, int nBufYSize, - GDALDataType eBufType, int nBandCount, - int *panBandMap, GSpacing nPixelSpace, - GSpacing nLineSpace, GSpacing nBandSpace, - GDALRasterIOExtraArg *psExtraArg) +CPLErr GDALTileIndexDataset::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, + int nXSize, int nYSize, void *pData, + int nBufXSize, int nBufYSize, + GDALDataType eBufType, int nBandCount, + int *panBandMap, GSpacing nPixelSpace, + GSpacing nLineSpace, GSpacing nBandSpace, + GDALRasterIOExtraArg *psExtraArg) { if (eRWFlag != GF_Read) return CE_Failure; @@ -3600,25 +3599,25 @@ CPLErr VRTTileIndexDataset::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, } /************************************************************************/ -/* GDALRegister_VRTTI() */ +/* GDALRegister_GTI() */ /************************************************************************/ -void GDALRegister_VRTTI() +void GDALRegister_GTI() { - if (GDALGetDriverByName("VRTTI") != nullptr) + if (GDALGetDriverByName("GTI") != nullptr) return; auto poDriver = std::make_unique(); - poDriver->SetDescription("VRTTI"); + poDriver->SetDescription("GTI"); poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES"); - poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "Virtual Raster Tile Index"); - poDriver->SetMetadataItem(GDAL_DMD_EXTENSIONS, "vrt.gpkg vrt.fgb vrtti"); - poDriver->SetMetadataItem(GDAL_DMD_CONNECTION_PREFIX, VRTTI_PREFIX); - poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/vrtti.html"); + poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "GDAL Raster Tile Index"); + poDriver->SetMetadataItem(GDAL_DMD_EXTENSIONS, "gti.gpkg gti.fgb gti"); + poDriver->SetMetadataItem(GDAL_DMD_CONNECTION_PREFIX, GTI_PREFIX); + poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/gti.html"); - poDriver->pfnOpen = VRTTileIndexDatasetOpen; - poDriver->pfnIdentify = VRTTileIndexDatasetIdentify; + poDriver->pfnOpen = GDALTileIndexDatasetOpen; + poDriver->pfnIdentify = GDALTileIndexDatasetIdentify; poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); diff --git a/frmts/vrt/vrt_priv.h b/frmts/vrt/vrt_priv.h index c7ca081608e1..ca2af63383fb 100644 --- a/frmts/vrt/vrt_priv.h +++ b/frmts/vrt/vrt_priv.h @@ -36,7 +36,7 @@ #include #include -struct CPL_DLL VRTTISourceDesc +struct CPL_DLL GTISourceDesc { std::string osFilename{}; int nDstXOff = 0; @@ -45,12 +45,12 @@ struct CPL_DLL VRTTISourceDesc int nDstYSize = 0; }; -class VRTTileIndexDataset; +class GDALTileIndexDataset; -VRTTileIndexDataset CPL_DLL *GDALDatasetCastToVRTTIDataset(GDALDataset *poDS); +GDALTileIndexDataset CPL_DLL *GDALDatasetCastToGTIDataset(GDALDataset *poDS); -std::vector CPL_DLL -VRTTIGetSourcesMoreRecentThan(VRTTileIndexDataset *poDS, int64_t mTime); +std::vector CPL_DLL +GTIGetSourcesMoreRecentThan(GDALTileIndexDataset *poDS, int64_t mTime); CPLStringList VRTParseCategoryNames(const CPLXMLNode *psCategoryNames); diff --git a/frmts/vrt/vrtdataset.h b/frmts/vrt/vrtdataset.h index d893e7361fdb..59dc1ecf91af 100644 --- a/frmts/vrt/vrtdataset.h +++ b/frmts/vrt/vrtdataset.h @@ -1024,8 +1024,8 @@ class CPL_DLL VRTSimpleSource CPL_NON_FINAL : public VRTSource protected: friend class VRTSourcedRasterBand; friend class VRTDataset; - friend class VRTTileIndexDataset; - friend class VRTTileIndexBand; + friend class GDALTileIndexDataset; + friend class GDALTileIndexBand; int m_nBand = 0; bool m_bGetMaskBand = false; diff --git a/gcore/gdal_frmts.h b/gcore/gdal_frmts.h index 66117ba6edad..129845bbe006 100644 --- a/gcore/gdal_frmts.h +++ b/gcore/gdal_frmts.h @@ -84,7 +84,7 @@ void CPL_DLL GDALRegister_ECW_JP2ECW(); void CPL_DLL GDALRegister_FujiBAS(void); void CPL_DLL GDALRegister_FIT(void); void CPL_DLL GDALRegister_VRT(void); -void CPL_DLL GDALRegister_VRTTI(void); +void CPL_DLL GDALRegister_GTI(void); void CPL_DLL GDALRegister_USGSDEM(void); void CPL_DLL GDALRegister_FAST(void); void CPL_DLL GDALRegister_HDF4(void); diff --git a/ogr/ogrsf_frmts/gpkg/ogrgeopackagedriver.cpp b/ogr/ogrsf_frmts/gpkg/ogrgeopackagedriver.cpp index 6e4c438978fb..3c43b5bf383b 100644 --- a/ogr/ogrsf_frmts/gpkg/ogrgeopackagedriver.cpp +++ b/ogr/ogrsf_frmts/gpkg/ogrgeopackagedriver.cpp @@ -94,9 +94,9 @@ static int OGRGeoPackageDriverIdentify(GDALOpenInfo *poOpenInfo, } if ((poOpenInfo->nOpenFlags & GDAL_OF_RASTER) != 0 && - ENDS_WITH_CI(poOpenInfo->pszFilename, ".vrt.gpkg")) + ENDS_WITH_CI(poOpenInfo->pszFilename, ".gti.gpkg")) { - // Handled by VRT driver + // Handled by GTI driver return FALSE; } diff --git a/swig/include/python/gdal_python.i b/swig/include/python/gdal_python.i index c35c072f116b..adf5aace5b78 100644 --- a/swig/include/python/gdal_python.i +++ b/swig/include/python/gdal_python.i @@ -3818,7 +3818,7 @@ def TileIndexOptions(options=None, outputSRS=None, writeAbsolutePath=None, skipDifferentProjection=None, - vrttiFilename=None, + gtiFilename=None, xRes=None, yRes=None, outputBounds=None, @@ -3856,8 +3856,8 @@ def TileIndexOptions(options=None, Enables writing the absolute path of the input dataset. By default, the filename is written in the location field exactly as the dataset name. skipDifferentProjection: Whether to skip sources that have a different SRS - vrttiFilename: - Filename of the XML Virtual Tile Index file + gtiFilename: + Filename of the GDAL XML Tile Index file xRes: output horizontal resolution yRes: @@ -3917,8 +3917,8 @@ def TileIndexOptions(options=None, new_options += ['-write_absolute_path'] if skipDifferentProjection: new_options += ['-skip_different_projection'] - if vrttiFilename is not None: - new_options += ['-vrtti_filename', vrttiFilename] + if gtiFilename is not None: + new_options += ['-gti_filename', gtiFilename] if xRes is not None and yRes is not None: new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)] elif xRes is not None: