forked from organicmaps/organicmaps
Framework::GetNearbyFeatureStreets().
This commit is contained in:
parent
e8619063bc
commit
b8f3547282
2 changed files with 27 additions and 0 deletions
|
@ -487,6 +487,29 @@ search::AddressInfo Framework::GetFeatureAddressInfo(FeatureType const & ft) con
|
|||
return info;
|
||||
}
|
||||
|
||||
vector<string> Framework::GetNearbyFeatureStreets(FeatureType const & ft) const
|
||||
{
|
||||
search::ReverseGeocoder const coder(m_model.GetIndex());
|
||||
// Need to filter out duplicate street names.
|
||||
auto const streets = coder.GetNearbyFeatureStreets(ft);
|
||||
// Reasonable number of different nearby street names to display in UI.
|
||||
size_t const kMinNumberOfNearbyStreets = 5;
|
||||
vector<string> results;
|
||||
// Feature's street from OSM data, if exists, always goes first.
|
||||
if (streets.second < streets.first.size())
|
||||
results.push_back(streets.first[streets.second].m_name);
|
||||
for (auto const & street : streets.first)
|
||||
{
|
||||
auto const e = results.end();
|
||||
if (e == find(results.begin(), e, street.m_name))
|
||||
{
|
||||
results.push_back(street.m_name);
|
||||
if (results.size() >= kMinNumberOfNearbyStreets)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
/*
|
||||
void Framework::GetLocality(m2::PointD const & pt, search::AddressInfo & info) const
|
||||
{
|
||||
|
|
|
@ -479,6 +479,10 @@ public:
|
|||
/// Please use this method for debug purposes only. It always tries to find closest street.
|
||||
search::AddressInfo GetMercatorAddressInfo(m2::PointD const & mercator) const;
|
||||
search::AddressInfo GetFeatureAddressInfo(FeatureType const & ft) const;
|
||||
/// If feature does not have explicit street in OSM data, first value can be a closest named street.
|
||||
/// If it does have explicit street name in OSM, it goes first in the returned vector.
|
||||
/// @returns empty vector if no named streets were found around feature.
|
||||
vector<string> GetNearbyFeatureStreets(FeatureType const & ft) const;
|
||||
/// Get feature at given point even if it's invisible on the screen.
|
||||
/// TODO(AlexZ): Refactor out other similar methods.
|
||||
/// @returns nullptr if no feature was found at the given mercator point.
|
||||
|
|
Loading…
Add table
Reference in a new issue