Skip to content
Snippets Groups Projects
Commit cabcb2d2 authored by Marina Bertolino's avatar Marina Bertolino
Browse files

ENH: add range band to otbExtendedFilenameToWriterOptions

parent 538f98e4
Branches
Tags
No related merge requests found
......@@ -69,6 +69,7 @@ public:
std::pair<bool, std::string> streamingSizeMode;
std::pair<bool, double> streamingSizeValue;
std::pair<bool, std::string> box;
std::pair< bool, std::string> bandRange;
std::vector<std::string> optionList;
};
......@@ -92,6 +93,16 @@ public:
bool BoxIsSet() const;
std::string GetBox() const;
/** Test if band range extended filename is set */
bool BandRangeIsSet () const;
/** Decode the string into a list of GenericBandRange, band indexes are
* 1-based. */
std::vector<ExtendedFilenameHelper::GenericBandRange> GetBandRange() const;
/** Resolve the list of band ranges into real band indexes, according to
* a total number of bands in the image. Note that the output indexes are
* zero-based (0 is the first component) */
bool ResolveBandRange(const unsigned int &nbBands, std::vector<unsigned int> &output) const;
protected:
ExtendedFilenameToWriterOptions();
......
......@@ -40,12 +40,16 @@ ExtendedFilenameToWriterOptions
m_Options.streamingSizeMode.first = false;
m_Options.streamingSizeValue.first = false;
m_Options.bandRange.first = false;
m_Options.bandRange.second = "";
m_Options.optionList.push_back("writegeom");
m_Options.optionList.push_back("writerpctags");
m_Options.optionList.push_back("streaming:type");
m_Options.optionList.push_back("streaming:sizemode");
m_Options.optionList.push_back("streaming:sizevalue");
m_Options.optionList.push_back("box");
m_Options.optionList.push_back("bands");
}
void
......@@ -155,6 +159,22 @@ ExtendedFilenameToWriterOptions
}
}
if (!map["bands"].empty())
{
// Basic check on bandRange (using regex)
itksys::RegularExpression reg;
reg.compile("^((\\-?[0-9]+)?(:(\\-?[0-9]+)?)?)(,(\\-?[0-9]+)?(:(\\-?[0-9]+)?)?)*$");
if (reg.find(map["bands"]))
{
m_Options.bandRange.first = true;
m_Options.bandRange.second = map["bands"];
}
else
{
itkWarningMacro("Unkwown value "<<map["bands"]<<" for band range. Expect a list of tokens separated with comma (each token being a single band index or a range in the form x:y)");
}
}
//Option Checking
for ( it=map.begin(); it != map.end(); it++ )
{
......@@ -286,5 +306,25 @@ ExtendedFilenameToWriterOptions
return m_Options.box.second;
}
bool
ExtendedFilenameToWriterOptions
::BandRangeIsSet () const
{
return m_Options.bandRange.first;
}
std::vector<ExtendedFilenameHelper::GenericBandRange>
ExtendedFilenameToWriterOptions
::GetBandRange () const
{
return Superclass::GetBandRange(m_Options.bandRange.second);
}
bool
ExtendedFilenameToWriterOptions
::ResolveBandRange(const unsigned int &nbBands, std::vector<unsigned int> &output) const
{
return Superclass::ResolveBandRange(nbBands, output, m_Options.bandRange.second);
}
} // end namespace otb
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment