Commit eab52713 authored by Volker Krause's avatar Volker Krause
Browse files

Remove unnecessary handling of invalid coordinates for timezone lookup

timezoneForLocation() handles that just fine.
parent a7f80990
...@@ -310,6 +310,9 @@ private Q_SLOTS: ...@@ -310,6 +310,9 @@ private Q_SLOTS:
// Hong Kong seems problematic on FreeBSD // Hong Kong seems problematic on FreeBSD
QCOMPARE(timezoneForCoordinate(22.31600, 113.93688), Tz::Asia_Hong_Kong); QCOMPARE(timezoneForCoordinate(22.31600, 113.93688), Tz::Asia_Hong_Kong);
// coordinates not provided
QCOMPARE(timezoneForLocation(NAN, NAN, CountryId{"LU"}), QTimeZone("Europe/Luxembourg"));
} }
void testCountryFromCoordinate() void testCountryFromCoordinate()
......
...@@ -275,14 +275,8 @@ QDateTime ExtractorPostprocessorPrivate::processTrainTripTime(QDateTime dt, QDat ...@@ -275,14 +275,8 @@ QDateTime ExtractorPostprocessorPrivate::processTrainTripTime(QDateTime dt, QDat
return dt; return dt;
} }
QTimeZone tz;
const auto geo = station.geo();
const KnowledgeDb::CountryId country{station.address().addressCountry()}; const KnowledgeDb::CountryId country{station.address().addressCountry()};
if (geo.isValid()) { const auto tz = KnowledgeDb::timezoneForLocation(station.geo().latitude(), station.geo().longitude(), country);
tz = KnowledgeDb::timezoneForLocation(geo.latitude(), geo.longitude(), country);
} else {
tz = KnowledgeDb::toQTimeZone(KnowledgeDb::timezoneForCountry(country));
}
if (!tz.isValid()) { if (!tz.isValid()) {
return dt; return dt;
} }
......
...@@ -39,7 +39,7 @@ namespace KnowledgeDb { ...@@ -39,7 +39,7 @@ namespace KnowledgeDb {
*/ */
KITINERARY_EXPORT Tz timezoneForCoordinate(float lat, float lon, bool *ambiguous = nullptr); KITINERARY_EXPORT Tz timezoneForCoordinate(float lat, float lon, bool *ambiguous = nullptr);
/** Returns the timezone for the given location consisting of coordinates and country. /** Returns the timezone for the given location consisting of coordinates and/or country.
* This combines the results of the two above individual queries * This combines the results of the two above individual queries
* to obtain better results close to borders. * to obtain better results close to borders.
*/ */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment