/* 14/07/2021 Alain Trinquet * Test application for QGeoCoordinate::toString() bug * with QGeoCoordinate::DegreesMinutes and * QGeoCoordinate::DegreesMinutesSeconds parameter */ #include #include #include int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); qInfo() << "Test application for QGeoCoordinate::toString() bug :"; qInfo() << " wrong result for degrees, minutes and seconds values"; qInfo() << " with QGeoCoordinate::DegreesMinutes and "; qInfo() << " QGeoCoordinate::DegreesMinutesSeconds parameters"; qInfo() << ""; // Test 1 : 0° 59.75' = 0° 59' 45" = 0,995833° double value1 = 0 + 59.0/60 + 45.0/3600; // Test only with positive values // Extract decimal and integer values of degrees, minutes and seconds from 'value1' double decimalDegrees1 = qAbs(value1); int integerDegrees1 = decimalDegrees1; double decimalMinutes1 = (decimalDegrees1 - integerDegrees1) * 60; int integerMinutes1 = decimalMinutes1; double decimalSeconds1 = (decimalMinutes1 - integerMinutes1) * 60; qInfo() << "TEST 1 :"; qInfo() << " decimal degrees : " << decimalDegrees1; // 0.995833 qInfo() << " integer degrees : " << integerDegrees1; // 0 qInfo() << " decimal minutes : " << decimalMinutes1; // 59.75 qInfo() << " integer minutes : " << integerMinutes1; // 59 qInfo() << " decimal seconds : " << decimalSeconds1; // 45 qInfo() << ""; // Construct QGeoCoordinate object with decimal degrees as latitude and longitude QGeoCoordinate test1(decimalDegrees1, decimalDegrees1); qInfo() << " QGeoCoordinate object created with " << decimalDegrees1 << " as latitude and longitude."; qInfo() << ""; qInfo() << " Check QGeoCoordinate created object :"; qInfo() << " latitude() : " << test1.latitude(); qInfo() << " longitude() : " << test1.longitude(); qInfo() << " toString(Degrees) : " << test1.toString(QGeoCoordinate::Degrees); qInfo() << " toString(DegreesMinutes) : " << test1.toString(QGeoCoordinate::DegreesMinutes) << " --> bug !!!"; qInfo() << " toString(DegreesMinutesSeconds) : " << test1.toString(QGeoCoordinate::DegreesMinutesSeconds); qInfo() << ""; // Test 2 : 0° 58.9933' = 0° 58' 59.6" = 0,9832222° double value2 = 0 + 58.0/60 + 59.6/3600; // Test only with positive values // Extract decimal and integer values of degrees, minutes and seconds from 'value2' double decimalDegrees2 = qAbs(value2); int integerDegrees2 = decimalDegrees2; double decimalMinutes2 = (decimalDegrees2 - integerDegrees2) * 60; int integerMinutes2 = decimalMinutes2; double decimalSeconds2 = (decimalMinutes2 - integerMinutes2) * 60; qInfo() << "TEST 2 :"; qInfo() << " decimal degrees : " << decimalDegrees2; // 0,983222 qInfo() << " integer degrees : " << integerDegrees2; // 0 qInfo() << " decimal minutes : " << decimalMinutes2; // 58.9933 qInfo() << " integer minutes : " << integerMinutes2; // 58 qInfo() << " decimal seconds : " << decimalSeconds2; // 59.6 qInfo() << ""; // Construct QGeoCoordinate object with decimal degrees as latitude and longitude QGeoCoordinate test2(decimalDegrees2, decimalDegrees2); qInfo() << " QGeoCoordinate object created with " << decimalDegrees2 << " as latitude and longitude."; qInfo() << ""; qInfo() << " Check QGeoCoordinate created object :"; qInfo() << " latitude() : " << test2.latitude(); qInfo() << " longitude() : " << test2.longitude(); qInfo() << " toString(Degrees) : " << test2.toString(QGeoCoordinate::Degrees); qInfo() << " toString(DegreesMinutes) : " << test2.toString(QGeoCoordinate::DegreesMinutes); qInfo() << " toString(DegreesMinutesSeconds) : " << test2.toString(QGeoCoordinate::DegreesMinutesSeconds) << " --> bug!!!"; qInfo() << ""; qInfo() << "End of test application"; return a.exec(); }