forked from organicmaps/organicmaps
[gps] add timestams and altitudes to the recorded track points
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
parent
b2a231ea5b
commit
c23a535dba
5 changed files with 28 additions and 8 deletions
|
@ -1148,26 +1148,33 @@ void BookmarkManager::SaveTrackRecording(std::string trackName)
|
|||
auto const & tracker = GpsTracker::Instance();
|
||||
CHECK(!tracker.IsEmpty(), ("Track recording should be not be empty"));
|
||||
|
||||
kml::MultiGeometry::LineT line;
|
||||
tracker.ForEachTrackPoint([&line](location::GpsInfo const & pt, size_t id)->bool
|
||||
kml::MultiGeometry geometry;
|
||||
geometry.m_lines.emplace_back();
|
||||
geometry.m_timestamps.emplace_back();
|
||||
auto & line = geometry.m_lines.back();
|
||||
auto & timestamps = geometry.m_timestamps.back();
|
||||
auto const trackSize = tracker.GetTrackSize();
|
||||
line.reserve(trackSize);
|
||||
timestamps.reserve(trackSize);
|
||||
|
||||
tracker.ForEachTrackPoint([&line, ×tamps](location::GpsInfo const & pt, size_t id)->bool
|
||||
{
|
||||
line.emplace_back(mercator::FromLatLon(pt.m_latitude, pt.m_longitude));
|
||||
line.emplace_back(mercator::FromLatLon(pt.m_latitude, pt.m_longitude), pt.m_altitude);
|
||||
timestamps.emplace_back(pt.m_timestamp);
|
||||
return true;
|
||||
});
|
||||
|
||||
kml::TrackData trackData;
|
||||
trackData.m_geometry = std::move(geometry);
|
||||
|
||||
if (trackName.empty())
|
||||
trackName = GenerateTrackRecordingName();
|
||||
kml::SetDefaultStr(trackData.m_name, trackName);
|
||||
|
||||
kml::MultiGeometry geometry;
|
||||
geometry.m_lines.push_back(std::move(line));
|
||||
trackData.m_geometry = std::move(geometry);
|
||||
|
||||
kml::ColorData colorData;
|
||||
colorData.m_rgba = GenerateTrackRecordingColor().GetRGBA();
|
||||
kml::TrackLayer layer;
|
||||
layer.m_color = colorData;
|
||||
layer.m_color = std::move(colorData);
|
||||
|
||||
std::vector<kml::TrackLayer> m_layers;
|
||||
m_layers.emplace_back(layer);
|
||||
|
|
|
@ -94,6 +94,12 @@ void GpsTrack::Clear()
|
|||
ScheduleTask();
|
||||
}
|
||||
|
||||
size_t GpsTrack::GetSize() const
|
||||
{
|
||||
CHECK(m_collection != nullptr, ());
|
||||
return m_collection->GetSize();
|
||||
}
|
||||
|
||||
bool GpsTrack::IsEmpty() const
|
||||
{
|
||||
if (!m_collection)
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
void Clear();
|
||||
|
||||
bool IsEmpty() const;
|
||||
size_t GetSize() const;
|
||||
|
||||
/// Sets tracking duration in hours.
|
||||
/// @note Callback is called with 'toRemove' points, if some points were removed.
|
||||
|
|
|
@ -99,6 +99,11 @@ bool GpsTracker::IsEmpty() const
|
|||
return m_track.IsEmpty();
|
||||
}
|
||||
|
||||
size_t GpsTracker::GetTrackSize() const
|
||||
{
|
||||
return m_track.GetSize();
|
||||
}
|
||||
|
||||
void GpsTracker::Connect(TGpsTrackDiffCallback const & fn)
|
||||
{
|
||||
m_track.SetCallback(fn);
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
|
||||
std::chrono::hours GetDuration() const;
|
||||
bool IsEmpty() const;
|
||||
size_t GetTrackSize() const;
|
||||
|
||||
void SetDuration(std::chrono::hours duration);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue