MCPcopy Create free account
hub / github.com/comaps/comaps / SetEditJournal

Method SetEditJournal

libs/editor/xml_feature.cpp:532–589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

530}
531
532void XMLFeature::SetEditJournal(osm::EditJournal const & journal)
533{
534 LOG(LDEBUG, ("Saving Journal:\n", journal.JournalToString()));
535
536 auto const insertEditJournalList = [](pugi::xml_node & xmlNode, std::list<osm::JournalEntry> const & journalList)
537 {
538 xmlNode.append_attribute("version") = "1.0";
539 for (osm::JournalEntry const & entry : journalList)
540 {
541 auto xmlEntry = xmlNode.append_child("entry");
542 xmlEntry.append_attribute("type") = osm::EditJournal::ToString(entry.journalEntryType).data();
543 xmlEntry.append_attribute("timestamp") = base::TimestampToString(entry.timestamp).data();
544
545 auto xmlData = xmlEntry.append_child("data");
546 switch (entry.journalEntryType)
547 {
548 case osm::JournalEntryType::TagModification:
549 {
550 osm::TagModData const & tagModData = std::get<osm::TagModData>(entry.data);
551 xmlData.append_attribute("key") = tagModData.key.data();
552 xmlData.append_attribute("old_value") = tagModData.old_value.data();
553 xmlData.append_attribute("new_value") = tagModData.new_value.data();
554 break;
555 }
556 case osm::JournalEntryType::ObjectCreated:
557 {
558 osm::ObjCreateData const & objCreateData = std::get<osm::ObjCreateData>(entry.data);
559 xmlData.append_attribute("type") = classif().GetReadableObjectName(objCreateData.type).data();
560 xmlData.append_attribute("geomType") = ToString(objCreateData.geomType).data();
561 ms::LatLon ll = mercator::ToLatLon(objCreateData.mercator);
562 xmlData.append_attribute("lat") = strings::to_string_dac(ll.m_lat, kLatLonTolerance).data();
563 xmlData.append_attribute("lon") = strings::to_string_dac(ll.m_lon, kLatLonTolerance).data();
564 break;
565 }
566 case osm::JournalEntryType::LegacyObject:
567 {
568 osm::LegacyObjData const & legacyObjData = std::get<osm::LegacyObjData>(entry.data);
569 xmlData.append_attribute("version") = legacyObjData.version.data();
570 break;
571 }
572 case osm::JournalEntryType::BusinessReplacement:
573 {
574 osm::BusinessReplacementData const & businessReplacementData =
575 std::get<osm::BusinessReplacementData>(entry.data);
576 xmlData.append_attribute("old_type") = classif().GetReadableObjectName(businessReplacementData.old_type).data();
577 xmlData.append_attribute("new_type") = classif().GetReadableObjectName(businessReplacementData.new_type).data();
578 break;
579 }
580 }
581 }
582 };
583
584 auto xmlJournal = GetRootNode().append_child("journal");
585 insertEditJournalList(xmlJournal, journal.GetJournal());
586
587 auto xmlJournalHistory = GetRootNode().append_child("journalHistory");
588 insertEditJournalList(xmlJournalHistory, journal.GetJournalHistory());
589}

Callers 3

SaveMethod · 0.80
GenerateUploadedFeatureFunction · 0.80
UNIT_TESTFunction · 0.80

Calls 7

to_string_dacFunction · 0.85
JournalToStringMethod · 0.80
GetReadableObjectNameMethod · 0.80
ToStringFunction · 0.50
TimestampToStringFunction · 0.50
ToLatLonFunction · 0.50
dataMethod · 0.45

Tested by 2

GenerateUploadedFeatureFunction · 0.64
UNIT_TESTFunction · 0.64