feat(#19647): check longitude and latitude max value
This commit is contained in:
parent
5e9e75537a
commit
f501c57fc3
|
@ -1446,6 +1446,8 @@ get_latitude_or_longitude(gchar *buf, int option, guint64 unmasked_value)
|
||||||
*/
|
*/
|
||||||
const guint variableBitSize = 34;
|
const guint variableBitSize = 34;
|
||||||
const guint fractionnalBitSize = 25;
|
const guint fractionnalBitSize = 25;
|
||||||
|
const guint64 maxlatitude = (G_GINT64_CONSTANT(0x1) << fractionnalBitSize) * G_GINT64_CONSTANT(90); // 90 degrees
|
||||||
|
const guint64 maxlongitude = (G_GINT64_CONSTANT(0x1) << fractionnalBitSize) * G_GINT64_CONSTANT(180); // 180 degrees
|
||||||
|
|
||||||
guint64 masked_value = getUint64MaskedValue(unmasked_value, variableBitSize); // get 34-bit value
|
guint64 masked_value = getUint64MaskedValue(unmasked_value, variableBitSize); // get 34-bit value
|
||||||
|
|
||||||
|
@ -1462,6 +1464,7 @@ get_latitude_or_longitude(gchar *buf, int option, guint64 unmasked_value)
|
||||||
guint64 fixedSizeDecimal = convertFractionalToFixedSizeDecimal(absolute_value, fractionnalBitSize, numberOfDigitToDisplay);
|
guint64 fixedSizeDecimal = convertFractionalToFixedSizeDecimal(absolute_value, fractionnalBitSize, numberOfDigitToDisplay);
|
||||||
|
|
||||||
const char *direction;
|
const char *direction;
|
||||||
|
const char *err_str = "";
|
||||||
if (option == 0){
|
if (option == 0){
|
||||||
// Latitude - north/south directions
|
// Latitude - north/south directions
|
||||||
if (isNegative){
|
if (isNegative){
|
||||||
|
@ -1469,6 +1472,9 @@ get_latitude_or_longitude(gchar *buf, int option, guint64 unmasked_value)
|
||||||
} else {
|
} else {
|
||||||
direction = "North";
|
direction = "North";
|
||||||
}
|
}
|
||||||
|
if(absolute_value > maxlatitude){
|
||||||
|
err_str = "[Error: value > 90 degrees] ";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Longitude - east/west directions
|
// Longitude - east/west directions
|
||||||
if (isNegative){
|
if (isNegative){
|
||||||
|
@ -1476,12 +1482,16 @@ get_latitude_or_longitude(gchar *buf, int option, guint64 unmasked_value)
|
||||||
} else {
|
} else {
|
||||||
direction = "East";
|
direction = "East";
|
||||||
}
|
}
|
||||||
|
if(absolute_value > maxlongitude){
|
||||||
|
err_str = "[Error: value > 180 degrees] ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const guint64 fractionalMask = (G_GINT64_CONSTANT(0x1) << fractionnalBitSize) - 1;
|
const guint64 fractionalMask = (G_GINT64_CONSTANT(0x1) << fractionnalBitSize) - 1;
|
||||||
|
|
||||||
// %04 correspond to numberOfDigitToDisplay
|
// %04 correspond to numberOfDigitToDisplay
|
||||||
snprintf(buf, ITEM_LABEL_LENGTH, "%u.%04" PRIu64 " degrees %s (0x%010" PRIX64 " - %u-bit integer part 0x%04" PRIX64 " / %u-bit fractional part 0x%08" PRIX64 ")",
|
snprintf(buf, ITEM_LABEL_LENGTH, "%s%u.%04" PRIu64 " degrees %s (0x%010" PRIX64 " - %u-bit integer part 0x%04" PRIX64 " / %u-bit fractional part 0x%08" PRIX64 ")",
|
||||||
|
err_str,
|
||||||
integerPortion, fixedSizeDecimal, direction, masked_value,
|
integerPortion, fixedSizeDecimal, direction, masked_value,
|
||||||
variableBitSize - fractionnalBitSize, masked_value >> fractionnalBitSize,
|
variableBitSize - fractionnalBitSize, masked_value >> fractionnalBitSize,
|
||||||
fractionnalBitSize, masked_value & fractionalMask
|
fractionnalBitSize, masked_value & fractionalMask
|
||||||
|
|
Loading…
Reference in New Issue