[editor] Change xml root to comaps

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-05-19 20:55:08 +07:00
committed by Konstantin Pastbin
parent 54ab965822
commit 2b7246d463
5 changed files with 10 additions and 13 deletions

View File

@@ -87,7 +87,7 @@ bool TypeDescriptionFromXml(pugi::xml_node const & root, pugi::xml_node const &
auto const node = xNode.node(); auto const node = xNode.node();
std::string const groupName = node.attribute("group").value(); std::string const groupName = node.attribute("group").value();
std::string const xpath = "/omaps/editor/fields/field_group[@name='" + groupName + "']"; std::string const xpath = "/comaps/editor/fields/field_group[@name='" + groupName + "']";
auto const group = root.select_node(xpath.data()).node(); auto const group = root.select_node(xpath.data()).node();
ASSERT(group, ("No such group", groupName)); ASSERT(group, ("No such group", groupName));
@@ -114,7 +114,7 @@ bool TypeDescriptionFromXml(pugi::xml_node const & root, pugi::xml_node const &
std::vector<pugi::xml_node> GetPrioritizedTypes(pugi::xml_node const & node) std::vector<pugi::xml_node> GetPrioritizedTypes(pugi::xml_node const & node)
{ {
std::vector<pugi::xml_node> result; std::vector<pugi::xml_node> result;
for (auto const & xNode : node.select_nodes("/omaps/editor/types/type[@id]")) for (auto const & xNode : node.select_nodes("/comaps/editor/types/type[@id]"))
result.push_back(xNode.node()); result.push_back(xNode.node());
stable_sort(begin(result), end(result), stable_sort(begin(result), end(result),
[](pugi::xml_node const & lhs, pugi::xml_node const & rhs) { [](pugi::xml_node const & lhs, pugi::xml_node const & rhs) {
@@ -168,7 +168,7 @@ bool EditorConfig::GetTypeDescription(std::vector<std::string> classificatorType
std::vector<std::string> EditorConfig::GetTypesThatCanBeAdded() const std::vector<std::string> EditorConfig::GetTypesThatCanBeAdded() const
{ {
auto const xpathResult = auto const xpathResult =
m_document.select_nodes("/omaps/editor/types/type[not(@can_add='no' or @editable='no')]"); m_document.select_nodes("/comaps/editor/types/type[not(@can_add='no' or @editable='no')]");
std::vector<std::string> result; std::vector<std::string> result;
for (auto const & xNode : xpathResult) for (auto const & xNode : xpathResult)

View File

@@ -16,9 +16,9 @@ using platform::tests_support::ScopedFile;
void CheckGeneralTags(pugi::xml_document const & doc) void CheckGeneralTags(pugi::xml_document const & doc)
{ {
auto const types = doc.select_nodes("/omaps/editor/types"); auto const types = doc.select_nodes("/comaps/editor/types");
TEST(!types.empty(), ()); TEST(!types.empty(), ());
auto const fields = doc.select_nodes("/omaps/editor/fields"); auto const fields = doc.select_nodes("/comaps/editor/fields");
TEST(!fields.empty(), ()); TEST(!fields.empty(), ());
} }

View File

@@ -162,7 +162,7 @@ void GenerateUploadedFeature(MwmSet::MwmId const & mwmId,
osm::EditableMapObject const & emo, osm::EditableMapObject const & emo,
pugi::xml_document & out) pugi::xml_document & out)
{ {
pugi::xml_node root = out.append_child("omaps"); pugi::xml_node root = out.append_child("comaps");
root.append_attribute("format_version") = 1; root.append_attribute("format_version") = 1;
pugi::xml_node mwmNode = root.append_child("mwm"); pugi::xml_node mwmNode = root.append_child("mwm");

View File

@@ -82,7 +82,7 @@ UNIT_TEST(OSM_ServerAPI_ChangesetAndNode)
XMLFeature node(XMLFeature::Type::Node); XMLFeature node(XMLFeature::Type::Node);
ServerApi06 const api = CreateAPI(); ServerApi06 const api = CreateAPI();
uint64_t changeSetId = api.CreateChangeSet({{"created_by", "OMaps Unit Test"}, uint64_t changeSetId = api.CreateChangeSet({{"created_by", "CoMaps Unit Test"},
{"comment", "For test purposes only."}}); {"comment", "For test purposes only."}});
auto const changesetCloser = [&]() { api.CloseChangeSet(changeSetId); }; auto const changesetCloser = [&]() { api.CloseChangeSet(changeSetId); };
@@ -110,7 +110,7 @@ UNIT_TEST(OSM_ServerAPI_ChangesetAndNode)
TEST_EQUAL(node.GetAttribute("version"), "2", ()); TEST_EQUAL(node.GetAttribute("version"), "2", ());
// All tags must be specified, because there is no merging of old and new tags. // All tags must be specified, because there is no merging of old and new tags.
api.UpdateChangeSet(changeSetId, {{"created_by", "OMaps Unit Test"}, api.UpdateChangeSet(changeSetId, {{"created_by", "CoMaps Unit Test"},
{"comment", "For test purposes only (updated)."}}); {"comment", "For test purposes only (updated)."}});
// To retrieve created node, changeset should be closed first. // To retrieve created node, changeset should be closed first.
@@ -124,7 +124,7 @@ UNIT_TEST(OSM_ServerAPI_ChangesetAndNode)
TEST_EQUAL(node.GetAttribute("id"), features[0].GetAttribute("id"), ()); TEST_EQUAL(node.GetAttribute("id"), features[0].GetAttribute("id"), ());
// Cleanup - delete unit test node from the server. // Cleanup - delete unit test node from the server.
changeSetId = api.CreateChangeSet({{"created_by", "OMaps Unit Test"}, changeSetId = api.CreateChangeSet({{"created_by", "CoMaps Unit Test"},
{"comment", "For test purposes only."}}); {"comment", "For test purposes only."}});
SCOPE_GUARD(guard, changesetCloser); SCOPE_GUARD(guard, changesetCloser);
// New changeset has new id. // New changeset has new id.

View File

@@ -38,7 +38,7 @@ using std::make_shared, std::string;
namespace namespace
{ {
constexpr char const * kXmlRootNode = "omaps"; constexpr char const * kXmlRootNode = "comaps";
constexpr char const * kXmlMwmNode = "mwm"; constexpr char const * kXmlMwmNode = "mwm";
constexpr char const * kDeleteSection = "delete"; constexpr char const * kDeleteSection = "delete";
constexpr char const * kModifySection = "modify"; constexpr char const * kModifySection = "modify";
@@ -168,9 +168,6 @@ void Editor::LoadEdits()
auto loadedFeatures = make_shared<FeaturesContainer>(); auto loadedFeatures = make_shared<FeaturesContainer>();
auto rootNode = doc.child(kXmlRootNode); auto rootNode = doc.child(kXmlRootNode);
// Migrate clients with an old root node.
if (!rootNode)
rootNode = doc.child("mapsme");
// TODO: Empty rootNode is an OK case for the current logic and unit tests. Check if there is a better way to do it. // TODO: Empty rootNode is an OK case for the current logic and unit tests. Check if there is a better way to do it.
for (auto const & mwm : rootNode.children(kXmlMwmNode)) for (auto const & mwm : rootNode.children(kXmlMwmNode))
{ {