27 #include "../../../common/StringUtils.h" 28 #include "../../../common/STLUtils.h" 29 #include "../../../common/progress/ProgressManager.h" 30 #include "../../../dataaccess/dataset/DataSet.h" 31 #include "../../../dataaccess/utils/Utils.h" 32 #include "../../../raster/Raster.h" 33 #include "../../../rp/FeedersRaster.h" 34 #include "../../../rp/Functions.h" 35 #include "../../../maptools/Utils.h" 36 #include "../help/HelpPushButton.h" 37 #include "../layer/search/LayerSearchWidget.h" 38 #include "../layer/search/LayerSearchWizardPage.h" 39 #include "../progress/ProgressViewerDialog.h" 42 #include "../raster/RasterInfoWidget.h" 50 #include <QMessageBox> 51 #include <QApplication> 58 this->setWizardStyle(QWizard::ModernStyle);
59 this->setWindowTitle(tr(
"Compose / Decompose Bands"));
61 this->setOption(QWizard::HaveHelpButton,
true);
62 this->setOption(QWizard::HelpButtonOnRight,
false);
66 this->setButton(QWizard::HelpButton, helpButton);
70 connect(
this, SIGNAL(currentIdChanged(
int)), SLOT(
onPageChanged(
int)));
81 std::list<te::map::AbstractLayerPtr> list =
m_layerSearchPage->getSearchWidget()->getSelecteds();
121 m_layerSearchPage->setSubTitle(tr(
"Allows selection of layers using filters for selection. Select one layer for DECOMPOSITION or multi layers for COMPOSITION."));
129 QMessageBox::warning(
this, tr(
"Compose / Decompose Bands"), tr(
"File already exists."));
145 std::map<std::string, std::string> rinfo =
m_rasterInfoPage->getWidget()->getInfo();
149 std::vector<const te::rst::Raster*> inputRasters;
150 std::vector<unsigned int> inputRasterBands;
153 m_composeBandsPage->getComposeParameters(inputRasters, inputRasterBands, interpMethod);
155 std::vector<const te::rst::Raster*> inputRastersComposed;
158 for(std::size_t i = 0; i < inputRasters.size(); ++i)
161 inputRastersComposed = inputRasters;
167 std::unique_ptr<te::rst::Raster> outputRaster;
169 QApplication::setOverrideCursor(Qt::WaitCursor);
177 catch(
const std::exception& e)
179 QMessageBox::warning(
this, tr(
"Compose"), e.what());
181 QApplication::restoreOverrideCursor();
192 QMessageBox::warning(
this, tr(
"Compose"), tr(
"An exception has occurred!"));
194 QApplication::restoreOverrideCursor();
204 QApplication::restoreOverrideCursor();
209 outputRaster.reset();
231 std::string outputDataSetNamePrefix =
m_rasterInfoPage->getWidget()->getShortName();
232 std::string outputDataSetNameExt =
m_rasterInfoPage->getWidget()->getExtension();
234 std::vector< std::map<std::string, std::string> > outputRastersInfos;
238 std::vector<unsigned int> inputRasterBands;
247 inputRasterDecomposed = inputRaster;
250 std::vector<std::string> outputDataSetNames;
252 for(std::size_t t = 0; t < inputRasterBands.size(); ++t)
254 std::string name = outputDataSetNamePrefix;
257 name += outputDataSetNameExt;
259 outputDataSetNames.push_back(name);
261 outputRastersInfos.push_back(
m_rasterInfoPage->getWidget()->getInfo((
int)t));
264 std::vector< boost::shared_ptr< te::rst::Raster > > outputRastersPtrs;
271 res =
te::rp::DecomposeBands(*inputRasterDecomposed, inputRasterBands, outputRastersInfos, type, outputRastersPtrs);
273 catch(
const std::exception& e)
275 QMessageBox::warning(
this, tr(
"Decompose"), e.what());
277 QApplication::restoreOverrideCursor();
279 outputRastersPtrs.clear();
284 delete inputRasterDecomposed;
290 QMessageBox::warning(
this, tr(
"Decompose"), tr(
"An exception has occurred!"));
292 QApplication::restoreOverrideCursor();
294 outputRastersPtrs.clear();
299 delete inputRasterDecomposed;
304 QApplication::restoreOverrideCursor();
309 outputRastersPtrs.clear();
313 for (std::size_t t = 0; t < outputRastersInfos.size(); ++t)
315 std::map<std::string, std::string> rinfo = outputRastersInfos[t];
326 delete inputRasterDecomposed;
A feeder from a input rasters vector;.
bool ComposeBands(te::rp::FeederConstRaster &feeder, const std::vector< unsigned int > &inputRasterBands, const te::rst::Interpolator::Method &interpMethod, const std::map< std::string, std::string > &outputRasterInfo, const std::string &outputDataSourceType, std::unique_ptr< te::rst::Raster > &outputRasterPtr)
Compose a set of bands into one multi-band raster.
bool DecomposeBands(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, const std::vector< std::map< std::string, std::string > > &outputRastersInfos, const std::string &outputDataSourceType, std::vector< boost::shared_ptr< te::rst::Raster > > &outputRastersPtrs)
Decompose a multi-band raster into a set of one-band rasters.
InterpolationMethod
Allowed interpolation methods.
This file defines a class for a Raster Info Wizard page.
A Qt dialog that allows users to compose or decompose bands.
This class is GUI used to defines a class for a Compose / Decompose Bands Wizard page.
bool NormalizeRaster(te::rst::Raster &inraster, double nmin, double nmax)
Normalizes one raster in a given interval.
An abstract class for raster data strucutures.
This class is GUI used to define the raster info parameters for raster factory.
Utility functions for the data access module.
TEMAPEXPORT te::rst::Raster * GetRaster(AbstractLayer *layer)
It gets the raster referenced by the given data set layer.
This file defines a class for a Compose / Decompose Bands Wizard page.
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...