From 9c71fbdcc07f920337af1113cb27289ce8b0c634 Mon Sep 17 00:00:00 2001 From: Yuri Gorshenin Date: Thu, 13 Jul 2017 13:43:58 +0300 Subject: [assessment-tool] Show user position on map, when available. --- qt/draw_widget.cpp | 12 ++---------- qt/qt_common/helpers.cpp | 15 +++++++++++++++ qt/qt_common/helpers.hpp | 4 ++++ 3 files changed, 21 insertions(+), 10 deletions(-) (limited to 'qt') diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index 858b17236f..24b405e954 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #include @@ -317,15 +316,8 @@ void DrawWidget::SetMapStyle(MapStyle mapStyle) void DrawWidget::SubmitFakeLocationPoint(m2::PointD const & pt) { m_emulatingLocation = true; - m2::PointD const point = m_framework.P3dtoG(pt); - - location::GpsInfo info; - info.m_latitude = MercatorBounds::YToLat(point.y); - info.m_longitude = MercatorBounds::XToLon(point.x); - info.m_horizontalAccuracy = 10; - info.m_timestamp = QDateTime::currentMSecsSinceEpoch() / 1000.0; - - m_framework.OnLocationUpdate(info); + auto const point = m_framework.P3dtoG(pt); + m_framework.OnLocationUpdate(qt::common::MakeGpsInfo(point)); if (m_framework.GetRoutingManager().IsRoutingActive()) { diff --git a/qt/qt_common/helpers.cpp b/qt/qt_common/helpers.cpp index a6081809b3..15ba4b68b1 100644 --- a/qt/qt_common/helpers.cpp +++ b/qt/qt_common/helpers.cpp @@ -1,5 +1,9 @@ #include "qt/qt_common/helpers.hpp" +#include "geometry/mercator.hpp" + +#include + namespace qt { namespace common @@ -23,5 +27,16 @@ bool IsCommandModifier(QMouseEvent const * const e) { return e->modifiers() & Qt bool IsShiftModifier(QMouseEvent const * const e) { return e->modifiers() & Qt::ShiftModifier; } bool IsAltModifier(QMouseEvent const * const e) { return e->modifiers() & Qt::AltModifier; } + +location::GpsInfo MakeGpsInfo(m2::PointD const & point) +{ + location::GpsInfo info; + info.m_source = location::EUser; + info.m_latitude = MercatorBounds::YToLat(point.y); + info.m_longitude = MercatorBounds::XToLon(point.x); + info.m_horizontalAccuracy = 10; + info.m_timestamp = QDateTime::currentMSecsSinceEpoch() / 1000.0; + return info; +} } // namespace common } // namespace qt diff --git a/qt/qt_common/helpers.hpp b/qt/qt_common/helpers.hpp index 71c1c37e83..b3f6882852 100644 --- a/qt/qt_common/helpers.hpp +++ b/qt/qt_common/helpers.hpp @@ -1,5 +1,7 @@ #pragma once +#include "platform/location.hpp" + #include namespace qt @@ -24,5 +26,7 @@ struct Hotkey int m_key = 0; char const * m_slot = nullptr; }; + +location::GpsInfo MakeGpsInfo(m2::PointD const & point); } // namespace common } // namespace qt -- cgit v1.2.3