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>2016-02-08 19:58:39 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:17:02 +0300
commitfc54d06072f725332fe6bbd96c22483ee3b66e67 (patch)
tree1b15e2ed11eef5e8692758d21f329e9a39bf9760
parent00bf8b26c01a19009cee1cbae02414f215d29264 (diff)
Review fixes.
-rw-r--r--android/jni/com/mapswithme/maps/Framework.cpp4
-rw-r--r--android/jni/com/mapswithme/maps/SearchEngine.cpp2
-rw-r--r--generator/search_index_builder.cpp6
-rw-r--r--indexer/osm_editor.hpp2
-rw-r--r--iphone/Maps/Classes/CustomViews/MapViewControls/Search/TableView/MWMSearchCommonCell.mm2
-rw-r--r--iphone/Maps/Classes/Share/MWMShareLocationActivityItem.mm4
-rw-r--r--map/framework.cpp8
-rw-r--r--search/house_detector.cpp18
-rw-r--r--search/house_detector.hpp6
-rw-r--r--search/result.cpp31
-rw-r--r--search/result.hpp10
-rw-r--r--search/reverse_geocoder.cpp61
-rw-r--r--search/reverse_geocoder.hpp15
-rw-r--r--search/v2/features_layer_matcher.cpp12
-rw-r--r--search/v2/features_layer_matcher.hpp25
15 files changed, 110 insertions, 96 deletions
diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp
index 2de146ca9e..61f5f3663a 100644
--- a/android/jni/com/mapswithme/maps/Framework.cpp
+++ b/android/jni/com/mapswithme/maps/Framework.cpp
@@ -635,9 +635,7 @@ extern "C"
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_Framework_nativeGetNameAndAddress(JNIEnv * env, jclass clazz, jdouble lat, jdouble lon)
{
- search::AddressInfo info = frm()->GetAddressInfoAtPoint(MercatorBounds::FromLatLon(lat, lon));
- if (info.m_distanceMeters > 200.0)
- info.Clear();
+ search::AddressInfo const info = frm()->GetAddressInfoAtPoint(MercatorBounds::FromLatLon(lat, lon));
return jni::ToJavaString(env, info.FormatNameAndAddress());
}
diff --git a/android/jni/com/mapswithme/maps/SearchEngine.cpp b/android/jni/com/mapswithme/maps/SearchEngine.cpp
index 0667f488f8..dd61f96251 100644
--- a/android/jni/com/mapswithme/maps/SearchEngine.cpp
+++ b/android/jni/com/mapswithme/maps/SearchEngine.cpp
@@ -71,7 +71,7 @@ jobject ToJavaResult(Result result, bool hasPosition, double lat, double lon)
auto const address = g_framework->NativeFramework()->GetSearchResultAddress(result);
jstring featureType = jni::ToJavaString(env, result.GetFeatureType());
- jstring region = jni::ToJavaString(env, address.FormatAddress());
+ jstring region = jni::ToJavaString(env, address.FormatAddress(search::AddressInfo::SEARCH_RESULT));
jstring dist = jni::ToJavaString(env, distance);
jstring cuisine = jni::ToJavaString(env, result.GetCuisine());
jobject desc = env->NewObject(g_descriptionClass, g_descriptionConstructor,
diff --git a/generator/search_index_builder.cpp b/generator/search_index_builder.cpp
index 46c7c54dbb..37bb7828e7 100644
--- a/generator/search_index_builder.cpp
+++ b/generator/search_index_builder.cpp
@@ -318,8 +318,8 @@ void BuildAddressTable(FilesContainerR & container, Writer & writer)
Index mwmIndex;
/// @ todo Make some better solution, or legalize MakeTemporary.
- auto const mwmId = mwmIndex.RegisterMap(platform::LocalCountryFile::MakeTemporary(container.GetFileName()));
- ASSERT_EQUAL(mwmId.second, MwmSet::RegResult::Success, ());
+ auto const res = mwmIndex.RegisterMap(platform::LocalCountryFile::MakeTemporary(container.GetFileName()));
+ ASSERT_EQUAL(res.second, MwmSet::RegResult::Success, ());
search::ReverseGeocoder rgc(mwmIndex);
{
@@ -339,7 +339,7 @@ void BuildAddressTable(FilesContainerR & container, Writer & writer)
{
FeatureType ft;
features.GetVector().GetByIndex(index, ft);
- ft.SetID(FeatureID(mwmId.first, index));
+ ft.SetID({res.first, index});
using TStreet = search::ReverseGeocoder::Street;
vector<TStreet> streets;
diff --git a/indexer/osm_editor.hpp b/indexer/osm_editor.hpp
index 67300dc452..b1efc2e4c5 100644
--- a/indexer/osm_editor.hpp
+++ b/indexer/osm_editor.hpp
@@ -51,7 +51,7 @@ public:
void SetMwmIdByNameAndVersionFn(TMwmIdByMapNameFn const & fn) { m_mwmIdByMapNameFn = fn; }
void SetInvalidateFn(TInvalidateFn const & fn) { m_invalidateFn = fn; }
void SetFeatureLoaderFn(TFeatureLoaderFn const & fn) { m_getOriginalFeatureFn = fn; }
- void SetFeatureOriginalStretFn(TFeatureOriginalStreetFn const & fn) { m_getOriginalFeatureStreetFn = fn; }
+ void SetFeatureOriginalStreetFn(TFeatureOriginalStreetFn const & fn) { m_getOriginalFeatureStreetFn = fn; }
void LoadMapEdits();
/// Resets editor to initial state: no any edits or created/deleted features.
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TableView/MWMSearchCommonCell.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TableView/MWMSearchCommonCell.mm
index fdb9a5a9b5..32ea439ae7 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TableView/MWMSearchCommonCell.mm
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TableView/MWMSearchCommonCell.mm
@@ -28,7 +28,7 @@
[super config:result];
self.typeLabel.text = @(result.GetFeatureType().c_str()).capitalizedString;
search::AddressInfo const info = GetFramework().GetSearchResultAddress(result);
- self.locationLabel.text = @(info.FormatAddress().c_str());
+ self.locationLabel.text = @(info.FormatAddress(search::AddressInfo::SEARCH_RESULT).c_str());
[self.locationLabel sizeToFit];
if (!forHeight)
diff --git a/iphone/Maps/Classes/Share/MWMShareLocationActivityItem.mm b/iphone/Maps/Classes/Share/MWMShareLocationActivityItem.mm
index 5ec676cf31..29debfe07e 100644
--- a/iphone/Maps/Classes/Share/MWMShareLocationActivityItem.mm
+++ b/iphone/Maps/Classes/Share/MWMShareLocationActivityItem.mm
@@ -86,10 +86,8 @@ NSString * httpGe0Url(NSString * shortUrl)
if (!self.myPosition)
return [NSString stringWithFormat:L(@"bookmark_share_email"), self.title, url, httpGe0Url(url)];
- search::AddressInfo info = GetFramework().GetAddressInfoAtPoint(
+ search::AddressInfo const info = GetFramework().GetAddressInfoAtPoint(
MercatorBounds::FromLatLon(self.location.latitude, self.location.longitude));
- if (info.m_distanceMeters > 200.0)
- info.Clear();
NSString * nameAndAddress = @(info.FormatNameAndAddress().c_str());
return [NSString stringWithFormat:L(@"my_position_share_email"), nameAndAddress, url, httpGe0Url(url)];
diff --git a/map/framework.cpp b/map/framework.cpp
index e140a7db8b..83ad22676f 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -352,7 +352,7 @@ Framework::Framework()
feature->ParseEverything();
return feature;
});
- editor.SetFeatureOriginalStretFn([this](FeatureType const & ft) -> string
+ editor.SetFeatureOriginalStreetFn([this](FeatureType const & ft) -> string
{
search::ReverseGeocoder const coder(m_model.GetIndex());
auto const streets = coder.GetNearbyFeatureStreets(ft);
@@ -1311,8 +1311,8 @@ search::AddressInfo Framework::GetSearchResultAddress(search::Result const & res
if (res.IsSuggest())
return info;
- /// @todo Optimize this stuff according to the fact that feature is
- /// already reading in many cases during search results processing.
+ /// @todo Optimize here according to the fact that feature is
+ /// already read in many cases during search results processing.
auto const & id = res.GetFeatureID();
if (id.IsValid())
{
@@ -1327,8 +1327,6 @@ search::AddressInfo Framework::GetSearchResultAddress(search::Result const & res
}
info = GetAddressInfoAtPoint(res.GetFeatureCenter());
- if (info.m_distanceMeters > 50.0)
- info.Clear();
string const & type = res.GetFeatureType();
if (!type.empty())
diff --git a/search/house_detector.cpp b/search/house_detector.cpp
index 4425071c8c..46f859d747 100644
--- a/search/house_detector.cpp
+++ b/search/house_detector.cpp
@@ -544,10 +544,10 @@ string const & MergedStreet::GetName() const
return m_cont.front()->GetName();
}
-bool MergedStreet::IsHousesReaded() const
+bool MergedStreet::IsHousesRead() const
{
ASSERT(!m_cont.empty(), ());
- return m_cont.front()->m_housesReaded;
+ return m_cont.front()->m_housesRead;
}
void MergedStreet::Next(Index & i) const
@@ -579,7 +579,7 @@ void MergedStreet::FinishReadingHouses()
m_cont[i]->m_houses[j].m_streetDistance += length;
length += m_cont[i]->m_length;
- m_cont[i]->m_housesReaded = true;
+ m_cont[i]->m_housesRead = true;
}
// Unique projections for merged street.
@@ -694,7 +694,7 @@ void HouseDetector::ReadHouse(FeatureType const & f, Street * st, ProjectionCalc
void HouseDetector::ReadHouses(Street * st)
{
- if (st->m_housesReaded)
+ if (st->m_housesRead)
return;
//offsetMeters = max(HN_MIN_READ_OFFSET_M, min(GetApprLengthMeters(st->m_number) / 2, offsetMeters));
@@ -716,19 +716,19 @@ void HouseDetector::ReadAllHouses(double offsetMeters)
for (auto & st : m_streets)
{
- if (!st.IsHousesReaded())
+ if (!st.IsHousesRead())
st.FinishReadingHouses();
}
}
void HouseDetector::ClearCaches()
{
- for (StreetMapT::iterator it = m_id2st.begin(); it != m_id2st.end(); ++it)
- delete it->second;
+ for (auto & st : m_id2st)
+ delete st.second;
m_id2st.clear();
- for (HouseMapT::iterator it = m_id2house.begin(); it != m_id2house.end(); ++it)
- delete it->second;
+ for (auto & h : m_id2house)
+ delete h.second;
m_streetNum = 0;
diff --git a/search/house_detector.hpp b/search/house_detector.hpp
index cbd8131475..d6fecd3d8f 100644
--- a/search/house_detector.hpp
+++ b/search/house_detector.hpp
@@ -113,9 +113,9 @@ public:
vector<HouseProjection> m_houses;
double m_length; /// Length in mercator
int m_number; /// Some ordered number after merging
- bool m_housesReaded;
+ bool m_housesRead;
- Street() : m_length(0.0), m_number(-1), m_housesReaded(false) {}
+ Street() : m_length(0.0), m_number(-1), m_housesRead(false) {}
void Reverse();
void SortHousesProjection();
@@ -146,7 +146,7 @@ public:
string const & GetDbgName() const;
string const & GetName() const;
- bool IsHousesReaded() const;
+ bool IsHousesRead() const;
void FinishReadingHouses();
HouseProjection const * GetHousePivot(bool isOdd, bool & sign) const;
diff --git a/search/result.cpp b/search/result.cpp
index 3e27f56ecd..c6cc6dac85 100644
--- a/search/result.cpp
+++ b/search/result.cpp
@@ -261,8 +261,18 @@ string AddressInfo::FormatPinText() const
return (ret.empty() ? type : (ret + " (" + type + ')'));
}
-string AddressInfo::FormatAddress() const
+string AddressInfo::FormatHouseAndStreet(AddressType type /* = DEFAULT */) const
{
+ // Check whether we can format address according to the query type and actual address distance.
+ /// @todo We can add "Near" prefix here in future according to the distance.
+ if (m_distanceMeters > 0.0)
+ {
+ if (type == SEARCH_RESULT && m_distanceMeters > 50.0)
+ return string();
+ if (m_distanceMeters > 200.0)
+ return string();
+ }
+
string result = m_street;
if (!m_house.empty())
{
@@ -270,6 +280,13 @@ string AddressInfo::FormatAddress() const
result += ", ";
result += m_house;
}
+
+ return result;
+}
+
+string AddressInfo::FormatAddress(AddressType type /* = DEFAULT */) const
+{
+ string result = FormatHouseAndStreet(type);
if (!m_city.empty())
{
if (!result.empty())
@@ -285,6 +302,12 @@ string AddressInfo::FormatAddress() const
return result;
}
+string AddressInfo::FormatNameAndAddress(AddressType type /* = DEFAULT */) const
+{
+ string const addr = FormatAddress(type);
+ return (m_name.empty() ? addr : m_name + ", " + addr);
+}
+
string AddressInfo::FormatTypes() const
{
string result;
@@ -298,12 +321,6 @@ string AddressInfo::FormatTypes() const
return result;
}
-string AddressInfo::FormatNameAndAddress() const
-{
- string const addr = FormatAddress();
- return (m_name.empty() ? addr : m_name + ", " + addr);
-}
-
string AddressInfo::GetBestType() const
{
if (m_types.empty())
diff --git a/search/result.hpp b/search/result.hpp
index 872056695f..3ba05f0c1f 100644
--- a/search/result.hpp
+++ b/search/result.hpp
@@ -191,12 +191,18 @@ struct AddressInfo
string GetPinType() const; // shop
string FormatPinText() const; // Caroline (clothes shop)
- string FormatAddress() const; // 7 vulica Frunze, Belarus
string FormatTypes() const; // clothes shop
- string FormatNameAndAddress() const; // Caroline, 7 vulica Frunze, Belarus
string GetBestType() const;
bool IsEmptyName() const;
+ enum AddressType { DEFAULT, SEARCH_RESULT };
+ // 7 vulica Frunze
+ string FormatHouseAndStreet(AddressType type = DEFAULT) const;
+ // 7 vulica Frunze, Minsk, Belarus
+ string FormatAddress(AddressType type = DEFAULT) const;
+ // Caroline, 7 vulica Frunze, Minsk, Belarus
+ string FormatNameAndAddress(AddressType type = DEFAULT) const;
+
friend string DebugPrint(AddressInfo const & info);
void Clear();
diff --git a/search/reverse_geocoder.cpp b/search/reverse_geocoder.cpp
index 2c795d89a4..ed9a13e6a7 100644
--- a/search/reverse_geocoder.cpp
+++ b/search/reverse_geocoder.cpp
@@ -1,7 +1,6 @@
#include "reverse_geocoder.hpp"
#include "search_string_utils.hpp"
-#include "search/v2/house_to_street_table.hpp"
#include "search/v2/mwm_context.hpp"
#include "indexer/feature.hpp"
@@ -19,12 +18,11 @@ namespace search
namespace
{
size_t constexpr kSimilarityThresholdPercent = 10;
-int const kQueryScale = scales::GetUpperScale();
+int constexpr kQueryScale = scales::GetUpperScale();
+/// Max number of tries (nearest houses with housenumber) to check when getting point address.
+size_t constexpr kMaxNumTriesToApproxAddress = 10;
} // namespace
-// static
-double const ReverseGeocoder::kLookupRadiusM = 500.0;
-
ReverseGeocoder::ReverseGeocoder(Index const & index) : m_index(index) {}
void ReverseGeocoder::GetNearbyStreets(MwmSet::MwmId const & id, m2::PointD const & center,
@@ -108,8 +106,8 @@ ReverseGeocoder::GetNearbyFeatureStreets(FeatureType const & ft) const
GetNearbyStreets(const_cast<FeatureType &>(ft), result.first);
- HouseTable table;
- if (!table.Get(m_index, ft.GetID(), result.first, result.second))
+ HouseTable table(m_index);
+ if (!table.Get(ft.GetID(), result.second))
result.second = numeric_limits<uint32_t>::max();
return result;
@@ -120,19 +118,21 @@ void ReverseGeocoder::GetNearbyAddress(m2::PointD const & center, Address & addr
vector<Building> buildings;
GetNearbyBuildings(center, buildings);
- HouseTable table;
- int triesCount = 0;
+ HouseTable table(m_index);
+ size_t triesCount = 0;
for (auto const & b : buildings)
{
- if (GetNearbyAddress(table, b, addr) || (++triesCount == 5))
+ // It's quite enough to analize nearest kMaxNumTriesToApproxAddress houses for the exact nearby address.
+ // When we can't guarantee suitable address for the point with distant houses.
+ if (GetNearbyAddress(table, b, addr) || (++triesCount == kMaxNumTriesToApproxAddress))
break;
}
}
void ReverseGeocoder::GetNearbyAddress(FeatureType & ft, Address & addr) const
{
- HouseTable table;
+ HouseTable table(m_index);
(void)GetNearbyAddress(table, FromFeature(ft, 0.0 /* distMeters */), addr);
}
@@ -147,18 +147,23 @@ bool ReverseGeocoder::GetNearbyAddress(HouseTable & table, Building const & bld,
return true;
}
+ uint32_t ind;
+ if (!table.Get(bld.m_id, ind))
+ return false;
+
vector<Street> streets;
GetNearbyStreets(bld.m_id.m_mwmId, bld.m_center, streets);
-
- uint32_t ind;
- if (table.Get(m_index, bld.m_id, streets, ind))
+ if (ind < streets.size())
{
addr.m_building = bld;
addr.m_street = streets[ind];
return true;
}
-
- return false;
+ else
+ {
+ LOG(LWARNING, ("Out of bound street index", ind, "for", bld.m_id));
+ return false;
+ }
}
void ReverseGeocoder::GetNearbyBuildings(m2::PointD const & center, vector<Building> & buildings) const
@@ -187,30 +192,20 @@ m2::RectD ReverseGeocoder::GetLookupRect(m2::PointD const & center, double radiu
return MercatorBounds::RectByCenterXYAndSizeInMeters(center, radiusM);
}
-bool ReverseGeocoder::HouseTable::Get(Index const & index, FeatureID fId,
- vector<Street> const & streets, uint32_t & stIndex)
+bool ReverseGeocoder::HouseTable::Get(FeatureID const & fid, uint32_t & streetIndex)
{
- if (!m_table || m_mwmHandle.GetId() != fId.m_mwmId)
+ if (!m_table || m_handle.GetId() != fid.m_mwmId)
{
- m_mwmHandle = index.GetMwmHandleById(fId.m_mwmId);
- if (!m_mwmHandle.IsAlive())
+ m_handle = m_index.GetMwmHandleById(fid.m_mwmId);
+ if (!m_handle.IsAlive())
{
- LOG(LWARNING, ("MWM", fId, "is dead"));
+ LOG(LWARNING, ("MWM", fid, "is dead"));
return false;
}
- m_table = search::v2::HouseToStreetTable::Load(*m_mwmHandle.GetValue<MwmValue>());
- }
-
- if (!m_table->Get(fId.m_index, stIndex))
- return false;
-
- if (stIndex >= streets.size())
- {
- LOG(LWARNING, ("Out of bound index", stIndex, "for", fId));
- return false;
+ m_table = search::v2::HouseToStreetTable::Load(*m_handle.GetValue<MwmValue>());
}
- return true;
+ return m_table->Get(fid.m_index, streetIndex);
}
} // namespace search
diff --git a/search/reverse_geocoder.hpp b/search/reverse_geocoder.hpp
index ee1157b274..cfa8465c2b 100644
--- a/search/reverse_geocoder.hpp
+++ b/search/reverse_geocoder.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "search/v2/house_to_street_table.hpp"
+
#include "indexer/feature_decl.hpp"
#include "std/string.hpp"
@@ -12,10 +14,6 @@ class Index;
namespace search
{
-namespace v2
-{
-class HouseToStreetTable;
-}
class ReverseGeocoder
{
@@ -38,7 +36,7 @@ class ReverseGeocoder
public:
/// All "Nearby" functions work in this lookup radius.
- static double const kLookupRadiusM;
+ static int constexpr kLookupRadiusM = 500;
explicit ReverseGeocoder(Index const & index);
@@ -92,11 +90,12 @@ private:
/// Helper class to incapsulate house 2 street table reloading.
class HouseTable
{
+ Index const & m_index;
unique_ptr<search::v2::HouseToStreetTable> m_table;
- MwmSet::MwmHandle m_mwmHandle;
+ MwmSet::MwmHandle m_handle;
public:
- bool Get(Index const & index, FeatureID fId,
- vector<Street> const & streets, uint32_t & stIndex);
+ explicit HouseTable(Index const & index) : m_index(index) {}
+ bool Get(FeatureID const & fid, uint32_t & streetIndex);
};
bool GetNearbyAddress(HouseTable & table, Building const & bld, Address & addr) const;
diff --git a/search/v2/features_layer_matcher.cpp b/search/v2/features_layer_matcher.cpp
index 475d8058b0..ce480da166 100644
--- a/search/v2/features_layer_matcher.cpp
+++ b/search/v2/features_layer_matcher.cpp
@@ -11,6 +11,10 @@ namespace search
namespace v2
{
+/// Max distance from house to street where we do search matching
+/// even if there is no exact street written for this house.
+int constexpr kMaxApproxStreetDistanceM = 100;
+
FeaturesLayerMatcher::FeaturesLayerMatcher(Index & index, my::Cancellable const & cancellable)
: m_context(nullptr)
, m_reverseGeocoder(index)
@@ -63,7 +67,7 @@ uint32_t FeaturesLayerMatcher::GetMatchingStreet(uint32_t houseId, FeatureType &
return entry.first;
}
-vector<FeaturesLayerMatcher::TStreet> const &
+FeaturesLayerMatcher::TStreets const &
FeaturesLayerMatcher::GetNearbyStreets(uint32_t featureId)
{
auto entry = m_nearbyStreetsCache.Get(featureId);
@@ -77,7 +81,7 @@ FeaturesLayerMatcher::GetNearbyStreets(uint32_t featureId)
return entry.first;
}
-vector<FeaturesLayerMatcher::TStreet> const &
+FeaturesLayerMatcher::TStreets const &
FeaturesLayerMatcher::GetNearbyStreets(uint32_t featureId, FeatureType & feature)
{
auto entry = m_nearbyStreetsCache.Get(featureId);
@@ -88,7 +92,7 @@ FeaturesLayerMatcher::GetNearbyStreets(uint32_t featureId, FeatureType & feature
return entry.first;
}
-void FeaturesLayerMatcher::GetNearbyStreetsImpl(FeatureType & feature, vector<TStreet> & streets)
+void FeaturesLayerMatcher::GetNearbyStreetsImpl(FeatureType & feature, TStreets & streets)
{
m_reverseGeocoder.GetNearbyStreets(feature, streets);
for (size_t i = 0; i < streets.size(); ++i)
@@ -110,7 +114,7 @@ uint32_t FeaturesLayerMatcher::GetMatchingStreetImpl(uint32_t houseId, FeatureTy
return streets[index].m_id.m_index;
// If there is no saved street for feature, assume that it's a nearest street if it's too close.
- if (!streets.empty() && streets[0].m_distanceMeters < 100.0)
+ if (!streets.empty() && streets[0].m_distanceMeters < kMaxApproxStreetDistanceM)
return streets[0].m_id.m_index;
return kInvalidId;
diff --git a/search/v2/features_layer_matcher.hpp b/search/v2/features_layer_matcher.hpp
index 0505203cce..2b3ff2beb7 100644
--- a/search/v2/features_layer_matcher.hpp
+++ b/search/v2/features_layer_matcher.hpp
@@ -57,8 +57,8 @@ class FeaturesLayerMatcher
{
public:
static uint32_t const kInvalidId = numeric_limits<uint32_t>::max();
- static int const kMatchPoiToBuildingRadiusMeters = 50;
- static int const kMatchPoiToStreetRadiusMeters = 100;
+ static int constexpr kBuildingRadiusMeters = 50;
+ static int constexpr kStreetRadiusMeters = 100;
FeaturesLayerMatcher(Index & index, my::Cancellable const & cancellable);
void SetContext(MwmContext * context);
@@ -139,7 +139,7 @@ private:
continue;
double const distMeters = feature::GetMinDistanceMeters(buildingFt, poiCenters[j]);
- if (distMeters <= kMatchPoiToBuildingRadiusMeters)
+ if (distMeters <= kBuildingRadiusMeters)
{
fn(pois[j], buildings[i]);
isPOIProcessed[j] = true;
@@ -162,13 +162,13 @@ private:
for (size_t i = 0; i < pois.size(); ++i)
{
m_context->ForEachFeature(
- MercatorBounds::RectByCenterXYAndSizeInMeters(poiCenters[i], kMatchPoiToBuildingRadiusMeters),
+ MercatorBounds::RectByCenterXYAndSizeInMeters(poiCenters[i], kBuildingRadiusMeters),
[&](FeatureType & ft)
{
if (HouseNumbersMatch(strings::MakeUniString(ft.GetHouseNumber()), queryTokens))
{
double const distanceM = MercatorBounds::DistanceOnEarth(feature::GetCenter(ft), poiCenters[i]);
- if (distanceM < kMatchPoiToBuildingRadiusMeters)
+ if (distanceM < kBuildingRadiusMeters)
fn(pois[i], ft.GetID().m_index);
}
});
@@ -192,7 +192,7 @@ private:
{
for (auto const & street : GetNearbyStreets(poiId))
{
- if (street.m_distanceMeters > kMatchPoiToStreetRadiusMeters)
+ if (street.m_distanceMeters > kStreetRadiusMeters)
break;
uint32_t const streetId = street.m_id.m_index;
@@ -206,7 +206,7 @@ private:
for (uint32_t streetId : streets)
{
BailIfCancelled(m_cancellable);
- m_loader.ForEachInVicinity(streetId, pois, kMatchPoiToStreetRadiusMeters,
+ m_loader.ForEachInVicinity(streetId, pois, kStreetRadiusMeters,
bind(fn, _1, streetId));
}
}
@@ -329,12 +329,11 @@ private:
uint32_t GetMatchingStreet(uint32_t houseId, FeatureType & houseFeature);
uint32_t GetMatchingStreetImpl(uint32_t houseId, FeatureType & houseFeature);
- using TStreet = ReverseGeocoder::Street;
+ using TStreets = vector<ReverseGeocoder::Street>;
- vector<TStreet> const & GetNearbyStreets(uint32_t featureId);
- vector<TStreet> const & GetNearbyStreets(uint32_t featureId,
- FeatureType & feature);
- void GetNearbyStreetsImpl(FeatureType & feature, vector<TStreet> & streets);
+ TStreets const & GetNearbyStreets(uint32_t featureId);
+ TStreets const & GetNearbyStreets(uint32_t featureId, FeatureType & feature);
+ void GetNearbyStreetsImpl(FeatureType & feature, TStreets & streets);
inline void GetByIndex(uint32_t id, FeatureType & ft) const
{
@@ -348,7 +347,7 @@ private:
// Cache of streets in a feature's vicinity. All lists in the cache
// are ordered by distance from the corresponding feature.
- Cache<uint32_t, vector<TStreet>> m_nearbyStreetsCache;
+ Cache<uint32_t, TStreets> m_nearbyStreetsCache;
// Cache of correct streets for buildings. Current search algorithm
// supports only one street for a building, whereas buildings can be