forked from organicmaps/organicmaps
added Framework::GetVisiblePOI initial implementation. need help from VNG to make it useful.
This commit is contained in:
parent
eae2259f62
commit
aafcb7d9fe
9 changed files with 83 additions and 4 deletions
|
@ -93,6 +93,8 @@ void BasicRenderPolicy::DrawFrame(shared_ptr<PaintEvent> const & e,
|
|||
|
||||
m_RenderQueue->renderState().m_mutex->Lock();
|
||||
|
||||
SetOverlay(m_RenderQueue->renderState().m_currentOverlay);
|
||||
|
||||
if (m_RenderQueue->renderState().m_actualTarget.get() != 0)
|
||||
{
|
||||
m2::PointD const ptShift = m_RenderQueue->renderState().coordSystemShift(false);
|
||||
|
|
|
@ -111,6 +111,8 @@ void BasicTilingRenderPolicy::DrawFrame(shared_ptr<PaintEvent> const & e, Screen
|
|||
|
||||
ScreenCoverage * curCvg = &m_CoverageGenerator->CurrentCoverage();
|
||||
|
||||
SetOverlay(curCvg->GetOverlay());
|
||||
|
||||
curCvg->Draw(pDrawer->screen().get(), s);
|
||||
|
||||
m_DrawScale = curCvg->GetDrawScale();
|
||||
|
|
|
@ -1255,6 +1255,61 @@ void Framework::SaveFacebookDialogResult(int result)
|
|||
}
|
||||
}
|
||||
|
||||
void GetClosestToPivot(list<shared_ptr<yg::OverlayElement> > & l,
|
||||
m2::PointD const & pxPoint,
|
||||
shared_ptr<yg::OverlayElement> & res)
|
||||
{
|
||||
double dist = numeric_limits<double>::max();
|
||||
|
||||
for (list<shared_ptr<yg::OverlayElement> >::const_iterator it = l.begin();
|
||||
it != l.end();
|
||||
++it)
|
||||
{
|
||||
double curDist = pxPoint.Length((*it)->pivot());
|
||||
|
||||
if (curDist < dist)
|
||||
{
|
||||
dist = curDist;
|
||||
res = *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Framework::GetVisiblePOI(m2::PointD const & pxPoint,
|
||||
m2::PointD & pv,
|
||||
AddressInfo & info)
|
||||
{
|
||||
m2::PointD pt = GetNavigator().ShiftPoint(pxPoint);
|
||||
|
||||
if (!m_renderPolicy)
|
||||
{
|
||||
LOG(LINFO, ("GetVisiblePOI called without valid renderPolicy!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
shared_ptr<yg::Overlay> overlay = m_renderPolicy->GetOverlay();
|
||||
|
||||
m2::PointD halfSize(12 * m_renderPolicy->VisualScale(),
|
||||
12 * m_renderPolicy->VisualScale());
|
||||
|
||||
list<shared_ptr<yg::OverlayElement> > candidates;
|
||||
overlay->selectOverlayElements(m2::RectD(pt - halfSize, pt + halfSize), candidates);
|
||||
|
||||
shared_ptr<yg::OverlayElement> res;
|
||||
|
||||
GetClosestToPivot(candidates, pt, res);
|
||||
|
||||
if (res)
|
||||
{
|
||||
/// TODO : get featureID associated with res.
|
||||
/// Obtain AddressInfo by this featureID.
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
Navigator & Framework::GetNavigator()
|
||||
{
|
||||
return m_navigator;
|
||||
|
|
|
@ -292,6 +292,10 @@ public:
|
|||
/// @param[in] pt Point in mercator coordinates.
|
||||
void GetAddressInfo(m2::PointD const & pt, AddressInfo & info) const;
|
||||
|
||||
bool GetVisiblePOI(m2::PointD const & pxPoint,
|
||||
m2::PointD & pv,
|
||||
AddressInfo & info);
|
||||
|
||||
virtual void BeginPaint(shared_ptr<PaintEvent> const & e);
|
||||
/// Function for calling from platform dependent-paint function.
|
||||
virtual void DoPaint(shared_ptr<PaintEvent> const & e);
|
||||
|
|
|
@ -225,6 +225,16 @@ shared_ptr<anim::Controller> const & RenderPolicy::GetAnimController() const
|
|||
return m_controller;
|
||||
}
|
||||
|
||||
void RenderPolicy::SetOverlay(shared_ptr<yg::Overlay> const & overlay)
|
||||
{
|
||||
m_overlay = overlay;
|
||||
}
|
||||
|
||||
shared_ptr<yg::Overlay> const RenderPolicy::GetOverlay() const
|
||||
{
|
||||
return m_overlay;
|
||||
}
|
||||
|
||||
RenderPolicy * CreateRenderPolicy(RenderPolicy::Params const & params)
|
||||
{
|
||||
#ifdef OMIM_OS_ANDROID
|
||||
|
|
|
@ -61,6 +61,9 @@ protected:
|
|||
double m_visualScale;
|
||||
string m_skinName;
|
||||
shared_ptr<anim::Controller> m_controller;
|
||||
shared_ptr<yg::Overlay> m_overlay;
|
||||
|
||||
void SetOverlay(shared_ptr<yg::Overlay> const & overlay);
|
||||
|
||||
public:
|
||||
|
||||
|
@ -138,6 +141,8 @@ public:
|
|||
/// Benchmarking protocol
|
||||
virtual int InsertBenchmarkFence();
|
||||
virtual void JoinBenchmarkFence(int fenceID);
|
||||
|
||||
virtual shared_ptr<yg::Overlay> const GetOverlay() const;
|
||||
};
|
||||
|
||||
RenderPolicy * CreateRenderPolicy(RenderPolicy::Params const & params);
|
||||
|
|
|
@ -300,6 +300,7 @@ void RenderQueueRoutine::Do()
|
|||
shared_ptr<yg::Overlay> overlay(new yg::Overlay());
|
||||
overlay->setCouldOverlap(false);
|
||||
m_threadDrawer->screen()->setOverlay(overlay);
|
||||
m_renderState->m_currentOverlay = overlay;
|
||||
|
||||
while (!IsCancelled())
|
||||
{
|
||||
|
|
|
@ -377,9 +377,9 @@ void ScreenCoverage::Draw(yg::gl::Screen * s, ScreenBase const & screen)
|
|||
m_displayList->draw(m_screen.PtoGMatrix() * screen.GtoPMatrix());
|
||||
}
|
||||
|
||||
yg::Overlay * ScreenCoverage::GetOverlay() const
|
||||
shared_ptr<yg::Overlay> const & ScreenCoverage::GetOverlay() const
|
||||
{
|
||||
return m_overlay.get();
|
||||
return m_overlay;
|
||||
}
|
||||
|
||||
int ScreenCoverage::GetDrawScale() const
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
/// from TileCache while drawing them
|
||||
TTileSet m_tiles;
|
||||
/// Overlay composed of overlays for visible tiles
|
||||
scoped_ptr<yg::Overlay> m_overlay;
|
||||
shared_ptr<yg::Overlay> m_overlay;
|
||||
|
||||
/// State flags
|
||||
|
||||
|
@ -111,7 +111,7 @@ public:
|
|||
/// Check, whether the model is empty at the center of the coverage.
|
||||
void CheckEmptyModelAtCoverageCenter();
|
||||
/// Getter for Overlay
|
||||
yg::Overlay * GetOverlay() const;
|
||||
shared_ptr<yg::Overlay> const & GetOverlay() const;
|
||||
/// Cache coverage in display list
|
||||
void Cache();
|
||||
/// add rendered tile to coverage. Tile is locked, so make sure to unlock it in case it's not needed.
|
||||
|
|
Loading…
Add table
Reference in a new issue