summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-09-24 17:49:19 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-09-24 17:49:19 (GMT)
commitbacea90c3ef5bf5605d28e70568a86df3cab1403 (patch)
tree2cbbd6634d28387e89eb079981456d551a6337d7
parent996e761ad772c63ce8226a5db2d10024649f1c66 (diff)
Create multiple placemarks for multipolygons with several outer ways
-rw-r--r--src/plugins/runner/osm/OsmRelation.cpp49
1 files changed, 27 insertions, 22 deletions
diff --git a/src/plugins/runner/osm/OsmRelation.cpp b/src/plugins/runner/osm/OsmRelation.cpp
index d13c6c1..654285c 100644
--- a/src/plugins/runner/osm/OsmRelation.cpp
+++ b/src/plugins/runner/osm/OsmRelation.cpp
@@ -65,12 +65,6 @@ void OsmRelation::create(GeoDataDocument *document, OsmWays &ways, const OsmNode
return;
}
- if (outer.size() > 1) {
- /** @todo: Merge ways with common start/end, create multipolygon geometries for ones with multiple outer rings */
- mDebug() << "Polygons with " << outer.size() << " ways are not yet supported";
- return;
- }
-
GeoDataFeature::GeoDataVisualCategory outerCategory = StyleBuilder::determineVisualCategory(m_osmData);
if (outerCategory == GeoDataFeature::None) {
// Try to determine the visual category from the relation members
@@ -136,23 +130,34 @@ void OsmRelation::create(GeoDataDocument *document, OsmWays &ways, const OsmNode
}
}
- GeoDataPolygon *polygon = new GeoDataPolygon;
- polygon->setOuterBoundary(outer[0]);
- foreach(const GeoDataLinearRing &ring, inner) {
- polygon->appendInnerBoundary(ring);
- }
+ bool const hasMultipleOuterRings = outer.size() > 1;
+ foreach(auto const &outerRing, outer) {
+ GeoDataPolygon *polygon = new GeoDataPolygon;
+ polygon->setOuterBoundary(outerRing);
+ foreach(const GeoDataLinearRing &innerRing, inner) {
+ if (!innerRing.isEmpty() && outerRing.contains(innerRing.first())) {
+ polygon->appendInnerBoundary(innerRing);
+ }
+ }
+
+ GeoDataPlacemark *placemark = new GeoDataPlacemark;
+ placemark->setName(m_osmData.tagValue(QStringLiteral("name")));
+ placemark->setVisualCategory(outerCategory);
+ placemark->setStyle( GeoDataStyle::Ptr() );
+ placemark->setVisible(outerCategory != GeoDataFeature::None);
+ placemark->setGeometry(polygon);
+ if (hasMultipleOuterRings) {
+ /** @TODO Use a GeoDataMultiGeometry to keep the ID? */
+ osmData.setId(0);
+ OsmObjectManager::initializeOsmData(placemark);
+ } else {
+ OsmObjectManager::registerId(osmData.id());
+ }
+ placemark->setOsmData(osmData);
+ usedNodes |= outerNodes;
- GeoDataPlacemark *placemark = new GeoDataPlacemark;
- placemark->setName(m_osmData.tagValue(QStringLiteral("name")));
- placemark->setVisualCategory(outerCategory);
- placemark->setStyle( GeoDataStyle::Ptr() );
- placemark->setVisible(outerCategory != GeoDataFeature::None);
- placemark->setGeometry(polygon);
- placemark->setOsmData(osmData);
- usedNodes |= outerNodes;
-
- OsmObjectManager::registerId( osmData.id() );
- document->append(placemark);
+ document->append(placemark);
+ }
}
QList<GeoDataLinearRing> OsmRelation::rings(const QStringList &roles, const OsmWays &ways, const OsmNodes &nodes, QSet<qint64> &usedNodes, QSet<qint64> &usedWays) const