<commit_before>#include "feature_rect.hpp"
#include "classificator.hpp"
#include "../geometry/point2d.hpp"
#include "../base/base.hpp"
#include "../base/buffer_vector.hpp"
#include "../base/macros.hpp"
#include "../base/stl_add.hpp"
#include "../std/utility.hpp"
#include "../std/vector.hpp"

namespace
{

class FeatureViewportEstimator
{
public:

  FeatureViewportEstimator()
  {
    m_TypeContinent   = GetType("place", "continent");
    m_TypeCountry     = GetType("place", "country");
    m_TypeCity        = GetType("place", "city");
    m_TypeCityCapital = GetType("place", "city", "capital");
    m_TypeTown        = GetType("place", "town");
    m_TypeVillage     = GetType("place", "village");
  }

  m2::RectD GetViewport(FeatureType const & feature) const
  {
    m2::RectD limitRect = feature.GetLimitRect(0);
    if (feature.GetFeatureType() != feature::GEOM_POINT)
      return limitRect;

    m2::PointD maxSizeMeters(0, 0);
    typedef buffer_vector<uint32_t, 8> TypeVectorT;
    TypeVectorT types;
    BackInsertFunctor<TypeVectorT> backInserter(types);
    feature.ForEachTypeRef(backInserter);
    for (size_t i = 0; i < types.size(); ++i)
    {
      m2::PointD const sizeMeters = GetSizeForType(types[i], feature);
      maxSizeMeters.x = max(maxSizeMeters.x, sizeMeters.x);
      maxSizeMeters.y = max(maxSizeMeters.y, sizeMeters.y);
    }

    m2::PointD const centerXY = limitRect.Center();
    return MercatorBounds::RectByCenterXYAndSizeInMeters(centerXY.x, centerXY.y,
                                                         maxSizeMeters.x, maxSizeMeters.y);
  }

  // Returns width and height (lon and lat) for a given type.
  m2::PointD GetSizeForType(uint32_t const type, FeatureType const & feature) const
  {
    static double const km = 1000.0;<commit_msg>Added worst feature rect support for ViewPort<commit_after>#include "feature_rect.hpp"
#include "classificator.hpp"
#include "../geometry/point2d.hpp"
#include "../base/base.hpp"
#include "../base/buffer_vector.hpp"
#include "../base/macros.hpp"
#include "../base/stl_add.hpp"
#include "../std/utility.hpp"
#include "../std/vector.hpp"

namespace
{

class FeatureViewportEstimator
{
public:

  FeatureViewportEstimator()
  {
    m_TypeContinent   = GetType("place", "continent");
    m_TypeCountry     = GetType("place", "country");
    m_TypeCity        = GetType("place", "city");
    m_TypeCityCapital = GetType("place", "city", "capital");
    m_TypeTown        = GetType("place", "town");
    m_TypeVillage     = GetType("place", "village");
  }

  m2::RectD GetViewport(FeatureType const & feature) const
  {
    m2::RectD limitRect = feature.GetLimitRect(-2);
    if (feature.GetFeatureType() != feature::GEOM_POINT)
      return limitRect;

    m2::PointD maxSizeMeters(0, 0);
    typedef buffer_vector<uint32_t, 8> TypeVectorT;
    TypeVectorT types;
    BackInsertFunctor<TypeVectorT> backInserter(types);
    feature.ForEachTypeRef(backInserter);
    for (size_t i = 0; i < types.size(); ++i)
    {
      m2::PointD const sizeMeters = GetSizeForType(types[i], feature);
      maxSizeMeters.x = max(maxSizeMeters.x, sizeMeters.x);
      maxSizeMeters.y = max(maxSizeMeters.y, sizeMeters.y);
    }

    m2::PointD const centerXY = limitRect.Center();
    return MercatorBounds::RectByCenterXYAndSizeInMeters(centerXY.x, centerXY.y,
                                                         maxSizeMeters.x, maxSizeMeters.y);
  }

  // Returns width and height (lon and lat) for a given type.
  m2::PointD GetSizeForType(uint32_t const type, FeatureType const & feature) const
  {
    static double const km = 1000.0;
{'fraction_non_alphanumeric': 0.13692946058091288, 'fraction_numerical': 0.011618257261410789, 'mean_word_length': 3.4097560975609755, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '84664', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1192, 'n_words': 241}