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

Method ApplyJournalEntry

libs/indexer/editable_map_object.cpp:762–869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

760}
761
762void EditableMapObject::ApplyJournalEntry(JournalEntry const & entry)
763{
764 LOG(LDEBUG, (osm::EditJournal::ToString(entry)));
765
766 switch (entry.journalEntryType)
767 {
768 case JournalEntryType::TagModification:
769 {
770 TagModData const & tagModData = std::get<TagModData>(entry.data);
771
772 // Metadata
773 MetadataID type;
774 if (feature::Metadata::TypeFromString(tagModData.key, type))
775 {
776 if (type == MetadataID::FMD_CHARGE_SOCKETS)
777 {
778 // Charge sockets need special handling: we need to aggregate the new entry
779 // to existing ones, not just replace the whole string.
780 ChargeSocketsHelper helper(GetChargeSockets());
781 helper.AggregateChargeSocketKey(tagModData.key, tagModData.new_value);
782 m_metadata.Set(type, helper.ToString());
783 }
784 else
785 m_metadata.Set(type, tagModData.new_value);
786
787 if (type == MetadataID::FMD_INTERNET)
788 {
789 uint32_t const wifiType = ftypes::IsWifiChecker::Instance().GetType();
790 if (tagModData.new_value == "wifi")
791 m_types.SafeAdd(wifiType);
792 else
793 m_types.Remove(wifiType);
794 }
795 break;
796 }
797
798 // Names
799 localisation::LanguageIndex languageIndex = StringUtf8Multilang::GetCodeByOSMTag(tagModData.key);
800 if (languageIndex != localisation::kUnsupportedLanguageIndex)
801 {
802 m_name.AddString(languageIndex, tagModData.new_value);
803 break;
804 }
805
806 if (tagModData.key == "addr:street")
807 m_street.m_defaultName = tagModData.new_value;
808
809 else if (tagModData.key == "addr:housenumber")
810 m_houseNumber = tagModData.new_value;
811
812 else if (tagModData.key == "cuisine")
813 {
814 Classificator const & cl = classif();
815 // Remove old cuisine values
816 vector<std::string_view> oldCuisines = strings::Tokenize(tagModData.old_value, ";");
817 for (std::string_view const & cuisine : oldCuisines)
818 m_types.Remove(cl.GetTypeByPath({string_view("cuisine"), cuisine}));
819 // Add new cuisine values

Callers

nothing calls this directly

Calls 12

TypeFromStringFunction · 0.85
SafeAddMethod · 0.80
GetTypeByPathMethod · 0.80
ToStringFunction · 0.70
TokenizeFunction · 0.50
SetMethod · 0.45
ToStringMethod · 0.45
GetTypeMethod · 0.45
RemoveMethod · 0.45
AddStringMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected