From 3c9c54eda61d84609bdcf5f298d0abb26e3f4281 Mon Sep 17 00:00:00 2001 From: map-per Date: Sat, 13 Apr 2024 18:43:49 +0200 Subject: [PATCH] [editor] Fixed bug overwriting existing features Signed-off-by: map-per --- editor/changeset_wrapper.cpp | 5 +++++ editor/changeset_wrapper.hpp | 3 +++ editor/osm_editor.cpp | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/editor/changeset_wrapper.cpp b/editor/changeset_wrapper.cpp index 7ca9f97be6..3850840e87 100644 --- a/editor/changeset_wrapper.cpp +++ b/editor/changeset_wrapper.cpp @@ -247,6 +247,11 @@ void ChangesetWrapper::Delete(editor::XMLFeature node) m_deleted_types[GetTypeForFeature(node)]++; } +void ChangesetWrapper::AddChangesetTag(std::string key, std::string value) +{ + m_changesetComments.emplace(std::move(key), std::move(value)); +} + std::string ChangesetWrapper::TypeCountToString(TypeCount const & typeCount) { if (typeCount.empty()) diff --git a/editor/changeset_wrapper.hpp b/editor/changeset_wrapper.hpp index 2ce690b3a8..e8974dfa45 100644 --- a/editor/changeset_wrapper.hpp +++ b/editor/changeset_wrapper.hpp @@ -49,6 +49,9 @@ public: /// Throws exceptions from above list. void Delete(editor::XMLFeature node); + /// Add a tag to the changeset + void AddChangesetTag(std::string key, std::string value); + /// Allows to see exception details in OSM changesets for easier debugging. void SetErrorDescription(std::string const & error); diff --git a/editor/osm_editor.cpp b/editor/osm_editor.cpp index fc8c6995e0..c0809afc49 100644 --- a/editor/osm_editor.cpp +++ b/editor/osm_editor.cpp @@ -646,8 +646,10 @@ void Editor::UploadChanges(string const & oauthToken, ChangesetTags tags, } else { - LOG(LDEBUG, ("Create case: uploading patched feature", osmFeature)); - changeset.Modify(osmFeature); + LOG(LDEBUG, ("Create case: uploading new feature", feature)); + // There is another node nearby, but it is saver to upload a new node (#2298). + changeset.AddChangesetTag("info:feature_close_by", "yes"); + changeset.Create(feature); } } catch (ChangesetWrapper::OsmObjectWasDeletedException const &)