27 #include "../../../core/translator/Translator.h" 28 #include "../../../dataaccess/datasource/DataSource.h" 29 #include "../../../dataaccess/datasource/DataSourceFactory.h" 30 #include "../../../dataaccess/utils/Utils.h" 31 #include "../../../raster/Interpolator.h" 32 #include "../../../raster/Raster.h" 33 #include "../../../raster/RasterFactory.h" 34 #include "../Exception.h" 36 #include "ui_MultiResolutionWidgetForm.h" 39 #include <QFileDialog> 40 #include <QMessageBox> 44 te::qt::widgets::MultiResolutionWidget::MultiResolutionWidget(
QWidget* parent, Qt::WindowFlags f)
46 m_ui(new
Ui::MultiResolutionWidgetForm)
52 m_ui->m_fileToolButton->setIcon(QIcon::fromTheme(
"file-raster"));
53 m_ui->m_folderToolButton->setIcon(QIcon::fromTheme(
"folder-open"));
56 connect(m_ui->m_fileToolButton, SIGNAL(clicked()),
this, SLOT(onFileToolButtonClicked()));
57 connect(m_ui->m_folderToolButton, SIGNAL(clicked()),
this, SLOT(onFolderToolButtonClicked()));
59 fillInterpolatorTypes();
64 Ui::MultiResolutionWidgetForm*
72 if(
m_ui->m_layerRadioButton->isChecked())
74 else if(
m_ui->m_fileRadioButton->isChecked())
76 else if(
m_ui->m_folderRadioButton->isChecked())
84 m_ui->m_layerComboBox->clear();
86 std::list<te::map::AbstractLayerPtr>::iterator it = layerList.begin();
88 while(it != layerList.end())
92 std::unique_ptr<te::da::DataSetType> dsType = l->getSchema();
94 if(dsType->hasRaster())
95 m_ui->m_layerComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
103 if(
m_ui->m_layerComboBox->currentText().isEmpty())
105 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Layer not selected."));
109 int idx =
m_ui->m_layerComboBox->currentIndex();
110 QVariant varLayer =
m_ui->m_layerComboBox->itemData(idx, Qt::UserRole);
115 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Invalid layer selected."));
119 std::unique_ptr<te::da::DataSet>
ds = layer->getData();
121 std::unique_ptr<te::rst::Raster>
rst = ds->getRaster(rpos);
125 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Selected layer does not have raster representation."));
133 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Error creating multi resolution."));
136 QMessageBox::information(
this, tr(
"Information"), tr(
"Multi resolution created."));
143 if(
m_ui->m_fileLineEdit->text().isEmpty())
145 QMessageBox::warning(
this, tr(
"Warning"), tr(
"File not selected."));
149 std::map<std::string, std::string> rinfo;
150 rinfo[
"URI"] =
m_ui->m_fileLineEdit->text().toUtf8().data();
156 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Invalid file selected."));
164 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Error creating multi resolution."));
167 QMessageBox::information(
this, tr(
"Information"), tr(
"Multi resolution created."));
174 if(
m_ui->m_folderLineEdit->text().isEmpty())
176 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Folder not selected."));
180 const std::string dsInfo(
"file://" + std::string(
m_ui->m_folderLineEdit->text().toUtf8().data()));
185 std::vector<std::string> rasterNames = ds->getDataSetNames();
187 for(std::size_t t = 0; t < rasterNames.size(); ++t)
189 std::unique_ptr<te::da::DataSet> dataSet = ds->getDataSet(rasterNames[t]);
195 std::unique_ptr<te::rst::Raster>
rst = dataSet->getRaster(rpos);
203 std::string errorMsg =
"Error creating multi resolution. File: " + rasterNames[t] +
".";
204 QMessageBox::warning(
this, tr(
"Warning"), errorMsg.c_str());
210 QMessageBox::information(
this, tr(
"Information"), tr(
"Multi resolution created."));
219 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Invalid Raster."));
223 QApplication::setOverrideCursor(Qt::WaitCursor);
227 unsigned int nLevels =
m_ui->m_levelsSpinBox->value();
229 int interpolationIdx =
m_ui->m_interpolatorComboBox->currentIndex();
236 QApplication::restoreOverrideCursor();
241 QApplication::restoreOverrideCursor();
248 m_ui->m_interpolatorComboBox->clear();
257 QString filter = tr(
"Image File (*.png *.jpg *.jpeg *.tif *.tiff *.geotif *.geotiff);; Web Map Service - WMS (*.xml *.wms);; Web Coverage Service - WCS (*.xml *.wcs);; All Files (*.*)");
259 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Open Raster File"),
"", filter);
261 if(fileName.isEmpty())
264 m_ui->m_fileLineEdit->setText(fileName);
269 QString folderName = QFileDialog::getExistingDirectory(
this, tr(
"Select a directory"),
"");
271 if(folderName.isEmpty())
274 m_ui->m_folderLineEdit->setText(folderName);
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
Near neighborhood interpolation method.
virtual bool createMultiResolution(const unsigned int levels, const InterpolationMethod interpMethod)=0
Create a sub-sampled multi-resolution pyramid.
static te::dt::Date ds(2010, 01, 01)
InterpolationMethod
Allowed interpolation methods.
InterpolationMethod Method
Allowed interpolation methods.
te::common::AccessPolicy getAccessPolicy() const
Returns the raster access policy.
An abstract class for raster data strucutures.
Bicubic interpolation method.
Bilinear interpolation method.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
static Raster * open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
It opens a raster with the given parameters and default raster driver.