Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
e477021c
Commit
e477021c
authored
Oct 17, 2021
by
Volker Krause
Browse files
Remove all external use of timezoneForCoordinate as well
parent
636e3ff4
Pipeline
#89387
passed with stage
in 14 minutes and 7 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
autotests/airportdbtest.cpp
View file @
e477021c
...
...
@@ -129,7 +129,7 @@ private Q_SLOTS:
const
auto
coord
=
KnowledgeDb
::
coordinateForAirport
(
KnowledgeDb
::
IataCode
{
"HKG"
});
QVERIFY
(
coord
.
isValid
());
QVERIFY
(
LocationUtil
::
distance
(
coord
.
latitude
,
coord
.
longitude
,
22.31600
,
113.93688
)
<
500
);
QCOMPARE
(
KnowledgeDb
::
timezoneFor
Coordinate
(
coord
.
latitude
,
coord
.
longitude
),
KnowledgeDb
::
Tz
::
Asia
_
Hong_Kong
);
QCOMPARE
(
KnowledgeDb
::
timezoneFor
Location
(
coord
.
latitude
,
coord
.
longitude
,
{}),
QTimeZone
(
"
Asia
/
Hong_Kong
"
)
);
const
auto
country
=
KnowledgeDb
::
countryForAirport
(
KnowledgeDb
::
IataCode
{
"HKG"
});
QCOMPARE
(
country
,
KnowledgeDb
::
CountryId
{
"CN"
});
QCOMPARE
(
KnowledgeDb
::
timezoneForLocation
(
coord
.
latitude
,
coord
.
longitude
,
country
),
QTimeZone
(
"Asia/Shanghai"
));
...
...
autotests/knowledgedbtest.cpp
View file @
e477021c
...
...
@@ -260,13 +260,13 @@ private Q_SLOTS:
using
namespace
KnowledgeDb
;
// basic checks in all quadrants
QCOMPARE
(
timezoneFor
Coordinate
(
52.4
,
13.1
),
Tz
::
Europe
_
Berlin
);
QCOMPARE
(
timezoneFor
Coordinate
(
-
8.0
,
-
35.0
),
Tz
::
America
_
Recife
);
QCOMPARE
(
timezoneFor
Coordinate
(
-
36.5
,
175.0
),
Tz
::
Pacific
_
Auckland
);
QCOMPARE
(
timezoneFor
Coordinate
(
44.0
,
-
79.5
),
Tz
::
America
_
Toronto
);
QCOMPARE
(
timezoneFor
Location
(
52.4
,
13.1
,
{}),
QTimeZone
(
"
Europe
/
Berlin
"
)
);
QCOMPARE
(
timezoneFor
Location
(
-
8.0
,
-
35.0
,
{}),
QTimeZone
(
"
America
/
Recife
"
)
);
QCOMPARE
(
timezoneFor
Location
(
-
36.5
,
175.0
,
{}),
QTimeZone
(
"
Pacific
/
Auckland
"
)
);
QCOMPARE
(
timezoneFor
Location
(
44.0
,
-
79.5
,
{}),
QTimeZone
(
"
America
/
Toronto
"
)
);
// Special case: Northern Vietnam has a Thai timezone
QCOMPARE
(
timezoneFor
Coordinate
(
21.0
,
106.0
),
Tz
::
Asia
_
Bangkok
);
QCOMPARE
(
timezoneFor
Location
(
21.0
,
106.0
,
{}),
QTimeZone
(
"
Asia
/
Bangkok
"
)
);
// Maastricht (NL), very close to the BE border
QCOMPARE
(
timezoneForLocation
(
50.8505
,
5.6881
,
CountryId
{}),
QTimeZone
(
"Europe/Amsterdam"
));
...
...
@@ -288,10 +288,8 @@ private Q_SLOTS:
// Baarle, the ultimate special case, NL/BE differs house by house
QCOMPARE
(
timezoneForLocation
(
51.44344
,
4.93373
,
CountryId
{
"BE"
}),
QTimeZone
(
"Europe/Brussels"
));
QCOMPARE
(
timezoneForLocation
(
51.44344
,
4.93373
,
CountryId
{
"NL"
}),
QTimeZone
(
"Europe/Amsterdam"
));
bool
ambiguous
=
false
;
auto
tz
=
timezoneForCoordinate
(
51.44344
,
4.93373
,
&
ambiguous
);
QVERIFY
(
ambiguous
);
QVERIFY
(
tz
==
Tz
::
Europe_Amsterdam
||
tz
==
Tz
::
Europe_Brussels
);
const
auto
tz
=
timezoneForLocation
(
51.44344
,
4.93373
,
{});
QVERIFY
(
tz
==
QTimeZone
(
"Europe/Amsterdam"
)
||
tz
==
QTimeZone
(
"Europe/Brussels"
));
// Eliat Airport (IL), close to JO, and with a minor timezone variation due to different weekends
QCOMPARE
(
timezoneForLocation
(
29.72530
,
35.00598
,
CountryId
{
"IL"
}),
QTimeZone
(
"Asia/Jerusalem"
));
...
...
@@ -305,11 +303,11 @@ private Q_SLOTS:
QCOMPARE
(
timezoneForLocation
(
-
31.4
,
-
64.2
,
CountryId
{
"AR"
}),
QTimeZone
(
"America/Argentina/Cordoba"
));
// polar regions
QCOMPARE
(
timezoneFor
Coordinate
(
-
90.0
,
0.0
),
Tz
::
Undefined
);
QCOMPARE
(
timezoneFor
Coordinate
(
90.0
,
0.0
),
Tz
::
Undefined
);
QCOMPARE
(
timezoneFor
Location
(
-
90.0
,
0.0
,
{}),
QTimeZone
()
);
QCOMPARE
(
timezoneFor
Location
(
90.0
,
0.0
,
{}),
QTimeZone
()
);
// Hong Kong seems problematic on FreeBSD
QCOMPARE
(
timezoneFor
Coordinate
(
22.31600
,
113.93688
),
Tz
::
Asia
_
Hong_Kong
);
QCOMPARE
(
timezoneFor
Location
(
22.31600
,
113.93688
,
{}),
QTimeZone
(
"
Asia
/
Hong_Kong
"
)
);
// coordinates not provided
QCOMPARE
(
timezoneForLocation
(
NAN
,
NAN
,
CountryId
{
"LU"
}),
QTimeZone
(
"Europe/Luxembourg"
));
...
...
src/lib/knowledgedb/timezonedb.cpp
View file @
e477021c
...
...
@@ -44,8 +44,9 @@ KnowledgeDb::CountryId KnowledgeDb::countryForTimezone(KnowledgeDb::Tz tz)
return
timezone_country_map
[
static_cast
<
std
::
underlying_type
<
KnowledgeDb
::
Tz
>::
type
>
(
tz
)];
}
KnowledgeDb
::
Tz
KnowledgeDb
::
timezoneForCoordinate
(
float
lat
,
float
lon
,
bool
*
ambiguous
)
static
KnowledgeDb
::
Tz
timezoneForCoordinate
(
float
lat
,
float
lon
,
bool
*
ambiguous
)
{
using
namespace
KnowledgeDb
;
if
(
std
::
isnan
(
lat
)
||
std
::
isnan
(
lon
))
{
return
Tz
::
Undefined
;
}
...
...
src/lib/knowledgedb/timezonedb.h
View file @
e477021c
...
...
@@ -26,11 +26,6 @@ namespace KnowledgeDb {
*/
KITINERARY_EXPORT
CountryId
countryForTimezone
(
Tz
tz
);
/** Returns the timezone for the given coordinate.
* The result can be @c Tz::Undefined if this cannot be clearly determined.
*/
KITINERARY_EXPORT
Tz
timezoneForCoordinate
(
float
lat
,
float
lon
,
bool
*
ambiguous
=
nullptr
);
/** Returns the timezone for the given location consisting of coordinates and/or country.
* Either argument can be omitted, if both are available better results can be provided.
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment