Should throw error on reading ill-formed .pet-file (e.g. wrong decimal separator)
Part of this problem was that PeTrack did not complain on ill-formed XML files, where the floating-point numbers were saved in the wrong format in the .pet file. We should check whether parsing of the number was successfull, instead of continuing with the default value. This is going to lead to even more noise for each single parameter:
if(subElem.hasAttribute("AVG_PH"))
{
bool parsedSuccessfully = false;
mPointHeightAvg = subElem.attribute("AVG_PH").toDouble(&parsedSuccessfully);
if(!parsedSuccessfully){
throw std::runtime_error("Could not parse parameter xxx successfully. Ill-formed .pet-file.");
}
}
(possibly adding checks for the bounds that are e.g. set for the UI element and need to be respected as well)
I propose adding a few new helper methods which abstract all of this away, such that we can call sth. like
mPointHeightAvg = read_double(subElem, "AVG_PH", /*default_value*/ 0);
Click to expand (old content of issue)
Floating point number in pet file can have comma separation like 1,2 instead of 1.2 An example can be found here: ias-7_ped:/experiments/2018.11.28_Palestine_ArabAmericanUniversity_SingleFile/data/Extracted data - PeTrack/pet_files/NikonD3300/UX_14_3.petSuggestion:
- force PeTrack to write "." instead of ","
- force PeTrack to write no separation for thousands etc.
- not touching reading pet files (for older projects where this problem caused no error until today)
This only occurs in these files and it does not seem like there is a bug in PeTrack that created these files, however it is likely that the parsing failed and we just went on with it; we should notify the user and abort the loading of the pet-file (i.e. throw a descriptive exception)