| 530 | } |
| 531 | |
| 532 | void 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 | } |