27 #include "../../../common/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>
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"));
73 if(m_ui->m_layerRadioButton->isChecked())
75 else if(m_ui->m_fileRadioButton->isChecked())
77 else if(m_ui->m_folderRadioButton->isChecked())
85 m_ui->m_layerComboBox->clear();
87 std::list<te::map::AbstractLayerPtr>::iterator it = layerList.begin();
89 while(it != layerList.end())
93 std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
95 if(dsType->hasRaster())
96 m_ui->m_layerComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
104 if(m_ui->m_layerComboBox->currentText().isEmpty())
106 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Layer not selected."));
110 int idx = m_ui->m_layerComboBox->currentIndex();
111 QVariant varLayer = m_ui->m_layerComboBox->itemData(idx, Qt::UserRole);
116 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Invalid layer selected."));
120 std::auto_ptr<te::da::DataSet> ds = layer->getData();
122 std::auto_ptr<te::rst::Raster> rst = ds->getRaster(rpos);
126 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Selected layer does not have raster representation."));
130 bool res = createMultiRes(rst.get());
134 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Error creating multi resolution."));
137 QMessageBox::information(
this, tr(
"Information"), tr(
"Multi resolution created."));
144 if(m_ui->m_fileLineEdit->text().isEmpty())
146 QMessageBox::warning(
this, tr(
"Warning"), tr(
"File not selected."));
150 std::map<std::string, std::string> rinfo;
151 rinfo[
"URI"] = m_ui->m_fileLineEdit->text().toStdString();
157 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Invalid file selected."));
161 bool res = createMultiRes(rst.get());
165 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Error creating multi resolution."));
168 QMessageBox::information(
this, tr(
"Information"), tr(
"Multi resolution created."));
175 if(m_ui->m_folderLineEdit->text().isEmpty())
177 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Folder not selected."));
181 std::map<std::string, std::string> dsInfo;
182 dsInfo[
"SOURCE"] = m_ui->m_folderLineEdit->text().toStdString();
186 ds->setConnectionInfo(dsInfo);
190 std::vector<std::string> rasterNames = ds->getDataSetNames();
192 for(std::size_t t = 0; t < rasterNames.size(); ++t)
194 std::auto_ptr<te::da::DataSet> dataSet = ds->getDataSet(rasterNames[t]);
200 std::auto_ptr<te::rst::Raster> rst = dataSet->getRaster(rpos);
204 bool res = createMultiRes(rst.get());
208 std::string errorMsg =
"Error creating multi resolution. File: " + rasterNames[t] +
".";
209 QMessageBox::warning(
this, tr(
"Warning"), errorMsg.c_str());
215 QMessageBox::information(
this, tr(
"Information"), tr(
"Multi resolution created."));
224 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Invalid Raster."));
228 QApplication::setOverrideCursor(Qt::WaitCursor);
232 unsigned int nLevels = m_ui->m_levelsSpinBox->value();
234 int interpolationIdx = m_ui->m_interpolatorComboBox->currentIndex();
241 QApplication::restoreOverrideCursor();
246 QApplication::restoreOverrideCursor();
253 m_ui->m_interpolatorComboBox->clear();
262 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 (*.*)");
264 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Open Raster File"),
"", filter);
266 if(fileName.isEmpty())
269 m_ui->m_fileLineEdit->setText(fileName);
274 QString folderName = QFileDialog::getExistingDirectory(
this, tr(
"Select a directory"),
"");
276 if(folderName.isEmpty())
279 m_ui->m_folderLineEdit->setText(folderName);
Near neighborhood interpolation method.
virtual bool createMultiResolution(const unsigned int levels, const InterpolationMethod interpMethod)=0
Create a sub-sampled multi-resolution pyramid.
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.
static std::auto_ptr< DataSource > make(const std::string &dsType)
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.