[reverse-geocoder] Skip address initialization for features outside of buildings.

This commit is contained in:
Yuri Gorshenin 2016-03-25 12:16:38 +03:00
parent 50f87a44d9
commit fe782535bc
3 changed files with 22 additions and 9 deletions

View file

@ -453,16 +453,25 @@ namespace
}
}
*/
search::AddressInfo Framework::GetAddressInfoAtPoint(m2::PointD const & pt) const
{
double kDistanceThresholdMeters = 0.5;
search::AddressInfo info;
search::ReverseGeocoder const coder(m_model.GetIndex());
search::ReverseGeocoder::Address addr;
coder.GetNearbyAddress(pt, addr);
info.m_house = addr.GetHouseNumber();
info.m_street = addr.GetStreetName();
info.m_distanceMeters = addr.GetDistance();
// We do not init nearby address info for points that are located
// outside of the nearby building.
if (addr.GetDistance() < kDistanceThresholdMeters)
{
info.m_house = addr.GetHouseNumber();
info.m_street = addr.GetStreetName();
info.m_distanceMeters = addr.GetDistance();
}
return info;
}
@ -482,9 +491,11 @@ search::AddressInfo Framework::GetFeatureAddressInfo(FeatureType & ft) const
search::ReverseGeocoder const coder(m_model.GetIndex());
search::ReverseGeocoder::Address addr;
coder.GetNearbyAddress(ft, addr);
info.m_house = addr.GetHouseNumber();
info.m_street = addr.GetStreetName();
if (coder.GetExactAddress(ft, addr))
{
info.m_house = addr.GetHouseNumber();
info.m_street = addr.GetStreetName();
}
// TODO(vng): Why AddressInfo is responsible for types and names? Refactor out.
string defaultName, intName;

View file

@ -125,10 +125,12 @@ void ReverseGeocoder::GetNearbyAddress(m2::PointD const & center, Address & addr
}
}
void ReverseGeocoder::GetNearbyAddress(FeatureType & ft, Address & addr) const
bool ReverseGeocoder::GetExactAddress(FeatureType & ft, Address & addr) const
{
if (ft.GetHouseNumber().empty())
return false;
HouseTable table(m_index);
(void)GetNearbyAddress(table, FromFeature(ft, 0.0 /* distMeters */), addr);
return GetNearbyAddress(table, FromFeature(ft, 0.0 /* distMeters */), addr);
}
bool ReverseGeocoder::GetNearbyAddress(HouseTable & table, Building const & bld,

View file

@ -90,7 +90,7 @@ public:
void GetNearbyAddress(m2::PointD const & center, Address & addr) const;
/// @return The exact address for feature.
/// @precondition ft Should have house number.
void GetNearbyAddress(FeatureType & ft, Address & addr) const;
bool GetExactAddress(FeatureType & ft, Address & addr) const;
private: