diff --git a/tools/vectorosm-tilecreator/WayChunk.cpp b/tools/vectorosm-tilecreator/WayChunk.cpp index c3f098512..3e95f3574 100644 --- a/tools/vectorosm-tilecreator/WayChunk.cpp +++ b/tools/vectorosm-tilecreator/WayChunk.cpp @@ -1,105 +1,116 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2016 Akshat Tandon // #include #include #include #include "WayChunk.h" #include "GeoDataCoordinates.h" #include "GeoDataPlacemark.h" #include "GeoDataLineString.h" #include "OsmPlacemarkData.h" namespace Marble { -WayChunk::WayChunk(const PlacemarkPtr &placemark, qint64 first, qint64 last) +WayChunk::WayChunk(const PlacemarkPtr &placemark, qint64 first, qint64 last) : + m_first(first), + m_last(last), + m_visualCategory(placemark->visualCategory()), + m_isTunnel(isTunnel(placemark->osmData())) { m_wayList.append(placemark); - m_first = first; - m_last = last; - m_visualCategory = placemark->visualCategory(); } WayChunk::~WayChunk() { } qint64 WayChunk::first() const { return m_first; } qint64 WayChunk::last() const { return m_last; } void WayChunk::append(const PlacemarkPtr &placemark, qint64 last) { m_wayList.append(placemark); m_last = last; } void WayChunk::prepend(const PlacemarkPtr &placemark, qint64 first) { m_wayList.prepend(placemark); m_first = first; } void WayChunk::append(const WayChunk::Ptr &chunk) { m_wayList << chunk->m_wayList; m_last = chunk->last(); } WayChunk::PlacemarkPtr WayChunk::merge() { Q_ASSERT(!m_wayList.isEmpty()); PlacemarkPtr placemark = PlacemarkPtr(new GeoDataPlacemark(*(m_wayList.first()))); GeoDataLineString *line = static_cast(placemark->geometry()); QVector::iterator itr = m_wayList.begin(); QVector::iterator itrEnd = m_wayList.end(); ++itr; for (; itr != itrEnd; ++itr) { GeoDataLineString *currentLine = static_cast( (*itr)->geometry() ); currentLine->remove(0); (*line) << *currentLine; } return placemark; } void WayChunk::reverse() { std::reverse(m_wayList.begin(), m_wayList.end()); QVector::iterator itr = m_wayList.begin(); for (; itr != m_wayList.end(); ++itr) { GeoDataLineString *line = static_cast((*itr)->geometry()); line->reverse(); } qSwap(m_first, m_last); } int WayChunk::size() const { return m_wayList.size(); } bool WayChunk::concatPossible(const GeoDataPlacemark &placemark) const { const GeoDataPlacemark::GeoDataVisualCategory category = placemark.visualCategory(); - return (category == m_visualCategory); + return category == m_visualCategory && isTunnel(placemark.osmData()) == m_isTunnel; +} + +bool WayChunk::isTunnel(const OsmPlacemarkData &osmData) const +{ + if (osmData.containsTagKey(QStringLiteral("tunnel")) && + !osmData.containsTag(QStringLiteral("tunnel"), QStringLiteral("no"))) { + return true; + } + + return osmData.containsTag(QStringLiteral("covered"), QStringLiteral("yes")); } } diff --git a/tools/vectorosm-tilecreator/WayChunk.h b/tools/vectorosm-tilecreator/WayChunk.h index 0d3017c9c..f2384af4b 100644 --- a/tools/vectorosm-tilecreator/WayChunk.h +++ b/tools/vectorosm-tilecreator/WayChunk.h @@ -1,58 +1,61 @@ // // This file is part of the Marble Virtual Globe. // // This program is free software licensed under the GNU LGPL. You can // find a copy of this license in LICENSE.txt in the top directory of // the source code. // // Copyright 2016 Akshat Tandon // #ifndef MARBLE_WAYCHUNK_H #define MARBLE_WAYCHUNK_H #include "GeoDataPlacemark.h" #include #include namespace Marble { class GeoDataPlacemark; class WayChunk { private: typedef QSharedPointer PlacemarkPtr; public: typedef QSharedPointer Ptr; WayChunk(const PlacemarkPtr &placemark, qint64 first, qint64 last ); ~WayChunk(); void append(const PlacemarkPtr &placemark, qint64 last); void append(const Ptr &chunk); void prepend(const PlacemarkPtr & placemark, qint64 first); /* * Creates a new placemark object by concatenating all the linsetrings which exist in the WayChunk * Caller has the responsibility of deleting the object. */ PlacemarkPtr merge(); qint64 first() const; qint64 last() const; void reverse(); int size() const; bool concatPossible(const GeoDataPlacemark &placemark) const; private: + bool isTunnel(const OsmPlacemarkData &osmData) const; + QVector m_wayList; qint64 m_first; qint64 m_last; GeoDataPlacemark::GeoDataVisualCategory m_visualCategory; + bool m_isTunnel; }; } #endif