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
e6b10461
Commit
e6b10461
authored
Jul 01, 2020
by
Julien Osman
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2024-metadata-refac' into metadata-sentinel1
parents
934dbc96
0df350d8
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
218 additions
and
108 deletions
+218
-108
Data/Baseline/OTB/Files/ioTuImageMetadataAppendTest.txt
Data/Baseline/OTB/Files/ioTuImageMetadataAppendTest.txt
+24
-26
Data/Baseline/OTB/Files/ioTuImageMetadataCompactTest.txt
Data/Baseline/OTB/Files/ioTuImageMetadataCompactTest.txt
+17
-19
Data/Baseline/OTB/Files/ioTuImageMetadataMergeTest.txt
Data/Baseline/OTB/Files/ioTuImageMetadataMergeTest.txt
+14
-16
Data/Baseline/OTB/Files/ioTuImageMetadataSliceTest.txt
Data/Baseline/OTB/Files/ioTuImageMetadataSliceTest.txt
+12
-14
Data/Baseline/OTB/Files/ioTuImageMetadataToFromKeywordlistTest.txt
...line/OTB/Files/ioTuImageMetadataToFromKeywordlistTest.txt
+20
-24
Modules/Core/ImageBase/include/otbImageIOBase.h
Modules/Core/ImageBase/include/otbImageIOBase.h
+5
-0
Modules/Core/ImageBase/src/otbImageCommons.cxx
Modules/Core/ImageBase/src/otbImageCommons.cxx
+5
-2
Modules/Core/ImageBase/src/otbImageIOBase.cxx
Modules/Core/ImageBase/src/otbImageIOBase.cxx
+2
-0
Modules/Core/Metadata/test/otbImageMetadataTest.cxx
Modules/Core/Metadata/test/otbImageMetadataTest.cxx
+6
-5
Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
+12
-2
Modules/IO/ImageIO/include/otbImageFileReader.hxx
Modules/IO/ImageIO/include/otbImageFileReader.hxx
+9
-0
Modules/IO/TestKernel/include/otbTestTools.h
Modules/IO/TestKernel/include/otbTestTools.h
+92
-0
No files found.
Data/Baseline/OTB/Files/ioTuImageMetadataAppendTest.txt
View file @
e6b10461
{{"Extra.Comment": "Test Extrakeys",
"ProductionDate": "2009-08-10T10:30:08.142149Z",
"ProjectionWKT": "UTM projRef",
"SensorID": "PHR",
}Bands[{"PhysicalBias": "1",
"PhysicalGain": "2",
"BandName": "B0",
"NoData": "-10000",
},{"PhysicalBias": "2",
"PhysicalGain": "3",
"BandName": "B1",
"NoData": "-10000",
},{"PhysicalBias": "1",
"PhysicalGain": "2",
"BandName": "B0",
"NoData": "-10000",
},{"PhysicalBias": "2",
"PhysicalGain": "3",
"BandName": "B1",
"NoData": "-10000",
},{"PhysicalBias": "3",
"PhysicalGain": "4",
"BandName": "B2",
"NoData": "-10000",
},]
}
\ No newline at end of file
SensorID PHR
ProductionDate 2009-08-10T10:30:08.142149Z
ProjectionWKT UTM projRef
Extra.Comment Test Extrakeys
BandName B0
NoData -10000
PhysicalGain 2
PhysicalBias 1
BandName B1
NoData -10000
PhysicalGain 3
PhysicalBias 2
BandName B0
NoData -10000
PhysicalGain 2
PhysicalBias 1
BandName B1
NoData -10000
PhysicalGain 3
PhysicalBias 2
BandName B2
NoData -10000
PhysicalGain 4
PhysicalBias 3
Data/Baseline/OTB/Files/ioTuImageMetadataCompactTest.txt
View file @
e6b10461
{{"Extra.Information": "Very important",
"Extra.Comment": "Test Extrakeys",
"SensorID": "PHR",
"ProjectionWKT": "UTM projRef",
"ProductionDate": "2009-08-10T10:30:08.142149Z",
"Polarization": "Polarization",
"NoData": "-10000",
"AcquisitionDate": "2009-08-05T20:34:38.236478Z",
}Bands[{"PhysicalBias": "1",
"BandName": "B0",
"PhysicalGain": "2",
},{"PhysicalBias": "2",
"BandName": "B1",
"PhysicalGain": "3",
},{"PhysicalBias": "3",
"BandName": "B2",
"PhysicalGain": "4",
},]
}
\ No newline at end of file
SensorID PHR
Polarization Polarization
NoData -10000
AcquisitionDate 2009-08-05T20:34:38.236478Z
ProductionDate 2009-08-10T10:30:08.142149Z
ProjectionWKT UTM projRef
Extra.Comment Test Extrakeys
Extra.Information Very important
BandName B0
PhysicalGain 2
PhysicalBias 1
BandName B1
PhysicalGain 3
PhysicalBias 2
BandName B2
PhysicalGain 4
PhysicalBias 3
Data/Baseline/OTB/Files/ioTuImageMetadataMergeTest.txt
View file @
e6b10461
{{"ProductionDate": "2009-08-10T10:30:08.142149Z",
"Polarization": "Polarization",
"ProjectionWKT": "UTM projRef",
"Extra.Comment": "Test Extrakeys",
"SensorID": "SPOT",
}Bands[{"PhysicalBias": "1",
"PhysicalGain": "2",
"BandName": "B0",
"NoData": "-10000",
},{"PhysicalBias": "2",
"PhysicalGain": "3",
"BandName": "B1",
"SunAzimuth": "20",
"NoData": "-10000",
},]
}
\ No newline at end of file
SensorID SPOT
Polarization Polarization
ProductionDate 2009-08-10T10:30:08.142149Z
ProjectionWKT UTM projRef
Extra.Comment Test Extrakeys
BandName B0
NoData -10000
PhysicalGain 2
PhysicalBias 1
BandName B1
NoData -10000
PhysicalGain 3
PhysicalBias 2
SunAzimuth 20
Data/Baseline/OTB/Files/ioTuImageMetadataSliceTest.txt
View file @
e6b10461
{{"Extra.Comment": "Test Extrakeys",
"ProductionDate": "2009-08-10T10:30:08.142149Z",
"ProjectionWKT": "UTM projRef",
"SensorID": "PHR",
}Bands[{"PhysicalBias": "1",
"PhysicalGain": "2",
"BandName": "B0",
"NoData": "-10000",
},{"PhysicalBias": "2",
"PhysicalGain": "3",
"BandName": "B1",
"NoData": "-10000",
},]
}
\ No newline at end of file
SensorID PHR
ProductionDate 2009-08-10T10:30:08.142149Z
ProjectionWKT UTM projRef
Extra.Comment Test Extrakeys
BandName B0
NoData -10000
PhysicalGain 2
PhysicalBias 1
BandName B1
NoData -10000
PhysicalGain 3
PhysicalBias 2
Data/Baseline/OTB/Files/ioTuImageMetadataToFromKeywordlistTest.txt
View file @
e6b10461
{{"Extra.Comment": "Test Extrakeys",
"ProjectionEPSG": "4326",
"ProjectionWKT": "UTM projRef",
"ProjectionProj": "+proj=longlat +datum=WGS84 +no_defs ",
"SpectralSensitivity": "LUT1D.DIM0.SIZE = 3
SensorID PHR
ProductionDate 2009-08-10T10:30:08.142149Z
ProjectionWKT UTM projRef
ProjectionEPSG 4326
ProjectionProj +proj=longlat +datum=WGS84 +no_defs
SpectralSensitivity LUT1D.DIM0.SIZE = 3
LUT1D.DIM0.ORIGIN = 0
LUT1D.DIM0.SPACING = 1
LUT1D.ARRAY = 1 2 3"
"RPC": "<RPCParam>",
"ProductionDate": "2009-08-10T10:30:08.142149Z",
"GCP": "<GCPParam>",
"SensorID": "PHR",
}Bands[{"PhysicalBias": "1",
"PhysicalGain": "2",
"BandName": "B0",
"NoData": "-10000",
},{"PhysicalBias": "2",
"PhysicalGain": "3",
"BandName": "B1",
"NoData": "-10000",
},{"PhysicalBias": "3",
"PhysicalGain": "4",
"BandName": "B2",
"NoData": "-10000",
},]
}
\ No newline at end of file
LUT1D.ARRAY = 1 2 3
Extra.Comment Test Extrakeys
BandName B0
NoData -10000
PhysicalGain 2
PhysicalBias 1
BandName B1
NoData -10000
PhysicalGain 3
PhysicalBias 2
BandName B2
NoData -10000
PhysicalGain 4
PhysicalBias 3
Modules/Core/ImageBase/include/otbImageIOBase.h
View file @
e6b10461
...
...
@@ -567,6 +567,11 @@ protected:
/** Image metadata pre-parsed by the ImageIO */
ImageMetadata
m_Imd
;
/** Mapping between origin components and output components. Note that the buffer is
already mapped after calling the DoMapBuffer method. This attribute is useful to write
band related metadatas. */
std
::
vector
<
unsigned
int
>
m_BandList
;
private:
ImageIOBase
(
const
Self
&
)
=
delete
;
void
operator
=
(
const
Self
&
)
=
delete
;
...
...
Modules/Core/ImageBase/src/otbImageCommons.cxx
View file @
e6b10461
...
...
@@ -54,8 +54,11 @@ void ImageCommons::SetProjectionRef(const std::string& proj)
std
::
string
ImageCommons
::
GetGCPProjection
(
void
)
const
{
assert
(
m_Imd
.
Has
(
MDGeom
::
GCP
));
return
m_Imd
.
GetGCPParam
().
GCPProjection
;
if
(
m_Imd
.
Has
(
MDGeom
::
GCP
))
{
return
m_Imd
.
GetGCPParam
().
GCPProjection
;
}
return
""
;
}
...
...
Modules/Core/ImageBase/src/otbImageIOBase.cxx
View file @
e6b10461
...
...
@@ -1194,6 +1194,8 @@ std::vector<double> ImageIOBase::GetDefaultDirection(unsigned int k) const
void
ImageIOBase
::
DoMapBuffer
(
void
*
buffer
,
size_t
numberOfPixels
,
std
::
vector
<
unsigned
int
>&
bandList
)
{
m_BandList
=
bandList
;
size_t
componentSize
=
this
->
GetComponentSize
();
size_t
inPixelSize
=
componentSize
*
this
->
GetNumberOfComponents
();
size_t
outPixelSize
=
componentSize
*
bandList
.
size
();
...
...
Modules/Core/Metadata/test/otbImageMetadataTest.cxx
View file @
e6b10461
...
...
@@ -26,6 +26,7 @@
#include <utility>
#include <cstdlib>
#include "otbStopwatch.h"
#include "otbTestTools.h"
void
SetUpImageMetadata
(
otb
::
ImageMetadata
&
md
,
unsigned
int
nbBands
)
{
...
...
@@ -189,7 +190,7 @@ void otbImageMetadataSliceTest(char* argv[])
SetUpImageMetadata
(
md
,
3
);
ImageMetadata
md2
=
md
.
slice
(
0
,
1
);
o
utfile
<<
md2
;
o
tb
::
testtools
::
PrintMetadata
(
md2
,
outfile
)
;
outfile
.
close
();
}
...
...
@@ -207,7 +208,7 @@ void otbImageMetadataAppendTest(char* argv[])
SetUpImageMetadata
(
md2
,
3
);
md
.
append
(
md2
);
o
utfile
<<
md
;
o
tb
::
testtools
::
PrintMetadata
(
md
,
outfile
)
;
outfile
.
close
();
}
...
...
@@ -234,7 +235,7 @@ void otbImageMetadataMergeTest(char* argv[])
md
.
Merge
(
md2
);
o
utfile
<<
md
;
o
tb
::
testtools
::
PrintMetadata
(
md
,
outfile
)
;
outfile
.
close
();
}
void
otbImageMetadataToFromKeywordlistTest
(
char
*
argv
[])
...
...
@@ -265,7 +266,7 @@ void otbImageMetadataToFromKeywordlistTest(char* argv[])
md
.
AppendToKeywordlists
(
kwlVect
);
ImageMetadata
md2
;
md2
.
FromKeywordlists
(
kwlVect
);
o
utfile
<<
md2
;
o
tb
::
testtools
::
PrintMetadata
(
md2
,
outfile
)
;
outfile
.
close
();
}
...
...
@@ -288,7 +289,7 @@ void otbImageMetadataCompactTest(char* argv[])
}
md
.
compact
();
o
utfile
<<
md
;
o
tb
::
testtools
::
PrintMetadata
(
md
,
outfile
)
;
outfile
.
close
();
}
...
...
Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
View file @
e6b10461
...
...
@@ -1294,9 +1294,19 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer)
// char ** papszOptions = NULL;
std
::
string
driverShortName
;
m_NbBands
=
this
->
GetNumberOfComponents
();
// If the band mapping is different from the one of the input (e.g. because an extended filename
// has been set, the bands in the imageMetadata object needs to be reorganized.
if
(
!
m_BandList
.
empty
())
{
ImageMetadata
::
ImageMetadataBandsType
bandRangeMetadata
;
for
(
auto
elem
:
m_BandList
)
{
bandRangeMetadata
.
push_back
(
m_Imd
.
Bands
[
elem
]);
}
m_Imd
.
Bands
=
bandRangeMetadata
;
}
std
::
cout
<<
m_Imd
<<
std
::
endl
;
std
::
cout
<<
"m_NbBands "
<<
(
std
::
size_t
)
m_NbBands
<<
std
::
endl
;
std
::
cout
<<
"m_ImdBands size "
<<
m_Imd
.
Bands
.
size
()
<<
std
::
endl
;
if
(
!
m_Imd
.
Bands
.
empty
()
&&
(
std
::
size_t
)
m_NbBands
!=
m_Imd
.
Bands
.
size
())
{
...
...
Modules/IO/ImageIO/include/otbImageFileReader.hxx
View file @
e6b10461
...
...
@@ -574,6 +574,15 @@ void ImageFileReader<TOutputImage, ConvertPixelTraits>::GenerateOutputInformatio
m_IOComponents
=
m_BandList
.
size
();
}
// Delete band metadata if the Conversion policy changed the number of bands, in the case of
// grayscale to RGB for example. Because we cannot know how the metadata should be mapped.
// TODO: define proper behavior in this case.
using
ConvertIOPixelTraits
=
otb
::
DefaultConvertPixelTraits
<
typename
TOutputImage
::
IOPixelType
>
;
if
(
strcmp
(
output
->
GetNameOfClass
(),
"Image"
)
==
0
&&
!
(
this
->
m_ImageIO
->
GetNumberOfComponents
()
==
ConvertIOPixelTraits
::
GetNumberOfComponents
()))
{
imd
.
Bands
=
ImageMetadata
::
ImageMetadataBandsType
(
ConvertIOPixelTraits
::
GetNumberOfComponents
());
}
// THOMAS : ajout
// If a VectorImage, this requires us to set the
// VectorLength before allocate
...
...
Modules/IO/TestKernel/include/otbTestTools.h
0 → 100644
View file @
e6b10461
/*
* Copyright (C) 2005-2020 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef otbTestTools_h
#define otbTestTools_h
#include "otbMetaDataKey.h"
#include "otbImageMetadata.h"
namespace
otb
{
namespace
testtools
{
void
PrintMetadataBase
(
ImageMetadataBase
imdb
,
std
::
ostream
&
oss
)
{
std
::
unordered_map
<
std
::
string
,
std
::
string
>
kwl
;
imdb
.
ToKeywordlist
(
kwl
);
for
(
auto
It
=
otb
::
MetaData
::
MDStrNames
.
left
.
begin
()
;
It
!=
otb
::
MetaData
::
MDStrNames
.
left
.
end
()
;
++
It
)
{
auto
Key
=
kwl
.
find
(
It
->
second
);
if
(
Key
!=
kwl
.
end
())
oss
<<
It
->
second
<<
' '
<<
Key
->
second
<<
'\n'
;
}
for
(
auto
It
=
otb
::
MetaData
::
MDNumNames
.
left
.
begin
()
;
It
!=
otb
::
MetaData
::
MDNumNames
.
left
.
end
()
;
++
It
)
{
auto
Key
=
kwl
.
find
(
It
->
second
);
if
(
Key
!=
kwl
.
end
())
oss
<<
It
->
second
<<
' '
<<
Key
->
second
<<
'\n'
;
}
for
(
auto
It
=
otb
::
MetaData
::
MDTimeNames
.
left
.
begin
()
;
It
!=
otb
::
MetaData
::
MDTimeNames
.
left
.
end
()
;
++
It
)
{
auto
Key
=
kwl
.
find
(
It
->
second
);
if
(
Key
!=
kwl
.
end
())
oss
<<
It
->
second
<<
' '
<<
Key
->
second
<<
'\n'
;
}
for
(
auto
It
=
otb
::
MetaData
::
MDGeomNames
.
left
.
begin
()
;
It
!=
otb
::
MetaData
::
MDGeomNames
.
left
.
end
()
;
++
It
)
{
auto
Key
=
kwl
.
find
(
It
->
second
);
if
(
Key
!=
kwl
.
end
())
oss
<<
It
->
second
<<
' '
<<
Key
->
second
<<
'\n'
;
}
for
(
auto
It
=
otb
::
MetaData
::
MDL1DNames
.
left
.
begin
()
;
It
!=
otb
::
MetaData
::
MDL1DNames
.
left
.
end
()
;
++
It
)
{
auto
Key
=
kwl
.
find
(
It
->
second
);
if
(
Key
!=
kwl
.
end
())
oss
<<
It
->
second
<<
' '
<<
Key
->
second
<<
'\n'
;
}
for
(
auto
It
=
otb
::
MetaData
::
MDL2DNames
.
left
.
begin
()
;
It
!=
otb
::
MetaData
::
MDL2DNames
.
left
.
end
()
;
++
It
)
{
auto
Key
=
kwl
.
find
(
It
->
second
);
if
(
Key
!=
kwl
.
end
())
oss
<<
It
->
second
<<
' '
<<
Key
->
second
<<
'\n'
;
}
std
::
string
prefix
(
"Extra."
);
for
(
const
auto
&
kv
:
imdb
.
ExtraKeys
)
oss
<<
prefix
+
kv
.
first
<<
' '
<<
kv
.
second
<<
'\n'
;
}
void
PrintMetadata
(
ImageMetadata
imd
,
std
::
ostream
&
oss
)
{
PrintMetadataBase
(
imd
,
oss
);
for
(
ImageMetadataBase
imdb
:
imd
.
Bands
)
PrintMetadataBase
(
imdb
,
oss
);
}
}
}
#endif
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