27 #include "../../core/translator/Translator.h" 28 #include "../../dataaccess/datasource/DataSource.h" 29 #include "../../dataaccess/datasource/DataSourceFactory.h" 30 #include "../../dataaccess/datasource/DataSourceManager.h" 31 #include "../../dataaccess/datasource/DataSourceInfoManager.h" 32 #include "../../dataaccess/utils/Utils.h" 33 #include "../../datatype/SimpleProperty.h" 34 #include "../../geometry/GeometryProperty.h" 35 #include "../../qt/widgets/canvas/Canvas.h" 36 #include "../../qt/widgets/Utils.h" 37 #include "../../qt/widgets/layer/utils/DataSet2Layer.h" 38 #include "../../srs/Config.h" 44 #include <QFileDialog> 45 #include <QMessageBox> 51 #include <boost/filesystem.hpp> 52 #include <boost/uuid/random_generator.hpp> 53 #include <boost/uuid/uuid_io.hpp> 57 #if QT_VERSION >= 0x050000 70 QString fileName = QFileDialog::getSaveFileName(
nullptr,
TE_TR(
"Create Draft Layer..."), QString(),
TE_TR(
"Shapefile (*.shp *.SHP);;"));
72 if (fileName.isEmpty())
76 boost::filesystem::path outfile(fileName.toUtf8().data());
77 std::string layerName = outfile.stem().string();
80 std::string outputdataset = layerName;
81 std::size_t idx = outputdataset.find(
".");
82 if (idx != std::string::npos)
83 outputdataset = outputdataset.substr(0, idx);
85 std::string connInfo(
"file://");
86 connInfo += fileName.toUtf8().data();
89 boost::uuids::basic_random_generator<boost::mt19937> gen;
90 boost::uuids::uuid u = gen();
91 std::string
id = boost::uuids::to_string(u);
94 dsInfo->setConnInfo(connInfo);
95 dsInfo->setTitle(layerName);
96 dsInfo->setAccessDriver(
"OGR");
97 dsInfo->setType(
"OGR");
98 dsInfo->setDescription(layerName);
107 dsType->add(nameProperty);
110 dsType->add(descriptionProperty);
113 dsType->add(geomProperty);
119 std::map<std::string, std::string> nopt;
123 ds->createDataSet(dsType.get(), nopt);
136 layer = converter(
dt);
147 dsPtr->dropDataSet(layerName);
153 dsType->add(nameProperty);
156 dsType->add(descriptionProperty);
159 dsType->add(geomProperty);
162 std::map<std::string, std::string> nopt;
163 if (!dsPtr->isOpened())
168 dsPtr->createDataSet(dsType.get(), nopt);
179 layer = converter(dt);
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)
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
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)
#define TE_TR(message)
It marks a string in order to get translated.
TEEDITQTEXPORT te::map::AbstractLayerPtr CreateShapeFileLayer(const te::gm::GeomType &type, const int &srid)
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
static te::dt::TimeDuration dt(20, 30, 50, 11)
TEEDITQTEXPORT QPointF GetPosition(QMouseEvent *e)
Utility functions for the data access module.
A class that represents a data source component.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr