<commit_before>#include "feature_styler.hpp"
#include "geometry_processors.hpp"
#include "proto_to_styles.hpp"

#include "../indexer/drawing_rules.hpp"
#include "../indexer/feature.hpp"
#include "../indexer/feature_visibility.hpp"
#include "../indexer/scales.hpp"
#include "../indexer/drules_include.hpp"

#include "../geometry/screenbase.hpp"

#include "../graphics/glyph_cache.hpp"

#include "../base/stl_add.hpp"

#include "../std/iterator_facade.hpp"

namespace
{
  struct less_depth
  {
    bool operator() (di::DrawRule const & r1, di::DrawRule const & r2) const
    {
      return (r1.m_depth < r2.m_depth);
    }
  };
}

namespace di
{
  uint32_t DrawRule::GetID(size_t threadSlot) const
  {
    return m_rule->GetID(threadSlot);
  }

  void DrawRule::SetID(size_t threadSlot, uint32_t id) const
  {
    m_rule->SetID(threadSlot, id);
  }

  FeatureStyler::FeatureStyler(FeatureType const & f,
                               int const zoom,
                               double const visualScale,
                               graphics::GlyphCache * glyphCache,
                               ScreenBase const * convertor,
                               m2::RectD const * rect)
    : m_hasPathText(false),
      m_visualScale(visualScale),
      m_glyphCache(glyphCache),
      m_convertor(convertor),
      m_rect(rect)
  {
    drule::KeysT keys;
    pair<int, bool> type = feature::GetDrawRule(f, zoom, keys);

    // don't try to do anything to invisible feature
    if (keys.empty())
      return;

    m_hasLineStyles = false;
    m_hasPointStyles = false;

    m_geometryType = type.first;
    m_isCoastline = type.second;

    f.GetPreferredNames(m_primaryText, m_secondaryText);

    // Draw only one text for features on the World zoom level in user's native language.
    if (zoom <= scales::GetUpperWorldScale() && !m_secondaryText.empty())
    {
      m_primaryText.swap(m_secondaryText);
      m_secondaryText.clear();
    }

    // Low zoom heuristics - don't show superlong names on World map.
    //if (zoom <= 5)
    //{
    //  if (strings::MakeUniString(m_primaryText).size() > 50)
    //    m_primaryText.clear();
    //}

    string houseNumber = f.GetHouseNumber();
    bool const hasName = !m_primaryText.empty() || !houseNumber.empty();

    m_refText = f.GetRoadNumber();

    double const population = static_cast<double>(f.GetPopulation());
    if (population == 1)
      m_popRank =  0.0;
    else
    {
      double const upperBound = 3.0E6;
      m_popRank = min(upperBound, population) / upperBound / 4;
    }

    double area = 0.0;
    if (m_geometryType != feature::GEOM_POINT)
    {
      m2::RectD const bbox = f.GetLimitRect(zoom);<commit_msg>Allow users to select houses without names by single tap.<commit_after>#include "feature_styler.hpp"
#include "geometry_processors.hpp"
#include "proto_to_styles.hpp"

#include "../indexer/drawing_rules.hpp"
#include "../indexer/feature.hpp"
#include "../indexer/feature_visibility.hpp"
#include "../indexer/ftypes_matcher.hpp"
#include "../indexer/scales.hpp"
#include "../indexer/drules_include.hpp"

#include "../geometry/screenbase.hpp"

#include "../graphics/glyph_cache.hpp"

#include "../base/stl_add.hpp"

#include "../std/iterator_facade.hpp"

namespace
{
  struct less_depth
  {
    bool operator() (di::DrawRule const & r1, di::DrawRule const & r2) const
    {
      return (r1.m_depth < r2.m_depth);
    }
  };
}

namespace di
{
  uint32_t DrawRule::GetID(size_t threadSlot) const
  {
    return m_rule->GetID(threadSlot);
  }

  void DrawRule::SetID(size_t threadSlot, uint32_t id) const
  {
    m_rule->SetID(threadSlot, id);
  }

  FeatureStyler::FeatureStyler(FeatureType const & f,
                               int const zoom,
                               double const visualScale,
                               graphics::GlyphCache * glyphCache,
                               ScreenBase const * convertor,
                               m2::RectD const * rect)
    : m_hasPathText(false),
      m_visualScale(visualScale),
      m_glyphCache(glyphCache),
      m_convertor(convertor),
      m_rect(rect)
  {
    drule::KeysT keys;
    pair<int, bool> type = feature::GetDrawRule(f, zoom, keys);

    // don't try to do anything to invisible feature
    if (keys.empty())
      return;

    m_hasLineStyles = false;
    m_hasPointStyles = false;

    m_geometryType = type.first;
    m_isCoastline = type.second;

    f.GetPreferredNames(m_primaryText, m_secondaryText);

    // Draw only one text for features on the World zoom level in user's native language.
    if (zoom <= scales::GetUpperWorldScale() && !m_secondaryText.empty())
    {
      m_primaryText.swap(m_secondaryText);
      m_secondaryText.clear();
    }

    // Low zoom heuristics - don't show superlong names on World map.
    //if (zoom <= 5)
    //{
    //  if (strings::MakeUniString(m_primaryText).size() > 50)
    //    m_primaryText.clear();
    //}

    string houseNumber;
    static ftypes::IsBuildingChecker const isBuilding;
    if (isBuilding(f))
    {
      houseNumber = f.GetHouseNumber();
      // Mark houses without names/numbers so user can select them by single tap.
      if (houseNumber.empty() && m_primaryText.empty())
        houseNumber = "·";
    }
    bool const hasName = !m_primaryText.empty() || !houseNumber.empty();

    m_refText = f.GetRoadNumber();

    double const population = static_cast<double>(f.GetPopulation());
    if (population == 1)
      m_popRank =  0.0;
    else
    {
      double const upperBound = 3.0E6;
      m_popRank = min(upperBound, population) / upperBound / 4;
    }

    double area = 0.0;
    if (m_geometryType != feature::GEOM_POINT)
    {
      m2::RectD const bbox = f.GetLimitRect(zoom);
{'fraction_non_alphanumeric': 0.12406342568391705, 'fraction_numerical': 0.007666840913051054, 'mean_word_length': 2.6168872085696284, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1513123', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1827, 'n_words': 400}