21 #include "../../../common/progress/ProgressManager.h" 22 #include "../../../dataaccess/datasource/DataSource.h" 23 #include "../../../dataaccess/datasource/DataSourceInfoManager.h" 24 #include "../../../dataaccess/datasource/DataSourceInfoManager.h" 25 #include "../../../dataaccess/datasource/DataSourceManager.h" 26 #include "../../../dataaccess/utils/Utils.h" 27 #include "../../../core/filesystem/FileSystem.h" 28 #include "../../../datatype/SimpleProperty.h" 29 #include "../../../geometry/GeometryProperty.h" 30 #include "../../../memory/DataSet.h" 31 #include "../../../memory/DataSetItem.h" 32 #include "../../widgets/layer/utils/DataSet2Layer.h" 33 #include "../help/HelpPushButton.h" 34 #include "../layer/search/LayerSearchWidget.h" 35 #include "../layer/search/LayerSearchWizardPage.h" 36 #include "../progress/ProgressViewerDialog.h" 41 #include <boost/algorithm/string.hpp> 42 #include <boost/filesystem.hpp> 43 #include <boost/lexical_cast.hpp> 44 #include <boost/uuid/random_generator.hpp> 45 #include <boost/uuid/uuid_io.hpp> 48 #include <QApplication> 49 #include <QMessageBox> 54 this->setWizardStyle(QWizard::ModernStyle);
55 this->setWindowTitle(tr(
"Vectorization"));
57 this->setOption(QWizard::HaveHelpButton,
true);
58 this->setOption(QWizard::HelpButtonOnRight,
false);
62 this->setButton(QWizard::HelpButton, helpButton);
66 connect(
this, SIGNAL(currentIdChanged(
int)), SLOT(
onPageChanged(
int)));
77 std::list<te::map::AbstractLayerPtr> list =
m_layerSearchPage->getSearchWidget()->getSelecteds();
79 if(list.empty() ==
false)
120 QMessageBox::warning(
this, tr(
"Vectorization"), tr(
"File already exists."));
125 std::string outputdataset =
m_vectorPage->getLayerName();
127 if(outputdataset.empty())
129 QMessageBox::warning(
this, tr(
"Vectorizer"), tr(
"Output dataset name not defined."));
137 QMessageBox::warning(
this, tr(
"Vectorizer"), tr(
"Output repository name not defined."));
148 boost::filesystem::path uri(uriStr);
150 std::size_t idx = outputdataset.find(
".");
151 if(idx != std::string::npos)
152 outputdataset = outputdataset.substr(0,idx);
154 const std::string connInfo(
"file://" + uri.string());
157 boost::uuids::basic_random_generator<boost::mt19937> gen;
158 boost::uuids::uuid u = gen();
159 std::string
id = boost::uuids::to_string(u);
162 ds->setConnInfo(connInfo);
163 ds->setTitle(uri.stem().string());
164 ds->setAccessDriver(
"OGR");
166 ds->setDescription(uri.string());
178 std::unique_ptr<te::rst::Raster> raster =
m_vectorPage->getRaster();
180 unsigned int maxGeom = 0;
184 std::vector<te::gm::Geometry*> geomVec;
185 std::vector< double > geomsValues;
190 QApplication::setOverrideCursor(Qt::WaitCursor);
195 raster->vectorize(geomVec, band, maxGeom, &geomsValues);
197 catch(
const std::exception& e)
199 QMessageBox::warning(
this, tr(
"Vectorizer"), e.what());
201 QApplication::restoreOverrideCursor();
207 QMessageBox::warning(
this, tr(
"Vectorizer"), tr(
"An exception has occurred!"));
209 QApplication::restoreOverrideCursor();
217 std::unique_ptr<te::da::DataSetType> dsType =
createDataSetType(outputdataset, raster->getSRID());
219 std::unique_ptr<te::mem::DataSet> dsMem =
createDataSet(dsType.get(), geomVec, geomsValues);
234 QMessageBox::information(
this, tr(
"Vectorizer"), tr(
"Vectorizer ended sucessfully."));
236 catch(
const std::exception& e)
238 QMessageBox::warning(
this, tr(
"Vectorizer"), e.what());
240 QApplication::restoreOverrideCursor();
246 QMessageBox::warning(
this, tr(
"Vectorizer"), tr(
"An exception has occurred saving geometries!"));
248 QApplication::restoreOverrideCursor();
253 QApplication::restoreOverrideCursor();
264 dsType->add(idProperty);
267 dsType->add(valueProperty);
271 dsType->add(geomProperty);
274 std::string pkName =
"pk_id";
275 pkName+=
"_" + dataSetName;
286 for(std::size_t t = 0; t < geoms.size(); ++t)
311 std::map<std::string, std::string> options;
313 ds->createDataSet(dsType, options);
315 ds->add(dataSetName, dataSet, options);
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
void setGeometry(std::size_t i, te::gm::Geometry *value)
It sets the value of the i-th property.
static bool exists(const std::string &path)
Checks if a given path in UTF-8 exists.
void setDouble(std::size_t i, double value)
It sets the value of the i-th property.
boost::shared_ptr< DataSetType > DataSetTypePtr
An atomic property like an integer or double.
boost::shared_ptr< DataSource > DataSourcePtr
A class that models the description of a dataset.
static te::dt::Date ds(2010, 01, 01)
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
static te::dt::TimeDuration dt(20, 30, 50, 11)
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
It describes a primary key (pk) constraint.
A class that represents a data source component.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr