Skip to content

Commit c085222

Browse files
authored
Merge pull request OSGeo#12799 from rouault/gti_fix_source_removal
GTI: fix erroneous removal of contributing source in some cases
2 parents d0ebbc6 + ae0b324 commit c085222

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed
833 Bytes
Binary file not shown.
833 Bytes
Binary file not shown.
104 KB
Binary file not shown.

autotest/gdrivers/gti.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3027,3 +3027,20 @@ def test_gti_stac_geoparquet_sentinel2(filename):
30273027
"CENTRAL_WAVELENGTH_UM": "0.783",
30283028
"FWHM_UM": "0.028",
30293029
}
3030+
3031+
3032+
###############################################################################
3033+
# Test case when 2 sources where collected, but erroneously discarded
3034+
3035+
3036+
def test_gti_tile_001():
3037+
3038+
out_ds = gdal.Warp(
3039+
"",
3040+
"vrt://data/gti/tile-001.gti.gpkg?bands=3,2,1",
3041+
options="-f MEM -t_srs epsg:3857 -dstalpha -ts 256 256 -te -12151653.008664179593 3101508.859699312598 -12141869.069043677300 3111292.799319814891 -r cubic",
3042+
)
3043+
assert out_ds.GetRasterBand(1).ComputeRasterMinMax() == (1000, 1000)
3044+
assert out_ds.GetRasterBand(2).ComputeRasterMinMax() == (1000, 1000)
3045+
assert out_ds.GetRasterBand(3).ComputeRasterMinMax() == (1000, 1000)
3046+
assert out_ds.GetRasterBand(4).ComputeRasterMinMax() == (65535, 65535)

frmts/gti/gdaltileindexdataset.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3864,17 +3864,12 @@ bool GDALTileIndexDataset::CollectSources(double dfXOff, double dfYOff,
38643864
m_aoSourceDesc.begin() + i);
38653865
}
38663866

3867-
// Truncate the array when its last elements have no dataset
3868-
i = m_aoSourceDesc.size();
3869-
while (i > 0)
3870-
{
3871-
--i;
3872-
if (!m_aoSourceDesc[i].poDS)
3873-
{
3874-
m_aoSourceDesc.resize(i);
3875-
break;
3876-
}
3877-
}
3867+
// Remove elements that have no dataset
3868+
m_aoSourceDesc.erase(std::remove_if(m_aoSourceDesc.begin(),
3869+
m_aoSourceDesc.end(),
3870+
[](const SourceDesc &desc)
3871+
{ return desc.poDS == nullptr; }),
3872+
m_aoSourceDesc.end());
38783873

38793874
return true;
38803875
}

0 commit comments

Comments
 (0)