summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-11-13 20:14:38 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-11-13 20:14:38 (GMT)
commitc188ca3b4cbf17488560921e3cec9b27e528c0c6 (patch)
treedc264a33bd55a3ccdf0f9c5520e7fa7496603105
parentd9b3ee197f479316e3863fe2dc30bdb421051790 (diff)
Use mx:oid tags if available
-rw-r--r--tools/vectorosm-tilecreator/WayChunk.cpp14
-rw-r--r--tools/vectorosm-tilecreator/WayChunk.h2
-rw-r--r--tools/vectorosm-tilecreator/WayConcatenator.cpp24
-rw-r--r--tools/vectorosm-tilecreator/WayConcatenator.h1
4 files changed, 15 insertions, 26 deletions
diff --git a/tools/vectorosm-tilecreator/WayChunk.cpp b/tools/vectorosm-tilecreator/WayChunk.cpp
index 5199905..c3f0985 100644
--- a/tools/vectorosm-tilecreator/WayChunk.cpp
+++ b/tools/vectorosm-tilecreator/WayChunk.cpp
@@ -91,20 +91,6 @@ void WayChunk::reverse()
qSwap(m_first, m_last);
}
-qint64 WayChunk::id() const
-{
- return m_wayList.first()->osmData().id();
-}
-
-void WayChunk::printIds() const
-{
- QVector<PlacemarkPtr>::const_iterator itr = m_wayList.begin();
- qDebug()<<"IDs of placemarks in chunk";
- for (; itr != m_wayList.end(); ++itr) {
- qDebug()<<"Id :- "<<(*itr)->osmData().id();
- }
-}
-
int WayChunk::size() const
{
return m_wayList.size();
diff --git a/tools/vectorosm-tilecreator/WayChunk.h b/tools/vectorosm-tilecreator/WayChunk.h
index 3c8ab0b..0d3017c 100644
--- a/tools/vectorosm-tilecreator/WayChunk.h
+++ b/tools/vectorosm-tilecreator/WayChunk.h
@@ -43,8 +43,6 @@ public:
qint64 first() const;
qint64 last() const;
void reverse();
- qint64 id() const;
- void printIds() const;
int size() const;
bool concatPossible(const GeoDataPlacemark &placemark) const;
diff --git a/tools/vectorosm-tilecreator/WayConcatenator.cpp b/tools/vectorosm-tilecreator/WayConcatenator.cpp
index eb768a4..7d456b5 100644
--- a/tools/vectorosm-tilecreator/WayConcatenator.cpp
+++ b/tools/vectorosm-tilecreator/WayConcatenator.cpp
@@ -43,10 +43,8 @@ WayConcatenator::WayConcatenator(GeoDataDocument *document) :
osmData.containsTagKey("waterway");
if (isWay) {
GeoDataLineString *line = static_cast<GeoDataLineString*>(placemark->geometry());
- qint64 firstId = osmData.nodeReference(line->first()).id();
- Q_ASSERT(firstId != 0);
- qint64 lastId = osmData.nodeReference(line->last()).id();
- Q_ASSERT(lastId != 0);
+ qint64 firstId = osmId(osmData.nodeReference(line->first()));
+ qint64 lastId = osmId(osmData.nodeReference(line->last()));
if (firstId > 0 && lastId > 0) {
++m_originalWays;
bool containsFirst = m_hash.contains(firstId);
@@ -111,6 +109,12 @@ int WayConcatenator::mergedWays() const
return m_mergedWays;
}
+qint64 WayConcatenator::osmId(const OsmPlacemarkData &osmData)
+{
+ auto const value = osmData.tagValue(QStringLiteral("mx:oid")).toLong();
+ return value > 0 ? value : osmData.id();
+}
+
void WayConcatenator::addWayChunks()
{
for (auto const &placemark: m_wayPlacemarks) {
@@ -167,8 +171,8 @@ WayChunk::Ptr WayConcatenator::wayChunk(const GeoDataPlacemark &placemark, qint6
void WayConcatenator::concatFirst(const PlacemarkPtr &placemark, const WayChunk::Ptr &chunk)
{
GeoDataLineString *line = static_cast<GeoDataLineString*>(placemark->geometry());
- qint64 firstId = placemark->osmData().nodeReference(line->first()).id();
- qint64 lastId = placemark->osmData().nodeReference(line->last()).id();
+ qint64 firstId = osmId(placemark->osmData().nodeReference(line->first()));
+ qint64 lastId = osmId(placemark->osmData().nodeReference(line->last()));
if (chunk->first() != chunk->last()) {
int chunksRemoved = m_hash.remove(firstId, chunk);
@@ -190,8 +194,8 @@ void WayConcatenator::concatFirst(const PlacemarkPtr &placemark, const WayChunk:
void WayConcatenator::concatLast(const PlacemarkPtr &placemark, const WayChunk::Ptr &chunk)
{
GeoDataLineString *line = static_cast<GeoDataLineString*>(placemark->geometry());
- qint64 firstId = placemark->osmData().nodeReference(line->first()).id();
- qint64 lastId = placemark->osmData().nodeReference(line->last()).id();
+ qint64 firstId = osmId(placemark->osmData().nodeReference(line->first()));
+ qint64 lastId = osmId(placemark->osmData().nodeReference(line->last()));
if (chunk->first() != chunk->last()) {
int chunksRemoved = m_hash.remove(lastId, chunk);
@@ -210,8 +214,8 @@ void WayConcatenator::concatLast(const PlacemarkPtr &placemark, const WayChunk::
void WayConcatenator::concatBoth(const PlacemarkPtr &placemark, const WayChunk::Ptr &chunk, const WayChunk::Ptr &otherChunk)
{
GeoDataLineString *line = static_cast<GeoDataLineString*>(placemark->geometry());
- qint64 firstId = placemark->osmData().nodeReference(line->first()).id();
- qint64 lastId = placemark->osmData().nodeReference(line->last()).id();
+ qint64 firstId = osmId(placemark->osmData().nodeReference(line->first()));
+ qint64 lastId = osmId(placemark->osmData().nodeReference(line->last()));
int chunksRemoved;
if (chunk->first() != chunk->last()) {
diff --git a/tools/vectorosm-tilecreator/WayConcatenator.h b/tools/vectorosm-tilecreator/WayConcatenator.h
index 3a95674..bc75cc0 100644
--- a/tools/vectorosm-tilecreator/WayConcatenator.h
+++ b/tools/vectorosm-tilecreator/WayConcatenator.h
@@ -27,6 +27,7 @@ public:
int originalWays() const;
int mergedWays() const;
+ static qint64 osmId(const OsmPlacemarkData &osmData);
private:
void createWayChunk(const PlacemarkPtr &placemark, qint64 firstId, qint64 lastId);