summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-11-13 17:17:48 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-11-13 17:17:48 (GMT)
commite2ed541fe4fe43cb5b7976534e3f353df759dfe2 (patch)
treed90d63146524e5790d9ae1bac5fe488624bed125
parent9d845f69cdd8cdfde9d4cb0a0aa469aa5651d733 (diff)
Assign to the correct osm placemark data. Do not re-use original ids.
Re-using the original osm ids can create duplicate ids in the same tile, which results in information loss during writing. Now the original osm id is stored in the mx:oid osm tag to use it later on for patching line strings, linear rings and polygons across tiles.
-rw-r--r--tools/vectorosm-tilecreator/VectorClipper.cpp35
-rw-r--r--tools/vectorosm-tilecreator/VectorClipper.h2
2 files changed, 21 insertions, 16 deletions
diff --git a/tools/vectorosm-tilecreator/VectorClipper.cpp b/tools/vectorosm-tilecreator/VectorClipper.cpp
index eaf8412..d28b0ba 100644
--- a/tools/vectorosm-tilecreator/VectorClipper.cpp
+++ b/tools/vectorosm-tilecreator/VectorClipper.cpp
@@ -437,16 +437,19 @@ void VectorClipper::clipPolygon(const GeoDataPlacemark *placemark, const Clipper
foreach(const auto &path, paths) {
GeoDataPlacemark* newPlacemark = new GeoDataPlacemark;
GeoDataLinearRing outerRing;
+ OsmPlacemarkData const & placemarkOsmData = placemark->osmData();
+ OsmPlacemarkData & newPlacemarkOsmData = newPlacemark->osmData();
int index = -1;
- auto const & osmData = placemark->osmData().memberReference(index);
+ OsmPlacemarkData const & outerRingOsmData = placemarkOsmData.memberReference(index);
+ OsmPlacemarkData & newOuterRingOsmData = newPlacemarkOsmData.memberReference(index);
QVector<int> borderPoints;
int nodeIndex = 0;
foreach(const auto &point, path) {
GeoDataCoordinates const coordinates = point.coordinates();
outerRing << coordinates;
- auto const originalOsmData = osmData.nodeReference(coordinates);
+ auto const originalOsmData = outerRingOsmData.nodeReference(coordinates);
if (originalOsmData.id() > 0) {
- newPlacemark->osmData().addNodeReference(coordinates, originalOsmData);
+ newOuterRingOsmData.addNodeReference(coordinates, originalOsmData);
}
if (!point.isInside(minX, maxX, minY, maxY)) {
borderPoints << nodeIndex;
@@ -457,15 +460,15 @@ void VectorClipper::clipPolygon(const GeoDataPlacemark *placemark, const Clipper
GeoDataPolygon* newPolygon = new GeoDataPolygon;
newPolygon->setOuterBoundary(outerRing);
newPlacemark->setGeometry(newPolygon);
- newPlacemark->osmData().setId(osmData.id());
- OsmObjectManager::initializeOsmData(newPlacemark);
- copyTags(*placemark, *newPlacemark);
- setBorderPoints(newPlacemark->osmData(), borderPoints, outerRing.size());
- copyTags(osmData.memberReference(index), newPlacemark->osmData().memberReference(index));
+ newPlacemarkOsmData.addTag(QStringLiteral("mx:oid"), QString::number(placemarkOsmData.id()));
+ copyTags(placemarkOsmData, newPlacemarkOsmData);
+ copyTags(outerRingOsmData, newOuterRingOsmData);
+ newOuterRingOsmData.addTag(QStringLiteral("mx:oid"), QString::number(outerRingOsmData.id()));
+ setBorderPoints(newOuterRingOsmData, borderPoints, outerRing.size());
auto const & innerBoundaries = polygon->innerBoundaries();
for (index = 0; index < innerBoundaries.size(); ++index) {
- auto const & osmData = placemark->osmData().memberReference(index);
+ auto const & innerRingOsmData = placemarkOsmData.memberReference(index);
clipper.Clear();
clipper.AddPath(path, ptClip, true);
Path innerPath;
@@ -476,15 +479,17 @@ void VectorClipper::clipPolygon(const GeoDataPlacemark *placemark, const Clipper
Paths innerPaths;
clipper.Execute(ctIntersection, innerPaths);
foreach(auto const &innerPath, innerPaths) {
+ int const newIndex = newPolygon->innerBoundaries().size();
+ auto & newInnerRingOsmData = newPlacemarkOsmData.memberReference(newIndex);
GeoDataLinearRing innerRing;
borderPoints.clear();
nodeIndex = 0;
foreach(const auto &point, innerPath) {
GeoDataCoordinates const coordinates = point.coordinates();
innerRing << coordinates;
- auto const originalOsmData = osmData.nodeReference(coordinates);
+ auto const originalOsmData = innerRingOsmData.nodeReference(coordinates);
if (originalOsmData.id() > 0) {
- newPlacemark->osmData().addNodeReference(coordinates, originalOsmData);
+ newInnerRingOsmData.addNodeReference(coordinates, originalOsmData);
}
if (!point.isInside(minX, maxX, minY, maxY)) {
borderPoints << nodeIndex;
@@ -492,13 +497,13 @@ void VectorClipper::clipPolygon(const GeoDataPlacemark *placemark, const Clipper
++nodeIndex;
}
newPolygon->appendInnerBoundary(innerRing);
- OsmObjectManager::initializeOsmData(newPlacemark);
- int const newIndex = newPolygon->innerBoundaries().size()-1;
- copyTags(placemark->osmData().memberReference(index), newPlacemark->osmData().memberReference(newIndex));
- setBorderPoints(newPlacemark->osmData().memberReference(newIndex), borderPoints, innerRing.size());
+ newInnerRingOsmData.addTag(QStringLiteral("mx:oid"), QString::number(innerRingOsmData.id()));
+ copyTags(innerRingOsmData, newInnerRingOsmData);
+ setBorderPoints(newInnerRingOsmData, borderPoints, innerRing.size());
}
}
+ OsmObjectManager::initializeOsmData(newPlacemark);
document->append(newPlacemark);
}
}
diff --git a/tools/vectorosm-tilecreator/VectorClipper.h b/tools/vectorosm-tilecreator/VectorClipper.h
index fe8a859..c23ba2d 100644
--- a/tools/vectorosm-tilecreator/VectorClipper.h
+++ b/tools/vectorosm-tilecreator/VectorClipper.h
@@ -92,7 +92,7 @@ private:
}
newPlacemark->setGeometry(newRing);
- newPlacemark->osmData().setId(placemark->osmData().id());
+ newPlacemark->osmData().addTag(QStringLiteral("mx:oid"), QString::number(placemark->osmData().id()));
copyTags(*placemark, *newPlacemark);
setBorderPoints(newPlacemark->osmData(), borderPoints, newRing->size());
OsmObjectManager::initializeOsmData(newPlacemark);