27 #include "../../../common/STLUtils.h" 28 #include "../../../common/StringUtils.h" 29 #include "../../../dataaccess/dataset/DataSet.h" 30 #include "../../../dataaccess/utils/Utils.h" 31 #include "../../../geometry/Coord2D.h" 32 #include "../../../geometry/GTFactory.h" 33 #include "../../../maptools/MarkRendererManager.h" 34 #include "../../../geometry/Point.h" 35 #include "../../../raster/Interpolator.h" 36 #include "../../../raster/Grid.h" 37 #include "../../../raster/Raster.h" 38 #include "../../../rp/Functions.h" 39 #include "../../../se/Fill.h" 40 #include "../../../se/Mark.h" 41 #include "../../../se/Stroke.h" 42 #include "../../../se/Utils.h" 43 #include "../../../srs/Converter.h" 44 #include "../../widgets/canvas/Canvas.h" 45 #include "../../widgets/canvas/MapDisplay.h" 46 #include "../../widgets/srs/SRSManagerDialog.h" 47 #include "../../widgets/Utils.h" 51 #include "ui_RasterNavigatorWidgetForm.h" 52 #include "ui_TiePointLocatorWidgetForm.h" 53 #include "ui_TiePointLocatorParametersWidgetForm.h" 56 #include <QGridLayout> 57 #include <QMessageBox> 59 #include <QFileDialog> 63 #include <boost/filesystem.hpp> 69 #define PATTERN_SIZE 12 74 m_acqType(InvalidAcquisitionT),
99 m_ui(new
Ui::TiePointLocatorWidgetForm),
100 m_tiePointFirstCoord(
None),
101 m_tiePointIdCounter(0)
105 m_ui->m_x1LineEdit->setValidator(
new QDoubleValidator(
this));
106 m_ui->m_y1LineEdit->setValidator(
new QDoubleValidator(
this));
107 m_ui->m_x2LineEdit->setValidator(
new QDoubleValidator(
this));
108 m_ui->m_y2LineEdit->setValidator(
new QDoubleValidator(
this));
110 m_ui->m_outResXLineEdit->setValidator(
new QDoubleValidator(
this));
111 m_ui->m_outResYLineEdit->setValidator(
new QDoubleValidator(
this));
113 m_ui->m_selectAllToolButton->setIcon(QIcon::fromTheme(
"table-select"));
114 m_ui->m_unselectAllToolButton->setIcon(QIcon::fromTheme(
"table-unselect"));
115 m_ui->m_deleteSelectedToolButton->setIcon(QIcon::fromTheme(
"table-delete-select"));
116 m_ui->m_autoAcquireTiePointsToolButton->setIcon(QIcon::fromTheme(
"wand"));
117 m_ui->m_addToolButton->setIcon(QIcon::fromTheme(
"list-add"));
118 m_ui->m_refreshToolButton->setIcon(QIcon::fromTheme(
"view-refresh"));
119 m_ui->m_doneToolButton->setIcon(QIcon::fromTheme(
"check"));
120 m_ui->m_loadTiePointsToolButton_->setIcon(QIcon::fromTheme(
"folder-open"));
121 m_ui->m_saveTiePointsToolButton_->setIcon(QIcon::fromTheme(
"document-save"));
201 te::qt::widgets::TiePointData::TPContainerT::const_iterator itB =
m_tiePoints.begin();
203 const te::qt::widgets::TiePointData::TPContainerT::const_iterator itE =
m_tiePoints.end();
212 tp.first = itB->second.m_tiePoint.second;
213 tp.second = itB->second.m_tiePoint.first;
214 tiePoints.push_back(tp);
220 std::unique_ptr<te::da::DataSet>
ds(
m_refLayer->getData());
222 std::unique_ptr<te::rst::Raster> inputRst =
ds->getRaster(rpos);
226 converter->setSourceSRID(
m_refLayer->getSRID());
227 converter->setTargetSRID(
m_ui->m_outSridLineEdit->text().toInt());
233 tp.first = itB->second.m_tiePoint.second;
235 te::gm::Coord2D c = inputRst->getGrid()->gridToGeo(itB->second.m_tiePoint.first.x, itB->second.m_tiePoint.first.y);
237 converter->convert(c.
x, c.
y, c.
x, c.
y);
241 tiePoints.push_back(tp);
250 std::unique_ptr<te::da::DataSet>
ds(
m_refLayer->getData());
252 std::unique_ptr<te::rst::Raster> inputRst =
ds->getRaster(rpos);
254 te::qt::widgets::TiePointData::TPContainerT::const_iterator itB =
m_tiePoints.begin();
256 const te::qt::widgets::TiePointData::TPContainerT::const_iterator itE =
m_tiePoints.end();
264 tiePoints.push_back(tp);
293 m_ui->m_referenceGroupBox->setMaximumSize(0,0);
294 m_ui->m_autoAcquireTiePointsToolButton->hide();
295 m_ui->m_referenceBandComboBox->hide();
296 m_ui->m_referenceBandLabel->hide();
297 m_ui->m_referenceGroupBox_2->hide();
298 m_ui->m_tiePointsTableWidget->setHorizontalHeaderItem(3,
new QTableWidgetItem(
"X"));
299 m_ui->m_tiePointsTableWidget->setHorizontalHeaderItem(4,
new QTableWidgetItem(
"Y"));
300 m_ui->m_tiePointsTableWidget->setHorizontalHeaderItem(5,
new QTableWidgetItem(tr(
"Column")));
301 m_ui->m_tiePointsTableWidget->setHorizontalHeaderItem(6,
new QTableWidgetItem(tr(
"Line")));
302 m_ui->m_x1Label->setText(
"X");
303 m_ui->m_y1Label->setText(
"Y");
304 m_ui->m_x2Label->setText(tr(
"Column"));
305 m_ui->m_y2Label->setText(tr(
"Line"));
310 m_ui->m_tiePointsTableWidget->setHorizontalHeaderItem(3,
new QTableWidgetItem(
"X1"));
311 m_ui->m_tiePointsTableWidget->setHorizontalHeaderItem(4,
new QTableWidgetItem(
"Y1"));
312 m_ui->m_tiePointsTableWidget->setHorizontalHeaderItem(5,
new QTableWidgetItem(
"X2"));
313 m_ui->m_tiePointsTableWidget->setHorizontalHeaderItem(6,
new QTableWidgetItem(
"Y2"));
314 m_ui->m_x1Label->setText(
"X1");
315 m_ui->m_y1Label->setText(
"Y1");
316 m_ui->m_x2Label->setText(
"X2");
317 m_ui->m_y2Label->setText(
"Y2");
319 m_ui->m_referenceGroupBox->setMaximumSize(16777215, 16777215);
320 m_ui->m_autoAcquireTiePointsToolButton->show();
321 m_ui->m_referenceBandComboBox->show();
322 m_ui->m_referenceBandLabel->show();
323 m_ui->m_referenceGroupBox_2->show();
331 std::unique_ptr<te::da::DataSet>
ds =
m_refLayer->getData();
336 std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
338 m_ui->m_referenceGroupBox->setTitle( tr(
"Reference - ") +
" " +
m_refLayer->getTitle().c_str() );
342 m_ui->m_referenceBandComboBox->clear();
344 for(
unsigned band1Idx = 0; band1Idx < inputRst->getNumberOfBands(); ++band1Idx)
345 m_ui->m_referenceBandComboBox->addItem(QString::number(band1Idx));
350 m_ui->m_referenceSRIDLineEdit->setText(strSRID);
353 strResX.setNum(inputRst->getGrid()->getResolutionX(),
'f');
354 m_ui->m_referenceResXLineEdit->setText(strResX);
357 strResY.setNum(inputRst->getGrid()->getResolutionY(),
'f');
358 m_ui->m_referenceResYLineEdit->setText(strResY);
363 std::unique_ptr<te::da::DataSet> dsAdj =
m_adjLayer->getData();
368 std::unique_ptr<te::rst::Raster> inputRstAdj = dsAdj->getRaster(rpos);
370 if(inputRstAdj.get())
372 double maxSize1 = std::max(inputRst->getNumberOfColumns(), inputRstAdj->getNumberOfColumns());
373 double maxSize2 = std::max(inputRst->getNumberOfRows(), inputRstAdj->getNumberOfRows());
374 double maxSize = std::max(maxSize1, maxSize2);
378 double rescaleFactor = 1000. / maxSize;
396 std::unique_ptr<te::da::DataSet>
ds =
m_adjLayer->getData();
401 std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
403 m_ui->m_adjustGroupBox->setTitle( tr(
"Adjust - ") +
" " +
m_adjLayer->getTitle().c_str() );
407 m_ui->m_adjBandComboBox->clear();
409 for(
unsigned band2Idx = 0; band2Idx < inputRst->getNumberOfBands(); ++band2Idx)
410 m_ui->m_adjBandComboBox->addItem(QString::number(band2Idx));
414 m_ui->m_adjustSRIDLineEdit->setText(strSRID);
415 m_ui->m_outSridLineEdit->setText(strSRID);
418 strResX.setNum(inputRst->getGrid()->getResolutionX(),
'f');
419 m_ui->m_adjustResXLineEdit->setText(strResX);
420 m_ui->m_outResXLineEdit->setText(strResX);
423 strResY.setNum(inputRst->getGrid()->getResolutionY(),
'f');
424 m_ui->m_adjustResYLineEdit->setText(strResY);
425 m_ui->m_outResYLineEdit->setText(strResY);
430 std::unique_ptr<te::da::DataSet> dsRef =
m_refLayer->getData();
435 std::unique_ptr<te::rst::Raster> inputRstRef = dsRef->getRaster(rpos);
437 if(inputRstRef.get())
439 double maxSize1 = std::max(inputRst->getNumberOfColumns(), inputRstRef->getNumberOfColumns());
440 double maxSize2 = std::max(inputRst->getNumberOfRows(), inputRstRef->getNumberOfRows());
441 double maxSize = std::max(maxSize1, maxSize2);
445 double rescaleFactor = 1000. / maxSize;
456 srid =
m_ui->m_outSridLineEdit->text().toInt();
461 resX =
m_ui->m_outResXLineEdit->text().toDouble();
462 resY =
m_ui->m_outResYLineEdit->text().toDouble();
473 ==
"NearestNeighbor" )
493 std::unique_ptr<te::da::DataSet>
ds =
m_refLayer->getData();
498 std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
534 te::qt::widgets::TiePointData::TPContainerT::const_iterator tPIt =
m_tiePoints.begin();
535 const te::qt::widgets::TiePointData::TPContainerT::const_iterator tPItEnd =
m_tiePoints.end();
537 while (tPIt != tPItEnd)
539 transParams.
m_tiePoints.push_back(tPIt->second.m_tiePoint);
547 if (!transfPtr.get())
550 if (!transfPtr->initialize(transParams))
557 transfPtr->directMap(transfPtr->getParameters(),
m_currentTiePoint.first, newpt);
564 std::unique_ptr<te::da::DataSet>
ds =
m_adjLayer->getData();
569 std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
586 std::unique_ptr<te::da::DataSet>
ds =
m_adjLayer->getData();
591 std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
631 te::qt::widgets::TiePointData::TPContainerT::const_iterator tPIt =
m_tiePoints.begin();
632 const te::qt::widgets::TiePointData::TPContainerT::const_iterator tPItEnd =
m_tiePoints.end();
634 while (tPIt != tPItEnd)
636 transParams.
m_tiePoints.push_back(tPIt->second.m_tiePoint);
644 if (!transfPtr.get())
647 if (!transfPtr->initialize(transParams))
653 transfPtr->inverseMap(transfPtr->getParameters(),
m_currentTiePoint.second, newpt);
660 std::unique_ptr<te::da::DataSet>
ds =
m_refLayer->getData();
665 std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
683 std::unique_ptr<te::da::DataSet>
ds =
m_refLayer->getData();
688 std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
694 te::qt::widgets::TiePointData::TPContainerT::iterator tPIt =
m_tiePoints.begin();
695 const te::qt::widgets::TiePointData::TPContainerT::iterator tPItEnd =
m_tiePoints.end();
697 while (tPIt != tPItEnd)
699 if ((
int)(tPIt->second.m_tiePoint.first.x) == (
int)orig.
x &&
700 (
int)(tPIt->second.m_tiePoint.first.y) == (
int)orig.
y)
702 tPIt->second.m_tiePoint.first = inputRst->getGrid()->geoToGrid(xnew, ynew);
717 std::unique_ptr<te::da::DataSet>
ds =
m_adjLayer->getData();
722 std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
727 te::qt::widgets::TiePointData::TPContainerT::iterator tPIt =
m_tiePoints.begin();
728 const te::qt::widgets::TiePointData::TPContainerT::iterator tPItEnd =
m_tiePoints.end();
730 while (tPIt != tPItEnd)
732 if ((
int)(tPIt->second.m_tiePoint.second.x) == (
int)orig.
x &&
733 (
int)(tPIt->second.m_tiePoint.second.y) == (
int)orig.
y)
735 tPIt->second.m_tiePoint.second = inputRst->getGrid()->geoToGrid(xnew, ynew);
747 m_ui->m_tiePointLabel->setPixmap(p);
752 m_ui->m_selectedTiePointLabel->setPixmap(p);
757 m_ui->m_refTiePointLabel->setPixmap(p);
762 m_ui->m_tiePointsTableWidget->clearSelection();
764 QModelIndex idxStart =
m_ui->m_tiePointsTableWidget->model()->index(initialIdx, 0);
765 QModelIndex idxEnd =
m_ui->m_tiePointsTableWidget->model()->index(initialIdx + nPos - 1, 6);
767 if(idxStart.isValid() && idxEnd.isValid())
769 QItemSelection itemSel(idxStart, idxEnd);
771 m_ui->m_tiePointsTableWidget->selectionModel()->select(itemSel, QItemSelectionModel::Select);
778 if(
m_ui->m_outSridLineEdit->text().isEmpty())
780 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Output SRID not defined."));
784 if(
m_ui->m_outResXLineEdit->text().isEmpty() ||
m_ui->m_outResYLineEdit->text().isEmpty())
786 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Output resolution not defined."));
791 (
m_ui->m_adjustResXLineEdit->text().toDouble() <= 0.0 )
793 (
m_ui->m_adjustResYLineEdit->text().toDouble() <= 0.0 )
795 (
m_ui->m_referenceResXLineEdit->text().toDouble() <= 0.0 )
797 (
m_ui->m_referenceResYLineEdit->text().toDouble() <= 0.0 )
799 (
m_ui->m_outResXLineEdit->text().toDouble() <= 0.0 )
801 (
m_ui->m_outResYLineEdit->text().toDouble() <= 0.0 )
804 QMessageBox::warning(
this, tr(
"Warning"),
"Invalid rasters resolution values" );
809 std::unique_ptr<te::da::DataSet> dsRef(
m_refLayer->getData());
811 std::unique_ptr<te::rst::Raster> inputRstRef = dsRef->getRaster(rpos);
813 std::unique_ptr<te::da::DataSet> dsAdj(
m_adjLayer->getData());
815 std::unique_ptr<te::rst::Raster> inputRstAdj = dsAdj->getRaster(rpos);
853 m_ui->m_referenceSRIDLineEdit->text().toInt()
855 m_ui->m_adjustSRIDLineEdit->text().toInt()
859 m_ui->m_referenceSRIDLineEdit->text().toInt() != 0
863 m_ui->m_adjustSRIDLineEdit->text().toInt() != 0
869 adjustRasterEnvelope.
transform(
m_ui->m_adjustSRIDLineEdit->text().toInt(),
870 m_ui->m_referenceSRIDLineEdit->text().toInt() );
872 double adjustResX = adjustRasterEnvelope.getWidth() /
873 inputRstAdj->getNumberOfColumns();
874 double adjustResY = adjustRasterEnvelope.getHeight() /
875 inputRstAdj->getNumberOfRows();
885 /
m_ui->m_adjustResXLineEdit->text().toDouble();
887 /
m_ui->m_adjustResYLineEdit->text().toDouble();
890 if(!(inputRstRef->getExtent()->within(referenceNavigatorCurrentEnvelope) &&
891 inputRstAdj->getExtent()->within(adjustNavigatorCurrentEnvelope)))
899 unsigned int manualTPNumber = 0;
900 te::qt::widgets::TiePointData::TPContainerT::const_iterator itB =
m_tiePoints.begin();
901 const te::qt::widgets::TiePointData::TPContainerT::const_iterator itE =
m_tiePoints.end();
914 QApplication::setOverrideCursor(Qt::WaitCursor);
922 if(algorithmInstance.
execute(outputParams))
924 const unsigned int tpsNmb = (
unsigned int)outputParams.
m_tiePoints.size();
933 for(
unsigned int tpIdx = 0; tpIdx < tpsNmb; ++tpIdx)
941 inputRstRef->getGrid()->gridToGeo(auxTpData.
m_tiePoint.first.x, auxTpData.
m_tiePoint.first.y, x, y);
945 inputRstAdj->getGrid()->gridToGeo(auxTpData.
m_tiePoint.second.x, auxTpData.
m_tiePoint.second.y, x, y);
963 QMessageBox::warning(
this, tr(
"Warning"), tr(
"None tie points was located."));
978 QApplication::restoreOverrideCursor();
980 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Error locating tie points."));
983 QApplication::restoreOverrideCursor();
988 m_ui->m_tiePointsTableWidget->selectAll();
993 m_ui->m_tiePointsTableWidget->clearSelection();
998 const int rowCount =
m_ui->m_tiePointsTableWidget->rowCount();
1000 for(
int row = 0 ; row < rowCount ; ++row )
1002 QTableWidgetItem* itemPtr =
m_ui->m_tiePointsTableWidget->item(row, 0);
1004 if(itemPtr->isSelected())
1006 unsigned int tpID = itemPtr->text().toUInt();
1008 te::qt::widgets::TiePointData::TPContainerT::iterator deletionIt =
m_tiePoints.find(tpID);
1014 std::map<unsigned int, QPointF>::iterator it_pts =
m_adjPoints.find(tpID);
1037 std::unique_ptr<te::da::DataSet> dsadj(
m_adjLayer->getData());
1039 std::unique_ptr<te::rst::Raster> adjRst = dsadj->getRaster(rposadj);
1040 std::unique_ptr<te::rst::Raster> refRst;
1044 std::unique_ptr<te::da::DataSet> dsref(
m_refLayer->getData());
1046 refRst = dsref->getRaster(rposref);
1049 if ((!
m_ui->m_x1LineEdit->text().isEmpty()) && (!
m_ui->m_y1LineEdit->text().isEmpty()) &&
1050 (!
m_ui->m_x2LineEdit->text().isEmpty()) && (!
m_ui->m_y2LineEdit->text().isEmpty()))
1057 else if ((!
m_ui->m_x1LineEdit->text().isEmpty()) && (!
m_ui->m_y1LineEdit->text().isEmpty()) &&
1058 (
m_ui->m_x2LineEdit->text().isEmpty()) && (
m_ui->m_y2LineEdit->text().isEmpty()))
1069 else if ((
m_ui->m_x1LineEdit->text().isEmpty()) && (
m_ui->m_y1LineEdit->text().isEmpty()) &&
1070 (!
m_ui->m_x2LineEdit->text().isEmpty()) && (!
m_ui->m_y2LineEdit->text().isEmpty()))
1099 refRst->getGrid()->gridToGeo(refCoord.
x, refCoord.
y, refGeoCoord.
x, refGeoCoord.
y);
1105 adjRst->getGrid()->gridToGeo(adjCoord.
x, adjCoord.
y, adjGeoCoord.
x, adjGeoCoord.
y);
1111 adjRst->getGrid()->gridToGeo(tpD.
m_tiePoint.second.x, tpD.
m_tiePoint.second.y, adjGeoCoord.
x, adjGeoCoord.
y);
1180 srsDialog.setWindowTitle(tr(
"Choose the SRS"));
1182 if(srsDialog.exec() == QDialog::Accepted)
1187 strSRID.setNum(srid.first);
1188 m_ui->m_outSridLineEdit->setText(strSRID);
1194 QString tiePointsFileName = QFileDialog::getOpenFileName(
this, tr(
"Select the input file name"),
1196 tr(
"Tie-points file (*.tps)"), 0 ,QFileDialog::ReadOnly);
1198 if( !tiePointsFileName.isEmpty() )
1200 boost::filesystem::path fullFilePath( tiePointsFileName.toUtf8().data() );
1202 "tie_points_file_directory");
1204 std::ifstream tiePointsFile;
1205 tiePointsFile.open( tiePointsFileName.toUtf8().data(), std::ofstream::in );
1206 if( !tiePointsFile.good() )
1208 QMessageBox::critical(
this, tr(
"Warning"), tr(
"Tie points file open error"));
1212 std::string lineStr;
1213 std::vector< std::string > tokens;
1218 while( !tiePointsFile.eof() )
1220 std::getline( tiePointsFile, lineStr );
1222 if( lineStr.find(
"REFSRID", 0 ) == 0 )
1226 refSRID = boost::lexical_cast<
int >( tokens[ 1 ] );
1228 else if( lineStr.find(
"ADJSRID", 0 ) == 0 )
1232 adjSRID = boost::lexical_cast<
int >( tokens[ 1 ] );
1234 else if( lineStr.find(
"TPID", 0 ) == 0 )
1242 unsigned int tpID =
static_cast<unsigned int>(
m_tiePoints.size());
1248 QMessageBox::critical(
this, tr(
"Warning"), tr(
"Invalid tie-points file (invalid reference raster SRID)"));
1253 std::unique_ptr< te::rst::Raster > refRasterPtr =
m_refLayer->getData()->getRaster(0);
1254 std::unique_ptr< te::rst::Raster > adjRasterPtr =
m_adjLayer->getData()->getRaster(0);
1257 if (adjSRID && adjRasterPtr->getSRID())
1260 adjConverter.setTargetSRID(adjRasterPtr->getSRID());
1263 while( !tiePointsFile.eof() )
1265 std::getline( tiePointsFile, lineStr );
1267 if( lineStr.size() )
1272 if( tokens.size() > 9 )
1274 if( tokens[ 1 ] ==
"auto" )
1283 point.
x = boost::lexical_cast<
double >( tokens[ 4 ] );
1284 point.
y = boost::lexical_cast<
double >( tokens[ 5 ] );
1285 refConverter.convert( point.
x, point.
y, reprojectedPoint.
x, reprojectedPoint.
y );
1286 refRasterPtr->getGrid()->geoToGrid( reprojectedPoint.
x, reprojectedPoint.
y,
1291 point.
x = boost::lexical_cast<
double >( tokens[ 8 ] );
1292 point.
y = boost::lexical_cast<
double >( tokens[ 9 ] );
1293 if (adjSRID && adjRasterPtr->getSRID())
1295 adjConverter.convert( point.
x, point.
y, reprojectedPoint.
x, reprojectedPoint.
y );
1298 reprojectedPoint = point;
1300 adjRasterPtr->getGrid()->geoToGrid( reprojectedPoint.
x, reprojectedPoint.
y,
1305 auxTpData.
m_tiePoint.second.x = boost::lexical_cast<
double >( tokens[ 6 ] );
1306 auxTpData.
m_tiePoint.second.y = boost::lexical_cast<
double >( tokens[ 7 ] );
1317 refRasterPtr->getGrid()->gridToGeo(auxTpData.
m_tiePoint.first.x, auxTpData.
m_tiePoint.first.y, x, y);
1320 adjRasterPtr->getGrid()->gridToGeo(auxTpData.
m_tiePoint.second.x, auxTpData.
m_tiePoint.second.y, x, y);
1329 std::unique_ptr< te::rst::Raster > adjRasterPtr =
m_adjLayer->getData()->getRaster(0);
1330 while (!tiePointsFile.eof())
1332 std::getline(tiePointsFile, lineStr);
1339 if (tokens.size() > 9)
1341 QMessageBox::critical(
this, tr(
"Warning"), tr(
"Invalid tie-points file (reference raster is necessary)"));
1344 else if (tokens.size() > 5)
1346 if (tokens[1] ==
"auto")
1355 auxTpData.
m_tiePoint.first.x = boost::lexical_cast<
double>(tokens[2]);
1356 auxTpData.
m_tiePoint.first.y = boost::lexical_cast<
double>(tokens[3]);
1357 auxTpData.
m_tiePoint.second.x = boost::lexical_cast<
double>(tokens[4]);
1358 auxTpData.
m_tiePoint.second.y = boost::lexical_cast<
double>(tokens[5]);
1368 adjRasterPtr->getGrid()->gridToGeo(auxTpData.
m_tiePoint.second.x, auxTpData.
m_tiePoint.second.y, x, y);
1383 QString tiePointsFileName = QFileDialog::getSaveFileName(
this, tr(
"Select the output file name"),
1385 tr(
"Tie-points file (*.tps)"), 0, 0);
1387 if( !tiePointsFileName.isEmpty() )
1389 boost::filesystem::path fullFilePath( tiePointsFileName.toUtf8().data() );
1391 "tie_points_file_directory");
1393 std::ofstream tiePointsFile;
1394 tiePointsFile.open( tiePointsFileName.toUtf8().data(), std::ofstream::out |
1395 std::ofstream::trunc );
1397 if( !tiePointsFile.good() )
1399 QMessageBox::critical(
this, tr(
"Warning"), tr(
"Tie points file creation error"));
1402 tiePointsFile.precision( 40 );
1406 std::unique_ptr< te::rst::Raster > refRasterPtr =
m_refLayer->getData()->getRaster(0);
1407 std::unique_ptr< te::rst::Raster > adjRasterPtr =
m_adjLayer->getData()->getRaster(0);
1409 tiePointsFile <<
"REFSRID " << refRasterPtr->getSRID();
1410 tiePointsFile << std::endl <<
"REFDSNAME " <<
m_refLayer->getDataSetName();
1411 tiePointsFile << std::endl <<
"ADJSRID " << adjRasterPtr->getSRID();
1412 tiePointsFile << std::endl <<
"ADJDSNAME " <<
m_adjLayer->getDataSetName();
1413 tiePointsFile << std::endl <<
"TPID;ACKTYPE;REFCOL;REFROW;REFX;REFY;ADJCOL;AJDROW;ADJX;ADJY";
1418 TiePointData::TPContainerT::const_iterator tpIt =
m_tiePoints.begin();
1419 TiePointData::TPContainerT::const_iterator tpItEnd =
m_tiePoints.end();
1422 while( tpIt != tpItEnd )
1424 tiePointsFile << std::endl << tpIt->first;
1428 tiePointsFile <<
";manual";
1432 tiePointsFile <<
";auto";
1435 auxCood = refGrid.
gridToGeo( tpIt->second.m_tiePoint.first.x,
1436 tpIt->second.m_tiePoint.first.y );
1438 <<
";" << tpIt->second.m_tiePoint.first.x
1439 <<
";" << tpIt->second.m_tiePoint.first.y
1444 auxCood = adjGrid.
gridToGeo( tpIt->second.m_tiePoint.second.x,
1445 tpIt->second.m_tiePoint.second.y );
1447 <<
";" << tpIt->second.m_tiePoint.second.x
1448 <<
";" << tpIt->second.m_tiePoint.second.y
1458 std::unique_ptr< te::rst::Raster > adjRasterPtr =
m_adjLayer->getData()->getRaster(0);
1460 tiePointsFile << std::endl <<
"ADJSRID " << adjRasterPtr->getSRID();
1461 tiePointsFile << std::endl <<
"ADJDSNAME " <<
m_adjLayer->getDataSetName();
1462 tiePointsFile << std::endl <<
"TPID;ACKTYPE;ADJX;ADJY;ADJCOL;AJDROW";
1464 TiePointData::TPContainerT::const_iterator tpIt =
m_tiePoints.begin();
1465 TiePointData::TPContainerT::const_iterator tpItEnd =
m_tiePoints.end();
1467 while (tpIt != tpItEnd)
1469 tiePointsFile << std::endl << tpIt->first;
1471 tiePointsFile <<
";manual";
1474 <<
";" << tpIt->second.m_tiePoint.first.x
1475 <<
";" << tpIt->second.m_tiePoint.first.y
1476 <<
";" << tpIt->second.m_tiePoint.second.x
1477 <<
";" << tpIt->second.m_tiePoint.second.y
1491 te::qt::widgets::TiePointData::TPContainerT::const_iterator tPIt =
m_tiePoints.begin();
1492 const te::qt::widgets::TiePointData::TPContainerT::const_iterator tPItEnd =
m_tiePoints.end();
1494 while( tPIt != tPItEnd )
1496 transParams.
m_tiePoints.push_back(tPIt->second.m_tiePoint);
1506 if(!transfPtr->initialize(transParams))
1511 m_ui->m_tiePointsTableWidget->blockSignals(
true );
1512 m_ui->m_tiePointsTableWidget->setSortingEnabled(
false );
1514 m_ui->m_tiePointsTableWidget->setRowCount(0);
1516 double currTPError = 0;
1520 while( tPIt != tPItEnd )
1522 int newrow =
m_ui->m_tiePointsTableWidget->rowCount();
1523 m_ui->m_tiePointsTableWidget->insertRow(newrow);
1526 currTPError = transfPtr.get() ? transfPtr->getInverseMappingError(currTP) : 0.0;
1529 QTableWidgetItem* itemId =
new QTableWidgetItem(QString::number(tPIt->first));
1530 itemId->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1531 m_ui->m_tiePointsTableWidget->setItem(newrow, 0, itemId);
1534 QTableWidgetItem* itemError =
new QTableWidgetItem(QString::number(currTPError));
1535 itemError->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1536 m_ui->m_tiePointsTableWidget->setItem(newrow, 1, itemError);
1542 type = tr(
"Manual");
1546 type = tr(
"Automatic");
1549 QTableWidgetItem* itemType =
new QTableWidgetItem(type);
1550 itemType->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1551 m_ui->m_tiePointsTableWidget->setItem(newrow, 2, itemType);
1556 QTableWidgetItem* itemRefX =
new QTableWidgetItem(QString::number((
int)currTP.first.x));
1557 itemRefX->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
1558 m_ui->m_tiePointsTableWidget->setItem(newrow, 3, itemRefX);
1561 QTableWidgetItem* itemRefY =
new QTableWidgetItem(QString::number((
int)currTP.first.y));
1562 itemRefY->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
1563 m_ui->m_tiePointsTableWidget->setItem(newrow, 4, itemRefY);
1568 QTableWidgetItem* itemRefX =
new QTableWidgetItem(QString::number(currTP.first.x));
1569 itemRefX->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
1570 m_ui->m_tiePointsTableWidget->setItem(newrow, 3, itemRefX);
1573 QTableWidgetItem* itemRefY =
new QTableWidgetItem(QString::number(currTP.first.y));
1574 itemRefY->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
1575 m_ui->m_tiePointsTableWidget->setItem(newrow, 4, itemRefY);
1579 QTableWidgetItem* itemAdjX =
new QTableWidgetItem(QString::number((
int)currTP.second.x));
1580 itemAdjX->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
1581 m_ui->m_tiePointsTableWidget->setItem(newrow, 5, itemAdjX);
1584 QTableWidgetItem* itemAdjY =
new QTableWidgetItem(QString::number((
int)currTP.second.y));
1585 itemAdjY->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
1586 m_ui->m_tiePointsTableWidget->setItem(newrow, 6, itemAdjY);
1593 m_ui->m_tiePointsTableWidget->selectRow(newrow);
1599 m_ui->m_tiePointsTableWidget->setSortingEnabled(
true);
1600 m_ui->m_tiePointsTableWidget->blockSignals(
false );
1601 m_ui->m_tiePointsTableWidget->resizeColumnsToContents();
1615 const int rowCount =
m_ui->m_tiePointsTableWidget->rowCount();
1617 for(
int row = 0; row < rowCount; ++row)
1619 QTableWidgetItem* itemPtr =
m_ui->m_tiePointsTableWidget->item(row, 0);
1621 int id = itemPtr->text().toUInt();
1623 te::qt::widgets::TiePointData::TPContainerT::iterator it =
m_tiePoints.find(
id);
1629 if( itemPtr->isSelected() )
1631 it->second.m_selected =
true;
1633 transParamsSelectedTP.
m_tiePoints.push_back(tiePoint);
1639 it->second.m_selected =
false;
1641 transParamsUnselectedTP.
m_tiePoints.push_back(tiePoint);
1651 if(transfAllTPPtr.get())
1652 if(!transfAllTPPtr->initialize(transParamsAllTP))
1653 transfAllTPPtr.reset();
1656 if(transfSelectedTPPtr.get())
1657 if(!transfSelectedTPPtr->initialize(transParamsSelectedTP))
1658 transfSelectedTPPtr.reset();
1660 std::unique_ptr<te::gm::GeometricTransformation> transfUnselectedTPPtr(
te::gm::GTFactory::make(geoTransfName));
1661 if(transfUnselectedTPPtr.get())
1662 if(!transfUnselectedTPPtr->initialize(transParamsUnselectedTP))
1663 transfUnselectedTPPtr.reset();
1666 m_ui->m_tiePointsNumberLineEdit->setText(QString::number(
m_tiePoints.size()));
1668 if(transfAllTPPtr.get())
1669 m_ui->m_transformationRMSEAllLineEdit->setText(QString::number(transfAllTPPtr->getInverseMapRMSE()));
1671 m_ui->m_transformationRMSEAllLineEdit->setText(
"N/A");
1673 if(transfSelectedTPPtr.get())
1674 m_ui->m_transformationRMSESelectedLineEdit->setText(QString::number(transfSelectedTPPtr->getInverseMapRMSE()));
1676 m_ui->m_transformationRMSESelectedLineEdit->setText(
"N/A");
1678 if(transfUnselectedTPPtr.get())
1679 m_ui->m_transformationRMSEunselectedLineEdit->setText(QString::number(transfUnselectedTPPtr->getInverseMapRMSE()));
1681 m_ui->m_transformationRMSEunselectedLineEdit->setText(
"N/A");
1690 QGridLayout* layoutRef =
new QGridLayout(
m_ui->m_refWidget);
1701 layoutRef->setContentsMargins(0,0,0,0);
1708 QGridLayout* layoutAdj =
new QGridLayout(
m_ui->m_adjWidget);
1719 layoutAdj->setContentsMargins(0,0,0,0);
1730 std::unique_ptr<te::qt::widgets::Canvas> refCanvasInstance;
1731 std::unique_ptr<te::rst::Raster> rstRef;
1739 refCanvasInstance->setWindow(refMapExt.
m_llx, refMapExt.
m_lly, refMapExt.
m_urx, refMapExt.
m_ury);
1741 std::unique_ptr<te::da::DataSet> dsRef =
m_refLayer->getData();
1745 rstRef.reset(dsRef->getRaster(rpos).release());
1749 refCanvasInstance->setTextContourEnabled(
true);
1750 refCanvasInstance->setTextContourWidth(2);
1762 std::unique_ptr<te::da::DataSet> dsAdj =
m_adjLayer->getData();
1766 std::unique_ptr<te::rst::Raster> rstAdj = dsAdj->getRaster(rpos);
1773 te::qt::widgets::TiePointData::TPContainerT::const_iterator it = tpc.begin();
1775 adjCanvasInstance.setTextContourEnabled(
true );
1776 adjCanvasInstance.setTextContourWidth( 2 );
1779 while(it != tpc.end())
1785 if (refCanvasInstance.get())
1792 if (refCanvasInstance.get())
1803 if (refCanvasInstance.get())
1818 rstRef->getGrid()->gridToGeo(refCoord.
x, refCoord.
y, refGeoCoord.
x, refGeoCoord.
y );
1821 refCanvasInstance->draw(&refPoint);
1824 QMatrix matrix = refCanvasInstance->getMatrix();
1825 QPointF pointCanvas = matrix.map(QPointF(refGeoCoord.
x, refGeoCoord.
y ) );
1826 pointCanvas.setY(pointCanvas.y() + 15);
1827 QPointF pointGeo = matrix.inverted().map(pointCanvas);
1828 refPoint.
setX(pointGeo.x());
1829 refPoint.
setY(pointGeo.y());
1830 refCanvasInstance->drawText(&refPoint, QString::number(
id).toUtf8().data());
1836 rstAdj->getGrid()->gridToGeo(adjCoord.
x, adjCoord.
y, adjGeoCoord.
x, adjGeoCoord.
y );
1839 adjCanvasInstance.draw(&adjPoint);
1842 QMatrix matrix = adjCanvasInstance.getMatrix();
1843 QPointF pointCanvas = matrix.map(QPointF(adjGeoCoord.
x, adjGeoCoord.
y) );
1844 pointCanvas.setY(pointCanvas.y() + 15);
1845 QPointF pointGeo = matrix.inverted().map(pointCanvas);
1846 adjPoint.
setX(pointGeo.x());
1847 adjPoint.
setY(pointGeo.y());
1848 adjCanvasInstance.drawText(&adjPoint, QString::number(
id).toUtf8().data());
1862 rstRef->getGrid()->gridToGeo(firstCoord.
x, firstCoord.
y, geoCoord.
x, geoCoord.
y );
1865 refCanvasInstance->draw(&refPoint);
1868 refDisplay->repaint();
1876 rstAdj->getGrid()->gridToGeo(firstCoord.
x, firstCoord.
y, geoCoord.
x, geoCoord.
y);
1879 adjCanvasInstance.draw(&geoPoint);
1881 adjDisplay->repaint();
1887 QPixmap
p = QPixmap::fromImage(*img);
1896 int row = item->row();
1897 QTableWidgetItem* itemPtr =
m_ui->m_tiePointsTableWidget->item(row, 0);
1898 unsigned int tpID = itemPtr->text().toUInt();
1899 te::qt::widgets::TiePointData::TPContainerT::iterator editIt =
m_tiePoints.find(tpID);
1902 int col = item->column();
1907 (*editIt).second.m_tiePoint.first.x = item->text().toDouble(&ok);
1910 (*editIt).second.m_tiePoint.first.y = item->text().toDouble(&ok);
1913 (*editIt).second.m_tiePoint.second.x = item->text().toDouble(&ok);
1916 (*editIt).second.m_tiePoint.second.y = item->text().toDouble(&ok);
1922 QMessageBox::critical(
this, tr(
"Warning"), tr(
"Invalid Value"));
1924 std::unique_ptr<te::da::DataSet> dsadj(
m_adjLayer->getData());
1926 std::unique_ptr<te::rst::Raster> adjRst = dsadj->getRaster(rposadj);
1930 std::unique_ptr<te::da::DataSet> dsref(
m_refLayer->getData());
1932 std::unique_ptr<te::rst::Raster> refRst = dsref->getRaster(rposref);
1936 refRst->getGrid()->gridToGeo(refCoord.
x, refCoord.
y, refGeoCoord.
x, refGeoCoord.
y);
1942 adjRst->getGrid()->gridToGeo(adjCoord.
x, adjCoord.
y, adjGeoCoord.
x, adjGeoCoord.
y);
1948 adjRst->getGrid()->gridToGeo((*editIt).second.m_tiePoint.second.x, (*editIt).second.m_tiePoint.second.y, adjGeoCoord.
x, adjGeoCoord.
y);
1952 catch (
const std::exception&)
1954 QMessageBox::critical(
this, tr(
"Warning"), tr(
"Invalid Value"));
Near neighborhood interpolation method.
std::vector< te::gm::GTParameters::TiePoint > m_tiePoints
The generated tie-points (te::gm::GTParameters::TiePoint::first are raster 1 line/column indexes...
std::vector< TiePoint > m_tiePoints
Tie points.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
double m_urx
Upper right corner x-coordinate.
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
An utility struct for representing 2D coordinates.
double getY() const
It returns the y-coordinate.
static te::dt::Date ds(2010, 01, 01)
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
InterpolationMethod
Allowed interpolation methods.
static const std::string getLastLogStr()
Returns the last log string generated by this module.
std::pair< Coord2D, Coord2D > TiePoint
Tie point type definition.
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
void setSourceSRID(int sourceSRID)
Sets the source SRS identifier.
Coord2D getCenter() const
It returns the rectangle's center coordinate.
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
double m_llx
Lower left corner x-coordinate.
static MarkRendererManager & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
An Envelope defines a 2D rectangular region.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
A Fill specifies the pattern for filling an area geometry.
Grid * getGrid()
It returns the raster grid.
TESEEXPORT Mark * CreateMark(const std::string &wellKnownName, Stroke *stroke, Fill *fill)
Creates a mark.
static GeometricTransformation * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
TiePointsLocator output parameters.
double m_lly
Lower left corner y-coordinate.
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
TESEEXPORT Stroke * CreateStroke(const std::string &color, const std::string &width)
Creates a stroke.
Bicubic interpolation method.
double getX() const
It returns the x-coordinate.
void setX(const double &x)
It sets the Point x-coordinate value.
double m_ury
Upper right corner y-coordinate.
A Stroke specifies the appearance of a linear geometry.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
Bilinear interpolation method.
2D Geometric transformation parameters.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
void setY(const double &y)
It sets the Point y-coordinate value.
A rectified grid is the spatial support for raster data.
#define TE_TRANSPARENT
For an RGBA color this is the value of the alpha-channel for totally transparent. ...
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
TESEEXPORT Fill * CreateFill(const std::string &color, const std::string &opacity)
Creates a fill.