Commit 90cfcdd5 authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Don't create further items from ways that are part of multipolygons

parent c3c21ad6
......@@ -114,8 +114,12 @@ GeoDataDocument *OsmParser::createDocument(OsmNodes &nodes, OsmWays &ways, OsmRe
backgroundStyle->setId( "background" );
document->addStyle( backgroundStyle );
QSet<qint64> usedWays;
foreach(OsmRelation const &relation, relations) {
relation.create(document, ways, nodes);
relation.create(document, ways, nodes, usedWays);
}
foreach(qint64 id, usedWays) {
ways.remove(id);
}
foreach(OsmWay const &way, ways) {
......
......@@ -41,14 +41,14 @@ void OsmRelation::parseMember(const QXmlStreamAttributes &attributes)
m_members << member;
}
void OsmRelation::create(GeoDataDocument *document, const OsmWays &ways, const OsmNodes &nodes) const
void OsmRelation::create(GeoDataDocument *document, const OsmWays &ways, const OsmNodes &nodes, QSet<qint64> &usedWays) const
{
if (!m_osmData.containsTag("type", "multipolygon")) {
return;
}
QStringList const outerRoles = QStringList() << "outer" << "";
QList<GeoDataLinearRing> outer = rings(outerRoles, ways, nodes);
QList<GeoDataLinearRing> outer = rings(outerRoles, ways, nodes, usedWays);
if (outer.isEmpty()) {
return;
} else if (outer.size() > 1) {
......@@ -69,7 +69,7 @@ void OsmRelation::create(GeoDataDocument *document, const OsmWays &ways, const O
// placemark->osmData().addMemberReference(-1, );
QStringList const innerRoles = QStringList() << "inner";
QList<GeoDataLinearRing> inner = rings(innerRoles, ways, nodes);
QList<GeoDataLinearRing> inner = rings(innerRoles, ways, nodes, usedWays);
foreach(const GeoDataLinearRing &ring, inner) {
// @todo: How to get the reference here?
// placemark->osmData().addMemberReference(polygon->innerBoundaries().size(), );
......@@ -81,7 +81,7 @@ void OsmRelation::create(GeoDataDocument *document, const OsmWays &ways, const O
document->append(placemark);
}
QList<GeoDataLinearRing> OsmRelation::rings(const QStringList &roles, const OsmWays &ways, const OsmNodes &nodes) const
QList<GeoDataLinearRing> OsmRelation::rings(const QStringList &roles, const OsmWays &ways, const OsmNodes &nodes, QSet<qint64> &usedWays) const
{
QList<qint64> roleMembers;
foreach(const OsmMember &member, m_members) {
......@@ -110,6 +110,7 @@ QList<GeoDataLinearRing> OsmRelation::rings(const QStringList &roles, const OsmW
}
ring << nodes[id].coordinates();
}
usedWays << wayId;
result << ring;
}
......
......@@ -19,6 +19,7 @@
#include <QString>
#include <QXmlStreamAttributes>
#include <QSet>
namespace Marble {
......@@ -30,7 +31,7 @@ public:
const OsmPlacemarkData & osmData() const;
void create(GeoDataDocument* document, const OsmWays &ways, const OsmNodes &nodes) const;
void create(GeoDataDocument* document, const OsmWays &ways, const OsmNodes &nodes, QSet<qint64> &usedWays) const;
private:
struct OsmMember
......@@ -42,7 +43,7 @@ private:
OsmMember();
};
QList<GeoDataLinearRing> rings(const QStringList &roles, const OsmWays &ways, const OsmNodes &nodes) const;
QList<GeoDataLinearRing> rings(const QStringList &roles, const OsmWays &ways, const OsmNodes &nodes, QSet<qint64> &usedWays) const;
OsmPlacemarkData m_osmData;
QVector<OsmMember> m_members;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment