34 for (
size_t pos = eClass.find(
"EU"); pos != std::string::npos; pos = eClass.find(
"EU", pos + 5)) {
35 eClass.replace(pos, 2,
"EURO ");
41 : privateDataPath(dataPath) {
108 std::ifstream detReader;
111 if (detReader.good()) {
115 if (!detReader.good()) {
134 std::ifstream vmaReader;
137 if (vmaReader.good()) {
141 if (!vmaReader.good()) {
164 for (
const auto& it :
DETdata.at(
"Vehicle").at(Helper->
getvClass()).at(
"PropulsionClass").at(Helper->
getpClass()).at(
"Emission").items()) {
169 std::string EUclassShort = EUclass.substr(0, 6);
171 if (!it.value().at(
"EUClass").contains(EUclass) && it.value().at(
"EUClass").contains(EUclassShort)) {
172 EUclass = EUclassShort;
177 std::string key = it.key();
178 std::transform(key.begin(), key.end(), key.begin(), [](
char c) { return (char)::toupper(c); });
180 if (it.value().at(
"EUClass").contains(EUclass)) {
181 const std::vector<double>& Mileage = it.value().at(
"Mileage");
182 const std::vector<double>& Factor = it.value().at(
"EUClass").at(EUclass);
187 for (
int i = 1; i < (int)Mileage.size(); i++) {
189 DETFactors.insert(std::make_pair(key, Factor[0]));
192 else if (i == (
int)Mileage.size() - 1 &&
getVehMileage() > Mileage[i]) {
193 DETFactors.insert(std::make_pair(key, Factor[i]));
219 std::string Sclass =
"0";
239 if (
VMAdata.at(
"Vehicle").at(Helper->
getvClass()).at(
"PropulsionClass").at(Helper->
getpClass()).at(
"SizeClass").contains(Sclass)) {
240 const nlohmann::json& sclassJson =
VMAdata.at(
"Vehicle").at(Helper->
getvClass()).at(
"PropulsionClass").at(Helper->
getpClass()).at(
"SizeClass").at(Sclass);
245 std::string EUclassShort = EUclass.substr(0, 6);
247 if (!sclassJson.at(
"EUClass").contains(EUclass) && sclassJson.at(
"EUClass").contains(EUclassShort)) {
248 EUclass = EUclassShort;
252 if (sclassJson.contains(EUclass)) {
254 const std::vector<double>& Factor = sclassJson.at(EUclass);
255 int AnzYear =
getYear() - 2020 + 1;
256 Mileage = Factor[0] * std::pow(AnzYear, 3) + Factor[1] * std::pow(AnzYear, 2) + Factor[2] * AnzYear + Factor[3];
306 std::ifstream tnoxReader;
309 if (tnoxReader.good()) {
313 if (!tnoxReader.good()) {
344 std::string EUclassShort = EUclass.substr(0, 6);
346 if (!
TNOxdata.at(
"Vehicle").at(Helper->
getvClass()).at(
"EUClass").contains(EUclass) &&
TNOxdata.at(
"Vehicle").at(Helper->
getvClass()).at(
"EUClass").contains(EUclassShort)) {
347 EUclass = EUclassShort;
352 if (
TNOxdata.at(
"Vehicle").at(Helper->
getvClass()).at(
"EUClass").contains(EUclass)) {
354 const nlohmann::json& EUclassJson =
TNOxdata.at(
"Vehicle").at(Helper->
getvClass()).at(
"EUClass").at(EUclass);
355 const double m = EUclassJson.at(
"m");
356 const double c = EUclassJson.at(
"c");
357 const double tb0 = EUclassJson.at(
"TB")[0];
361 else if (
getAmbTemp() > EUclassJson.at(
"TB")[1]) {
379 return e1 + (px - p1) / (p2 - p1) * (e2 - e1);
static const std::string strLNF
static const std::string strPKW
static const std::string strDiesel
void setAmbTemp(const double &value)
const std::vector< std::string > privateDataPath
bool IniDETfactor(Helpers *Helper)
const bool & getUseTNOx() const
void setTNOxFilePath(const std::string &value)
const int & getYear() const
bool IniTNOxfactor(Helpers *Helper)
std::map< std::string, double > DETFactors
std::string privateDETFilePath
void setDETFilePath(const std::string &value)
bool ReadVMAFile(std::string &ErrMSG)
bool ReadDet(std::string &ErrMSG)
const std::string & getTNOxFilePath() const
double Interpolate(double px, double p1, double p2, double e1, double e2)
const double & getVehMileage() const
void setTNOxFactor(const double &value)
const std::string & getDETFilePath() const
void setVMAFilePath(const std::string &value)
bool ReadTNOx(std::string &ErrMSG)
const double & getTNOxFactor() const
Correction(const std::vector< std::string > &dataPath)
std::string privateVMAFilePath
std::string privateTNOxFilePath
const double & getAmbTemp() const
double GetMileage(Helpers *Helper)
bool ReadDETFile(std::string &ErrMSG)
void setYear(const int &value)
void setUseTNOx(const bool &value)
void setVehMileage(const double &value)
const bool & getUseDet() const
void setUseDet(const bool &value)
const std::string & getVMAFilePath() const
const std::string & getpClass() const
const std::string & getvClass() const
const std::string & getsClass() const
const std::string & geteClass() const
static std::string euroClass(std::string eClass)