| 2996 | } |
| 2997 | |
| 2998 | osm::Editor::SaveResult Framework::SaveEditedMapObject(osm::EditableMapObject emo) |
| 2999 | { |
| 3000 | auto & editor = osm::Editor::Instance(); |
| 3001 | |
| 3002 | // Update EditJournal |
| 3003 | osm::EditableMapObject unedited_emo; |
| 3004 | if (emo.GetEditingLifecycle() == osm::EditingLifecycle::CREATED && emo.GetJournal().GetJournal().size() == 1) |
| 3005 | unedited_emo = {}; |
| 3006 | else |
| 3007 | CHECK(GetEditableMapObject(emo.GetID(), unedited_emo), ("Loading unedited EditableMapObject failed.")); |
| 3008 | |
| 3009 | emo.LogDiffInJournal(unedited_emo); |
| 3010 | |
| 3011 | ms::LatLon issueLatLon; |
| 3012 | |
| 3013 | auto shouldNotify = false; |
| 3014 | // Notify if a poi address and it's hosting building address differ. |
| 3015 | do |
| 3016 | { |
| 3017 | auto const isCreatedFeature = editor.IsCreatedFeature(emo.GetID()); |
| 3018 | |
| 3019 | FeaturesLoaderGuard g(m_featuresFetcher.GetDataSource(), emo.GetID().m_mwmId); |
| 3020 | std::unique_ptr<FeatureType> originalFeature; |
| 3021 | if (!isCreatedFeature) |
| 3022 | { |
| 3023 | originalFeature = g.GetOriginalFeatureByIndex(emo.GetID().m_index); |
| 3024 | if (!originalFeature) |
| 3025 | return osm::Editor::SaveResult::NoUnderlyingMapError; |
| 3026 | } |
| 3027 | else |
| 3028 | { |
| 3029 | originalFeature = FeatureType::CreateFromMapObject(emo); |
| 3030 | } |
| 3031 | |
| 3032 | // Handle only pois. |
| 3033 | if (ftypes::IsBuildingChecker::Instance()(*originalFeature)) |
| 3034 | break; |
| 3035 | |
| 3036 | auto const hostingBuildingFid = FindBuildingAtPoint(feature::GetCenter(*originalFeature)); |
| 3037 | // The is no building to take address from. Fallback to simple saving. |
| 3038 | if (!hostingBuildingFid.IsValid()) |
| 3039 | break; |
| 3040 | |
| 3041 | auto hostingBuildingFeature = g.GetFeatureByIndex(hostingBuildingFid.m_index); |
| 3042 | if (!hostingBuildingFeature) |
| 3043 | break; |
| 3044 | |
| 3045 | issueLatLon = mercator::ToLatLon(feature::GetCenter(*hostingBuildingFeature)); |
| 3046 | |
| 3047 | search::ReverseGeocoder::Address hostingBuildingAddress; |
| 3048 | search::ReverseGeocoder const coder(m_featuresFetcher.GetDataSource()); |
| 3049 | // The is no address to take from a hosting building. Fallback to simple saving. |
| 3050 | if (!coder.GetExactAddress(*hostingBuildingFeature, hostingBuildingAddress)) |
| 3051 | break; |
| 3052 | |
| 3053 | string originalFeatureStreet; |
| 3054 | if (!isCreatedFeature) |
| 3055 | originalFeatureStreet = coder.GetOriginalFeatureStreetName(originalFeature->GetID()); |
no test coverage detected