27 #include "../../common/Logger.h" 
   28 #include "../../common/progress/ProgressManager.h" 
   29 #include "../../common/Translator.h" 
   30 #include "../../common/STLUtils.h" 
   31 #include "../../dataaccess/datasource/DataSource.h" 
   32 #include "../../dataaccess/utils/Utils.h" 
   33 #include "../../geometry/GeometryProperty.h" 
   34 #include "../../maptools/DataSetLayer.h" 
   35 #include "../../qt/widgets/datasource/selector/DataSourceSelectorDialog.h" 
   36 #include "../../qt/widgets/progress/ProgressViewerDialog.h" 
   37 #include "../core/SamplePointsGeneratorRandom.h" 
   38 #include "../core/SamplePointsGeneratorStratified.h" 
   40 #include "../Exception.h" 
   43 #include "ui_SamplePointsGeneratorDialogForm.h" 
   46 #include <QFileDialog> 
   48 #include <QMessageBox> 
   55 #include <boost/filesystem.hpp> 
   61     m_ui(new Ui::SamplePointsGeneratorDialogForm)
 
   68   m_ui->m_nPointsRandomLineEdit->setValidator(
new QIntValidator(
this));
 
   69   m_ui->m_nPointsStratifiedLineEdit->setValidator(
new QIntValidator(
this));
 
   72   m_ui->m_imgLabel->setPixmap(QIcon::fromTheme(
"sa-samplepoint-hint").pixmap(112,48));
 
   73   m_ui->m_targetDatasourceToolButton->setIcon(QIcon::fromTheme(
"datasource"));
 
   83   m_ui->m_helpPushButton->setNameSpace(
"dpi.inpe.br.plugins"); 
 
   84   m_ui->m_helpPushButton->setPageReference(
"plugins/sa/sa_samplepointsgenerator.html");
 
   93   std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin();
 
   95   while(it != layers.end())
 
  101       std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
 
  103       if(dsType->hasGeom())
 
  104         m_ui->m_inputLayerComboBox->addItem(it->get()->getTitle().c_str(), QVariant::fromValue(l));
 
  111   if(m_ui->m_inputLayerComboBox->count() > 0)
 
  112     onInputLayerComboBoxActivated(0);
 
  117   return m_outputLayer;
 
  122   QVariant varLayer = m_ui->m_inputLayerComboBox->itemData(index, Qt::UserRole);
 
  126   std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
 
  128   std::vector<te::dt::Property*> propVec = dsType->getProperties();
 
  130   m_ui->m_attrStratifiedComboBox->clear();
 
  132   for(std::size_t t = 0; t < propVec.size(); ++t)
 
  134     int dataType = propVec[t]->getType();
 
  137       m_ui->m_attrStratifiedComboBox->addItem(propVec[t]->getName().c_str(), dataType);
 
  144   if(m_ui->m_repositoryLineEdit->text().isEmpty())
 
  146     QMessageBox::information(
this, tr(
"Warning"), tr(
"Define a repository for the result."));
 
  150   if(m_ui->m_newLayerNameLineEdit->text().isEmpty())
 
  152     QMessageBox::information(
this, tr(
"Warning"), tr(
"Define a name for the resulting layer."));
 
  161     if(m_ui->m_nPointsRandomLineEdit->text().isEmpty())
 
  163       QMessageBox::information(
this, tr(
"Warning"), tr(
"Number of points not defined."));
 
  169     if(m_ui->m_nPointsStratifiedLineEdit->text().isEmpty())
 
  171       QMessageBox::information(
this, tr(
"Warning"), tr(
"Number of points not defined."));
 
  177   QVariant varLayer = m_ui->m_inputLayerComboBox->itemData(m_ui->m_inputLayerComboBox->currentIndex(), Qt::UserRole);
 
  180   std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
 
  205   std::string dataSetName = m_ui->m_newLayerNameLineEdit->text().toStdString();
 
  207   std::size_t idx = dataSetName.find(
".");
 
  208   if (idx != std::string::npos)
 
  209         dataSetName=dataSetName.substr(0,idx);
 
  211   std::vector<std::string> classNames;
 
  217   QApplication::setOverrideCursor(Qt::WaitCursor);
 
  261   catch(
const std::exception& e)
 
  263     QMessageBox::warning(
this, tr(
"Warning"), e.what());
 
  265     QApplication::restoreOverrideCursor();
 
  273     QMessageBox::warning(
this, tr(
"Warning"), tr(
"Internal Error.Sample Points not generated."));
 
  275     QApplication::restoreOverrideCursor();
 
  282   QApplication::restoreOverrideCursor();
 
  299   m_ui->m_newLayerNameLineEdit->clear();
 
  300   m_ui->m_newLayerNameLineEdit->setEnabled(
true);
 
  305   std::list<te::da::DataSourceInfoPtr> dsPtrList = dlg.
getSelecteds();
 
  307   if(dsPtrList.size() <= 0)
 
  310   std::list<te::da::DataSourceInfoPtr>::iterator it = dsPtrList.begin();
 
  312   m_ui->m_repositoryLineEdit->setText(QString(it->get()->getTitle().c_str()));
 
  314   m_outputDatasource = *it;
 
  321   m_ui->m_newLayerNameLineEdit->clear();
 
  322   m_ui->m_repositoryLineEdit->clear();
 
  324   QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save as..."), QString(), tr(
"Shapefile (*.shp *.SHP);;"),0, QFileDialog::DontConfirmOverwrite);
 
  326   if (fileName.isEmpty())
 
  329   boost::filesystem::path outfile(fileName.toStdString());
 
  331   m_ui->m_repositoryLineEdit->setText(outfile.string().c_str());
 
  333   m_ui->m_newLayerNameLineEdit->setText(outfile.leaf().string().c_str());
 
  335   m_ui->m_newLayerNameLineEdit->setEnabled(
false);
 
  342   m_ui->m_generatorTypeComboBox->clear();
 
  344   m_ui->m_generatorTypeComboBox->addItem(
"Random", QVariant(
te::sa::Random));
 
SamplePointsGeneratorDialog(QWidget *parent=0, Qt::WindowFlags f=0)
 
void onTargetDatasourceToolButtonPressed()
 
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager. 
 
Utility functions for the data access module. 
 
void setEnvelope(te::gm::Envelope env)
 
boost::shared_ptr< DataSource > DataSourcePtr
 
TESAEXPORT te::da::DataSourcePtr CreateOGRDataSource(std::string repository)
 
void onTargetFileToolButtonPressed()
 
TESAEXPORT void CreateSampleGeneratorStratifiedGrouping(te::map::AbstractLayerPtr layer, std::vector< std::string > strVec)
 
void setOutputDataSource(te::da::DataSourcePtr ds)
 
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
Set the layer that can be used. 
 
Class to generate samples points using stratified strategy. 
 
void onOkPushButtonClicked()
 
void fillGeneratorTypes()
 
std::auto_ptr< Ui::SamplePointsGeneratorDialogForm > m_ui
 
int getSRID() const 
It returns the spatial reference system identifier associated to this property. 
 
void removeViewer(int viewerId)
Dettach a progress viewer. 
 
static ProgressManager & getInstance()
It returns a reference to the singleton instance. 
 
An Envelope defines a 2D rectangular region. 
 
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
 
void onInputLayerComboBoxActivated(int index)
 
Virtual class to generate samples points. 
 
void execute()
Function to execute the kernel operation. 
 
void setOutputDataSetName(std::string dataSetName)
 
int addViewer(AbstractProgressViewer *apv)
Attach a progress viewer. 
 
Class to generate samples points using random strategy. 
 
~SamplePointsGeneratorDialog()
 
TESAEXPORT te::map::AbstractLayerPtr CreateLayer(te::da::DataSourcePtr ds, std::string dataSetName)
 
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
 
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
 
A dialog to generate sample points inside an area of a dataset. 
 
SamplePointsGeneratorType
Generator types used to create sample of points. 
 
te::map::AbstractLayerPtr getOutputLayer()