Compare commits
321 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c34fff5e7a | |||
| da3b7c86c5 | |||
| 4d8a9c7262 | |||
| 5de5dd0906 | |||
| 4293997406 | |||
| ef0ef90a19 | |||
| b95faabefb | |||
| 7f1f044fa0 | |||
| 7f7d7816e5 | |||
| 144536a09d | |||
| 6a4abfffda | |||
| 0084f54f0d | |||
| 34337ec3c9 | |||
| 83134c4cbd | |||
| 909d341eb8 | |||
| a5de5451f8 | |||
| 93dd806913 | |||
| cab023726c | |||
| c75c22e652 | |||
| c7c46d3ff6 | |||
| 55c6bc49d4 | |||
| 6a72e61497 | |||
| a5cdb85d79 | |||
| f32a21b02c | |||
| 0a12aab97b | |||
| 52af0a615d | |||
| 964c002b47 | |||
| d3dea9439a | |||
| 5de8f57549 | |||
| da525eb8dc | |||
| 6e2b4d3cc3 | |||
| 0a06641c2c | |||
| 9eda7d3845 | |||
| f87a13f5cf | |||
| b52c8819f5 | |||
| af57742307 | |||
| 9859808d03 | |||
| 1f18dc300f | |||
| 23d41d584b | |||
| 335be174d2 | |||
| b3aca211d6 | |||
| d1b9c09c23 | |||
| fad3fc116e | |||
| eeefb24a8e | |||
| dfce2a64f4 | |||
| 2a103c4362 | |||
| 76d64f27cc | |||
| 3d9f1e5c66 | |||
| c7b0e5abc3 | |||
| 166aebbff4 | |||
| 6ec5622ec5 | |||
| c36e8cc9ea | |||
| 7f3f98a264 | |||
| 4fd68e3970 | |||
| 94d3340d63 | |||
| ee96cbfd00 | |||
| edb4b1366f | |||
| f29e92c776 | |||
| 888f2e10e3 | |||
| 28a8079eef | |||
| c630128281 | |||
| 990ed90a2d | |||
| 467d93ffff | |||
| d4e2b5a3b8 | |||
| e9369293dc | |||
| e94384a5d9 | |||
| d820ef0796 | |||
| b61beee95c | |||
| dcb7651f40 | |||
| c6c7e1a478 | |||
| 909be09ebf | |||
| de2205cac7 | |||
| 73050c0503 | |||
| f54419d4dd | |||
| 99c8c4e7cb | |||
| 78bcaada6b | |||
| ee12704133 | |||
| 848b3815bd | |||
| 0fcdb4b8e6 | |||
| 88a1a69c1b | |||
| 222d06850c | |||
| a2612a1ebe | |||
| 598c78200f | |||
| bf8e4e8270 | |||
| 1bcdc0fa75 | |||
| 3ed46aa4c5 | |||
| 4d2be0b44c | |||
| 3135bb34b3 | |||
| ceb46b8da4 | |||
| bc0222c204 | |||
| d40f777a87 | |||
| 290101b8ce | |||
| a548155f65 | |||
| 0a4015690f | |||
| 5553dad423 | |||
| 991a0b38c5 | |||
| c9e2a8d24a | |||
| ebd8bf7c7c | |||
| 156b01ae93 | |||
| 306b0610a2 | |||
| 7e5274e6e6 | |||
| f998cb8c54 | |||
| 324cfaac83 | |||
| dbcc86c59d | |||
| 22cd9505ef | |||
| 3e1b7ad6d5 | |||
| 1c41a6b1e8 | |||
| 776c0d0ae2 | |||
| a86f09a1f7 | |||
| cecb0c547b | |||
| f8bd22dc6f | |||
| a4ccc59833 | |||
| d774a875cd | |||
| bfde117ff5 | |||
| 4bb7e734f9 | |||
| f16a865420 | |||
| c087a11659 | |||
| de1f1b8ab3 | |||
| 665f93c92f | |||
| e1d9d9c218 | |||
| 09c40db4ad | |||
| cb212a7315 | |||
| 9dbd437233 | |||
| fea6c2731a | |||
| 1d11701034 | |||
| 28fe1600ae | |||
| 7ccb3a6327 | |||
| 5edc332e49 | |||
| e68c057139 | |||
| 943a2d4ab7 | |||
| 5b00bb81e3 | |||
| e050f15cf8 | |||
| 0acf7f7400 | |||
| 9abfb7ea3b | |||
| 8a4551500d | |||
| d0c534e5fa | |||
| 822bb97a5f | |||
| 6cd3b8bc00 | |||
| a145520b5b | |||
| 3d75d15361 | |||
| 8dd3fe3173 | |||
| 0bb1b04170 | |||
| 11629e0538 | |||
| 6462ea14a2 | |||
| 993c4796c1 | |||
| b11d3ad1ba | |||
| 9681d662cb | |||
| 6a5ffc126a | |||
| 7bf2cb1917 | |||
| 2b0a1bbb63 | |||
| 31297d1c9f | |||
| 4e854399b6 | |||
| 17adeaf3e2 | |||
| cf92e52b86 | |||
| 250acf6a2a | |||
| 49c852917f | |||
| 3467696f8a | |||
| a6a4fb0d49 | |||
| d3888942e8 | |||
| 1f853385d5 | |||
| 08e56956d6 | |||
| fc027417d8 | |||
| f07da00dfe | |||
| 5bd874aab6 | |||
| 6904851eb6 | |||
| 6d70e1d47d | |||
| 7a55b46848 | |||
| 989b374d86 | |||
| 9034d0c521 | |||
| 064eb8bca7 | |||
| b63f3cc247 | |||
| 4f1503c4a1 | |||
| 64ace032f6 | |||
| 2d4fc9a0b7 | |||
| 0c4cb9fb1b | |||
| d2bd2c7ec6 | |||
| 10f8bf53b4 | |||
| 3058135f55 | |||
| ba00871793 | |||
| bd66ba9eee | |||
| dacd3b4833 | |||
| 94c465aeb9 | |||
| 1b1bb780fe | |||
| 0ce18f1658 | |||
| 811372fca8 | |||
| 21a1a2da93 | |||
| 43b0638074 | |||
| 146f20191a | |||
| 0be7ce2c0f | |||
| 1109b8de16 | |||
| 86a2b6eb07 | |||
| 1af59e874d | |||
| 09a9d6c417 | |||
| 44c12afc3f | |||
| b01c2bc8b8 | |||
| 770d9833d1 | |||
| b6c2e86443 | |||
| a4134db847 | |||
| fa56abcd58 | |||
| 611eafb4c6 | |||
| afa62064fd | |||
| 64933389ae | |||
| cb84e6009d | |||
| 6b0b160f37 | |||
| 7cc689af7d | |||
| 25bd7d6d30 | |||
| 5c6cbd2b10 | |||
| 32d5b6b1b7 | |||
| 458a1c8157 | |||
| b45efeb4bd | |||
| b5619e89c8 | |||
| e1da384b62 | |||
| b250fce92c | |||
| 11da796a70 | |||
| 2985e73938 | |||
| b5a67003fe | |||
| 4797d6f1e1 | |||
| 426f773cb7 | |||
| 5c39449263 | |||
| 1062007e67 | |||
| ea81866e28 | |||
| 3b9c772d14 | |||
| 9d1032a742 | |||
| a27f7326bd | |||
| ba3f167b99 | |||
| 8322a7ccaf | |||
| 8c71239e48 | |||
| ffb3578180 | |||
| c918d68b3e | |||
| ebdae7591b | |||
| 0ba70bcbf9 | |||
| 3cdd282e0f | |||
| 72202b7e4a | |||
| 9f9040eaf6 | |||
| bc252ea110 | |||
| bcf7741f95 | |||
| 70afe209d5 | |||
| 4e9709d038 | |||
| 8b50f48d8e | |||
| 09d70f7342 | |||
| 6f89ce516f | |||
| 666d363c93 | |||
| 0182b9a584 | |||
| cc93ed15c0 | |||
| b0a83191cd | |||
| b8f6d3ca97 | |||
| 5a0ee6d1d8 | |||
| 4e02e8e1a0 | |||
| 407509d1af | |||
| c1bea5c22d | |||
| cf63399c9f | |||
| 17382b2a28 | |||
| c2423ef20f | |||
| e6782fd30b | |||
| 77a4530433 | |||
| ee8302bf27 | |||
| 5e1a8d82d6 | |||
| cf1274de21 | |||
| 4ce786b357 | |||
| e5efee2dd8 | |||
| 20ace659b6 | |||
| 1d026882f9 | |||
| 48000008d7 | |||
| 60d83ccf53 | |||
| dcab2b19c2 | |||
| ce2c0ba160 | |||
| 776add7ea2 | |||
| dab8f76516 | |||
| db170d006a | |||
| 84d79f789c | |||
| b1d70b8a8c | |||
| 1b1211092b | |||
| 4e0f2e13bd | |||
| 28961ed593 | |||
| c32900091c | |||
| 283926dbc9 | |||
| 40bf5c6092 | |||
| 2a88477178 | |||
| f8d8289c84 | |||
| 030682fc62 | |||
| 1e891e6ec5 | |||
| 6a77ac442e | |||
| 9578b9a045 | |||
| 130c88bd0c | |||
| 2617960d6c | |||
| f10da205bb | |||
| 247d0d5290 | |||
| bb5ca42114 | |||
| 66cb69d1d2 | |||
| 48008cdc6e | |||
| 3ff86c4536 | |||
| ce82242004 | |||
| d989714007 | |||
| 9704ca7a8b | |||
| ec79d1e933 | |||
| 94f6005358 | |||
| 7d51a76e79 | |||
| 5b18278ee5 | |||
| 1d312f212a | |||
| 1258a64b3e | |||
| c57e85f391 | |||
| 59b4a142ec | |||
| bcea53460c | |||
| 72ebb3acb8 | |||
| 9e5a300cbb | |||
| bf9824502a | |||
| d69bad9cb2 | |||
| 66d241a2d8 | |||
| a1b87b5236 | |||
| 3044c5ea52 | |||
| d0636a9f6d | |||
| 0d291cb68e | |||
| c8bb50497b | |||
| ea027a7cc1 | |||
| 62e8601919 | |||
| be2cc7aed9 | |||
| 17babb22e2 | |||
| 21245273b4 | |||
| 8d7821c84e | |||
| c78dff9a15 | |||
| 25fea558ba |
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"rules": {
|
||||
"indent": [
|
||||
2,
|
||||
4
|
||||
],
|
||||
"quotes": [
|
||||
1,
|
||||
"single"
|
||||
],
|
||||
"linebreak-style": [
|
||||
2,
|
||||
"unix"
|
||||
],
|
||||
"semi": [
|
||||
2,
|
||||
"always"
|
||||
],
|
||||
"no-console": [
|
||||
1
|
||||
]
|
||||
},
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended"
|
||||
}
|
||||
@@ -40,6 +40,8 @@ Thumbs.db
|
||||
# build related files #
|
||||
#######################
|
||||
/build/
|
||||
/example/build/
|
||||
/test/data/monaco*
|
||||
/cmake/postinst
|
||||
|
||||
# Eclipse related files #
|
||||
@@ -73,7 +75,12 @@ stxxl.errlog
|
||||
###################
|
||||
/sandbox/
|
||||
|
||||
# Test related files #
|
||||
######################
|
||||
/test/profile.lua
|
||||
/test/cache
|
||||
/test/speeds.csv
|
||||
node_modules
|
||||
|
||||
# Deprecated config file #
|
||||
##########################
|
||||
|
||||
+14
-13
@@ -26,7 +26,7 @@ matrix:
|
||||
addons: &gcc5
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-5', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'rubygems-integration', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
packages: ['g++-5', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
env: COMPILER='g++-5' BUILD_TYPE='Debug'
|
||||
|
||||
- os: linux
|
||||
@@ -34,7 +34,7 @@ matrix:
|
||||
addons: &gcc48
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.8', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'rubygems-integration', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
packages: ['g++-4.8', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
env: COMPILER='g++-4.8' BUILD_TYPE='Debug'
|
||||
|
||||
- os: linux
|
||||
@@ -42,7 +42,7 @@ matrix:
|
||||
addons: &clang38
|
||||
apt:
|
||||
sources: ['llvm-toolchain-precise', 'ubuntu-toolchain-r-test']
|
||||
packages: ['clang-3.8', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'rubygems-integration', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
packages: ['clang-3.8', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Debug' RUN_CLANG_FORMAT=ON
|
||||
|
||||
- os: osx
|
||||
@@ -56,7 +56,7 @@ matrix:
|
||||
addons: &gcc5
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-5', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'rubygems-integration', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
packages: ['g++-5', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
env: COMPILER='g++-5' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
@@ -64,7 +64,7 @@ matrix:
|
||||
addons: &gcc48
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.8', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'rubygems-integration', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
packages: ['g++-4.8', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
env: COMPILER='g++-4.8' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
@@ -72,7 +72,7 @@ matrix:
|
||||
addons: &clang38
|
||||
apt:
|
||||
sources: ['llvm-toolchain-precise', 'ubuntu-toolchain-r-test']
|
||||
packages: ['clang-3.8', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'rubygems-integration', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
packages: ['clang-3.8', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Release'
|
||||
|
||||
- os: osx
|
||||
@@ -86,7 +86,7 @@ matrix:
|
||||
addons: &gcc5
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-5', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'rubygems-integration', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
packages: ['g++-5', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
env: COMPILER='g++-5' BUILD_TYPE='Release' BUILD_SHARED_LIBS=ON
|
||||
|
||||
- os: linux
|
||||
@@ -94,7 +94,7 @@ matrix:
|
||||
addons: &clang38
|
||||
apt:
|
||||
sources: ['llvm-toolchain-precise', 'ubuntu-toolchain-r-test']
|
||||
packages: ['clang-3.8', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'rubygems-integration', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
packages: ['clang-3.8', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev']
|
||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Release' BUILD_SHARED_LIBS=ON
|
||||
|
||||
|
||||
@@ -121,8 +121,11 @@ matrix:
|
||||
# compiler: clang
|
||||
# env: COMPILER='clang++' BUILD_TYPE='Release' BUILD_SHARED_LIBS=ON
|
||||
|
||||
before_install:
|
||||
- source ./scripts/install_node.sh 4
|
||||
|
||||
install:
|
||||
- npm install
|
||||
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
|
||||
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
|
||||
- |
|
||||
@@ -142,12 +145,9 @@ before_script:
|
||||
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
|
||||
./scripts/check_taginfo.py taginfo.json profiles/car.lua
|
||||
fi
|
||||
- rvm use 1.9.3
|
||||
- gem install bundler
|
||||
- bundle install
|
||||
- mkdir build && pushd build
|
||||
- export CXX=${COMPILER}
|
||||
- export OSRM_PORT=5000 OSRM_TIMEOUT=60
|
||||
- export OSRM_PORT=5000 OSRM_TIMEOUT=6000
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS:-OFF} -DBUILD_TOOLS=1 -DENABLE_CCACHE=0
|
||||
|
||||
script:
|
||||
@@ -163,8 +163,9 @@ script:
|
||||
- ./engine-tests
|
||||
- ./util-tests
|
||||
- popd
|
||||
- cucumber -p verify
|
||||
- npm test
|
||||
- make -C test/data
|
||||
- ./build/library-tests test/data/monaco.osrm
|
||||
- mkdir example/build && pushd example/build
|
||||
- cmake ..
|
||||
- make
|
||||
|
||||
+15
-1
@@ -1,3 +1,17 @@
|
||||
# 5.0.0
|
||||
# 5.0.0 RC1
|
||||
- Renamed osrm-prepare into osrm-contract
|
||||
- osrm-contract does not need a profile parameter anymore
|
||||
- New public HTTP API, find documentation [here](https://github.com/Project-OSRM/osrm-backend/wiki/New-Server-api)
|
||||
- POST support is discontinued, please use library bindings for more complex requests
|
||||
- Removed timestamp plugin
|
||||
- Coordinate order is now Longitude,Latitude
|
||||
- Cucumber tests now based on Javascript (run with `npm test`)
|
||||
- Profile API changed:
|
||||
- `forward_mode` and `backward_mode` now need to be selected from a pre-defined list
|
||||
- Global profile properties are now stored in a global `properties` element. This includes:
|
||||
- `properties.traffic_signal_penalty`
|
||||
- `properties.use_turn_restrictions`
|
||||
- `properties.u_turn_penalty`
|
||||
- `properties.allow_u_turn_at_via`
|
||||
|
||||
|
||||
|
||||
+34
-14
@@ -7,9 +7,9 @@ This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. P
|
||||
endif()
|
||||
|
||||
project(OSRM C CXX)
|
||||
set(OSRM_VERSION_MAJOR 4)
|
||||
set(OSRM_VERSION_MINOR 9)
|
||||
set(OSRM_VERSION_PATCH 1)
|
||||
set(OSRM_VERSION_MAJOR 5)
|
||||
set(OSRM_VERSION_MINOR 0)
|
||||
set(OSRM_VERSION_PATCH 0)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
include(CheckCXXCompilerFlag)
|
||||
@@ -32,6 +32,7 @@ endif()
|
||||
option(ENABLE_CCACHE "Speed up incremental rebuilds via ccache" ON)
|
||||
option(ENABLE_JSON_LOGGING "Adds additional JSON debug logging to the response" OFF)
|
||||
option(BUILD_TOOLS "Build OSRM tools" OFF)
|
||||
option(BUILD_COMPONENTS "Build OSRM tools" ON)
|
||||
option(ENABLE_ASSERTIONS OFF)
|
||||
|
||||
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include/)
|
||||
@@ -45,7 +46,7 @@ add_custom_target(FingerPrintConfigure ALL ${CMAKE_COMMAND}
|
||||
COMMENT "Configuring revision fingerprint"
|
||||
VERBATIM)
|
||||
|
||||
add_custom_target(tests DEPENDS engine-tests extractor-tests util-tests)
|
||||
add_custom_target(tests DEPENDS engine-tests extractor-tests util-tests server-tests library-tests)
|
||||
add_custom_target(benchmarks DEPENDS rtree-bench)
|
||||
|
||||
set(BOOST_COMPONENTS date_time filesystem iostreams program_options regex system thread unit_test_framework)
|
||||
@@ -55,7 +56,7 @@ configure_file(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/util/version.hpp
|
||||
)
|
||||
file(GLOB UtilGlob src/util/*.cpp)
|
||||
file(GLOB ExtractorGlob src/extractor/*.cpp)
|
||||
file(GLOB ExtractorGlob src/extractor/*.cpp src/extractor/*/*.cpp)
|
||||
file(GLOB ContractorGlob src/contractor/*.cpp)
|
||||
file(GLOB StorageGlob src/storage/*.cpp)
|
||||
file(GLOB ServerGlob src/server/*.cpp src/server/**/*.cpp)
|
||||
@@ -63,6 +64,8 @@ file(GLOB EngineGlob src/engine/*.cpp src/engine/**/*.cpp)
|
||||
file(GLOB ExtractorTestsGlob unit_tests/extractor/*.cpp)
|
||||
file(GLOB EngineTestsGlob unit_tests/engine/*.cpp)
|
||||
file(GLOB UtilTestsGlob unit_tests/util/*.cpp)
|
||||
file(GLOB ServerTestsGlob unit_tests/server/*.cpp)
|
||||
file(GLOB LibraryTestsGlob unit_tests/library/*.cpp)
|
||||
file(GLOB IOTestsGlob unit_tests/io/*.cpp)
|
||||
|
||||
add_library(UTIL OBJECT ${UtilGlob})
|
||||
@@ -79,20 +82,24 @@ add_executable(osrm-extract src/tools/extract.cpp)
|
||||
add_executable(osrm-contract src/tools/contract.cpp)
|
||||
add_executable(osrm-routed src/tools/routed.cpp $<TARGET_OBJECTS:SERVER> $<TARGET_OBJECTS:UTIL>)
|
||||
add_executable(osrm-datastore src/tools/store.cpp $<TARGET_OBJECTS:UTIL>)
|
||||
add_library(osrm src/osrm/osrm.cpp $<TARGET_OBJECTS:ENGINE> $<TARGET_OBJECTS:UTIL>)
|
||||
add_library(osrm src/osrm/osrm.cpp $<TARGET_OBJECTS:ENGINE> $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:STORAGE>)
|
||||
add_library(osrm_extract $<TARGET_OBJECTS:EXTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
||||
add_library(osrm_contract $<TARGET_OBJECTS:CONTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
||||
add_library(osrm_store $<TARGET_OBJECTS:STORAGE> $<TARGET_OBJECTS:UTIL>)
|
||||
|
||||
# Unit tests
|
||||
add_executable(engine-tests EXCLUDE_FROM_ALL unit_tests/engine_tests.cpp ${EngineTestsGlob} $<TARGET_OBJECTS:ENGINE> $<TARGET_OBJECTS:UTIL>)
|
||||
add_executable(engine-tests EXCLUDE_FROM_ALL unit_tests/engine_tests.cpp ${EngineTestsGlob} $<TARGET_OBJECTS:ENGINE> $<TARGET_OBJECTS:STORAGE> $<TARGET_OBJECTS:UTIL>)
|
||||
add_executable(extractor-tests EXCLUDE_FROM_ALL unit_tests/extractor_tests.cpp ${ExtractorTestsGlob} $<TARGET_OBJECTS:EXTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
||||
add_executable(util-tests EXCLUDE_FROM_ALL unit_tests/util_tests.cpp ${UtilTestsGlob} $<TARGET_OBJECTS:UTIL>)
|
||||
add_executable(server-tests EXCLUDE_FROM_ALL unit_tests/server_tests.cpp ${ServerTestsGlob} $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:SERVER>)
|
||||
add_executable(library-tests EXCLUDE_FROM_ALL unit_tests/library_tests.cpp ${LibraryTestsGlob})
|
||||
|
||||
# Benchmarks
|
||||
add_executable(rtree-bench EXCLUDE_FROM_ALL src/benchmarks/static_rtree.cpp $<TARGET_OBJECTS:UTIL>)
|
||||
|
||||
target_include_directories(engine-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/unit_tests)
|
||||
target_include_directories(util-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/unit_tests)
|
||||
target_include_directories(library-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/)
|
||||
target_include_directories(rtree-bench PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/unit_tests)
|
||||
|
||||
# Check the release mode
|
||||
@@ -175,8 +182,10 @@ elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
|
||||
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
||||
# using Visual Studio C++
|
||||
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} date_time chrono zlib)
|
||||
add_definitions(-DBOOST_LIB_DIAGNOSTIC)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
add_definitions(-DNOMINMAX) # avoid min and max macros that can break compilation
|
||||
add_definitions(-D_USE_MATH_DEFINES) #needed for M_PI with cmath.h
|
||||
add_definitions(-D_WIN32_WINNT=0x0501)
|
||||
add_definitions(-DXML_STATIC)
|
||||
find_library(ws2_32_LIBRARY_PATH ws2_32)
|
||||
@@ -234,7 +243,10 @@ include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS})
|
||||
|
||||
|
||||
find_package(Boost 1.49.0 COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
|
||||
add_definitions(-DBOOST_TEST_DYN_LINK -DBOOST_SPIRIT_USE_PHOENIX_V3 -DBOOST_RESULT_OF_USE_DECLTYPE)
|
||||
if(NOT WIN32)
|
||||
add_definitions(-DBOOST_TEST_DYN_LINK)
|
||||
endif()
|
||||
add_definitions(-DBOOST_SPIRIT_USE_PHOENIX_V3 -DBOOST_RESULT_OF_USE_DECLTYPE)
|
||||
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
@@ -327,12 +339,13 @@ target_link_libraries(osrm_extract ${EXTRACTOR_LIBRARIES})
|
||||
target_link_libraries(osrm_store ${STORAGE_LIBRARIES})
|
||||
# Tests
|
||||
target_link_libraries(engine-tests ${ENGINE_LIBRARIES})
|
||||
target_link_libraries(server-tests osrm ${Boost_LIBRARIES})
|
||||
target_link_libraries(extractor-tests ${EXTRACTOR_LIBRARIES})
|
||||
target_link_libraries(rtree-bench ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${TBB_LIBRARIES})
|
||||
target_link_libraries(util-tests ${UTIL_LIBRARIES})
|
||||
target_link_libraries(library-tests osrm ${Boost_LIBRARIES})
|
||||
|
||||
if(BUILD_TOOLS)
|
||||
message(STATUS "Activating OSRM internal tools")
|
||||
if(BUILD_COMPONENTS)
|
||||
find_package(GDAL)
|
||||
if(GDAL_FOUND)
|
||||
add_executable(osrm-components src/tools/components.cpp $<TARGET_OBJECTS:UTIL>)
|
||||
@@ -343,6 +356,10 @@ if(BUILD_TOOLS)
|
||||
else()
|
||||
message(WARNING "libgdal and/or development headers not found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_TOOLS)
|
||||
message(STATUS "Activating OSRM internal tools")
|
||||
add_executable(osrm-io-benchmark src/tools/io-benchmark.cpp $<TARGET_OBJECTS:UTIL>)
|
||||
target_link_libraries(osrm-io-benchmark ${Boost_LIBRARIES})
|
||||
add_executable(osrm-unlock-all src/tools/unlock_all_mutexes.cpp $<TARGET_OBJECTS:UTIL>)
|
||||
@@ -373,16 +390,19 @@ set_property(TARGET osrm-routed PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
file(GLOB VariantGlob third_party/variant/*.hpp)
|
||||
file(GLOB LibraryGlob include/osrm/*.hpp)
|
||||
set(EngineHeader include/engine/engine.hpp include/engine/engine_config.hpp include/engine/route_parameters.hpp)
|
||||
set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp)
|
||||
set(ExtractorHeader include/extractor/extractor.hpp include/extractor/extractor_config.hpp)
|
||||
file(GLOB ParametersGlob include/engine/api/*_parameters.hpp)
|
||||
set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/phantom_node.hpp)
|
||||
set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp include/util/typedefs.hpp include/util/strong_typedef.hpp)
|
||||
set(ExtractorHeader include/extractor/extractor.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp)
|
||||
set(ContractorHeader include/contractor/contractor.hpp include/contractor/contractor_config.hpp)
|
||||
#set(StorageHeader include/storage/storage.hpp include/storage/storage_config.hpp)
|
||||
set(StorageHeader include/storage/storage.hpp include/storage/storage_config.hpp)
|
||||
install(FILES ${EngineHeader} DESTINATION include/osrm/engine)
|
||||
install(FILES ${UtilHeader} DESTINATION include/osrm/util)
|
||||
install(FILES ${StorageHeader} DESTINATION include/osrm/storage)
|
||||
install(FILES ${ExtractorHeader} DESTINATION include/osrm/extractor)
|
||||
install(FILES ${ContractorHeader} DESTINATION include/osrm/contractor)
|
||||
install(FILES ${LibraryGlob} DESTINATION include/osrm)
|
||||
install(FILES ${ParametersGlob} DESTINATION include/osrm/engine/api)
|
||||
install(FILES ${VariantGlob} DESTINATION include/variant)
|
||||
install(TARGETS osrm-extract DESTINATION bin)
|
||||
install(TARGETS osrm-contract DESTINATION bin)
|
||||
|
||||
@@ -18,6 +18,7 @@ RECURSIVE = YES
|
||||
|
||||
EXCLUDE = @CMAKE_CURRENT_SOURCE_DIR@/third_party \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/build \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/node_modules \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/unit_tests \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/benchmarks \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/features
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
source "http://rubygems.org"
|
||||
|
||||
gem "cucumber"
|
||||
gem "rake"
|
||||
gem "osmlib-base"
|
||||
gem "sys-proctable"
|
||||
gem "rspec-expectations"
|
||||
@@ -1,35 +0,0 @@
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
builder (3.2.2)
|
||||
cucumber (2.0.0)
|
||||
builder (>= 2.1.2)
|
||||
cucumber-core (~> 1.1.3)
|
||||
diff-lcs (>= 1.1.3)
|
||||
gherkin (~> 2.12)
|
||||
multi_json (>= 1.7.5, < 2.0)
|
||||
multi_test (>= 0.1.2)
|
||||
cucumber-core (1.1.3)
|
||||
gherkin (~> 2.12.0)
|
||||
diff-lcs (1.2.5)
|
||||
gherkin (2.12.2)
|
||||
multi_json (~> 1.3)
|
||||
multi_json (1.11.0)
|
||||
multi_test (0.1.2)
|
||||
osmlib-base (0.1.4)
|
||||
rake (10.4.2)
|
||||
rspec-expectations (3.2.1)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.2.0)
|
||||
rspec-support (3.2.2)
|
||||
sys-proctable (0.9.8)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
cucumber
|
||||
osmlib-base
|
||||
rake
|
||||
rspec-expectations
|
||||
sys-proctable
|
||||
@@ -1,190 +0,0 @@
|
||||
require 'OSM/StreamParser'
|
||||
require 'socket'
|
||||
require 'digest/sha1'
|
||||
require 'cucumber/rake/task'
|
||||
require 'sys/proctable'
|
||||
|
||||
BUILD_FOLDER = 'build'
|
||||
DATA_FOLDER = 'sandbox'
|
||||
PROFILE = 'bicycle'
|
||||
OSRM_PORT = 5000
|
||||
PROFILES_FOLDER = '../profiles'
|
||||
|
||||
Cucumber::Rake::Task.new do |t|
|
||||
t.cucumber_opts = %w{--format pretty}
|
||||
end
|
||||
|
||||
areas = {
|
||||
:kbh => { :country => 'denmark', :bbox => 'top=55.6972 left=12.5222 right=12.624 bottom=55.6376' },
|
||||
:frd => { :country => 'denmark', :bbox => 'top=55.7007 left=12.4765 bottom=55.6576 right=12.5698' },
|
||||
:regh => { :country => 'denmark', :bbox => 'top=56.164 left=11.792 bottom=55.403 right=12.731' },
|
||||
:denmark => { :country => 'denmark', :bbox => nil },
|
||||
:skaane => { :country => 'sweden', :bbox => 'top=56.55 left=12.4 bottom=55.3 right=14.6' }
|
||||
}
|
||||
|
||||
|
||||
|
||||
osm_data_area_name = ARGV[1] ? ARGV[1].to_s.to_sym : :kbh
|
||||
raise "Unknown data area." unless areas[osm_data_area_name]
|
||||
osm_data_country = areas[osm_data_area_name][:country]
|
||||
osm_data_area_bbox = areas[osm_data_area_name][:bbox]
|
||||
|
||||
|
||||
task osm_data_area_name.to_sym {} #define empty task to prevent rake from whining. will break if area has same name as a task
|
||||
|
||||
|
||||
def each_process name, &block
|
||||
Sys::ProcTable.ps do |process|
|
||||
if process.comm.strip == name.strip && process.state != 'zombie'
|
||||
yield process.pid.to_i, process.state.strip
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def up?
|
||||
find_pid('osrm-routed') != nil
|
||||
end
|
||||
|
||||
def find_pid name
|
||||
each_process(name) { |pid,state| return pid.to_i }
|
||||
return nil
|
||||
end
|
||||
|
||||
def wait_for_shutdown name
|
||||
timeout = 10
|
||||
(timeout*10).times do
|
||||
return if find_pid(name) == nil
|
||||
sleep 0.1
|
||||
end
|
||||
raise "*** Could not terminate #{name}."
|
||||
end
|
||||
|
||||
|
||||
desc "Rebuild and run tests."
|
||||
task :default => [:build]
|
||||
|
||||
desc "Build using CMake."
|
||||
task :build do
|
||||
if Dir.exists? BUILD_FOLDER
|
||||
Dir.chdir BUILD_FOLDER do
|
||||
system "make"
|
||||
end
|
||||
else
|
||||
system "mkdir build; cd build; cmake ..; make"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Setup config files."
|
||||
task :setup do
|
||||
end
|
||||
|
||||
desc "Download OSM data."
|
||||
task :download do
|
||||
Dir.mkdir "#{DATA_FOLDER}" unless File.exist? "#{DATA_FOLDER}"
|
||||
puts "Downloading..."
|
||||
puts "curl http://download.geofabrik.de/europe/#{osm_data_country}-latest.osm.pbf -o #{DATA_FOLDER}/#{osm_data_country}.osm.pbf"
|
||||
raise "Error while downloading data." unless system "curl http://download.geofabrik.de/europe/#{osm_data_country}-latest.osm.pbf -o #{DATA_FOLDER}/#{osm_data_country}.osm.pbf"
|
||||
if osm_data_area_bbox
|
||||
puts "Cropping and converting to protobuffer..."
|
||||
raise "Error while cropping data." unless system "osmosis --read-pbf file=#{DATA_FOLDER}/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=#{DATA_FOLDER}/#{osm_data_area_name}.osm.pbf omitmetadata=true"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Crop OSM data"
|
||||
task :crop do
|
||||
if osm_data_area_bbox
|
||||
raise "Error while cropping data." unless system "osmosis --read-pbf file=#{DATA_FOLDER}/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=#{DATA_FOLDER}/#{osm_data_area_name}.osm.pbf omitmetadata=true"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Reprocess OSM data."
|
||||
task :process => [:extract,:contract] do
|
||||
end
|
||||
|
||||
desc "Extract OSM data."
|
||||
task :extract do
|
||||
Dir.chdir DATA_FOLDER do
|
||||
raise "Error while extracting data." unless system "../#{BUILD_FOLDER}/osrm-extract #{osm_data_area_name}.osm.pbf --profile ../profiles/#{PROFILE}.lua"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Contract OSM data."
|
||||
task :contract do
|
||||
Dir.chdir DATA_FOLDER do
|
||||
raise "Error while contracting data." unless system "../#{BUILD_FOLDER}/osrm-contract #{osm_data_area_name}.osrm"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Delete preprocessing files."
|
||||
task :clean do
|
||||
File.delete *Dir.glob("#{DATA_FOLDER}/*.osrm")
|
||||
File.delete *Dir.glob("#{DATA_FOLDER}/*.osrm.*")
|
||||
end
|
||||
|
||||
desc "Run all cucumber test"
|
||||
task :test do
|
||||
system "cucumber"
|
||||
puts
|
||||
end
|
||||
|
||||
desc "Run the routing server in the terminal. Press Ctrl-C to stop."
|
||||
task :run do
|
||||
Dir.chdir DATA_FOLDER do
|
||||
system "../#{BUILD_FOLDER}/osrm-routed #{osm_data_area_name}.osrm --port #{OSRM_PORT}"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Launch the routing server in the background. Use rake:down to stop it."
|
||||
task :up do
|
||||
Dir.chdir DATA_FOLDER do
|
||||
abort("Already up.") if up?
|
||||
pipe = IO.popen("../#{BUILD_FOLDER}/osrm-routed #{osm_data_area_name}.osrm --port #{OSRM_PORT} 1>>osrm-routed.log 2>>osrm-routed.log")
|
||||
timeout = 5
|
||||
(timeout*10).times do
|
||||
begin
|
||||
socket = TCPSocket.new('localhost', OSRM_PORT)
|
||||
socket.puts 'ping'
|
||||
rescue Errno::ECONNREFUSED
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Stop the routing server."
|
||||
task :down do
|
||||
pid = find_pid 'osrm-routed'
|
||||
if pid
|
||||
Process.kill 'TERM', pid
|
||||
else
|
||||
puts "Already down."
|
||||
end
|
||||
end
|
||||
|
||||
desc "Kill all osrm-extract, osrm-contract and osrm-routed processes."
|
||||
task :kill do
|
||||
each_process('osrm-routed') { |pid,state| Process.kill 'KILL', pid }
|
||||
each_process('osrm-contract') { |pid,state| Process.kill 'KILL', pid }
|
||||
each_process('osrm-extract') { |pid,state| Process.kill 'KILL', pid }
|
||||
wait_for_shutdown 'osrm-routed'
|
||||
wait_for_shutdown 'osrm-contract'
|
||||
wait_for_shutdown 'osrm-extract'
|
||||
end
|
||||
|
||||
desc "Get PIDs of all osrm-extract, osrm-contract and osrm-routed processes."
|
||||
task :pid do
|
||||
each_process 'osrm-routed' do |pid,state|
|
||||
puts "#{pid}\t#{state}"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Stop, reprocess and restart."
|
||||
task :update => [:down,:process,:up] do
|
||||
end
|
||||
|
||||
|
||||
desc "Remove test cache files."
|
||||
task :sweep do
|
||||
system "rm test/cache/*"
|
||||
end
|
||||
|
||||
+37
-2
@@ -8,16 +8,39 @@ SET PROJECT_DIR=%CD%
|
||||
ECHO PROJECT_DIR^: %PROJECT_DIR%
|
||||
ECHO NUMBER_OF_PROCESSORS^: %NUMBER_OF_PROCESSORS%
|
||||
ECHO cmake^: && cmake --version
|
||||
IF %ERRORLEVEL% NEQ 0 ECHO CMAKE not found GOTO ERROR
|
||||
|
||||
FOR /F %%G IN ("--version") DO cmake %%G 2>&1 | findstr /C:"3.5.0" > nul && goto CMAKE_NOT_OK
|
||||
GOTO CMAKE_OK
|
||||
|
||||
:CMAKE_NOT_OK
|
||||
ECHO CMAKE NOT OK - downloading new CMake
|
||||
IF NOT EXIST cm.zip powershell Invoke-WebRequest https://cmake.org/files/v3.5/cmake-3.5.1-win32-x86.zip -OutFile $env:PROJECT_DIR\cm.zip
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
|
||||
IF NOT EXIST cmake-3.5.1-win32-x86 7z -y x cm.zip | %windir%\system32\FIND "ing archive"
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
|
||||
SET PATH=%PROJECT_DIR%\cmake-3.5.1-win32-x86\bin;%PATH%
|
||||
|
||||
:CMAKE_OK
|
||||
ECHO CMAKE_OK
|
||||
cmake --version
|
||||
|
||||
ECHO activating VS command prompt ...
|
||||
SET PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
|
||||
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
|
||||
|
||||
ECHO platform^: %platform%
|
||||
|
||||
ECHO cl.exe version
|
||||
cl
|
||||
ECHO msbuild version
|
||||
msbuild /version
|
||||
|
||||
:: HARDCODE "x64" as it is uppercase on AppVeyor and download from S3 is case sensitive
|
||||
SET DEPSPKG=osrm-deps-win-x64-14.0.7z
|
||||
|
||||
:: local development
|
||||
ECHO.
|
||||
ECHO LOCAL_DEV^: %LOCAL_DEV%
|
||||
IF NOT DEFINED LOCAL_DEV SET LOCAL_DEV=0
|
||||
IF DEFINED LOCAL_DEV IF %LOCAL_DEV% EQU 1 IF EXIST %DEPSPKG% ECHO skipping deps download && GOTO SKIPDL
|
||||
@@ -33,27 +56,39 @@ IF %ERRORLEVEL% NEQ 0 GOTO ERROR
|
||||
|
||||
IF EXIST osrm-deps ECHO deleting osrm-deps... && RD /S /Q osrm-deps
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
|
||||
IF EXIST build ECHO deletings build dir... && RD /S /Q build
|
||||
IF EXIST build ECHO deleting build dir... && RD /S /Q build
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
|
||||
|
||||
7z -y x %DEPSPKG% | %windir%\system32\FIND "ing archive"
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
|
||||
|
||||
::tree osrm-deps
|
||||
|
||||
MKDIR build
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
|
||||
cd build
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
|
||||
|
||||
SET OSRMDEPSDIR=%PROJECT_DIR%\osrm-deps
|
||||
SET OSRMDEPSDIR=%PROJECT_DIR%/osrm-deps
|
||||
set PREFIX=%OSRMDEPSDIR%/libs
|
||||
set BOOST_ROOT=%OSRMDEPSDIR%/boost
|
||||
set BOOST_LIBRARYDIR=%BOOST_ROOT%/lib
|
||||
set TBB_INSTALL_DIR=%OSRMDEPSDIR%/tbb
|
||||
set TBB_ARCH_PLATFORM=intel64/vc14
|
||||
|
||||
ECHO OSRMDEPSDIR ^: %OSRMDEPSDIR%
|
||||
ECHO PREFIX ^: %PREFIX%
|
||||
ECHO BOOST_ROOT ^: %BOOST_ROOT%
|
||||
ECHO BOOST_LIBRARYDIR ^: %BOOST_LIBRARYDIR%
|
||||
ECHO TBB_INSTALL_DIR ^: %TBB_INSTALL_DIR%
|
||||
ECHO TBB_ARCH_PLATFORM ^: %TBB_ARCH_PLATFORM%
|
||||
|
||||
|
||||
ECHO calling cmake ....
|
||||
cmake .. ^
|
||||
-G "Visual Studio 14 2015 Win64" ^
|
||||
-DBOOST_ROOT=%BOOST_ROOT% ^
|
||||
-DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% ^
|
||||
-DBoost_ADDITIONAL_VERSIONS=1.58 ^
|
||||
-DBoost_USE_MULTITHREADED=ON ^
|
||||
-DBoost_USE_STATIC_LIBS=ON ^
|
||||
|
||||
@@ -41,9 +41,3 @@ deploy:
|
||||
folder: /
|
||||
enable_ssl: true
|
||||
active_mode: false
|
||||
|
||||
# notifications:
|
||||
# - provider: HipChat
|
||||
# auth_token:
|
||||
# secure: boLE7BjcahdIUxv9jkN7U3F8iOASF+MkhtctlVoWJoo=
|
||||
# room: Directions
|
||||
|
||||
+2
-1
@@ -11,7 +11,8 @@ SET CONFIGURATION=Release
|
||||
FOR /F "tokens=*" %%i in ('git rev-parse --abbrev-ref HEAD') do SET APPVEYOR_REPO_BRANCH=%%i
|
||||
ECHO APPVEYOR_REPO_BRANCH^: %APPVEYOR_REPO_BRANCH%
|
||||
|
||||
SET PATH=C:\mb\windows-builds-64\tmp-bin\cmake-3.4.0-win32-x86\bin;%PATH%
|
||||
::SET PATH=C:\mb\windows-builds-64\tmp-bin\cmake-3.5.0-win32-x86\bin;%PATH%
|
||||
SET PATH=C:\mb\windows-builds-64\tmp-bin\cmake-3.5.1-win32-x86\bin;%PATH%
|
||||
SET PATH=C:\Program Files\7-Zip;%PATH%
|
||||
|
||||
powershell Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
includedir=${prefix}/include
|
||||
includedir=${prefix}/include ${prefix}/include/osrm
|
||||
libdir=${prefix}/lib
|
||||
|
||||
Name: libOSRM
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# config/cucumber.yml
|
||||
##YAML Template
|
||||
---
|
||||
default: --require features --tags ~@todo --tags ~@bug --tag ~@stress
|
||||
verify: --require features --tags ~@todo --tags ~@bug --tags ~@stress -f progress
|
||||
jenkins: --require features --tags ~@todo --tags ~@bug --tags ~@stress --tags ~@options -f progress
|
||||
bugs: --require features --tags @bug
|
||||
todo: --require features --tags @todo
|
||||
all: --require features
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
default: '--require features --tags ~@todo --tags ~@bug --tags ~@stress --tags ~@guidance',
|
||||
verify: '--require features --tags ~@todo --tags ~@bug --tags ~@stress -f progress --tags ~@guidance',
|
||||
jenkins: '--require features --tags ~@todo --tags ~@bug --tags ~@stress --tags ~@options -f progress',
|
||||
bugs: '--require features --tags @bug',
|
||||
todo: '--require features --tags @todo',
|
||||
all: '--require features'
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ find_path(LibOSRM_INCLUDE_DIR osrm/osrm.hpp
|
||||
/opt/local
|
||||
/opt)
|
||||
|
||||
set(LibOSRM_INCLUDE_DIRS ${LibOSRM_INCLUDE_DIR})
|
||||
set(LibOSRM_INCLUDE_DIRS ${LibOSRM_INCLUDE_DIR} ${LibOSRM_INCLUDE_DIR}/osrm)
|
||||
|
||||
find_library(TEST_LibOSRM_STATIC_LIBRARY Names osrm.lib libosrm.a
|
||||
PATH_SUFFIXES osrm lib/osrm lib
|
||||
|
||||
+60
-36
@@ -1,61 +1,85 @@
|
||||
#include "osrm/json_container.hpp"
|
||||
#include "osrm/engine_config.hpp"
|
||||
#include "osrm/route_parameters.hpp"
|
||||
#include "osrm/table_parameters.hpp"
|
||||
#include "osrm/nearest_parameters.hpp"
|
||||
#include "osrm/trip_parameters.hpp"
|
||||
#include "osrm/match_parameters.hpp"
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "osrm/engine_config.hpp"
|
||||
#include "osrm/json_container.hpp"
|
||||
|
||||
#include "osrm/status.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
int main(int argc, const char *argv[]) try
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
std::cerr << "Error: Not enough arguments." << std::endl
|
||||
<< "Run " << argv[0] << " data.osrm" << std::endl;
|
||||
std::cerr << "Usage: " << argv[0] << " data.osrm\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
osrm::EngineConfig engine_config;
|
||||
std::string base_path(argv[1]);
|
||||
engine_config.server_paths["ramindex"] = base_path + ".ramIndex";
|
||||
engine_config.server_paths["fileindex"] = base_path + ".fileIndex";
|
||||
engine_config.server_paths["hsgrdata"] = base_path + ".hsgr";
|
||||
engine_config.server_paths["nodesdata"] = base_path + ".nodes";
|
||||
engine_config.server_paths["edgesdata"] = base_path + ".edges";
|
||||
engine_config.server_paths["coredata"] = base_path + ".core";
|
||||
engine_config.server_paths["geometries"] = base_path + ".geometry";
|
||||
engine_config.server_paths["timestamp"] = base_path + ".timestamp";
|
||||
engine_config.server_paths["namesdata"] = base_path + ".names";
|
||||
engine_config.use_shared_memory = false;
|
||||
using namespace osrm;
|
||||
|
||||
osrm::OSRM routing_machine(engine_config);
|
||||
// Configure based on a .osrm base path, and no datasets in shared mem from osrm-datastore
|
||||
EngineConfig config;
|
||||
config.storage_config = {argv[1]};
|
||||
config.use_shared_memory = false;
|
||||
|
||||
osrm::RouteParameters route_parameters;
|
||||
// route is in Monaco
|
||||
route_parameters.service = "viaroute";
|
||||
route_parameters.AddCoordinate(43.731142, 7.419758);
|
||||
route_parameters.AddCoordinate(43.736825, 7.419505);
|
||||
// Routing machine with several services (such as Route, Table, Nearest, Trip, Match)
|
||||
OSRM osrm{config};
|
||||
|
||||
osrm::json::Object json_result;
|
||||
const int result_code = routing_machine.RunQuery(route_parameters, json_result);
|
||||
std::cout << "result code: " << result_code << std::endl;
|
||||
// 2xx code
|
||||
if (result_code / 100 == 2)
|
||||
// The following shows how to use the Route service; configure this service
|
||||
RouteParameters params;
|
||||
|
||||
// Route in monaco
|
||||
params.coordinates.push_back({util::FloatLongitude(7.419758), util::FloatLatitude(43.731142)});
|
||||
params.coordinates.push_back({util::FloatLongitude(7.419505), util::FloatLatitude(43.736825)});
|
||||
|
||||
// Response is in JSON format
|
||||
json::Object result;
|
||||
|
||||
// Execute routing request, this does the heavy lifting
|
||||
const auto status = osrm.Route(params, result);
|
||||
|
||||
if (status == Status::Ok)
|
||||
{
|
||||
// Extract data out of JSON structure
|
||||
auto& summary = json_result.values["route_summary"].get<osrm::json::Object>();
|
||||
auto duration = summary.values["total_time"].get<osrm::json::Number>().value;
|
||||
auto distance = summary.values["total_distance"].get<osrm::json::Number>().value;
|
||||
std::cout << "duration: " << duration << std::endl;
|
||||
std::cout << "distance: " << distance << std::endl;
|
||||
auto &routes = result.values["routes"].get<json::Array>();
|
||||
|
||||
// Let's just use the first route
|
||||
auto &route = routes.values.at(0).get<json::Object>();
|
||||
const auto distance = route.values["distance"].get<json::Number>().value;
|
||||
const auto duration = route.values["duration"].get<json::Number>().value;
|
||||
|
||||
// Warn users if extract does not contain the default Berlin coordinates from above
|
||||
if (distance == 0 or duration == 0)
|
||||
{
|
||||
std::cout << "Note: distance or duration is zero. ";
|
||||
std::cout << "You are probably doing a query outside of the OSM extract.\n\n";
|
||||
}
|
||||
|
||||
std::cout << "Distance: " << distance << " meter\n";
|
||||
std::cout << "Duration: " << duration << " seconds\n";
|
||||
}
|
||||
else if (status == Status::Error)
|
||||
{
|
||||
const auto code = result.values["code"].get<json::String>().value;
|
||||
const auto message = result.values["message"].get<json::String>().value;
|
||||
|
||||
std::cout << "Code: " << code << "\n";
|
||||
std::cout << "Message: " << code << "\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
catch (const std::exception ¤t_exception)
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
std::cout << "exception: " << current_exception.what();
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ Feature: Bike - Squares and other areas
|
||||
Background:
|
||||
Given the profile "bicycle"
|
||||
|
||||
@square
|
||||
@square @mokob @2154
|
||||
Scenario: Bike - Route along edge of a squares
|
||||
Given the node map
|
||||
| x | |
|
||||
@@ -17,15 +17,15 @@ Feature: Bike - Squares and other areas
|
||||
| abcda | yes | residential |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | abcda |
|
||||
| a | d | abcda |
|
||||
| b | c | abcda |
|
||||
| c | b | abcda |
|
||||
| c | d | abcda |
|
||||
| d | c | abcda |
|
||||
| d | a | abcda |
|
||||
| a | d | abcda |
|
||||
| from | to | route |
|
||||
| a | b | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
| b | c | abcda,abcda |
|
||||
| c | b | abcda,abcda |
|
||||
| c | d | abcda,abcda |
|
||||
| d | c | abcda,abcda |
|
||||
| d | a | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
|
||||
@building
|
||||
Scenario: Bike - Don't route on buildings
|
||||
@@ -41,16 +41,16 @@ Feature: Bike - Squares and other areas
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | xa |
|
||||
| a | d | xa |
|
||||
| b | c | xa |
|
||||
| c | b | xa |
|
||||
| c | d | xa |
|
||||
| d | c | xa |
|
||||
| d | a | xa |
|
||||
| a | d | xa |
|
||||
| a | b | xa,xa |
|
||||
| a | d | xa,xa |
|
||||
| b | c | xa,xa |
|
||||
| c | b | xa,xa |
|
||||
| c | d | xa,xa |
|
||||
| d | c | xa,xa |
|
||||
| d | a | xa,xa |
|
||||
| a | d | xa,xa |
|
||||
|
||||
@parking
|
||||
@parking @mokob @2154
|
||||
Scenario: Bike - parking areas
|
||||
Given the node map
|
||||
| e | | | f |
|
||||
@@ -65,19 +65,20 @@ Feature: Bike - Squares and other areas
|
||||
| abcda | (nil) | parking |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| x | y | xa,abcda,by |
|
||||
| y | x | by,abcda,xa |
|
||||
| a | b | abcda |
|
||||
| a | d | abcda |
|
||||
| b | c | abcda |
|
||||
| c | b | abcda |
|
||||
| c | d | abcda |
|
||||
| d | c | abcda |
|
||||
| d | a | abcda |
|
||||
| a | d | abcda |
|
||||
| from | to | route |
|
||||
| x | y | xa,abcda,by,by |
|
||||
| y | x | by,abcda,xa,xa |
|
||||
| a | b | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
| b | c | abcda,abcda |
|
||||
| c | b | abcda,abcda |
|
||||
| c | d | abcda,abcda |
|
||||
| d | c | abcda,abcda |
|
||||
| d | a | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
|
||||
@train @platform
|
||||
|
||||
@train @platform @mokob @2154
|
||||
Scenario: Bike - railway platforms
|
||||
Given the node map
|
||||
| x | a | b | y |
|
||||
@@ -90,14 +91,14 @@ Feature: Bike - Squares and other areas
|
||||
| abcda | (nil) | platform |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| x | y | xa,abcda,by |
|
||||
| y | x | by,abcda,xa |
|
||||
| a | b | abcda |
|
||||
| a | d | abcda |
|
||||
| b | c | abcda |
|
||||
| c | b | abcda |
|
||||
| c | d | abcda |
|
||||
| d | c | abcda |
|
||||
| d | a | abcda |
|
||||
| a | d | abcda |
|
||||
| from | to | route |
|
||||
| x | y | xa,abcda,by,by |
|
||||
| y | x | by,abcda,xa,xa |
|
||||
| a | b | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
| b | c | abcda,abcda |
|
||||
| c | b | abcda,abcda |
|
||||
| c | d | abcda,abcda |
|
||||
| d | c | abcda,abcda |
|
||||
| d | a | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
|
||||
@@ -4,7 +4,7 @@ Feature: Bicycle - Handle movable bridge
|
||||
Background:
|
||||
Given the profile "bicycle"
|
||||
|
||||
Scenario: Car - Use a ferry route
|
||||
Scenario: Bicycle - Use a ferry route
|
||||
Given the node map
|
||||
| a | b | c | | |
|
||||
| | | d | | |
|
||||
@@ -17,17 +17,17 @@ Feature: Bicycle - Handle movable bridge
|
||||
| efg | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes |
|
||||
| a | g | abc,cde,efg | 1,5,1 |
|
||||
| b | f | abc,cde,efg | 1,5,1 |
|
||||
| e | c | cde | 5 |
|
||||
| e | b | cde,abc | 5,1 |
|
||||
| e | a | cde,abc | 5,1 |
|
||||
| c | e | cde | 5 |
|
||||
| c | f | cde,efg | 5,1 |
|
||||
| c | g | cde,efg | 5,1 |
|
||||
| from | to | route | modes |
|
||||
| a | g | abc,cde,efg,efg | cycling,movable bridge,cycling,cycling |
|
||||
| b | f | abc,cde,efg,efg | cycling,movable bridge,cycling,cycling |
|
||||
| e | c | cde,cde | movable bridge,movable bridge |
|
||||
| e | b | cde,abc,abc | movable bridge,cycling,cycling |
|
||||
| e | a | cde,abc,abc | movable bridge,cycling,cycling |
|
||||
| c | e | cde,cde | movable bridge,movable bridge |
|
||||
| c | f | cde,efg,efg | movable bridge,cycling,cycling |
|
||||
| c | g | cde,efg,efg | movable bridge,cycling,cycling |
|
||||
|
||||
Scenario: Car - Properly handle durations
|
||||
Scenario: Bicycle - Properly handle durations
|
||||
Given the node map
|
||||
| a | b | c | | |
|
||||
| | | d | | |
|
||||
@@ -40,8 +40,8 @@ Feature: Bicycle - Handle movable bridge
|
||||
| efg | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes | speed |
|
||||
| a | g | abc,cde,efg | 1,5,1 | 5 km/h |
|
||||
| b | f | abc,cde,efg | 1,5,1 | 4 km/h |
|
||||
| c | e | cde | 5 | 2 km/h |
|
||||
| e | c | cde | 5 | 2 km/h |
|
||||
| from | to | route | modes | speed |
|
||||
| a | g | abc,cde,efg,efg | cycling,movable bridge,cycling,cycling | 5 km/h |
|
||||
| b | f | abc,cde,efg,efg | cycling,movable bridge,cycling,cycling | 4 km/h |
|
||||
| c | e | cde,cde | movable bridge,movable bridge | 2 km/h |
|
||||
| e | c | cde,cde | movable bridge,movable bridge | 2 km/h |
|
||||
|
||||
@@ -17,15 +17,15 @@ Feature: Bike - Handle ferry routes
|
||||
| efg | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | g | abc,cde,efg |
|
||||
| b | f | abc,cde,efg |
|
||||
| e | c | cde |
|
||||
| e | b | cde,abc |
|
||||
| e | a | cde,abc |
|
||||
| c | e | cde |
|
||||
| c | f | cde,efg |
|
||||
| c | g | cde,efg |
|
||||
| from | to | route |
|
||||
| a | g | abc,cde,efg,efg |
|
||||
| b | f | abc,cde,efg,efg |
|
||||
| e | c | cde,cde |
|
||||
| e | b | cde,abc,abc |
|
||||
| e | a | cde,abc,abc |
|
||||
| c | e | cde,cde |
|
||||
| c | f | cde,efg,efg |
|
||||
| c | g | cde,efg,efg |
|
||||
|
||||
Scenario: Bike - Ferry duration, single node
|
||||
Given the node map
|
||||
@@ -59,5 +59,5 @@ Feature: Bike - Handle ferry routes
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | time |
|
||||
| a | d | abcd | 3600s +-10 |
|
||||
| d | a | abcd | 3600s +-10 |
|
||||
| a | d | abcd,abcd | 3600s +-10 |
|
||||
| d | a | abcd,abcd | 3600s +-10 |
|
||||
|
||||
@@ -48,9 +48,9 @@ Feature: Bike - Max speed restrictions
|
||||
| bc | residential | 80 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | speed |
|
||||
| a | b | ab | 15 km/h |
|
||||
| b | c | bc | 15 km/h |
|
||||
| from | to | route | speed |
|
||||
| a | b | ab,ab | 15 km/h |
|
||||
| b | c | bc,bc | 15 km/h |
|
||||
|
||||
Scenario: Bike - Forward/backward maxspeed
|
||||
Given the shortcuts
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
@routing @bicycle @mode
|
||||
Feature: Bike - Mode flag
|
||||
|
||||
# bicycle modes:
|
||||
# 1 bike
|
||||
# 2 pushing
|
||||
# 3 ferry
|
||||
# 4 train
|
||||
|
||||
Background:
|
||||
Given the profile "bicycle"
|
||||
|
||||
|
||||
Scenario: Bike - Mode when using a ferry
|
||||
Given the node map
|
||||
| a | b | |
|
||||
@@ -22,13 +16,13 @@ Feature: Bike - Mode flag
|
||||
| cd | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd | head,right,left,destination | 1,3,1 |
|
||||
| d | a | cd,bc,ab | head,right,left,destination | 1,3,1 |
|
||||
| c | a | bc,ab | head,left,destination | 3,1 |
|
||||
| d | b | cd,bc | head,right,destination | 1,3 |
|
||||
| a | c | ab,bc | head,right,destination | 1,3 |
|
||||
| b | d | bc,cd | head,left,destination | 3,1 |
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd,cd | depart,right,left,arrive | cycling,ferry,cycling,cycling |
|
||||
| d | a | cd,bc,ab,ab | depart,right,left,arrive | cycling,ferry,cycling,cycling |
|
||||
| c | a | bc,ab,ab | depart,left,arrive | ferry,cycling,cycling |
|
||||
| d | b | cd,bc,bc | depart,right,arrive | cycling,ferry,ferry |
|
||||
| a | c | ab,bc,bc | depart,right,arrive | cycling,ferry,ferry |
|
||||
| b | d | bc,cd,cd | depart,left,arrive | ferry,cycling,cycling |
|
||||
|
||||
Scenario: Bike - Mode when using a train
|
||||
Given the node map
|
||||
@@ -42,13 +36,13 @@ Feature: Bike - Mode flag
|
||||
| cd | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd | head,right,left,destination | 1,4,1 |
|
||||
| d | a | cd,bc,ab | head,right,left,destination | 1,4,1 |
|
||||
| c | a | bc,ab | head,left,destination | 4,1 |
|
||||
| d | b | cd,bc | head,right,destination | 1,4 |
|
||||
| a | c | ab,bc | head,right,destination | 1,4 |
|
||||
| b | d | bc,cd | head,left,destination | 4,1 |
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd,cd | depart,right,left,arrive | cycling,train,cycling,cycling |
|
||||
| d | a | cd,bc,ab,ab | depart,right,left,arrive | cycling,train,cycling,cycling |
|
||||
| c | a | bc,ab,ab | depart,left,arrive | train,cycling,cycling |
|
||||
| d | b | cd,bc,bc | depart,right,arrive | cycling,train,train |
|
||||
| a | c | ab,bc,bc | depart,right,arrive | cycling,train,train |
|
||||
| b | d | bc,cd,cd | depart,left,arrive | train,cycling,cycling |
|
||||
|
||||
Scenario: Bike - Mode when pushing bike against oneways
|
||||
Given the node map
|
||||
@@ -62,13 +56,13 @@ Feature: Bike - Mode flag
|
||||
| cd | primary | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd | head,straight,straight,destination | 1,1,1 |
|
||||
| d | a | cd,bc,ab | head,right,left,destination | 1,2,1 |
|
||||
| c | a | bc,ab | head,left,destination | 2,1 |
|
||||
| d | b | cd,bc | head,right,destination | 1,2 |
|
||||
| a | c | ab,bc | head,straight,destination | 1,1 |
|
||||
| b | d | bc,cd | head,straight,destination | 1,1 |
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd,cd | depart,right,left,arrive | cycling,cycling,cycling,cycling |
|
||||
| d | a | cd,bc,ab,ab | depart,right,left,arrive | cycling,pushing bike,cycling,cycling |
|
||||
| c | a | bc,ab,ab | depart,left,arrive | pushing bike,cycling,cycling |
|
||||
| d | b | cd,bc,bc | depart,right,arrive | cycling,pushing bike,pushing bike |
|
||||
| a | c | ab,bc,bc | depart,right,arrive | cycling,cycling,cycling |
|
||||
| b | d | bc,cd,cd | depart,left,arrive | cycling,cycling,cycling |
|
||||
|
||||
Scenario: Bike - Mode when pushing on pedestrain streets
|
||||
Given the node map
|
||||
@@ -82,13 +76,13 @@ Feature: Bike - Mode flag
|
||||
| cd | primary |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd | head,right,left,destination | 1,2,1 |
|
||||
| d | a | cd,bc,ab | head,right,left,destination | 1,2,1 |
|
||||
| c | a | bc,ab | head,left,destination | 2,1 |
|
||||
| d | b | cd,bc | head,right,destination | 1,2 |
|
||||
| a | c | ab,bc | head,right,destination | 1,2 |
|
||||
| b | d | bc,cd | head,left,destination | 2,1 |
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd,cd | depart,right,left,arrive | cycling,pushing bike,cycling,cycling |
|
||||
| d | a | cd,bc,ab,ab | depart,right,left,arrive | cycling,pushing bike,cycling,cycling |
|
||||
| c | a | bc,ab,ab | depart,left,arrive | pushing bike,cycling,cycling |
|
||||
| d | b | cd,bc,bc | depart,right,arrive | cycling,pushing bike,pushing bike |
|
||||
| a | c | ab,bc,bc | depart,right,arrive | cycling,pushing bike,pushing bike |
|
||||
| b | d | bc,cd,cd | depart,left,arrive | pushing bike,cycling,cycling |
|
||||
|
||||
Scenario: Bike - Mode when pushing on pedestrain areas
|
||||
Given the node map
|
||||
@@ -102,13 +96,13 @@ Feature: Bike - Mode flag
|
||||
| df | primary | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes |
|
||||
| a | f | ab,bcd,df | 1,2,1 |
|
||||
| f | a | df,bcd,ab | 1,2,1 |
|
||||
| d | a | bcd,ab | 2,1 |
|
||||
| f | b | df,bcd | 1,2 |
|
||||
| a | d | ab,bcd | 1,2 |
|
||||
| b | f | bcd,df | 2,1 |
|
||||
| from | to | route | modes |
|
||||
| a | f | ab,bcd,df,df | cycling,pushing bike,cycling,cycling |
|
||||
| f | a | df,bcd,ab,ab | cycling,pushing bike,cycling,cycling |
|
||||
| d | a | bcd,ab,ab | pushing bike,cycling,cycling |
|
||||
| f | b | df,bcd,bcd | cycling,pushing bike,pushing bike |
|
||||
| a | d | ab,bcd,bcd | cycling,pushing bike,pushing bike |
|
||||
| b | f | bcd,df,df | pushing bike,cycling,cycling |
|
||||
|
||||
Scenario: Bike - Mode when pushing on steps
|
||||
Given the node map
|
||||
@@ -122,13 +116,13 @@ Feature: Bike - Mode flag
|
||||
| cd | primary |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd | head,right,left,destination | 1,2,1 |
|
||||
| d | a | cd,bc,ab | head,right,left,destination | 1,2,1 |
|
||||
| c | a | bc,ab | head,left,destination | 2,1 |
|
||||
| d | b | cd,bc | head,right,destination | 1,2 |
|
||||
| a | c | ab,bc | head,right,destination | 1,2 |
|
||||
| b | d | bc,cd | head,left,destination | 2,1 |
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd,cd | depart,right,left,arrive | cycling,pushing bike,cycling,cycling |
|
||||
| d | a | cd,bc,ab,ab | depart,right,left,arrive | cycling,pushing bike,cycling,cycling |
|
||||
| c | a | bc,ab,ab | depart,left,arrive | pushing bike,cycling,cycling |
|
||||
| d | b | cd,bc,bc | depart,right,arrive | cycling,pushing bike,pushing bike |
|
||||
| a | c | ab,bc,bc | depart,right,arrive | cycling,pushing bike,pushing bike |
|
||||
| b | d | bc,cd,cd | depart,left,arrive | pushing bike,cycling,cycling |
|
||||
|
||||
Scenario: Bike - Mode when bicycle=dismount
|
||||
Given the node map
|
||||
@@ -142,13 +136,13 @@ Feature: Bike - Mode flag
|
||||
| cd | primary | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd | head,right,left,destination | 1,2,1 |
|
||||
| d | a | cd,bc,ab | head,right,left,destination | 1,2,1 |
|
||||
| c | a | bc,ab | head,left,destination | 2,1 |
|
||||
| d | b | cd,bc | head,right,destination | 1,2 |
|
||||
| a | c | ab,bc | head,right,destination | 1,2 |
|
||||
| b | d | bc,cd | head,left,destination | 2,1 |
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd,cd | depart,right,left,arrive | cycling,pushing bike,cycling,cycling |
|
||||
| d | a | cd,bc,ab,ab | depart,right,left,arrive | cycling,pushing bike,cycling,cycling |
|
||||
| c | a | bc,ab,ab | depart,left,arrive | pushing bike,cycling,cycling |
|
||||
| d | b | cd,bc,bc | depart,right,arrive | cycling,pushing bike,pushing bike |
|
||||
| a | c | ab,bc,bc | depart,right,arrive | cycling,pushing bike,pushing bike |
|
||||
| b | d | bc,cd,cd | depart,left,arrive | pushing bike,cycling,cycling |
|
||||
|
||||
Scenario: Bicycle - Modes when starting on forward oneway
|
||||
Given the node map
|
||||
@@ -159,9 +153,9 @@ Feature: Bike - Mode flag
|
||||
| ab | yes |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes |
|
||||
| a | b | ab | 1 |
|
||||
| b | a | ab | 2 |
|
||||
| from | to | route | modes |
|
||||
| a | b | ab,ab | cycling,cycling |
|
||||
| b | a | ab,ab | pushing bike,pushing bike |
|
||||
|
||||
Scenario: Bicycle - Modes when starting on reverse oneway
|
||||
Given the node map
|
||||
@@ -172,6 +166,6 @@ Feature: Bike - Mode flag
|
||||
| ab | -1 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes |
|
||||
| a | b | ab | 2 |
|
||||
| b | a | ab | 1 |
|
||||
| from | to | route | modes |
|
||||
| a | b | ab,ab | pushing bike,pushing bike |
|
||||
| b | a | ab,ab | cycling,cycling |
|
||||
|
||||
@@ -15,8 +15,8 @@ Feature: Bike - Street names in instructions
|
||||
| bc | Your Way |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | c | My Way,Your Way |
|
||||
| from | to | route |
|
||||
| a | c | My Way,Your Way,Your Way |
|
||||
|
||||
@unnamed
|
||||
Scenario: Bike - Use way type to describe unnamed ways
|
||||
@@ -29,5 +29,5 @@ Feature: Bike - Street names in instructions
|
||||
| bcd | track | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | d | {highway:cycleway},{highway:track} |
|
||||
| from | to | route |
|
||||
| a | d | {highway:cycleway},{highway:track},{highway:track} |
|
||||
|
||||
@@ -29,9 +29,9 @@ Feature: Bike - Oneway streets
|
||||
| da | | no |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | ab |
|
||||
| b | a | bc,cd,da |
|
||||
| from | to | route |
|
||||
| a | b | ab,ab |
|
||||
| b | a | bc,cd,da,da |
|
||||
|
||||
Scenario: Bike - Handle various oneway tag values
|
||||
Then routability should be
|
||||
@@ -124,5 +124,5 @@ Feature: Bike - Oneway streets
|
||||
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | c | ab,bc |
|
||||
| from | to | route |
|
||||
| a | c | ab,bc,bc |
|
||||
|
||||
@@ -32,7 +32,7 @@ Feature: Bike - Accessability of different way types
|
||||
| primary | -1 | foot | bike |
|
||||
| pedestrian | -1 | foot | foot |
|
||||
|
||||
@square
|
||||
@square
|
||||
Scenario: Bike - Push bikes on pedestrian areas
|
||||
Given the node map
|
||||
| x | |
|
||||
@@ -46,14 +46,14 @@ Feature: Bike - Accessability of different way types
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | abcda |
|
||||
| a | d | abcda |
|
||||
| b | c | abcda |
|
||||
| c | b | abcda |
|
||||
| c | d | abcda |
|
||||
| d | c | abcda |
|
||||
| d | a | abcda |
|
||||
| a | d | abcda |
|
||||
| a | b | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
| b | c | abcda,abcda |
|
||||
| c | b | abcda,abcda |
|
||||
| c | d | abcda,abcda |
|
||||
| d | c | abcda,abcda |
|
||||
| d | a | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
|
||||
Scenario: Bike - Pushing bikes on ways with foot=yes
|
||||
Then routability should be
|
||||
@@ -62,7 +62,7 @@ Feature: Bike - Accessability of different way types
|
||||
| motorway | yes | foot | |
|
||||
| runway | | | |
|
||||
| runway | yes | foot | foot |
|
||||
|
||||
|
||||
@todo
|
||||
Scenario: Bike - Pushing bikes on ways with foot=yes in one direction
|
||||
Then routability should be
|
||||
@@ -72,20 +72,20 @@ Feature: Bike - Accessability of different way types
|
||||
| motorway | | yes | | foot |
|
||||
|
||||
@construction
|
||||
Scenario: Bike - Don't allow routing on ways still under construction
|
||||
Scenario: Bike - Don't allow routing on ways still under construction
|
||||
Then routability should be
|
||||
| highway | foot | bicycle | bothw |
|
||||
| primary | | | x |
|
||||
| construction | | | |
|
||||
| construction | yes | | |
|
||||
| construction | | yes | |
|
||||
|
||||
|
||||
@roundabout
|
||||
Scenario: Bike - Don't push bikes against oneway flow on roundabouts
|
||||
Then routability should be
|
||||
| junction | forw | backw |
|
||||
| roundabout | x | |
|
||||
|
||||
|
||||
Scenario: Bike - Instructions when pushing bike on oneways
|
||||
Given the node map
|
||||
| a | b | |
|
||||
@@ -98,11 +98,11 @@ Feature: Bike - Accessability of different way types
|
||||
| cd | primary | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns |
|
||||
| a | d | ab,bc,cd | head,straight,straight,destination |
|
||||
| d | a | cd,bc,ab | head,right,left,destination |
|
||||
| c | a | bc,ab | head,left,destination |
|
||||
| d | b | cd,bc | head,right,destination |
|
||||
| from | to | route | turns |
|
||||
| a | d | ab,bc,cd,cd | depart,right,left,arrive |
|
||||
| d | a | cd,bc,ab,ab | depart,right,left,arrive |
|
||||
| c | a | bc,ab,ab | depart,left,arrive |
|
||||
| d | b | cd,bc,bc | depart,right,arrive |
|
||||
|
||||
@todo
|
||||
Scenario: Bike - Instructions when pushing bike on footway/pedestrian, etc.
|
||||
@@ -117,8 +117,8 @@ Feature: Bike - Accessability of different way types
|
||||
| cd | primary |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns |
|
||||
| a | d | ab,bc,cd | head,right,left,destination |
|
||||
| d | a | cd,bc,ab | head,right,left,destination |
|
||||
| c | a | bc,ab | head,left,destination |
|
||||
| d | b | cd,bc | head,right,destination |
|
||||
| from | to | route | turns |
|
||||
| a | d | ab,bc,cd,cd | depart,right,left,arrive |
|
||||
| d | a | cd,bc,ab,ab | depart,right,left,arrive |
|
||||
| c | a | bc,ab,ab | depart,left,arrive |
|
||||
| d | b | cd,bc,bc | depart,right,arrive |
|
||||
|
||||
@@ -13,8 +13,8 @@ Feature: Bike - Way ref
|
||||
| ab | Utopia Drive | E7 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | Utopia Drive / E7 |
|
||||
| from | to | route |
|
||||
| a | b | Utopia Drive / E7,Utopia Drive / E7 |
|
||||
|
||||
Scenario: Bike - Way with only ref
|
||||
Given the node map
|
||||
@@ -26,7 +26,7 @@ Feature: Bike - Way ref
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | E7 |
|
||||
| a | b | E7,E7 |
|
||||
|
||||
Scenario: Bike - Way with only name
|
||||
Given the node map
|
||||
@@ -37,5 +37,5 @@ Feature: Bike - Way ref
|
||||
| ab | Utopia Drive |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | Utopia Drive |
|
||||
| from | to | route |
|
||||
| a | b | Utopia Drive,Utopia Drive |
|
||||
|
||||
@@ -25,10 +25,10 @@ Feature: Bike - Turn restrictions
|
||||
| restriction | sj | wj | j | no_left_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@no_turning
|
||||
Scenario: Bike - No right turn
|
||||
@@ -49,10 +49,10 @@ Feature: Bike - Turn restrictions
|
||||
| restriction | sj | ej | j | no_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@no_turning
|
||||
Scenario: Bike - No u-turn
|
||||
@@ -73,10 +73,10 @@ Feature: Bike - Turn restrictions
|
||||
| restriction | sj | wj | j | no_u_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@no_turning
|
||||
Scenario: Bike - Handle any no_* relation
|
||||
@@ -97,10 +97,10 @@ Feature: Bike - Turn restrictions
|
||||
| restriction | sj | wj | j | no_weird_zigzags |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@only_turning
|
||||
Scenario: Bike - Only left turn
|
||||
@@ -121,10 +121,10 @@ Feature: Bike - Turn restrictions
|
||||
| restriction | sj | wj | j | only_left_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@only_turning
|
||||
Scenario: Bike - Only right turn
|
||||
@@ -145,10 +145,10 @@ Feature: Bike - Turn restrictions
|
||||
| restriction | sj | ej | j | only_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@only_turning
|
||||
Scenario: Bike - Only straight on
|
||||
@@ -169,10 +169,10 @@ Feature: Bike - Turn restrictions
|
||||
| restriction | sj | nj | j | only_straight_on |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@no_turning
|
||||
Scenario: Bike - Handle any only_* restriction
|
||||
@@ -193,10 +193,10 @@ Feature: Bike - Turn restrictions
|
||||
| restriction | sj | nj | j | only_weird_zigzags |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@except
|
||||
Scenario: Bike - Except tag and on no_ restrictions
|
||||
@@ -222,11 +222,11 @@ Feature: Bike - Turn restrictions
|
||||
| restriction | sj | dj | j | no_right_turn | bicycle |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | a | sj,aj |
|
||||
| s | b | sj,bj |
|
||||
| s | c | sj,cj |
|
||||
| s | d | sj,dj |
|
||||
| from | to | route |
|
||||
| s | a | sj,aj,aj |
|
||||
| s | b | sj,bj,bj |
|
||||
| s | c | sj,cj,cj |
|
||||
| s | d | sj,dj,dj |
|
||||
|
||||
@except
|
||||
Scenario: Bike - Except tag and on only_ restrictions
|
||||
@@ -246,9 +246,9 @@ Feature: Bike - Turn restrictions
|
||||
| restriction | sj | aj | j | only_straight_on | bicycle |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | a | sj,aj |
|
||||
| s | b | sj,bj |
|
||||
| from | to | route |
|
||||
| s | a | sj,aj,aj |
|
||||
| s | b | sj,bj,bj |
|
||||
|
||||
@except
|
||||
Scenario: Bike - Multiple except tag values
|
||||
@@ -280,10 +280,10 @@ Feature: Bike - Turn restrictions
|
||||
| restriction | sj | jf | j | no_straight_on | bicycle, bus |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | a | sj,ja |
|
||||
| s | b | sj,jb |
|
||||
| s | c | sj,jc |
|
||||
| s | d | sj,jd |
|
||||
| s | e | sj,je |
|
||||
| s | f | sj,jf |
|
||||
| from | to | route |
|
||||
| s | a | sj,ja,ja |
|
||||
| s | b | sj,jb,jb |
|
||||
| s | c | sj,jc,jc |
|
||||
| s | d | sj,jd,jd |
|
||||
| s | e | sj,je,je |
|
||||
| s | f | sj,jf,jf |
|
||||
|
||||
@@ -21,10 +21,10 @@ Feature: Roundabout Instructions
|
||||
| abcda | roundabout |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns |
|
||||
| s | t | sa,tb | head,enter_roundabout-1,destination |
|
||||
| s | u | sa,uc | head,enter_roundabout-2,destination |
|
||||
| s | v | sa,vd | head,enter_roundabout-3,destination |
|
||||
| u | v | uc,vd | head,enter_roundabout-1,destination |
|
||||
| u | s | uc,sa | head,enter_roundabout-2,destination |
|
||||
| u | t | uc,tb | head,enter_roundabout-3,destination |
|
||||
| from | to | route | turns |
|
||||
| s | t | sa,tb,tb | depart,roundabout-exit-1,arrive |
|
||||
| s | u | sa,uc,uc | depart,roundabout-exit-2,arrive |
|
||||
| s | v | sa,vd,vd | depart,roundabout-exit-3,arrive |
|
||||
| u | v | uc,vd,vd | depart,roundabout-exit-1,arrive |
|
||||
| u | s | uc,sa,sa | depart,roundabout-exit-2,arrive |
|
||||
| u | t | uc,tb,tb | depart,roundabout-exit-3,arrive |
|
||||
|
||||
@@ -31,7 +31,7 @@ Feature: Bike - Stop areas for public transport
|
||||
| public_transport | stop_area | c | st |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | d | abcd |
|
||||
| s | t | st |
|
||||
| s | d | /st,.+,abcd/ |
|
||||
| from | to | route |
|
||||
| a | d | abcd,abcd |
|
||||
| s | t | st,st |
|
||||
| s | d | /st,.+,abcd/,abcd/ |
|
||||
|
||||
@@ -23,11 +23,11 @@ Feature: Turn Penalties
|
||||
| jg |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | time | distance |
|
||||
| s | a | sj,ja | 39s +-1 | 242m +-1 |
|
||||
| s | b | sj,jb | 30s +-1 | 200m +-1 |
|
||||
| s | c | sj,jc | 29s +-1 | 242m +-1 |
|
||||
| s | d | sj,jd | 20s +-1 | 200m +-1 |
|
||||
| s | e | sj,je | 29s +-1 | 242m +-1 |
|
||||
| s | f | sj,jf | 30s +-1 | 200m +-1 |
|
||||
| s | g | sj,jg | 39s +-1 | 242m +-1 |
|
||||
| from | to | route | time | distance |
|
||||
| s | a | sj,ja,ja | 39s +-1 | 242m +-1 |
|
||||
| s | b | sj,jb,jb | 30s +-1 | 200m +-1 |
|
||||
| s | c | sj,jc,jc | 29s +-1 | 242m +-1 |
|
||||
| s | d | sj,jd,jd | 20s +-1 | 200m +-1 |
|
||||
| s | e | sj,je,je | 29s +-1 | 242m +-1 |
|
||||
| s | f | sj,jf,jf | 30s +-1 | 200m +-1 |
|
||||
| s | g | sj,jg,jg | 39s +-1 | 242m +-1 |
|
||||
|
||||
@@ -17,8 +17,8 @@ OSRM will use 4/5 of the projected free-flow speed.
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | speed |
|
||||
| a | b | ab | 47 km/h +- 1 |
|
||||
| b | c | bc | 47 km/h +- 1 |
|
||||
| a | b | ab,ab | 47 km/h +- 1 |
|
||||
| b | c | bc,bc | 47 km/h +- 1 |
|
||||
|
||||
Scenario: Car - Advisory speed overwrites forward maxspeed
|
||||
Given the node map
|
||||
@@ -31,9 +31,10 @@ OSRM will use 4/5 of the projected free-flow speed.
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | speed |
|
||||
| a | b | ab | 47 km/h +- 1 |
|
||||
| b | c | bc | 47 km/h +- 1 |
|
||||
| a | b | ab,ab | 47 km/h +- 1 |
|
||||
| b | c | bc,bc | 47 km/h +- 1 |
|
||||
|
||||
@mokob @2162
|
||||
Scenario: Car - Advisory speed overwrites backwards maxspeed
|
||||
Given the node map
|
||||
| a | b | c |
|
||||
@@ -45,9 +46,26 @@ OSRM will use 4/5 of the projected free-flow speed.
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | speed |
|
||||
| b | a | ab | 47 km/h +- 1 |
|
||||
| c | b | bc | 47 km/h +- 1 |
|
||||
| b | a | ab,ab | 47 km/h +- 1 |
|
||||
| c | b | bc,bc | 47 km/h +- 1 |
|
||||
|
||||
@mokob @2162 @deleteme
|
||||
Scenario: Car - Advisory speed overwrites backwards maxspeed
|
||||
Given the node map
|
||||
| a | b | c | d |
|
||||
|
||||
And the ways
|
||||
| nodes | highway | maxspeed:backward | maxspeed:advisory:backward |
|
||||
| ab | residential | | 45 |
|
||||
| bc | residential | 90 | 45 |
|
||||
| cd | residential | | 45 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | speed |
|
||||
| c | b | bc,bc | 47 km/h +- 1 |
|
||||
| d | c | cd,cd | 47 km/h +- 1 |
|
||||
|
||||
@mokob @2162
|
||||
Scenario: Car - Directional advisory speeds play nice with eachother
|
||||
Given the node map
|
||||
| a | b | c |
|
||||
@@ -59,9 +77,9 @@ OSRM will use 4/5 of the projected free-flow speed.
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | speed |
|
||||
| a | b | ab | 47 km/h +- 1 |
|
||||
| b | a | ab | 59 km/h +- 1 |
|
||||
| b | c | bc | 59 km/h +- 1 |
|
||||
| c | b | bc | 47 km/h +- 1 |
|
||||
| a | b | ab,ab | 47 km/h +- 1 |
|
||||
| b | a | ab,ab | 59 km/h +- 1 |
|
||||
| b | c | bc,bc | 59 km/h +- 1 |
|
||||
| c | b | bc,bc | 47 km/h +- 1 |
|
||||
|
||||
|
||||
|
||||
+14
-14
@@ -17,15 +17,15 @@ Feature: Car - Handle movable bridge
|
||||
| efg | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes |
|
||||
| a | g | abc,cde,efg | 1,3,1 |
|
||||
| b | f | abc,cde,efg | 1,3,1 |
|
||||
| e | c | cde | 3 |
|
||||
| e | b | cde,abc | 3,1 |
|
||||
| e | a | cde,abc | 3,1 |
|
||||
| c | e | cde | 3 |
|
||||
| c | f | cde,efg | 3,1 |
|
||||
| c | g | cde,efg | 3,1 |
|
||||
| from | to | route | modes |
|
||||
| a | g | abc,cde,efg,efg | driving,movable bridge,driving,driving |
|
||||
| b | f | abc,cde,efg,efg | driving,movable bridge,driving,driving |
|
||||
| e | c | cde,cde | movable bridge,movable bridge |
|
||||
| e | b | cde,abc,abc | movable bridge,driving,driving |
|
||||
| e | a | cde,abc,abc | movable bridge,driving,driving |
|
||||
| c | e | cde,cde | movable bridge,movable bridge |
|
||||
| c | f | cde,efg,efg | movable bridge,driving,driving |
|
||||
| c | g | cde,efg,efg | movable bridge,driving,driving |
|
||||
|
||||
Scenario: Car - Properly handle durations
|
||||
Given the node map
|
||||
@@ -40,8 +40,8 @@ Feature: Car - Handle movable bridge
|
||||
| efg | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes | speed |
|
||||
| a | g | abc,cde,efg | 1,3,1 | 7 km/h |
|
||||
| b | f | abc,cde,efg | 1,3,1 | 5 km/h |
|
||||
| c | e | cde | 3 | 2 km/h |
|
||||
| e | c | cde | 3 | 2 km/h |
|
||||
| from | to | route | modes | speed |
|
||||
| a | g | abc,cde,efg,efg | driving,movable bridge,driving,driving | 7 km/h |
|
||||
| b | f | abc,cde,efg,efg | driving,movable bridge,driving,driving | 5 km/h |
|
||||
| c | e | cde,cde | movable bridge,movable bridge | 2 km/h |
|
||||
| e | c | cde,cde | movable bridge,movable bridge | 2 km/h |
|
||||
|
||||
+19
-19
@@ -17,15 +17,15 @@ Feature: Car - Handle ferry routes
|
||||
| efg | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes |
|
||||
| a | g | abc,cde,efg | 1,2,1 |
|
||||
| b | f | abc,cde,efg | 1,2,1 |
|
||||
| e | c | cde | 2 |
|
||||
| e | b | cde,abc | 2,1 |
|
||||
| e | a | cde,abc | 2,1 |
|
||||
| c | e | cde | 2 |
|
||||
| c | f | cde,efg | 2,1 |
|
||||
| c | g | cde,efg | 2,1 |
|
||||
| from | to | route | modes |
|
||||
| a | g | abc,cde,efg,efg | driving,ferry,driving,driving |
|
||||
| b | f | abc,cde,efg,efg | driving,ferry,driving,driving |
|
||||
| e | c | cde,cde | ferry,ferry |
|
||||
| e | b | cde,abc,abc | ferry,driving,driving |
|
||||
| e | a | cde,abc,abc | ferry,driving,driving |
|
||||
| c | e | cde,cde | ferry,ferry |
|
||||
| c | f | cde,efg,efg | ferry,driving,driving |
|
||||
| c | g | cde,efg,efg | ferry,driving,driving |
|
||||
|
||||
Scenario: Car - Properly handle simple durations
|
||||
Given the node map
|
||||
@@ -40,11 +40,11 @@ Feature: Car - Handle ferry routes
|
||||
| efg | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes | speed |
|
||||
| a | g | abc,cde,efg | 1,2,1 | 25 km/h |
|
||||
| b | f | abc,cde,efg | 1,2,1 | 20 km/h |
|
||||
| c | e | cde | 2 | 12 km/h |
|
||||
| e | c | cde | 2 | 12 km/h |
|
||||
| from | to | route | modes | speed |
|
||||
| a | g | abc,cde,efg,efg | driving,ferry,driving,driving | 25 km/h |
|
||||
| b | f | abc,cde,efg,efg | driving,ferry,driving,driving | 20 km/h |
|
||||
| c | e | cde,cde | ferry,ferry | 12 km/h |
|
||||
| e | c | cde,cde | ferry,ferry | 12 km/h |
|
||||
|
||||
Scenario: Car - Properly handle ISO 8601 durations
|
||||
Given the node map
|
||||
@@ -59,8 +59,8 @@ Feature: Car - Handle ferry routes
|
||||
| efg | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes | speed |
|
||||
| a | g | abc,cde,efg | 1,2,1 | 25 km/h |
|
||||
| b | f | abc,cde,efg | 1,2,1 | 20 km/h |
|
||||
| c | e | cde | 2 | 12 km/h |
|
||||
| e | c | cde | 2 | 12 km/h |
|
||||
| from | to | route | modes | speed |
|
||||
| a | g | abc,cde,efg,efg | driving,ferry,driving,driving | 25 km/h |
|
||||
| b | f | abc,cde,efg,efg | driving,ferry,driving,driving | 20 km/h |
|
||||
| c | e | cde,cde | ferry,ferry | 12 km/h |
|
||||
| e | c | cde,cde | ferry,ferry | 12 km/h |
|
||||
|
||||
+15
-15
@@ -24,9 +24,9 @@ Feature: Car - Speed on links
|
||||
| dy | unclassified |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| x | y | xa,ae,ef,fd,dy |
|
||||
| b | c | bc |
|
||||
| from | to | route |
|
||||
| x | y | xa,ae,ef,fd,dy,dy |
|
||||
| b | c | bc,bc |
|
||||
|
||||
Scenario: Car - Use trunk_link when reasonable
|
||||
Given the node map
|
||||
@@ -44,9 +44,9 @@ Feature: Car - Speed on links
|
||||
| fd | trunk |
|
||||
| dy | unclassified |
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| x | y | xa,ae,ef,fd,dy |
|
||||
| b | c | bc |
|
||||
| from | to | route |
|
||||
| x | y | xa,ae,ef,fd,dy,dy |
|
||||
| b | c | bc,bc |
|
||||
|
||||
Scenario: Car - Use primary_link when reasonable
|
||||
Given the node map
|
||||
@@ -64,9 +64,9 @@ Feature: Car - Speed on links
|
||||
| fd | primary |
|
||||
| dy | unclassified |
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| x | y | xa,ae,ef,fd,dy |
|
||||
| b | c | bc |
|
||||
| from | to | route |
|
||||
| x | y | xa,ae,ef,fd,dy,dy |
|
||||
| b | c | bc,bc |
|
||||
|
||||
Scenario: Car - Use secondary_link when reasonable
|
||||
Given the node map
|
||||
@@ -85,9 +85,9 @@ Feature: Car - Speed on links
|
||||
| dy | unclassified |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| x | y | xa,ae,ef,fd,dy |
|
||||
| b | c | bc |
|
||||
| from | to | route |
|
||||
| x | y | xa,ae,ef,fd,dy,dy |
|
||||
| b | c | bc,bc |
|
||||
|
||||
Scenario: Car - Use tertiary_link when reasonable
|
||||
Given the node map
|
||||
@@ -106,6 +106,6 @@ Feature: Car - Speed on links
|
||||
| dy | unclassified |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| x | y | xa,ae,ef,fd,dy |
|
||||
| b | c | bc |
|
||||
| from | to | route |
|
||||
| x | y | xa,ae,ef,fd,dy,dy |
|
||||
| b | c | bc,bc |
|
||||
|
||||
@@ -21,12 +21,12 @@ OSRM will use 4/5 of the projected free-flow speed.
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | speed |
|
||||
| a | b | ab | 78 km/h |
|
||||
| b | c | bc | 59 km/h +- 1 |
|
||||
| c | d | cd | 51 km/h |
|
||||
| d | e | de | 75 km/h |
|
||||
| e | f | ef | 90 km/h |
|
||||
| f | g | fg | 106 km/h |
|
||||
| a | b | ab,ab | 79 km/h |
|
||||
| b | c | bc,bc | 59 km/h +- 1 |
|
||||
| c | d | cd,cd | 51 km/h |
|
||||
| d | e | de,de | 75 km/h |
|
||||
| e | f | ef,ef | 91 km/h |
|
||||
| f | g | fg,fg | 107 km/h |
|
||||
|
||||
Scenario: Car - Do not ignore maxspeed when higher than way speed
|
||||
Given the node map
|
||||
@@ -40,9 +40,9 @@ OSRM will use 4/5 of the projected free-flow speed.
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | speed |
|
||||
| a | b | ab | 31 km/h |
|
||||
| b | c | bc | 83 km/h +- 1 |
|
||||
| c | d | cd | 51 km/h |
|
||||
| a | b | ab,ab | 31 km/h |
|
||||
| b | c | bc,bc | 83 km/h +- 1 |
|
||||
| c | d | cd,cd | 51 km/h |
|
||||
|
||||
Scenario: Car - Forward/backward maxspeed
|
||||
Given a grid size of 100 meters
|
||||
|
||||
@@ -15,13 +15,13 @@ Feature: Car - Mode flag
|
||||
| cd | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd | head,right,left,destination | 1,2,1 |
|
||||
| d | a | cd,bc,ab | head,right,left,destination | 1,2,1 |
|
||||
| c | a | bc,ab | head,left,destination | 2,1 |
|
||||
| d | b | cd,bc | head,right,destination | 1,2 |
|
||||
| a | c | ab,bc | head,right,destination | 1,2 |
|
||||
| b | d | bc,cd | head,left,destination | 2,1 |
|
||||
| from | to | route | turns | modes |
|
||||
| a | d | ab,bc,cd,cd | depart,right,left,arrive | driving,ferry,driving,driving |
|
||||
| d | a | cd,bc,ab,ab | depart,right,left,arrive | driving,ferry,driving,driving |
|
||||
| c | a | bc,ab,ab | depart,left,arrive | ferry,driving,driving |
|
||||
| d | b | cd,bc,bc | depart,right,arrive | driving,ferry,ferry |
|
||||
| a | c | ab,bc,bc | depart,right,arrive | driving,ferry,ferry |
|
||||
| b | d | bc,cd,cd | depart,left,arrive | ferry,driving,driving |
|
||||
|
||||
Scenario: Car - Snapping when using a ferry
|
||||
Given the node map
|
||||
@@ -34,7 +34,7 @@ Feature: Car - Mode flag
|
||||
| ef | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns | modes | time |
|
||||
| c | d | bcde | head,destination | 2 | 600s |
|
||||
| from | to | route | turns | modes | time |
|
||||
| c | d | bcde,bcde | depart,arrive | ferry,ferry | 600s |
|
||||
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ Feature: Car - Street names in instructions
|
||||
| bc | Your Way | A1 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | c | My Way,Your Way (A1) |
|
||||
| from | to | route |
|
||||
| a | c | My Way,Your Way (A1),Your Way (A1) |
|
||||
|
||||
@todo
|
||||
Scenario: Car - Use way type to describe unnamed ways
|
||||
@@ -29,5 +29,5 @@ Feature: Car - Street names in instructions
|
||||
| bcd | residential | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | c | tertiary,residential |
|
||||
| from | to | route |
|
||||
| a | c | tertiary,residential,residential |
|
||||
|
||||
@@ -44,9 +44,9 @@ Feature: Car - Oneway streets
|
||||
| da | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | ab |
|
||||
| b | a | bc,cd,da |
|
||||
| from | to | route |
|
||||
| a | b | ab,ab |
|
||||
| b | a | bc,cd,da,da |
|
||||
|
||||
Scenario: Car - Cars should not be affected by bicycle tags
|
||||
Then routability should be
|
||||
@@ -75,5 +75,5 @@ Feature: Car - Oneway streets
|
||||
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | c | ab,bc |
|
||||
| from | to | route |
|
||||
| a | c | ab,bc,bc |
|
||||
|
||||
@@ -25,10 +25,10 @@ Feature: Car - Turn restrictions
|
||||
| restriction | sj | wj | j | no_left_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@no_turning
|
||||
Scenario: Car - No straight on
|
||||
@@ -55,8 +55,8 @@ Feature: Car - Turn restrictions
|
||||
| restriction | bj | jd | j | no_straight_on |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | e | av,vw,wx,xy,yz,ze |
|
||||
| from | to | route |
|
||||
| a | e | av,vw,wx,xy,yz,ze,ze |
|
||||
|
||||
@no_turning
|
||||
Scenario: Car - No right turn
|
||||
@@ -77,10 +77,10 @@ Feature: Car - Turn restrictions
|
||||
| restriction | sj | ej | j | no_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | |
|
||||
|
||||
@no_turning
|
||||
Scenario: Car - No u-turn
|
||||
@@ -101,10 +101,10 @@ Feature: Car - Turn restrictions
|
||||
| restriction | sj | wj | j | no_u_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@no_turning
|
||||
Scenario: Car - Handle any no_* relation
|
||||
@@ -125,10 +125,10 @@ Feature: Car - Turn restrictions
|
||||
| restriction | sj | wj | j | no_weird_zigzags |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@only_turning
|
||||
Scenario: Car - Only left turn
|
||||
@@ -149,10 +149,10 @@ Feature: Car - Turn restrictions
|
||||
| restriction | sj | wj | j | only_left_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | |
|
||||
| s | e | |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | |
|
||||
| s | e | |
|
||||
|
||||
@only_turning
|
||||
Scenario: Car - Only right turn
|
||||
@@ -173,10 +173,10 @@ Feature: Car - Turn restrictions
|
||||
| restriction | sj | ej | j | only_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | |
|
||||
| s | n | |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | |
|
||||
| s | n | |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@only_turning
|
||||
Scenario: Car - Only straight on
|
||||
@@ -197,10 +197,10 @@ Feature: Car - Turn restrictions
|
||||
| restriction | sj | nj | j | only_straight_on |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | |
|
||||
| s | n | sj,nj |
|
||||
| s | e | |
|
||||
| from | to | route |
|
||||
| s | w | |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | |
|
||||
|
||||
@no_turning
|
||||
Scenario: Car - Handle any only_* restriction
|
||||
@@ -221,10 +221,10 @@ Feature: Car - Turn restrictions
|
||||
| restriction | sj | nj | j | only_weird_zigzags |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | |
|
||||
| s | n | sj,nj |
|
||||
| s | e | |
|
||||
| from | to | route |
|
||||
| s | w | |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | |
|
||||
|
||||
@specific
|
||||
Scenario: Car - :hgv-qualified on a standard turn restriction
|
||||
@@ -245,10 +245,10 @@ Feature: Car - Turn restrictions
|
||||
| restriction | sj | nj | j | no_straight_on |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@specific
|
||||
Scenario: Car - :motorcar-qualified on a standard turn restriction
|
||||
@@ -269,10 +269,10 @@ Feature: Car - Turn restrictions
|
||||
| restriction | sj | nj | j | no_straight_on |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@except
|
||||
Scenario: Car - Except tag and on no_ restrictions
|
||||
@@ -298,11 +298,11 @@ Feature: Car - Turn restrictions
|
||||
| restriction | sj | dj | j | no_right_turn | motorcar |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | a | sj,aj |
|
||||
| s | b | |
|
||||
| s | c | |
|
||||
| s | d | sj,dj |
|
||||
| from | to | route |
|
||||
| s | a | sj,aj,aj |
|
||||
| s | b | |
|
||||
| s | c | |
|
||||
| s | d | sj,dj,dj |
|
||||
|
||||
@except
|
||||
Scenario: Car - Except tag and on only_ restrictions
|
||||
@@ -322,9 +322,9 @@ Feature: Car - Turn restrictions
|
||||
| restriction | sj | aj | j | only_straight_on | motorcar |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | a | sj,aj |
|
||||
| s | b | sj,bj |
|
||||
| from | to | route |
|
||||
| s | a | sj,aj,aj |
|
||||
| s | b | sj,bj,bj |
|
||||
|
||||
@except
|
||||
Scenario: Car - Several only_ restrictions at the same segment
|
||||
@@ -356,10 +356,10 @@ Feature: Car - Turn restrictions
|
||||
| restriction | da | ae | a | only_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| e | f | ae,xa,bx,fb |
|
||||
| c | f | dc,da,ae,ge,hg,hg,ge,ae,xa,bx,fb |
|
||||
| d | f | da,ae,ge,hg,hg,ge,ae,xa,bx,fb |
|
||||
| from | to | route |
|
||||
| e | f | ae,xa,bx,fb,fb |
|
||||
| c | f | dc,da,ae,ge,hg,hg,ge,ae,xa,bx,fb,fb |
|
||||
| d | f | da,ae,ge,hg,hg,ge,ae,xa,bx,fb,fb |
|
||||
|
||||
@except
|
||||
Scenario: Car - two only_ restrictions share same to-way
|
||||
@@ -391,9 +391,9 @@ Feature: Car - Turn restrictions
|
||||
| restriction | by | xy | y | only_straight_on |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | ax,xy,yb |
|
||||
| b | a | yb,xy,ax |
|
||||
| from | to | route |
|
||||
| a | b | ax,xy,yb,yb |
|
||||
| b | a | yb,xy,ax,ax |
|
||||
|
||||
@except
|
||||
Scenario: Car - two only_ restrictions share same from-way
|
||||
@@ -425,7 +425,7 @@ Feature: Car - Turn restrictions
|
||||
| restriction | xy | yb | y | only_straight_on |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | ax,xy,yb |
|
||||
| b | a | yb,xy,ax |
|
||||
| from | to | route |
|
||||
| a | b | ax,xy,yb,yb |
|
||||
| b | a | yb,xy,ax,ax |
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ Feature: Roundabout Instructions
|
||||
| abcda | roundabout |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns |
|
||||
| s | t | sa,tb | head,enter_roundabout-1,destination |
|
||||
| s | u | sa,uc | head,enter_roundabout-2,destination |
|
||||
| s | v | sa,vd | head,enter_roundabout-3,destination |
|
||||
| u | v | uc,vd | head,enter_roundabout-1,destination |
|
||||
| u | s | uc,sa | head,enter_roundabout-2,destination |
|
||||
| u | t | uc,tb | head,enter_roundabout-3,destination |
|
||||
| from | to | route | turns |
|
||||
| s | t | sa,tb,tb | depart,roundabout-exit-1,arrive |
|
||||
| s | u | sa,uc,uc | depart,roundabout-exit-2,arrive |
|
||||
| s | v | sa,vd,vd | depart,roundabout-exit-3,arrive |
|
||||
| u | v | uc,vd,vd | depart,roundabout-exit-1,arrive |
|
||||
| u | s | uc,sa,sa | depart,roundabout-exit-2,arrive |
|
||||
| u | t | uc,tb,tb | depart,roundabout-exit-3,arrive |
|
||||
|
||||
@@ -19,13 +19,13 @@ Feature: Car - Handle ferryshuttle train routes
|
||||
| gh | primary | | no |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | f | abc,cde,ef |
|
||||
| b | f | abc,cde,ef |
|
||||
| e | c | cde |
|
||||
| e | b | cde,abc |
|
||||
| e | a | cde,abc |
|
||||
| c | e | cde |
|
||||
| c | f | cde,ef |
|
||||
| f | g | |
|
||||
| g | h | gh |
|
||||
| from | to | route |
|
||||
| a | f | abc,cde,ef,ef |
|
||||
| b | f | abc,cde,ef,ef |
|
||||
| e | c | cde,cde |
|
||||
| e | b | cde,abc,abc |
|
||||
| e | a | cde,abc,abc |
|
||||
| c | e | cde,cde |
|
||||
| c | f | cde,ef,ef |
|
||||
| f | g | |
|
||||
| g | h | gh,gh |
|
||||
|
||||
@@ -36,12 +36,12 @@ Feature: Traffic - speeds
|
||||
Given the extract extra arguments "--generate-edge-lookup"
|
||||
Given the contract extra arguments "--segment-speed-file speeds.csv"
|
||||
And I route I should get
|
||||
| from | to | route | speed |
|
||||
| a | b | ab | 27 km/h |
|
||||
| a | c | ab,bc | 27 km/h |
|
||||
| b | c | bc | 27 km/h |
|
||||
| a | d | ad | 27 km/h |
|
||||
| d | c | dc | 36 km/h |
|
||||
| g | b | ab | 27 km/h |
|
||||
| a | g | ab | 27 km/h |
|
||||
| from | to | route | speed |
|
||||
| a | b | ab,ab | 27 km/h |
|
||||
| a | c | ab,bc,bc | 27 km/h |
|
||||
| b | c | bc,bc | 27 km/h |
|
||||
| a | d | ad,ad | 27 km/h |
|
||||
| d | c | dc,dc | 36 km/h |
|
||||
| g | b | ab,ab | 27 km/h |
|
||||
| a | g | ab,ab | 27 km/h |
|
||||
|
||||
|
||||
+39
-39
@@ -17,15 +17,15 @@ Feature: Foot - Squares and other areas
|
||||
| abcda | yes | residential |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | abcda |
|
||||
| a | d | abcda |
|
||||
| b | c | abcda |
|
||||
| c | b | abcda |
|
||||
| c | d | abcda |
|
||||
| d | c | abcda |
|
||||
| d | a | abcda |
|
||||
| a | d | abcda |
|
||||
| from | to | route |
|
||||
| a | b | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
| b | c | abcda,abcda |
|
||||
| c | b | abcda,abcda |
|
||||
| c | d | abcda,abcda |
|
||||
| d | c | abcda,abcda |
|
||||
| d | a | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
|
||||
@building
|
||||
Scenario: Foot - Don't route on buildings
|
||||
@@ -41,14 +41,14 @@ Feature: Foot - Squares and other areas
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | xa |
|
||||
| a | d | xa |
|
||||
| b | c | xa |
|
||||
| c | b | xa |
|
||||
| c | d | xa |
|
||||
| d | c | xa |
|
||||
| d | a | xa |
|
||||
| a | d | xa |
|
||||
| a | b | xa,xa |
|
||||
| a | d | xa,xa |
|
||||
| b | c | xa,xa |
|
||||
| c | b | xa,xa |
|
||||
| c | d | xa,xa |
|
||||
| d | c | xa,xa |
|
||||
| d | a | xa,xa |
|
||||
| a | d | xa,xa |
|
||||
|
||||
@parking
|
||||
Scenario: Foot - parking areas
|
||||
@@ -65,17 +65,17 @@ Feature: Foot - Squares and other areas
|
||||
| abcda | (nil) | parking |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| x | y | xa,abcda,by |
|
||||
| y | x | by,abcda,xa |
|
||||
| a | b | abcda |
|
||||
| a | d | abcda |
|
||||
| b | c | abcda |
|
||||
| c | b | abcda |
|
||||
| c | d | abcda |
|
||||
| d | c | abcda |
|
||||
| d | a | abcda |
|
||||
| a | d | abcda |
|
||||
| from | to | route |
|
||||
| x | y | xa,abcda,by,by |
|
||||
| y | x | by,abcda,xa,xa |
|
||||
| a | b | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
| b | c | abcda,abcda |
|
||||
| c | b | abcda,abcda |
|
||||
| c | d | abcda,abcda |
|
||||
| d | c | abcda,abcda |
|
||||
| d | a | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
|
||||
@train @platform
|
||||
Scenario: Foot - railway platforms
|
||||
@@ -90,14 +90,14 @@ Feature: Foot - Squares and other areas
|
||||
| abcda | (nil) | platform |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| x | y | xa,abcda,by |
|
||||
| y | x | by,abcda,xa |
|
||||
| a | b | abcda |
|
||||
| a | d | abcda |
|
||||
| b | c | abcda |
|
||||
| c | b | abcda |
|
||||
| c | d | abcda |
|
||||
| d | c | abcda |
|
||||
| d | a | abcda |
|
||||
| a | d | abcda |
|
||||
| from | to | route |
|
||||
| x | y | xa,abcda,by,by |
|
||||
| y | x | by,abcda,xa,xa |
|
||||
| a | b | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
| b | c | abcda,abcda |
|
||||
| c | b | abcda,abcda |
|
||||
| c | d | abcda,abcda |
|
||||
| d | c | abcda,abcda |
|
||||
| d | a | abcda,abcda |
|
||||
| a | d | abcda,abcda |
|
||||
|
||||
+12
-12
@@ -17,15 +17,15 @@ Feature: Foot - Handle ferry routes
|
||||
| efg | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes |
|
||||
| a | g | abc,cde,efg | 1,2,1 |
|
||||
| b | f | abc,cde,efg | 1,2,1 |
|
||||
| e | c | cde | 2 |
|
||||
| e | b | cde,abc | 2,1 |
|
||||
| e | a | cde,abc | 2,1 |
|
||||
| c | e | cde | 2 |
|
||||
| c | f | cde,efg | 2,1 |
|
||||
| c | g | cde,efg | 2,1 |
|
||||
| from | to | route | modes |
|
||||
| a | g | abc,cde,efg,efg | walking,ferry,walking,walking |
|
||||
| b | f | abc,cde,efg,efg | walking,ferry,walking,walking |
|
||||
| e | c | cde,cde | ferry,ferry |
|
||||
| e | b | cde,abc,abc | ferry,walking,walking |
|
||||
| e | a | cde,abc,abc | ferry,walking,walking |
|
||||
| c | e | cde,cde | ferry,ferry |
|
||||
| c | f | cde,efg,efg | ferry,walking,walking |
|
||||
| c | g | cde,efg,efg | ferry,walking,walking |
|
||||
|
||||
Scenario: Foot - Ferry duration, single node
|
||||
Given the node map
|
||||
@@ -58,6 +58,6 @@ Feature: Foot - Handle ferry routes
|
||||
| abcd | | ferry | yes | 1:00 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | time |
|
||||
| a | d | abcd | 3600s +-10 |
|
||||
| d | a | abcd | 3600s +-10 |
|
||||
| from | to | route | time |
|
||||
| a | d | abcd,abcd | 3600s +-10 |
|
||||
| d | a | abcd,abcd | 3600s +-10 |
|
||||
|
||||
@@ -15,8 +15,8 @@ Feature: Foot - Street names in instructions
|
||||
| bc | Your Way |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | c | My Way,Your Way |
|
||||
| from | to | route |
|
||||
| a | c | My Way,Your Way,Your Way |
|
||||
|
||||
@unnamed
|
||||
Scenario: Foot - Use way type to describe unnamed ways
|
||||
@@ -29,5 +29,5 @@ Feature: Foot - Street names in instructions
|
||||
| bcd | track | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | d | {highway:footway},{highway:track} |
|
||||
| from | to | route |
|
||||
| a | d | {highway:footway},{highway:track},{highway:track} |
|
||||
|
||||
@@ -13,8 +13,8 @@ Feature: Foot - Way ref
|
||||
| ab | Utopia Drive | E7 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | Utopia Drive / E7 |
|
||||
| from | to | route |
|
||||
| a | b | Utopia Drive / E7,Utopia Drive / E7 |
|
||||
|
||||
Scenario: Foot - Way with only ref
|
||||
Given the node map
|
||||
@@ -26,7 +26,7 @@ Feature: Foot - Way ref
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | E7 |
|
||||
| a | b | E7,E7 |
|
||||
|
||||
Scenario: Foot - Way with only name
|
||||
Given the node map
|
||||
@@ -37,5 +37,5 @@ Feature: Foot - Way ref
|
||||
| ab | Utopia Drive |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | Utopia Drive |
|
||||
| from | to | route |
|
||||
| a | b | Utopia Drive,Utopia Drive |
|
||||
|
||||
@@ -24,10 +24,10 @@ Feature: Foot - Turn restrictions
|
||||
| restriction | sj | wj | j | no_left_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@no_turning
|
||||
Scenario: Foot - No right turn
|
||||
@@ -48,10 +48,10 @@ Feature: Foot - Turn restrictions
|
||||
| restriction | sj | ej | j | no_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@no_turning
|
||||
Scenario: Foot - No u-turn
|
||||
@@ -72,10 +72,10 @@ Feature: Foot - Turn restrictions
|
||||
| restriction | sj | wj | j | no_u_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@no_turning
|
||||
Scenario: Foot - Handle any no_* relation
|
||||
@@ -96,10 +96,10 @@ Feature: Foot - Turn restrictions
|
||||
| restriction | sj | wj | j | no_weird_zigzags |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@only_turning
|
||||
Scenario: Foot - Only left turn
|
||||
@@ -120,10 +120,10 @@ Feature: Foot - Turn restrictions
|
||||
| restriction | sj | wj | j | only_left_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@only_turning
|
||||
Scenario: Foot - Only right turn
|
||||
@@ -144,10 +144,10 @@ Feature: Foot - Turn restrictions
|
||||
| restriction | sj | ej | j | only_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@only_turning
|
||||
Scenario: Foot - Only straight on
|
||||
@@ -168,10 +168,10 @@ Feature: Foot - Turn restrictions
|
||||
| restriction | sj | nj | j | only_straight_on |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@no_turning
|
||||
Scenario: Foot - Handle any only_* restriction
|
||||
@@ -192,10 +192,10 @@ Feature: Foot - Turn restrictions
|
||||
| restriction | sj | nj | j | only_weird_zigzags |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | w | sj,wj |
|
||||
| s | n | sj,nj |
|
||||
| s | e | sj,ej |
|
||||
| from | to | route |
|
||||
| s | w | sj,wj,wj |
|
||||
| s | n | sj,nj,nj |
|
||||
| s | e | sj,ej,ej |
|
||||
|
||||
@except
|
||||
Scenario: Foot - Except tag and on no_ restrictions
|
||||
@@ -221,11 +221,11 @@ Feature: Foot - Turn restrictions
|
||||
| restriction | sj | dj | j | no_right_turn | foot |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | a | sj,aj |
|
||||
| s | b | sj,bj |
|
||||
| s | c | sj,cj |
|
||||
| s | d | sj,dj |
|
||||
| from | to | route |
|
||||
| s | a | sj,aj,aj |
|
||||
| s | b | sj,bj,bj |
|
||||
| s | c | sj,cj,cj |
|
||||
| s | d | sj,dj,dj |
|
||||
|
||||
@except
|
||||
Scenario: Foot - Except tag and on only_ restrictions
|
||||
@@ -245,9 +245,9 @@ Feature: Foot - Turn restrictions
|
||||
| restriction | sj | aj | j | only_straight_on | foot |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | a | sj,aj |
|
||||
| s | b | sj,bj |
|
||||
| from | to | route |
|
||||
| s | a | sj,aj,aj |
|
||||
| s | b | sj,bj,bj |
|
||||
|
||||
@except
|
||||
Scenario: Foot - Multiple except tag values
|
||||
@@ -279,10 +279,10 @@ Feature: Foot - Turn restrictions
|
||||
| restriction | sj | jf | j | no_straight_on | foot, bus |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| s | a | sj,ja |
|
||||
| s | b | sj,jb |
|
||||
| s | c | sj,jc |
|
||||
| s | d | sj,jd |
|
||||
| s | e | sj,je |
|
||||
| s | f | sj,jf |
|
||||
| from | to | route |
|
||||
| s | a | sj,ja,ja |
|
||||
| s | b | sj,jb,jb |
|
||||
| s | c | sj,jc,jc |
|
||||
| s | d | sj,jd,jd |
|
||||
| s | e | sj,je,je |
|
||||
| s | f | sj,jf,jf |
|
||||
|
||||
@@ -3,12 +3,12 @@ Feature: Roundabout Instructions
|
||||
|
||||
Background:
|
||||
Given the profile "foot"
|
||||
|
||||
|
||||
@todo
|
||||
Scenario: Foot - Roundabout instructions
|
||||
# You can walk in both directions on a roundabout, bu the normal roundabout instructions don't
|
||||
# make sense when you're going the opposite way around the roundabout.
|
||||
|
||||
|
||||
Given the node map
|
||||
| | | v | | |
|
||||
| | | d | | |
|
||||
@@ -25,10 +25,10 @@ Feature: Roundabout Instructions
|
||||
| abcda | roundabout |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns |
|
||||
| s | t | sa,tb | head,enter_roundabout-1,destination |
|
||||
| s | u | sa,uc | head,enter_roundabout-2,destination |
|
||||
| s | v | sa,vd | head,enter_roundabout-3,destination |
|
||||
| u | v | uc,vd | head,enter_roundabout-1,destination |
|
||||
| u | s | uc,sa | head,enter_roundabout-2,destination |
|
||||
| u | t | uc,tb | head,enter_roundabout-3,destination |
|
||||
| from | to | route | turns |
|
||||
| s | t | sa,tb | depart,roundabout-exit-1,arrive |
|
||||
| s | u | sa,uc | depart,roundabout-exit-2,arrive |
|
||||
| s | v | sa,vd | depart,roundabout-exit-3,arrive |
|
||||
| u | v | uc,vd | depart,roundabout-exit-1,arrive |
|
||||
| u | s | uc,sa | depart,roundabout-exit-2,arrive |
|
||||
| u | t | uc,tb | depart,roundabout-exit-3,arrive |
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
@routing @guidance
|
||||
Feature: Basic Roundabout
|
||||
|
||||
Background:
|
||||
Given the profile "testbot"
|
||||
Given a grid size of 10 meters
|
||||
|
||||
Scenario: Ramp Exit Right
|
||||
Given the node map
|
||||
| a | b | c | d | e |
|
||||
| | | | f | g |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abcde | motorway |
|
||||
| bfg | motorway_link |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,e | abcde, abcde | depart, arrive |
|
||||
| a,g | abcde, bfg, bfg | depart, ramp-slight-right, arrive |
|
||||
|
||||
Scenario: Ramp Exit Right Curved Right
|
||||
Given the node map
|
||||
| a | b | c | | |
|
||||
| | | f | d | |
|
||||
| | | | g | e |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abcde | motorway |
|
||||
| bfg | motorway_link |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,e | abcde, abcde | depart, arrive |
|
||||
| a,g | abcde, bfg, bfg | depart, ramp-slight-right, arrive |
|
||||
|
||||
Scenario: Ramp Exit Right Curved Left
|
||||
Given the node map
|
||||
| | | | | e |
|
||||
| | | | d | g |
|
||||
| a | b | c | f | |
|
||||
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abcde | motorway |
|
||||
| cfg | motorway_link |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,e | abcde, abcde | depart, arrive |
|
||||
| a,g | abcde, cfg, cfg | depart, ramp-slight-right, arrive |
|
||||
|
||||
|
||||
Scenario: Ramp Exit Left
|
||||
Given the node map
|
||||
| | | | f | g |
|
||||
| a | b | c | d | e |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abcde | motorway |
|
||||
| bfg | motorway_link |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,e | abcde, abcde | depart, arrive |
|
||||
| a,g | abcde, bfg, bfg | depart, ramp-slight-left, arrive |
|
||||
|
||||
Scenario: Ramp Exit Left Curved Left
|
||||
Given the node map
|
||||
| | | | g | e |
|
||||
| | | f | d | |
|
||||
| a | b | c | | |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abcde | motorway |
|
||||
| bfg | motorway_link |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,e | abcde, abcde | depart, arrive |
|
||||
| a,g | abcde, bfg, bfg | depart, ramp-slight-left, arrive |
|
||||
|
||||
Scenario: Ramp Exit Left Curved Right
|
||||
Given the node map
|
||||
| a | b | c | f | |
|
||||
| | | | d | g |
|
||||
| | | | | e |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abcde | motorway |
|
||||
| cfg | motorway_link |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,e | abcde, abcde | depart, arrive |
|
||||
| a,g | abcde, cfg, cfg | depart, ramp-slight-left, arrive |
|
||||
|
||||
Scenario: On Ramp Right
|
||||
Given the node map
|
||||
| a | b | c | d | e |
|
||||
| f | g | | | |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abcde | motorway |
|
||||
| fgd | motorway_link |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,e | abcde, abcde | depart, arrive |
|
||||
| f,e | abcde, fgd, fgd | depart, merge-slight-left, arrive |
|
||||
|
||||
Scenario: On Ramp Left
|
||||
Given the node map
|
||||
| f | g | | | |
|
||||
| a | b | c | d | e |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abcde | motorway |
|
||||
| fgd | motorway_link |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,e | abcde, abcde | depart, arrive |
|
||||
| f,e | abcde, fgd, fgd | depart, merge-slight-right, arrive |
|
||||
|
||||
Scenario: Highway Fork
|
||||
Given the node map
|
||||
| | | | | d | e |
|
||||
| a | b | c | | | |
|
||||
| | | | | f | g |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abcde | motorway |
|
||||
| cfg | motorway |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,e | abcde, abcde, abcde | depart, fork-left, arrive |
|
||||
| a,g | abcde, cfg, cfg | depart, fork-right, arrive |
|
||||
|
||||
Scenario: Fork After Ramp
|
||||
Given the node map
|
||||
| | | | | d | e |
|
||||
| a | b | c | | | |
|
||||
| | | | | f | g |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abc | motorway_link |
|
||||
| cde | motorway |
|
||||
| cfg | motorway |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,e | abc, cde, cde | depart, fork-left, arrive |
|
||||
| a,g | abc, cfg, cfg | depart, fork-right, arrive |
|
||||
|
||||
Scenario: On And Off Ramp Right
|
||||
Given the node map
|
||||
| a | b | | c | | d | e |
|
||||
| f | g | | | | h | i |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abcde | motorway |
|
||||
| fgc | motorway_link |
|
||||
| chi | motorway_link |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,e | abcde, abcde | depart, arrive |
|
||||
| f,e | fgc, abcde, abcde | depart, merge-slight-left, arrive |
|
||||
| a,i | abcde, chi, chi | depart, ramp-slight-right, arrive |
|
||||
| f,i | fgc, chi, chi | depart, turn-slight-right, arrive |
|
||||
|
||||
Scenario: On And Off Ramp Left
|
||||
Given the node map
|
||||
| f | g | | | | h | i |
|
||||
| a | b | | c | | d | e |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| abcde | motorway |
|
||||
| fgc | motorway_link |
|
||||
| chi | motorway_link |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,e | abcde, abcde | depart, arrive |
|
||||
| f,e | fgc, abcde, abcde | depart, merge-slight-right, arrive |
|
||||
| a,i | abcde, chi, chi | depart, ramp-slight-left, arrive |
|
||||
| f,i | fgc, chi, chi | depart, turn-slight-left, arrive |
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
@routing @guidance
|
||||
Feature: Basic Roundabout
|
||||
|
||||
Background:
|
||||
Given the profile "testbot"
|
||||
Given a grid size of 10 meters
|
||||
|
||||
Scenario: Enter and Exit
|
||||
Given the node map
|
||||
| | | a | | |
|
||||
| | | b | | |
|
||||
| h | g | | c | d |
|
||||
| | | e | | |
|
||||
| | | f | | |
|
||||
|
||||
And the ways
|
||||
| nodes | junction |
|
||||
| ab | |
|
||||
| cd | |
|
||||
| ef | |
|
||||
| gh | |
|
||||
| bcegb | roundabout |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,d | ab,cd,cd | depart,roundabout-exit-1,arrive |
|
||||
| a,f | ab,ef,ef | depart,roundabout-exit-2,arrive |
|
||||
| a,h | ab,gh,gh | depart,roundabout-exit-3,arrive |
|
||||
| d,f | cd,ef,ef | depart,roundabout-exit-1,arrive |
|
||||
| d,h | cd,gh,gh | depart,roundabout-exit-2,arrive |
|
||||
| d,a | cd,ab,ab | depart,roundabout-exit-3,arrive |
|
||||
| f,h | ef,gh,gh | depart,roundabout-exit-1,arrive |
|
||||
| f,a | ef,ab,ab | depart,roundabout-exit-2,arrive |
|
||||
| f,d | ef,cd,cd | depart,roundabout-exit-3,arrive |
|
||||
| h,a | gh,ab,ab | depart,roundabout-exit-1,arrive |
|
||||
| h,d | gh,cd,cd | depart,roundabout-exit-2,arrive |
|
||||
| h,f | gh,ef,ef | depart,roundabout-exit-3,arrive |
|
||||
|
||||
Scenario: Only Enter
|
||||
Given the node map
|
||||
| | | a | | |
|
||||
| | | b | | |
|
||||
| h | g | | c | d |
|
||||
| | | e | | |
|
||||
| | | f | | |
|
||||
|
||||
And the ways
|
||||
| nodes | junction |
|
||||
| ab | |
|
||||
| cd | |
|
||||
| ef | |
|
||||
| gh | |
|
||||
| bcegb | roundabout |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,b | ab,ab | depart,arrive |
|
||||
| a,c | ab,bcegb | depart,roundabout-enter,arrive |
|
||||
| a,e | ab,bcegb | depart,roundabout-enter,arrive |
|
||||
| a,g | ab,bcegb | depart,roundabout-enter,arrive |
|
||||
| d,c | cd,cd | depart,arrive |
|
||||
| d,e | cd,bcegb | depart,roundabout-enter,arrive |
|
||||
| d,g | cd,bcegb | depart,roundabout-enter,arrive |
|
||||
| d,b | cd,bcegb | depart,roundabout-enter,arrive |
|
||||
| f,e | ef,ef | depart,arrive |
|
||||
| f,g | ef,bcegb | depart,roundabout-enter,arrive |
|
||||
| f,b | ef,bcegb | depart,roundabout-enter,arrive |
|
||||
| f,c | ef,bcegb | depart,roundabout-enter,arrive |
|
||||
| h,g | gh,gh | depart,arrive |
|
||||
| h,b | gh,bcegb | depart,roundabout-enter,arrive |
|
||||
| h,c | gh,bcegb | depart,roundabout-enter,arrive |
|
||||
| h,e | gh,bcegb | depart,roundabout-enter,arrive |
|
||||
|
||||
Scenario: Only Exit
|
||||
Given the node map
|
||||
| | | a | | |
|
||||
| | | b | | |
|
||||
| h | g | | c | d |
|
||||
| | | e | | |
|
||||
| | | f | | |
|
||||
|
||||
And the ways
|
||||
| nodes | junction |
|
||||
| ab | |
|
||||
| cd | |
|
||||
| ef | |
|
||||
| gh | |
|
||||
| bcegb | roundabout |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| b,a | ab,ab | depart,arrive |
|
||||
| b,d | bcegb,cd,cd | depart,roundabout-exit-1,arrive |
|
||||
| b,f | bcegb,ef,ef | depart,roundabout-exit-2,arrive |
|
||||
| b,h | bcegb,gh,gh | depart,roundabout-exit-3,arrive |
|
||||
| c,d | cd,cd | depart,arrive |
|
||||
| c,f | bcegb,ef,ef | depart,roundabout-exit-1,arrive |
|
||||
| c,h | bcegb,gh,gh | depart,roundabout-exit-2,arrive |
|
||||
| c,a | bcegb,ab,ab | depart,roundabout-exit-3,arrive |
|
||||
| e,f | ef,ef | depart,arrive |
|
||||
| e,h | bcegb,gh,gh | depart,roundabout-exit-1,arrive |
|
||||
| e,a | bcegb,ab,ab | depart,roundabout-exit-2,arrive |
|
||||
| e,d | bcegb,cd,cd | depart,roundabout-exit-3,arrive |
|
||||
| g,h | gh,gh | depart,arrive |
|
||||
| g,a | bcegb,ab,ab | depart,roundabout-exit-1,arrive |
|
||||
| g,d | bcegb,cd,cd | depart,roundabout-exit-2,arrive |
|
||||
| g,f | bcegb,ef,ef | depart,roundabout-exit-3,arrive |
|
||||
|
||||
Scenario: Drive Around
|
||||
Given the node map
|
||||
| | | a | | |
|
||||
| | | b | | |
|
||||
| h | g | | c | d |
|
||||
| | | e | | |
|
||||
| | | f | | |
|
||||
|
||||
And the ways
|
||||
| nodes | junction |
|
||||
| ab | |
|
||||
| cd | |
|
||||
| ef | |
|
||||
| gh | |
|
||||
| bcegb | roundabout |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| b,c | bcegb,bcegb | depart,arrive |
|
||||
| b,e | bcegb,bcegb | depart,arrive |
|
||||
| b,g | bcegb,bcegb | depart,arrive |
|
||||
| c,e | bcegb,bcegb | depart,arrive |
|
||||
| c,g | bcegb,bcegb | depart,arrive |
|
||||
| c,b | bcegb,bcegb | depart,arrive |
|
||||
| e,g | bcegb,bcegb | depart,arrive |
|
||||
| e,b | bcegb,bcegb | depart,arrive |
|
||||
| e,c | bcegb,bcegb | depart,arrive |
|
||||
| g,b | bcegb,bcegb | depart,arrive |
|
||||
| g,c | bcegb,bcegb | depart,arrive |
|
||||
| g,e | bcegb,bcegb | depart,arrive |
|
||||
|
||||
Scenario: Mixed Entry and Exit
|
||||
Given the node map
|
||||
| | a | | c | |
|
||||
| l | | b | | d |
|
||||
| | k | | e | |
|
||||
| j | | h | | f |
|
||||
| | i | | g | |
|
||||
|
||||
And the ways
|
||||
| nodes | junction | oneway |
|
||||
| abc | | yes |
|
||||
| def | | yes |
|
||||
| ghi | | yes |
|
||||
| jkl | | yes |
|
||||
| behkb | roundabout | yes |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | turns |
|
||||
| a,c | abc,abc,abc | depart,roundabout-exit-1,arrive |
|
||||
| a,f | abc,def,def | depart,roundabout-exit-2,arrive |
|
||||
| a,i | abc,ghi,ghi | depart,roundabout-exit-3,arrive |
|
||||
| a,l | abc,jkl,jkl | depart,roundabout-exit-4,arrive |
|
||||
| d,f | def,def,def | depart,roundabout-exit-1,arrive |
|
||||
| d,i | def,ghi,ghi | depart,roundabout-exit-2,arrive |
|
||||
| d,l | def,jkl,jkl | depart,roundabout-exit-3,arrive |
|
||||
| d,c | def,abc,abc | depart,roundabout-exit-4,arrive |
|
||||
| g,i | ghi,ghi,ghi | depart,roundabout-exit-1,arrive |
|
||||
| g,l | ghi,jkl,jkl | depart,roundabout-exit-2,arrive |
|
||||
| g,c | ghi,abc,abc | depart,roundabout-exit-3,arrive |
|
||||
| g,f | ghi,edf,edf | depart,roundabout-exit-4,arrive |
|
||||
| j,l | jkl,jkl,jkl | depart,roundabout-exit-1,arrive |
|
||||
| j,c | jkl,abc,abc | depart,roundabout-exit-2,arrive |
|
||||
| j,f | jkl,def,def | depart,roundabout-exit-3,arrive |
|
||||
| j,i | jkl,ghi,ghi | depart,roundabout-exit-4,arrive |
|
||||
@@ -13,13 +13,6 @@ Feature: osrm-routed command line options: help
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--trial"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--hsgrdata arg"
|
||||
And stdout should contain "--nodesdata arg"
|
||||
And stdout should contain "--edgesdata arg"
|
||||
And stdout should contain "--ramindex arg"
|
||||
And stdout should contain "--fileindex arg"
|
||||
And stdout should contain "--namesdata arg"
|
||||
And stdout should contain "--timestamp arg"
|
||||
And stdout should contain "--ip"
|
||||
And stdout should contain "--port"
|
||||
And stdout should contain "--threads"
|
||||
@@ -39,13 +32,6 @@ Feature: osrm-routed command line options: help
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--trial"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--hsgrdata arg"
|
||||
And stdout should contain "--nodesdata arg"
|
||||
And stdout should contain "--edgesdata arg"
|
||||
And stdout should contain "--ramindex arg"
|
||||
And stdout should contain "--fileindex arg"
|
||||
And stdout should contain "--namesdata arg"
|
||||
And stdout should contain "--timestamp arg"
|
||||
And stdout should contain "--ip"
|
||||
And stdout should contain "--port"
|
||||
And stdout should contain "--threads"
|
||||
@@ -65,13 +51,6 @@ Feature: osrm-routed command line options: help
|
||||
And stdout should contain "--help"
|
||||
And stdout should contain "--trial"
|
||||
And stdout should contain "Configuration:"
|
||||
And stdout should contain "--hsgrdata arg"
|
||||
And stdout should contain "--nodesdata arg"
|
||||
And stdout should contain "--edgesdata arg"
|
||||
And stdout should contain "--ramindex arg"
|
||||
And stdout should contain "--fileindex arg"
|
||||
And stdout should contain "--namesdata arg"
|
||||
And stdout should contain "--timestamp arg"
|
||||
And stdout should contain "--ip"
|
||||
And stdout should contain "--port"
|
||||
And stdout should contain "--threads"
|
||||
|
||||
@@ -13,7 +13,6 @@ Feature: osrm-routed command line options: invalid options
|
||||
|
||||
Scenario: osrm-routed - Missing file
|
||||
When I run "osrm-routed over-the-rainbow.osrm"
|
||||
Then stdout should contain "over-the-rainbow.osrm"
|
||||
And stderr should contain "exception"
|
||||
Then stderr should contain "over-the-rainbow.osrm"
|
||||
And stderr should contain "not found"
|
||||
And it should exit with code 1
|
||||
|
||||
@@ -28,18 +28,19 @@ Feature: Raster - weights
|
||||
0 0 0 250
|
||||
0 0 0 0
|
||||
"""
|
||||
And the data has been saved to disk
|
||||
|
||||
Scenario: Weighting not based on raster sources
|
||||
Given the profile "testbot"
|
||||
When I run "osrm-extract {osm_base}.osm -p {profile}"
|
||||
And I run "osrm-contract {osm_base}.osm"
|
||||
And I route I should get
|
||||
| from | to | route | speed |
|
||||
| a | b | ab | 36 km/h |
|
||||
| a | c | ab,bc | 36 km/h |
|
||||
| b | c | bc | 36 km/h |
|
||||
| a | d | ad | 36 km/h |
|
||||
| d | c | dc | 36 km/h |
|
||||
| from | to | route | speed |
|
||||
| a | b | ab,ab | 36 km/h |
|
||||
| a | c | ab,bc,bc | 36 km/h |
|
||||
| b | c | bc,bc | 36 km/h |
|
||||
| a | d | ad,ad | 36 km/h |
|
||||
| d | c | dc,dc | 36 km/h |
|
||||
|
||||
Scenario: Weighting based on raster sources
|
||||
Given the profile "rasterbot"
|
||||
@@ -47,32 +48,32 @@ Feature: Raster - weights
|
||||
Then stdout should contain "evaluating segment"
|
||||
And I run "osrm-contract {osm_base}.osm"
|
||||
And I route I should get
|
||||
| from | to | route | speed |
|
||||
| a | b | ab | 8 km/h |
|
||||
| a | c | ad,dc | 15 km/h |
|
||||
| b | c | bc | 8 km/h |
|
||||
| a | d | ad | 15 km/h |
|
||||
| d | c | dc | 15 km/h |
|
||||
| d | e | de | 10 km/h |
|
||||
| e | b | eb | 10 km/h |
|
||||
| d | f | df | 15 km/h |
|
||||
| f | b | fb | 7 km/h |
|
||||
| d | b | de,eb | 10 km/h |
|
||||
| from | to | route | speed |
|
||||
| a | b | ab,ab | 8 km/h |
|
||||
| a | c | ad,dc,dc | 15 km/h |
|
||||
| b | c | bc,bc | 8 km/h |
|
||||
| a | d | ad,ad | 15 km/h |
|
||||
| d | c | dc,dc | 15 km/h |
|
||||
| d | e | de,de | 10 km/h |
|
||||
| e | b | eb,eb | 10 km/h |
|
||||
| d | f | df,df | 15 km/h |
|
||||
| f | b | fb,fb | 7 km/h |
|
||||
| d | b | de,eb,eb | 10 km/h |
|
||||
|
||||
Scenario: Weighting based on raster sources
|
||||
Given the profile "rasterbot-interp"
|
||||
Given the profile "rasterbotinterp"
|
||||
When I run "osrm-extract {osm_base}.osm -p {profile}"
|
||||
Then stdout should contain "evaluating segment"
|
||||
And I run "osrm-contract {osm_base}.osm"
|
||||
And I route I should get
|
||||
| from | to | route | speed |
|
||||
| a | b | ab | 8 km/h |
|
||||
| a | c | ad,dc | 15 km/h |
|
||||
| b | c | bc | 8 km/h |
|
||||
| a | d | ad | 15 km/h |
|
||||
| d | c | dc | 15 km/h |
|
||||
| d | e | de | 10 km/h |
|
||||
| e | b | eb | 10 km/h |
|
||||
| d | f | df | 15 km/h |
|
||||
| f | b | fb | 7 km/h |
|
||||
| d | b | de,eb | 10 km/h |
|
||||
| from | to | route | speed |
|
||||
| a | b | ab,ab | 8 km/h |
|
||||
| a | c | ad,dc,dc | 15 km/h |
|
||||
| b | c | bc,bc | 8 km/h |
|
||||
| a | d | ad,ad | 15 km/h |
|
||||
| d | c | dc,dc | 15 km/h |
|
||||
| d | e | de,de | 10 km/h |
|
||||
| e | b | eb,eb | 10 km/h |
|
||||
| d | f | df,df | 15 km/h |
|
||||
| f | b | fb,fb | 7 km/h |
|
||||
| d | b | de,eb,eb | 10 km/h |
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
var util = require('util');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var d3 = require('d3-queue');
|
||||
var OSM = require('../support/build_osm');
|
||||
|
||||
module.exports = function () {
|
||||
this.Given(/^the profile "([^"]*)"$/, (profile, callback) => {
|
||||
this.setProfile(profile, callback);
|
||||
});
|
||||
|
||||
this.Given(/^the extract extra arguments "(.*?)"$/, (args, callback) => {
|
||||
this.setExtractArgs(args);
|
||||
callback();
|
||||
});
|
||||
|
||||
this.Given(/^the contract extra arguments "(.*?)"$/, (args, callback) => {
|
||||
this.setContractArgs(args);
|
||||
callback();
|
||||
});
|
||||
|
||||
this.Given(/^a grid size of (\d+) meters$/, (meters, callback) => {
|
||||
this.setGridSize(meters);
|
||||
callback();
|
||||
});
|
||||
|
||||
this.Given(/^the origin ([-+]?[0-9]*\.?[0-9]+),([-+]?[0-9]*\.?[0-9]+)$/, (lat, lon, callback) => {
|
||||
this.setOrigin([parseFloat(lon), parseFloat(lat)]);
|
||||
callback();
|
||||
});
|
||||
|
||||
this.Given(/^the shortcuts$/, (table, callback) => {
|
||||
var q = d3.queue();
|
||||
|
||||
var addShortcut = (row, cb) => {
|
||||
this.shortcutsHash[row.key] = row.value;
|
||||
cb();
|
||||
};
|
||||
|
||||
table.hashes().forEach((row) => {
|
||||
q.defer(addShortcut, row);
|
||||
});
|
||||
|
||||
q.awaitAll(callback);
|
||||
});
|
||||
|
||||
this.Given(/^the node map$/, (table, callback) => {
|
||||
var q = d3.queue();
|
||||
|
||||
var addNode = (name, ri, ci, cb) => {
|
||||
if (name) {
|
||||
if (name.length !== 1) throw new Error(util.format('*** node invalid name %s, must be single characters', name));
|
||||
if (!name.match(/[a-z0-9]/)) throw new Error(util.format('*** invalid node name %s, must me alphanumeric', name));
|
||||
|
||||
var lonLat;
|
||||
if (name.match(/[a-z]/)) {
|
||||
if (this.nameNodeHash[name]) throw new Error(util.format('*** duplicate node %s', name));
|
||||
lonLat = this.tableCoordToLonLat(ci, ri);
|
||||
this.addOSMNode(name, lonLat[0], lonLat[1], null);
|
||||
} else {
|
||||
if (this.locationHash[name]) throw new Error(util.format('*** duplicate node %s'), name);
|
||||
lonLat = this.tableCoordToLonLat(ci, ri);
|
||||
this.addLocation(name, lonLat[0], lonLat[1], null);
|
||||
}
|
||||
|
||||
cb();
|
||||
}
|
||||
else cb();
|
||||
};
|
||||
|
||||
table.raw().forEach((row, ri) => {
|
||||
row.forEach((name, ci) => {
|
||||
q.defer(addNode, name, ri, ci);
|
||||
});
|
||||
});
|
||||
|
||||
q.awaitAll(callback);
|
||||
});
|
||||
|
||||
this.Given(/^the node locations$/, (table, callback) => {
|
||||
var q = d3.queue();
|
||||
|
||||
var addNodeLocations = (row, cb) => {
|
||||
var name = row.node;
|
||||
if (this.findNodeByName(name)) throw new Error(util.format('*** duplicate node %s'), name);
|
||||
|
||||
if (name.match(/[a-z]/)) {
|
||||
var id = row.id && parseInt(row.id);
|
||||
this.addOSMNode(name, row.lon, row.lat, id);
|
||||
} else {
|
||||
this.addLocation(name, row.lon, row.lat);
|
||||
}
|
||||
|
||||
cb();
|
||||
};
|
||||
|
||||
table.hashes().forEach((row) => q.defer(addNodeLocations, row));
|
||||
|
||||
q.awaitAll(callback);
|
||||
});
|
||||
|
||||
this.Given(/^the nodes$/, (table, callback) => {
|
||||
var q = d3.queue();
|
||||
|
||||
var addNode = (row, cb) => {
|
||||
var name = row.node,
|
||||
node = this.findNodeByName(name);
|
||||
delete row.node;
|
||||
if (!node) throw new Error(util.format('*** unknown node %s'), name);
|
||||
for (var key in row) {
|
||||
node.addTag(key, row[key]);
|
||||
}
|
||||
cb();
|
||||
};
|
||||
|
||||
table.hashes().forEach((row) => q.defer(addNode, row));
|
||||
|
||||
q.awaitAll(callback);
|
||||
});
|
||||
|
||||
this.Given(/^the ways$/, (table, callback) => {
|
||||
if (this.osm_str) throw new Error('*** Map data already defined - did you pass an input file in this scenario?');
|
||||
|
||||
var q = d3.queue();
|
||||
|
||||
var addWay = (row, cb) => {
|
||||
var way = new OSM.Way(this.makeOSMId(), this.OSM_USER, this.OSM_TIMESTAMP, this.OSM_UID);
|
||||
|
||||
var nodes = row.nodes;
|
||||
if (this.nameWayHash.nodes) throw new Error(util.format('*** duplicate way %s', nodes));
|
||||
|
||||
for (var i=0; i<nodes.length; i++) {
|
||||
var c = nodes[i];
|
||||
if (!c.match(/[a-z]/)) throw new Error(util.format('*** ways can only use names a-z (%s)', c));
|
||||
var node = this.findNodeByName(c);
|
||||
if (!node) throw new Error(util.format('*** unknown node %s', c));
|
||||
way.addNode(node);
|
||||
}
|
||||
|
||||
var tags = {
|
||||
highway: 'primary'
|
||||
};
|
||||
|
||||
for (var key in row) {
|
||||
tags[key] = row[key];
|
||||
}
|
||||
|
||||
delete tags.nodes;
|
||||
|
||||
if (row.highway === '(nil)') delete tags.highway;
|
||||
|
||||
if (row.name === undefined)
|
||||
tags.name = nodes;
|
||||
else if (row.name === '""' || row.name === "''") // eslint-disable-line quotes
|
||||
tags.name = '';
|
||||
else if (row.name === '' || row.name === '(nil)')
|
||||
delete tags.name;
|
||||
else
|
||||
tags.name = row.name;
|
||||
|
||||
way.setTags(tags);
|
||||
this.OSMDB.addWay(way);
|
||||
this.nameWayHash[nodes] = way;
|
||||
cb();
|
||||
};
|
||||
|
||||
table.hashes().forEach((row) => q.defer(addWay, row));
|
||||
|
||||
q.awaitAll(callback);
|
||||
});
|
||||
|
||||
this.Given(/^the relations$/, (table, callback) => {
|
||||
if (this.osm_str) throw new Error('*** Map data already defined - did you pass an input file in this scenario?');
|
||||
|
||||
var q = d3.queue();
|
||||
|
||||
var addRelation = (row, cb) => {
|
||||
var relation = new OSM.Relation(this.makeOSMId(), this.OSM_USER, this.OSM_TIMESTAMP, this.OSM_UID);
|
||||
|
||||
for (var key in row) {
|
||||
var isNode = key.match(/^node:(.*)/),
|
||||
isWay = key.match(/^way:(.*)/),
|
||||
isColonSeparated = key.match(/^(.*):(.*)/);
|
||||
if (isNode) {
|
||||
row[key].split(',').map(function(v) { return v.trim(); }).forEach((nodeName) => {
|
||||
if (nodeName.length !== 1) throw new Error(util.format('*** invalid relation node member "%s"'), nodeName);
|
||||
var node = this.findNodeByName(nodeName);
|
||||
if (!node) throw new Error(util.format('*** unknown relation node member "%s"'), nodeName);
|
||||
relation.addMember('node', node.id, isNode[1]);
|
||||
});
|
||||
} else if (isWay) {
|
||||
row[key].split(',').map(function(v) { return v.trim(); }).forEach((wayName) => {
|
||||
var way = this.findWayByName(wayName);
|
||||
if (!way) throw new Error(util.format('*** unknown relation way member "%s"'), wayName);
|
||||
relation.addMember('way', way.id, isWay[1]);
|
||||
});
|
||||
} else if (isColonSeparated && isColonSeparated[1] !== 'restriction') {
|
||||
throw new Error(util.format('*** unknown relation member type "%s:%s", must be either "node" or "way"'), isColonSeparated[1], isColonSeparated[2]);
|
||||
} else {
|
||||
relation.addTag(key, row[key]);
|
||||
}
|
||||
}
|
||||
relation.uid = this.OSM_UID;
|
||||
|
||||
this.OSMDB.addRelation(relation);
|
||||
|
||||
cb();
|
||||
};
|
||||
|
||||
table.hashes().forEach((row) => q.defer(addRelation, row));
|
||||
|
||||
q.awaitAll(callback);
|
||||
});
|
||||
|
||||
this.Given(/^the input file ([^"]*)$/, (file, callback) => {
|
||||
if (path.extname(file) !== '.osm') throw new Error('*** Input file must be in .osm format');
|
||||
fs.readFile(file, 'utf8', (err, data) => {
|
||||
if (!err) this.osm_str = data.toString();
|
||||
callback(err);
|
||||
});
|
||||
});
|
||||
|
||||
this.Given(/^the raster source$/, (data, callback) => {
|
||||
fs.writeFile(path.resolve(this.TEST_FOLDER, 'rastersource.asc'), data, callback);
|
||||
});
|
||||
|
||||
this.Given(/^the speed file$/, (data, callback) => {
|
||||
fs.writeFile(path.resolve(this.TEST_FOLDER, 'speeds.csv'), data, callback);
|
||||
});
|
||||
|
||||
this.Given(/^the data has been saved to disk$/, (callback) => {
|
||||
try {
|
||||
this.reprocess(callback);
|
||||
} catch(e) {
|
||||
this.processError = e;
|
||||
callback(e);
|
||||
}
|
||||
});
|
||||
|
||||
this.Given(/^the data has been extracted$/, (callback) => {
|
||||
this.writeAndExtract((err) => {
|
||||
if (err) this.processError = err;
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
this.Given(/^the data has been contracted$/, (callback) => {
|
||||
this.reprocess((err) => {
|
||||
if (err) this.processError = err;
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
this.Given(/^osrm\-routed is stopped$/, (callback) => {
|
||||
this.OSRMLoader.shutdown((err) => {
|
||||
if (err) this.processError = err;
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
this.Given(/^data is loaded directly/, () => {
|
||||
this.loadMethod = 'directly';
|
||||
});
|
||||
|
||||
this.Given(/^data is loaded with datastore$/, () => {
|
||||
this.loadMethod = 'datastore';
|
||||
});
|
||||
|
||||
this.Given(/^the HTTP method "([^"]*)"$/, (method, callback) => {
|
||||
this.httpMethod = method;
|
||||
callback();
|
||||
});
|
||||
};
|
||||
@@ -1,202 +0,0 @@
|
||||
Given /^the profile "([^"]*)"$/ do |profile|
|
||||
set_profile profile
|
||||
end
|
||||
|
||||
Given(/^the import format "(.*?)"$/) do |format|
|
||||
set_input_format format
|
||||
end
|
||||
|
||||
Given /^the extract extra arguments "(.*?)"$/ do |args|
|
||||
set_extract_args args
|
||||
end
|
||||
|
||||
Given /^the contract extra arguments "(.*?)"$/ do |args|
|
||||
set_contract_args args
|
||||
end
|
||||
|
||||
Given /^a grid size of (\d+) meters$/ do |meters|
|
||||
set_grid_size meters
|
||||
end
|
||||
|
||||
Given /^the origin ([-+]?[0-9]*\.?[0-9]+),([-+]?[0-9]*\.?[0-9]+)$/ do |lat,lon|
|
||||
set_origin [lon.to_f,lat.to_f]
|
||||
end
|
||||
|
||||
Given /^the shortcuts$/ do |table|
|
||||
table.hashes.each do |row|
|
||||
shortcuts_hash[ row['key'] ] = row['value']
|
||||
end
|
||||
end
|
||||
|
||||
Given /^the node map$/ do |table|
|
||||
table.raw.each_with_index do |row,ri|
|
||||
row.each_with_index do |name,ci|
|
||||
unless name.empty?
|
||||
raise "*** node invalid name '#{name}', must be single characters" unless name.size == 1
|
||||
raise "*** invalid node name '#{name}', must me alphanumeric" unless name.match /[a-z0-9]/
|
||||
if name.match /[a-z]/
|
||||
raise "*** duplicate node '#{name}'" if name_node_hash[name]
|
||||
add_osm_node name, *table_coord_to_lonlat(ci,ri), nil
|
||||
else
|
||||
raise "*** duplicate node '#{name}'" if location_hash[name]
|
||||
add_location name, *table_coord_to_lonlat(ci,ri)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Given /^the node locations$/ do |table|
|
||||
table.hashes.each do |row|
|
||||
name = row['node']
|
||||
raise "*** duplicate node '#{name}'" if find_node_by_name name
|
||||
if name.match /[a-z]/
|
||||
id = row['id']
|
||||
id = id.to_i if id
|
||||
add_osm_node name, row['lon'].to_f, row['lat'].to_f, id
|
||||
else
|
||||
add_location name, row['lon'].to_f, row['lat'].to_f
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Given /^the nodes$/ do |table|
|
||||
table.hashes.each do |row|
|
||||
name = row.delete 'node'
|
||||
node = find_node_by_name(name)
|
||||
raise "*** unknown node '#{c}'" unless node
|
||||
node << row
|
||||
end
|
||||
end
|
||||
|
||||
Given /^the ways$/ do |table|
|
||||
raise "*** Map data already defined - did you pass an input file in this scenaria?" if @osm_str
|
||||
table.hashes.each do |row|
|
||||
way = OSM::Way.new make_osm_id, OSM_USER, OSM_TIMESTAMP
|
||||
way.uid = OSM_UID
|
||||
|
||||
nodes = row.delete 'nodes'
|
||||
raise "*** duplicate way '#{nodes}'" if name_way_hash[nodes]
|
||||
nodes.each_char do |c|
|
||||
raise "*** ways can only use names a-z, '#{name}'" unless c.match /[a-z]/
|
||||
node = find_node_by_name(c)
|
||||
raise "*** unknown node '#{c}'" unless node
|
||||
way << node
|
||||
end
|
||||
|
||||
defaults = { 'highway' => 'primary' }
|
||||
tags = defaults.merge(row)
|
||||
|
||||
if row['highway'] == '(nil)'
|
||||
tags.delete 'highway'
|
||||
end
|
||||
|
||||
if row['name'] == nil
|
||||
tags['name'] = nodes
|
||||
elsif (row['name'] == '""') || (row['name'] == "''")
|
||||
tags['name'] = ''
|
||||
elsif row['name'] == '' || row['name'] == '(nil)'
|
||||
tags.delete 'name'
|
||||
else
|
||||
tags['name'] = row['name']
|
||||
end
|
||||
|
||||
way << tags
|
||||
osm_db << way
|
||||
name_way_hash[nodes] = way
|
||||
end
|
||||
end
|
||||
|
||||
Given /^the relations$/ do |table|
|
||||
raise "*** Map data already defined - did you pass an input file in this scenaria?" if @osm_str
|
||||
table.hashes.each do |row|
|
||||
relation = OSM::Relation.new make_osm_id, OSM_USER, OSM_TIMESTAMP
|
||||
row.each_pair do |key,value|
|
||||
if key =~ /^node:(.*)/
|
||||
value.split(',').map { |v| v.strip }.each do |node_name|
|
||||
raise "***invalid relation node member '#{node_name}', must be single character" unless node_name.size == 1
|
||||
node = find_node_by_name(node_name)
|
||||
raise "*** unknown relation node member '#{node_name}'" unless node
|
||||
relation << OSM::Member.new( 'node', node.id, $1 )
|
||||
end
|
||||
elsif key =~ /^way:(.*)/
|
||||
value.split(',').map { |v| v.strip }.each do |way_name|
|
||||
way = find_way_by_name(way_name)
|
||||
raise "*** unknown relation way member '#{way_name}'" unless way
|
||||
relation << OSM::Member.new( 'way', way.id, $1 )
|
||||
end
|
||||
elsif key =~ /^(.*):(.*)/ && "#{$1}" != 'restriction'
|
||||
raise "*** unknown relation member type '#{$1}:#{$2}', must be either 'node' or 'way'"
|
||||
else
|
||||
relation << { key => value }
|
||||
end
|
||||
end
|
||||
relation.uid = OSM_UID
|
||||
osm_db << relation
|
||||
end
|
||||
end
|
||||
|
||||
Given /^the defaults$/ do
|
||||
end
|
||||
|
||||
Given /^the input file ([^"]*)$/ do |file|
|
||||
raise "*** Input file must in .osm format" unless File.extname(file)=='.osm'
|
||||
@osm_str = File.read file
|
||||
end
|
||||
|
||||
Given /^the raster source$/ do |data|
|
||||
Dir.chdir TEST_FOLDER do
|
||||
File.open("rastersource.asc", "w") {|f| f.write(data)}
|
||||
end
|
||||
end
|
||||
|
||||
Given /^the speed file$/ do |data|
|
||||
Dir.chdir TEST_FOLDER do
|
||||
File.open("speeds.csv", "w") {|f| f.write(data)}
|
||||
end
|
||||
end
|
||||
|
||||
Given /^the data has been saved to disk$/ do
|
||||
begin
|
||||
write_input_data
|
||||
rescue OSRMError => e
|
||||
@process_error = e
|
||||
end
|
||||
end
|
||||
|
||||
Given /^the data has been extracted$/ do
|
||||
begin
|
||||
write_input_data
|
||||
extract_data unless extracted?
|
||||
rescue OSRMError => e
|
||||
@process_error = e
|
||||
end
|
||||
end
|
||||
|
||||
Given /^the data has been contracted$/ do
|
||||
begin
|
||||
reprocess
|
||||
rescue OSRMError => e
|
||||
@process_error = e
|
||||
end
|
||||
end
|
||||
|
||||
Given /^osrm\-routed is stopped$/ do
|
||||
begin
|
||||
OSRMLoader.shutdown
|
||||
rescue OSRMError => e
|
||||
@process_error = e
|
||||
end
|
||||
end
|
||||
|
||||
Given /^data is loaded directly/ do
|
||||
@load_method = 'directly'
|
||||
end
|
||||
|
||||
Given /^data is loaded with datastore$/ do
|
||||
@load_method = 'datastore'
|
||||
end
|
||||
|
||||
Given /^the HTTP method "([^"]*)"$/ do |method|
|
||||
@http_method = method
|
||||
end
|
||||
@@ -0,0 +1,81 @@
|
||||
var util = require('util');
|
||||
|
||||
module.exports = function () {
|
||||
this.When(/^I request a travel time matrix I should get$/, (table, callback) => {
|
||||
var NO_ROUTE = 2147483647; // MAX_INT
|
||||
|
||||
var tableRows = table.raw();
|
||||
|
||||
if (tableRows[0][0] !== '') throw new Error('*** Top-left cell of matrix table must be empty');
|
||||
|
||||
var waypoints = [],
|
||||
columnHeaders = tableRows[0].slice(1),
|
||||
rowHeaders = tableRows.map((h) => h[0]).slice(1),
|
||||
symmetric = columnHeaders.every((ele, i) => ele === rowHeaders[i]);
|
||||
|
||||
if (symmetric) {
|
||||
columnHeaders.forEach((nodeName) => {
|
||||
var node = this.findNodeByName(nodeName);
|
||||
if (!node) throw new Error(util.format('*** unknown node "%s"'), nodeName);
|
||||
waypoints.push({ coord: node, type: 'loc' });
|
||||
});
|
||||
} else {
|
||||
columnHeaders.forEach((nodeName) => {
|
||||
var node = this.findNodeByName(nodeName);
|
||||
if (!node) throw new Error(util.format('*** unknown node "%s"'), nodeName);
|
||||
waypoints.push({ coord: node, type: 'dst' });
|
||||
});
|
||||
rowHeaders.forEach((nodeName) => {
|
||||
var node = this.findNodeByName(nodeName);
|
||||
if (!node) throw new Error(util.format('*** unknown node "%s"'), nodeName);
|
||||
waypoints.push({ coord: node, type: 'src' });
|
||||
});
|
||||
}
|
||||
|
||||
var actual = [];
|
||||
actual.push(table.headers);
|
||||
|
||||
this.reprocessAndLoadData(() => {
|
||||
// compute matrix
|
||||
var params = this.queryParams;
|
||||
|
||||
this.requestTable(waypoints, params, (err, response) => {
|
||||
if (err) return callback(err);
|
||||
if (!response.body.length) return callback(new Error('Invalid response body'));
|
||||
|
||||
var json = JSON.parse(response.body);
|
||||
|
||||
var result = json['durations'].map(row => {
|
||||
var hashes = {};
|
||||
row.forEach((v, i) => { hashes[tableRows[0][i+1]] = isNaN(parseInt(v)) ? '' : v; });
|
||||
return hashes;
|
||||
});
|
||||
|
||||
var testRow = (row, ri, cb) => {
|
||||
var ok = true;
|
||||
|
||||
for (var k in result[ri]) {
|
||||
if (this.FuzzyMatch.match(result[ri][k], row[k])) {
|
||||
result[ri][k] = row[k];
|
||||
} else if (row[k] === '' && result[ri][k] === NO_ROUTE) {
|
||||
result[ri][k] = '';
|
||||
} else {
|
||||
result[ri][k] = result[ri][k].toString();
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
var failed = { attempt: 'distance_matrix', query: this.query, response: response };
|
||||
this.logFail(row, result[ri], [failed]);
|
||||
}
|
||||
|
||||
result[ri][''] = row[''];
|
||||
cb(null, result[ri]);
|
||||
};
|
||||
|
||||
this.processRowsAndDiff(table, testRow, callback);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,66 +0,0 @@
|
||||
When /^I request a travel time matrix I should get$/ do |table|
|
||||
no_route = 2147483647 # MAX_INT
|
||||
|
||||
raise "*** Top-left cell of matrix table must be empty" unless table.headers[0]==""
|
||||
|
||||
waypoints = []
|
||||
column_headers = table.headers[1..-1]
|
||||
row_headers = table.rows.map { |h| h.first }
|
||||
symmetric = Set.new(column_headers) == Set.new(row_headers)
|
||||
if symmetric then
|
||||
column_headers.each do |node_name|
|
||||
node = find_node_by_name(node_name)
|
||||
raise "*** unknown node '#{node_name}" unless node
|
||||
waypoints << {:coord => node, :type => "loc"}
|
||||
end
|
||||
else
|
||||
column_headers.each do |node_name|
|
||||
node = find_node_by_name(node_name)
|
||||
raise "*** unknown node '#{node_name}" unless node
|
||||
waypoints << {:coord => node, :type => "dst"}
|
||||
end
|
||||
row_headers.each do |node_name|
|
||||
node = find_node_by_name(node_name)
|
||||
raise "*** unknown node '#{node_name}" unless node
|
||||
waypoints << {:coord => node, :type => "src"}
|
||||
end
|
||||
end
|
||||
|
||||
reprocess
|
||||
actual = []
|
||||
actual << table.headers
|
||||
OSRMLoader.load(self,"#{contracted_file}.osrm") do
|
||||
|
||||
# compute matrix
|
||||
params = @query_params
|
||||
response = request_table waypoints, params
|
||||
if response.body.empty? == false
|
||||
json_result = JSON.parse response.body
|
||||
result = json_result["distance_table"]
|
||||
end
|
||||
|
||||
|
||||
# compare actual and expected result, one row at a time
|
||||
table.rows.each_with_index do |row,ri|
|
||||
# fuzzy match
|
||||
ok = true
|
||||
0.upto(result[ri].size-1) do |i|
|
||||
if FuzzyMatch.match result[ri][i], row[i+1]
|
||||
result[ri][i] = row[i+1]
|
||||
elsif row[i+1]=="" and result[ri][i]==no_route
|
||||
result[ri][i] = ""
|
||||
else
|
||||
result[ri][i] = result[ri][i].to_s
|
||||
ok = false
|
||||
end
|
||||
end
|
||||
|
||||
# add row header
|
||||
r = [row[0],result[ri]].flatten
|
||||
|
||||
# store row for comparison
|
||||
actual << r
|
||||
end
|
||||
end
|
||||
table.diff! actual
|
||||
end
|
||||
@@ -0,0 +1,30 @@
|
||||
var util = require('util');
|
||||
|
||||
module.exports = function () {
|
||||
this.Before((scenario, callback) => {
|
||||
this.scenarioTitle = scenario.getName();
|
||||
|
||||
this.loadMethod = this.DEFAULT_LOAD_METHOD;
|
||||
this.queryParams = {};
|
||||
var d = new Date();
|
||||
this.scenarioTime = util.format('%d-%d-%dT%s:%s:%sZ', d.getFullYear(), d.getMonth()+1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds());
|
||||
this.resetData();
|
||||
this.hasLoggedPreprocessInfo = false;
|
||||
this.hasLoggedScenarioInfo = false;
|
||||
this.setGridSize(this.DEFAULT_GRID_SIZE);
|
||||
this.setOrigin(this.DEFAULT_ORIGIN);
|
||||
callback();
|
||||
});
|
||||
|
||||
this.Before('@ignore-platform-windows', () => {
|
||||
this.skipThisScenario();
|
||||
});
|
||||
|
||||
this.Before('@ignore-platform-unix', () => {
|
||||
this.skipThisScenario();
|
||||
});
|
||||
|
||||
this.Before('@ignore-platform-mac', () => {
|
||||
this.skipThisScenario();
|
||||
});
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
Before '@ignore-platform-windows' do
|
||||
skip_this_scenario
|
||||
end
|
||||
|
||||
Before '@ignore-platform-unix' do
|
||||
skip_this_scenario
|
||||
end
|
||||
|
||||
Before '@ignore-platform-mac' do
|
||||
skip_this_scenario
|
||||
end
|
||||
@@ -0,0 +1,174 @@
|
||||
var util = require('util');
|
||||
var d3 = require('d3-queue');
|
||||
|
||||
module.exports = function () {
|
||||
this.When(/^I match I should get$/, (table, callback) => {
|
||||
var got;
|
||||
|
||||
this.reprocessAndLoadData(() => {
|
||||
var testRow = (row, ri, cb) => {
|
||||
var afterRequest = (err, res) => {
|
||||
if (err) return cb(err);
|
||||
var json;
|
||||
|
||||
var headers = new Set(table.raw()[0]);
|
||||
|
||||
if (res.body.length) {
|
||||
json = JSON.parse(res.body);
|
||||
}
|
||||
|
||||
if (headers.has('status')) {
|
||||
got.status = json.status.toString();
|
||||
}
|
||||
|
||||
if (headers.has('message')) {
|
||||
got.message = json.status_message;
|
||||
}
|
||||
|
||||
if (headers.has('#')) {
|
||||
// comment column
|
||||
got['#'] = row['#'];
|
||||
}
|
||||
|
||||
var subMatchings = [],
|
||||
turns = '',
|
||||
route = '',
|
||||
duration = '';
|
||||
|
||||
if (res.statusCode === 200) {
|
||||
if (headers.has('matchings')) {
|
||||
subMatchings = json.matchings.filter(m => !!m).map(sub => sub.matched_points);
|
||||
}
|
||||
|
||||
if (headers.has('turns')) {
|
||||
if (json.matchings.length != 1) throw new Error('*** Checking turns only supported for matchings with one subtrace');
|
||||
turns = this.turnList(json.matchings[0].instructions);
|
||||
}
|
||||
|
||||
if (headers.has('route')) {
|
||||
if (json.matchings.length != 1) throw new Error('*** Checking route only supported for matchings with one subtrace');
|
||||
route = this.wayList(json.matchings[0]);
|
||||
}
|
||||
|
||||
if (headers.has('duration')) {
|
||||
if (json.matchings.length != 1) throw new Error('*** Checking duration only supported for matchings with one subtrace');
|
||||
duration = json.matchings[0].duration;
|
||||
}
|
||||
}
|
||||
|
||||
if (headers.has('turns')) {
|
||||
got.turns = turns;
|
||||
}
|
||||
|
||||
if (headers.has('route')) {
|
||||
got.route = route;
|
||||
}
|
||||
|
||||
if (headers.has('duration')) {
|
||||
got.duration = duration.toString();
|
||||
}
|
||||
|
||||
var ok = true;
|
||||
var encodedResult = '',
|
||||
extendedTarget = '';
|
||||
|
||||
var q = d3.queue();
|
||||
|
||||
var testSubMatching = (sub, si, scb) => {
|
||||
if (si >= subMatchings.length) {
|
||||
ok = false;
|
||||
q.abort();
|
||||
scb();
|
||||
} else {
|
||||
var sq = d3.queue();
|
||||
|
||||
var testSubNode = (ni, ncb) => {
|
||||
var node = this.findNodeByName(sub[ni]),
|
||||
outNode = subMatchings[si][ni];
|
||||
|
||||
if (this.FuzzyMatch.matchLocation(outNode, node)) {
|
||||
encodedResult += sub[ni];
|
||||
extendedTarget += sub[ni];
|
||||
} else {
|
||||
encodedResult += util.format('? [%s,%s]', outNode[0], outNode[1]);
|
||||
extendedTarget += util.format('%s [%d,%d]', node.lat, node.lon);
|
||||
ok = false;
|
||||
}
|
||||
ncb();
|
||||
};
|
||||
|
||||
for (var i=0; i<sub.length; i++) {
|
||||
sq.defer(testSubNode, i);
|
||||
}
|
||||
|
||||
sq.awaitAll(scb);
|
||||
}
|
||||
};
|
||||
|
||||
row.matchings.split(',').forEach((sub, si) => {
|
||||
q.defer(testSubMatching, sub, si);
|
||||
});
|
||||
|
||||
q.awaitAll(() => {
|
||||
if (ok) {
|
||||
if (headers.has('matchings')) {
|
||||
got.matchings = row.matchings;
|
||||
}
|
||||
|
||||
if (headers.has('timestamps')) {
|
||||
got.timestamps = row.timestamps;
|
||||
}
|
||||
} else {
|
||||
got.matchings = encodedResult;
|
||||
row.matchings = extendedTarget;
|
||||
this.logFail(row, got, { matching: { query: this.query, response: res } });
|
||||
}
|
||||
|
||||
cb(null, got);
|
||||
});
|
||||
};
|
||||
|
||||
if (row.request) {
|
||||
got = {};
|
||||
got.request = row.request;
|
||||
this.requestUrl(row.request, afterRequest);
|
||||
} else {
|
||||
var params = this.queryParams;
|
||||
got = {};
|
||||
for (var k in row) {
|
||||
var match = k.match(/param:(.*)/);
|
||||
if (match) {
|
||||
if (row[k] === '(nil)') {
|
||||
params[match[1]] = null;
|
||||
} else if (row[k]) {
|
||||
params[match[1]] = [row[k]];
|
||||
}
|
||||
got[k] = row[k];
|
||||
}
|
||||
}
|
||||
|
||||
var trace = [],
|
||||
timestamps = [];
|
||||
|
||||
if (row.trace) {
|
||||
for (var i=0; i<row.trace.length; i++) {
|
||||
var n = row.trace[i],
|
||||
node = this.findNodeByName(n);
|
||||
if (!node) throw new Error(util.format('*** unknown waypoint node "%s"'), n);
|
||||
trace.push(node);
|
||||
}
|
||||
if (row.timestamps) {
|
||||
timestamps = row.timestamps.split(' ').filter(s => !!s).map(t => parseInt(t, 10));
|
||||
}
|
||||
got.trace = row.trace;
|
||||
this.requestMatching(trace, timestamps, params, afterRequest);
|
||||
} else {
|
||||
throw new Error('*** no trace');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.processRowsAndDiff(table, testRow, callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,124 +0,0 @@
|
||||
When /^I match I should get$/ do |table|
|
||||
reprocess
|
||||
actual = []
|
||||
OSRMLoader.load(self,"#{contracted_file}.osrm") do
|
||||
table.hashes.each_with_index do |row,ri|
|
||||
if row['request']
|
||||
got = {'request' => row['request'] }
|
||||
response = request_url row['request']
|
||||
else
|
||||
params = @query_params
|
||||
got = {}
|
||||
row.each_pair do |k,v|
|
||||
if k =~ /param:(.*)/
|
||||
if v=='(nil)'
|
||||
params[$1]=nil
|
||||
elsif v!=nil
|
||||
params[$1]=[v]
|
||||
end
|
||||
got[k]=v
|
||||
end
|
||||
end
|
||||
trace = []
|
||||
timestamps = []
|
||||
if row['trace']
|
||||
row['trace'].each_char do |n|
|
||||
node = find_node_by_name(n.strip)
|
||||
raise "*** unknown waypoint node '#{n.strip}" unless node
|
||||
trace << node
|
||||
end
|
||||
if row['timestamps']
|
||||
timestamps = row['timestamps'].split(" ").compact.map { |t| t.to_i}
|
||||
end
|
||||
got = got.merge({'trace' => row['trace'] })
|
||||
response = request_matching trace, timestamps, params
|
||||
else
|
||||
raise "*** no trace"
|
||||
end
|
||||
end
|
||||
|
||||
if response.body.empty? == false
|
||||
json = JSON.parse response.body
|
||||
end
|
||||
|
||||
if table.headers.include? 'status'
|
||||
got['status'] = json['status'].to_s
|
||||
end
|
||||
if table.headers.include? 'message'
|
||||
got['message'] = json['status_message']
|
||||
end
|
||||
if table.headers.include? '#' # comment column
|
||||
got['#'] = row['#'] # copy value so it always match
|
||||
end
|
||||
|
||||
sub_matchings = []
|
||||
turns = ''
|
||||
route = ''
|
||||
duration = ''
|
||||
if response.code == "200"
|
||||
if table.headers.include? 'matchings'
|
||||
sub_matchings = json['matchings'].compact.map { |sub| sub['matched_points']}
|
||||
end
|
||||
if table.headers.include? 'turns'
|
||||
raise "*** Checking turns only support for matchings with one subtrace" unless json['matchings'].size == 1
|
||||
turns = turn_list json['matchings'][0]['instructions']
|
||||
end
|
||||
if table.headers.include? 'route'
|
||||
raise "*** Checking route only support for matchings with one subtrace" unless json['matchings'].size == 1
|
||||
route = way_list json['matchings'][0]['instructions']
|
||||
if table.headers.include? 'duration'
|
||||
raise "*** Checking duration only support for matchings with one subtrace" unless json['matchings'].size == 1
|
||||
duration = json['matchings'][0]['route_summary']['total_time']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if table.headers.include? 'turns'
|
||||
got['turns'] = turns
|
||||
end
|
||||
if table.headers.include? 'route'
|
||||
got['route'] = route
|
||||
end
|
||||
if table.headers.include? 'duration'
|
||||
got['duration'] = duration.to_s
|
||||
end
|
||||
|
||||
ok = true
|
||||
encoded_result = ""
|
||||
extended_target = ""
|
||||
row['matchings'].split(',').each_with_index do |sub, sub_idx|
|
||||
if sub_idx >= sub_matchings.length
|
||||
ok = false
|
||||
break
|
||||
end
|
||||
sub.length.times do |node_idx|
|
||||
node = find_node_by_name(sub[node_idx])
|
||||
out_node = sub_matchings[sub_idx][node_idx]
|
||||
if FuzzyMatch.match_location out_node, node
|
||||
encoded_result += sub[node_idx]
|
||||
extended_target += sub[node_idx]
|
||||
else
|
||||
encoded_result += "? [#{out_node[0]},#{out_node[1]}]"
|
||||
extended_target += "#{sub[node_idx]} [#{node.lat},#{node.lon}]"
|
||||
ok = false
|
||||
end
|
||||
end
|
||||
end
|
||||
if ok
|
||||
if table.headers.include? 'matchings'
|
||||
got['matchings'] = row['matchings']
|
||||
end
|
||||
if table.headers.include? 'timestamps'
|
||||
got['timestamps'] = row['timestamps']
|
||||
end
|
||||
else
|
||||
got['matchings'] = encoded_result
|
||||
row['matchings'] = extended_target
|
||||
log_fail row,got, { 'matching' => {:query => @query, :response => response} }
|
||||
end
|
||||
|
||||
actual << got
|
||||
end
|
||||
end
|
||||
table.diff! actual
|
||||
end
|
||||
@@ -0,0 +1,53 @@
|
||||
var util = require('util');
|
||||
|
||||
module.exports = function () {
|
||||
this.When(/^I request nearest I should get$/, (table, callback) => {
|
||||
this.reprocessAndLoadData(() => {
|
||||
var testRow = (row, ri, cb) => {
|
||||
var inNode = this.findNodeByName(row.in);
|
||||
if (!inNode) throw new Error(util.format('*** unknown in-node "%s"'), row.in);
|
||||
|
||||
var outNode = this.findNodeByName(row.out);
|
||||
if (!outNode) throw new Error(util.format('*** unknown out-node "%s"'), row.out);
|
||||
|
||||
this.requestNearest(inNode, this.queryParams, (err, response) => {
|
||||
if (err) return cb(err);
|
||||
var coord;
|
||||
|
||||
if (response.statusCode === 200 && response.body.length) {
|
||||
var json = JSON.parse(response.body);
|
||||
|
||||
coord = json.waypoints[0].location;
|
||||
|
||||
var got = { in: row.in, out: row.out };
|
||||
|
||||
var ok = true;
|
||||
|
||||
Object.keys(row).forEach((key) => {
|
||||
if (key === 'out') {
|
||||
if (this.FuzzyMatch.matchLocation(coord, outNode)) {
|
||||
got[key] = row[key];
|
||||
} else {
|
||||
row[key] = util.format('%s [%d,%d]', row[key], outNode.lat, outNode.lon);
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!ok) {
|
||||
var failed = { attempt: 'nearest', query: this.query, response: response };
|
||||
this.logFail(row, got, [failed]);
|
||||
}
|
||||
|
||||
cb(null, got);
|
||||
}
|
||||
else {
|
||||
cb();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.processRowsAndDiff(table, testRow, callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,51 +0,0 @@
|
||||
When /^I request nearest I should get$/ do |table|
|
||||
reprocess
|
||||
actual = []
|
||||
OSRMLoader.load(self,"#{contracted_file}.osrm") do
|
||||
table.hashes.each_with_index do |row,ri|
|
||||
in_node = find_node_by_name row['in']
|
||||
raise "*** unknown in-node '#{row['in']}" unless in_node
|
||||
|
||||
out_node = find_node_by_name row['out']
|
||||
raise "*** unknown out-node '#{row['out']}" unless out_node
|
||||
|
||||
response = request_nearest in_node, @query_params
|
||||
if response.code == "200" && response.body.empty? == false
|
||||
json = JSON.parse response.body
|
||||
if json['status'] == 200
|
||||
coord = json['mapped_coordinate']
|
||||
end
|
||||
end
|
||||
|
||||
got = {'in' => row['in'], 'out' => coord }
|
||||
|
||||
ok = true
|
||||
row.keys.each do |key|
|
||||
if key=='out'
|
||||
if FuzzyMatch.match_location coord, out_node
|
||||
got[key] = row[key]
|
||||
else
|
||||
row[key] = "#{row[key]} [#{out_node.lat},#{out_node.lon}]"
|
||||
ok = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless ok
|
||||
failed = { :attempt => 'nearest', :query => @query, :response => response }
|
||||
log_fail row,got,[failed]
|
||||
end
|
||||
|
||||
actual << got
|
||||
end
|
||||
end
|
||||
table.diff! actual
|
||||
end
|
||||
|
||||
When /^I request nearest (\d+) times I should get$/ do |n,table|
|
||||
ok = true
|
||||
n.to_i.times do
|
||||
ok = false unless step "I request nearest I should get", table
|
||||
end
|
||||
ok
|
||||
end
|
||||
@@ -0,0 +1,69 @@
|
||||
var assert = require('assert');
|
||||
|
||||
module.exports = function () {
|
||||
this.When(/^I run "osrm\-routed\s?(.*?)"$/, { timeout: this.SHUTDOWN_TIMEOUT }, (options, callback) => {
|
||||
this.runBin('osrm-routed', options, () => {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
this.When(/^I run "osrm\-extract\s?(.*?)"$/, (options, callback) => {
|
||||
this.runBin('osrm-extract', options, () => {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
this.When(/^I run "osrm\-contract\s?(.*?)"$/, (options, callback) => {
|
||||
this.runBin('osrm-contract', options, () => {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
this.When(/^I run "osrm\-datastore\s?(.*?)"$/, (options, callback) => {
|
||||
this.runBin('osrm-datastore', options, () => {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
this.Then(/^it should exit with code (\d+)$/, (code) => {
|
||||
assert.equal(this.exitCode, parseInt(code));
|
||||
});
|
||||
|
||||
this.Then(/^stdout should contain "(.*?)"$/, (str) => {
|
||||
assert.ok(this.stdout.indexOf(str) > -1);
|
||||
});
|
||||
|
||||
this.Then(/^stderr should contain "(.*?)"$/, (str) => {
|
||||
assert.ok(this.stderr.indexOf(str) > -1);
|
||||
});
|
||||
|
||||
this.Then(/^stdout should contain \/(.*)\/$/, (regexStr) => {
|
||||
var re = new RegExp(regexStr);
|
||||
assert.ok(this.stdout.match(re));
|
||||
});
|
||||
|
||||
this.Then(/^stderr should contain \/(.*)\/$/, (regexStr) => {
|
||||
var re = new RegExp(regexStr);
|
||||
assert.ok(this.stdout.match(re));
|
||||
});
|
||||
|
||||
this.Then(/^stdout should be empty$/, () => {
|
||||
assert.equal(this.stdout.trim(), '');
|
||||
});
|
||||
|
||||
this.Then(/^stderr should be empty$/, () => {
|
||||
assert.equal(this.stderr.trim(), '');
|
||||
});
|
||||
|
||||
this.Then(/^stdout should contain (\d+) lines?$/, (lines) => {
|
||||
assert.equal(this.stdout.split('\n').length - 1, parseInt(lines));
|
||||
});
|
||||
|
||||
this.Given(/^the query options$/, (table, callback) => {
|
||||
table.raw().forEach(tuple => {
|
||||
this.queryParams[tuple[0]] = tuple[1];
|
||||
});
|
||||
|
||||
callback();
|
||||
});
|
||||
};
|
||||
@@ -1,57 +0,0 @@
|
||||
When(/^I run "osrm\-routed\s?(.*?)"$/) do |options|
|
||||
begin
|
||||
Timeout.timeout(SHUTDOWN_TIMEOUT) { run_bin 'osrm-routed', options }
|
||||
rescue Timeout::Error
|
||||
raise "*** osrm-routed didn't quit. Maybe the --trial option wasn't used?"
|
||||
end
|
||||
end
|
||||
|
||||
When(/^I run "osrm\-extract\s?(.*?)"$/) do |options|
|
||||
run_bin 'osrm-extract', options
|
||||
end
|
||||
|
||||
When(/^I run "osrm\-contract\s?(.*?)"$/) do |options|
|
||||
run_bin 'osrm-contract', options
|
||||
end
|
||||
|
||||
When(/^I run "osrm\-datastore\s?(.*?)"$/) do |options|
|
||||
run_bin 'osrm-datastore', options
|
||||
end
|
||||
|
||||
Then /^it should exit with code (\d+)$/ do |code|
|
||||
expect(@exit_code).to eq( code.to_i )
|
||||
end
|
||||
|
||||
Then /^stdout should contain "(.*?)"$/ do |str|
|
||||
expect(@stdout).to include(str)
|
||||
end
|
||||
|
||||
Then /^stderr should contain "(.*?)"$/ do |str|
|
||||
expect(@stderr).to include(str)
|
||||
end
|
||||
|
||||
Then(/^stdout should contain \/(.*)\/$/) do |regex_str|
|
||||
regex = Regexp.new regex_str
|
||||
expect(@stdout).to match( regex )
|
||||
end
|
||||
|
||||
Then(/^stderr should contain \/(.*)\/$/) do |regex_str|
|
||||
regex = Regexp.new regex_str
|
||||
expect(@stderr).to match( regex )
|
||||
end
|
||||
|
||||
Then /^stdout should be empty$/ do
|
||||
expect(@stdout).to eq("")
|
||||
end
|
||||
|
||||
Then /^stderr should be empty$/ do
|
||||
expect(@stderr).to eq("")
|
||||
end
|
||||
|
||||
Then /^stdout should contain (\d+) lines?$/ do |lines|
|
||||
expect(@stdout.lines.count).to eq( lines.to_i )
|
||||
end
|
||||
|
||||
Given (/^the query options$/) do |table|
|
||||
table.rows_hash.each { |k,v| @query_params << [k, v] }
|
||||
end
|
||||
@@ -0,0 +1,60 @@
|
||||
var assert = require('assert');
|
||||
|
||||
module.exports = function () {
|
||||
this.When(/^I request \/(.*)$/, (path, callback) => {
|
||||
this.reprocessAndLoadData(() => {
|
||||
this.requestPath(path, {}, (err, res, body) => {
|
||||
this.response = res;
|
||||
callback(err, res, body);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
this.Then(/^I should get a response/, () => {
|
||||
this.ShouldGetAResponse();
|
||||
});
|
||||
|
||||
this.Then(/^response should be valid JSON$/, (callback) => {
|
||||
this.ShouldBeValidJSON(callback);
|
||||
});
|
||||
|
||||
this.Then(/^response should be well-formed$/, () => {
|
||||
this.ShouldBeWellFormed();
|
||||
});
|
||||
|
||||
this.Then(/^status code should be (\d+)$/, (code, callback) => {
|
||||
try {
|
||||
this.json = JSON.parse(this.response.body);
|
||||
} catch(e) {
|
||||
return callback(e);
|
||||
}
|
||||
assert.equal(this.json.status, parseInt(code));
|
||||
callback();
|
||||
});
|
||||
|
||||
this.Then(/^status message should be "(.*?)"$/, (message, callback) => {
|
||||
try {
|
||||
this.json = JSON.parse(this.response.body);
|
||||
} catch(e) {
|
||||
return callback(e);
|
||||
}
|
||||
assert(this.json.status_message, message);
|
||||
callback();
|
||||
});
|
||||
|
||||
this.Then(/^response should be a well-formed route$/, () => {
|
||||
this.ShouldBeWellFormed();
|
||||
assert.equal(typeof this.json.status_message, 'string');
|
||||
assert.equal(typeof this.json.route_summary, 'object');
|
||||
assert.equal(typeof this.json.route_geometry, 'string');
|
||||
assert.ok(Array.isArray(this.json.route_instructions));
|
||||
assert.ok(Array.isArray(this.json.via_points));
|
||||
assert.ok(Array.isArray(this.json.via_indices));
|
||||
});
|
||||
|
||||
this.Then(/^"([^"]*)" should return code (\d+)$/, (binary, code) => {
|
||||
assert.ok(this.processError instanceof this.OSRMError);
|
||||
assert.equal(this.processError.process, binary);
|
||||
assert.equal(parseInt(this.processError.code), parseInt(code));
|
||||
});
|
||||
};
|
||||
@@ -1,46 +0,0 @@
|
||||
When /^I request \/(.*)$/ do |path|
|
||||
reprocess
|
||||
OSRMLoader.load(self,"#{contracted_file}.osrm") do
|
||||
@response = request_path path, []
|
||||
end
|
||||
end
|
||||
|
||||
Then /^I should get a response/ do
|
||||
expect(@response.code).to eq("200")
|
||||
expect(@response.body).not_to eq(nil)
|
||||
expect(@response.body).not_to eq('')
|
||||
end
|
||||
|
||||
Then /^response should be valid JSON$/ do
|
||||
@json = JSON.parse @response.body
|
||||
end
|
||||
|
||||
Then /^response should be well-formed$/ do
|
||||
expect(@json['status'].class).to eq(Fixnum)
|
||||
end
|
||||
|
||||
Then /^status code should be (\d+)$/ do |code|
|
||||
@json = JSON.parse @response.body
|
||||
expect(@json['status']).to eq(code.to_i)
|
||||
end
|
||||
|
||||
Then /^status message should be "(.*?)"$/ do |message|
|
||||
@json = JSON.parse @response.body
|
||||
expect(@json['status_message']).to eq(message)
|
||||
end
|
||||
|
||||
Then /^response should be a well-formed route$/ do
|
||||
step "response should be well-formed"
|
||||
expect(@json['status_message'].class).to eq(String)
|
||||
expect(@json['route_summary'].class).to eq(Hash)
|
||||
expect(@json['route_geometry'].class).to eq(String)
|
||||
expect(@json['route_instructions'].class).to eq(Array)
|
||||
expect(@json['via_points'].class).to eq(Array)
|
||||
expect(@json['via_indices'].class).to eq(Array)
|
||||
end
|
||||
|
||||
Then /^"([^"]*)" should return code (\d+)$/ do |binary, code|
|
||||
expect(@process_error.is_a?(OSRMError)).to eq(true)
|
||||
expect(@process_error.process).to eq(binary)
|
||||
expect(@process_error.code.to_i).to eq(code.to_i)
|
||||
end
|
||||
@@ -0,0 +1,120 @@
|
||||
var util = require('util');
|
||||
var d3 = require('d3-queue');
|
||||
var classes = require('../support/data_classes');
|
||||
|
||||
module.exports = function () {
|
||||
this.Then(/^routability should be$/, (table, callback) => {
|
||||
this.buildWaysFromTable(table, () => {
|
||||
var directions = ['forw','backw','bothw'],
|
||||
headers = new Set(Object.keys(table.hashes()[0]));
|
||||
|
||||
if (!directions.some(k => !!headers.has(k))) {
|
||||
throw new Error('*** routability table must contain either "forw", "backw" or "bothw" column');
|
||||
}
|
||||
|
||||
this.reprocessAndLoadData(() => {
|
||||
var testRow = (row, i, cb) => {
|
||||
var outputRow = row;
|
||||
|
||||
testRoutabilityRow(i, (err, result) => {
|
||||
if (err) return cb(err);
|
||||
directions.filter(d => headers.has(d)).forEach((direction) => {
|
||||
var want = this.shortcutsHash[row[direction]] || row[direction];
|
||||
|
||||
switch (true) {
|
||||
case '' === want:
|
||||
case 'x' === want:
|
||||
outputRow[direction] = result[direction].status ?
|
||||
result[direction].status.toString() : '';
|
||||
break;
|
||||
case /^\d+s/.test(want):
|
||||
break;
|
||||
case /^\d+ km\/h/.test(want):
|
||||
break;
|
||||
default:
|
||||
throw new Error(util.format('*** Unknown expectation format: %s', want));
|
||||
}
|
||||
|
||||
if (this.FuzzyMatch.match(outputRow[direction], want)) {
|
||||
outputRow[direction] = row[direction];
|
||||
}
|
||||
});
|
||||
|
||||
if (outputRow != row) {
|
||||
this.logFail(row, outputRow, result);
|
||||
}
|
||||
|
||||
cb(null, outputRow);
|
||||
});
|
||||
};
|
||||
|
||||
this.processRowsAndDiff(table, testRow, callback);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var testRoutabilityRow = (i, cb) => {
|
||||
var result = {};
|
||||
|
||||
var testDirection = (dir, callback) => {
|
||||
var a = new classes.Location(this.origin[0] + (1+this.WAY_SPACING*i) * this.zoom, this.origin[1]),
|
||||
b = new classes.Location(this.origin[0] + (3+this.WAY_SPACING*i) * this.zoom, this.origin[1]),
|
||||
r = {};
|
||||
|
||||
r.which = dir;
|
||||
|
||||
this.requestRoute((dir === 'forw' ? [a, b] : [b, a]), [], this.queryParams, (err, res, body) => {
|
||||
if (err) return callback(err);
|
||||
|
||||
r.query = this.query;
|
||||
r.json = JSON.parse(body);
|
||||
r.status = res.statusCode === 200 ? 'x' : null;
|
||||
if (r.status) {
|
||||
r.route = this.wayList(r.json.routes[0]);
|
||||
|
||||
if (r.route.split(',')[0] === util.format('w%d', i)) {
|
||||
r.time = r.json.routes[0].duration;
|
||||
r.distance = r.json.routes[0].distance;
|
||||
r.speed = r.time > 0 ? parseInt(3.6 * r.distance / r.time) : null;
|
||||
} else {
|
||||
r.status = null;
|
||||
}
|
||||
}
|
||||
|
||||
callback(null, r);
|
||||
});
|
||||
};
|
||||
|
||||
d3.queue(1)
|
||||
.defer(testDirection, 'forw')
|
||||
.defer(testDirection, 'backw')
|
||||
.awaitAll((err, res) => {
|
||||
if (err) return cb(err);
|
||||
// check if forw and backw returned the same values
|
||||
res.forEach((dirRes) => {
|
||||
var which = dirRes.which;
|
||||
delete dirRes.which;
|
||||
result[which] = dirRes;
|
||||
});
|
||||
|
||||
result.bothw = {};
|
||||
|
||||
var sq = d3.queue();
|
||||
|
||||
var parseRes = (key, scb) => {
|
||||
if (result.forw[key] === result.backw[key]) {
|
||||
result.bothw[key] = result.forw[key];
|
||||
} else {
|
||||
result.bothw[key] = 'diff';
|
||||
}
|
||||
scb();
|
||||
};
|
||||
|
||||
['status', 'time', 'distance', 'speed'].forEach((key) => {
|
||||
sq.defer(parseRes, key);
|
||||
});
|
||||
|
||||
sq.awaitAll(() => { cb(null, result); });
|
||||
});
|
||||
};
|
||||
};
|
||||
@@ -1,78 +0,0 @@
|
||||
def test_routability_row i
|
||||
result = {}
|
||||
['forw','backw'].each do |direction|
|
||||
a = Location.new @origin[0]+(1+WAY_SPACING*i)*@zoom, @origin[1]
|
||||
b = Location.new @origin[0]+(3+WAY_SPACING*i)*@zoom, @origin[1]
|
||||
r = {}
|
||||
r[:response] = request_route (direction=='forw' ? [a,b] : [b,a]), [], @query_params
|
||||
r[:query] = @query
|
||||
r[:json] = JSON.parse(r[:response].body)
|
||||
|
||||
r[:status] = (route_status r[:response]) == 200 ? 'x' : nil
|
||||
if r[:status] then
|
||||
r[:route] = way_list r[:json]['route_instructions']
|
||||
|
||||
if r[:route]=="w#{i}"
|
||||
r[:time] = r[:json]['route_summary']['total_time']
|
||||
r[:distance] = r[:json]['route_summary']['total_distance']
|
||||
r[:speed] = r[:time]>0 ? (3.6*r[:distance]/r[:time]).to_i : nil
|
||||
else
|
||||
# if we hit the wrong way segment, we assume it's
|
||||
# because the one we tested was not unroutable
|
||||
r[:status] = nil
|
||||
end
|
||||
end
|
||||
result[direction] = r
|
||||
end
|
||||
|
||||
# check if forw and backw returned the same values
|
||||
result['bothw'] = {}
|
||||
[:status,:time,:distance,:speed].each do |key|
|
||||
if result['forw'][key] == result['backw'][key]
|
||||
result['bothw'][key] = result['forw'][key]
|
||||
else
|
||||
result['bothw'][key] = 'diff'
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
Then /^routability should be$/ do |table|
|
||||
build_ways_from_table table
|
||||
reprocess
|
||||
actual = []
|
||||
if table.headers&["forw","backw","bothw"] == []
|
||||
raise "*** routability tabel must contain either 'forw', 'backw' or 'bothw' column"
|
||||
end
|
||||
OSRMLoader.load(self,"#{contracted_file}.osrm") do
|
||||
table.hashes.each_with_index do |row,i|
|
||||
output_row = row.dup
|
||||
attempts = []
|
||||
result = test_routability_row i
|
||||
directions = ['forw','backw','bothw']
|
||||
(directions & table.headers).each do |direction|
|
||||
want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts
|
||||
case want
|
||||
when '', 'x'
|
||||
output_row[direction] = result[direction][:status] ? result[direction][:status].to_s : ''
|
||||
when /^\d+s/
|
||||
output_row[direction] = result[direction][:time] ? "#{result[direction][:time]}s" : ''
|
||||
when /^\d+ km\/h/
|
||||
output_row[direction] = result[direction][:speed] ? "#{result[direction][:speed]} km/h" : ''
|
||||
else
|
||||
raise "*** Unknown expectation format: #{want}"
|
||||
end
|
||||
|
||||
if FuzzyMatch.match output_row[direction], want
|
||||
output_row[direction] = row[direction]
|
||||
end
|
||||
end
|
||||
|
||||
if output_row != row
|
||||
log_fail row,output_row,result
|
||||
end
|
||||
actual << output_row
|
||||
end
|
||||
end
|
||||
table.diff! actual
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
var d3 = require('d3-queue');
|
||||
|
||||
module.exports = function () {
|
||||
this.When(/^I route I should get$/, this.WhenIRouteIShouldGet);
|
||||
|
||||
// This is used to route 100 times; timeout for entire step is therefore set to 100 * STRESS_TIMEOUT
|
||||
this.When(/^I route (\d+) times I should get$/, { timeout: 30000 }, (n, table, callback) => {
|
||||
var q = d3.queue(1);
|
||||
|
||||
for (var i=0; i<n; i++) {
|
||||
q.defer(this.WhenIRouteIShouldGet, table);
|
||||
}
|
||||
|
||||
q.awaitAll(callback);
|
||||
});
|
||||
};
|
||||
@@ -1,165 +0,0 @@
|
||||
When /^I route I should get$/ do |table|
|
||||
reprocess
|
||||
actual = []
|
||||
OSRMLoader.load(self,"#{contracted_file}.osrm") do
|
||||
table.hashes.each_with_index do |row,ri|
|
||||
if row['request']
|
||||
got = {'request' => row['request'] }
|
||||
response = request_url row['request']
|
||||
else
|
||||
default_params = @query_params
|
||||
user_params = []
|
||||
got = {}
|
||||
row.each_pair do |k,v|
|
||||
if k =~ /param:(.*)/
|
||||
if v=='(nil)'
|
||||
user_params << [$1, nil]
|
||||
elsif v!=nil
|
||||
user_params << [$1, v]
|
||||
end
|
||||
got[k]=v
|
||||
end
|
||||
end
|
||||
params = overwrite_params default_params, user_params
|
||||
waypoints = []
|
||||
bearings = []
|
||||
if row['bearings']
|
||||
got['bearings'] = row['bearings']
|
||||
bearings = row['bearings'].split(' ').compact
|
||||
end
|
||||
if row['from'] and row['to']
|
||||
node = find_node_by_name(row['from'])
|
||||
raise "*** unknown from-node '#{row['from']}" unless node
|
||||
waypoints << node
|
||||
|
||||
node = find_node_by_name(row['to'])
|
||||
raise "*** unknown to-node '#{row['to']}" unless node
|
||||
waypoints << node
|
||||
|
||||
got = got.merge({'from' => row['from'], 'to' => row['to'] })
|
||||
response = request_route waypoints, bearings, params
|
||||
elsif row['waypoints']
|
||||
row['waypoints'].split(',').each do |n|
|
||||
node = find_node_by_name(n.strip)
|
||||
raise "*** unknown waypoint node '#{n.strip}" unless node
|
||||
waypoints << node
|
||||
end
|
||||
got = got.merge({'waypoints' => row['waypoints'] })
|
||||
response = request_route waypoints, bearings, params
|
||||
else
|
||||
raise "*** no waypoints"
|
||||
end
|
||||
end
|
||||
|
||||
if response.body.empty? == false
|
||||
json = JSON.parse response.body
|
||||
end
|
||||
|
||||
if response.body.empty? == false
|
||||
if json['status'] == 200
|
||||
instructions = way_list json['route_instructions']
|
||||
bearings = bearing_list json['route_instructions']
|
||||
compasses = compass_list json['route_instructions']
|
||||
turns = turn_list json['route_instructions']
|
||||
modes = mode_list json['route_instructions']
|
||||
times = time_list json['route_instructions']
|
||||
distances = distance_list json['route_instructions']
|
||||
end
|
||||
end
|
||||
|
||||
if table.headers.include? 'status'
|
||||
got['status'] = json['status'].to_s
|
||||
end
|
||||
if table.headers.include? 'message'
|
||||
got['message'] = json['status_message']
|
||||
end
|
||||
if table.headers.include? '#' # comment column
|
||||
got['#'] = row['#'] # copy value so it always match
|
||||
end
|
||||
|
||||
if table.headers.include? 'start'
|
||||
got['start'] = instructions ? json['route_summary']['start_point'] : nil
|
||||
end
|
||||
if table.headers.include? 'end'
|
||||
got['end'] = instructions ? json['route_summary']['end_point'] : nil
|
||||
end
|
||||
if table.headers.include? 'geometry'
|
||||
got['geometry'] = json['route_geometry']
|
||||
end
|
||||
if table.headers.include? 'route'
|
||||
got['route'] = (instructions || '').strip
|
||||
if table.headers.include?('alternative')
|
||||
got['alternative'] =
|
||||
if json['found_alternative']
|
||||
way_list json['alternative_instructions'].first
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
if table.headers.include?('distance')
|
||||
if row['distance']!=''
|
||||
raise "*** Distance must be specied in meters. (ex: 250m)" unless row['distance'] =~ /\d+m/
|
||||
end
|
||||
got['distance'] = instructions ? "#{json['route_summary']['total_distance'].to_s}m" : ''
|
||||
end
|
||||
if table.headers.include?('time')
|
||||
raise "*** Time must be specied in seconds. (ex: 60s)" unless row['time'] =~ /\d+s/
|
||||
got['time'] = instructions ? "#{json['route_summary']['total_time'].to_s}s" : ''
|
||||
end
|
||||
if table.headers.include?('speed')
|
||||
if row['speed'] != '' && instructions
|
||||
raise "*** Speed must be specied in km/h. (ex: 50 km/h)" unless row['speed'] =~ /\d+ km\/h/
|
||||
time = json['route_summary']['total_time']
|
||||
distance = json['route_summary']['total_distance']
|
||||
speed = time>0 ? (3.6*distance/time).round : nil
|
||||
got['speed'] = "#{speed} km/h"
|
||||
else
|
||||
got['speed'] = ''
|
||||
end
|
||||
end
|
||||
if table.headers.include? 'bearing'
|
||||
got['bearing'] = instructions ? bearings : ''
|
||||
end
|
||||
if table.headers.include? 'compass'
|
||||
got['compass'] = instructions ? compasses : ''
|
||||
end
|
||||
if table.headers.include? 'turns'
|
||||
got['turns'] = instructions ? turns : ''
|
||||
end
|
||||
if table.headers.include? 'modes'
|
||||
got['modes'] = instructions ? modes : ''
|
||||
end
|
||||
if table.headers.include? 'times'
|
||||
got['times'] = instructions ? times : ''
|
||||
end
|
||||
if table.headers.include? 'distances'
|
||||
got['distances'] = instructions ? distances : ''
|
||||
end
|
||||
end
|
||||
|
||||
ok = true
|
||||
row.keys.each do |key|
|
||||
if FuzzyMatch.match got[key], row[key]
|
||||
got[key] = row[key]
|
||||
else
|
||||
ok = false
|
||||
end
|
||||
end
|
||||
|
||||
unless ok
|
||||
log_fail row,got, { 'route' => {:query => @query, :response => response} }
|
||||
end
|
||||
|
||||
actual << got
|
||||
end
|
||||
end
|
||||
table.diff! actual
|
||||
end
|
||||
|
||||
When /^I route (\d+) times I should get$/ do |n,table|
|
||||
ok = true
|
||||
n.to_i.times do
|
||||
ok = false unless step "I route I should get", table
|
||||
end
|
||||
ok
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
var assert = require('assert');
|
||||
|
||||
module.exports = function () {
|
||||
this.Then(/^I should get a valid timestamp/, (callback) => {
|
||||
this.ShouldGetAResponse();
|
||||
this.ShouldBeValidJSON((err) => {
|
||||
this.ShouldBeWellFormed();
|
||||
assert.equal(typeof this.json.timestamp, 'string');
|
||||
assert.equal(this.json.timestamp, '2000-01-01T00:00:00Z');
|
||||
callback(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
Then /^I should get a valid timestamp/ do
|
||||
step "I should get a response"
|
||||
step "response should be valid JSON"
|
||||
step "response should be well-formed"
|
||||
expect(@json['timestamp'].class).to eq(String)
|
||||
expect(@json['timestamp']).to eq("2000-01-01T00:00:00Z")
|
||||
end
|
||||
@@ -0,0 +1,141 @@
|
||||
var util = require('util');
|
||||
|
||||
module.exports = function () {
|
||||
this.When(/^I plan a trip I should get$/, (table, callback) => {
|
||||
var got;
|
||||
|
||||
this.reprocessAndLoadData(() => {
|
||||
var testRow = (row, ri, cb) => {
|
||||
var afterRequest = (err, res) => {
|
||||
if (err) return cb(err);
|
||||
var headers = new Set(table.raw()[0]);
|
||||
|
||||
for (var k in row) {
|
||||
var match = k.match(/param:(.*)/);
|
||||
if (match) {
|
||||
if (row[k] === '(nil)') {
|
||||
params[match[1]] = null;
|
||||
} else if (row[k]) {
|
||||
params[match[1]] = [row[k]];
|
||||
}
|
||||
|
||||
got[k] = row[k];
|
||||
}
|
||||
}
|
||||
|
||||
var json;
|
||||
if (res.body.length) {
|
||||
json = JSON.parse(res.body);
|
||||
}
|
||||
|
||||
if (headers.has('status')) {
|
||||
got.status = json.status.toString();
|
||||
}
|
||||
|
||||
if (headers.has('message')) {
|
||||
got.message = json.status_message;
|
||||
}
|
||||
|
||||
if (headers.has('#')) {
|
||||
// comment column
|
||||
got['#'] = row['#'];
|
||||
}
|
||||
|
||||
var subTrips;
|
||||
if (res.statusCode === 200) {
|
||||
if (headers.has('trips')) {
|
||||
subTrips = json.trips.filter(t => !!t).map(t => t.legs).map(tl => Array.prototype.concat.apply([], tl.map((sl, i) => {
|
||||
var toAdd = [];
|
||||
if (i === 0) toAdd.push(sl.steps[0].maneuver.location);
|
||||
toAdd.push(sl.steps[sl.steps.length-1].maneuver.location);
|
||||
return toAdd;
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
var ok = true,
|
||||
encodedResult = '',
|
||||
extendedTarget = '';
|
||||
|
||||
row.trips.split(',').forEach((sub, si) => {
|
||||
if (si >= subTrips.length) {
|
||||
ok = false;
|
||||
} else {
|
||||
ok = false;
|
||||
// TODO: Check all rotations of the round trip
|
||||
for (var ni=0; ni<sub.length; ni++) {
|
||||
var node = this.findNodeByName(sub[ni]),
|
||||
outNode = subTrips[si][ni];
|
||||
if (this.FuzzyMatch.matchLocation(outNode, node)) {
|
||||
encodedResult += sub[ni];
|
||||
extendedTarget += sub[ni];
|
||||
ok = true;
|
||||
} else {
|
||||
encodedResult += util.format('? [%s,%s]', outNode[0], outNode[1]);
|
||||
extendedTarget += util.format('%s [%d,%d]', sub[ni], node.lat, node.lon);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (ok) {
|
||||
got.trips = row.trips;
|
||||
got.via_points = row.via_points;
|
||||
} else {
|
||||
got.trips = encodedResult;
|
||||
got.trips = extendedTarget;
|
||||
this.logFail(row, got, { trip: { query: this.query, response: res }});
|
||||
}
|
||||
|
||||
ok = true;
|
||||
|
||||
for (var key in row) {
|
||||
if (this.FuzzyMatch.match(got[key], row[key])) {
|
||||
got[key] = row[key];
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
this.logFail(row, got, { trip: { query: this.query, response: res }});
|
||||
}
|
||||
|
||||
cb(null, got);
|
||||
};
|
||||
|
||||
if (row.request) {
|
||||
got.request = row.request;
|
||||
this.requestUrl(row.request, afterRequest);
|
||||
} else {
|
||||
var params = this.queryParams,
|
||||
waypoints = [];
|
||||
if (row.from && row.to) {
|
||||
var fromNode = this.findNodeByName(row.from);
|
||||
if (!fromNode) throw new Error(util.format('*** unknown from-node "%s"', row.from));
|
||||
waypoints.push(fromNode);
|
||||
|
||||
var toNode = this.findNodeByName(row.to);
|
||||
if (!toNode) throw new Error(util.format('*** unknown to-node "%s"', row.to));
|
||||
waypoints.push(toNode);
|
||||
|
||||
got = { from: row.from, to: row.to };
|
||||
this.requestTrip(waypoints, params, afterRequest);
|
||||
} else if (row.waypoints) {
|
||||
row.waypoints.split(',').forEach((n) => {
|
||||
var node = this.findNodeByName(n);
|
||||
if (!node) throw new Error(util.format('*** unknown waypoint node "%s"', n.trim()));
|
||||
waypoints.push(node);
|
||||
});
|
||||
got = { waypoints: row.waypoints };
|
||||
this.requestTrip(waypoints, params, afterRequest);
|
||||
} else {
|
||||
throw new Error('*** no waypoints');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.processRowsAndDiff(table, testRow, callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,121 +0,0 @@
|
||||
When /^I plan a trip I should get$/ do |table|
|
||||
reprocess
|
||||
actual = []
|
||||
OSRMLoader.load(self,"#{contracted_file}.osrm") do
|
||||
table.hashes.each_with_index do |row,ri|
|
||||
if row['request']
|
||||
got = {'request' => row['request'] }
|
||||
response = request_url row['request']
|
||||
else
|
||||
params = @query_params
|
||||
waypoints = []
|
||||
if row['from'] and row['to']
|
||||
node = find_node_by_name(row['from'])
|
||||
raise "*** unknown from-node '#{row['from']}" unless node
|
||||
waypoints << node
|
||||
|
||||
node = find_node_by_name(row['to'])
|
||||
raise "*** unknown to-node '#{row['to']}" unless node
|
||||
waypoints << node
|
||||
|
||||
got = {'from' => row['from'], 'to' => row['to'] }
|
||||
response = request_trip waypoints, params
|
||||
elsif row['waypoints']
|
||||
row['waypoints'].split(',').each do |n|
|
||||
node = find_node_by_name(n.strip)
|
||||
raise "*** unknown waypoint node '#{n.strip}" unless node
|
||||
waypoints << node
|
||||
end
|
||||
got = {'waypoints' => row['waypoints'] }
|
||||
response = request_trip waypoints, params
|
||||
else
|
||||
raise "*** no waypoints"
|
||||
end
|
||||
end
|
||||
|
||||
row.each_pair do |k,v|
|
||||
if k =~ /param:(.*)/
|
||||
if v=='(nil)'
|
||||
params[$1]=nil
|
||||
elsif v!=nil
|
||||
params[$1]=[v]
|
||||
end
|
||||
got[k]=v
|
||||
end
|
||||
end
|
||||
|
||||
if response.body.empty? == false
|
||||
json = JSON.parse response.body
|
||||
end
|
||||
|
||||
if table.headers.include? 'status'
|
||||
got['status'] = json['status'].to_s
|
||||
end
|
||||
if table.headers.include? 'message'
|
||||
got['message'] = json['status_message']
|
||||
end
|
||||
if table.headers.include? '#' # comment column
|
||||
got['#'] = row['#'] # copy value so it always match
|
||||
end
|
||||
|
||||
if response.code == "200"
|
||||
if table.headers.include? 'trips'
|
||||
sub_trips = json['trips'].compact.map { |sub| sub['via_points']}
|
||||
end
|
||||
end
|
||||
|
||||
######################
|
||||
ok = true
|
||||
encoded_result = ""
|
||||
extended_target = ""
|
||||
row['trips'].split(',').each_with_index do |sub, sub_idx|
|
||||
if sub_idx >= sub_trips.length
|
||||
ok = false
|
||||
break
|
||||
end
|
||||
|
||||
ok = false;
|
||||
#TODO: Check all rotations of the round trip
|
||||
sub.length.times do |node_idx|
|
||||
node = find_node_by_name(sub[node_idx])
|
||||
out_node = sub_trips[sub_idx][node_idx]
|
||||
if FuzzyMatch.match_location out_node, node
|
||||
encoded_result += sub[node_idx]
|
||||
extended_target += sub[node_idx]
|
||||
ok = true
|
||||
else
|
||||
encoded_result += "? [#{out_node[0]},#{out_node[1]}]"
|
||||
extended_target += "#{sub[node_idx]} [#{node.lat},#{node.lon}]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if ok
|
||||
got['trips'] = row['trips']
|
||||
got['via_points'] = row['via_points']
|
||||
else
|
||||
got['trips'] = encoded_result
|
||||
row['trips'] = extended_target
|
||||
log_fail row,got, { 'trip' => {:query => @query, :response => response} }
|
||||
end
|
||||
|
||||
|
||||
ok = true
|
||||
row.keys.each do |key|
|
||||
if FuzzyMatch.match got[key], row[key]
|
||||
got[key] = row[key]
|
||||
else
|
||||
ok = false
|
||||
end
|
||||
end
|
||||
|
||||
unless ok
|
||||
log_fail row,got, { 'trip' => {:query => @query, :response => response} }
|
||||
end
|
||||
|
||||
actual << got
|
||||
end
|
||||
end
|
||||
table.diff! actual
|
||||
end
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
'use strict';
|
||||
|
||||
var builder = require('xmlbuilder');
|
||||
|
||||
var ensureDecimal = (i) => {
|
||||
if (parseInt(i) === i) return i.toFixed(1);
|
||||
else return i;
|
||||
};
|
||||
|
||||
class DB {
|
||||
constructor () {
|
||||
this.nodes = new Array();
|
||||
this.ways = new Array();
|
||||
this.relations = new Array();
|
||||
}
|
||||
|
||||
addNode (node) {
|
||||
this.nodes.push(node);
|
||||
}
|
||||
|
||||
addWay (way) {
|
||||
this.ways.push(way);
|
||||
}
|
||||
|
||||
addRelation (relation) {
|
||||
this.relations.push(relation);
|
||||
}
|
||||
|
||||
clear () {
|
||||
this.nodes = [];
|
||||
this.ways = [];
|
||||
this.relations = [];
|
||||
}
|
||||
|
||||
toXML (callback) {
|
||||
var xml = builder.create('osm', {'encoding':'UTF-8'});
|
||||
xml.att('generator', 'osrm-test')
|
||||
.att('version', '0.6');
|
||||
|
||||
this.nodes.forEach((n) => {
|
||||
var node = xml.ele('node', {
|
||||
id: n.id,
|
||||
version: 1,
|
||||
uid: n.OSM_UID,
|
||||
user: n.OSM_USER,
|
||||
timestamp: n.OSM_TIMESTAMP,
|
||||
lon: ensureDecimal(n.lon),
|
||||
lat: ensureDecimal(n.lat)
|
||||
});
|
||||
|
||||
for (var k in n.tags) {
|
||||
node.ele('tag')
|
||||
.att('k', k)
|
||||
.att('v', n.tags[k]);
|
||||
}
|
||||
});
|
||||
|
||||
this.ways.forEach((w) => {
|
||||
var way = xml.ele('way', {
|
||||
id: w.id,
|
||||
version: 1,
|
||||
uid: w.OSM_UID,
|
||||
user: w.OSM_USER,
|
||||
timestamp: w.OSM_TIMESTAMP
|
||||
});
|
||||
|
||||
w.nodes.forEach((k) => {
|
||||
way.ele('nd')
|
||||
.att('ref', k.id);
|
||||
});
|
||||
|
||||
for (var k in w.tags) {
|
||||
way.ele('tag')
|
||||
.att('k', k)
|
||||
.att('v', w.tags[k]);
|
||||
}
|
||||
});
|
||||
|
||||
this.relations.forEach((r) => {
|
||||
var relation = xml.ele('relation', {
|
||||
id: r.id,
|
||||
user: r.OSM_USER,
|
||||
timestamp: r.OSM_TIMESTAMP,
|
||||
uid: r.OSM_UID
|
||||
});
|
||||
|
||||
r.members.forEach((m) => {
|
||||
relation.ele('member', {
|
||||
type: m.type,
|
||||
ref: m.id,
|
||||
role: m.role
|
||||
});
|
||||
});
|
||||
|
||||
for (var k in r.tags) {
|
||||
relation.ele('tag')
|
||||
.att('k', k)
|
||||
.att('v', r.tags[k]);
|
||||
}
|
||||
});
|
||||
|
||||
callback(xml.end({ pretty: true, indent: ' ' }));
|
||||
}
|
||||
}
|
||||
|
||||
class Node {
|
||||
constructor (id, OSM_USER, OSM_TIMESTAMP, OSM_UID, lon, lat, tags) {
|
||||
this.id = id;
|
||||
this.OSM_USER = OSM_USER;
|
||||
this.OSM_TIMESTAMP = OSM_TIMESTAMP;
|
||||
this.OSM_UID = OSM_UID;
|
||||
this.lon = lon;
|
||||
this.lat = lat;
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
addTag (k, v) {
|
||||
this.tags[k] = v;
|
||||
}
|
||||
}
|
||||
|
||||
class Way {
|
||||
constructor (id, OSM_USER, OSM_TIMESTAMP, OSM_UID) {
|
||||
this.id = id;
|
||||
this.OSM_USER = OSM_USER;
|
||||
this.OSM_TIMESTAMP = OSM_TIMESTAMP;
|
||||
this.OSM_UID = OSM_UID;
|
||||
this.tags = {};
|
||||
this.nodes = [];
|
||||
}
|
||||
|
||||
addNode (node) {
|
||||
this.nodes.push(node);
|
||||
}
|
||||
|
||||
setTags (tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
}
|
||||
|
||||
class Relation {
|
||||
constructor (id, OSM_USER, OSM_TIMESTAMP, OSM_UID) {
|
||||
this.id = id;
|
||||
this.OSM_USER = OSM_USER;
|
||||
this.OSM_TIMESTAMP = OSM_TIMESTAMP;
|
||||
this.OSM_UID = OSM_UID;
|
||||
this.members = [];
|
||||
this.tags = {};
|
||||
}
|
||||
|
||||
addMember (memberType, id, role) {
|
||||
this.members.push({type: memberType, id: id, role: role});
|
||||
}
|
||||
|
||||
addTag (k, v) {
|
||||
this.tags[k] = v;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
DB: DB,
|
||||
Node: Node,
|
||||
Way: Way,
|
||||
Relation: Relation
|
||||
};
|
||||
@@ -0,0 +1,115 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var util = require('util');
|
||||
var d3 = require('d3-queue');
|
||||
var OSM = require('./build_osm');
|
||||
var classes = require('./data_classes');
|
||||
|
||||
module.exports = function () {
|
||||
this.initializeOptions = (callback) => {
|
||||
this.profile = this.profile || this.DEFAULT_SPEEDPROFILE;
|
||||
|
||||
this.OSMDB = this.OSMDB || new OSM.DB();
|
||||
|
||||
this.nameNodeHash = this.nameNodeHash || {};
|
||||
|
||||
this.locationHash = this.locationHash || {};
|
||||
|
||||
this.nameWayHash = this.nameWayHash || {};
|
||||
|
||||
this.osmData = new classes.osmData(this);
|
||||
|
||||
this.STRESS_TIMEOUT = 300;
|
||||
|
||||
this.OSRMLoader = this._OSRMLoader();
|
||||
|
||||
this.PREPROCESS_LOG_FILE = path.resolve(this.TEST_FOLDER, 'preprocessing.log');
|
||||
|
||||
this.LOG_FILE = path.resolve(this.TEST_FOLDER, 'fail.log');
|
||||
|
||||
this.HOST = 'http://127.0.0.1:' + this.OSRM_PORT;
|
||||
|
||||
this.DESTINATION_REACHED = 15; // OSRM instruction code
|
||||
|
||||
this.shortcutsHash = this.shortcutsHash || {};
|
||||
|
||||
var hashLuaLib = (cb) => {
|
||||
fs.readdir(path.normalize(this.PROFILES_PATH + '/lib/'), (err, files) => {
|
||||
if (err) cb(err);
|
||||
var luaFiles = files.filter(f => !!f.match(/\.lua$/)).map(f => path.normalize(this.PROFILES_PATH + '/lib/' + f));
|
||||
this.hashOfFiles(luaFiles, hash => {
|
||||
this.luaLibHash = hash;
|
||||
cb();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var hashProfile = (cb) => {
|
||||
this.hashProfile((hash) => {
|
||||
this.profileHash = hash;
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
var hashExtract = (cb) => {
|
||||
this.hashOfFiles(util.format('%s/osrm-extract%s', this.BIN_PATH, this.EXE), (hash) => {
|
||||
this.binExtractHash = hash;
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
var hashContract = (cb) => {
|
||||
this.hashOfFiles(util.format('%s/osrm-contract%s', this.BIN_PATH, this.EXE), (hash) => {
|
||||
this.binContractHash = hash;
|
||||
this.fingerprintContract = this.hashString(this.binContractHash);
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
var hashRouted = (cb) => {
|
||||
this.hashOfFiles(util.format('%s/osrm-routed%s', this.BIN_PATH, this.EXE), (hash) => {
|
||||
this.binRoutedHash = hash;
|
||||
this.fingerprintRoute = this.hashString(this.binRoutedHash);
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
d3.queue()
|
||||
.defer(hashLuaLib)
|
||||
.defer(hashProfile)
|
||||
.defer(hashExtract)
|
||||
.defer(hashContract)
|
||||
.defer(hashRouted)
|
||||
.awaitAll(() => {
|
||||
this.fingerprintExtract = this.hashString([this.profileHash, this.luaLibHash, this.binExtractHash].join('-'));
|
||||
this.AfterConfiguration(() => {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.setProfileBasedHashes = () => {
|
||||
this.fingerprintExtract = this.hashString([this.profileHash, this.luaLibHash, this.binExtractHash].join('-'));
|
||||
this.fingerprintContract = this.hashString(this.binContractHash);
|
||||
};
|
||||
|
||||
this.setProfile = (profile, cb) => {
|
||||
var lastProfile = this.profile;
|
||||
if (profile !== lastProfile) {
|
||||
this.profile = profile;
|
||||
this.hashProfile((hash) => {
|
||||
this.profileHash = hash;
|
||||
this.setProfileBasedHashes();
|
||||
cb();
|
||||
});
|
||||
} else cb();
|
||||
};
|
||||
|
||||
this.setExtractArgs = (args) => {
|
||||
this.extractArgs = args;
|
||||
};
|
||||
|
||||
this.setContractArgs = (args) => {
|
||||
this.contractArgs = args;
|
||||
};
|
||||
};
|
||||
@@ -1,20 +0,0 @@
|
||||
def profile
|
||||
@profile ||= reset_profile
|
||||
end
|
||||
|
||||
def reset_profile
|
||||
@profile = nil
|
||||
set_profile DEFAULT_SPEEDPROFILE
|
||||
end
|
||||
|
||||
def set_profile profile
|
||||
@profile = profile
|
||||
end
|
||||
|
||||
def set_extract_args args
|
||||
@extract_args = args
|
||||
end
|
||||
|
||||
def set_contract_args args
|
||||
@contract_args = args
|
||||
end
|
||||
@@ -0,0 +1,340 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var util = require('util');
|
||||
var exec = require('child_process').exec;
|
||||
var d3 = require('d3-queue');
|
||||
|
||||
var OSM = require('./build_osm');
|
||||
var classes = require('./data_classes');
|
||||
|
||||
module.exports = function () {
|
||||
this.setGridSize = (meters) => {
|
||||
// the constant is calculated (with BigDecimal as: 1.0/(DEG_TO_RAD*EARTH_RADIUS_IN_METERS
|
||||
// see ApproximateDistance() in ExtractorStructs.h
|
||||
// it's only accurate when measuring along the equator, or going exactly north-south
|
||||
this.zoom = parseFloat(meters) * 0.8990679362704610899694577444566908445396483347536032203503E-5;
|
||||
};
|
||||
|
||||
this.setOrigin = (origin) => {
|
||||
this.origin = origin;
|
||||
};
|
||||
|
||||
this.buildWaysFromTable = (table, callback) => {
|
||||
// add one unconnected way for each row
|
||||
var buildRow = (row, ri, cb) => {
|
||||
// comments ported directly from ruby suite:
|
||||
// NOTE: currently osrm crashes when processing an isolated oneway with just 2 nodes, so we use 4 edges
|
||||
// this is related to the fact that a oneway dead-end street doesn't make a lot of sense
|
||||
|
||||
// if we stack ways on different x coordinates, routability tests get messed up, because osrm might pick a neighboring way if the one test can't be used.
|
||||
// instead we place all lines as a string on the same y coordinate. this prevents using neighboring ways.
|
||||
|
||||
// add some nodes
|
||||
|
||||
var makeFakeNode = (namePrefix, offset) => {
|
||||
return new OSM.Node(this.makeOSMId(), this.OSM_USER, this.OSM_TIMESTAMP,
|
||||
this.OSM_UID, this.origin[0]+(offset + this.WAY_SPACING * ri) * this.zoom,
|
||||
this.origin[1], {name: util.format('%s%d', namePrefix, ri)});
|
||||
};
|
||||
|
||||
var nodes = ['a','b','c','d','e'].map((l, i) => makeFakeNode(l, i));
|
||||
|
||||
nodes.forEach(node => { this.OSMDB.addNode(node); });
|
||||
|
||||
// ...with a way between them
|
||||
var way = new OSM.Way(this.makeOSMId(), this.OSM_USER, this.OSM_TIMESTAMP, this.OSM_UID);
|
||||
|
||||
nodes.forEach(node => { way.addNode(node); });
|
||||
|
||||
// remove tags that describe expected test result, reject empty tags
|
||||
var tags = {};
|
||||
for (var rkey in row) {
|
||||
if (!rkey.match(/^forw\b/) &&
|
||||
!rkey.match(/^backw\b/) &&
|
||||
!rkey.match(/^bothw\b/) &&
|
||||
row[rkey].length)
|
||||
tags[rkey] = row[rkey];
|
||||
}
|
||||
|
||||
var wayTags = { highway: 'primary' },
|
||||
nodeTags = {};
|
||||
|
||||
for (var key in tags) {
|
||||
var nodeMatch = key.match(/node\/(.*)/);
|
||||
if (nodeMatch) {
|
||||
if (tags[key] === '(nil)') {
|
||||
delete nodeTags[key];
|
||||
} else {
|
||||
nodeTags[nodeMatch[1]] = tags[key];
|
||||
}
|
||||
} else {
|
||||
if (tags[key] === '(nil)') {
|
||||
delete wayTags[key];
|
||||
} else {
|
||||
wayTags[key] = tags[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wayTags.name = util.format('w%d', ri);
|
||||
way.setTags(wayTags);
|
||||
this.OSMDB.addWay(way);
|
||||
|
||||
for (var k in nodeTags) {
|
||||
nodes[2].addTag(k, nodeTags[k]);
|
||||
}
|
||||
cb();
|
||||
};
|
||||
|
||||
var q = d3.queue();
|
||||
table.hashes().forEach((row, ri) => {
|
||||
q.defer(buildRow, row, ri);
|
||||
});
|
||||
|
||||
q.awaitAll(callback);
|
||||
};
|
||||
|
||||
this.ensureDecimal = (i) => {
|
||||
if (parseInt(i) === i) return i.toFixed(1);
|
||||
else return i;
|
||||
};
|
||||
|
||||
this.tableCoordToLonLat = (ci, ri) => {
|
||||
return [this.origin[0] + ci * this.zoom, this.origin[1] - ri * this.zoom].map(this.ensureDecimal);
|
||||
};
|
||||
|
||||
this.addOSMNode = (name, lon, lat, id) => {
|
||||
id = id || this.makeOSMId();
|
||||
var node = new OSM.Node(id, this.OSM_USER, this.OSM_TIMESTAMP, this.OSM_UID, lon, lat, {name: name});
|
||||
this.OSMDB.addNode(node);
|
||||
this.nameNodeHash[name] = node;
|
||||
};
|
||||
|
||||
this.addLocation = (name, lon, lat) => {
|
||||
this.locationHash[name] = new classes.Location(lon, lat);
|
||||
};
|
||||
|
||||
this.findNodeByName = (s) => {
|
||||
if (s.length !== 1) throw new Error(util.format('*** invalid node name "%s", must be single characters', s));
|
||||
if (!s.match(/[a-z0-9]/)) throw new Error(util.format('*** invalid node name "%s", must be alphanumeric', s));
|
||||
|
||||
var fromNode;
|
||||
if (s.match(/[a-z]/)) {
|
||||
fromNode = this.nameNodeHash[s.toString()];
|
||||
} else {
|
||||
fromNode = this.locationHash[s.toString()];
|
||||
}
|
||||
|
||||
return fromNode;
|
||||
};
|
||||
|
||||
this.findWayByName = (s) => {
|
||||
return this.nameWayHash[s.toString()] || this.nameWayHash[s.toString().split('').reverse().join('')];
|
||||
};
|
||||
|
||||
this.resetData = () => {
|
||||
this.resetOSM();
|
||||
};
|
||||
|
||||
this.makeOSMId = () => {
|
||||
this.osmID = this.osmID + 1;
|
||||
return this.osmID;
|
||||
};
|
||||
|
||||
this.resetOSM = () => {
|
||||
this.OSMDB.clear();
|
||||
this.osmData.reset();
|
||||
this.nameNodeHash = {};
|
||||
this.locationHash = {};
|
||||
this.nameWayHash = {};
|
||||
this.osmID = 0;
|
||||
};
|
||||
|
||||
this.writeOSM = (callback) => {
|
||||
fs.exists(this.DATA_FOLDER, (exists) => {
|
||||
var mkDirFn = exists ? (cb) => { cb(); } : fs.mkdir.bind(fs.mkdir, this.DATA_FOLDER);
|
||||
mkDirFn((err) => {
|
||||
if (err) return callback(err);
|
||||
var osmPath = path.resolve(this.DATA_FOLDER, util.format('%s.osm', this.osmData.osmFile));
|
||||
fs.exists(osmPath, (exists) => {
|
||||
if (!exists) fs.writeFile(osmPath, this.osmData.str, callback);
|
||||
else callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.isExtracted = (callback) => {
|
||||
fs.exists(util.format('%s.osrm', this.osmData.extractedFile), (core) => {
|
||||
if (!core) return callback(false);
|
||||
fs.exists(util.format('%s.osrm.names', this.osmData.extractedFile), (names) => {
|
||||
if (!names) return callback(false);
|
||||
fs.exists(util.format('%s.osrm.restrictions', this.osmData.extractedFile), (restrictions) => {
|
||||
return callback(restrictions);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.isContracted = (callback) => {
|
||||
fs.exists(util.format('%s.osrm.hsgr', this.osmData.contractedFile), callback);
|
||||
};
|
||||
|
||||
this.writeTimestamp = (callback) => {
|
||||
fs.writeFile(util.format('%s.osrm.timestamp', this.osmData.contractedFile), this.OSM_TIMESTAMP, callback);
|
||||
};
|
||||
|
||||
this.writeInputData = (callback) => {
|
||||
this.writeOSM((err) => {
|
||||
if (err) return callback(err);
|
||||
this.writeTimestamp(callback);
|
||||
});
|
||||
};
|
||||
|
||||
this.extractData = (callback) => {
|
||||
this.logPreprocessInfo();
|
||||
this.log(util.format('== Extracting %s.osm...', this.osmData.osmFile), 'preprocess');
|
||||
var cmd = util.format('%s%s/osrm-extract %s.osm %s --profile %s/%s.lua >>%s 2>&1',
|
||||
this.LOAD_LIBRARIES, this.BIN_PATH, this.osmData.osmFile, this.extractArgs || '', this.PROFILES_PATH, this.profile, this.PREPROCESS_LOG_FILE);
|
||||
this.log(cmd);
|
||||
process.chdir(this.TEST_FOLDER);
|
||||
exec(cmd, (err) => {
|
||||
if (err) {
|
||||
this.log(util.format('*** Exited with code %d', err.code), 'preprocess');
|
||||
process.chdir('../');
|
||||
return callback(this.ExtractError(err.code, util.format('osrm-extract exited with code %d', err.code)));
|
||||
}
|
||||
|
||||
var q = d3.queue();
|
||||
|
||||
var rename = (file, cb) => {
|
||||
this.log(util.format('Renaming %s.%s to %s.%s', this.osmData.osmFile, file, this.osmData.extractedFile, file), 'preprocess');
|
||||
fs.rename([this.osmData.osmFile, file].join('.'), [this.osmData.extractedFile, file].join('.'), (err) => {
|
||||
if (err) return cb(this.FileError(null, 'failed to rename data file after extracting'));
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
var renameIfExists = (file, cb) => {
|
||||
fs.stat([this.osmData.osmFile, file].join('.'), (doesNotExistErr, exists) => {
|
||||
if (exists) rename(file, cb);
|
||||
else cb();
|
||||
});
|
||||
};
|
||||
|
||||
['osrm','osrm.names','osrm.restrictions','osrm.ebg','osrm.enw','osrm.edges','osrm.fileIndex','osrm.geometry','osrm.nodes','osrm.ramIndex','osrm.properties'].forEach(file => {
|
||||
q.defer(rename, file);
|
||||
});
|
||||
|
||||
['osrm.edge_segment_lookup','osrm.edge_penalties'].forEach(file => {
|
||||
q.defer(renameIfExists, file);
|
||||
});
|
||||
|
||||
q.awaitAll((err) => {
|
||||
this.log('Finished extracting ' + this.osmData.extractedFile, 'preprocess');
|
||||
process.chdir('../');
|
||||
callback(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.contractData = (callback) => {
|
||||
this.logPreprocessInfo();
|
||||
this.log(util.format('== Contracting %s.osm...', this.osmData.extractedFile), 'preprocess');
|
||||
var cmd = util.format('%s%s/osrm-contract %s %s.osrm >>%s 2>&1',
|
||||
this.LOAD_LIBRARIES, this.BIN_PATH, this.contractArgs || '', this.osmData.extractedFile, this.PREPROCESS_LOG_FILE);
|
||||
this.log(cmd);
|
||||
process.chdir(this.TEST_FOLDER);
|
||||
exec(cmd, (err) => {
|
||||
if (err) {
|
||||
this.log(util.format('*** Exited with code %d', err.code), 'preprocess');
|
||||
process.chdir('../');
|
||||
return callback(this.ContractError(err.code, util.format('osrm-contract exited with code %d', err.code)));
|
||||
}
|
||||
|
||||
var rename = (file, cb) => {
|
||||
this.log(util.format('Renaming %s.%s to %s.%s', this.osmData.extractedFile, file, this.osmData.contractedFile, file), 'preprocess');
|
||||
fs.rename([this.osmData.extractedFile, file].join('.'), [this.osmData.contractedFile, file].join('.'), (err) => {
|
||||
if (err) return cb(this.FileError(null, 'failed to rename data file after contracting.'));
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
var copy = (file, cb) => {
|
||||
this.log(util.format('Copying %s.%s to %s.%s', this.osmData.extractedFile, file, this.osmData.contractedFile, file), 'preprocess');
|
||||
fs.createReadStream([this.osmData.extractedFile, file].join('.'))
|
||||
.pipe(fs.createWriteStream([this.osmData.contractedFile, file].join('.'))
|
||||
.on('finish', cb)
|
||||
)
|
||||
.on('error', () => {
|
||||
return cb(this.FileError(null, 'failed to copy data after contracting.'));
|
||||
});
|
||||
};
|
||||
|
||||
var q = d3.queue();
|
||||
|
||||
['osrm.hsgr','osrm.fileIndex','osrm.geometry','osrm.nodes','osrm.ramIndex','osrm.core','osrm.edges','osrm.datasource_indexes','osrm.datasource_names','osrm.level'].forEach((file) => {
|
||||
q.defer(rename, file);
|
||||
});
|
||||
|
||||
['osrm.names','osrm.restrictions','osrm.properties','osrm'].forEach((file) => {
|
||||
q.defer(copy, file);
|
||||
});
|
||||
|
||||
q.awaitAll((err) => {
|
||||
this.log('Finished contracting ' + this.osmData.contractedFile, 'preprocess');
|
||||
process.chdir('../');
|
||||
callback(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var noop = (cb) => cb();
|
||||
|
||||
this.reprocess = (callback) => {
|
||||
this.writeAndExtract((e) => {
|
||||
if (e) return callback(e);
|
||||
this.isContracted((isContracted) => {
|
||||
var contractFn = isContracted ? noop : this.contractData;
|
||||
if (isContracted) this.log('Already contracted ' + this.osmData.contractedFile, 'preprocess');
|
||||
contractFn((e) => {
|
||||
if (e) return callback(e);
|
||||
this.logPreprocessDone();
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.writeAndExtract = (callback) => {
|
||||
this.osmData.populate(() => {
|
||||
this.writeInputData((e) => {
|
||||
if (e) return callback(e);
|
||||
this.isExtracted((isExtracted) => {
|
||||
var extractFn = isExtracted ? noop : this.extractData;
|
||||
if (isExtracted) this.log('Already extracted ' + this.osmData.extractedFile, 'preprocess');
|
||||
extractFn((e) => {
|
||||
callback(e);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.reprocessAndLoadData = (callback) => {
|
||||
this.reprocess(() => {
|
||||
this.OSRMLoader.load(util.format('%s.osrm', this.osmData.contractedFile), callback);
|
||||
});
|
||||
};
|
||||
|
||||
this.processRowsAndDiff = (table, fn, callback) => {
|
||||
var q = d3.queue(1);
|
||||
|
||||
table.hashes().forEach((row, i) => { q.defer(fn, row, i); });
|
||||
|
||||
q.awaitAll((err, actual) => {
|
||||
if (err) return callback(err);
|
||||
this.diffTables(table, actual, {}, callback);
|
||||
});
|
||||
};
|
||||
};
|
||||
@@ -1,321 +0,0 @@
|
||||
require 'OSM/objects' #osmlib gem
|
||||
require 'OSM/Database'
|
||||
require 'builder'
|
||||
require 'fileutils'
|
||||
|
||||
class Location
|
||||
attr_accessor :lon,:lat
|
||||
|
||||
def initialize lon,lat
|
||||
@lat = lat
|
||||
@lon = lon
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def set_input_format format
|
||||
raise '*** Input format must be eiter "osm" or "pbf"' unless ['pbf','osm'].include? format.to_s
|
||||
@input_format = format.to_s
|
||||
end
|
||||
|
||||
def input_format
|
||||
@input_format || DEFAULT_INPUT_FORMAT
|
||||
end
|
||||
|
||||
def sanitized_scenario_title
|
||||
@sanitized_scenario_title ||= @scenario_title.to_s.gsub /[^0-9A-Za-z.\-]/, '_'
|
||||
end
|
||||
|
||||
def set_grid_size meters
|
||||
#the constant is calculated (with BigDecimal as: 1.0/(DEG_TO_RAD*EARTH_RADIUS_IN_METERS
|
||||
#see ApproximateDistance() in ExtractorStructs.h
|
||||
#it's only accurate when measuring along the equator, or going exactly north-south
|
||||
@zoom = meters.to_f*0.8990679362704610899694577444566908445396483347536032203503E-5
|
||||
end
|
||||
|
||||
def set_origin origin
|
||||
@origin = origin
|
||||
end
|
||||
|
||||
def build_ways_from_table table
|
||||
#add one unconnected way for each row
|
||||
table.hashes.each_with_index do |row,ri|
|
||||
#NOTE:
|
||||
#currently osrm crashes when processing an isolated oneway with just 2 nodes, so we use 4 edges
|
||||
#this is relatated to the fact that a oneway dead-end street doesn't make a lot of sense
|
||||
|
||||
#if we stack ways on different x coordinates, routability tests get messed up, because osrm might pick a neighboring way if the one test can't be used.
|
||||
#instead we place all lines as a string on the same y coordinate. this prevents using neightboring ways.
|
||||
|
||||
#a few nodes...
|
||||
node1 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, @origin[0]+(0+WAY_SPACING*ri)*@zoom, @origin[1]
|
||||
node2 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, @origin[0]+(1+WAY_SPACING*ri)*@zoom, @origin[1]
|
||||
node3 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, @origin[0]+(2+WAY_SPACING*ri)*@zoom, @origin[1]
|
||||
node4 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, @origin[0]+(3+WAY_SPACING*ri)*@zoom, @origin[1]
|
||||
node5 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, @origin[0]+(4+WAY_SPACING*ri)*@zoom, @origin[1]
|
||||
node1.uid = OSM_UID
|
||||
node2.uid = OSM_UID
|
||||
node3.uid = OSM_UID
|
||||
node4.uid = OSM_UID
|
||||
node5.uid = OSM_UID
|
||||
node1 << { :name => "a#{ri}" }
|
||||
node2 << { :name => "b#{ri}" }
|
||||
node3 << { :name => "c#{ri}" }
|
||||
node4 << { :name => "d#{ri}" }
|
||||
node5 << { :name => "e#{ri}" }
|
||||
|
||||
osm_db << node1
|
||||
osm_db << node2
|
||||
osm_db << node3
|
||||
osm_db << node4
|
||||
osm_db << node5
|
||||
|
||||
#...with a way between them
|
||||
way = OSM::Way.new make_osm_id, OSM_USER, OSM_TIMESTAMP
|
||||
way.uid = OSM_UID
|
||||
way << node1
|
||||
way << node2
|
||||
way << node3
|
||||
way << node4
|
||||
way << node5
|
||||
|
||||
tags = row.dup
|
||||
|
||||
# remove tags that describe expected test result
|
||||
tags.reject! do |k,v|
|
||||
k =~ /^forw\b/ ||
|
||||
k =~ /^backw\b/ ||
|
||||
k =~ /^bothw\b/
|
||||
end
|
||||
|
||||
##remove empty tags
|
||||
tags.reject! { |k,v| v=='' }
|
||||
|
||||
# sort tag keys in the form of 'node/....'
|
||||
way_tags = { 'highway' => 'primary' }
|
||||
|
||||
node_tags = {}
|
||||
tags.each_pair do |k,v|
|
||||
if k =~ /node\/(.*)/
|
||||
if v=='(nil)'
|
||||
node_tags.delete k
|
||||
else
|
||||
node_tags[$1] = v
|
||||
end
|
||||
else
|
||||
if v=='(nil)'
|
||||
way_tags.delete k
|
||||
else
|
||||
way_tags[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
way_tags['name'] = "w#{ri}"
|
||||
way << way_tags
|
||||
node3 << node_tags
|
||||
|
||||
osm_db << way
|
||||
end
|
||||
end
|
||||
|
||||
def table_coord_to_lonlat ci,ri
|
||||
[@origin[0]+ci*@zoom, @origin[1]-ri*@zoom]
|
||||
end
|
||||
|
||||
def add_osm_node name,lon,lat,id
|
||||
id = make_osm_id if id == nil
|
||||
node = OSM::Node.new id, OSM_USER, OSM_TIMESTAMP, lon, lat
|
||||
node << { :name => name }
|
||||
node.uid = OSM_UID
|
||||
osm_db << node
|
||||
name_node_hash[name] = node
|
||||
end
|
||||
|
||||
def add_location name,lon,lat
|
||||
location_hash[name] = Location.new(lon,lat)
|
||||
end
|
||||
|
||||
def find_node_by_name s
|
||||
raise "***invalid node name '#{s}', must be single characters" unless s.size == 1
|
||||
raise "*** invalid node name '#{s}', must be alphanumeric" unless s.match /[a-z0-9]/
|
||||
if s.match /[a-z]/
|
||||
from_node = name_node_hash[ s.to_s ]
|
||||
else
|
||||
from_node = location_hash[ s.to_s ]
|
||||
end
|
||||
end
|
||||
|
||||
def find_way_by_name s
|
||||
name_way_hash[s.to_s] || name_way_hash[s.to_s.reverse]
|
||||
end
|
||||
|
||||
def reset_data
|
||||
Dir.chdir TEST_FOLDER do
|
||||
#clear_log
|
||||
#clear_data_files
|
||||
end
|
||||
reset_profile
|
||||
reset_osm
|
||||
@fingerprint_osm = nil
|
||||
@fingerprint_extract = nil
|
||||
@fingerprint_prepare = nil
|
||||
@fingerprint_route = nil
|
||||
end
|
||||
|
||||
def make_osm_id
|
||||
@osm_id = @osm_id+1
|
||||
end
|
||||
|
||||
def reset_osm
|
||||
osm_db.clear
|
||||
name_node_hash.clear
|
||||
location_hash.clear
|
||||
name_way_hash.clear
|
||||
@osm_str = nil
|
||||
@osm_hash = nil
|
||||
@osm_id = 0
|
||||
end
|
||||
|
||||
def clear_data_files
|
||||
File.delete *Dir.glob("#{DATA_FOLDER}/test.*")
|
||||
end
|
||||
|
||||
def clear_log
|
||||
File.delete *Dir.glob("*.log")
|
||||
end
|
||||
|
||||
def osm_db
|
||||
@osm_db ||= OSM::Database.new
|
||||
end
|
||||
|
||||
def name_node_hash
|
||||
@name_node_hash ||= {}
|
||||
end
|
||||
|
||||
def location_hash
|
||||
@location_hash ||= {}
|
||||
end
|
||||
|
||||
def name_way_hash
|
||||
@name_way_hash ||= {}
|
||||
end
|
||||
|
||||
def osm_str
|
||||
return @osm_str if @osm_str
|
||||
@osm_str = ''
|
||||
doc = Builder::XmlMarkup.new :indent => 2, :target => @osm_str
|
||||
doc.instruct!
|
||||
osm_db.to_xml doc, OSM_GENERATOR
|
||||
@osm_str
|
||||
end
|
||||
|
||||
def osm_file
|
||||
@osm_file ||= "#{DATA_FOLDER}/#{fingerprint_osm}"
|
||||
end
|
||||
|
||||
def extracted_file
|
||||
@extracted_file ||= "#{osm_file}_#{fingerprint_extract}"
|
||||
end
|
||||
|
||||
def contracted_file
|
||||
@contracted_file ||= "#{osm_file}_#{fingerprint_extract}_#{fingerprint_prepare}"
|
||||
end
|
||||
|
||||
def write_osm
|
||||
Dir.mkdir DATA_FOLDER unless File.exist? DATA_FOLDER
|
||||
unless File.exist?("#{osm_file}.osm")
|
||||
File.open( "#{osm_file}.osm", 'w') {|f| f.write(osm_str) }
|
||||
end
|
||||
end
|
||||
|
||||
def extracted?
|
||||
Dir.chdir TEST_FOLDER do
|
||||
File.exist?("#{extracted_file}.osrm") &&
|
||||
File.exist?("#{extracted_file}.osrm.names") &&
|
||||
File.exist?("#{extracted_file}.osrm.restrictions")
|
||||
end
|
||||
end
|
||||
|
||||
def contracted?
|
||||
Dir.chdir TEST_FOLDER do
|
||||
File.exist?("#{contracted_file}.osrm.hsgr")
|
||||
end
|
||||
end
|
||||
|
||||
def write_timestamp
|
||||
File.open( "#{contracted_file}.osrm.timestamp", 'w') {|f| f.write(OSM_TIMESTAMP) }
|
||||
end
|
||||
|
||||
def write_input_data
|
||||
Dir.chdir TEST_FOLDER do
|
||||
write_osm
|
||||
write_timestamp
|
||||
end
|
||||
end
|
||||
|
||||
def extract_data
|
||||
Dir.chdir TEST_FOLDER do
|
||||
log_preprocess_info
|
||||
log "== Extracting #{osm_file}.osm...", :preprocess
|
||||
log "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-extract #{osm_file}.osm #{@extract_args} --profile #{PROFILES_PATH}/#{@profile}.lua >>#{PREPROCESS_LOG_FILE} 2>&1"
|
||||
unless system "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-extract #{osm_file}.osm #{@extract_args} --profile #{PROFILES_PATH}/#{@profile}.lua >>#{PREPROCESS_LOG_FILE} 2>&1"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise ExtractError.new $?.exitstatus, "osrm-extract exited with code #{$?.exitstatus}."
|
||||
end
|
||||
begin
|
||||
["osrm","osrm.names","osrm.restrictions","osrm.ebg","osrm.enw","osrm.edges","osrm.fileIndex","osrm.geometry","osrm.nodes","osrm.ramIndex"].each do |file|
|
||||
log "Renaming #{osm_file}.#{file} to #{extracted_file}.#{file}", :preprocess
|
||||
File.rename "#{osm_file}.#{file}", "#{extracted_file}.#{file}"
|
||||
end
|
||||
rescue Exception => e
|
||||
raise FileError.new nil, "failed to rename data file after extracting."
|
||||
end
|
||||
begin
|
||||
["osrm.edge_segment_lookup","osrm.edge_penalties"].each do |file|
|
||||
if File.exists?("#{osm_file}.#{file}")
|
||||
log "Renaming #{osm_file}.#{file} to #{extracted_file}.#{file}", :preprocess
|
||||
File.rename "#{osm_file}.#{file}", "#{extracted_file}.#{file}"
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
raise FileError.new nil, "failed to rename data file after extracting."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def prepare_data
|
||||
Dir.chdir TEST_FOLDER do
|
||||
log_preprocess_info
|
||||
log "== Preparing #{extracted_file}.osm...", :preprocess
|
||||
log "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-contract #{@contract_args} #{extracted_file}.osrm >>#{PREPROCESS_LOG_FILE} 2>&1"
|
||||
unless system "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-contract #{@contract_args} #{extracted_file}.osrm >>#{PREPROCESS_LOG_FILE} 2>&1"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise PrepareError.new $?.exitstatus, "osrm-contract exited with code #{$?.exitstatus}."
|
||||
end
|
||||
begin
|
||||
["osrm.hsgr","osrm.fileIndex","osrm.geometry","osrm.nodes","osrm.ramIndex","osrm.core","osrm.edges"].each do |file|
|
||||
log "Renaming #{extracted_file}.#{file} to #{contracted_file}.#{file}", :preprocess
|
||||
File.rename "#{extracted_file}.#{file}", "#{contracted_file}.#{file}"
|
||||
end
|
||||
rescue Exception => e
|
||||
raise FileError.new nil, "failed to rename data file after preparing."
|
||||
end
|
||||
begin
|
||||
["osrm.names","osrm.restrictions","osrm"].each do |file|
|
||||
log "Copying #{extracted_file}.#{file} to #{contracted_file}.#{file}", :preprocess
|
||||
FileUtils.cp "#{extracted_file}.#{file}", "#{contracted_file}.#{file}"
|
||||
end
|
||||
rescue Exception => e
|
||||
raise FileError.new nil, "failed to copy data file after preparing."
|
||||
end
|
||||
log '', :preprocess
|
||||
end
|
||||
end
|
||||
|
||||
def reprocess
|
||||
write_input_data
|
||||
extract_data unless extracted?
|
||||
prepare_data unless contracted?
|
||||
log_preprocess_done
|
||||
end
|
||||
@@ -0,0 +1,85 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var path = require('path');
|
||||
|
||||
module.exports = {
|
||||
Location: class {
|
||||
constructor (lon, lat) {
|
||||
this.lon = lon;
|
||||
this.lat = lat;
|
||||
}
|
||||
},
|
||||
|
||||
osmData: class {
|
||||
constructor (scope) {
|
||||
this.scope = scope;
|
||||
this.str = null;
|
||||
this.hash = null;
|
||||
this.fingerprintOSM = null;
|
||||
this.osmFile = null;
|
||||
this.extractedFile = null;
|
||||
this.contractedFile = null;
|
||||
}
|
||||
|
||||
populate (callback) {
|
||||
this.scope.OSMDB.toXML((str) => {
|
||||
this.str = str;
|
||||
|
||||
this.hash = this.scope.hashString(str);
|
||||
this.fingerprintOSM = this.scope.hashString(this.hash);
|
||||
|
||||
this.osmFile = path.resolve(this.scope.DATA_FOLDER, this.fingerprintOSM);
|
||||
|
||||
this.extractedFile = path.resolve([this.osmFile, this.scope.fingerprintExtract].join('_'));
|
||||
this.contractedFile = path.resolve([this.osmFile, this.scope.fingerprintExtract, this.scope.fingerprintContract].join('_'));
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
reset () {
|
||||
this.str = null;
|
||||
this.hash = null;
|
||||
this.fingerprintOSM = null;
|
||||
this.osmFile = null;
|
||||
this.extractedFile = null;
|
||||
this.contractedFile = null;
|
||||
}
|
||||
},
|
||||
|
||||
FuzzyMatch: class {
|
||||
match (got, want) {
|
||||
var matchPercent = want.match(/(.*)\s+~(.+)%$/),
|
||||
matchAbs = want.match(/(.*)\s+\+\-(.+)$/),
|
||||
matchRe = want.match(/^\/(.*)\/$/);
|
||||
|
||||
if (got === want) {
|
||||
return true;
|
||||
} else if (matchPercent) { // percentage range: 100 ~ 5%
|
||||
var target = parseFloat(matchPercent[1]),
|
||||
percentage = parseFloat(matchPercent[2]);
|
||||
if (target === 0) {
|
||||
return true;
|
||||
} else {
|
||||
var ratio = Math.abs(1 - parseFloat(got) / target);
|
||||
return 100 * ratio < percentage;
|
||||
}
|
||||
} else if (matchAbs) { // absolute range: 100 +-5
|
||||
var margin = parseFloat(matchAbs[2]),
|
||||
fromR = parseFloat(matchAbs[1]) - margin,
|
||||
toR = parseFloat(matchAbs[1]) + margin;
|
||||
return parseFloat(got) >= fromR && parseFloat(got) <= toR;
|
||||
} else if (matchRe) { // regex: /a,b,.*/
|
||||
return got.match(matchRe[1]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
matchLocation (got, want) {
|
||||
return this.match(got[0], util.format('%d ~0.0025%', want.lon)) &&
|
||||
this.match(got[1], util.format('%d ~0.0025%', want.lat));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,125 @@
|
||||
var path = require('path');
|
||||
var util = require('util');
|
||||
var fs = require('fs');
|
||||
var exec = require('child_process').exec;
|
||||
var d3 = require('d3-queue');
|
||||
|
||||
module.exports = function () {
|
||||
this.initializeEnv = (callback) => {
|
||||
this.DEFAULT_PORT = 5000;
|
||||
this.DEFAULT_TIMEOUT = 2000;
|
||||
this.setDefaultTimeout(this.DEFAULT_TIMEOUT);
|
||||
this.ROOT_FOLDER = process.cwd();
|
||||
this.OSM_USER = 'osrm';
|
||||
this.OSM_GENERATOR = 'osrm-test';
|
||||
this.OSM_UID = 1;
|
||||
this.TEST_FOLDER = path.resolve(this.ROOT_FOLDER, 'test');
|
||||
this.DATA_FOLDER = path.resolve(this.TEST_FOLDER, 'cache');
|
||||
this.OSM_TIMESTAMP = '2000-01-01T00:00:00Z';
|
||||
this.DEFAULT_SPEEDPROFILE = 'bicycle';
|
||||
this.WAY_SPACING = 100;
|
||||
this.DEFAULT_GRID_SIZE = 100; // meters
|
||||
this.PROFILES_PATH = path.resolve(this.ROOT_FOLDER, 'profiles');
|
||||
this.FIXTURES_PATH = path.resolve(this.ROOT_FOLDER, 'unit_tests/fixtures');
|
||||
this.BIN_PATH = path.resolve(this.ROOT_FOLDER, 'build');
|
||||
this.DEFAULT_INPUT_FORMAT = 'osm';
|
||||
this.DEFAULT_ORIGIN = [1,1];
|
||||
this.LAUNCH_TIMEOUT = 1000;
|
||||
this.SHUTDOWN_TIMEOUT = 10000;
|
||||
this.DEFAULT_LOAD_METHOD = 'datastore';
|
||||
this.OSRM_ROUTED_LOG_FILE = path.resolve(this.TEST_FOLDER, 'osrm-routed.log');
|
||||
this.ERROR_LOG_FILE = path.resolve(this.TEST_FOLDER, 'error.log');
|
||||
|
||||
// OS X shim to ensure shared libraries from custom locations can be loaded
|
||||
// This is needed in OS X >= 10.11 because DYLD_LIBRARY_PATH is blocked
|
||||
// https://forums.developer.apple.com/thread/9233
|
||||
this.LOAD_LIBRARIES = process.env.OSRM_SHARED_LIBRARY_PATH ? util.format('DYLD_LIBRARY_PATH=%s ', process.env.OSRM_SHARED_LIBRARY_PATH) : '';
|
||||
|
||||
// TODO make sure this works on win
|
||||
if (process.platform.match(/indows.*/)) {
|
||||
this.TERMSIGNAL = 9;
|
||||
this.EXE = '.exe';
|
||||
this.QQ = '"';
|
||||
} else {
|
||||
this.TERMSIGNAL = 'SIGTERM';
|
||||
this.EXE = '';
|
||||
this.QQ = '';
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(util.format('Node Version', process.version));
|
||||
if (parseInt(process.version.match(/v(\d)/)[1]) < 4) throw new Error('*** PLease upgrade to Node 4.+ to run OSRM cucumber tests');
|
||||
|
||||
if (process.env.OSRM_PORT) {
|
||||
this.OSRM_PORT = parseInt(process.env.OSRM_PORT);
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(util.format('Port set to %d', this.OSRM_PORT));
|
||||
} else {
|
||||
this.OSRM_PORT = this.DEFAULT_PORT;
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(util.format('Using default port %d', this.OSRM_PORT));
|
||||
}
|
||||
|
||||
if (process.env.OSRM_TIMEOUT) {
|
||||
this.OSRM_TIMEOUT = parseInt(process.env.OSRM_TIMEOUT);
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(util.format('Timeout set to %d', this.OSRM_TIMEOUT));
|
||||
} else {
|
||||
this.OSRM_TIMEOUT = this.DEFAULT_TIMEOUT;
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(util.format('Using default timeout %d', this.OSRM_TIMEOUT));
|
||||
}
|
||||
|
||||
fs.exists(this.TEST_FOLDER, (exists) => {
|
||||
if (!exists) throw new Error(util.format('*** Test folder %s doesn\'t exist.', this.TEST_FOLDER));
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
this.verifyOSRMIsNotRunning = () => {
|
||||
if (this.OSRMLoader.up()) {
|
||||
throw new Error('*** osrm-routed is already running.');
|
||||
}
|
||||
};
|
||||
|
||||
this.verifyExistenceOfBinaries = (callback) => {
|
||||
var verify = (bin, cb) => {
|
||||
var binPath = path.resolve(util.format('%s/%s%s', this.BIN_PATH, bin, this.EXE));
|
||||
fs.exists(binPath, (exists) => {
|
||||
if (!exists) throw new Error(util.format('%s is missing. Build failed?', binPath));
|
||||
var helpPath = util.format('%s%s --help > /dev/null 2>&1', this.LOAD_LIBRARIES, binPath);
|
||||
exec(helpPath, (err) => {
|
||||
if (err) {
|
||||
this.log(util.format('*** Exited with code %d', err.code), 'preprocess');
|
||||
throw new Error(util.format('*** %s exited with code %d', helpPath, err.code));
|
||||
}
|
||||
cb();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var q = d3.queue();
|
||||
['osrm-extract', 'osrm-contract', 'osrm-routed'].forEach(bin => { q.defer(verify, bin); });
|
||||
q.awaitAll(() => {
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
this.AfterConfiguration = (callback) => {
|
||||
this.clearLogFiles(() => {
|
||||
this.verifyOSRMIsNotRunning();
|
||||
this.verifyExistenceOfBinaries(() => {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
process.on('exit', () => {
|
||||
if (this.OSRMLoader.loader) this.OSRMLoader.shutdown(() => {});
|
||||
});
|
||||
|
||||
process.on('SIGINT', () => {
|
||||
process.exit(2);
|
||||
// TODO need to handle for windows??
|
||||
});
|
||||
};
|
||||
@@ -1,111 +0,0 @@
|
||||
require 'rspec/expectations'
|
||||
|
||||
|
||||
DEFAULT_PORT = 5000
|
||||
DEFAULT_TIMEOUT = 2
|
||||
ROOT_FOLDER = Dir.pwd
|
||||
OSM_USER = 'osrm'
|
||||
OSM_GENERATOR = 'osrm-test'
|
||||
OSM_UID = 1
|
||||
TEST_FOLDER = File.join ROOT_FOLDER, 'test'
|
||||
DATA_FOLDER = 'cache'
|
||||
OSM_TIMESTAMP = '2000-01-01T00:00:00Z'
|
||||
DEFAULT_SPEEDPROFILE = 'bicycle'
|
||||
WAY_SPACING = 100
|
||||
DEFAULT_GRID_SIZE = 100 #meters
|
||||
PROFILES_PATH = File.join ROOT_FOLDER, 'profiles'
|
||||
FIXTURES_PATH = File.join ROOT_FOLDER, 'unit_tests/fixtures'
|
||||
BIN_PATH = File.join ROOT_FOLDER, 'build'
|
||||
DEFAULT_INPUT_FORMAT = 'osm'
|
||||
DEFAULT_ORIGIN = [1,1]
|
||||
LAUNCH_TIMEOUT = 1
|
||||
SHUTDOWN_TIMEOUT = 10
|
||||
DEFAULT_LOAD_METHOD = 'datastore'
|
||||
OSRM_ROUTED_LOG_FILE = 'osrm-routed.log'
|
||||
|
||||
# OS X shim to ensure shared libraries from custom locations can be loaded
|
||||
# This is needed in OS X >= 10.11 because DYLD_LIBRARY_PATH is blocked
|
||||
# https://forums.developer.apple.com/thread/9233
|
||||
if ENV['OSRM_SHARED_LIBRARY_PATH']
|
||||
LOAD_LIBRARIES="DYLD_LIBRARY_PATH=#{ENV['OSRM_SHARED_LIBRARY_PATH']} "
|
||||
else
|
||||
LOAD_LIBRARIES=""
|
||||
end
|
||||
|
||||
if ENV['OS']=~/Windows.*/ then
|
||||
TERMSIGNAL=9
|
||||
else
|
||||
TERMSIGNAL='TERM'
|
||||
end
|
||||
|
||||
|
||||
def log_time_and_run cmd
|
||||
log_time cmd
|
||||
`#{cmd}`
|
||||
end
|
||||
|
||||
def log_time cmd
|
||||
puts "[#{Time.now.strftime('%Y-%m-%d %H:%M:%S:%L')}] #{cmd}"
|
||||
end
|
||||
|
||||
|
||||
puts "Ruby version #{RUBY_VERSION}"
|
||||
unless RUBY_VERSION.to_f >= 1.9
|
||||
raise "*** Please upgrade to Ruby 1.9.x to run the OSRM cucumber tests"
|
||||
end
|
||||
|
||||
if ENV["OSRM_PORT"]
|
||||
OSRM_PORT = ENV["OSRM_PORT"].to_i
|
||||
puts "Port set to #{OSRM_PORT}"
|
||||
else
|
||||
OSRM_PORT = DEFAULT_PORT
|
||||
puts "Using default port #{OSRM_PORT}"
|
||||
end
|
||||
|
||||
if ENV["OSRM_TIMEOUT"]
|
||||
OSRM_TIMEOUT = ENV["OSRM_TIMEOUT"].to_i
|
||||
puts "Timeout set to #{OSRM_TIMEOUT}"
|
||||
else
|
||||
OSRM_TIMEOUT = DEFAULT_TIMEOUT
|
||||
puts "Using default timeout #{OSRM_TIMEOUT}"
|
||||
end
|
||||
|
||||
unless File.exists? TEST_FOLDER
|
||||
raise "*** Test folder #{TEST_FOLDER} doesn't exist."
|
||||
end
|
||||
|
||||
def verify_osrm_is_not_running
|
||||
if OSRMLoader::OSRMBaseLoader.new.osrm_up?
|
||||
raise "*** osrm-routed is already running."
|
||||
end
|
||||
end
|
||||
|
||||
def verify_existance_of_binaries
|
||||
["osrm-extract", "osrm-contract", "osrm-routed"].each do |bin|
|
||||
unless File.exists? "#{BIN_PATH}/#{bin}#{EXE}"
|
||||
raise "*** #{BIN_PATH}/#{bin}#{EXE} is missing. Build failed?"
|
||||
end
|
||||
unless system "#{LOAD_LIBRARIES}#{BIN_PATH}/#{bin}#{EXE} --help > /dev/null 2>&1"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise "*** #{LOAD_LIBRARIES}#{BIN_PATH}/#{bin}#{EXE} --help exited with code #{$?.exitstatus}."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if ENV['OS']=~/Windows.*/ then
|
||||
EXE='.exe'
|
||||
QQ='"'
|
||||
else
|
||||
EXE=''
|
||||
QQ=''
|
||||
end
|
||||
|
||||
AfterConfiguration do |config|
|
||||
clear_log_files
|
||||
verify_osrm_is_not_running
|
||||
verify_existance_of_binaries
|
||||
end
|
||||
|
||||
at_exit do
|
||||
OSRMLoader::OSRMBaseLoader.new.shutdown
|
||||
end
|
||||
@@ -0,0 +1,132 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var chalk = require('chalk');
|
||||
|
||||
var OSRMError = class extends Error {
|
||||
constructor (process, code, msg, log, lines) {
|
||||
super(msg);
|
||||
this.process = process;
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.lines = lines;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
extract (callback) {
|
||||
this.logTail(this.log, this.lines, callback);
|
||||
}
|
||||
|
||||
// toString (callback) {
|
||||
// this.extract((tail) => {
|
||||
// callback(util.format('*** %s\nLast %s from %s:\n%s\n', this.msg, this.lines, this.log, tail));
|
||||
// });
|
||||
// }
|
||||
|
||||
logTail (logPath, n, callback) {
|
||||
var expanded = path.resolve(this.TEST_FOLDER, logPath);
|
||||
fs.exists(expanded, (exists) => {
|
||||
if (exists) {
|
||||
fs.readFile(expanded, (err, data) => {
|
||||
var lines = data.toString().trim().split('\n');
|
||||
callback(lines
|
||||
.slice(lines.length - n)
|
||||
.map(line => util.format(' %s', line))
|
||||
.join('\n'));
|
||||
});
|
||||
} else {
|
||||
callback(util.format('File %s does not exist!', expanded));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var unescapeStr = (str) => str.replace(/\\\|/g, '\|').replace(/\\\\/g, '\\');
|
||||
|
||||
module.exports = {
|
||||
OSRMError: OSRMError,
|
||||
|
||||
FileError: class extends OSRMError {
|
||||
constructor (logFile, code, msg) {
|
||||
super ('fileutil', code, msg, logFile, 5);
|
||||
}
|
||||
},
|
||||
|
||||
LaunchError: class extends OSRMError {
|
||||
constructor (logFile, launchProcess, code, msg) {
|
||||
super (launchProcess, code, msg, logFile, 5);
|
||||
}
|
||||
},
|
||||
|
||||
ExtractError: class extends OSRMError {
|
||||
constructor (logFile, code, msg) {
|
||||
super('osrm-extract', code, msg, logFile, 3);
|
||||
}
|
||||
},
|
||||
|
||||
ContractError: class extends OSRMError {
|
||||
constructor (logFile, code, msg) {
|
||||
super('osrm-contract', code, msg, logFile, 3);
|
||||
}
|
||||
},
|
||||
|
||||
RoutedError: class extends OSRMError {
|
||||
constructor (logFile, msg) {
|
||||
super('osrm-routed', null, msg, logFile, 3);
|
||||
}
|
||||
},
|
||||
|
||||
TableDiffError: class extends Error {
|
||||
constructor (expected, actual) {
|
||||
super();
|
||||
this.headers = expected.raw()[0];
|
||||
this.expected = expected.hashes();
|
||||
this.actual = actual;
|
||||
this.diff = [];
|
||||
this.hasErrors = false;
|
||||
|
||||
var good = 0, bad = 0;
|
||||
|
||||
this.expected.forEach((row, i) => {
|
||||
var rowError = false;
|
||||
|
||||
for (var j in row) {
|
||||
if (unescapeStr(row[j]) != actual[i][j]) {
|
||||
rowError = true;
|
||||
this.hasErrors = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rowError) {
|
||||
bad++;
|
||||
this.diff.push(Object.assign({}, row, {c_status: 'undefined'}));
|
||||
this.diff.push(Object.assign({}, actual[i], {c_status: 'comment'}));
|
||||
} else {
|
||||
good++;
|
||||
this.diff.push(row);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
get string () {
|
||||
if (!this.hasErrors) return null;
|
||||
|
||||
var s = ['Tables were not identical:'];
|
||||
s.push(this.headers.map(key => ' ' + key).join(' | '));
|
||||
this.diff.forEach((row) => {
|
||||
var rowString = '| ';
|
||||
this.headers.forEach((header) => {
|
||||
if (!row.c_status) rowString += chalk.green(' ' + row[header] + ' | ');
|
||||
else if (row.c_status === 'undefined') rowString += chalk.yellow('(-) ' + row[header] + ' | ');
|
||||
else rowString += chalk.red('(+) ' + row[header] + ' | ');
|
||||
});
|
||||
s.push(rowString);
|
||||
});
|
||||
|
||||
return s.join('\n') + '\nTODO this is a temp workaround waiting for https://github.com/cucumber/cucumber-js/issues/534';
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
var exceptions = require('./exception_classes');
|
||||
|
||||
module.exports = function () {
|
||||
this.OSRMError = exceptions.OSRMError,
|
||||
|
||||
this.FileError = (code, msg) => new (exceptions.FileError.bind(exceptions.FileError, this.PREPROCESS_LOG_FILE))(code, msg);
|
||||
|
||||
this.LaunchError = (code, launchProcess, msg) => new (exceptions.LaunchError.bind(exceptions.LaunchError, this.ERROR_LOG_FILE))(code, launchProcess, msg);
|
||||
|
||||
this.ExtractError = (code, msg) => new (exceptions.ExtractError.bind(exceptions.ExtractError, this.PREPROCESS_LOG_FILE))(code, msg);
|
||||
|
||||
this.ContractError = (code, msg) => new (exceptions.ContractError.bind(exceptions.ContractError, this.PREPROCESS_LOG_FILE))(code, msg);
|
||||
|
||||
this.RoutedError = (msg) => new (exceptions.RoutedError.bind(exceptions.RoutedError, this.OSRM_ROUTED_LOG_FILE))(msg);
|
||||
};
|
||||
@@ -1,56 +0,0 @@
|
||||
|
||||
class OSRMError < StandardError
|
||||
attr_accessor :msg, :code, :process
|
||||
|
||||
def initialize process, code, msg, log, lines
|
||||
@process = process
|
||||
@code = code
|
||||
@msg = msg
|
||||
@lines = lines
|
||||
@log = log
|
||||
@extract = log_tail @log, @lines
|
||||
end
|
||||
|
||||
def to_s
|
||||
"*** #{@msg}\nLast #{@lines} lines from #{@log}:\n#{@extract}\n"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def log_tail path, n
|
||||
Dir.chdir TEST_FOLDER do
|
||||
expanded = File.expand_path path
|
||||
if File.exists? expanded
|
||||
File.open(expanded) do |f|
|
||||
return f.tail(n).map { |line| " #{line}" }.join "\n"
|
||||
end
|
||||
else
|
||||
return "File '#{expanded} does not exist!"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class FileError < OSRMError
|
||||
def initialize code, msg
|
||||
super 'fileutil', code, msg, PREPROCESS_LOG_FILE, 5
|
||||
end
|
||||
end
|
||||
|
||||
class ExtractError < OSRMError
|
||||
def initialize code, msg
|
||||
super 'osrm-extract', code, msg, PREPROCESS_LOG_FILE, 3
|
||||
end
|
||||
end
|
||||
|
||||
class PrepareError < OSRMError
|
||||
def initialize code, msg
|
||||
super 'osrm-contract', code, msg, PREPROCESS_LOG_FILE, 3
|
||||
end
|
||||
end
|
||||
|
||||
class RoutedError < OSRMError
|
||||
def initialize msg
|
||||
super 'osrm-routed', nil, msg, OSRM_ROUTED_LOG_FILE, 3
|
||||
end
|
||||
end
|
||||
@@ -1,34 +0,0 @@
|
||||
class File
|
||||
|
||||
# read last n lines of a file (trailing newlines are ignored)
|
||||
def tail(n)
|
||||
return [] if size==0
|
||||
buffer = 1024
|
||||
str = nil
|
||||
|
||||
if size>buffer
|
||||
chunks = []
|
||||
lines = 0
|
||||
idx = size
|
||||
begin
|
||||
idx -= buffer # rewind
|
||||
if idx<0
|
||||
buffer += idx # adjust last read to avoid negative index
|
||||
idx = 0
|
||||
end
|
||||
seek(idx)
|
||||
chunk = read(buffer)
|
||||
chunk.gsub!(/\n+\Z/,"") if chunks.empty? # strip newlines from end of file (first chunk)
|
||||
lines += chunk.count("\n") # update total lines found
|
||||
chunks.unshift chunk # prepend
|
||||
end while lines<(n) && idx>0 # stop when enough lines found or no more to read
|
||||
str = chunks.join('')
|
||||
else
|
||||
str = read(buffer)
|
||||
end
|
||||
|
||||
# return last n lines of str
|
||||
lines = str.split("\n")
|
||||
lines.size>=n ? lines[-n,n] : lines
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
var classes = require('./data_classes');
|
||||
|
||||
module.exports = function() {
|
||||
this.FuzzyMatch = new classes.FuzzyMatch();
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
class FuzzyMatch
|
||||
|
||||
def self.match got, want
|
||||
if got == want
|
||||
return true
|
||||
elsif want.match /(.*)\s+~(.+)%$/ #percentage range: 100 ~5%
|
||||
target = $1.to_f
|
||||
percentage = $2.to_f
|
||||
if target==0
|
||||
return true
|
||||
else
|
||||
ratio = (1-(got.to_f / target)).abs;
|
||||
return 100*ratio < percentage;
|
||||
end
|
||||
elsif want.match /(.*)\s+\+\-(.+)$/ #absolute range: 100 +-5
|
||||
margin = $2.to_f
|
||||
from = $1.to_f-margin
|
||||
to = $1.to_f+margin
|
||||
return got.to_f >= from && got.to_f <= to
|
||||
elsif want =~ /^\/(.*)\/$/ #regex: /a,b,.*/
|
||||
return got =~ /#{$1}/
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def self.match_location got, want
|
||||
match( got[0], "#{want.lat} ~0.0025%" ) &&
|
||||
match( got[1], "#{want.lon} ~0.0025%" )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,37 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var crypto = require('crypto');
|
||||
var d3 = require('d3-queue');
|
||||
|
||||
module.exports = function () {
|
||||
this.hashOfFiles = (paths, cb) => {
|
||||
paths = Array.isArray(paths) ? paths : [paths];
|
||||
var shasum = crypto.createHash('sha1');
|
||||
|
||||
var q = d3.queue(1);
|
||||
|
||||
var addFile = (path, cb) => {
|
||||
fs.readFile(path, (err, data) => {
|
||||
shasum.update(data);
|
||||
cb(err);
|
||||
});
|
||||
};
|
||||
|
||||
paths.forEach(path => { q.defer(addFile, path); });
|
||||
|
||||
q.awaitAll(err => {
|
||||
if (err) throw new Error('*** Error reading files:', err);
|
||||
cb(shasum.digest('hex'));
|
||||
});
|
||||
};
|
||||
|
||||
this.hashProfile = (cb) => {
|
||||
this.hashOfFiles(path.resolve(this.PROFILES_PATH, this.profile + '.lua'), cb);
|
||||
};
|
||||
|
||||
this.hashString = (str) => {
|
||||
return crypto.createHash('sha1').update(str).digest('hex');
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
@@ -1,63 +0,0 @@
|
||||
require 'digest/sha1'
|
||||
|
||||
bin_extract_hash = nil
|
||||
profile_hashes = nil
|
||||
|
||||
def hash_of_files paths
|
||||
paths = [paths] unless paths.is_a? Array
|
||||
hash = Digest::SHA1.new
|
||||
for path in paths do
|
||||
open(path,'rb') do |io|
|
||||
while !io.eof
|
||||
buf = io.readpartial 1024
|
||||
hash.update buf
|
||||
end
|
||||
end
|
||||
end
|
||||
return hash.hexdigest
|
||||
end
|
||||
|
||||
|
||||
def profile_hash
|
||||
profile_hashes ||= {}
|
||||
profile_hashes[@profile] ||= hash_of_files "#{PROFILES_PATH}/#{@profile}.lua"
|
||||
end
|
||||
|
||||
def osm_hash
|
||||
@osm_hash ||= Digest::SHA1.hexdigest osm_str
|
||||
end
|
||||
|
||||
def lua_lib_hash
|
||||
@lua_lib_hash ||= hash_of_files Dir.glob("../profiles/lib/*.lua")
|
||||
end
|
||||
|
||||
def bin_extract_hash
|
||||
@bin_extract_hash ||= hash_of_files "#{BIN_PATH}/osrm-extract#{EXE}"
|
||||
@bin_extract_hash
|
||||
end
|
||||
|
||||
def bin_prepare_hash
|
||||
@bin_prepare_hash ||= hash_of_files "#{BIN_PATH}/osrm-contract#{EXE}"
|
||||
end
|
||||
|
||||
def bin_routed_hash
|
||||
@bin_routed_hash ||= hash_of_files "#{BIN_PATH}/osrm-routed#{EXE}"
|
||||
end
|
||||
|
||||
# combine state of data, profile and binaries into a hashes that identifies
|
||||
# the exact test situation at different stages, so we can later skip steps when possible.
|
||||
def fingerprint_osm
|
||||
@fingerprint_osm ||= Digest::SHA1.hexdigest "#{osm_hash}"
|
||||
end
|
||||
|
||||
def fingerprint_extract
|
||||
@fingerprint_extract ||= Digest::SHA1.hexdigest "#{profile_hash}-#{lua_lib_hash}-#{bin_extract_hash}"
|
||||
end
|
||||
|
||||
def fingerprint_prepare
|
||||
@fingerprint_prepare ||= Digest::SHA1.hexdigest "#{bin_prepare_hash}"
|
||||
end
|
||||
|
||||
def fingerprint_route
|
||||
@fingerprint_route ||= Digest::SHA1.hexdigest "#{bin_routed_hash}"
|
||||
end
|
||||
@@ -0,0 +1,37 @@
|
||||
var util = require('util');
|
||||
|
||||
module.exports = function () {
|
||||
this.BeforeFeatures((features, callback) => {
|
||||
this.pid = null;
|
||||
this.initializeEnv(() => {
|
||||
this.initializeOptions(callback);
|
||||
});
|
||||
});
|
||||
|
||||
this.Before((scenario, callback) => {
|
||||
this.scenarioTitle = scenario.getName();
|
||||
|
||||
this.loadMethod = this.DEFAULT_LOAD_METHOD;
|
||||
this.queryParams = {};
|
||||
var d = new Date();
|
||||
this.scenarioTime = util.format('%d-%d-%dT%s:%s:%sZ', d.getFullYear(), d.getMonth()+1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds());
|
||||
this.resetData();
|
||||
this.hasLoggedPreprocessInfo = false;
|
||||
this.hasLoggedScenarioInfo = false;
|
||||
this.setGridSize(this.DEFAULT_GRID_SIZE);
|
||||
this.setOrigin(this.DEFAULT_ORIGIN);
|
||||
callback();
|
||||
});
|
||||
|
||||
this.After((scenario, callback) => {
|
||||
this.setExtractArgs('');
|
||||
this.setContractArgs('');
|
||||
if (this.loadMethod === 'directly' && !!this.OSRMLoader.loader) this.OSRMLoader.shutdown(callback);
|
||||
else callback();
|
||||
});
|
||||
|
||||
this.Around('@stress', (scenario, callback) => {
|
||||
// TODO implement stress timeout? Around support is being dropped in cucumber-js anyway
|
||||
callback();
|
||||
});
|
||||
};
|
||||
@@ -1,35 +0,0 @@
|
||||
|
||||
STRESS_TIMEOUT = 300
|
||||
|
||||
|
||||
Before do |scenario|
|
||||
|
||||
# fetch scenario and feature name, so we can use it in log files if needed
|
||||
case scenario
|
||||
when Cucumber::RunningTestCase::Scenario
|
||||
@feature_name = scenario.feature.name
|
||||
@scenario_title = scenario.name
|
||||
when Cucumber::RunningTestCase::ExampleRow
|
||||
@feature_name = scenario.scenario_outline.feature.name
|
||||
@scenario_title = scenario.scenario_outline.name
|
||||
end
|
||||
|
||||
@load_method = DEFAULT_LOAD_METHOD
|
||||
@query_params = []
|
||||
@scenario_time = Time.now.strftime("%Y-%m-%dT%H:%m:%SZ")
|
||||
reset_data
|
||||
@has_logged_preprocess_info = false
|
||||
@has_logged_scenario_info = false
|
||||
set_grid_size DEFAULT_GRID_SIZE
|
||||
set_origin DEFAULT_ORIGIN
|
||||
|
||||
end
|
||||
|
||||
Around('@stress') do |scenario, block|
|
||||
Timeout.timeout(STRESS_TIMEOUT) do
|
||||
block.call
|
||||
end
|
||||
end
|
||||
|
||||
After do
|
||||
end
|
||||
@@ -0,0 +1,51 @@
|
||||
var Timeout = require('node-timeout');
|
||||
var request = require('request');
|
||||
|
||||
module.exports = function () {
|
||||
this.paramsToString = (params) => {
|
||||
var paramString = '';
|
||||
if (params.coordinates !== undefined) {
|
||||
// FIXME this disables passing the output if its a default
|
||||
// Remove after #2173 is fixed.
|
||||
var outputString = (params.output && params.output !== 'json') ? ('.' + params.output) : '';
|
||||
paramString = params.coordinates.join(';') + outputString;
|
||||
delete params.coordinates;
|
||||
delete params.output;
|
||||
}
|
||||
if (Object.keys(params).length) {
|
||||
paramString += '?' + Object.keys(params).map(k => k + '=' + params[k]).join('&');
|
||||
}
|
||||
|
||||
return paramString;
|
||||
};
|
||||
|
||||
this.sendRequest = (baseUri, parameters, callback) => {
|
||||
var limit = Timeout(this.OSRM_TIMEOUT, { err: { statusCode: 408 } });
|
||||
|
||||
var runRequest = (cb) => {
|
||||
var params = this.paramsToString(parameters);
|
||||
this.query = baseUri + (params.length ? '/' + params : '');
|
||||
|
||||
request(this.query, (err, res, body) => {
|
||||
if (err && err.code === 'ECONNREFUSED') {
|
||||
throw new Error('*** osrm-routed is not running.');
|
||||
} else if (err && err.statusCode === 408) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
return cb(err, res, body);
|
||||
});
|
||||
};
|
||||
|
||||
runRequest(limit((err, res, body) => {
|
||||
if (err) {
|
||||
if (err.statusCode === 408)
|
||||
return callback(this.RoutedError('*** osrm-routed did not respond'));
|
||||
else if (err.code === 'ECONNREFUSED')
|
||||
return callback(this.RoutedError('*** osrm-routed is not running'));
|
||||
}
|
||||
//console.log(body+"\n");
|
||||
return callback(err, res, body);
|
||||
}));
|
||||
};
|
||||
};
|
||||
@@ -1,33 +0,0 @@
|
||||
require 'net/http'
|
||||
|
||||
# Converts an array [["param","val1"], ["param","val2"]] into param=val1¶m=val2
|
||||
def params_to_string params
|
||||
kv_pairs = params.map { |kv| kv[0].to_s + "=" + kv[1].to_s }
|
||||
url = kv_pairs.size > 0 ? kv_pairs.join("&") : ""
|
||||
return url
|
||||
end
|
||||
|
||||
def send_request base_uri, parameters
|
||||
Timeout.timeout(OSRM_TIMEOUT) do
|
||||
uri_string = base_uri
|
||||
params = params_to_string(parameters)
|
||||
if not params.eql? ""
|
||||
uri_string = uri_string + "?" + params
|
||||
end
|
||||
uri = URI.parse(uri_string)
|
||||
@query = uri.to_s
|
||||
if @http_method.eql? "POST"
|
||||
Net::HTTP.start(uri.hostname, uri.port) do |http|
|
||||
req = Net::HTTP::Post.new(uri.path)
|
||||
req.body = params_to_string parameters
|
||||
response = http.request(req)
|
||||
end
|
||||
else
|
||||
response = Net::HTTP.get_response uri
|
||||
end
|
||||
end
|
||||
rescue Errno::ECONNREFUSED => e
|
||||
raise "*** osrm-routed is not running."
|
||||
rescue Timeout::Error
|
||||
raise "*** osrm-routed did not respond."
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
var launchClasses = require('./launch_classes');
|
||||
|
||||
module.exports = function () {
|
||||
this._OSRMLoader = () => new (launchClasses._OSRMLoader.bind(launchClasses._OSRMLoader, this))();
|
||||
};
|
||||
@@ -1,137 +0,0 @@
|
||||
require 'socket'
|
||||
require 'open3'
|
||||
require 'json'
|
||||
|
||||
# Only one isntance of osrm-routed is ever launched, to avoid collisions.
|
||||
# The default is to keep osrm-routed running and load data with datastore.
|
||||
# however, osrm-routed it shut down and relaunched for each scenario thats
|
||||
# loads data directly.
|
||||
class OSRMLoader
|
||||
|
||||
class OSRMBaseLoader
|
||||
@@pid = nil
|
||||
|
||||
def launch
|
||||
Timeout.timeout(LAUNCH_TIMEOUT) do
|
||||
osrm_up
|
||||
wait_for_connection
|
||||
end
|
||||
rescue Timeout::Error
|
||||
raise RoutedError.new "Launching osrm-routed timed out."
|
||||
end
|
||||
|
||||
def shutdown
|
||||
Timeout.timeout(SHUTDOWN_TIMEOUT) do
|
||||
osrm_down
|
||||
end
|
||||
rescue Timeout::Error
|
||||
kill
|
||||
raise RoutedError.new "Shutting down osrm-routed timed out."
|
||||
end
|
||||
|
||||
def osrm_up?
|
||||
if @@pid
|
||||
begin
|
||||
if Process.waitpid(@@pid, Process::WNOHANG) then
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
rescue Errno::ESRCH, Errno::ECHILD
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def osrm_down
|
||||
if @@pid
|
||||
Process.kill TERMSIGNAL, @@pid
|
||||
wait_for_shutdown
|
||||
@@pid = nil
|
||||
end
|
||||
end
|
||||
|
||||
def kill
|
||||
if @@pid
|
||||
Process.kill 'KILL', @@pid
|
||||
end
|
||||
end
|
||||
|
||||
def wait_for_connection
|
||||
while true
|
||||
begin
|
||||
socket = TCPSocket.new('127.0.0.1', OSRM_PORT)
|
||||
return
|
||||
rescue Errno::ECONNREFUSED
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def wait_for_shutdown
|
||||
while osrm_up?
|
||||
sleep 0.01
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# looading data directly when lauching osrm-routed:
|
||||
# under this scheme, osmr-routed is launched and shutdown for each scenario,
|
||||
# and osrm-datastore is not used
|
||||
class OSRMDirectLoader < OSRMBaseLoader
|
||||
def load world, input_file, &block
|
||||
@world = world
|
||||
@input_file = input_file
|
||||
Dir.chdir TEST_FOLDER do
|
||||
shutdown
|
||||
launch
|
||||
yield
|
||||
shutdown
|
||||
end
|
||||
end
|
||||
|
||||
def osrm_up
|
||||
return if @@pid
|
||||
@@pid = Process.spawn("#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-routed #{@input_file} --port #{OSRM_PORT}",:out=>OSRM_ROUTED_LOG_FILE, :err=>OSRM_ROUTED_LOG_FILE)
|
||||
Process.detach(@@pid) # avoid zombie processes
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# looading data with osrm-datastore:
|
||||
# under this scheme, osmr-routed is launched once and kept running for all scenarios,
|
||||
# and osrm-datastore is used to load data for each scenario
|
||||
class OSRMDatastoreLoader < OSRMBaseLoader
|
||||
def load world, input_file, &block
|
||||
@world = world
|
||||
@input_file = input_file
|
||||
Dir.chdir TEST_FOLDER do
|
||||
load_data
|
||||
launch unless @@pid
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
def load_data
|
||||
run_bin "osrm-datastore", @input_file
|
||||
end
|
||||
|
||||
def osrm_up
|
||||
return if osrm_up?
|
||||
@@pid = Process.spawn("#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-routed --shared-memory=1 --port #{OSRM_PORT}",:out=>OSRM_ROUTED_LOG_FILE, :err=>OSRM_ROUTED_LOG_FILE)
|
||||
Process.detach(@@pid) # avoid zombie processes
|
||||
end
|
||||
end
|
||||
|
||||
def self.load world, input_file, &block
|
||||
method = world.instance_variable_get "@load_method"
|
||||
if method == 'datastore'
|
||||
OSRMDatastoreLoader.new.load world, input_file, &block
|
||||
elsif method == 'directly'
|
||||
OSRMDirectLoader.new.load world, input_file, &block
|
||||
else
|
||||
raise "*** Unknown load method '#{method}'"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,163 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var net = require('net');
|
||||
var spawn = require('child_process').spawn;
|
||||
var util = require('util');
|
||||
var Timeout = require('node-timeout');
|
||||
|
||||
var OSRMBaseLoader = class {
|
||||
constructor (scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
launch (callback) {
|
||||
var limit = Timeout(this.scope.LAUNCH_TIMEOUT, { err: this.scope.RoutedError('Launching osrm-routed timed out.') });
|
||||
|
||||
var runLaunch = (cb) => {
|
||||
this.osrmUp(() => {
|
||||
this.waitForConnection(cb);
|
||||
});
|
||||
};
|
||||
|
||||
runLaunch(limit((e) => { if (e) callback(e); else callback(); }));
|
||||
}
|
||||
|
||||
shutdown (callback) {
|
||||
var limit = Timeout(this.scope.SHUTDOWN_TIMEOUT, { err: this.scope.RoutedError('Shutting down osrm-routed timed out.')});
|
||||
|
||||
var runShutdown = (cb) => {
|
||||
this.osrmDown(cb);
|
||||
};
|
||||
|
||||
runShutdown(limit((e) => { if (e) callback(e); else callback(); }));
|
||||
}
|
||||
|
||||
osrmIsRunning () {
|
||||
return !!this.scope.pid && this.child && !this.child.killed;
|
||||
}
|
||||
|
||||
osrmDown (callback) {
|
||||
if (this.scope.pid) {
|
||||
process.kill(this.scope.pid, this.scope.TERMSIGNAL);
|
||||
this.waitForShutdown(callback);
|
||||
this.scope.pid = null;
|
||||
} else callback(true);
|
||||
}
|
||||
|
||||
waitForConnection (callback) {
|
||||
net.connect({
|
||||
port: this.scope.OSRM_PORT,
|
||||
host: '127.0.0.1'
|
||||
})
|
||||
.on('connect', () => {
|
||||
callback();
|
||||
})
|
||||
.on('error', (e) => {
|
||||
setTimeout(() => {
|
||||
callback(e);
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
waitForShutdown (callback) {
|
||||
var check = () => {
|
||||
if (!this.osrmIsRunning()) return callback();
|
||||
};
|
||||
setTimeout(check, 100);
|
||||
}
|
||||
};
|
||||
|
||||
var OSRMDirectLoader = class extends OSRMBaseLoader {
|
||||
constructor (scope) {
|
||||
super(scope);
|
||||
}
|
||||
|
||||
load (inputFile, callback) {
|
||||
this.inputFile = inputFile;
|
||||
this.shutdown(() => {
|
||||
this.launch(callback);
|
||||
});
|
||||
}
|
||||
|
||||
osrmUp (callback) {
|
||||
if (this.scope.pid) return callback();
|
||||
var writeToLog = (data) => {
|
||||
fs.appendFile(this.scope.OSRM_ROUTED_LOG_FILE, data, (err) => { if (err) throw err; });
|
||||
};
|
||||
|
||||
var child = spawn(util.format('%s%s/osrm-routed', this.scope.LOAD_LIBRARIES, this.scope.BIN_PATH), [this.inputFile, util.format('-p%d', this.scope.OSRM_PORT)]);
|
||||
this.scope.pid = child.pid;
|
||||
child.stdout.on('data', writeToLog);
|
||||
child.stderr.on('data', writeToLog);
|
||||
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
var OSRMDatastoreLoader = class extends OSRMBaseLoader {
|
||||
constructor (scope) {
|
||||
super(scope);
|
||||
}
|
||||
|
||||
load (inputFile, callback) {
|
||||
this.inputFile = inputFile;
|
||||
this.loadData((err) => {
|
||||
if (err) return callback(err);
|
||||
if (!this.scope.pid) return this.launch(callback);
|
||||
else callback();
|
||||
});
|
||||
}
|
||||
|
||||
loadData (callback) {
|
||||
this.scope.runBin('osrm-datastore', this.inputFile, (err) => {
|
||||
if (err) return callback(this.scope.LaunchError(this.exitCode, 'datastore', err));
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
osrmUp (callback) {
|
||||
if (this.scope.pid) return callback();
|
||||
var writeToLog = (data) => {
|
||||
fs.appendFile(this.scope.OSRM_ROUTED_LOG_FILE, data, (err) => { if (err) throw err; });
|
||||
};
|
||||
|
||||
var child = spawn(util.format('%s%s/osrm-routed', this.scope.LOAD_LIBRARIES, this.scope.BIN_PATH), ['--shared-memory=1', util.format('-p%d', this.scope.OSRM_PORT)]);
|
||||
this.child = child;
|
||||
this.scope.pid = child.pid;
|
||||
child.stdout.on('data', writeToLog);
|
||||
child.stderr.on('data', writeToLog);
|
||||
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
_OSRMLoader: class {
|
||||
constructor (scope) {
|
||||
this.scope = scope;
|
||||
this.loader = null;
|
||||
}
|
||||
|
||||
load (inputFile, callback) {
|
||||
var method = this.scope.loadMethod;
|
||||
if (method === 'datastore') {
|
||||
this.loader = new OSRMDatastoreLoader(this.scope);
|
||||
this.loader.load(inputFile, callback);
|
||||
} else if (method === 'directly') {
|
||||
this.loader = new OSRMDirectLoader(this.scope);
|
||||
this.loader.load(inputFile, callback);
|
||||
} else {
|
||||
throw new Error('*** Unknown load method ' + method);
|
||||
}
|
||||
}
|
||||
|
||||
shutdown (callback) {
|
||||
this.loader.shutdown(callback);
|
||||
}
|
||||
|
||||
up () {
|
||||
return this.loader ? this.loader.osrmIsRunning() : false;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,90 @@
|
||||
var fs = require('fs');
|
||||
|
||||
module.exports = function () {
|
||||
this.clearLogFiles = (callback) => {
|
||||
// emptying existing files, rather than deleting and writing new ones makes it
|
||||
// easier to use tail -f from the command line
|
||||
fs.writeFile(this.OSRM_ROUTED_LOG_FILE, '', err => {
|
||||
if (err) throw err;
|
||||
fs.writeFile(this.PREPROCESS_LOG_FILE, '', err => {
|
||||
if (err) throw err;
|
||||
fs.writeFile(this.LOG_FILE, '', err => {
|
||||
if (err) throw err;
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var log = this.log = (s, type) => {
|
||||
s = s || '';
|
||||
type = type || null;
|
||||
var file = type === 'preprocess' ? this.PREPROCESS_LOG_FILE : this.LOG_FILE;
|
||||
fs.appendFile(file, s + '\n', err => {
|
||||
if (err) throw err;
|
||||
});
|
||||
};
|
||||
|
||||
this.logScenarioFailInfo = () => {
|
||||
if (this.hasLoggedScenarioInfo) return;
|
||||
|
||||
log('=========================================');
|
||||
log('Failed scenario: ' + this.scenarioTitle);
|
||||
log('Time: ' + this.scenarioTime);
|
||||
log('Fingerprint osm stage: ' + this.osmData.fingerprintOSM);
|
||||
log('Fingerprint extract stage: ' + this.fingerprintExtract);
|
||||
log('Fingerprint contract stage: ' + this.fingerprintContract);
|
||||
log('Fingerprint route stage: ' + this.fingerprintRoute);
|
||||
log('Profile: ' + this.profile);
|
||||
log();
|
||||
log('```xml'); // so output can be posted directly to github comment fields
|
||||
log(this.osmData.str.trim());
|
||||
log('```');
|
||||
log();
|
||||
log();
|
||||
|
||||
this.hasLoggedScenarioInfo = true;
|
||||
};
|
||||
|
||||
this.logFail = (expected, got, attempts) => {
|
||||
this.logScenarioFailInfo();
|
||||
log('== ');
|
||||
log('Expected: ' + JSON.stringify(expected));
|
||||
log('Got: ' + JSON.stringify(got));
|
||||
log();
|
||||
['route','forw','backw'].forEach((direction) => {
|
||||
if (attempts[direction]) {
|
||||
log('Direction: ' + direction);
|
||||
log('Query: ' + attempts[direction].query);
|
||||
log('Response: ' + attempts[direction].response.body);
|
||||
log();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.logPreprocessInfo = () => {
|
||||
if (this.hasLoggedPreprocessInfo) return;
|
||||
log('=========================================', 'preprocess');
|
||||
log('Preprocessing data for scenario: ' + this.scenarioTitle, 'preprocess');
|
||||
log('Time: ' + this.scenarioTime, 'preprocess');
|
||||
log('', 'preprocess');
|
||||
log('== OSM data:', 'preprocess');
|
||||
log('```xml', 'preprocess'); // so output can be posted directly to github comment fields
|
||||
log(this.osmData.str, 'preprocess');
|
||||
log('```', 'preprocess');
|
||||
log('', 'preprocess');
|
||||
log('== Profile:', 'preprocess');
|
||||
log(this.profile, 'preprocess');
|
||||
log('', 'preprocess');
|
||||
this.hasLoggedPreprocessInfo = true;
|
||||
};
|
||||
|
||||
this.logPreprocess = (str) => {
|
||||
this.logPreprocessInfo();
|
||||
log(str, 'preprocess');
|
||||
};
|
||||
|
||||
this.logPreprocessDone = () => {
|
||||
log('Done with preprocessing at ' + new Date(), 'preprocess');
|
||||
};
|
||||
};
|
||||
@@ -1,88 +0,0 @@
|
||||
# logging
|
||||
|
||||
PREPROCESS_LOG_FILE = 'preprocessing.log'
|
||||
LOG_FILE = 'fail.log'
|
||||
|
||||
|
||||
def clear_log_files
|
||||
Dir.chdir TEST_FOLDER do
|
||||
# emptying existing files, rather than deleting and writing new ones makes it
|
||||
# easier to use tail -f from the command line
|
||||
`echo '' > #{OSRM_ROUTED_LOG_FILE}`
|
||||
`echo '' > #{PREPROCESS_LOG_FILE}`
|
||||
`echo '' > #{LOG_FILE}`
|
||||
end
|
||||
end
|
||||
|
||||
def log s='', type=nil
|
||||
if type == :preprocess
|
||||
file = PREPROCESS_LOG_FILE
|
||||
else
|
||||
file = LOG_FILE
|
||||
end
|
||||
File.open(file, 'a') {|f| f.write("#{s}\n") }
|
||||
end
|
||||
|
||||
|
||||
def log_scenario_fail_info
|
||||
return if @has_logged_scenario_info
|
||||
log "========================================="
|
||||
log "Failed scenario: #{@scenario_title}"
|
||||
log "Time: #{@scenario_time}"
|
||||
log "Fingerprint osm stage: #{@fingerprint_osm}"
|
||||
log "Fingerprint extract stage: #{@fingerprint_extract}"
|
||||
log "Fingerprint prepare stage: #{@fingerprint_prepare}"
|
||||
log "Fingerprint route stage: #{@fingerprint_route}"
|
||||
log "Profile: #{@profile}"
|
||||
log
|
||||
log '```xml' #so output can be posted directly to github comment fields
|
||||
log osm_str.strip
|
||||
log '```'
|
||||
log
|
||||
log
|
||||
@has_logged_scenario_info = true
|
||||
end
|
||||
|
||||
def log_fail expected,got,attempts
|
||||
return
|
||||
log_scenario_fail_info
|
||||
log "== "
|
||||
log "Expected: #{expected}"
|
||||
log "Got: #{got}"
|
||||
log
|
||||
['route','forw','backw'].each do |direction|
|
||||
if attempts[direction]
|
||||
attempts[direction]
|
||||
log "Direction: #{direction}"
|
||||
log "Query: #{attempts[direction][:query]}"
|
||||
log "Response: #{attempts[direction][:response].body}"
|
||||
log
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def log_preprocess_info
|
||||
return if @has_logged_preprocess_info
|
||||
log "=========================================", :preprocess
|
||||
log "Preprocessing data for scenario: #{@scenario_title}", :preprocess
|
||||
log "Time: #{@scenario_time}", :preprocess
|
||||
log '', :preprocess
|
||||
log "== OSM data:", :preprocess
|
||||
log '```xml', :preprocess #so output can be posted directly to github comment fields
|
||||
log osm_str, :preprocess
|
||||
log '```', :preprocess
|
||||
log '', :preprocess
|
||||
log "== Profile:", :preprocess
|
||||
log @profile, :preprocess
|
||||
log '', :preprocess
|
||||
@has_logged_preprocess_info = true
|
||||
end
|
||||
|
||||
def log_preprocess str
|
||||
log_preprocess_info
|
||||
log str, :preprocess
|
||||
end
|
||||
|
||||
def log_preprocess_done
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user