diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx index 1085a23c6f8b86a0b6b7b4e76925f064e45332d1..37c14462dcafe9c7e086da4a10a00f8b4c3019c4 100644 --- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx @@ -1679,6 +1679,28 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) { dataset->SetProjection(projectionRef.c_str()); } + else + { + /* -------------------------------------------------------------------- */ + /* Set the RPC coeffs if no projection available (since GDAL 1.10.0) */ + /* -------------------------------------------------------------------- */ +#if GDAL_VERSION_NUM >= 1100000 + ImageKeywordlist otb_kwl; + itk::ExposeMetaData<ImageKeywordlist>(dict, + MetaDataKey::OSSIMKeywordlistKey, + otb_kwl); + if( otb_kwl.GetSize() != 0 ) + { + GDALRPCInfo gdalRpcStruct; + if ( otb_kwl.convertToGDALRPC(gdalRpcStruct) ) + { + char **rpcMetadata = RPCInfoToMD(&gdalRpcStruct); + dataset->SetMetadata(rpcMetadata, "RPC"); + CSLDestroy( rpcMetadata ); + } + } +#endif + } /* -------------------------------------------------------------------- */ /* Set the six coefficients of affine geoTransform */ @@ -1719,23 +1741,6 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) } } -#if GDAL_VERSION_NUM >= 1100000 - // Report any RPC coefficients (feature available since GDAL 1.10.0) - ImageKeywordlist otb_kwl; - itk::ExposeMetaData<ImageKeywordlist>(dict, - MetaDataKey::OSSIMKeywordlistKey, - otb_kwl); - if( otb_kwl.GetSize() != 0 ) - { - GDALRPCInfo gdalRpcStruct; - if ( otb_kwl.convertToGDALRPC(gdalRpcStruct) ) - { - char **rpcMetadata = RPCInfoToMD(&gdalRpcStruct); - dataset->SetMetadata(rpcMetadata, "RPC"); - CSLDestroy( rpcMetadata ); - } - } -#endif // END