27 #include "../../../common/Logger.h" 
   28 #include "../../../common/progress/ProgressManager.h" 
   29 #include "../../../common/Translator.h" 
   30 #include "../../../common/STLUtils.h" 
   31 #include "../../../dataaccess/dataset/DataSetType.h" 
   32 #include "../../../dataaccess/dataset/ObjectIdSet.h" 
   33 #include "../../../dataaccess/datasource/DataSourceCapabilities.h" 
   34 #include "../../../dataaccess/datasource/DataSourceInfo.h" 
   35 #include "../../../dataaccess/datasource/DataSourceInfoManager.h" 
   36 #include "../../../dataaccess/datasource/DataSourceFactory.h" 
   37 #include "../../../dataaccess/datasource/DataSourceManager.h" 
   38 #include "../../../dataaccess/utils/Utils.h" 
   39 #include "../../../datatype/Enums.h" 
   40 #include "../../../datatype/Property.h" 
   41 #include "../../../geometry/GeometryProperty.h" 
   42 #include "../../../maptools/AbstractLayer.h" 
   43 #include "../../../postgis/Transactor.h" 
   44 #include "../../../qt/af/Utils.h" 
   45 #include "../../../qt/widgets/datasource/selector/DataSourceSelectorDialog.h" 
   46 #include "../../../qt/widgets/layer/utils/DataSet2Layer.h" 
   47 #include "../../../qt/widgets/progress/ProgressViewerDialog.h" 
   48 #include "../../../qt/widgets/utils/DoubleListWidget.h" 
   49 #include "../../../statistics/core/Utils.h" 
   51 #include "ui_MapLayerChoice.h" 
   54 #include <QFileDialog> 
   55 #include <QGridLayout> 
   56 #include <QMessageBox> 
   59 #include <boost/algorithm/string.hpp> 
   60 #include <boost/filesystem.hpp> 
   61 #include <boost/uuid/random_generator.hpp> 
   62 #include <boost/uuid/uuid_io.hpp> 
   70     m_ui(new Ui::MapLayerChoice),
 
   78   QGridLayout* displayLayout = 
new QGridLayout(
m_ui->m_widget);
 
   79   displayLayout->addWidget(
m_widget.get());
 
   81   m_widget->setLeftLabel(
"Available Attributes");
 
   82   m_widget->setRightLabel(
"Selected Attributes");
 
   97   std::list<te::map::AbstractLayerPtr>::iterator it = m_layers.begin();
 
   99   while(it != m_layers.end())
 
  101     std::auto_ptr<te::da::DataSetType> dsType = it->get()->getSchema();
 
  102     if(dsType->hasGeom())
 
  114   return m_selectedLayer;
 
  127     QMessageBox::information(
this, 
"Address Geocoding", 
"Can not execute this operation on this type of layer.");
 
  132   if(!m_dataSource.get())
 
  134     QMessageBox::information(
this, 
"Address Geocoding", 
"The selected input data source can not be accessed.");
 
  137   m_selectedProps = m_widget->getOutputValues();
 
  138   if(m_selectedProps.empty())
 
  140     QMessageBox::information(
this, 
"Address Geocoding", 
"Select at least one attribute.");
 
  145   std::auto_ptr<te::da::DataSetType> schema = m_selectedLayer->getSchema();
 
  146   const std::vector<te::dt::Property*>& properties = schema->getProperties();
 
  148   bool addNewColumn = 
true;
 
  149   for(std::size_t i = 0; i < properties.size(); ++i)
 
  151     std::string name = properties[i]->getName();
 
  152     if(name == 
"tsvector")
 
  153       addNewColumn = 
false;
 
  157   if(addNewColumn == 
true)
 
  159     std::auto_ptr<te::da::DataSourceTransactor> trans = m_dataSource->getTransactor();
 
  160     std::string alterTable = 
"ALTER TABLE "+ m_selectedLayer->getTitle() + 
" ADD tsvector tsvector";
 
  161     trans->execute(alterTable);
 
  167   std::string updateTable = 
"UPDATE " + m_selectedLayer->getTitle() + 
" SET tsvector = to_tsvector('english', ";
 
  169   for(std::size_t selProps = 0; selProps < m_selectedProps.size(); ++selProps)
 
  172       updateTable += 
" "+ m_selectedProps[selProps];
 
  174       updateTable += 
"||' '||"+ m_selectedProps[selProps];
 
  179   m_dataSource->execute(updateTable);
 
  182   unsigned dot = m_selectedLayer->getTitle().find_last_of(
".");
 
  183   std::string table = m_selectedLayer->getTitle().substr(dot+1);
 
  186   std::string dropIndex = 
"DROP INDEX IF EXISTS " + table +
"_idx";
 
  187   m_dataSource->execute(dropIndex);
 
  190   std::string createIndex = 
"CREATE INDEX "+ table +
"_idx ON "+ m_selectedLayer->getTitle() + 
"  USING GIN(tsvector)";
 
  192   m_dataSource->execute(createIndex);
 
  204   setVisible(context.
isShow());
 
  205   if(context.
isShow() == 
true)
 
  219   QPointF posF = pos();
 
  220   qreal valuex = posF.x();
 
  221   qreal valuey = posF.y();
 
  224   coordinate.
x = valuex;
 
  225   coordinate.
y = valuey;
 
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager. 
 
Abstract class to represent an observable. "Model" part of MVC component. 
 
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
 
boost::shared_ptr< DataSource > DataSourcePtr
 
A dialog configure the input layer to address geocoding operation. 
 
virtual te::gm::Coord2D getPosition()
Method that returns the position llx, lly Reimplement this function in a ItemObserver subclass to pro...
 
Abstract class to represent an observer. "View" part of MVC widget. All classes representing the grap...
 
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
Set the layer that can be used. 
 
An utility struct for representing 2D coordinates. 
 
virtual void setPosition(const double &x, const double &y)
Change coordinate llx,lly of the MVC widget. Reimplement this function in a ItemController subclass t...
 
std::auto_ptr< te::qt::widgets::DoubleListWidget > m_widget
 
void onOkPushButtonClicked()
 
te::da::DataSourcePtr getDataSource()
 
te::map::AbstractLayerPtr getLayer()
 
MapLayerChoiceOutside(OutsideController *controller, Observable *o)
 
const std::string & getDataSourceId() const 
 
GeomType getGeometryType() const 
It returns the geometry subtype allowed for the property. 
 
void onCancelPushButtonClicked()
 
virtual void updateObserver(ContextItem context)
Reimplemented from Observer. 
 
std::auto_ptr< Ui::MapLayerChoice > m_ui
 
A layer with reference to a dataset. 
 
Abstract class to represent a controller. "Controller" part of MVC widget. All classes representing t...
 
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
 
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr