Add local time support for windows

This commit is contained in:
Michael Krasnyk 2017-06-02 17:01:59 +02:00
parent 0e39320a77
commit 50d9c4b34a
No known key found for this signature in database
GPG Key ID: 49C12AD0F43D2108
11 changed files with 278 additions and 49 deletions

View File

@ -1,9 +1,7 @@
module.exports = {
default: '--strict --tags ~@stress --tags ~@todo --tags ~@conditionals --require features/support --require features/step_definitions',
default: '--strict --tags ~@stress --tags ~@todo --require features/support --require features/step_definitions',
verify: '--strict --tags ~@stress --tags ~@todo -f progress --require features/support --require features/step_definitions',
todo: '--strict --tags @todo --require features/support --require features/step_definitions',
all: '--strict --require features/support --require features/step_definitions',
mld: '--strict --tags ~@stress --tags ~@todo --tags ~@alternative --tags ~@matrix --tags ~@trip --tags --require features/support --require features/step_definitions -f progress',
conditionals: '--strict --tags @conditionals --require features/support --require features/step_definitions',
mld_conditionals: '--strict --tags @conditionals --require features/support --require features/step_definitions -f progress'
mld: '--strict --tags ~@stress --tags ~@todo --tags ~@alternative --tags ~@matrix --tags ~@trip --tags --require features/support --require features/step_definitions -f progress'
}

View File

@ -13,8 +13,8 @@ Feature: Car - Turn restrictions
Scenario: Car - ignores unrecognized restriction
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
n
@ -43,8 +43,8 @@ Feature: Car - Turn restrictions
Scenario: Car - Restriction would be on, but the restriction was badly tagged
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
@ -76,8 +76,8 @@ Feature: Car - Turn restrictions
Scenario: Car - ignores except restriction
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
n
@ -108,8 +108,8 @@ Feature: Car - Turn restrictions
Scenario: Car - only_right_turn
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
n
@ -138,8 +138,8 @@ Feature: Car - Turn restrictions
Scenario: Car - No right turn
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
n
@ -168,8 +168,8 @@ Feature: Car - Turn restrictions
Scenario: Car - only_left_turn
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
n
@ -198,8 +198,8 @@ Feature: Car - Turn restrictions
Scenario: Car - No left turn
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
n
@ -228,8 +228,8 @@ Feature: Car - Turn restrictions
Scenario: Car - Conditional restriction is off
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
n
@ -258,8 +258,8 @@ Feature: Car - Turn restrictions
Scenario: Car - Conditional restriction is on
Given the extract extra arguments "--parse-conditional-restrictions"
# 10am utc, wed
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493805600"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493805600"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493805600"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493805600"
Given the node map
"""
n
@ -288,8 +288,8 @@ Feature: Car - Turn restrictions
Scenario: Car - Conditional restriction with multiple time windows
Given the extract extra arguments "--parse-conditional-restrictions"
# 5pm Wed 02 May, 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493744400"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493744400"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493744400"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493744400"
Given the node map
"""
@ -321,8 +321,8 @@ Feature: Car - Turn restrictions
Scenario: Car - only_right_turn
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
n
@ -351,8 +351,8 @@ Feature: Car - Turn restrictions
Scenario: Car - No right turn
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
n
@ -381,8 +381,8 @@ Feature: Car - Turn restrictions
Scenario: Car - only_left_turn
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
n
@ -411,8 +411,8 @@ Feature: Car - Turn restrictions
Scenario: Car - No left turn
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
n
@ -441,8 +441,8 @@ Feature: Car - Turn restrictions
Scenario: Car - Conditional restriction is off
Given the extract extra arguments "--parse-conditional-restrictions"
# time stamp for 10am on Tues, 02 May 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493719200"
Given the node map
"""
n
@ -471,8 +471,8 @@ Feature: Car - Turn restrictions
Scenario: Car - Conditional restriction is on
Given the extract extra arguments "--parse-conditional-restrictions"
# 10am utc, wed
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493805600"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493805600"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493805600"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493805600"
Given the node map
"""
n
@ -501,8 +501,8 @@ Feature: Car - Turn restrictions
Scenario: Car - Conditional restriction with multiple time windows
Given the extract extra arguments "--parse-conditional-restrictions"
# 5pm Wed 02 May, 2017 GMT
Given the contract extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493744400"
Given the customize extra arguments "--time-zone-file=test/data/tz/guinea.geojson --parse-conditionals-from-now=1493744400"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493744400"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/guinea.geojson --parse-conditionals-from-now=1493744400"
Given the node map
"""
@ -534,9 +534,9 @@ Feature: Car - Turn restrictions
@no_turning @conditionals
Scenario: Car - DC North capitol situation, two on one off
Given the extract extra arguments "--parse-conditional-restrictions=1"
# 9pm Wed 02 May, 2017 UTC, 5pm EST
Given the contract extra arguments "--time-zone-file=test/data/tz/dc.geojson --parse-conditionals-from-now=1493845200"
Given the customize extra arguments "--time-zone-file=test/data/tz/dc.geojson --parse-conditionals-from-now=1493845200"
# 9pm Wed 02 May, 2017 UTC, 5pm EDT
Given the contract extra arguments "--time-zone-file=test/data/tz/win/dc.geojson --parse-conditionals-from-now=1493845200"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/dc.geojson --parse-conditionals-from-now=1493845200"
# """
# a h
@ -582,8 +582,8 @@ Feature: Car - Turn restrictions
Scenario: Car - DC North capitol situation, one on two off
Given the extract extra arguments "--parse-conditional-restrictions=1"
# 10:30am utc, wed, 6:30am est
Given the contract extra arguments "--time-zone-file=test/data/tz/dc.geojson --parse-conditionals-from-now=1493807400"
Given the customize extra arguments "--time-zone-file=test/data/tz/dc.geojson --parse-conditionals-from-now=1493807400"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/dc.geojson --parse-conditionals-from-now=1493807400"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/dc.geojson --parse-conditionals-from-now=1493807400"
# """
# a h
@ -630,8 +630,8 @@ Feature: Car - Turn restrictions
# same test as the following one, but given a different time zone file
Given the extract extra arguments "--parse-conditional-restrictions"
# 9am UTC, 10am BST
Given the contract extra arguments "--time-zone-file=test/data/tz/dc.geojson --parse-conditionals-from-now=1493802000"
Given the customize extra arguments "--time-zone-file=test/data/tz/dc.geojson --parse-conditionals-from-now=1493802000"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/dc.geojson --parse-conditionals-from-now=1493802000"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/dc.geojson --parse-conditionals-from-now=1493802000"
# """
# a
@ -668,8 +668,8 @@ Feature: Car - Turn restrictions
Scenario: Car - Somewhere in london, the UK, GMT timezone
Given the extract extra arguments "--parse-conditional-restrictions"
# 9am UTC, 10am BST
Given the contract extra arguments "--time-zone-file=test/data/tz/london.geojson --parse-conditionals-from-now=1493802000"
Given the customize extra arguments "--time-zone-file=test/data/tz/london.geojson --parse-conditionals-from-now=1493802000"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/london.geojson --parse-conditionals-from-now=1493802000"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/london.geojson --parse-conditionals-from-now=1493802000"
# """
# a
@ -706,8 +706,8 @@ Feature: Car - Turn restrictions
Scenario: Car - Somewhere in London, the UK, GMT timezone
Given the extract extra arguments "--parse-conditional-restrictions=1"
# 9am UTC, 10am BST
Given the contract extra arguments "--time-zone-file=test/data/tz/london.geojson --parse-conditionals-from-now=1493802000"
Given the customize extra arguments "--time-zone-file=test/data/tz/london.geojson --parse-conditionals-from-now=1493802000"
Given the contract extra arguments "--time-zone-file=test/data/tz/win/london.geojson --parse-conditionals-from-now=1493802000"
Given the customize extra arguments "--time-zone-file=test/data/tz/win/london.geojson --parse-conditionals-from-now=1493802000"
# """
# a

View File

@ -16,6 +16,8 @@
#include <string>
#include <unordered_map>
#include <time.h>
// Function loads time zone shape polygons, computes a zone local time for utc_time,
// creates a lookup R-tree and returns a lambda function that maps a point
// to the corresponding local time
@ -86,9 +88,15 @@ void Timezoner::LoadLocalTimesRTree(rapidjson::Document &geojson, std::time_t ut
if (it == local_time_memo.end())
{
struct tm timeinfo;
#if defined(_WIN32)
_putenv_s("TZ", tzname);
_tzset();
localtime_s(&timeinfo, &utc_time);
#else
setenv("TZ", tzname, 1);
tzset();
localtime_r(&utc_time, &timeinfo);
#endif
it = local_time_memo.insert({tzname, timeinfo}).first;
}
@ -158,6 +166,7 @@ boost::optional<struct tm> Timezoner::operator()(const point_t &point) const
if (boost::geometry::within(point, local_times[index].first))
return local_times[index].second;
}
return boost::none;
}
}
}

View File

@ -0,0 +1,7 @@
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "tzid": "EST+5EDT" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -77.22564697265625, 38.758366935612784 ], [ -77.22564697265625, 39.030919255760622 ], [ -76.8218994140625, 39.030919255760622 ], [ -76.8218994140625, 38.758366935612784 ], [ -77.22564697265625, 38.758366935612784 ] ] ] } }
]
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,195 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"tzid": "GMT0BST"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-4.115297325087907,
54.52745749948722
],
[
-4.0344301,
54.479
],
[
-3.9654913,
54.292
],
[
-3.9921158,
54.219
],
[
-4.1294243,
54.062
],
[
-4.3969301,
53.905
],
[
-4.4945949,
53.869
],
[
-4.8076135,
53.845
],
[
-4.9658203125,
53.863090828317766
],
[
-4.9658203125,
54.35334454933009
],
[
-4.8948807,
54.392
],
[
-4.868376,
54.4339904
],
[
-4.542761329182349,
54.52745749948722
],
[
-4.115297325087907,
54.52745749948722
]
]
]
}
},
{
"type": "Feature",
"properties": {
"tzid": "Europe\\/London"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-4.9658203125,
52.99176453037065
],
[
-4.8118632,
53.085
],
[
-4.9658203125,
53.175318218576706
],
[
-4.9658203125,
53.42898022700984
],
[
-4.8911294,
53.532
],
[
-4.7808677,
53.595
],
[
-4.6646014,
53.621
],
[
-4.4026046,
53.634
],
[
-4.147566,
53.599
],
[
-4.0053089,
53.526
],
[
-3.8324713,
53.541
],
[
-3.6271987,
53.508
],
[
-3.4402166,
53.547
],
[
-3.4248294,
53.62
],
[
-3.3683406,
53.697
],
[
-3.3958062,
53.764
],
[
-3.3917274,
53.8697263
],
[
-3.5494708,
53.99
],
[
-3.605841,
54.079
],
[
-3.729297,
54.198
],
[
-3.7790165,
54.288
],
[
-3.9491542,
54.4245157
],
[
-4.115297325087907,
54.52745749948722
],
[
-2.13134765625,
54.52745749948722
],
[
-2.13134765625,
52.65639394198803
],
[
-4.9658203125,
52.65639394198803
],
[
-4.9658203125,
52.99176453037065
]
]
]
}
}
]
}

View File

@ -0,0 +1,7 @@
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "tzid": "GMT0BST" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -0.212860107421875, 51.468766318140872 ], [ -0.212860107421875, 51.573868997085803 ], [ -0.014076232910156, 51.573868997085803 ], [ -0.014076232910156, 51.468766318140872 ], [ -0.212860107421875, 51.468766318140872 ] ] ] } }
]
}