<commit_before>// Copyright 2017 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//

#include "CoordinateConversionOptions.h"
#include "CoordinateConversionConstants.h"
#include "CoordinateFormatFactory.h"

#include "GeodatabaseTypes.h"

#include <QObject>

namespace Esri
{
namespace ArcGISRuntime
{
namespace Toolkit
{

int CoordinateFormatFactory::DMS_DECIMALPLACES = 6;
int CoordinateFormatFactory::USNG_PRECISION = 7;
bool CoordinateFormatFactory::USNG_SPACES = true;
MgrsConversionMode CoordinateFormatFactory::MGRS_CONVERSION_MODE = MgrsConversionMode::Automatic;
UtmConversionMode CoordinateFormatFactory::UTM_CONVERSION_MODE = UtmConversionMode::NorthSouthIndicators;
bool CoordinateFormatFactory::UTM_SPACES = true;
GarsConversionMode CoordinateFormatFactory::GARS_CONVERSION_MODE = GarsConversionMode::Center;

CoordinateConversionOptions* CoordinateFormatFactory::createFormat(const QString& formatName, QObject* parent)
{
  CoordinateConversionOptions* option = new CoordinateConversionOptions(parent);
  option->setName(formatName);

  if (formatName.compare(CoordinateConversionConstants::DEGREES_DECIMAL_MINUTES_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeLatLon);
    option->setLatLonFormat(LatitudeLongitudeFormat::DegreesDecimalMinutes);
  }
  else if (formatName.compare(CoordinateConversionConstants::USNG_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeUsng);
    option->setPrecision(usngPrecision());
    option->setAddSpaces(usngUseSpaces());
  }
  else if (formatName.compare(CoordinateConversionConstants::UTM_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeUtm);
    option->setUtmConversionMode(utmConversioMode());
    option->setAddSpaces(utmUseSpaces());
  }
  else if (formatName.compare(CoordinateConversionConstants::DEGREES_MINUTES_SECONDS_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeLatLon);
    option->setLatLonFormat(LatitudeLongitudeFormat::DegreesMinutesSeconds);
    option->setDecimalPlaces(degreesMinutesSecondsDecimalPlaces());
  }
  else if (formatName.compare(CoordinateConversionConstants::MGRS_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeMgrs);
    option->setMgrsConversionMode(mgrsConversionMode());
  }
  else if (formatName.compare(CoordinateConversionConstants::DECIMAL_DEGREES_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeLatLon);
    option->setLatLonFormat(LatitudeLongitudeFormat::DegreesDecimalMinutes);
  }
  else if (formatName.compare(CoordinateConversionConstants::GARS_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeGars);
    option->setGarsConversionMode(garsConversionMode());
  }
  else
  {
    delete option;
    return nullptr;
  }

  return option;
}

void CoordinateFormatFactory::setDegreesMinutesSecondsDecimalPlaces(int decimalPlaces)
{
  DMS_DECIMALPLACES = decimalPlaces;
}

int CoordinateFormatFactory::degreesMinutesSecondsDecimalPlaces()
{
  return DMS_DECIMALPLACES;
}
<commit_msg>fix incorrect format for DecimalDegrees<commit_after>// Copyright 2017 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//

#include "CoordinateFormatFactory.h"

// toolkit headers
#include "CoordinateConversionConstants.h"
#include "CoordinateConversionOptions.h"

// C++ API headers
#include "GeodatabaseTypes.h"

// Qt headers
#include <QObject>

namespace Esri
{
namespace ArcGISRuntime
{
namespace Toolkit
{

int CoordinateFormatFactory::DMS_DECIMALPLACES = 6;
int CoordinateFormatFactory::USNG_PRECISION = 7;
bool CoordinateFormatFactory::USNG_SPACES = true;
MgrsConversionMode CoordinateFormatFactory::MGRS_CONVERSION_MODE = MgrsConversionMode::Automatic;
UtmConversionMode CoordinateFormatFactory::UTM_CONVERSION_MODE = UtmConversionMode::NorthSouthIndicators;
bool CoordinateFormatFactory::UTM_SPACES = true;
GarsConversionMode CoordinateFormatFactory::GARS_CONVERSION_MODE = GarsConversionMode::Center;

CoordinateConversionOptions* CoordinateFormatFactory::createFormat(const QString& formatName, QObject* parent)
{
  CoordinateConversionOptions* option = new CoordinateConversionOptions(parent);
  option->setName(formatName);

  if (formatName.compare(CoordinateConversionConstants::DEGREES_DECIMAL_MINUTES_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeLatLon);
    option->setLatLonFormat(LatitudeLongitudeFormat::DegreesDecimalMinutes);
  }
  else if (formatName.compare(CoordinateConversionConstants::USNG_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeUsng);
    option->setPrecision(usngPrecision());
    option->setAddSpaces(usngUseSpaces());
  }
  else if (formatName.compare(CoordinateConversionConstants::UTM_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeUtm);
    option->setUtmConversionMode(utmConversioMode());
    option->setAddSpaces(utmUseSpaces());
  }
  else if (formatName.compare(CoordinateConversionConstants::DEGREES_MINUTES_SECONDS_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeLatLon);
    option->setLatLonFormat(LatitudeLongitudeFormat::DegreesMinutesSeconds);
    option->setDecimalPlaces(degreesMinutesSecondsDecimalPlaces());
  }
  else if (formatName.compare(CoordinateConversionConstants::MGRS_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeMgrs);
    option->setMgrsConversionMode(mgrsConversionMode());
  }
  else if (formatName.compare(CoordinateConversionConstants::DECIMAL_DEGREES_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeLatLon);
    option->setLatLonFormat(LatitudeLongitudeFormat::DecimalDegrees);
  }
  else if (formatName.compare(CoordinateConversionConstants::GARS_FORMAT, Qt::CaseInsensitive) == 0)
  {
    option->setOutputMode(CoordinateConversionOptions::CoordinateType::CoordinateTypeGars);
    option->setGarsConversionMode(garsConversionMode());
  }
  else
  {
    delete option;
    return nullptr;
  }

  return option;
}

void CoordinateFormatFactory::setDegreesMinutesSecondsDecimalPlaces(int decimalPlaces)
{
  DMS_DECIMALPLACES = decimalPlaces;
}

int CoordinateFormatFactory::degreesMinutesSecondsDecimalPlaces()
{
  return DMS_DECIMALPLACES;
}

{'fraction_non_alphanumeric': 0.09577836411609499, 'fraction_numerical': 0.003430079155672823, 'mean_word_length': 7.815116279069767, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3873302', 'n_tokens_mistral': 2307, 'n_tokens_neox': 2251, 'n_words': 351}