| 130 | } |
| 131 | |
| 132 | void Notes::CreateNote(ms::LatLon const & latLon, std::string const & text) |
| 133 | { |
| 134 | if (text.empty()) |
| 135 | { |
| 136 | LOG(LWARNING, ("Attempt to create empty note")); |
| 137 | return; |
| 138 | } |
| 139 | |
| 140 | if (!mercator::ValidLat(latLon.m_lat) || !mercator::ValidLon(latLon.m_lon)) |
| 141 | { |
| 142 | LOG(LWARNING, ("A note attached to a wrong latLon", latLon)); |
| 143 | return; |
| 144 | } |
| 145 | |
| 146 | std::lock_guard<std::mutex> g(m_dataAccessMutex); |
| 147 | auto const it = std::find_if(m_notes.begin(), m_notes.end(), [&latLon, &text](Note const & note) |
| 148 | { return latLon.EqualDxDy(note.m_point, kTolerance) && text == note.m_note; }); |
| 149 | // No need to add the same note. It works in case when saved note are not uploaded yet. |
| 150 | if (it != m_notes.end()) |
| 151 | return; |
| 152 | |
| 153 | m_notes.emplace_back(latLon, text); |
| 154 | Save(m_fileName, m_notes, m_uploadedNotesCount); |
| 155 | } |
| 156 | |
| 157 | void Notes::Upload(osm::OsmOAuth const & auth) |
| 158 | { |