| 973 | } |
| 974 | |
| 975 | void Editor::CreateNote(ms::LatLon const & latLon, FeatureID const & fid, feature::TypesHolder const & holder, |
| 976 | std::string_view defaultName, NoteProblemType type, std::string_view note) |
| 977 | { |
| 978 | CHECK_THREAD_CHECKER(MainThreadChecker, ("")); |
| 979 | |
| 980 | std::ostringstream sstr; |
| 981 | auto canCreate = true; |
| 982 | |
| 983 | switch (type) |
| 984 | { |
| 985 | case NoteProblemType::PlaceDoesNotExist: |
| 986 | { |
| 987 | sstr << "This place does not exist:\n"; |
| 988 | |
| 989 | if (!note.empty()) |
| 990 | sstr << '"' << note << "\"\n"; |
| 991 | |
| 992 | sstr << "A CoMaps user reported that the POI was visible on the map (see snapshot date below), " |
| 993 | "but was not found on the ground.\n"; |
| 994 | auto const features = m_features.Get(); |
| 995 | auto const isCreated = GetFeatureStatusImpl(*features, fid.m_mwmId, fid.m_index) == FeatureStatus::Created; |
| 996 | auto const createdAndUploaded = |
| 997 | (isCreated && AreSomeFeatureChangesUploadedImpl(*features, fid.m_mwmId, fid.m_index)); |
| 998 | CHECK(!isCreated || createdAndUploaded, ()); |
| 999 | |
| 1000 | if (createdAndUploaded) |
| 1001 | canCreate = RemoveFeature(fid); |
| 1002 | else |
| 1003 | canCreate = MarkFeatureAsObsolete(fid); |
| 1004 | |
| 1005 | break; |
| 1006 | } |
| 1007 | case NoteProblemType::General: |
| 1008 | { |
| 1009 | if (!note.empty()) |
| 1010 | sstr << '"' << note << "\"\n"; |
| 1011 | break; |
| 1012 | } |
| 1013 | } |
| 1014 | |
| 1015 | if (!canCreate) |
| 1016 | return; |
| 1017 | |
| 1018 | auto const version = GetMwmCreationTimeByMwmId(fid.m_mwmId); |
| 1019 | auto const strVersion = base::TimestampToString(base::SecondsSinceEpochToTimeT(version)); |
| 1020 | sstr << "OSM snapshot date: " << strVersion << "\n"; |
| 1021 | |
| 1022 | if (defaultName.empty()) |
| 1023 | sstr << "POI has no name\n"; |
| 1024 | else |
| 1025 | sstr << "POI name: " << defaultName << "\n"; |
| 1026 | |
| 1027 | sstr << "POI types:"; |
| 1028 | for (auto const & poiType : holder.ToObjectNames()) |
| 1029 | sstr << ' ' << poiType; |
| 1030 | sstr << "\n"; |
| 1031 | std::cout << "***TEXT*** " << sstr.str(); |
| 1032 | m_notes->CreateNote(latLon, sstr.str()); |
no test coverage detected