Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Main Repositories
otb
Commits
62e3e09d
Commit
62e3e09d
authored
Jul 06, 2022
by
Julien Osman
Browse files
FIX: Correctly take into account the extended filename writerpctag
parent
762e6f14
Pipeline
#11042
passed with stages
in 81 minutes and 37 seconds
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Modules/IO/IOGDAL/include/otbGDALImageIO.h
View file @
62e3e09d
...
...
@@ -32,6 +32,7 @@
#include
"otbMetadataStorageInterface.h"
#include
"OTBIOGDALExport.h"
#include
"otbGDALDriverManagerWrapper.h"
#include
"otbSpatialReference.h"
namespace
otb
...
...
@@ -249,6 +250,8 @@ protected:
void
GDALMetadataToKeywordlist
(
const
char
*
const
*
,
ImageMetadataBase
::
Keywordlist
&
);
/** Parses the RPC from the GDAL Metadata */
void
GDALMetadataReadRPC
();
/** Write the RPC to the GDAL Metadata */
void
GDALMetadataWriteRPC
(
GDALDataset
*
);
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
override
;
/** Read all information on the image*/
...
...
Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
View file @
62e3e09d
...
...
@@ -43,8 +43,6 @@
#include
"itksys/RegularExpression.hxx"
#include
"otbGDALDriverManagerWrapper.h"
#include
"otb_boost_string_header.h"
#include
"otbOGRHelpers.h"
...
...
@@ -118,7 +116,7 @@ GDALImageIO::GDALImageIO()
m_NumberOfOverviews
=
0
;
m_ResolutionFactor
=
0
;
m_BytePerPixel
=
0
;
m_WriteRPCTags
=
tru
e
;
m_WriteRPCTags
=
fals
e
;
m_epsgCode
=
0
;
}
...
...
@@ -1486,11 +1484,15 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer)
{
std
::
string
projectionRef
(
m_Imd
.
GetProjectionWKT
()
);
dataset
->
SetProjection
(
projectionRef
.
c_str
());
if
(
m_WriteRPCTags
&&
m_Imd
.
Has
(
MDGeom
::
RPC
))
GDALMetadataWriteRPC
(
dataset
);
}
else
if
(
m_Imd
.
Has
(
MDGeom
::
ProjectionProj
))
{
std
::
string
projectionRef
(
m_Imd
.
GetProjectionProj
()
);
dataset
->
SetProjection
(
projectionRef
.
c_str
());
if
(
m_WriteRPCTags
&&
m_Imd
.
Has
(
MDGeom
::
RPC
))
GDALMetadataWriteRPC
(
dataset
);
}
/* -------------------------------------------------------------------- */
/* Case 2: Sensor geometry */
...
...
@@ -1500,29 +1502,9 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer)
/* -------------------------------------------------------------------- */
/* Set the RPC coeffs (since GDAL 1.10.0) */
/* -------------------------------------------------------------------- */
if
(
m_WriteRPCTags
&&
m_Imd
.
Has
(
MDGeom
::
RPC
))
if
(
m_Imd
.
Has
(
MDGeom
::
RPC
))
{
const
Projection
::
RPCParam
&
rpc
=
boost
::
any_cast
<
const
Projection
::
RPCParam
&>
(
m_Imd
[
MDGeom
::
RPC
]);
otbLogMacro
(
Debug
,
<<
"Saving RPC to file ("
<<
m_FileName
<<
")"
)
GDALRPCInfo
gdalRpcStruct
;
gdalRpcStruct
.
dfSAMP_OFF
=
rpc
.
SampleOffset
;
gdalRpcStruct
.
dfLINE_OFF
=
rpc
.
LineOffset
;
gdalRpcStruct
.
dfSAMP_SCALE
=
rpc
.
SampleScale
;
gdalRpcStruct
.
dfLINE_SCALE
=
rpc
.
LineScale
;
gdalRpcStruct
.
dfLAT_OFF
=
rpc
.
LatOffset
;
gdalRpcStruct
.
dfLONG_OFF
=
rpc
.
LonOffset
;
gdalRpcStruct
.
dfHEIGHT_OFF
=
rpc
.
HeightOffset
;
gdalRpcStruct
.
dfLAT_SCALE
=
rpc
.
LatScale
;
gdalRpcStruct
.
dfLONG_SCALE
=
rpc
.
LonScale
;
gdalRpcStruct
.
dfHEIGHT_SCALE
=
rpc
.
HeightScale
;
memcpy
(
gdalRpcStruct
.
adfLINE_NUM_COEFF
,
rpc
.
LineNum
,
sizeof
(
double
)
*
20
);
memcpy
(
gdalRpcStruct
.
adfLINE_DEN_COEFF
,
rpc
.
LineDen
,
sizeof
(
double
)
*
20
);
memcpy
(
gdalRpcStruct
.
adfSAMP_NUM_COEFF
,
rpc
.
SampleNum
,
sizeof
(
double
)
*
20
);
memcpy
(
gdalRpcStruct
.
adfSAMP_DEN_COEFF
,
rpc
.
SampleDen
,
sizeof
(
double
)
*
20
);
char
**
rpcMetadata
=
RPCInfoToMD
(
&
gdalRpcStruct
);
dataset
->
SetMetadata
(
rpcMetadata
,
"RPC"
);
CSLDestroy
(
rpcMetadata
);
GDALMetadataWriteRPC
(
dataset
);
}
else
if
(
m_Imd
.
Has
(
MDGeom
::
SAR
))
{
...
...
@@ -1583,6 +1565,9 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer)
// disable geotransform with GCP (check that SetGCPs succeed by verifying the the dataset has GCPs)
writeGeotransform
=
writeGeotransform
&&
!
dataset
->
GetGCPCount
();
if
(
m_WriteRPCTags
&&
m_Imd
.
Has
(
MDGeom
::
RPC
))
GDALMetadataWriteRPC
(
dataset
);
}
/* -------------------------------------------------------------------- */
...
...
@@ -2049,5 +2034,31 @@ void GDALImageIO::GDALMetadataReadRPC()
m_Imd
.
Add
(
MDGeom
::
RPC
,
rpcStruct
);
}
void
GDALImageIO
::
GDALMetadataWriteRPC
(
GDALDataset
*
dataset
)
{
assert
(
m_Imd
.
Has
(
MDGeom
::
RPC
));
const
Projection
::
RPCParam
&
rpc
=
boost
::
any_cast
<
const
Projection
::
RPCParam
&>
(
m_Imd
[
MDGeom
::
RPC
]);
otbLogMacro
(
Debug
,
<<
"Saving RPC to file ("
<<
m_FileName
<<
")"
)
GDALRPCInfo
gdalRpcStruct
;
gdalRpcStruct
.
dfSAMP_OFF
=
rpc
.
SampleOffset
;
gdalRpcStruct
.
dfLINE_OFF
=
rpc
.
LineOffset
;
gdalRpcStruct
.
dfSAMP_SCALE
=
rpc
.
SampleScale
;
gdalRpcStruct
.
dfLINE_SCALE
=
rpc
.
LineScale
;
gdalRpcStruct
.
dfLAT_OFF
=
rpc
.
LatOffset
;
gdalRpcStruct
.
dfLONG_OFF
=
rpc
.
LonOffset
;
gdalRpcStruct
.
dfHEIGHT_OFF
=
rpc
.
HeightOffset
;
gdalRpcStruct
.
dfLAT_SCALE
=
rpc
.
LatScale
;
gdalRpcStruct
.
dfLONG_SCALE
=
rpc
.
LonScale
;
gdalRpcStruct
.
dfHEIGHT_SCALE
=
rpc
.
HeightScale
;
memcpy
(
gdalRpcStruct
.
adfLINE_NUM_COEFF
,
rpc
.
LineNum
,
sizeof
(
double
)
*
20
);
memcpy
(
gdalRpcStruct
.
adfLINE_DEN_COEFF
,
rpc
.
LineDen
,
sizeof
(
double
)
*
20
);
memcpy
(
gdalRpcStruct
.
adfSAMP_NUM_COEFF
,
rpc
.
SampleNum
,
sizeof
(
double
)
*
20
);
memcpy
(
gdalRpcStruct
.
adfSAMP_DEN_COEFF
,
rpc
.
SampleDen
,
sizeof
(
double
)
*
20
);
char
**
rpcMetadata
=
RPCInfoToMD
(
&
gdalRpcStruct
);
dataset
->
SetMetadata
(
rpcMetadata
,
"RPC"
);
CSLDestroy
(
rpcMetadata
);
}
}
// end namespace otb
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment