35 : privateDataPath(dataPath) {
102 std::ifstream detReader;
105 if (detReader.good()) {
109 if (!detReader.good()) {
128 std::ifstream vmaReader;
131 if (vmaReader.good()) {
135 if (!vmaReader.good()) {
163 std::string EUclassShort = EUclass.substr(0, 6);
165 if (!it.value().at(
"EUClass").contains(EUclass) && it.value().at(
"EUClass").contains(EUclassShort)) {
166 EUclass = EUclassShort;
171 std::string key = it.key();
172 std::transform(key.begin(), key.end(), key.begin(), [](
char c) { return (char)::toupper(c); });
174 if (it.value().at(
"EUClass").contains(EUclass)) {
175 const std::vector<double>& Mileage = it.value().at(
"Mileage");
176 const std::vector<double>& Factor = it.value().at(
"EUClass").at(EUclass);
181 for (
int i = 1; i < (int)Mileage.size(); i++) {
183 DETFactors.insert(std::make_pair(key, Factor[0]));
186 else if (i == (
int)Mileage.size() - 1 &&
getVehMileage() > Mileage[i]) {
187 DETFactors.insert(std::make_pair(key, Factor[i]));
213 std::string Sclass =
"0";
239 std::string EUclassShort = EUclass.substr(0, 6);
241 if (!sclassJson.
at(
"EUClass").
contains(EUclass) && sclassJson.
at(
"EUClass").
contains(EUclassShort)) {
242 EUclass = EUclassShort;
248 const std::vector<double>& Factor = sclassJson.
at(EUclass);
249 int AnzYear =
getYear() - 2020 + 1;
250 Mileage = Factor[0] * std::pow(AnzYear, 3) + Factor[1] * std::pow(AnzYear, 2) + Factor[2] * AnzYear + Factor[3];
300 std::ifstream tnoxReader;
303 if (tnoxReader.good()) {
307 if (!tnoxReader.good()) {
338 std::string EUclassShort = EUclass.substr(0, 6);
341 EUclass = EUclassShort;
349 const double m = EUclassJson.
at(
"m");
350 const double c = EUclassJson.
at(
"c");
351 const double tb0 = EUclassJson.
at(
"TB")[0];
373 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 replace(std::string str, const std::string &what, const std::string &by)
Replaces all occurrences of the second string by the third string within the first string.
a class to store JSON values
bool contains(KeyT &&key) const
check the existence of an element in a JSON object
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
reference at(size_type idx)
access specified array element with bounds checking