forked from organicmaps/organicmaps
[assessment-tool] Show user position on map, when available.
This commit is contained in:
parent
9235813588
commit
9c71fbdcc0
10 changed files with 56 additions and 18 deletions
|
@ -32,7 +32,8 @@ namespace location
|
|||
EAndroidNative,
|
||||
EGoogle,
|
||||
ETizen,
|
||||
EPredictor
|
||||
EPredictor,
|
||||
EUser
|
||||
};
|
||||
|
||||
/// Our structure ALWAYS has valid lat, lon and horizontal accuracy.
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <QtWidgets/QMenu>
|
||||
|
||||
#include <QtCore/QLocale>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#include "qt/qt_common/helpers.hpp"
|
||||
|
||||
#include "geometry/mercator.hpp"
|
||||
|
||||
#include <QtCore/QDateTime>
|
||||
|
||||
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
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "platform/location.hpp"
|
||||
|
||||
#include <QtGui/QMouseEvent>
|
||||
|
||||
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
|
||||
|
|
|
@ -122,7 +122,7 @@ void MainModel::OnSampleSelected(int index)
|
|||
|
||||
auto & context = m_contexts[index];
|
||||
auto const & sample = context.m_sample;
|
||||
m_view->ShowSample(index, sample, sample.m_posAvailable, context.HasChanges());
|
||||
m_view->ShowSample(index, sample, sample.m_posAvailable, sample.m_pos, context.HasChanges());
|
||||
|
||||
ResetSearch();
|
||||
auto const timestamp = m_queryTimestamp;
|
||||
|
|
|
@ -82,11 +82,11 @@ void MainView::OnSearchCompleted()
|
|||
}
|
||||
|
||||
void MainView::ShowSample(size_t sampleIndex, search::Sample const & sample, bool positionAvailable,
|
||||
bool hasEdits)
|
||||
m2::PointD const & position, bool hasEdits)
|
||||
{
|
||||
MoveViewportToRect(sample.m_viewport);
|
||||
|
||||
m_sampleView->SetContents(sample, positionAvailable);
|
||||
m_sampleView->SetContents(sample, positionAvailable, position);
|
||||
m_sampleView->show();
|
||||
|
||||
OnResultChanged(sampleIndex, ResultType::Found, Edits::Update::MakeAll());
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
void OnSearchStarted() override;
|
||||
void OnSearchCompleted() override;
|
||||
void ShowSample(size_t sampleIndex, search::Sample const & sample, bool positionAvailable,
|
||||
bool hasEdits) override;
|
||||
m2::PointD const & position, bool hasEdits) override;
|
||||
|
||||
void AddFoundResults(search::Results::ConstIter begin, search::Results::ConstIter end) override;
|
||||
void ShowNonFoundResults(std::vector<search::Sample::Result> const & results,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "search/search_quality/assessment_tool/sample_view.hpp"
|
||||
|
||||
#include "qt/qt_common/helpers.hpp"
|
||||
#include "qt/qt_common/spinner.hpp"
|
||||
|
||||
#include "map/bookmark_manager.hpp"
|
||||
|
@ -12,6 +13,8 @@
|
|||
#include "search/search_quality/assessment_tool/results_view.hpp"
|
||||
#include "search/search_quality/sample.hpp"
|
||||
|
||||
#include "platform/location.hpp"
|
||||
|
||||
#include <QtGui/QStandardItem>
|
||||
#include <QtGui/QStandardItemModel>
|
||||
#include <QtWidgets/QComboBox>
|
||||
|
@ -150,7 +153,8 @@ SampleView::SampleView(QWidget * parent, Framework & framework)
|
|||
Clear();
|
||||
}
|
||||
|
||||
void SampleView::SetContents(search::Sample const & sample, bool positionAvailable)
|
||||
void SampleView::SetContents(search::Sample const & sample, bool positionAvailable,
|
||||
m2::PointD const & position)
|
||||
{
|
||||
if (!sample.m_query.empty())
|
||||
{
|
||||
|
@ -172,6 +176,10 @@ void SampleView::SetContents(search::Sample const & sample, bool positionAvailab
|
|||
m_relatedQueriesBox->show();
|
||||
|
||||
ClearAllResults();
|
||||
if (positionAvailable)
|
||||
ShowUserPosition(position);
|
||||
else
|
||||
HideUserPosition();
|
||||
}
|
||||
|
||||
void SampleView::OnSearchStarted() { m_spinner->Show(); }
|
||||
|
@ -264,6 +272,7 @@ void SampleView::Clear()
|
|||
m_relatedQueriesBox->hide();
|
||||
|
||||
ClearAllResults();
|
||||
HideUserPosition();
|
||||
OnSearchCompleted();
|
||||
}
|
||||
|
||||
|
@ -284,3 +293,13 @@ void SampleView::SetEdits(ResultsView & results, Edits & edits)
|
|||
}
|
||||
|
||||
void SampleView::OnRemoveNonFoundResult(int row) { m_nonFoundResultsEdits->Delete(row); }
|
||||
|
||||
void SampleView::ShowUserPosition(m2::PointD const & position)
|
||||
{
|
||||
m_framework.OnLocationUpdate(qt::common::MakeGpsInfo(position));
|
||||
}
|
||||
|
||||
void SampleView::HideUserPosition()
|
||||
{
|
||||
m_framework.OnLocationError(location::EGPSIsOff);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "search/search_quality/assessment_tool/edits.hpp"
|
||||
#include "search/search_quality/sample.hpp"
|
||||
|
||||
#include "geometry/point2d.hpp"
|
||||
|
||||
#include <QtCore/QMargins>
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
|
@ -23,7 +25,8 @@ public:
|
|||
|
||||
SampleView(QWidget * parent, Framework & framework);
|
||||
|
||||
void SetContents(search::Sample const & sample, bool positionAvailable);
|
||||
void SetContents(search::Sample const & sample, bool positionAvailable,
|
||||
m2::PointD const & position);
|
||||
void OnSearchStarted();
|
||||
void OnSearchCompleted();
|
||||
|
||||
|
@ -54,6 +57,9 @@ private:
|
|||
void SetEdits(ResultsView & results, Edits & edits);
|
||||
void OnRemoveNonFoundResult(int row);
|
||||
|
||||
void ShowUserPosition(m2::PointD const & position);
|
||||
void HideUserPosition();
|
||||
|
||||
Framework & m_framework;
|
||||
|
||||
Spinner * m_spinner = nullptr;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "search/search_quality/assessment_tool/edits.hpp"
|
||||
#include "search/search_quality/sample.hpp"
|
||||
|
||||
#include "geometry/point2d.hpp"
|
||||
#include "geometry/rect2d.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
|
@ -31,7 +32,7 @@ public:
|
|||
virtual void OnSearchStarted() = 0;
|
||||
virtual void OnSearchCompleted() = 0;
|
||||
virtual void ShowSample(size_t index, search::Sample const & sample, bool positionAvailable,
|
||||
bool hasEdits) = 0;
|
||||
m2::PointD const & position, bool hasEdits) = 0;
|
||||
|
||||
virtual void AddFoundResults(search::Results::ConstIter begin,
|
||||
search::Results::ConstIter end) = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue