forked from organicmaps/organicmaps
Get[Feature|Mercator]AddressInfo correctly fills types and name fields.
This commit is contained in:
parent
81531bc0ee
commit
99d014ccae
2 changed files with 16 additions and 5 deletions
|
@ -479,11 +479,21 @@ search::AddressInfo Framework::GetFeatureAddressInfo(FeatureType const & ft) con
|
|||
//GetLocality(pt, info);
|
||||
|
||||
info.m_house = ft.GetHouseNumber();
|
||||
// TODO(vng): Now geocoder assumes that buildings without house numbers also do not have a specified street.
|
||||
if (!info.m_house.empty())
|
||||
{
|
||||
search::ReverseGeocoder const coder(m_model.GetIndex());
|
||||
auto const streets = coder.GetNearbyFeatureStreets(ft);
|
||||
if (streets.second < streets.first.size())
|
||||
info.m_street = streets.first[streets.second].m_name;
|
||||
}
|
||||
|
||||
// TODO(vng): Why AddressInfo is responsible for types and names? Refactor out.
|
||||
string defaultName, intName;
|
||||
ft.GetPreferredNames(defaultName, intName);
|
||||
info.m_name = defaultName.empty() ? intName : defaultName;
|
||||
info.m_types = GetPrintableFeatureTypes(ft);
|
||||
|
||||
search::ReverseGeocoder const coder(m_model.GetIndex());
|
||||
vector<search::ReverseGeocoder::Street> const streets = coder.GetNearbyFeatureStreets(ft);
|
||||
if (!streets.empty())
|
||||
info.m_street = streets.front().m_name;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
|
@ -476,8 +476,9 @@ private:
|
|||
//void GetLocality(m2::PointD const & pt, search::AddressInfo & info) const;
|
||||
|
||||
public:
|
||||
/// Please use this method for debug purposes only. It always tries to find closest street.
|
||||
/// @returns address of nearby building with house number in approx 1km distance.
|
||||
search::AddressInfo GetMercatorAddressInfo(m2::PointD const & mercator) const;
|
||||
/// @returns valid street address only if it was specified in OSM for given feature; used in the editor.
|
||||
search::AddressInfo GetFeatureAddressInfo(FeatureType const & ft) const;
|
||||
vector<string> GetPrintableFeatureTypes(FeatureType const & ft) const;
|
||||
/// If feature does not have explicit street in OSM data, first value can be a closest named street.
|
||||
|
|
Loading…
Add table
Reference in a new issue