From 9fe6f4f55fd4b2081d1c3a5cbaf60da512fe221e Mon Sep 17 00:00:00 2001 From: vng Date: Tue, 10 Sep 2013 15:48:30 +0300 Subject: [PATCH] Fixed Framework::GetFeatureTypes. --- geometry/any_rect2d.hpp | 2 ++ map/address_finder.cpp | 20 +++++++------------- map/framework.cpp | 3 --- map/framework.hpp | 7 +++++-- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/geometry/any_rect2d.hpp b/geometry/any_rect2d.hpp index d09ad108b0..e8cd054268 100644 --- a/geometry/any_rect2d.hpp +++ b/geometry/any_rect2d.hpp @@ -108,6 +108,8 @@ namespace m2 return m_rect.Center(); } + T GetMaxSize() const { return max(m_rect.SizeX(), m_rect.SizeY()); } + bool IsPointInside(Point const & pt) const { return m_rect.IsPointInside(ConvertTo(pt)); diff --git a/map/address_finder.cpp b/map/address_finder.cpp index e92824122e..adb163a84f 100644 --- a/map/address_finder.cpp +++ b/map/address_finder.cpp @@ -160,22 +160,16 @@ namespace }; } -void Framework::GetFeatureTypes(m2::PointD pt, vector & types) const +void Framework::GetFeatureTypes(m2::PointD const & pxPoint, vector & types) const { - pt = m_navigator.ShiftPoint(pt); + m2::AnyRectD rect; + m_navigator.GetTouchRect(pxPoint, TOUCH_PIXEL_RADIUS * GetVisualScale(), rect); - int const sm = 20; - m2::RectD pixR(m2::PointD(pt.x - sm, pt.y - sm), m2::PointD(pt.x + sm, pt.y + sm)); + // This scale should fit in geometry scales range. + int const scale = min(GetDrawScale(), scales::GetUpperScale()); - m2::RectD glbR; - m_navigator.Screen().PtoG(pixR, glbR); - - int const scale = GetDrawScale(); - DoGetFeatureTypes getTypes(m_navigator.Screen().PtoG(pt), - max(glbR.SizeX(), glbR.SizeY()) / 2.0, - scale); - - m_model.ForEachFeature(glbR, getTypes, scale); + DoGetFeatureTypes getTypes(rect.GlobalCenter(), rect.GetMaxSize() / 2.0, scale); + m_model.ForEachFeature(rect.GetGlobalRect(), getTypes, scale); getTypes.GetFeatureTypes(5, types); } diff --git a/map/framework.cpp b/map/framework.cpp index 07d573f9c4..45b2a4377d 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -46,9 +46,6 @@ #include "../../api/src/c/api-client.h" -/// How many pixels around touch point are used to get bookmark or POI -#define TOUCH_PIXEL_RADIUS 20 - #define KMZ_EXTENSION ".kmz" #define DEFAULT_BOOKMARK_TYPE "placemark-red" diff --git a/map/framework.hpp b/map/framework.hpp index 8ed54d7fe2..ce781bbc9a 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -118,6 +118,9 @@ protected: scoped_ptr m_animController; InformationDisplay m_informationDisplay; + /// How many pixels around touch point are used to get bookmark or POI + static const int TOUCH_PIXEL_RADIUS = 20; + /// This function is called by m_storage to notify that country downloading is finished. /// @param[in] file Country file name (without extensions). void UpdateAfterDownload(string const & file); @@ -333,8 +336,8 @@ public: } /// Get classificator types for nearest features. - /// @param[in] pixPt Current touch point in device pixel coordinates. - void GetFeatureTypes(m2::PointD pixPt, vector & types) const; + /// @param[in] pxPoint Current touch point in device pixel coordinates. + void GetFeatureTypes(m2::PointD const & pxPoint, vector & types) const; /// Get address information for point on map. inline void GetAddressInfoForPixelPoint(m2::PointD const & pxPoint, search::AddressInfo & info) const