27 #include "../../../common/progress/ProgressManager.h" 28 #include "../../../common/StringUtils.h" 29 #include "../../../dataaccess/dataset/DataSet.h" 30 #include "../../../dataaccess/dataset/DataSetType.h" 31 #include "../../../dataaccess/utils/Utils.h" 32 #include "../../../geometry/Utils.h" 33 #include "../../../maptools/Utils.h" 34 #include "../../../raster/RasterProperty.h" 35 #include "../../../rp/Filter.h" 36 #include "../../../rp/Module.h" 37 #include "../../../se/CoverageStyle.h" 38 #include "../../../se/RasterSymbolizer.h" 39 #include "../../../se/Rule.h" 40 #include "../../../se/SelectedChannel.h" 41 #include "../../../se/Utils.h" 42 #include "../../af/events/LayerEvents.h" 43 #include "../../widgets/tools/ExtentAcquire.h" 44 #include "../../widgets/utils/DoubleListWidget.h" 45 #include "../canvas/Canvas.h" 46 #include "../canvas/MapDisplay.h" 47 #include "../progress/ProgressViewerDialog.h" 51 #include "ui_FilterDialogForm.h" 54 #include <QApplication> 55 #include <QGridLayout> 56 #include <QMessageBox> 60 #include <boost/lexical_cast.hpp> 65 m_previewRaster(nullptr),
72 m_ui->m_maskToolButton->setIcon(QIcon::fromTheme(
"mask"));
73 m_ui->m_loadMaskToolButton->setIcon(QIcon::fromTheme(
"mask-fill"));
74 m_ui->m_maskDefaultValueLineEdit->setValidator(
new QDoubleValidator(
this));
76 QGridLayout* displayLayout =
new QGridLayout(
m_ui->m_navigatorWidget);
79 displayLayout->setContentsMargins(0,0,0,0);
82 QGridLayout* inputLayout =
new QGridLayout(
m_ui->m_inputWidget);
83 inputLayout->setContentsMargins(0, 0, 0, 0);
88 QGridLayout* outputLayout =
new QGridLayout(
m_ui->m_outputWidget);
89 outputLayout->setContentsMargins(0, 0, 0, 0);
98 QGridLayout* layout =
new QGridLayout(
m_ui->m_bandsGroupBox);
100 layout->setContentsMargins(0, 0, 0, 0);
102 m_ui->m_helpPushButton->setNameSpace(
"dpi.inpe.br.plugins");
103 m_ui->m_helpPushButton->setPageReference(
"plugins/rp/rp_filter.html");
105 m_ui->m_navigatorWidget->setEnabled(
false);
137 std::vector<std::string>
bands;
138 for (
unsigned int b = 0;
b < raster->getNumberOfBands();
b++)
146 std::list<te::map::AbstractLayerPtr> layersRasterList;
148 std::list<te::map::AbstractLayerPtr>::iterator it = layerList.begin();
150 while (it != layerList.end())
152 std::unique_ptr<te::da::DataSetType> dsType = it->get()->getSchema();
153 if (dsType->hasRaster())
154 layersRasterList.push_back(it->get());
160 if (!layersRasterList.empty())
162 m_layer = layersRasterList.begin()->get();
166 if (selectedlayer && selectedlayer->isValid())
174 std::vector<std::string>
bands;
178 bands.push_back(channelName);
181 bands.push_back(channelName);
184 bands.push_back(channelName);
189 bands.push_back(channelName);
192 std::vector<std::string> inputBands;
193 for (
unsigned int i = 0; i < raster->getNumberOfBands(); i++)
195 bool isOutputBand =
false;
196 for (
unsigned int b = 0;
b < bands.size();
b++)
230 int idx =
m_ui->m_typeComboBox->currentIndex();
257 algoInputParams.
m_windowH =
m_ui->m_maskSizeSpinBox->value();
258 algoInputParams.
m_windowW =
m_ui->m_maskSizeSpinBox->value();
262 for(
int i = 0; i < nBands; ++i)
267 return algoInputParams;
272 int filterType =
m_ui->m_typeComboBox->itemData(index).toInt();
283 m_ui->m_maskSizeSpinBox->setEnabled(flag);
284 m_ui->m_maskToolButton->setEnabled(flag);
285 m_ui->m_maskDefaultValueLineEdit->setEnabled(flag);
287 if(
m_ui->m_previewCheckBox->isChecked())
295 if(
m_ui->m_previewCheckBox->isChecked())
304 m_ui->m_maskDefaultValueLineEdit->text().isEmpty() ? 0 :
m_ui->m_maskDefaultValueLineEdit->text().toDouble());
306 if(dlg.exec() == QDialog::Accepted)
310 m_ui->m_loadMaskToolButton->setEnabled(
true);
320 m_ui->m_maskSizeSpinBox->setValue(static_cast<int>(
m_window.size1()));
322 if(dlg.exec() == QDialog::Accepted)
332 m_ui->m_navigatorWidget->setEnabled(
true);
337 m_ui->m_navigatorWidget->setEnabled(
false);
346 QMessageBox::information(
this, tr(
"Filter"), tr(
"Input image is not defined."));
353 QMessageBox::information(
this, tr(
"Filter"), tr(
"Output image is not defined."));
359 QMessageBox::information(
this, tr(
"Filter"), tr(
"Error to execute the filter."));
375 if (!
m_ui->m_previewCheckBox->isChecked() || !env.
isValid())
382 bool needRemap =
false;
394 converter->setTargetSRID(
m_layer->getSRID());
402 QMessageBox::warning(
this, tr(
"Warning"), tr(
"ROI is invalid."));
432 QMessageBox::warning(
this, tr(
"Filter"), tr(
"File already exists."));
452 QApplication::setOverrideCursor(Qt::WaitCursor);
454 if (algorithmInstance.
initialize(algoInputParams))
456 if (algorithmInstance.
execute(algoOutputParams))
458 algoOutputParams.
reset();
464 QMessageBox::information(
this, tr(
"Filter"), tr(
"Filter ended sucessfully"));
468 QMessageBox::critical(
this, tr(
"Filter"), tr(
"Filter execution error.") +
471 QApplication::restoreOverrideCursor();
478 QMessageBox::critical(
this, tr(
"Filter"), tr(
"Filter initialization error.") +
481 QApplication::restoreOverrideCursor();
486 QApplication::restoreOverrideCursor();
505 std::vector<std::string>
bands;
507 for(
unsigned int i = 0; i < inputRst->getNumberOfBands(); ++i)
516 m_ui->m_typeComboBox->clear();
543 std::map<std::string, std::string> rinfo;
549 algoOutputParams.
m_rType =
"MEM";
550 algoOutputParams.
m_rInfo = rinfo;
555 QApplication::setOverrideCursor(Qt::WaitCursor);
557 if (algorithmInstance.
initialize(algoInputParams))
559 if (algorithmInstance.
execute(algoOutputParams))
567 if (
m_ui->m_previewCheckBox->isChecked())
570 QApplication::restoreOverrideCursor();
574 QApplication::restoreOverrideCursor();
576 QMessageBox::critical(
this, tr(
"Filter"), tr(
"Filter execution error.") +
584 QApplication::restoreOverrideCursor();
586 QMessageBox::critical(
this, tr(
"Filter"), tr(
"Filter initialization error.") +
595 QApplication::setOverrideCursor(Qt::WaitCursor);
623 delete canvasInstance;
625 QApplication::restoreOverrideCursor();
646 delete canvasInstance;
660 const std::vector<te::se::Symbolizer*>& symbolizers = rule->
getSymbolizers();
661 assert(!symbolizers.empty());
667 return symbolizer->getChannelSelection();
674 QApplication::setOverrideCursor(Qt::WaitCursor);
679 bool needRemap =
false;
689 converter->setTargetSRID(
m_layer->getSRID());
697 std::map<std::string, std::string> info;
698 info[
"FORCE_MEM_DRIVER"] =
"TRUE";
702 if (
m_ui->m_previewCheckBox->isChecked())
707 QApplication::restoreOverrideCursor();
715 canvasInstance.
clear();
const std::string & getErrorMessage() const
Return the current error message if there is any.
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
bool intersects(const Envelope &rhs) const
It returns true if the envelopes "spatially intersects".
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
The CoverageStyle defines the styling that is to be applied to a subset of Coverage data...
virtual Raster * trim(const te::gm::Envelope *env, const std::map< std::string, std::string > &rinfo) const
Subsetting operation for trimming (cropping) the raster.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
TESEEXPORT Style * CreateCoverageStyle(const std::vector< te::rst::BandProperty * > &properties)
Try creates an appropriate coverage style based on given band properties.
double m_urx
Upper right corner x-coordinate.
bool execute(AlgorithmOutputParameters &outputParams) _NOEXCEPT_OP(false)
Executes the algorithm using the supplied parameters.
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
SelectedChannel * getRedChannel() const
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
SelectedChannel * getBlueChannel() const
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
std::string getSourceChannelName() const
Rule * getRule(std::size_t i) const
std::map< std::string, std::string > m_rInfo
The necessary information to create the raster (as described in te::raster::RasterFactory).
TEMAPEXPORT void DrawRaster(te::da::DataSetType *type, te::da::DataSourcePtr ds, Canvas *canvas, const te::gm::Envelope &bbox, int bboxSRID, const te::gm::Envelope &visibleArea, int srid, te::se::CoverageStyle *style, te::map::RasterContrast *rc, const double &scale, bool *cancel)
void reset() _NOEXCEPT_OP(false)
Clear all internal allocated resources and reset the parameters instance to its initial state...
double m_llx
Lower left corner x-coordinate.
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
virtual bool isValid() const _NOEXCEPT_OP(false)
It tells if the geometry is well formed.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
virtual int getBandDataType(std::size_t i) const =0
Returns the data type in a particular band (or dimension).
ColorCompositionType getColorCompositionType() const
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
This file defines a class for a MaskDialog.
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
A base class for values that can be retrieved from the data access module.
Utility functions for the data access module.
A series of well-known filtering algorithms for images, linear and non-linear..
const std::vector< Symbolizer * > & getSymbolizers() const
double m_lly
Lower left corner y-coordinate.
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
TEMAPEXPORT te::rst::Raster * GetRaster(AbstractLayer *layer)
It gets the raster referenced by the given data set layer.
int getSRID() const
Returns the raster spatial reference system identifier.
SelectedChannel * getGreenChannel() const
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
double m_ury
Upper right corner y-coordinate.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
bool initialize(const AlgorithmInputParameters &inputParams) _NOEXCEPT_OP(false)
Initialize the algorithm instance making it ready for execution.
Filter output parameters.
SelectedChannel * getGrayChannel() const
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
bool isValid() const
It tells if the rectangle is valid or not.
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
A pointer the ge generated output raster (label image).
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
ChannelSelection specifies the false-color channel selection for a multi-spectral raster source (such...