4 #include "../../../edit/Enums.h" 5 #include "../../../edit/Utils.h" 6 #include "../../../maptools/AbstractLayer.h" 10 #if QT_VERSION >= 0x050000 11 #include <QStandardPaths> 13 #if QT_VERSION < 0x050000 14 #include <QDesktopServices> 21 #if QT_VERSION >= 0x050000 22 userDataDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
24 userDataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
27 QDir dir(userDataDir +
"/edition/" +layer->
getTitle().c_str());
30 dir.mkpath(dir.path());
32 QString f = dir.path() +
"/" + QString::fromUtf8(layer->
getTitle().c_str());
33 QString f2 = f +
"_r";
35 std::vector<te::gm::Geometry*> gs;
36 std::vector<te::gm::Geometry*> gsR;
38 std::string fName = (f +
".ids").toUtf8().data();
40 std::ofstream idsFile(fName.c_str(), std::ios::out);
41 std::ofstream idsRFile((fName +
"r").c_str(), std::ios::out);
43 for(std::map<std::string, te::gm::Geometry*>::const_iterator it = geoms.begin(); it != geoms.end(); ++it)
45 std::string
id = it->first;
49 gsR.push_back(it->second);
50 idsRFile <<
id <<
"\n";
54 gs.push_back(it->second);
55 idsFile <<
id <<
"\n";
71 #if QT_VERSION >= 0x050000 72 userDataDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
74 userDataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
77 QDir dir(userDataDir +
"/edition/" + QString::fromUtf8(layer->
getTitle().c_str()));
83 QString fName = dir.path() +
"/" + QString::fromUtf8(layer->
getTitle().c_str()) +
".geom";
87 QFile qf(dir.path() +
"/" + QString::fromUtf8(layer->
getTitle().c_str()) +
".ids");
89 if(!qf.open(QIODevice::ReadOnly | QIODevice::Text))
94 QString id(qf.readLine().data());
109 geoms[
id.toUtf8().data()] = gm;
112 fName = dir.path() +
"/" + QString::fromUtf8(layer->
getTitle().c_str()) +
"_r.geom";
118 QFile qf2(dir.path() +
"/" + QString::fromUtf8(layer->
getTitle().c_str()) +
".idsr");
120 if(!qf2.open(QIODevice::ReadOnly | QIODevice::Text))
125 QString id(qf2.readLine().data());
140 geoms[
id.toUtf8().data()] = gm;
147 std::set<std::string> res;
151 #if QT_VERSION >= 0x050000 152 userDataDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
154 userDataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
157 QDir dir(userDataDir +
"/edition");
159 QStringList lst = dir.entryList(QDir::Dirs);
161 for(QStringList::iterator it = lst.begin(); it != lst.end(); ++it)
162 res.insert((*it).toUtf8().data());
171 #if QT_VERSION >= 0x050000 172 userDataDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
174 userDataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
177 QDir dir(userDataDir +
"/edition/" + QString::fromUtf8(layer->
getTitle().c_str()));
188 if (dir.exists(dirName)) {
189 Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) {
191 result =
RemoveDir(info.absoluteFilePath());
194 result = QFile::remove(info.absoluteFilePath());
201 result = dir.rmdir(dirName);
bool RemoveDir(const QString &dirName)
This is the base class for layers.
void openFile(const char *fileName)
Opens the file fileName.
virtual const std::string & getTitle() const
It returns the layer title.
static void writeGeometries(const char *fileName, const std::map< int, te::gm::Geometry * > &geoms)
void RemoveStash(const te::map::AbstractLayer *layer)
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void StashGeometries(const te::map::AbstractLayer *layer, const std::map< std::string, te::gm::Geometry * > &geoms, const std::map< std::string, int > &ops)
te::gm::Geometry * next()
Returns the next geometry.
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
std::set< std::string > GetStashedLayers()
A class that can parses a file with wkb encoded geometries.
void GetStashedGeometries(const te::map::AbstractLayer *layer, std::map< std::string, te::gm::Geometry * > &geoms, std::map< std::string, int > &ops)