27 #include "../../../dataaccess/dataset/DataSetAdapter.h"
28 #include "../../../dataaccess/dataset/DataSetTypeConverter.h"
29 #include "../../../dataaccess/datasource/DataSourceFactory.h"
30 #include "../../../dataaccess/datasource/DataSourceInfo.h"
31 #include "../../../dataaccess/datasource/DataSourceInfoManager.h"
32 #include "../../../dataaccess/datasource/DataSourceManager.h"
33 #include "../../../dataaccess/utils/Utils.h"
34 #include "../../../geometry/GeometryProperty.h"
35 #include "../../../maptools/DataSetLayer.h"
37 #include "ui_PostGIS2SHPDialogForm.h"
40 #include <QFileDialog>
41 #include <QMessageBox>
44 #include <boost/uuid/random_generator.hpp>
45 #include <boost/uuid/uuid_io.hpp>
52 m_ui(new Ui::PostGis2SHPDialogForm)
58 m_ui->m_imgLabel->setPixmap(QIcon::fromTheme(
"data-exchange-pgis-shp-hint").pixmap(112,48));
72 std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin();
74 while(it != layers.end())
87 if(dsPtr->getType() ==
"POSTGIS")
88 m_ui->m_inputLayerComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
96 QMessageBox::information(
this,
"Help",
"Under development");
101 int idxLayer = m_ui->m_inputLayerComboBox->currentIndex();
105 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Input layer not selected."));
109 QVariant varLayer = m_ui->m_inputLayerComboBox->itemData(idxLayer, Qt::UserRole);
114 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Error getting selected layer."));
118 if(m_ui->m_dataSetLineEdit->text().isEmpty())
120 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Output File Name not defined."));
128 std::auto_ptr<te::da::DataSetType> dsType = layer->getSchema();
132 if(dsType->size() == 0)
137 std::map<std::string, std::string> connInfo;
138 connInfo[
"URI"] = m_ui->m_dataSetLineEdit->text().toStdString();
139 connInfo[
"DRIVER"] =
"ESRI Shapefile";
142 dsOGR->setConnectionInfo(connInfo);
149 dsTypeResult->
setName(m_ui->m_dataSetLineEdit->text().toStdString());
152 std::map<std::string,std::string> nopt;
154 std::auto_ptr<te::da::DataSet> dataset = layer->getData();
156 dsOGR->createDataSet(dsTypeResult, nopt);
160 if(dataset->moveBeforeFirst())
161 dsOGR->add(dsTypeResult->getName(), dsAdapter.get(), dsOGR->getConnectionInfo());
165 QMessageBox::information(
this, tr(
"Exchanger"), tr(
"Layer exported successfully."));
167 catch(
const std::exception& e)
169 QString errMsg(tr(
"Error during exchanger. The reported error is: %1"));
171 errMsg = errMsg.arg(e.what());
173 QMessageBox::information(
this, tr(
"Exchanger"), errMsg);
181 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save as..."),
182 QString(), tr(
"Shapefile (*.shp *.SHP);;"),0, QFileDialog::DontConfirmOverwrite);
184 if (fileName.isEmpty())
187 m_ui->m_dataSetLineEdit->setText(fileName);
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
PostGIS2SHPDialog(QWidget *parent=0, Qt::WindowFlags f=0)
TEDATAACCESSEXPORT void LoadProperties(te::da::DataSetType *dataset, const std::string &datasourceId)
void onDirToolButtonClicked()
boost::shared_ptr< DataSource > DataSourcePtr
A class that models the description of a dataset.
DataSetType * getResult() const
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
An converter for DataSetType.
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
Set the layer that can be used.
void setName(const std::string &name)
It sets the property name.
void onHelpPushButtonClicked()
const std::string & getDataSourceId() const
static std::auto_ptr< DataSource > make(const std::string &dsType)
std::auto_ptr< Ui::PostGis2SHPDialogForm > m_ui
A layer with reference to a dataset.
void onOkPushButtonClicked()
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
A exchanger dialog from PostGis to SHP operation.