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;
}
Example #2
0
void CaptionDescription::Init(FeatureType & f, int8_t deviceLang, int const zoomLevel,
                              feature::EGeomType const type, drule::text_type_t const mainTextType,
                              bool const auxCaptionExists)
{
  if (auxCaptionExists || type == feature::GEOM_LINE)
    f.GetPreferredNames(true /* allowTranslit */, deviceLang, m_mainText, m_auxText);
  else
    f.GetReadableName(true /* allowTranslit */, deviceLang, m_mainText);

  // Set max text size to avoid VB/IB overflow in rendering.
  size_t constexpr kMaxTextSize = 200;
  if (m_mainText.size() > kMaxTextSize)
    m_mainText = m_mainText.substr(0, kMaxTextSize) + "...";

  m_roadNumber = f.GetRoadNumber();
  m_houseNumber = f.GetHouseNumber();

  ProcessZoomLevel(zoomLevel);
  ProcessMainTextType(mainTextType);
}
Example #3
0
    void operator() (FeatureType const & f)
    {
      feature::TypesHolder types(f);
      if (!types.Has(m_coastType) && NeedProcess(types))
      {
        double const d = f.GetDistance(m_pt, m_scale);
        ASSERT_GREATER_OR_EQUAL(d, 0.0, ());

        if (IsInclude(d, types))
        {
          string name;
          f.GetReadableName(name);
          string house = f.GetHouseNumber();

          // if geom type is not GEOM_POINT, result center point doesn't matter in future use
          m2::PointD const pt =
              (types.GetGeoType() == feature::GEOM_POINT) ? f.GetCenter() : m2::PointD();

          // name, house are assigned like move semantics
          m_cont.push_back(FeatureInfoT(GetResultDistance(d, types), types, name, house, pt));
        }
      }