| 869 | } |
| 870 | |
| 871 | void EditableMapObject::LogDiffInJournal(EditableMapObject const & unedited_emo) |
| 872 | { |
| 873 | LOG(LDEBUG, ("Executing LogDiffInJournal")); |
| 874 | |
| 875 | // Capture the initial size of the journal to detect if changes occur later |
| 876 | auto const initialJournalSize = m_journal.GetJournal().size(); |
| 877 | |
| 878 | // Name |
| 879 | for (localisation::Language const & language : localisation::GetSupportedLanguages()) |
| 880 | { |
| 881 | localisation::LanguageIndex const languageIndex = localisation::ConvertLanguageCodeToLanguageIndex(language.m_languageCode); |
| 882 | std::string_view new_name, old_name; |
| 883 | UNUSED_VALUE(m_name.GetString(languageIndex, new_name)); |
| 884 | UNUSED_VALUE(unedited_emo.GetNameMultilang().GetString(languageIndex, old_name)); |
| 885 | |
| 886 | if (new_name != old_name) |
| 887 | { |
| 888 | m_journal.AddTagChange(StringUtf8Multilang::GetOSMTagByCode(languageIndex), std::string(old_name), |
| 889 | std::string(new_name)); |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | // Address |
| 894 | if (m_street.m_defaultName != unedited_emo.GetStreet().m_defaultName) |
| 895 | m_journal.AddTagChange("addr:street", unedited_emo.GetStreet().m_defaultName, m_street.m_defaultName); |
| 896 | |
| 897 | if (m_houseNumber != unedited_emo.GetHouseNumber()) |
| 898 | m_journal.AddTagChange("addr:housenumber", unedited_emo.GetHouseNumber(), m_houseNumber); |
| 899 | |
| 900 | // Metadata |
| 901 | for (uint8_t i = 0; i < static_cast<uint8_t>(feature::Metadata::FMD_COUNT); ++i) |
| 902 | { |
| 903 | auto const type = static_cast<feature::Metadata::EType>(i); |
| 904 | |
| 905 | // CHARGE_SOCKETS have multiple keys/values; handled separately further down |
| 906 | if (type == feature::Metadata::FMD_CHARGE_SOCKETS) |
| 907 | continue; |
| 908 | std::string_view const & value = GetMetadata(type); |
| 909 | std::string_view const & old_value = unedited_emo.GetMetadata(type); |
| 910 | |
| 911 | if (value != old_value) |
| 912 | m_journal.AddTagChange(ToString(type), std::string(old_value), std::string(value)); |
| 913 | } |
| 914 | |
| 915 | // cuisine and diet |
| 916 | std::vector<std::string> new_cuisines = GetCuisines(); |
| 917 | std::vector<std::string> old_cuisines = unedited_emo.GetCuisines(); |
| 918 | |
| 919 | auto const findAndErase = [](std::vector<std::string> & cuisinesPtr, std::string_view s) |
| 920 | { |
| 921 | auto it = std::find(cuisinesPtr.begin(), cuisinesPtr.end(), s); |
| 922 | if (it != cuisinesPtr.end()) |
| 923 | { |
| 924 | cuisinesPtr.erase(it); |
| 925 | return "yes"; |
| 926 | } |
| 927 | return ""; |
| 928 | }; |