Example #1
0
bool ResultMatches(DataSource const & dataSource, shared_ptr<MatchingRule> rule,
                   search::Result const & result)
{
  bool matches = false;
  dataSource.ReadFeature([&](FeatureType & ft) { matches = rule->Matches(ft); },
                         result.GetFeatureID());
  return matches;
}
bool Matches(Context & context, Sample::Result const & golden, search::Result const & actual)
{
  static double constexpr kToleranceMeters = 50;
  if (actual.GetResultType() != Result::RESULT_FEATURE)
    return false;

  FeatureType ft;
  if (!context.GetFeature(actual.GetFeatureID(), ft))
    return false;

  string name;
  if (!ft.GetName(FeatureType::DEFAULT_LANG, name))
    name.clear();
  auto const houseNumber = ft.GetHouseNumber();
  auto const center = feature::GetCenter(ft);

  return golden.m_name == strings::MakeUniString(name) && golden.m_houseNumber == houseNumber &&
         MercatorBounds::DistanceOnEarth(golden.m_pos, center) < kToleranceMeters;
}