Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2012-05-15 10:54:58 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:38:21 +0300
commit2daef24bc1b7bfa388766e32f78c93e3764f0cf1 (patch)
tree56ec6cdff9757b2fdc7d927702f39f926c581730 /map/address_finder.cpp
parentbff0fab8282df6cda8ce9b9cfbfd5c2269b6c44c (diff)
Make locality check faster.
Diffstat (limited to 'map/address_finder.cpp')
-rw-r--r--map/address_finder.cpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/map/address_finder.cpp b/map/address_finder.cpp
index 76e4c9be51..438411e7ee 100644
--- a/map/address_finder.cpp
+++ b/map/address_finder.cpp
@@ -112,10 +112,10 @@ namespace
private:
m2::PointD m_pt;
- int m_scale;
uint32_t m_coastType;
protected:
+ int m_scale;
double m_eps;
vector<FeatureInfoT> m_cont;
};
@@ -176,6 +176,7 @@ namespace
class TypeChecker
{
vector<uint32_t> m_localities, m_streets, m_buildings;
+ int m_localityScale;
template <size_t count, size_t ind>
void FillMatch(char const * (& arr)[count][ind], vector<uint32_t> & vec)
@@ -231,10 +232,19 @@ namespace
};
FillMatch(arrLocalities, m_localities);
+ m_localityScale = 0;
+ for (size_t i = 0; i < m_localities.size(); ++i)
+ {
+ m_localityScale = max(m_localityScale,
+ feature::GetDrawableScaleRange(m_localities[i]).first);
+ }
+
FillMatch(arrStreet, m_streets);
FillMatch(arrBuilding, m_buildings);
}
+ int GetLocalitySearchScale() const { return m_localityScale; }
+
bool IsLocality(feature::TypesHolder const & types) const
{
return IsMatchImpl(m_localities, types);
@@ -363,21 +373,18 @@ namespace
void Framework::GetAddressInfo(m2::PointD const & pt, AddressInfo & info) const
{
+ info.Clear();
+
info.m_country = GetCountryName(pt);
if (info.m_country.empty())
{
LOG(LINFO, ("Can't find region for point ", pt));
return;
}
- // Clear all other fields
- info.m_city.clear();
- info.m_street.clear();
- info.m_house.clear();
- info.m_name.clear();
- int const scale = scales::GetUpperScale();
+ int scale = scales::GetUpperScale();
double const addressR = 200.0;
- double const localityR = 20000;
+ double const localityR = 20000.0;
static DoGetAddressInfo::TypeChecker checker;
@@ -393,6 +400,9 @@ void Framework::GetAddressInfo(m2::PointD const & pt, AddressInfo & info) const
// now - get the locality
{
+ scale = checker.GetLocalitySearchScale();
+ LOG(LDEBUG, ("Locality scale = ", scale));
+
DoGetAddressInfo getLocality(pt, localityR, scale, checker);
getLocality.PrepareForLocalities();
@@ -438,3 +448,12 @@ string Framework::AddressInfo::FormatTypes() const
}
return result;
}
+
+void Framework::AddressInfo::Clear()
+{
+ m_country.clear();
+ m_city.clear();
+ m_street.clear();
+ m_house.clear();
+ m_name.clear();
+}