add testing geojson files

This commit is contained in:
karenzshea 2017-05-31 19:12:07 +02:00
parent c937d20e48
commit 564a29141e
6 changed files with 89 additions and 61 deletions

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 "--parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--parse-conditionals-from-now=1493719200"
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 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 "--parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--parse-conditionals-from-now=1493719200"
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 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 "--parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--parse-conditionals-from-now=1493719200"
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 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 "--parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--parse-conditionals-from-now=1493719200"
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 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 "--parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--parse-conditionals-from-now=1493719200"
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 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 "--parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--parse-conditionals-from-now=1493719200"
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 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 "--parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--parse-conditionals-from-now=1493719200"
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 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 "--parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--parse-conditionals-from-now=1493719200"
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 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 "--parse-conditionals-from-now=1493805600"
Given the customize extra arguments "--parse-conditionals-from-now=1493805600"
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 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 "--parse-conditionals-from-now=1493744400"
Given the customize extra arguments "--parse-conditionals-from-now=1493744400"
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 node map
"""
@ -321,8 +321,8 @@ Feature: Car - Turn restrictions
Scenario: Car - Somewhere in Liverpool, the UK, GMT timezone
Given the extract extra arguments "--parse-conditional-restrictions=1"
# 9am UTC, 10am BST
Given the contract extra arguments "--parse-conditionals-from-now=1493802000"
Given the customize extra arguments "--parse-conditionals-from-now=1493802000"
Given the contract extra arguments "--time-zone-file=test/data/tz/liverpool.geojson --parse-conditionals-from-now=1493802000"
Given the customize extra arguments "--time-zone-file=test/data/tz/liverpool.geojson --parse-conditionals-from-now=1493802000"
# """
# a
@ -355,12 +355,12 @@ Feature: Car - Turn restrictions
| a | c | albic,dobe,dobe,albic,albic | depart,turn left,continue uturn,turn left,arrive |
| a | e | albic,dobe,dobe | depart,turn left,arrive |
@shapelib @no_turning @conditionals
@no_turning @conditionals
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/OGRGeoJSON.shp --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/OGRGeoJSON.shp --parse-conditionals-from-now=1493719200"
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 node map
"""
n
@ -385,12 +385,12 @@ Feature: Car - Turn restrictions
| e | n | ej,nj,nj |
| e | p | ej,nj,nj,jp,jp |
@shapelib @no_turning @conditionals
@no_turning @conditionals
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/OGRGeoJSON.shp --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/OGRGeoJSON.shp --parse-conditionals-from-now=1493719200"
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 node map
"""
n
@ -415,12 +415,12 @@ Feature: Car - Turn restrictions
| e | n | ej,js,js,nj,nj | avoids right turn |
| e | p | ej,jp,jp | normal maneuver |
@shapelib @only_turning @conditionals
@only_turning @conditionals
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/OGRGeoJSON.shp --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/OGRGeoJSON.shp --parse-conditionals-from-now=1493719200"
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 node map
"""
n
@ -445,12 +445,12 @@ Feature: Car - Turn restrictions
| e | n | ej,js,js,nj,nj |
| e | p | ej,js,js,jp,jp |
@shapelib @no_turning @conditionals
@no_turning @conditionals
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/OGRGeoJSON.shp --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/OGRGeoJSON.shp --parse-conditionals-from-now=1493719200"
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 node map
"""
n
@ -475,12 +475,12 @@ Feature: Car - Turn restrictions
| e | n | ej,nj,nj |
| e | p | ej,jp,jp |
@shapelib @no_turning @conditionals
@no_turning @conditionals
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/OGRGeoJSON.shp --parse-conditionals-from-now=1493719200"
Given the customize extra arguments "--time-zone-file=test/data/tz/OGRGeoJSON.shp --parse-conditionals-from-now=1493719200"
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 node map
"""
n
@ -505,12 +505,12 @@ Feature: Car - Turn restrictions
| e | n | ej,nj,nj |
| e | p | ej,jp,jp |
@shapelib @no_turning @conditionals
@no_turning @conditionals
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/OGRGeoJSON.shp --parse-conditionals-from-now=1493805600"
Given the customize extra arguments "--time-zone-file=test/data/tz/OGRGeoJSON.shp --parse-conditionals-from-now=1493805600"
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 node map
"""
n
@ -535,12 +535,12 @@ Feature: Car - Turn restrictions
| e | n | ej,js,js,nj,nj |
| e | p | ej,jp,jp |
@shapelib @no_turning @conditionals
@no_turning @conditionals
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/OGRGeoJSON.shp --parse-conditionals-from-now=1493744400"
Given the customize extra arguments "--time-zone-file=test/data/tz/OGRGeoJSON.shp --parse-conditionals-from-now=1493744400"
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 node map
"""
@ -569,12 +569,12 @@ Feature: Car - Turn restrictions
| m | p | mj,jp,jp |
# https://www.openstreetmap.org/#map=18/38.91099/-77.00888
@shapelib @no_turning @conditionals
@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/OGRGeoJSON.shp --parse-conditionals-from-now=1493845200"
Given the customize extra arguments "--time-zone-file=test/data/tz/OGRGeoJSON.shp --parse-conditionals-from-now=1493845200"
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"
# """
# a h
@ -616,12 +616,12 @@ Feature: Car - Turn restrictions
| f | d | cap north,florida,florida nw | depart,turn left,arrive |
| e | c | florida ne,florida nw,cap south,cap south | depart,continue uturn,turn right,arrive |
@shapelib @no_turning @conditionals
@no_turning @conditionals
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/OGRGeoJSON.shp --parse-conditionals-from-now=1493807400"
Given the customize extra arguments "--time-zone-file=test/data/tz/OGRGeoJSON.shp --parse-conditionals-from-now=1493807400"
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"
# """
# a h
@ -663,12 +663,12 @@ Feature: Car - Turn restrictions
| f | d | cap north,florida ne,florida ne,florida nw | depart,turn sharp right,continue uturn,arrive |
| e | c | florida ne,cap south,cap south | depart,turn left,arrive |
@shapelib @only_turning @conditionals
@only_turning @conditionals
Scenario: Car - Somewhere in Liverpool, 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/OGRGeoJSON.shp --parse-conditionals-from-now=1493802000"
Given the customize extra arguments "--time-zone-file=test/data/tz/OGRGeoJSON.shp --parse-conditionals-from-now=1493802000"
Given the contract extra arguments "--time-zone-file=test/data/tz/liverpool.geojson --parse-conditionals-from-now=1493802000"
Given the customize extra arguments "--time-zone-file=test/data/tz/liverpool.geojson --parse-conditionals-from-now=1493802000"
# """
# a

View File

@ -44,14 +44,6 @@ inline void ValidateFeature(const rapidjson::Value &feature)
{
throw osrm::util::exception("Feature has non-object properties member.");
}
if (!feature["properties"].GetObject().HasMember("TZID"))
{
throw osrm::util::exception("Feature is missing TZID member in properties.");
}
else if (!feature["properties"].GetObject()["TZID"].IsString())
{
throw osrm::util::exception("Feature has non-string TZID value.");
}
if (!feature.HasMember("geometry"))
{
throw osrm::util::exception("Feature is missing geometry member.");

View File

@ -97,6 +97,15 @@ void Timezoner::LoadLocalTimesRTree(rapidjson::Document &geojson, std::time_t ut
for (rapidjson::SizeType i = 0; i < features_array.Size(); i++)
{
util::ValidateFeature(features_array[i]);
// time zone geojson specific checks
if (!features_array[i]["properties"].GetObject().HasMember("TZID") && !features_array[i]["properties"].GetObject().HasMember("tzid"))
{
throw osrm::util::exception("Feature is missing TZID member in properties.");
}
else if (!features_array[i]["properties"].GetObject()["tzid"].IsString())
{
throw osrm::util::exception("Feature has non-string TZID value.");
}
const std::string &feat_type = features_array[i].GetObject()["geometry"].GetObject()["type"].GetString();
if (feat_type == "polygon")
{
@ -141,7 +150,6 @@ struct tm Timezoner::operator()(const point_t &point) const
if (boost::geometry::within(point, local_times[index].first))
return local_times[index].second;
}
return default_time;
}
}
}

7
test/data/tz/dc.geojson Normal file
View File

@ -0,0 +1,7 @@
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "tzid": "America\/New_York" }, "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,8 @@
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "tzid": "Europe\/Isle_of_Man" }, "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.353344549330089 ], [ -4.8948807, 54.392 ], [ -4.868376, 54.4339904 ], [ -4.542761329182349, 54.52745749948722 ], [ -4.115297325087907, 54.52745749948722 ] ] ] } },
{ "type": "Feature", "properties": { "tzid": "Europe\/London" }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -4.868376, 54.4339904 ], [ -4.9658203125, 54.440433357982556 ], [ -4.9658203125, 54.52745749948722 ], [ -4.542761329182349, 54.52745749948722 ], [ -4.868376, 54.4339904 ] ] ], [ [ [ -4.9658203125, 52.991764530370652 ], [ -4.8118632, 53.085 ], [ -4.9658203125, 53.175318218576706 ], [ -4.9658203125, 53.428980227009838 ], [ -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.656393941988028 ], [ -4.9658203125, 52.656393941988028 ], [ -4.9658203125, 52.991764530370652 ] ] ] ] } }
]
}