<commit_before>#include "framework.hpp"
#include "draw_processor.hpp"
#include "drawer_yg.hpp"
#include "benchmark_provider.hpp"
#include "geourl_process.hpp"

#include "../defines.hpp"

#include "../search/search_engine.hpp"
#include "../search/result.hpp"

#include "../indexer/categories_holder.hpp"
#include "../indexer/feature.hpp"
#include "../indexer/scales.hpp"

#include "../gui/controller.hpp"

#include "../platform/settings.hpp"
#include "../platform/preferred_languages.hpp"
#include "../platform/platform.hpp"

#include "../yg/rendercontext.hpp"
#include "../yg/render_state.hpp"

#include "../base/math.hpp"

#include "../std/algorithm.hpp"
#include "../std/target_os.hpp"
#include "../std/vector.hpp"

using namespace storage;


void Framework::AddMap(string const & file)
{
  LOG(LDEBUG, ("Loading map:", file));

  //threads::MutexGuard lock(m_modelSyn);
  int const version = m_model.AddMap(file);
  if (m_lowestMapVersion == -1 || (version != -1 && m_lowestMapVersion > version))
    m_lowestMapVersion = version;
}

void Framework::RemoveMap(string const & datFile)
{
  //threads::MutexGuard lock(m_modelSyn);
  m_model.RemoveMap(datFile);
}

void Framework::SkipLocationCentering()
{
  m_centeringMode = ESkipLocationCentering;
}

void Framework::OnLocationStatusChanged(location::TLocationStatus newStatus)
{
  switch (newStatus)
  {
  case location::EStarted:
  case location::EFirstEvent:
    if (m_centeringMode != ESkipLocationCentering)
    {
      // set centering mode for the first location
      m_centeringMode = ECenterAndScale;
    }
    break;

  default:
    m_centeringMode = EDoNothing;
    m_locationState.TurnOff();
    Invalidate();
  }
}

void Framework::OnGpsUpdate(location::GpsInfo const & info)
{
  m2::RectD rect = MercatorBounds::MetresToXY(
        info.m_longitude, info.m_latitude, info.m_horizontalAccuracy);
  m2::PointD const center = rect.Center();

  m_locationState.UpdateGps(rect);

  switch (m_centeringMode)
  {
  case ECenterAndScale:
  {
    int const rectScale = scales::GetScaleLevel(rect);
    int setScale = -1;

    // correct rect scale if country isn't downloaded
    int const upperScale = scales::GetUpperWorldScale();
    if (rectScale > upperScale && IsCountryLoaded(center))
    {
      setScale = upperScale;
    }
    else
    {
      // correct rect scale for best user experience
      int const bestScale = scales::GetUpperScale() - 1;
      if (rectScale > bestScale)
        setScale = bestScale;
    }

    if (setScale != -1)
      rect = scales::GetRectForLevel(setScale, center, 1.0);

    ShowRectFixed(rect);

    m_centeringMode = ECenterOnly;
    break;
  }<commit_msg>Fix typo.<commit_after>#include "framework.hpp"
#include "draw_processor.hpp"
#include "drawer_yg.hpp"
#include "benchmark_provider.hpp"
#include "geourl_process.hpp"

#include "../defines.hpp"

#include "../search/search_engine.hpp"
#include "../search/result.hpp"

#include "../indexer/categories_holder.hpp"
#include "../indexer/feature.hpp"
#include "../indexer/scales.hpp"

#include "../gui/controller.hpp"

#include "../platform/settings.hpp"
#include "../platform/preferred_languages.hpp"
#include "../platform/platform.hpp"

#include "../yg/rendercontext.hpp"
#include "../yg/render_state.hpp"

#include "../base/math.hpp"

#include "../std/algorithm.hpp"
#include "../std/target_os.hpp"
#include "../std/vector.hpp"

using namespace storage;


void Framework::AddMap(string const & file)
{
  LOG(LDEBUG, ("Loading map:", file));

  //threads::MutexGuard lock(m_modelSyn);
  int const version = m_model.AddMap(file);
  if (m_lowestMapVersion == -1 || (version != -1 && m_lowestMapVersion > version))
    m_lowestMapVersion = version;
}

void Framework::RemoveMap(string const & datFile)
{
  //threads::MutexGuard lock(m_modelSyn);
  m_model.RemoveMap(datFile);
}

void Framework::SkipLocationCentering()
{
  m_centeringMode = ESkipLocationCentering;
}

void Framework::OnLocationStatusChanged(location::TLocationStatus newStatus)
{
  switch (newStatus)
  {
  case location::EStarted:
  case location::EFirstEvent:
    if (m_centeringMode != ESkipLocationCentering)
    {
      // set centering mode for the first location
      m_centeringMode = ECenterAndScale;
    }
    break;

  default:
    m_centeringMode = EDoNothing;
    m_locationState.TurnOff();
    Invalidate();
  }
}

void Framework::OnGpsUpdate(location::GpsInfo const & info)
{
  m2::RectD rect = MercatorBounds::MetresToXY(
        info.m_longitude, info.m_latitude, info.m_horizontalAccuracy);
  m2::PointD const center = rect.Center();

  m_locationState.UpdateGps(rect);

  switch (m_centeringMode)
  {
  case ECenterAndScale:
  {
    int const rectScale = scales::GetScaleLevel(rect);
    int setScale = -1;

    // correct rect scale if country isn't downloaded
    int const upperScale = scales::GetUpperWorldScale();
    if (rectScale > upperScale && !IsCountryLoaded(center))
    {
      setScale = upperScale;
    }
    else
    {
      // correct rect scale for best user experience
      int const bestScale = scales::GetUpperScale() - 1;
      if (rectScale > bestScale)
        setScale = bestScale;
    }

    if (setScale != -1)
      rect = scales::GetRectForLevel(setScale, center, 1.0);

    ShowRectFixed(rect);

    m_centeringMode = ECenterOnly;
    break;
  }
{'fraction_non_alphanumeric': 0.13772342427093132, 'fraction_numerical': 0.0033866415804327376, 'mean_word_length': 3.8371246587807097, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4964896', 'n_tokens_mistral': 1748, 'n_tokens_neox': 1718, 'n_words': 357}