<commit_before>//
//  LandscapeGeometry.cpp
//
//  Created by Soso Limited on 5/28/15.
//
//

#include "LandscapeGeometry.h"
#include "cinder/Path2d.h"
#include "cinder/Json.h"
#include "cinder/Xml.h"
#include "cinder/Log.h"

using namespace std;
using namespace cinder;
using namespace soso;

inline std::string toString(const ci::vec2 &vector)
{
	return "[" + toString(vector.x) + "," + toString(vector.y) + "]";
}

namespace cinder{

template<>
vec2 fromString<vec2>(const std::string &string)
{
	auto parts = split(string, ",");
	auto x = fromString<float>(parts.at(0).substr(1, parts.at(0).size()));
	auto y = fromString<float>(parts.at(1).substr(0, parts.at(1).size() - 1));

	return vec2(x, y);
}

} // namespace cinder

#pragma mark - Bar

Bar::Bar(const ci::vec2 &begin, const ci::vec2 &end, const ci::vec2 &begin_normal, const ci::vec2 &end_normal, int time, float texture_begin, float texture_end, int repeats)
: begin(begin),
	end(end),
  normal_begin(begin_normal),
  normal_end(end_normal),
	time(time),
	texture_begin(texture_begin),
	texture_end(texture_end),
	repeats(repeats)
{}

Bar::Bar(const ci::XmlTree &xml)
: begin(fromString<vec2>(xml.getChild("begin").getValue())),
	end(fromString<vec2>(xml.getChild("end").getValue())),
  normal_begin(fromString<vec2>(xml.getChild("normal_begin").getValue())),
  normal_end(fromString<vec2>(xml.getChild("normal_end").getValue())),
	time(fromString<int>(xml.getChild("time").getValue())),
	texture_begin(fromString<float>(xml.getChild("texture_begin").getValue())),
	texture_end(fromString<float>(xml.getChild("texture_end").getValue())),
	repeats(fromString<int>(xml.getChild("repeats").getValue()))
{}

ci::XmlTree Bar::toXml(float scale) const
{
	auto bar = XmlTree("b", "");
	bar.push_back(XmlTree("begin", toString(begin * scale)));
	bar.push_back(XmlTree("end", toString(end * scale)));<commit_msg>Add time divisor to android.<commit_after>//
//  LandscapeGeometry.cpp
//
//  Created by Soso Limited on 5/28/15.
//
//

#include "LandscapeGeometry.h"
#include "cinder/Path2d.h"
#include "cinder/Json.h"
#include "cinder/Xml.h"
#include "cinder/Log.h"

#if defined(CINDER_ANDROID)
	const int kTimeDivisor = 2;
#else
	const int kTimeDivisor = 1;
#endif

using namespace std;
using namespace cinder;
using namespace soso;

inline std::string toString(const ci::vec2 &vector)
{
	return "[" + toString(vector.x) + "," + toString(vector.y) + "]";
}

namespace cinder{

template<>
vec2 fromString<vec2>(const std::string &string)
{
	auto parts = split(string, ",");
	auto x = fromString<float>(parts.at(0).substr(1, parts.at(0).size()));
	auto y = fromString<float>(parts.at(1).substr(0, parts.at(1).size() - 1));

	return vec2(x, y);
}

} // namespace cinder

#pragma mark - Bar

Bar::Bar(const ci::vec2 &begin, const ci::vec2 &end, const ci::vec2 &begin_normal, const ci::vec2 &end_normal, int time, float texture_begin, float texture_end, int repeats)
: begin(begin),
	end(end),
  normal_begin(begin_normal),
  normal_end(end_normal),
	time(time),
	texture_begin(texture_begin),
	texture_end(texture_end),
	repeats(repeats)
{}

Bar::Bar(const ci::XmlTree &xml)
: begin(fromString<vec2>(xml.getChild("begin").getValue())),
	end(fromString<vec2>(xml.getChild("end").getValue())),
  normal_begin(fromString<vec2>(xml.getChild("normal_begin").getValue())),
  normal_end(fromString<vec2>(xml.getChild("normal_end").getValue())),
	time(fromString<int>(xml.getChild("time").getValue())  / kTimeDivisor),
	texture_begin(fromString<float>(xml.getChild("texture_begin").getValue())),
	texture_end(fromString<float>(xml.getChild("texture_end").getValue())),
	repeats(fromString<int>(xml.getChild("repeats").getValue()))
{}

ci::XmlTree Bar::toXml(float scale) const
{
	auto bar = XmlTree("b", "");
	bar.push_back(XmlTree("begin", toString(begin * scale)));
	bar.push_back(XmlTree("end", toString(end * scale)));
{'fraction_non_alphanumeric': 0.18974889981879367, 'fraction_numerical': 0.013461040641988092, 'mean_word_length': 6.561643835616438, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 18}, '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': '2123006', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1398, 'n_words': 244}