Skip to content

Commit d9b45af

Browse files
committed
logic now reject micmac step values and spatial resolution which don't follow the accepted numeric format
1 parent 54d8d4a commit d9b45af

File tree

4 files changed

+426
-3
lines changed

4 files changed

+426
-3
lines changed

sourceCode/application/logic/model/core/ComputationCore_structures.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,22 @@ bool S_CorrelationScoreMapParameters::fromQJson(const QJsonObject qjsonObj) {
229229
return(false);
230230
}
231231

232-
_thresholdRejection._f_rejectIfBelowValue = static_cast<float>(df_rejectIfBelow);
232+
if ( (df_rejectIfBelow < .0)
233+
||(df_rejectIfBelow > 999.999)) {
234+
return(false);
235+
}
236+
237+
bool bIsNotStringNumericZeroValue = false;
238+
if (!isConformToFormatPrecision_zeroValueIsAccepted(df_rejectIfBelow, 3, 5, bIsNotStringNumericZeroValue)) {
239+
return(false);
240+
}
241+
242+
if (bIsNotStringNumericZeroValue) {
243+
_thresholdRejection._f_rejectIfBelowValue = static_cast<float>(df_rejectIfBelow);
244+
} else {
245+
//to avoid to have -0 if this is the json double value
246+
_thresholdRejection._f_rejectIfBelowValue = .0;
247+
}
233248

234249
QString strKey_weighting {"option_weighting"};
235250
if (!qjsonObj.contains(strKey_weighting)) {

sourceCode/application/logic/toolbox/toolbox_conversion.cpp

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ bool string_isNotStringNumericZeroValue_and_totalCharIsEqualOrUnder(const QStrin
193193
bool &bTotalCharIsEqualOrUnder) {
194194

195195
qDebug() << __FUNCTION__<< "return: str =" << str;
196+
qDebug() << __FUNCTION__<< "totalCharIsEqualOrUnder to check:" << totalCharIsEqualOrUnder;
196197

197198
bIsNotStringNumericZeroValue = false;
198199
bTotalCharIsEqualOrUnder = false;
@@ -221,6 +222,10 @@ bool string_isNotStringNumericZeroValue_and_totalCharIsEqualOrUnder(const QStrin
221222

222223
bool stringNumericValue_isComplianWithMaxBeforeDottMaxAfterDot(const QString& str, int maxBeforeDot, int maxAfterDot) {
223224

225+
qDebug() << __FUNCTION__ << "str = " << str;
226+
qDebug() << __FUNCTION__ << "maxBeforeDot = " << maxBeforeDot;
227+
qDebug() << __FUNCTION__ << "maxAfterDot = " << maxAfterDot;
228+
224229
int textSize = str.size();
225230
if (!textSize) {
226231
return(false);
@@ -241,13 +246,59 @@ bool stringNumericValue_isComplianWithMaxBeforeDottMaxAfterDot(const QString& st
241246
}
242247

243248
bool isConformToFormatPrecision(double dValue, int maximumDecimalForStringConversion, int maxCharCountInString) {
244-
//convert using maximum decimal as maximumDecimalForStringConversion
245-
QString strOf_dValue = doubleToQStringPrecision_f_amountOfDecimal(dValue, maximumDecimalForStringConversion);
249+
//convert using maximum decimal with more than maximumDecimalForStringConversion
250+
QString strOf_dValue = doubleToQStringPrecision_f_amountOfDecimal(dValue, maximumDecimalForStringConversion+4);
251+
qDebug() << __FUNCTION__ << "#1 strOf_dValue = " << strOf_dValue;
252+
246253
//remove useless zero
247254
strOf_dValue = removeUselessZerosInNumericValueString_withoutSign_and_oneDecimalDotMaximum(strOf_dValue);
255+
qDebug() << __FUNCTION__ << "#2 strOf_dValue = " << strOf_dValue;
256+
257+
bool bCompliant = stringNumericValue_isComplianWithMaxBeforeDottMaxAfterDot(strOf_dValue,
258+
maxCharCountInString,
259+
maximumDecimalForStringConversion);
260+
qDebug() << __FUNCTION__ << "bCompliant: " << bCompliant;
261+
if (!bCompliant) {
262+
return(false);
263+
}
264+
248265
return(string_isNotStringNumericZeroValue_and_totalCharIsEqualOrUnder(strOf_dValue, maxCharCountInString));
249266
}
250267

268+
bool isConformToFormatPrecision_zeroValueIsAccepted(double dValue, int maximumDecimalForStringConversion, int maxCharCountInString,
269+
bool& bIsNotStringNumericZeroValue) {
270+
//convert using maximum decimal with more than maximumDecimalForStringConversion
271+
QString strOf_dValue = doubleToQStringPrecision_f_amountOfDecimal(dValue, maximumDecimalForStringConversion+4);
272+
qDebug() << __FUNCTION__ << "#1 strOf_dValue = " << strOf_dValue;
273+
274+
//remove useless zero
275+
strOf_dValue = removeUselessZerosInNumericValueString_withoutSign_and_oneDecimalDotMaximum(strOf_dValue);
276+
qDebug() << __FUNCTION__ << "#2 strOf_dValue = " << strOf_dValue;
277+
278+
bool bCompliant = stringNumericValue_isComplianWithMaxBeforeDottMaxAfterDot(strOf_dValue,
279+
maxCharCountInString,
280+
maximumDecimalForStringConversion);
281+
qDebug() << __FUNCTION__ << "bCompliant: " << bCompliant;
282+
if (!bCompliant) {
283+
return(false);
284+
}
285+
286+
/*bool*/ bIsNotStringNumericZeroValue = false;
287+
bool bTotalCharIsEqualOrUnder = false;
288+
/*bool bReport = */string_isNotStringNumericZeroValue_and_totalCharIsEqualOrUnder(strOf_dValue, maxCharCountInString,
289+
bIsNotStringNumericZeroValue,
290+
bTotalCharIsEqualOrUnder);
291+
if (!bTotalCharIsEqualOrUnder) {
292+
return(false);
293+
}
294+
//here if bTotalCharIsEqualOrUnder is true
295+
296+
//bIsNotStringNumericZeroValue true of false, it's ok
297+
return(true);
298+
}
299+
300+
301+
251302
bool floatToDoubleWithReducedPrecision(double dValue, int precision, double& dValueOut) {
252303

253304
qDebug() << __FUNCTION__ << "#0 strOf_dValue = " << dValue;

sourceCode/application/logic/toolbox/toolbox_conversion.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ bool string_isNotStringNumericZeroValue_and_totalCharIsEqualOrUnder(const QStrin
3535
bool stringNumericValue_isComplianWithMaxBeforeDottMaxAfterDot(const QString& str, int maxBeforeDot, int maxAfterDot);
3636

3737
bool isConformToFormatPrecision(double dValue, int maximumDecimalForStringConversion, int maxCharCountInString);
38+
bool isConformToFormatPrecision_zeroValueIsAccepted(double dValue, int maximumDecimalForStringConversion, int maxCharCountInString,
39+
bool& bIsNotStringNumericZeroValue);
40+
41+
3842
bool floatToDoubleWithReducedPrecision(double dValue, int precision, double& dValueOut);
3943

4044
/*

0 commit comments

Comments
 (0)