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

Method CreateNote

libs/editor/editor_notes.cpp:132–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132void 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
157void Notes::Upload(osm::OsmOAuth const & auth)
158{

Callers 1

UploadMethod · 0.45

Calls 8

ValidLatFunction · 0.85
ValidLonFunction · 0.85
SaveFunction · 0.70
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
EqualDxDyMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected