Commit 06d1c155 authored by Pino Toscano's avatar Pino Toscano
Browse files

Avoid NaN comparisons

In case any of latitude or longitude is NaN, immediately return
Tz::Undefined, instead of attempting comparisons the timezone range.

This fixes the timezone lookup on some architectures.
parent 8a13ede9
Pipeline #38537 passed with stage
in 8 minutes and 51 seconds
......@@ -11,6 +11,8 @@
#include <QTimeZone>
#include <cmath>
using namespace KItinerary;
const char* KnowledgeDb::tzId(KnowledgeDb::Tz tz)
......@@ -43,6 +45,10 @@ KnowledgeDb::CountryId KnowledgeDb::countryForTimezone(KnowledgeDb::Tz tz)
KnowledgeDb::Tz KnowledgeDb::timezoneForCoordinate(float lat, float lon, bool *ambiguous)
{
if (std::isnan(lat) || std::isnan(lon)) {
return Tz::Undefined;
}
// see arctic latitude filter in the generator script, we only cover 65°S to 80°N
if (lat < timezone_index_params.yStart || lat > timezone_index_params.yEnd()) {
return Tz::Undefined;
......
Markdown is supported
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