Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
David Youssefi
otb
Commits
3ec03180
Commit
3ec03180
authored
Jul 09, 2020
by
Julien Osman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: Read more Sentinel1 metadata
parent
f5cfce07
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
25 deletions
+98
-25
Modules/Core/Metadata/include/otbGeometryMetadata.h
Modules/Core/Metadata/include/otbGeometryMetadata.h
+15
-2
Modules/Core/Metadata/include/otbMetaDataKey.h
Modules/Core/Metadata/include/otbMetaDataKey.h
+2
-0
Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterface.h
...ore/Metadata/include/otbSentinel1ImageMetadataInterface.h
+4
-0
Modules/Core/Metadata/src/otbMetaDataKey.cxx
Modules/Core/Metadata/src/otbMetaDataKey.cxx
+2
-0
Modules/Core/Metadata/src/otbSentinel1ImageMetadataInterface.cxx
.../Core/Metadata/src/otbSentinel1ImageMetadataInterface.cxx
+75
-23
No files found.
Modules/Core/Metadata/include/otbGeometryMetadata.h
View file @
3ec03180
...
...
@@ -91,10 +91,10 @@ struct OTBMetadata_EXPORT OTB_calibrationVector
struct
OTBMetadata_EXPORT
OTB_dopplerCentroid
{
MetaData
::
Time
azimuthTime
;
double
t0
;
std
::
vector
<
double
>
dopCoef
;
std
::
vector
<
double
>
geoDopCoef
;
MetaData
::
Time
geoDopCoefTime
;
double
slantRangeTime
;
};
struct
OTBMetadata_EXPORT
OTB_SARNoise
...
...
@@ -104,6 +104,17 @@ struct OTBMetadata_EXPORT OTB_SARNoise
MetaData
::
LUT1D
noiseLut
;
};
struct
OTBMetadata_EXPORT
OTB_Orbit
{
MetaData
::
Time
time
;
double
posX
;
double
posY
;
double
posZ
;
double
velX
;
double
velY
;
double
velZ
;
};
namespace
Projection
{
...
...
@@ -212,6 +223,8 @@ struct OTBMetadata_EXPORT SARParam
std
::
vector
<
OTB_dopplerCentroid
>
dopplerCentroid
;
std
::
vector
<
OTB_SARNoise
>
noiseVector
;
std
::
vector
<
OTB_Orbit
>
orbits
;
};
}
// end namespace Projection
...
...
Modules/Core/Metadata/include/otbMetaDataKey.h
View file @
3ec03180
...
...
@@ -132,6 +132,8 @@ enum class MDNum
DataType
,
NoData
,
OrbitNumber
,
NumberOfLines
,
NumberOfColumns
,
// optical section
PhysicalGain
,
PhysicalBias
,
...
...
Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterface.h
View file @
3ec03180
...
...
@@ -95,6 +95,10 @@ public:
std
::
vector
<
OTB_azimuthFmRate
>
GetAzimuthFmRate
(
XMLMetadataSupplier
)
const
;
std
::
vector
<
OTB_dopplerCentroid
>
GetDopplerCentroid
(
XMLMetadataSupplier
)
const
;
std
::
vector
<
OTB_Orbit
>
GetOrbits
(
XMLMetadataSupplier
)
const
;
std
::
vector
<
OTB_calibrationVector
>
GetCalibrationVector
(
XMLMetadataSupplier
)
const
;
/* fetch the noise LUTs */
...
...
Modules/Core/Metadata/src/otbMetaDataKey.cxx
View file @
3ec03180
...
...
@@ -318,6 +318,8 @@ MDNumBmType MDNumNames = bimapGenerator<MDNum>(std::map<MDNum, std::string> {
{
MDNum
::
TileHintY
,
"TileHintY"
},
{
MDNum
::
DataType
,
"DataType"
},
{
MDNum
::
NoData
,
"NoData"
},
{
MDNum
::
NumberOfLines
,
"NumberOfLines"
},
{
MDNum
::
NumberOfColumns
,
"NumberOfColumns"
},
{
MDNum
::
OrbitNumber
,
"OrbitNumber"
},
{
MDNum
::
PhysicalGain
,
"PhysicalGain"
},
{
MDNum
::
PhysicalBias
,
"PhysicalBias"
},
...
...
Modules/Core/Metadata/src/otbSentinel1ImageMetadataInterface.cxx
View file @
3ec03180
...
...
@@ -372,6 +372,51 @@ std::vector<OTB_azimuthFmRate> Sentinel1ImageMetadataInterface::GetAzimuthFmRate
return
azimuthFmRateVector
;
}
std
::
vector
<
OTB_dopplerCentroid
>
Sentinel1ImageMetadataInterface
::
GetDopplerCentroid
(
XMLMetadataSupplier
xmlMS
)
const
{
std
::
vector
<
OTB_dopplerCentroid
>
dopplerCentroidVector
;
int
listCount
=
xmlMS
.
GetAs
<
double
>
(
"product.dopplerCentroid.dcEstimateList.count"
);
std
::
ostringstream
oss
;
for
(
int
listId
=
1
;
listId
<=
listCount
;
++
listId
)
{
oss
.
str
(
""
);
oss
<<
listId
;
std
::
string
path_root
=
"product.dopplerCentroid.dcEstimateList.dcEstimate_"
+
oss
.
str
();
OTB_dopplerCentroid
dopplerCent
;
std
::
istringstream
(
xmlMS
.
GetAs
<
std
::
string
>
(
path_root
+
".azimuthTime"
))
>>
dopplerCent
.
azimuthTime
;
dopplerCent
.
t0
=
xmlMS
.
GetAs
<
double
>
(
path_root
+
".t0"
);
dopplerCent
.
dopCoef
=
xmlMS
.
GetAsVector
<
double
>
(
path_root
+
".dataDcPolynomial"
,
' '
,
xmlMS
.
GetAs
<
int
>
((
path_root
+
".dataDcPolynomial.count"
).
c_str
()));
dopplerCent
.
geoDopCoef
=
xmlMS
.
GetAsVector
<
double
>
(
path_root
+
".geometryDcPolynomial"
,
' '
,
xmlMS
.
GetAs
<
int
>
((
path_root
+
".geometryDcPolynomial.count"
).
c_str
()));
dopplerCentroidVector
.
push_back
(
dopplerCent
);
}
return
dopplerCentroidVector
;
}
std
::
vector
<
OTB_Orbit
>
Sentinel1ImageMetadataInterface
::
GetOrbits
(
XMLMetadataSupplier
xmlMS
)
const
{
std
::
vector
<
OTB_Orbit
>
orbitVector
;
int
listCount
=
xmlMS
.
GetAs
<
double
>
(
"product.generalAnnotation.orbitList.count"
);
std
::
ostringstream
oss
;
for
(
int
listId
=
1
;
listId
<=
listCount
;
++
listId
)
{
oss
.
str
(
""
);
oss
<<
listId
;
std
::
string
path_root
=
"product.generalAnnotation.orbitList.orbit_"
+
oss
.
str
();
OTB_Orbit
orbit
;
std
::
istringstream
(
xmlMS
.
GetAs
<
std
::
string
>
(
path_root
+
".time"
))
>>
orbit
.
time
;
orbit
.
posX
=
xmlMS
.
GetAs
<
double
>
(
path_root
+
"1.position.x"
);
orbit
.
posY
=
xmlMS
.
GetAs
<
double
>
(
path_root
+
"1.position.y"
);
orbit
.
posZ
=
xmlMS
.
GetAs
<
double
>
(
path_root
+
"1.position.z"
);
orbit
.
velX
=
xmlMS
.
GetAs
<
double
>
(
path_root
+
"1.velocity.x"
);
orbit
.
velY
=
xmlMS
.
GetAs
<
double
>
(
path_root
+
"1.velocity.y"
);
orbit
.
velZ
=
xmlMS
.
GetAs
<
double
>
(
path_root
+
"1.velocity.z"
);
orbitVector
.
push_back
(
orbit
);
}
return
orbitVector
;
}
std
::
vector
<
OTB_calibrationVector
>
Sentinel1ImageMetadataInterface
::
GetCalibrationVector
(
XMLMetadataSupplier
xmlMS
)
const
{
std
::
vector
<
OTB_calibrationVector
>
calibrationVector
;
...
...
@@ -489,29 +534,36 @@ void Sentinel1ImageMetadataInterface::Parse(const MetadataSupplierInterface *mds
std
::
string
AnnotationFilePath
=
mds
->
GetResourceFile
(
std
::
string
(
"annotation[/
\\\\
]s1[ab].*-"
)
+
itksys
::
SystemTools
::
LowerCase
(
swath
)
+
std
::
string
(
"-.*
\\
.xml"
));
if
(
!
AnnotationFilePath
.
empty
())
{
XMLMetadataSupplier
AnnotationMS
=
XMLMetadataSupplier
(
AnnotationFilePath
);
sarParam
.
azimuthFmRate
=
this
->
GetAzimuthFmRate
(
AnnotationMS
);
// Calibration file
std
::
string
CalibrationFilePath
=
itksys
::
SystemTools
::
GetFilenamePath
(
AnnotationFilePath
)
+
"/calibration/calibration-"
+
itksys
::
SystemTools
::
GetFilenameName
(
AnnotationFilePath
);
XMLMetadataSupplier
CalibrationMS
=
XMLMetadataSupplier
(
CalibrationFilePath
);
sarParam
.
absoluteCalibrationConstant
=
CalibrationMS
.
GetAs
<
double
>
(
"calibration.calibrationInformation.absoluteCalibrationConstant"
);
sarParam
.
calibrationVectors
=
this
->
GetCalibrationVector
(
CalibrationMS
);
std
::
istringstream
(
CalibrationMS
.
GetAs
<
std
::
string
>
(
"calibration.adsHeader.startTime"
))
>>
sarParam
.
startTime
;
std
::
istringstream
(
CalibrationMS
.
GetAs
<
std
::
string
>
(
"calibration.adsHeader.stopTime"
))
>>
sarParam
.
stopTime
;
// Noise file
std
::
string
NoiseFilePath
=
itksys
::
SystemTools
::
GetFilenamePath
(
AnnotationFilePath
)
+
"/calibration/noise-"
+
itksys
::
SystemTools
::
GetFilenameName
(
AnnotationFilePath
);
XMLMetadataSupplier
NoiseMS
=
XMLMetadataSupplier
(
NoiseFilePath
);
sarParam
.
noiseVector
=
this
->
GetNoiseVector
(
NoiseMS
);
}
if
(
AnnotationFilePath
.
empty
())
otbGenericExceptionMacro
(
MissingMetadataException
,
<<
"Missing Annotation file for band '"
<<
swath
<<
"'"
);
XMLMetadataSupplier
AnnotationMS
=
XMLMetadataSupplier
(
AnnotationFilePath
);
sarParam
.
azimuthFmRate
=
this
->
GetAzimuthFmRate
(
AnnotationMS
);
sarParam
.
dopplerCentroid
=
this
->
GetDopplerCentroid
(
AnnotationMS
);
sarParam
.
orbits
=
this
->
GetOrbits
(
AnnotationMS
);
m_Imd
.
Add
(
MDNum
::
NumberOfLines
,
AnnotationMS
.
GetAs
<
int
>
(
"product.imageAnnotation.imageInformation.numberOfLines"
));
m_Imd
.
Add
(
MDNum
::
NumberOfColumns
,
AnnotationMS
.
GetAs
<
int
>
(
"product.imageAnnotation.imageInformation.numberOfSamples"
));
// Calibration file
std
::
string
CalibrationFilePath
=
itksys
::
SystemTools
::
GetFilenamePath
(
AnnotationFilePath
)
+
"/calibration/calibration-"
+
itksys
::
SystemTools
::
GetFilenameName
(
AnnotationFilePath
);
if
(
CalibrationFilePath
.
empty
())
otbGenericExceptionMacro
(
MissingMetadataException
,
<<
"Missing Calibration file for band '"
<<
swath
<<
"'"
);
XMLMetadataSupplier
CalibrationMS
=
XMLMetadataSupplier
(
CalibrationFilePath
);
sarParam
.
absoluteCalibrationConstant
=
CalibrationMS
.
GetAs
<
double
>
(
"calibration.calibrationInformation.absoluteCalibrationConstant"
);
sarParam
.
calibrationVectors
=
this
->
GetCalibrationVector
(
CalibrationMS
);
std
::
istringstream
(
CalibrationMS
.
GetAs
<
std
::
string
>
(
"calibration.adsHeader.startTime"
))
>>
sarParam
.
startTime
;
std
::
istringstream
(
CalibrationMS
.
GetAs
<
std
::
string
>
(
"calibration.adsHeader.stopTime"
))
>>
sarParam
.
stopTime
;
// Noise file
std
::
string
NoiseFilePath
=
itksys
::
SystemTools
::
GetFilenamePath
(
AnnotationFilePath
)
+
"/calibration/noise-"
+
itksys
::
SystemTools
::
GetFilenameName
(
AnnotationFilePath
);
if
(
NoiseFilePath
.
empty
())
otbGenericExceptionMacro
(
MissingMetadataException
,
<<
"Missing Noise file for band '"
<<
swath
<<
"'"
);
XMLMetadataSupplier
NoiseMS
=
XMLMetadataSupplier
(
NoiseFilePath
);
m_Imd
.
Bands
[
bandId
].
Add
(
MDGeom
::
SAR
,
sarParam
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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