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> 50 te::qt::widgets::PostGIS2SHPDialog::PostGIS2SHPDialog(
QWidget* parent, Qt::WindowFlags f)
52 m_ui(new
Ui::PostGis2SHPDialogForm)
58 m_ui->m_imgLabel->setPixmap(QIcon::fromTheme(
"data-exchange-pgis-shp-hint").pixmap(112,48));
61 connect(m_ui->m_helpPushButton, SIGNAL(clicked()),
this, SLOT(onHelpPushButtonClicked()));
62 connect(m_ui->m_okPushButton, SIGNAL(clicked()),
this, SLOT(onOkPushButtonClicked()));
63 connect(m_ui->m_dirToolButton, SIGNAL(clicked()),
this, SLOT(onDirToolButtonClicked()));
70 std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin();
72 while(it != layers.end())
76 std::string dsName = l->getDataSourceId();
80 if(dsPtr->getType() ==
"POSTGIS")
81 m_ui->m_inputLayerComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
89 QMessageBox::information(
this,
"Help",
"Under development");
94 int idxLayer =
m_ui->m_inputLayerComboBox->currentIndex();
98 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Input layer not selected."));
102 QVariant varLayer =
m_ui->m_inputLayerComboBox->itemData(idxLayer, Qt::UserRole);
107 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Error getting selected layer."));
111 if(
m_ui->m_dataSetLineEdit->text().isEmpty())
113 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Output File Name not defined."));
121 std::unique_ptr<te::da::DataSetType> dsType = layer->getSchema();
123 if(dsType->size() == 0)
134 dsTypeResult->
setName(
m_ui->m_dataSetLineEdit->text().toUtf8().data());
137 std::map<std::string,std::string> nopt;
139 std::unique_ptr<te::da::DataSet> dataset = layer->getData();
141 dsOGR->createDataSet(dsTypeResult, nopt);
145 if(dataset->moveBeforeFirst())
146 dsOGR->add(dsTypeResult->getName(), dsAdapter.get(), nopt);
150 QMessageBox::information(
this, tr(
"Exchanger"), tr(
"Layer exported successfully."));
152 catch(
const std::exception& e)
154 QString errMsg(tr(
"Error during exchanger. The reported error is: %1"));
156 errMsg = errMsg.arg(e.what());
158 QMessageBox::information(
this, tr(
"Exchanger"), errMsg);
166 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save as..."),
167 QString(), tr(
"Shapefile (*.shp *.SHP);;"),
nullptr, QFileDialog::DontConfirmOverwrite);
169 if (fileName.isEmpty())
172 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.
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
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
std::unique_ptr< Ui::PostGis2SHPDialogForm > m_ui
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()
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr) Q_DECLARE_METATYPE(te
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.