Skip to content

Commit ab5908a

Browse files
authored
Merge pull request #12113 from rouault/fix_12112
DIMAP2: do not report SRS on products that have no geotransform (i.e. primary with RPC only)
2 parents 37af87b + 43011b8 commit ab5908a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

autotest/gdrivers/dimap.py

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def test_dimap_2_vhr2020_ms_fs():
311311

312312
def test_dimap2_pneo_primary_rpc_center_h():
313313
ds = gdal.Open("data/dimap2/primary_rpc_center_h/DIM_PNEO3_STD_x_1_1_F_1.XML")
314+
assert ds.GetSpatialRef() is None
314315
assert ds.GetMetadata_Dict("RPC") == {
315316
"HEIGHT_DEFAULT": "123.45",
316317
"HEIGHT_OFF": "HEIGHT_OFF",

frmts/dimap/dimapdataset.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -1479,17 +1479,22 @@ int DIMAPDataset::ReadImageInformation2()
14791479

14801480
if (pszSRS != nullptr)
14811481
{
1482-
OGRSpatialReference &oSRS = nGCPCount > 0 ? m_oGCPSRS : m_oSRS;
1483-
oSRS.SetFromUserInput(
1484-
pszSRS, OGRSpatialReference::SET_FROM_USER_INPUT_LIMITATIONS_get());
1482+
if (bHaveGeoTransform)
1483+
{
1484+
OGRSpatialReference &oSRS = m_oSRS;
1485+
oSRS.SetFromUserInput(
1486+
pszSRS,
1487+
OGRSpatialReference::SET_FROM_USER_INPUT_LIMITATIONS_get());
1488+
}
14851489
}
14861490
else
14871491
{
14881492
// Check underlying raster for SRS. We have cases where
14891493
// HORIZONTAL_CS_CODE is empty and the underlying raster
14901494
// is georeferenced (rprinceley).
14911495
const auto poSRS = poImageDS->GetSpatialRef();
1492-
if (poSRS)
1496+
double adfGTTmp[6];
1497+
if (poSRS && poImageDS->GetGeoTransform(adfGTTmp) == CE_None)
14931498
{
14941499
m_oSRS = *poSRS;
14951500
}

0 commit comments

Comments
 (0)