28 #include "../../common/Logger.h" 
   29 #include "../../common/progress/ProgressManager.h" 
   30 #include "../../dataaccess/dataset/DataSet.h" 
   31 #include "../../dataaccess/dataset/DataSetType.h" 
   32 #include "../../dataaccess/datasource/DataSourceCapabilities.h" 
   33 #include "../../dataaccess/datasource/DataSourceInfo.h" 
   34 #include "../../dataaccess/datasource/DataSourceInfoManager.h" 
   35 #include "../../dataaccess/datasource/DataSourceFactory.h" 
   36 #include "../../dataaccess/datasource/DataSourceManager.h" 
   37 #include "../../dataaccess/utils/Utils.h" 
   39 #include "../../maptools/AbstractLayer.h" 
   41 #include "../../qt/widgets/help/HelpPushButton.h" 
   42 #include "../../qt/widgets/progress/ProgressViewerDialog.h" 
   43 #include "../../qt/widgets/layer/search/LayerSearchWidget.h" 
   44 #include "../../qt/widgets/layer/search/LayerSearchWizardPage.h" 
   45 #include "../../qt/widgets/layer/utils/DataSet2Layer.h" 
   47 #include "../Config.h" 
   48 #include "../Exception.h" 
   53 #include "../GeometricOp.h" 
   54 #include "../GeometricOpMemory.h" 
   55 #include "../GeometricOpQuery.h" 
   62 #include <QMessageBox> 
   65 #include <boost/filesystem.hpp> 
   66 #include <boost/uuid/random_generator.hpp> 
   67 #include <boost/uuid/uuid_io.hpp> 
   73   this->setWizardStyle(QWizard::ModernStyle);
 
   74   this->setWindowTitle(tr(
"Geometric Operation"));
 
   76   this->setOption(QWizard::HaveHelpButton, 
true);
 
   77   this->setOption(QWizard::HelpButtonOnRight, 
false);
 
   81   this->setButton(QWizard::HelpButton, helpButton);
 
   95   if(currentPage() ==  m_layerSearchPage.get())
 
   97     std::list<te::map::AbstractLayerPtr> list = m_layerSearchPage->getSearchWidget()->getSelecteds();
 
   99     if(list.empty() == 
false)
 
  102       m_geomOpPage->setLayer(l);
 
  105       std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
 
  106       std::vector<te::dt::Property*> vecProp = dsType->getProperties();
 
  107       std::vector<std::string> vecPropName;
 
  109       for(std::size_t i = 0; i < vecProp.size(); ++i)
 
  112           vecPropName.push_back(vecProp[i]->getName());
 
  115       m_geomOpOutputPage->setAttributes(vecPropName);
 
  118     return m_layerSearchPage->isComplete();
 
  120   else if(currentPage() ==  m_geomOpOutputPage.get())
 
  122     if(!m_geomOpOutputPage->getToFile())
 
  124       if(!m_geomOpOutputPage->getDsInfoPtr())
 
  126         QMessageBox::information(
this, 
 
  127                                 "Basic Geographic Operation", 
 
  128                                 "Set the output data source before execute the operation.");
 
  131       if(m_geomOpOutputPage->getOutDsName() == 
"")
 
  133         QMessageBox::information(
this, 
 
  134                                 "Basic Geographic Operation", 
 
  135                                 "Set a Name for the output dataset before execute the operation.");
 
  148   m_layerSearchPage->getSearchWidget()->setList(layerList);
 
  149   m_layerSearchPage->getSearchWidget()->filterOnlyByGeom();
 
  154   removePage(m_layerSearchId);
 
  155   m_geomOpPage->setLayer(layer);
 
  174   m_layerSearchId = addPage(m_layerSearchPage.get());
 
  175   addPage(m_geomOpPage.get());
 
  176   addPage(m_geomOpOutputPage.get());
 
  179   m_layerSearchPage->getSearchWidget()->enableMultiSelection(
false);
 
  198     if(m_geomOpOutputPage->hasConvexHull())
 
  201     if(m_geomOpOutputPage->hasCentroid())
 
  204     if(m_geomOpOutputPage->hasMBR())
 
  207     if(m_geomOpOutputPage->hasArea())
 
  210     if(m_geomOpOutputPage->hasLine())
 
  213     if(m_geomOpOutputPage->hasPerimeter())
 
  217     std::vector<std::string> geoProps = m_geomOpPage->getSelectedProps();
 
  219     std::string outputdataset = m_geomOpOutputPage->getOutDsName();
 
  220     std::vector<std::string> outputDSetNames;
 
  223     m_attribute = m_geomOpOutputPage->getAttribute();
 
  226     if(m_geomOpOutputPage->getToFile())
 
  228       boost::filesystem::path uri(m_geomOpOutputPage->getPath());
 
  230       bool ops_selected = 
false;
 
  232       if(m_geomOpOutputPage->hasConvexHull())
 
  234         boost::filesystem::path uri_file(m_geomOpOutputPage->getPath() + 
"/" + outputdataset + 
"_convex_hull.shp");
 
  235         if (boost::filesystem::exists(uri_file))
 
  237           QMessageBox::information(
this, 
"Geographic Operation", 
"The convex hull output file already exists. Remove it or select a new name and try again.");
 
  243       if(m_geomOpOutputPage->hasCentroid())
 
  245         boost::filesystem::path uri_file(m_geomOpOutputPage->getPath() + 
"/" + outputdataset + 
"_centroid.shp");
 
  246         if (boost::filesystem::exists(uri_file))
 
  248           QMessageBox::information(
this, 
"Geographic Operation", 
"The centroid output file already exists. Remove it or select a new name and try again.");
 
  254       if(m_geomOpOutputPage->hasMBR())
 
  256         boost::filesystem::path uri_file(m_geomOpOutputPage->getPath() + 
"/" + outputdataset + 
"_mbr.shp");
 
  257         if (boost::filesystem::exists(uri_file))
 
  259           QMessageBox::information(
this, 
"Geographic Operation", 
"The mbr output file already exists. Remove it or select a new name and try again.");
 
  267         boost::filesystem::path uri_file(m_geomOpOutputPage->getPath() + 
"/" + outputdataset + 
".shp");
 
  268         if (boost::filesystem::exists(uri_file))
 
  270           QMessageBox::information(
this, 
"Geographic Operation", 
"Output file already exists. Remove it or select a new name and try again.");
 
  275       std::size_t idx = outputdataset.find(
".");
 
  277       if (idx != std::string::npos)
 
  278         outputdataset=outputdataset.substr(0,idx);
 
  280       std::map<std::string, std::string> dsinfo;
 
  281       dsinfo[
"URI"] = uri.string();
 
  282       dsinfo[
"DRIVER"] = 
"ESRI Shapefile";
 
  285       dsOGR->setConnectionInfo(dsinfo);
 
  287       if (dsOGR->dataSetExists(outputdataset))
 
  289         QMessageBox::information(
this, 
"Basic Geographic Operation", 
"There is already a dataset with the requested name in the output data source. Remove it or select a new name and try again.");
 
  293       this->setCursor(Qt::WaitCursor);
 
  314                         m_geomOpOutputPage->getObjectStrategy(), 
 
  316                         m_geomOpOutputPage->hasOutputLayer());
 
  321         result = geomOp->
run();
 
  325         this->setCursor(Qt::ArrowCursor);
 
  326         QMessageBox::information(
this, 
"Geometric Operation", 
"Error: could not generate the operation, check the log file.");
 
  335       boost::uuids::basic_random_generator<boost::mt19937> gen;
 
  336       boost::uuids::uuid u = gen();
 
  337       std::string 
id = boost::uuids::to_string(u);
 
  340       ds->setConnInfo(dsinfo);
 
  341       ds->setTitle(uri.stem().string());
 
  342       ds->setAccessDriver(
"OGR");
 
  344       ds->setDescription(uri.string());
 
  350       m_outputDatasource = ds;
 
  354       m_outputDatasource = m_geomOpOutputPage->getDsInfoPtr();
 
  356       trgDs->setConnectionInfo(m_outputDatasource->getConnInfo());
 
  361         QMessageBox::information(
this, 
"Geometric Operation", 
"The selected output datasource can not be accessed.");
 
  365       if (trgDs->dataSetExists(outputdataset))
 
  367         QMessageBox::information(
this, 
"Geometric Operation", 
"Dataset already exists. Remove it or select a new name and try again.");
 
  389                         m_geomOpOutputPage->getObjectStrategy(),
 
  391                         m_geomOpOutputPage->hasOutputLayer());
 
  396         result = geomOp->
run();
 
  400         this->setCursor(Qt::ArrowCursor);
 
  401         QMessageBox::information(
this, 
"Geometric Operation", 
"Error: could not generate the operation.");
 
  414     for(std::size_t i = 0; i < outputDSetNames.size(); ++i)
 
  418         m_outLayer.push_back(converter(dt));
 
  421   catch(
const std::exception& e)
 
  423     this->setCursor(Qt::ArrowCursor);
 
  424     QMessageBox::information(
this, 
"Greographic Operation", e.what());
 
  426 #ifdef TERRALIB_LOGGER_ENABLED 
  427     std::string str = 
"Greographic Operation - ";
 
  429     te::common::Logger::logDebug(
"vp", str.c_str());
 
  437   this->setCursor(Qt::ArrowCursor);
 
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager. 
 
void setList(std::list< te::map::AbstractLayerPtr > &layerList)
 
const std::string & getDataSetName() const 
 
std::vector< std::string > GetOutputDSetNames()
 
boost::shared_ptr< DataSetType > DataSetTypePtr
 
The geographic operation Line. 
 
boost::shared_ptr< DataSource > DataSourcePtr
 
The geographic operation Minimum Bounding Rectangle. 
 
void setLayer(te::map::AbstractLayerPtr layer)
 
virtual bool validateCurrentPage()
 
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
 
This class is GUI used to define the basic geometric operator parameters for the VP operation...
 
const QueryCapabilities & getQueryCapabilities() const 
 
The geographic operation Area. 
 
void removeViewer(int viewerId)
Dettach a progress viewer. 
 
static ProgressManager & getInstance()
It returns a reference to the singleton instance. 
 
const std::string & getDataSourceId() const 
 
static std::auto_ptr< DataSource > make(const std::string &dsType)
 
A Qt dialog that allows users to run the basic geometric operations defined by VP module...
 
The geographic operation Perimeter. 
 
bool supportsSpatialSQLDialect() const 
 
void setOutput(std::auto_ptr< te::da::DataSource > outDsrc, std::string dsname)
 
The geographic operation Centroid. 
 
std::vector< te::map::AbstractLayerPtr > getOutLayer()
 
This file defines a class for Basic Geometric Operation Wizard Page. 
 
int addViewer(AbstractProgressViewer *apv)
Attach a progress viewer. 
 
bool supportsPreparedQueryAPI() const 
 
virtual bool paramsAreValid()
 
te::map::AbstractLayerPtr getInLayer()
 
The geographic operation Convex Hull. 
 
A class that represents a data source component. 
 
A layer with reference to a dataset. 
 
std::auto_ptr< LayerSchema > getSchema() const 
It returns the layer schema. 
 
void setInput(te::da::DataSourcePtr inDsrc, std::string inDsetName, std::auto_ptr< te::da::DataSetType > inDsetType)
 
void setParams(std::vector< std::string > selectedProps, std::vector< te::vp::GeometricOperation > operations, te::vp::GeometricOpObjStrategy objStrategy, std::string attribute, bool outputLayer)
 
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
 
GeometricOpWizard(QWidget *parent)
 
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr