Skip to content

Commit

Permalink
add check that restrictions are off when not found in timezone polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
karenzshea committed Jun 2, 2017
1 parent 65746ed commit f497201
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 39 deletions.
115 changes: 77 additions & 38 deletions features/car/conditional_restrictions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -317,44 +317,6 @@ Feature: Car - Turn restrictions
| n | p | nj,js,js,jp,jp |
| m | p | mj,jp,jp |

@only_turning @conditionals
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"

# """
# a
# e
# b
# d
# c
# """
Given the node locations
| node | lat | lon |
| a | 51.5250 | -0.1166 |
| b | 51.5243 | -0.1159 |
| c | 51.5238 | -0.1152 |
| d | 51.5241 | -0.1167 |
| e | 51.5247 | -0.1153 |

And the ways
| nodes | name |
| ab | albic |
| bc | albic |
| db | dobe |
| be | dobe |

And the relations
| type | way:from | way:to | node:via | restriction:conditional |
| restriction | ab | be | b | only_left_turn @ (Mo-Fr 07:00-11:00) |

When I route I should get
| from | to | route | turns |
| a | c | albic,dobe,dobe,albic,albic | depart,turn left,continue uturn,turn left,arrive |
| a | e | albic,dobe,dobe | depart,turn left,arrive |

@no_turning @conditionals
Scenario: Car - only_right_turn
Given the extract extra arguments "--parse-conditional-restrictions"
Expand Down Expand Up @@ -663,8 +625,85 @@ 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 |

@only_turning @conditionals
Scenario: Car - Restriction is always off when point not found in timezone files
# 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"

# """
# a
# e
# b
# d
# c
# """
Given the node locations
| node | lat | lon |
| a | 51.5250 | -0.1166 |
| b | 51.5243 | -0.1159 |
| c | 51.5238 | -0.1152 |
| d | 51.5241 | -0.1167 |
| e | 51.5247 | -0.1153 |

And the ways
| nodes | name |
| ab | albic |
| bc | albic |
| db | dobe |
| be | dobe |

And the relations
| type | way:from | way:to | node:via | restriction:conditional |
| restriction | ab | be | b | only_left_turn @ (Mo-Fr 07:00-11:00) |

When I route I should get
| from | to | route | turns |
| a | c | albic,albic | depart,arrive |
| a | e | albic,dobe,dobe | depart,turn left,arrive |

@only_turning @conditionals
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"

# """
# a
# e
# b
# d
# c
# """
Given the node locations
| node | lat | lon |
| a | 51.5250 | -0.1166 |
| b | 51.5243 | -0.1159 |
| c | 51.5238 | -0.1152 |
| d | 51.5241 | -0.1167 |
| e | 51.5247 | -0.1153 |

And the ways
| nodes | name |
| ab | albic |
| bc | albic |
| db | dobe |
| be | dobe |

And the relations
| type | way:from | way:to | node:via | restriction:conditional |
| restriction | ab | be | b | only_left_turn @ (Mo-Fr 07:00-11:00) |

When I route I should get
| from | to | route | turns |
| a | c | albic,dobe,dobe,albic,albic | depart,turn left,turn uturn,turn left,arrive |
| a | e | albic,dobe,dobe | depart,turn left,arrive |

@only_turning @conditionals
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"
Expand Down
2 changes: 1 addition & 1 deletion src/util/timezones.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "util/timezones.hpp"
#include "util/exception.hpp"
#include "util/geojson_validation.hpp"
#include "util/log.hpp"
#include "util/timezones.hpp"

#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/path.hpp>
Expand Down

0 comments on commit f497201

Please sign in to comment.