summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-10-04 18:28:34 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-10-04 18:28:34 (GMT)
commit98d069f88f2da028d10e70ecf989c08d98a4e3ae (patch)
tree1accd974b1ad378324c5ff1a7c047e8233316fd4
parent74b35067566f9b48f591e2f65d176e39381a402f (diff)
Do not create additional placemarks when converting file formats
-rw-r--r--src/lib/marble/geodata/data/GeoDataDocument.h3
-rw-r--r--src/plugins/runner/osm/OsmParser.cpp18
-rw-r--r--src/plugins/runner/osm/OsmParser.h9
-rw-r--r--src/plugins/runner/osm/OsmRunner.cpp2
-rw-r--r--src/plugins/runner/osm/OsmWay.cpp26
-rw-r--r--src/plugins/runner/osm/OsmWay.h3
-rw-r--r--tools/vectorosm-tilecreator/TileDirectory.cpp2
7 files changed, 34 insertions, 29 deletions
diff --git a/src/lib/marble/geodata/data/GeoDataDocument.h b/src/lib/marble/geodata/data/GeoDataDocument.h
index a210354..374f9bb 100644
--- a/src/lib/marble/geodata/data/GeoDataDocument.h
+++ b/src/lib/marble/geodata/data/GeoDataDocument.h
@@ -41,7 +41,8 @@ enum DocumentRole {
UserDocument,
TrackingDocument,
BookmarkDocument,
- SearchResultDocument
+ SearchResultDocument,
+ ConversionDocument
};
diff --git a/src/plugins/runner/osm/OsmParser.cpp b/src/plugins/runner/osm/OsmParser.cpp
index 8fecaef..dd4f547 100644
--- a/src/plugins/runner/osm/OsmParser.cpp
+++ b/src/plugins/runner/osm/OsmParser.cpp
@@ -30,7 +30,7 @@
namespace Marble {
-GeoDataDocument *OsmParser::parse(const QString &filename, QString &error)
+GeoDataDocument *OsmParser::parse(const QString &filename, DocumentRole role, QString &error)
{
QFileInfo const fileInfo(filename);
if (!fileInfo.exists() || !fileInfo.isReadable()) {
@@ -39,13 +39,13 @@ GeoDataDocument *OsmParser::parse(const QString &filename, QString &error)
}
if (fileInfo.completeSuffix() == QLatin1String("o5m")) {
- return parseO5m(filename, error);
+ return parseO5m(filename, role, error);
} else {
- return parseXml(filename, error);
+ return parseXml(filename, role, error);
}
}
-GeoDataDocument* OsmParser::parseO5m(const QString &filename, QString &error)
+GeoDataDocument* OsmParser::parseO5m(const QString &filename, DocumentRole role, QString &error)
{
O5mreader* reader;
O5mreaderDataset data;
@@ -119,10 +119,10 @@ GeoDataDocument* OsmParser::parseO5m(const QString &filename, QString &error)
fclose(file);
error = reader->errMsg;
o5mreader_close(reader);
- return createDocument(nodes, ways, relations);
+ return createDocument(role, nodes, ways, relations);
}
-GeoDataDocument* OsmParser::parseXml(const QString &filename, QString &error)
+GeoDataDocument* OsmParser::parseXml(const QString &filename, DocumentRole role, QString &error)
{
QXmlStreamReader parser;
QFile file;
@@ -198,10 +198,10 @@ GeoDataDocument* OsmParser::parseXml(const QString &filename, QString &error)
return nullptr;
}
- return createDocument(m_nodes, m_ways, m_relations);
+ return createDocument(role, m_nodes, m_ways, m_relations);
}
-GeoDataDocument *OsmParser::createDocument(OsmNodes &nodes, OsmWays &ways, OsmRelations &relations)
+GeoDataDocument *OsmParser::createDocument(DocumentRole role, OsmNodes &nodes, OsmWays &ways, OsmRelations &relations)
{
GeoDataDocument* document = new GeoDataDocument;
GeoDataPolyStyle backgroundPolyStyle;
@@ -222,7 +222,7 @@ GeoDataDocument *OsmParser::createDocument(OsmNodes &nodes, OsmWays &ways, OsmRe
}
foreach(OsmWay const &way, ways) {
- way.create(document, nodes, usedNodes);
+ way.create(document, role, nodes, usedNodes);
}
foreach(qint64 id, usedNodes) {
diff --git a/src/plugins/runner/osm/OsmParser.h b/src/plugins/runner/osm/OsmParser.h
index ea05fc1..86b8573 100644
--- a/src/plugins/runner/osm/OsmParser.h
+++ b/src/plugins/runner/osm/OsmParser.h
@@ -17,6 +17,7 @@
#include "OsmNode.h"
#include "OsmWay.h"
#include "OsmRelation.h"
+#include <GeoDataDocument.h>
#include <QString>
@@ -27,12 +28,12 @@ class GeoDataDocument;
class OsmParser
{
public:
- static GeoDataDocument* parse(const QString &filename, QString &error);
+ static GeoDataDocument* parse(const QString &filename, DocumentRole role, QString &error);
private:
- static GeoDataDocument* parseXml(const QString &filename, QString &error);
- static GeoDataDocument* parseO5m(const QString &filename, QString &error);
- static GeoDataDocument *createDocument(OsmNodes &nodes, OsmWays &way, OsmRelations &relations);
+ static GeoDataDocument* parseXml(const QString &filename, DocumentRole role, QString &error);
+ static GeoDataDocument* parseO5m(const QString &filename, DocumentRole role, QString &error);
+ static GeoDataDocument *createDocument(DocumentRole role, OsmNodes &nodes, OsmWays &way, OsmRelations &relations);
};
}
diff --git a/src/plugins/runner/osm/OsmRunner.cpp b/src/plugins/runner/osm/OsmRunner.cpp
index 8c2f2aa..d8d88ed 100644
--- a/src/plugins/runner/osm/OsmRunner.cpp
+++ b/src/plugins/runner/osm/OsmRunner.cpp
@@ -23,7 +23,7 @@ OsmRunner::OsmRunner(QObject *parent) :
GeoDataDocument *OsmRunner::parseFile(const QString &fileName, DocumentRole role, QString &error)
{
- GeoDataDocument* document = OsmParser::parse(fileName, error);
+ GeoDataDocument* document = OsmParser::parse(fileName, role, error);
if (document) {
document->setDocumentRole(role);
document->setFileName(fileName);
diff --git a/src/plugins/runner/osm/OsmWay.cpp b/src/plugins/runner/osm/OsmWay.cpp
index 9d2aa1c..8ddc89c 100644
--- a/src/plugins/runner/osm/OsmWay.cpp
+++ b/src/plugins/runner/osm/OsmWay.cpp
@@ -24,7 +24,7 @@ namespace Marble {
QSet<StyleBuilder::OsmTag> OsmWay::s_areaTags;
-void OsmWay::create(GeoDataDocument *document, const OsmNodes &nodes, QSet<qint64> &usedNodes) const
+void OsmWay::create(GeoDataDocument *document, DocumentRole role, const OsmNodes &nodes, QSet<qint64> &usedNodes) const
{
const double height = extractBuildingHeight(m_osmData);
@@ -102,17 +102,19 @@ void OsmWay::create(GeoDataDocument *document, const OsmNodes &nodes, QSet<qint6
document->append(placemark);
- QVector<NamedEntry> namedEntries = extractNamedEntries(osmData);
- if (!namedEntries.isEmpty()) {
- foreach (const auto &namedEntry, namedEntries) {
- GeoDataPlacemark *entry = new GeoDataPlacemark();
- entry->setCoordinate(namedEntry.coordinates);
- entry->setName(namedEntry.label);
- entry->setOsmData(namedEntry.osmData);
- entry->setVisualCategory(visualCategory);
- entry->setVisible(visualCategory != GeoDataPlacemark::None);
-
- document->append(entry);
+ if (role != ConversionDocument) {
+ QVector<NamedEntry> namedEntries = extractNamedEntries(osmData);
+ if (!namedEntries.isEmpty()) {
+ foreach (const auto &namedEntry, namedEntries) {
+ GeoDataPlacemark *entry = new GeoDataPlacemark();
+ entry->setCoordinate(namedEntry.coordinates);
+ entry->setName(namedEntry.label);
+ entry->setOsmData(namedEntry.osmData);
+ entry->setVisualCategory(visualCategory);
+ entry->setVisible(visualCategory != GeoDataPlacemark::None);
+
+ document->append(entry);
+ }
}
}
}
diff --git a/src/plugins/runner/osm/OsmWay.h b/src/plugins/runner/osm/OsmWay.h
index 213f61e..fafa06c 100644
--- a/src/plugins/runner/osm/OsmWay.h
+++ b/src/plugins/runner/osm/OsmWay.h
@@ -14,6 +14,7 @@
#include "OsmNode.h"
#include <osm/OsmPlacemarkData.h>
#include <StyleBuilder.h>
+#include <GeoDataDocument.h>
#include <QSet>
#include <QString>
@@ -31,7 +32,7 @@ public:
const OsmPlacemarkData & osmData() const;
const QVector<qint64> &references() const;
- void create(GeoDataDocument* document, const OsmNodes &nodes, QSet<qint64> &usedNodes) const;
+ void create(GeoDataDocument* document, DocumentRole role, const OsmNodes &nodes, QSet<qint64> &usedNodes) const;
private:
struct NamedEntry {
diff --git a/tools/vectorosm-tilecreator/TileDirectory.cpp b/tools/vectorosm-tilecreator/TileDirectory.cpp
index ec87d11..1edcf5e 100644
--- a/tools/vectorosm-tilecreator/TileDirectory.cpp
+++ b/tools/vectorosm-tilecreator/TileDirectory.cpp
@@ -139,7 +139,7 @@ QString TileDirectory::name() const
QSharedPointer<GeoDataDocument> TileDirectory::open(const QString &filename, ParsingRunnerManager &manager)
{
// Timeout is set to 10 min. If the file is reaaally huge, set it to something bigger.
- GeoDataDocument* map = manager.openFile(filename, DocumentRole::MapDocument, 600000);
+ GeoDataDocument* map = manager.openFile(filename, DocumentRole::ConversionDocument, 600000);
if(map == nullptr) {
qWarning() << "File" << filename << "couldn't be loaded.";
}