Skip to content
GitLab
Menu
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
2470289f
Commit
2470289f
authored
Mar 11, 2013
by
Otmane Lahlou
Browse files
BUG: attempt to handle case BandsName size not equal to image nb components
parent
d71cc5a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Code/Common/mvdAbstractImageModel.cxx
View file @
2470289f
...
...
@@ -95,66 +95,98 @@ AbstractImageModel
otb
::
ImageMetadataInterfaceBase
::
ConstPointer
metaDataInterface
(
GetMetaDataInterface
()
);
);
//
// Basic band names.
StringVector
stdBandNames1
(
metaDataInterface
->
GetBandName
()
);
// output band name list
QStringList
qBandNames1
(
QString
(
""
)
);
/*
qDebug() << "stdBandNames1.size(): " << stdBandNames1.size();
for( unsigned int i=0; i<stdBandNames1.size(); ++i )
qDebug() << i << ": " << QString( stdBandNames1[ i ].c_str() );
*/
assert
(
stdBandNames1
.
empty
()
||
stdBandNames1
.
size
()
==
output
->
GetNumberOfComponentsPerPixel
()
);
if
(
stdBandNames1
.
size
()
!=
output
->
GetNumberOfComponentsPerPixel
()
)
{
stdBandNames1
.
resize
(
output
->
GetNumberOfComponentsPerPixel
()
);
}
//
// Enhanced band names.
StringVector
stdBandNames2
;
if
(
enhanced
)
// PS: need to handle images with extracted channels and a geom file
// storing the original image band names.
if
(
stdBandNames1
.
empty
()
||
stdBandNames1
.
size
()
!=
output
->
GetNumberOfComponentsPerPixel
())
{
try
// output stringVector
StringVector
outputBandNames
;
//
// Fill the output std::vector with default values
for
(
unsigned
int
count
=
0
;
count
<
output
->
GetNumberOfComponentsPerPixel
();
count
++
)
{
stdBandNames2
=
metaDataInterface
->
GetEnhancedBandNames
();
std
::
ostringstream
oss
;
oss
<<
"BAND "
<<
count
;
outputBandNames
.
push_back
(
oss
.
str
());
}
catch
(
itk
::
ExceptionObject
&
)
{}
// set the output QStringList
qBandNames1
=
ToQStringList
(
outputBandNames
);
}
else
{
// useless
assert
(
stdBandNames1
.
empty
()
||
stdBandNames1
.
size
()
==
output
->
GetNumberOfComponentsPerPixel
()
);
/*
qDebug() << "stdBandNames2.size(): " << stdBandNames2.size();
for( unsigned int i=0; i<stdBandNames2.size(); ++i )
qDebug() << i << ": " << QString( stdBandNames2[ i ].c_str() );
*/
if
(
stdBandNames1
.
size
()
!=
output
->
GetNumberOfComponentsPerPixel
()
)
{
stdBandNames1
.
resize
(
output
->
GetNumberOfComponentsPerPixel
()
);
}
assert
(
stdBandNames2
.
empty
()
||
stdBandNames2
.
size
()
==
output
->
GetNumberOfComponentsPerPixel
()
);
//
// Enhanced band names.
StringVector
stdBandNames2
;
if
(
enhanced
)
{
try
{
stdBandNames2
=
metaDataInterface
->
GetEnhancedBandNames
();
}
catch
(
itk
::
ExceptionObject
&
)
{}
}
if
(
stdBandNames2
.
size
()
!=
output
->
GetNumberOfComponentsPerPixel
()
)
{
stdBandNames2
.
resize
(
output
->
GetNumberOfComponentsPerPixel
()
);
}
/*
qDebug() << "stdBandNames2.size(): " << stdBandNames2.size();
for( unsigned int i=0; i<stdBandNames2.size(); ++i )
qDebug() << i << ": " << QString( stdBandNames2[ i ].c_str() );
*/
//
// Join basic and enhanced band-name lists.
assert
(
stdBandNames1
.
size
()
==
stdBandNames2
.
size
()
);
assert
(
stdBandNames2
.
empty
()
||
stdBandNames2
.
size
()
==
output
->
GetNumberOfComponentsPerPixel
()
);
if
(
stdBandNames2
.
size
()
!=
output
->
GetNumberOfComponentsPerPixel
()
)
{
stdBandNames2
.
resize
(
output
->
GetNumberOfComponentsPerPixel
()
);
}
QStringList
qBandNames1
(
ToQStringList
(
stdBandNames1
)
);
QStringList
qBandNames2
(
ToQStringList
(
stdBandNames2
)
);
//
// Join basic and enhanced band-name lists.
assert
(
stdBandNames1
.
size
()
==
stdBandNames2
.
size
()
);
qBandNames1
=
ToQStringList
(
stdBandNames1
);
QStringList
qBandNames2
(
ToQStringList
(
stdBandNames2
)
);
QStringList
::
iterator
it1
(
qBandNames1
.
begin
()
);
QStringList
::
const_iterator
it2
(
qBandNames2
.
begin
()
);
for
(
;
it1
!=
qBandNames1
.
end
();
++
it1
,
++
it2
)
{
if
(
!
it2
->
isEmpty
()
)
it1
->
append
(
" ("
+
*
it2
+
")"
);
}
QStringList
::
iterator
it1
(
qBandNames1
.
begin
()
);
QStringList
::
const_iterator
it2
(
qBandNames2
.
begin
()
);
for
(
;
it1
!=
qBandNames1
.
end
();
++
it1
,
++
it2
)
{
if
(
!
it2
->
isEmpty
()
)
it1
->
append
(
" ("
+
*
it2
+
")"
);
}
//
...
...
Write
Preview
Supports
Markdown
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