diff options
author | vng <viktor.govako@gmail.com> | 2012-09-21 03:31:52 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:43:37 +0300 |
commit | d03e167bc0484fcf9837da2a84ff2bc220ad0203 (patch) | |
tree | 568ba7847b0287e787ab2d1afdd63cf6f05475f9 /map/address_finder.cpp | |
parent | 94fa7d216cffdffe1fbfd58923fe2e6f13523b3a (diff) |
Framework::GetVisiblePOI is working for symbols now.
Diffstat (limited to 'map/address_finder.cpp')
-rw-r--r-- | map/address_finder.cpp | 73 |
1 files changed, 54 insertions, 19 deletions
diff --git a/map/address_finder.cpp b/map/address_finder.cpp index 5b096cdfb2..3337259333 100644 --- a/map/address_finder.cpp +++ b/map/address_finder.cpp @@ -425,6 +425,21 @@ namespace }; } +namespace +{ + /// Global instance for type checker. + /// @todo Possible need to add synhronization. + typedef DoGetAddressBase::TypeChecker CheckerT; + CheckerT * g_checker = 0; + + CheckerT & GetChecker() + { + if (g_checker == 0) + g_checker = new CheckerT(); + return *g_checker; + } +} + void Framework::GetAddressInfo(m2::PointD const & pt, AddressInfo & info) const { info.Clear(); @@ -436,39 +451,59 @@ void Framework::GetAddressInfo(m2::PointD const & pt, AddressInfo & info) const return; } - int scale = scales::GetUpperScale(); + int const scale = scales::GetUpperScale(); double addressR[] = { 15.0, // radius to search point POI's 100.0, // radius to search street names 5.0 // radius to search building numbers (POI's) }; - double const localityR = 20000.0; // radius to search localities - static DoGetAddressBase::TypeChecker checker; + // pass maximum value for all addressR + m2::RectD const rect = MercatorBounds::RectByCenterXYAndSizeInMeters(pt, addressR[1]); + DoGetAddressInfo getAddress(pt, scale, GetChecker(), addressR); - // first of all - get an address - { - // pass maximum value for all addressR - m2::RectD const rect = MercatorBounds::RectByCenterXYAndSizeInMeters(pt, addressR[1]); - DoGetAddressInfo getAddress(pt, scale, checker, addressR); + m_model.ForEachFeature(rect, getAddress, scale); - m_model.ForEachFeature(rect, getAddress, scale); + getAddress.FillAddress(GetSearchEngine(), info); - getAddress.FillAddress(GetSearchEngine(), info); - } + GetLocality(pt, info); +} + +void Framework::GetAddressInfo(FeatureType const & ft, m2::PointD const & pt, AddressInfo & info) const +{ + info.Clear(); - // now - get the locality + info.m_country = GetCountryName(pt); + if (info.m_country.empty()) { - scale = checker.GetLocalitySearchScale(); - LOG(LDEBUG, ("Locality scale = ", scale)); + LOG(LINFO, ("Can't find region for point ", pt)); + return; + } - m2::RectD const rect = MercatorBounds::RectByCenterXYAndSizeInMeters(pt, localityR); - DoGetLocality getLocality(pt, scale, checker, rect); + double const inf = numeric_limits<double>::max(); + double addressR[] = { inf, inf, inf }; - m_model.ForEachFeature(rect, getLocality, scale); + DoGetAddressInfo getAddress(pt, scales::GetUpperScale(), GetChecker(), addressR); + getAddress(ft); + getAddress.FillAddress(GetSearchEngine(), info); - getLocality.FillLocality(info, *this); - } + GetLocality(pt, info); +} + +void Framework::GetLocality(m2::PointD const & pt, AddressInfo & info) const +{ + CheckerT & checker = GetChecker(); + + int const scale = checker.GetLocalitySearchScale(); + LOG(LDEBUG, ("Locality scale = ", scale)); + + // radius to search localities + m2::RectD const rect = MercatorBounds::RectByCenterXYAndSizeInMeters(pt, 20000.0); + DoGetLocality getLocality(pt, scale, checker, rect); + + m_model.ForEachFeature(rect, getLocality, scale); + + getLocality.FillLocality(info, *this); } string Framework::AddressInfo::FormatAddress() const |