Commit 06da643b authored by Volker Krause's avatar Volker Krause Committed by Torsten Rahn
Browse files

Retain node OSM data when reading multi-polygons

Besides not losing tags on such nodes, this also retains OSM ids in all
cases now, which simplifies geometry reassembly considerably, as this
gives us a lot fewer nodes to consider for merging.
parent aca42f45
...@@ -221,16 +221,20 @@ OsmRelation::OsmRings OsmRelation::rings(const QStringList &roles, const OsmWays ...@@ -221,16 +221,20 @@ OsmRelation::OsmRings OsmRelation::rings(const QStringList &roles, const OsmWays
unclosedWays.append(way); unclosedWays.append(way);
continue; continue;
} }
OsmPlacemarkData placemarkData = way.osmData();
for(auto id: way.references()) { for(auto id: way.references()) {
if (!nodes.contains(id)) { if (!nodes.contains(id)) {
// A node is missing. Return nothing. // A node is missing. Return nothing.
return OsmRings(); return OsmRings();
} }
ring << nodes[id].coordinates(); const auto &node = nodes[id];
ring << node.coordinates();
placemarkData.addNodeReference(node.coordinates(), node.osmData());
} }
Q_ASSERT(ways.contains(wayId)); Q_ASSERT(ways.contains(wayId));
currentWays << wayId; currentWays << wayId;
result << OsmRing(GeoDataLinearRing(ring.optimized()), way.osmData()); result << OsmRing(GeoDataLinearRing(ring.optimized()), placemarkData);
} }
if( !unclosedWays.isEmpty() ) { if( !unclosedWays.isEmpty() ) {
...@@ -239,6 +243,7 @@ OsmRelation::OsmRings OsmRelation::rings(const QStringList &roles, const OsmWays ...@@ -239,6 +243,7 @@ OsmRelation::OsmRings OsmRelation::rings(const QStringList &roles, const OsmWays
GeoDataLinearRing ring; GeoDataLinearRing ring;
qint64 firstReference = unclosedWays.first().references().first(); qint64 firstReference = unclosedWays.first().references().first();
qint64 lastReference = firstReference; qint64 lastReference = firstReference;
OsmPlacemarkData placemarkData;
bool ok = true; bool ok = true;
while( ok ) { while( ok ) {
ok = false; ok = false;
...@@ -256,7 +261,9 @@ OsmRelation::OsmRings OsmRelation::rings(const QStringList &roles, const OsmWays ...@@ -256,7 +261,9 @@ OsmRelation::OsmRings OsmRelation::rings(const QStringList &roles, const OsmWays
return OsmRings(); return OsmRings();
} }
if ( id != lastReference ) { if ( id != lastReference ) {
ring << nodes[id].coordinates(); const auto &node = nodes[id];
ring << node.coordinates();
placemarkData.addNodeReference(node.coordinates(), node.osmData());
currentNodes << id; currentNodes << id;
} }
} }
...@@ -277,7 +284,7 @@ OsmRelation::OsmRings OsmRelation::rings(const QStringList &roles, const OsmWays ...@@ -277,7 +284,7 @@ OsmRelation::OsmRings OsmRelation::rings(const QStringList &roles, const OsmWays
return OsmRings(); return OsmRings();
} else { } else {
/** @todo Merge tags common to all rings into the new osm data? */ /** @todo Merge tags common to all rings into the new osm data? */
result << OsmRing(GeoDataLinearRing(ring.optimized()), OsmPlacemarkData()); result << OsmRing(GeoDataLinearRing(ring.optimized()), placemarkData);
} }
} }
} }
......
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