diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..5ec6bad6f --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +features/support/flatbuffers.js +features/support/fbresult_generated.js \ No newline at end of file diff --git a/.gitignore b/.gitignore index 69b0c2afc..21bf08310 100644 --- a/.gitignore +++ b/.gitignore @@ -49,7 +49,7 @@ Thumbs.db /_build* /build/ /example/build/ -/test/data/monaco* +/test/data/monaco.osrm* /test/data/ch /test/data/corech /test/data/mld @@ -72,12 +72,6 @@ Thumbs.db ########################### .idea/ -# stxxl related files # -####################### -.stxxl -stxxl.log -stxxl.errlog - # Compiled Binary Files # #################################### /osrm-extract diff --git a/.travis.yml b/.travis.yml index 2c74ee996..af508c88d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,8 +25,6 @@ cache: env: global: - - secure: "hk+32aXXF5t1ApaM2Wjqooz3dx1si907L87WRMkO47WlpJmUUU/Ye+MJk9sViH8MdhOcceocVAmdYl5/WFWOIbDWNlBya9QvXDZyIu2KIre/0QyOCTZbrsif8paBXKIO5O/R4OTvIZ8rvWZsadBdmAT9GSbDhih6FzqXAEgeIYQ=" - - secure: "VE+cFkseFwW4jK6XwkP0yW3h4DixPJ8+Eb3yKcchGZ5iIJxlZ/8i1vKHYxadgPRwSYwPSB14tF70xj2OmiT2keGzZUfphmPXinBaLEhYk+Bde+GZZkoSl5ND109I/LcyNr0nG9dDgtV6pkvFchgchpyP9JnVOOS0+crEZlAz0RE=" - CCACHE_TEMPDIR=/tmp/.ccache-temp - CCACHE_COMPRESS=1 - CASHER_TIME_OUT=599 # one second less than 10m to avoid 10m timeout error: https://github.com/Project-OSRM/osrm-backend/issues/2742 @@ -36,6 +34,10 @@ env: - ENABLE_NODE_BINDINGS=On - NODE="10" +stages: + - core + - optional + matrix: fast_finish: true @@ -43,12 +45,14 @@ matrix: include: # Debug Builds - - os: linux + - stage: core + os: linux compiler: "format-taginfo-docs" env: NODE=10 sudo: false before_install: install: + - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash - source $NVM_DIR/nvm.sh - nvm install $NODE - nvm use $NODE @@ -56,8 +60,8 @@ matrix: - npm ci --ignore-scripts script: - ./scripts/check_taginfo.py taginfo.json profiles/car.lua - - ${MASON} install clang-format 3.8.1 - - PATH=$(${MASON} prefix clang-format 3.8.1)/bin:${PATH} ./scripts/format.sh && ./scripts/error_on_dirty.sh + - ${MASON} install clang-format 10.0.0 + - PATH=$(${MASON} prefix clang-format 10.0.0)/bin:${PATH} ./scripts/format.sh && ./scripts/error_on_dirty.sh - node ./scripts/validate_changelog.js # See issue 4043 #- npm run docs && ./scripts/error_on_dirty.sh @@ -115,6 +119,22 @@ matrix: packages: ['libstdc++-4.9-dev'] env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON RUN_CLANG_FORMAT=ON ENABLE_LTO=ON + - os: linux + compiler: "gcc-9-release" + addons: &gcc9 + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-9', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev'] + env: CCOMPILER='gcc-9' CXXCOMPILER='g++-9' BUILD_TYPE='Release' CXXFLAGS='-Wno-cast-function-type' + + - os: linux + compiler: "gcc-8-release" + addons: &gcc8 + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-8', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev'] + env: CCOMPILER='gcc-8' CXXCOMPILER='g++-8' BUILD_TYPE='Release' CXXFLAGS='-Wno-cast-function-type' + - os: linux compiler: "gcc-7-release" addons: &gcc7 @@ -129,14 +149,6 @@ matrix: TARGET_ARCH='i686' CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Release' CFLAGS='-m32 -msse2 -mfpmath=sse' CXXFLAGS='-m32 -msse2 -mfpmath=sse' - - os: linux - compiler: "gcc-7-stxxl" - addons: &gcc7 - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-7', 'libbz2-dev', 'libstxxl-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev'] - env: CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Release' ENABLE_STXXL=On - - os: linux compiler: "gcc-5-release" addons: &gcc49 @@ -163,9 +175,17 @@ matrix: - os: osx osx_image: xcode9.2 - compiler: "mason-osx-release-node-8" + compiler: "mason-osx-release-node-12" # we use the xcode provides clang and don't install our own - env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="8" + env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="12" + after_success: + - ./scripts/travis/publish.sh + + - os: osx + osx_image: xcode9.2 + compiler: "mason-osx-release-node-14" + # we use the xcode provides clang and don't install our own + env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="14" after_success: - ./scripts/travis/publish.sh @@ -181,12 +201,12 @@ matrix: # Node build jobs. These skip running the tests. - os: linux sudo: false - compiler: "node-8-mason-linux-release" + compiler: "node-14-mason-linux-release" addons: apt: sources: ['ubuntu-toolchain-r-test'] packages: ['libstdc++-4.9-dev'] - env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="8" + env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="14" install: - pushd ${OSRM_BUILD_DIR} - | @@ -205,12 +225,60 @@ matrix: - os: linux sudo: false - compiler: "node-8-mason-linux-debug" + compiler: "node-14-mason-linux-debug" addons: apt: sources: ['ubuntu-toolchain-r-test'] packages: ['libstdc++-4.9-dev'] - env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="8" + env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="14" + install: + - pushd ${OSRM_BUILD_DIR} + - | + cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DENABLE_MASON=${ENABLE_MASON:-OFF} \ + -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \ + -DENABLE_CCACHE=ON \ + -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \ + -DENABLE_GLIBC_WORKAROUND=ON + - make --jobs=${JOBS} + - popd + script: + - npm run nodejs-tests + after_success: + - ./scripts/travis/publish.sh + + - os: linux + sudo: false + compiler: "node-12-mason-linux-release" + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['libstdc++-4.9-dev'] + env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="12" + install: + - pushd ${OSRM_BUILD_DIR} + - | + cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DENABLE_MASON=${ENABLE_MASON:-OFF} \ + -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \ + -DENABLE_CCACHE=ON \ + -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \ + -DENABLE_GLIBC_WORKAROUND=ON + - make --jobs=${JOBS} + - popd + script: + - npm run nodejs-tests + after_success: + - ./scripts/travis/publish.sh + + - os: linux + sudo: false + compiler: "node-12-mason-linux-debug" + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['libstdc++-4.9-dev'] + env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="12" install: - pushd ${OSRM_BUILD_DIR} - | @@ -275,7 +343,135 @@ matrix: after_success: - ./scripts/travis/publish.sh + - os: osx + stage: optional + osx_image: xcode9.2 + compiler: "mason-osx-release-node-latest" + # we use the xcode provides clang and don't install our own + env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="node" + after_success: + - ./scripts/travis/publish.sh + + - os: linux + sudo: false + compiler: "node-latest-mason-linux-release" + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['libstdc++-4.9-dev'] + env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="node" + install: + - pushd ${OSRM_BUILD_DIR} + - | + cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DENABLE_MASON=${ENABLE_MASON:-OFF} \ + -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \ + -DENABLE_CCACHE=ON \ + -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \ + -DENABLE_GLIBC_WORKAROUND=ON + - make --jobs=${JOBS} + - popd + script: + - npm run nodejs-tests + after_success: + - ./scripts/travis/publish.sh + + - os: linux + sudo: false + compiler: "node-latest-mason-linux-debug" + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['libstdc++-4.9-dev'] + env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="node" + install: + - pushd ${OSRM_BUILD_DIR} + - | + cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DENABLE_MASON=${ENABLE_MASON:-OFF} \ + -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \ + -DENABLE_CCACHE=ON \ + -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \ + -DENABLE_GLIBC_WORKAROUND=ON + - make --jobs=${JOBS} + - popd + script: + - npm run nodejs-tests + after_success: + - ./scripts/travis/publish.sh + + - os: osx + osx_image: xcode9.2 + compiler: "mason-osx-release-node-lts" + # we use the xcode provides clang and don't install our own + env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="--lts" + after_success: + - ./scripts/travis/publish.sh + + - os: linux + sudo: false + compiler: "node-lts-mason-linux-release" + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['libstdc++-4.9-dev'] + env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="--lts" + install: + - pushd ${OSRM_BUILD_DIR} + - | + cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DENABLE_MASON=${ENABLE_MASON:-OFF} \ + -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \ + -DENABLE_CCACHE=ON \ + -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \ + -DENABLE_GLIBC_WORKAROUND=ON + - make --jobs=${JOBS} + - popd + script: + - npm run nodejs-tests + after_success: + - ./scripts/travis/publish.sh + + - os: linux + sudo: false + compiler: "node-lts-mason-linux-debug" + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['libstdc++-4.9-dev'] + env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="--lts" + install: + - pushd ${OSRM_BUILD_DIR} + - | + cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DENABLE_MASON=${ENABLE_MASON:-OFF} \ + -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \ + -DENABLE_CCACHE=ON \ + -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \ + -DENABLE_GLIBC_WORKAROUND=ON + - make --jobs=${JOBS} + - popd + script: + - npm run nodejs-tests + after_success: + - ./scripts/travis/publish.sh + + allow_failures: + - compiler: "mason-osx-release-node-latest" + env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="node" + - compiler: "node-latest-mason-linux-release" + env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="node" + - compiler: "node-latest-mason-linux-debug" + env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="node" + - compiler: "mason-osx-release-node-lts" + env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="--lts" + - compiler: "node-lts-mason-linux-release" + env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="--lts" + - compiler: "node-lts-mason-linux-debug" + env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="--lts" + before_install: + - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash - source $NVM_DIR/nvm.sh - nvm install $NODE - nvm use $NODE @@ -333,7 +529,6 @@ install: -DENABLE_COVERAGE=${ENABLE_COVERAGE:-OFF} \ -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \ -DENABLE_SANITIZER=${ENABLE_SANITIZER:-OFF} \ - -DENABLE_STXXL=${ENABLE_STXXL:-OFF} \ -DBUILD_TOOLS=ON \ -DENABLE_CCACHE=ON \ -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \ @@ -369,6 +564,7 @@ script: - ./unit_tests/util-tests - ./unit_tests/server-tests - ./unit_tests/partitioner-tests + - ./unit_tests/customizer-tests - | if [ -z "${ENABLE_SANITIZER}" ] && [ "$TARGET_ARCH" != "i686" ]; then npm run nodejs-tests diff --git a/CHANGELOG.md b/CHANGELOG.md index 598df2cc4..4f9007696 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,70 @@ # Unreleased + - Changes from 5.24.0 + - Misc: + - FIXED: Upgrade to @mapbox/node-pre-gyp fix various bugs with Node 12/14 [#5991](https://github.com/Project-OSRM/osrm-backend/pull/5991) + - FIXED: `valid` type in documentation examples [#5990](https://github.com/Project-OSRM/osrm-backend/issues/5990) + - Profile: + - FIXED: Add kerb barrier exception to default car profile. [#5999](https://github.com/Project-OSRM/osrm-backend/pull/5999) + +# 5.24.0 + - Changes from 5.23.0 + - Features + - ADDED: Added support for multiple via-way restrictions. [#5907](https://github.com/Project-OSRM/osrm-backend/pull/5907) + - ADDED: Add node bindings support for Node 12, 14, and publish binaries [#5918](https://github.com/Project-OSRM/osrm-backend/pull/5918) + - REMOVED: we no longer publish Node 8 binary modules (they are still buildable from source) [#5918](https://github.com/Project-OSRM/osrm-backend/pull/5918) + - Routing: + - FIXED: Avoid copying ManyToMany table results [#5923](https://github.com/Project-OSRM/osrm-backend/pull/5923) + - FIXED: Reduce copying in API parameter constructors [#5925](https://github.com/Project-OSRM/osrm-backend/pull/5925) + - Misc: + - CHANGED: Cleanup NodeJS dependencies [#5945](https://github.com/Project-OSRM/osrm-backend/pull/5945) + - CHANGED: Unify `.osrm.turn_penalites_index` dump processing same with `.osrm.turn_weight_penalties` and `.osrm.turn_duration_penalties` [#5868](https://github.com/Project-OSRM/osrm-backend/pull/5868) + - FIXED: Properly validate source/destination validation in NodeJS table service [#5595](https://github.com/Project-OSRM/osrm-backend/pull/5595/files) + - FIXED: turn.roads_on_the_left not containing incoming roads and turn.roads_on_the_right not containing outgoing roads on two-way roads [#5128](https://github.com/Project-OSRM/osrm-backend/issues/5128) + - Profile: + - ADDED: Profile debug script which fetches a way from OSM then outputs the result of the profile. [#5908](https://github.com/Project-OSRM/osrm-backend/pull/5908) + - Infrastructure + - CHANGED: Bundled protozero updated to v1.7.0. [#5858](https://github.com/Project-OSRM/osrm-backend/pull/5858) + - Windows: + - FIXED: Fix bit-shift overflow in MLD partition step. [#5878](https://github.com/Project-OSRM/osrm-backend/pull/5878) + - FIXED: Fix vector bool permutation in graph contraction step [#5882](https://github.com/Project-OSRM/osrm-backend/pull/5882) + - API: + - FIXED: Undo libosrm API break by adding old interface as method overload [#5861](https://github.com/Project-OSRM/osrm-backend/pull/5861) + - FIXED: Fixed validation of sources/destinations when accessed via node bindings [#5595](https://github.com/Project-OSRM/osrm-backend/pull/5595) + +# 5.23.0 + - Changes from 5.22.0 + - Build: + - FIXED: pessimistic calls to std::move [#5560](https://github.com/Project-OSRM/osrm-backend/pull/5561) + - Features: + - ADDED: new API parameter - `snapping=any|default` to allow snapping to previously unsnappable edges [#5361](https://github.com/Project-OSRM/osrm-backend/pull/5361) + - ADDED: keepalive support to the osrm-routed HTTP server [#5518](https://github.com/Project-OSRM/osrm-backend/pull/5518) + - ADDED: flatbuffers output format support [#5513](https://github.com/Project-OSRM/osrm-backend/pull/5513) + - ADDED: Global 'skip_waypoints' option [#5556](https://github.com/Project-OSRM/osrm-backend/pull/5556) + - FIXED: Install the libosrm_guidance library correctly [#5604](https://github.com/Project-OSRM/osrm-backend/pull/5604) + - FIXED: Http Handler can now deal witch optional whitespace between header-key and -value [#5606](https://github.com/Project-OSRM/osrm-backend/issues/5606) + - Routing: + - CHANGED: allow routing past `barrier=arch` [#5352](https://github.com/Project-OSRM/osrm-backend/pull/5352) + - CHANGED: default car weight was reduced to 2000 kg. [#5371](https://github.com/Project-OSRM/osrm-backend/pull/5371) + - CHANGED: default car height was reduced to 2 meters. [#5389](https://github.com/Project-OSRM/osrm-backend/pull/5389) + - FIXED: treat `bicycle=use_sidepath` as no access on the tagged way. [#5622](https://github.com/Project-OSRM/osrm-backend/pull/5622) + - FIXED: fix table result when source and destination on same one-way segment. [#5828](https://github.com/Project-OSRM/osrm-backend/pull/5828) + - FIXED: fix occasional segfault when swapping data with osrm-datastore and using `exclude=` [#5844](https://github.com/Project-OSRM/osrm-backend/pull/5844) + - FIXED: fix crash in MLD alternative search if source or target are invalid [#5851](https://github.com/Project-OSRM/osrm-backend/pull/5851) + - Misc: + - CHANGED: Reduce memory usage for raster source handling. [#5572](https://github.com/Project-OSRM/osrm-backend/pull/5572) + - CHANGED: Add cmake option `ENABLE_DEBUG_LOGGING` to control whether output debug logging. [#3427](https://github.com/Project-OSRM/osrm-backend/issues/3427) + - CHANGED: updated extent of Hong Kong as left hand drive country. [#5535](https://github.com/Project-OSRM/osrm-backend/issues/5535) + - FIXED: corrected error message when failing to snap input coordinates [#5846](https://github.com/Project-OSRM/osrm-backend/pull/5846) + - Infrastructure + - REMOVED: STXXL support removed as STXXL became abandonware. [#5760](https://github.com/Project-OSRM/osrm-backend/pull/5760) + +# 5.22.0 + - Changes from 5.21.0 + - Build: + - ADDED: optionally build Node `lts` and `latest` bindings [#5347](https://github.com/Project-OSRM/osrm-backend/pull/5347) + - Features: + - ADDED: new waypoints parameter to the `route` plugin, enabling silent waypoints [#5345](https://github.com/Project-OSRM/osrm-backend/pull/5345) + - ADDED: data timestamp information in the response (saved in new file `.osrm.timestamp`). [#5115](https://github.com/Project-OSRM/osrm-backend/issues/5115) # 5.21.0 - Changes from 5.20.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index e1767b961..e6feb6de9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,9 +23,9 @@ option(ENABLE_CCACHE "Speed up incremental rebuilds via ccache" ON) option(BUILD_TOOLS "Build OSRM tools" OFF) option(BUILD_PACKAGE "Build OSRM package" OFF) option(ENABLE_ASSERTIONS "Use assertions in release mode" OFF) +option(ENABLE_DEBUG_LOGGING "Use debug logging in release mode" OFF) option(ENABLE_COVERAGE "Build with coverage instrumentalisation" OFF) option(ENABLE_SANITIZER "Use memory sanitizer for Debug build" OFF) -option(ENABLE_STXXL "Use STXXL library" OFF) option(ENABLE_LTO "Use LTO if available" OFF) option(ENABLE_FUZZING "Fuzz testing using LLVM's libFuzzer" OFF) option(ENABLE_GOLD_LINKER "Use GNU gold linker if available" ON) @@ -37,7 +37,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") if(ENABLE_MASON) # versions in use set(MASON_BOOST_VERSION "1.65.1") - set(MASON_STXXL_VERSION "1.4.1-1") set(MASON_EXPAT_VERSION "2.2.0") set(MASON_LUA_VERSION "5.2.4") set(MASON_BZIP2_VERSION "1.0.6") @@ -57,6 +56,12 @@ endif() if (POLICY CMP0048) cmake_policy(SET CMP0048 OLD) endif() +if (POLICY CMP0057) + cmake_policy(SET CMP0057 NEW) +endif() +if (POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) +endif() project(OSRM C CXX) include(JSONParser) @@ -227,6 +232,7 @@ endif() if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) message(STATUS "Configuring debug mode flags") set(ENABLE_ASSERTIONS ON) + set(ENABLE_DEBUG_LOGGING ON) endif() if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") @@ -439,6 +445,12 @@ include_directories(SYSTEM ${PROTOZERO_INCLUDE_DIR}) set(VTZERO_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/vtzero/include") include_directories(SYSTEM ${VTZERO_INCLUDE_DIR}) +set(FLATBUFFERS_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers") +set(FLATBUFFERS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers/include") +include_directories(${FLATBUFFERS_INCLUDE_DIR}) +add_subdirectory(${FLATBUFFERS_SRC_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-build + EXCLUDE_FROM_ALL) # if mason is enabled no find_package calls are made # to ensure that we are only compiling and linking against @@ -466,13 +478,6 @@ if(ENABLE_MASON) mason_use(boost_libsystem VERSION ${MASON_BOOST_VERSION}) set(Boost_SYSTEM_LIBRARY ${MASON_PACKAGE_boost_libsystem_STATIC_LIBS}) - if (ENABLE_STXXL) - mason_use(stxxl VERSION ${MASON_STXXL_VERSION}) - add_dependency_includes(${MASON_PACKAGE_stxxl_INCLUDE_DIRS}) - set(MAYBE_STXXL_LIBRARY ${MASON_PACKAGE_stxxl_STATIC_LIBS}) - add_definitions(-DUSE_STXXL_LIBRARY) - endif() - mason_use(expat VERSION ${MASON_EXPAT_VERSION}) add_dependency_includes(${MASON_PACKAGE_expat_INCLUDE_DIRS}) set(EXPAT_LIBRARIES ${MASON_PACKAGE_expat_STATIC_LIBS}) @@ -518,30 +523,16 @@ else() find_package(Boost 1.54 REQUIRED COMPONENTS ${BOOST_COMPONENTS}) add_dependency_includes(${Boost_INCLUDE_DIRS}) - if(WIN32 AND Boost_VERSION VERSION_LESS 106200) - message(FATAL_ERROR "Building with MSVC needs Boost 1.62 with CXX11_CONSTEXPR support") - endif() find_package(TBB REQUIRED) add_dependency_includes(${TBB_INCLUDE_DIR}) - if(WIN32 AND CMAKE_BUILD_TYPE MATCHES Debug) - set(TBB_LIBRARIES ${TBB_DEBUG_LIBRARIES}) + if(WIN32) + set(TBB_LIBRARIES optimized ${TBB_LIBRARY} optimized ${TBB_MALLOC_LIBRARY} debug ${TBB_LIBRARY_DEBUG} debug ${TBB_MALLOC_LIBRARY_DEBUG}) endif() find_package(EXPAT REQUIRED) add_dependency_includes(${EXPAT_INCLUDE_DIRS}) - if (ENABLE_STXXL) - find_package(STXXL) - if (STXXL_FOUND) - add_dependency_includes(${STXXL_INCLUDE_DIR}) - set(MAYBE_STXXL_LIBRARY ${STXXL_LIBRARY}) - add_definitions(-DUSE_STXXL_LIBRARY) - else() - MESSAGE(STATUS "STXXL was requested but not found, default STL will be used") - endif() - endif() - find_package(BZip2 REQUIRED) add_dependency_includes(${BZIP2_INCLUDE_DIR}) @@ -601,15 +592,6 @@ add_dependency_defines(-DBOOST_SPIRIT_USE_PHOENIX_V3) add_dependency_defines(-DBOOST_RESULT_OF_USE_DECLTYPE) add_dependency_defines(-DBOOST_FILESYSTEM_NO_DEPRECATED) -if (ENABLE_STXXL) - set(OpenMP_FIND_QUIETLY ON) - find_package(OpenMP) - if(OPENMP_FOUND) - message(STATUS "OpenMP support found. Linking just in case for stxxl") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - endif() -endif() - add_definitions(${OSRM_DEFINES}) include_directories(SYSTEM ${DEPENDENCIES_INCLUDE_DIRS}) @@ -642,7 +624,6 @@ set(EXTRACTOR_LIBRARIES ${EXPAT_LIBRARIES} ${USED_LUA_LIBRARIES} ${OSMIUM_LIBRARIES} - ${MAYBE_STXXL_LIBRARY} ${TBB_LIBRARIES} ${ZLIB_LIBRARY} ${MAYBE_COVERAGE_LIBRARIES}) @@ -676,7 +657,6 @@ set(CONTRACTOR_LIBRARIES ${BOOST_BASE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${USED_LUA_LIBRARIES} - ${MAYBE_STXXL_LIBRARY} ${TBB_LIBRARIES} ${MAYBE_RT_LIBRARY} ${MAYBE_COVERAGE_LIBRARIES}) @@ -696,7 +676,6 @@ set(STORAGE_LIBRARIES set(UTIL_LIBRARIES ${BOOST_BASE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} - ${MAYBE_STXXL_LIBRARY} ${TBB_LIBRARIES} ${MAYBE_COVERAGE_LIBRARIES} ${ZLIB_LIBRARY}) @@ -728,6 +707,11 @@ if (ENABLE_ASSERTIONS) add_definitions(-DBOOST_ENABLE_ASSERT_HANDLER) endif() +if (ENABLE_DEBUG_LOGGING) + message(STATUS "Enabling debug logging") + add_definitions(-DENABLE_DEBUG_LOGGING) +endif() + # Add RPATH info to executables so that when they are run after being installed # (i.e., from /usr/local/bin/) the linker can find library dependencies. For # more info see http://www.cmake.org/Wiki/CMake_RPATH_handling @@ -738,8 +722,10 @@ set_property(TARGET osrm-datastore PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE) set_property(TARGET osrm-routed PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE) file(GLOB VariantGlob third_party/variant/include/mapbox/*.hpp) +file(GLOB FlatbuffersGlob third_party/flatbuffers/include/flatbuffers/*.h) file(GLOB LibraryGlob include/osrm/*.hpp) file(GLOB ParametersGlob include/engine/api/*_parameters.hpp) +set(ApiHeader include/engine/api/base_result.hpp) set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/approach.hpp include/engine/phantom_node.hpp) set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp include/util/typedefs.hpp include/util/alias.hpp include/util/exception.hpp include/util/bearing.hpp) set(ExtractorHeader include/extractor/extractor.hpp include/storage/io_config.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp) @@ -754,7 +740,9 @@ install(FILES ${PartitionerHeader} DESTINATION include/osrm/partitioner) install(FILES ${ContractorHeader} DESTINATION include/osrm/contractor) install(FILES ${LibraryGlob} DESTINATION include/osrm) install(FILES ${ParametersGlob} DESTINATION include/osrm/engine/api) +install(FILES ${ApiHeader} DESTINATION include/osrm/engine/api) install(FILES ${VariantGlob} DESTINATION include/mapbox) +install(FILES ${FlatbuffersGlob} DESTINATION include/flatbuffers) install(TARGETS osrm-extract DESTINATION bin) install(TARGETS osrm-partition DESTINATION bin) install(TARGETS osrm-customize DESTINATION bin) @@ -768,6 +756,7 @@ install(TARGETS osrm_customize DESTINATION lib) install(TARGETS osrm_update DESTINATION lib) install(TARGETS osrm_contract DESTINATION lib) install(TARGETS osrm_store DESTINATION lib) +install(TARGETS osrm_guidance DESTINATION lib) # Install profiles and support library to /usr/local/share/osrm/profiles by default diff --git a/README.md b/README.md index 155c81257..8435d558f 100644 --- a/README.md +++ b/README.md @@ -58,16 +58,16 @@ Download OpenStreetMap extracts for example from [Geofabrik](http://download.geo Pre-process the extract with the car profile and start a routing engine HTTP server on port 5000 - docker run -t -v $(pwd):/data osrm/osrm-backend osrm-extract -p /opt/car.lua /data/berlin-latest.osm.pbf + docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/berlin-latest.osm.pbf -The flag `-v $(pwd):/data` creates the directory `/data` inside the docker container and makes the current working directory `$(pwd)` available there. The file `/data/berlin-latest.osm.pbf` inside the container is referring to `$(pwd)/berlin-latest.osm.pbf` on the host. +The flag `-v "${PWD}:/data"` creates the directory `/data` inside the docker container and makes the current working directory `"${PWD}"` available there. The file `/data/berlin-latest.osm.pbf` inside the container is referring to `"${PWD}/berlin-latest.osm.pbf"` on the host. - docker run -t -v $(pwd):/data osrm/osrm-backend osrm-partition /data/berlin-latest.osrm - docker run -t -v $(pwd):/data osrm/osrm-backend osrm-customize /data/berlin-latest.osrm + docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-partition /data/berlin-latest.osrm + docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-customize /data/berlin-latest.osrm Note that `berlin-latest.osrm` has a different file extension. - docker run -t -i -p 5000:5000 -v $(pwd):/data osrm/osrm-backend osrm-routed --algorithm mld /data/berlin-latest.osrm + docker run -t -i -p 5000:5000 -v "${PWD}:/data" osrm/osrm-backend osrm-routed --algorithm mld /data/berlin-latest.osrm Make requests against the HTTP server diff --git a/appveyor-build.bat b/appveyor-build.bat index 09a2f421d..37cfd8f07 100644 --- a/appveyor-build.bat +++ b/appveyor-build.bat @@ -10,7 +10,7 @@ ECHO NUMBER_OF_PROCESSORS^: %NUMBER_OF_PROCESSORS% :: Check CMake version -SET CMAKE_VERSION=3.9.2 +SET CMAKE_VERSION=3.16.3 SET PATH=%PROJECT_DIR%\cmake-%CMAKE_VERSION%-win32-x86\bin;%PATH% ECHO cmake^: && cmake --version IF %ERRORLEVEL% NEQ 0 ECHO CMAKE not found && GOTO CMAKE_NOT_OK @@ -19,7 +19,7 @@ cmake --version | findstr /C:%CMAKE_VERSION% && GOTO CMAKE_OK :CMAKE_NOT_OK ECHO CMAKE NOT OK - downloading new CMake %CMAKE_VERSION% -powershell Invoke-WebRequest https://cmake.org/files/v3.9/cmake-%CMAKE_VERSION%-win32-x86.zip -OutFile $env:PROJECT_DIR\cm.zip +powershell Invoke-WebRequest https://cmake.org/files/v3.16/cmake-%CMAKE_VERSION%-win32-x86.zip -OutFile $env:PROJECT_DIR\cm.zip IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF NOT EXIST cmake-%CMAKE_VERSION%-win32-x86 7z -y x cm.zip | %windir%\system32\FIND "ing archive" IF %ERRORLEVEL% NEQ 0 GOTO ERROR @@ -29,8 +29,8 @@ 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 +SET PATH=C:\Program Files (x86)\MSBuild\15.0\Bin;%PATH% +CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" ECHO platform^: %platform% @@ -40,7 +40,7 @@ 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-2017.09.7z +SET DEPSPKG=osrm-deps-win-x64-14.2-2019.01.7z :: local development ECHO. @@ -52,7 +52,7 @@ IF EXIST %DEPSPKG% DEL %DEPSPKG% IF %ERRORLEVEL% NEQ 0 GOTO ERROR ECHO downloading %DEPSPKG% -powershell Invoke-WebRequest https://mapbox.s3.amazonaws.com/windows-builds/windows-build-deps/$env:DEPSPKG -OutFile $env:PROJECT_DIR\$env:DEPSPKG +powershell Invoke-WebRequest http://project-osrm.wolt.com/windows-build-deps/$env:DEPSPKG -OutFile $env:PROJECT_DIR\$env:DEPSPKG IF %ERRORLEVEL% NEQ 0 GOTO ERROR :SKIPDL @@ -74,27 +74,35 @@ IF %ERRORLEVEL% NEQ 0 GOTO ERROR SET OSRMDEPSDIR=%PROJECT_DIR%/osrm-deps set PREFIX=%OSRMDEPSDIR%/libs -set BOOST_ROOT=%OSRMDEPSDIR%/boost +set BOOST_ROOT=%OSRMDEPSDIR% set BOOST_LIBRARYDIR=%BOOST_ROOT%/lib -set TBB_INSTALL_DIR=%OSRMDEPSDIR%/tbb -set TBB_ARCH_PLATFORM=intel64/vc14 +set TBB_INSTALL_DIR=%OSRMDEPSDIR% +REM set TBB_ARCH_PLATFORM=intel64/vc17 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% +REM ECHO TBB_ARCH_PLATFORM ^: %TBB_ARCH_PLATFORM% ECHO calling cmake .... cmake .. ^ --G "Visual Studio 14 2015 Win64" ^ +-G "Visual Studio 16 2019" ^ -DBOOST_ROOT=%BOOST_ROOT% ^ -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% ^ --DBoost_ADDITIONAL_VERSIONS=1.58 ^ +-DBoost_ADDITIONAL_VERSIONS=1.73.0 ^ -DBoost_USE_MULTITHREADED=ON ^ -DBoost_USE_STATIC_LIBS=ON ^ +-DEXPAT_INCLUDE_DIR=%OSRMDEPSDIR% ^ +-DEXPAT_LIBRARY=%OSRMDEPSDIR%/lib/libexpat.lib ^ +-DBZIP2_INCLUDE_DIR=%OSRMDEPSDIR% ^ +-DBZIP2_LIBRARIES=%OSRMDEPSDIR%/lib/libbz2.lib ^ +-DLUA_INCLUDE_DIR=%OSRMDEPSDIR% ^ +-DLUA_LIBRARIES=%OSRMDEPSDIR%/lib/lua5.3.5.lib ^ +-DZLIB_INCLUDE_DIR=%OSRMDEPSDIR% ^ +-DZLIB_LIBRARY=%OSRMDEPSDIR%/lib/libz.lib ^ -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^ -DCMAKE_INSTALL_PREFIX=%PREFIX% IF %ERRORLEVEL% NEQ 0 GOTO ERROR @@ -106,34 +114,46 @@ msbuild OSRM.sln ^ /t:rebuild ^ /p:BuildInParallel=true ^ /m:%NUMBER_OF_PROCESSORS% ^ -/toolsversion:14.0 ^ -/p:PlatformToolset=v140 ^ +/toolsversion:Current ^ +/p:PlatformToolset=v142 ^ /clp:Verbosity=normal ^ /nologo ^ /flp1:logfile=build_errors.txt;errorsonly ^ /flp2:logfile=build_warnings.txt;warningsonly -IF %ERRORLEVEL% NEQ 0 GOTO ERROR +IF %ERRORLEVEL% EQU 1 GOTO ERROR CD %PROJECT_DIR%\build -IF %ERRORLEVEL% NEQ 0 GOTO ERROR +IF %ERRORLEVEL% EQU 1 GOTO ERROR -SET PATH=%PROJECT_DIR%\osrm-deps\libs\bin;%PATH% +SET PATH=%PROJECT_DIR%\osrm-deps\lib;%PATH% ECHO running extractor-tests.exe ... unit_tests\%Configuration%\extractor-tests.exe -IF %ERRORLEVEL% NEQ 0 GOTO ERROR +IF %ERRORLEVEL% EQU 1 GOTO ERROR + +ECHO running contractor-tests.exe ... +unit_tests\%Configuration%\contractor-tests.exe +IF %ERRORLEVEL% EQU 1 GOTO ERROR ECHO running engine-tests.exe ... unit_tests\%Configuration%\engine-tests.exe -IF %ERRORLEVEL% NEQ 0 GOTO ERROR +IF %ERRORLEVEL% EQU 1 GOTO ERROR ECHO running util-tests.exe ... unit_tests\%Configuration%\util-tests.exe -IF %ERRORLEVEL% NEQ 0 GOTO ERROR +IF %ERRORLEVEL% EQU 1 GOTO ERROR ECHO running server-tests.exe ... unit_tests\%Configuration%\server-tests.exe -IF %ERRORLEVEL% NEQ 0 GOTO ERROR +IF %ERRORLEVEL% EQU 1 GOTO ERROR + +ECHO running partitioner-tests.exe ... +unit_tests\%Configuration%\partitioner-tests.exe +IF %ERRORLEVEL% EQU 1 GOTO ERROR + +ECHO running customizer-tests.exe ... +unit_tests\%Configuration%\customizer-tests.exe +IF %ERRORLEVEL% EQU 1 GOTO ERROR ECHO running library-tests.exe ... SET test_region=monaco @@ -141,7 +161,9 @@ SET test_region_ch=ch\monaco SET test_region_corech=corech\monaco SET test_region_mld=mld\monaco SET test_osm=%test_region%.osm.pbf -IF NOT EXIST %test_osm% powershell Invoke-WebRequest https://s3.amazonaws.com/mapbox/osrm/testing/monaco.osm.pbf -OutFile %test_osm% +IF NOT EXIST %test_osm% powershell Invoke-WebRequest http://project-osrm.wolt.com/testing/monaco.osm.pbf -OutFile %test_osm% +ECHO running %Configuration%\osrm-extract.exe -p ../profiles/car.lua %test_osm% +%Configuration%\osrm-extract.exe %Configuration%\osrm-extract.exe -p ../profiles/car.lua %test_osm% MKDIR ch XCOPY %test_region%.osrm.* ch\ diff --git a/appveyor.yml b/appveyor.yml index 02e124c57..3fbf89cb6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,7 +10,7 @@ install: init: - git config --global core.autocrlf input -os: Visual Studio 2015 +os: Visual Studio 2019 # clone directory clone_folder: c:\projects\osrm @@ -25,9 +25,10 @@ before_test: - npm --version - npm install --ignore-scripts - npm link --ignore-scripts - - SET PATH=%CD%\osrm-deps\libs\bin;%PATH% + - SET PATH=%CD%\osrm-deps\lib;%PATH% - SET OSRM_BUILD_DIR=build\%Configuration% - - npm test +# TODO tests fail with "JavaScript heap out of memory", need a better host? +# - npm test branches: only: diff --git a/build-local.bat b/build-local.bat index 8598230f3..dad1d25c5 100644 --- a/build-local.bat +++ b/build-local.bat @@ -11,7 +11,6 @@ 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.7.0-rc2-win32-x86\bin;%PATH% SET PATH=C:\Program Files\7-Zip;%PATH% powershell Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force diff --git a/cmake/CPackConfig.cmake b/cmake/CPackConfig.cmake index c05dc2201..6ce8def8e 100644 --- a/cmake/CPackConfig.cmake +++ b/cmake/CPackConfig.cmake @@ -11,7 +11,7 @@ SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY "FALSE") SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open Source Routing Machine (OSRM) is a high-performance routing engine. It combines sophisticated routing algorithms with the open and free data of the OpenStreetMap.") SET(CPACK_PACKAGE_CONTACT "Project OSRM ") -SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENCE.TXT") +SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.TXT") SET(CPACK_STRIP_FILES "TRUE") file(GLOB_RECURSE ProfileGlob ${CMAKE_SOURCE_DIR}/profiles/*) diff --git a/cmake/FindSTXXL.cmake b/cmake/FindSTXXL.cmake deleted file mode 100644 index 473fb6a29..000000000 --- a/cmake/FindSTXXL.cmake +++ /dev/null @@ -1,51 +0,0 @@ -# Locate STXXL library -# This module defines -# STXXL_FOUND, if false, do not try to link to libstxxl -# STXXL_LIBRARY -# STXXL_INCLUDE_DIR, where to find stxxl.h -# - - -IF( NOT STXXL_FIND_QUIETLY ) - MESSAGE(STATUS "Looking for STXXL...") -ENDIF() - -FIND_PATH(STXXL_INCLUDE_DIR stxxl.h - HINTS - $ENV{STXXL_DIR} - PATH_SUFFIXES stxxl include/stxxl/stxxl include/stxxl include - PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /opt/local # DarwinPorts - /opt -) - -FIND_LIBRARY(STXXL_LIBRARY - NAMES stxxl stxxl_debug - HINTS - $ENV{STXXL_DIR} - PATH_SUFFIXES lib64 lib - PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /opt/local - /opt -) - -INCLUDE(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set STXXL_FOUND to TRUE if -# all listed variables are TRUE -FIND_PACKAGE_HANDLE_STANDARD_ARGS(STXXL DEFAULT_MSG STXXL_LIBRARY STXXL_INCLUDE_DIR) - -IF( NOT STXXL_FIND_QUIETLY ) - IF( STXXL_FOUND ) - MESSAGE(STATUS "Found STXXL: ${STXXL_LIBRARY}" ) - ENDIF() -ENDIF() - -MARK_AS_ADVANCED(STXXL_INCLUDE_DIR STXXL_LIBRARY) diff --git a/data/driving_side.geojson b/data/driving_side.geojson index 6ae14ceac..9dc8e7652 100644 --- a/data/driving_side.geojson +++ b/data/driving_side.geojson @@ -11,348 +11,288 @@ "coordinates": [ [ [ - 159.78515624999997, - -21.943045533438166 + 113.573, + 22.186 ], [ - 163.828125, - -7.710991655433217 + 114, + 22.5 ], [ - 154.8632597923279, - 1.230288366531784 + 114.05534, + 22.503 ], [ - 130.49558401107788, - 5.900103419579043 + 114.0595, + 22.51422 ], [ - 122.8710722923279, - 4.5653879923552605 + 114.07345, + 22.51934 ], [ - 120.7177519798279, - 5.315150278601077 + 114.0786, + 22.53012 ], [ - 120.5749297142029, - 5.697896578851922 + 114.08512, + 22.53228 ], [ - 120.3277373313904, - 5.531158894311544 + 114.09034, + 22.53717 ], [ - 119.5312285423279, - 5.484682580410128 + 114.09611, + 22.53486 ], [ - 118.9105010032654, - 7.275207196686071 + 114.10602, + 22.53472 ], [ - 117.7734160423279, - 7.710906600862094 + 114.1115, + 22.52929 ], [ - 102.6562285423279, - 8.059144644195047 + 114.11522, + 22.5308 ], [ - 102.91990041732791, - 11.652152342254183 + 114.11649, + 22.53418 ], [ - 102.90481567382812, - 11.766536924462363 + 114.11979, + 22.53511 ], [ - 102.82928466796874, - 11.884821555123915 + 114.1244, + 22.5393 ], [ - 102.7716064453125, - 12.052751072179356 + 114.12729, + 22.53947 ], [ - 102.70843505859375, - 12.181649710171742 + 114.13018, + 22.54132 ], [ - 102.72628784179688, - 12.352075625709524 + 114.13807, + 22.5432 ], [ - 102.78533935546875, - 12.412436216375175 + 114.14429, + 22.54176 ], [ - 102.56423950195311, - 12.656417878339736 + 114.14441, + 22.54114 ], [ - 102.49008178710938, - 12.981809528732812 + 114.14846, + 22.54179 ], [ - 102.381591796875, - 13.18914225554674 + 114.14855, + 22.54397 ], [ - 102.34725952148438, - 13.352209751204438 + 114.15042, + 22.54593 ], [ - 102.37058401107791, - 13.539117223464746 + 114.14964, + 22.54954 ], [ - 103.11765432357788, - 14.243003670396702 + 114.15166, + 22.55168 ], [ - 103.53515625, - 14.424040444354699 + 114.15192, + 22.55438 ], [ - 104.1064453125, - 14.370833973406821 + 114.15642, + 22.55495 ], [ - 105.1391386985779, - 14.285594123582854 + 114.15841, + 22.55909 ], [ - 105.5126953125, - 14.530415228007362 + 114.16032, + 22.56153 ], [ - 105.46875, - 15.114552871944115 + 114.16162, + 22.56187 ], [ - 105.6005859375, - 15.559544421458103 + 114.1634, + 22.55931 ], [ - 105.413818359375, - 16.003575733881327 + 114.16553, + 22.5593 ], [ - 105.062255859375, - 16.06692895745012 + 114.16733, + 22.56119 ], [ - 104.75463867187499, - 16.488764934242077 + 114.16934, + 22.56093 ], [ - 104.7656035423279, - 17.308605942846185 + 114.17061, + 22.5597 ], [ - 103.95261526107788, - 18.25013846381984 + 114.17702, + 22.56 ], [ - 103.2934355735779, - 18.3752976396967 + 114.17798, + 22.55546 ], [ - 102.67820119857791, - 17.85320841659695 + 114.18401, + 22.5552 ], [ - 102.1069121360779, - 18.166648857895012 + 114.18673, + 22.55468 ], [ - 101.0302519798279, - 17.56016467227813 + 114.1878, + 22.55545 ], [ - 101.326904296875, - 18.999802829053262 + 114.18979, + 22.55446 ], [ - 101.2060546875, - 19.611543503814232 + 114.1955, + 22.55564 ], [ - 100.7666015625, - 19.476950206488414 + 114.19674, + 22.55691 ], [ - 100.404052734375, - 19.72534224805787 + 114.20005, + 22.55717 ], [ - 100.546875, - 20.148784632164155 + 114.20376, + 22.55623 ], [ - 100.14038085937499, - 20.396123272467616 + 114.20884, + 22.55672 ], [ - 99.052734375, - 20.16941122761028 + 114.22438, + 22.55055 ], [ - 99.03076171875, - 19.735683578629445 + 114.2264, + 22.5476 ], [ - 98.59130859375, - 19.663280219987662 + 114.22545, + 22.54528 ], [ - 98.0419921875, - 19.797717490704738 + 114.22661, + 22.54339 ], [ - 97.75634765625, - 19.155546551403607 + 114.32, + 22.576 ], [ - 97.3828125, - 18.510865709091377 + 114.45, + 22.43 ], [ - 97.9541015625, - 17.612610761099077 + 114.45, + 22.14 ], [ - 98.89892578125, - 16.351767849269347 + 113.9, + 22.14 ], [ - 98.59130859375, - 16.014136002085912 + 113.75, + 22.22 ], [ - 98.5693359375, - 15.368949896534705 + 113.553, + 22.095 ], [ - 98.19580078125, - 15.231189704767242 + 113.54678, + 22.1207 ], [ - 98.382568359375, - 14.732386081418454 + 113.5456, + 22.1207 ], [ - 99.16257619857791, - 13.560478307112557 + 113.54076, + 22.12373 ], [ - 99.58142995834352, - 11.918331814112104 + 113.54016, + 22.13618 ], [ - 99.64872121810917, - 11.805501728366703 + 113.54701, + 22.13651 ], [ - 99.64111447334291, - 11.789853455395441 + 113.5475, + 22.14583 ], [ - 99.64106082916263, - 11.788918731650105 + 113.52456, + 22.17978 ], [ - 99.64245557785038, - 11.778699577993807 + 113.53623, + 22.20191 ], [ - 99.64048147201542, - 11.753071252426949 + 113.53299, + 22.21232 ], [ - 99.28342580795291, - 11.210712717455792 + 113.53497, + 22.21351 ], [ - 99.02662038803102, - 10.888581271040938 + 113.53735, + 22.21377 ], [ - 98.80277395248417, - 10.711866898462292 + 113.54156, + 22.21315 ], [ - 98.80826711654666, - 10.521547650627832 + 113.54385, + 22.21709 ], [ - 98.75196218490605, - 10.381094932405219 + 113.55849, + 22.21565 ], [ - 98.67231130599978, - 10.18246297848021 - ], - [ - 98.57343435287478, - 9.971534577962496 - ], - [ - 98.48417043685916, - 9.955303622625479 - ], - [ - 98.34615468978888, - 9.917428257015372 - ], - [ - 98.27405691146853, - 9.575000723804276 - ], - [ - 97.960946559906, - 9.493741474485672 - ], - [ - 97.13147878646853, - 9.786183416123238 - ], - [ - 92.56116628646856, - 15.147674168282906 - ], - [ - 90.71546316146853, - 0.759386240320313 - ], - [ - 109.34827566146853, - -15.46296618728526 - ], - [ - 107.23890066146849, - -38.418107244191766 - ], - [ - 130.4420256614686, - -41.64727816306098 - ], - [ - 160.67640066146856, - -53.96175413197849 - ], - [ - 185.81311941146856, - -48.23109085729586 - ], - [ - 184.93421316146848, - -33.73235247373941 - ], - [ - 159.78515624999997, - -21.943045533438166 + 113.573, + 22.186 ] ] ] @@ -368,56 +308,24 @@ "coordinates": [ [ [ - 147.15087890625003, - 44.13885576756881 + -75, + 18 ], [ - 145.52490234375, - 43.50075243569041 + -80, + 20.5 ], [ - 145.20629882812497, - 43.8186748554532 + -83, + 19 ], [ - 145.70068359375, - 44.55916341529182 + -77, + 16 ], [ - 141.48193359375, - 45.836454050187726 - ], - [ - 135.0439453125, - 37.71859032558816 - ], - [ - 127.88085937500001, - 32.565333160841035 - ], - [ - 125.61767578124999, - 27.196014383173306 - ], - [ - 122.54150390625, - 24.70691524106633 - ], - [ - 123.64013671874999, - 22.411028521558706 - ], - [ - 131.66015625, - 25.284437746983055 - ], - [ - 141.36108398437503, - 33.394759218577995 - ], - [ - 147.15087890625003, - 44.13885576756881 + -75, + 18 ] ] ] @@ -433,48 +341,440 @@ "coordinates": [ [ [ - 1.9116210937499998, - 61.19621314083867 + -64.33594, + 32.86113 ], [ - -2.0654296875, - 61.990587736204105 + -79.39819, + 27.21067 ], [ - -12.54638671875, - 55.94919982336746 + -80.63965, + 23.71998 ], [ - -12.260742187500002, - 50.62507306341437 + -73.39966, + 20.40642 ], [ - -1.9445800781249998, - 48.93693495409401 + -65.1709, + 19.20743 ], [ - -1.768798828125, - 49.210420445650286 + -65.09399, + 16.23577 ], [ - -2.142333984375, - 49.50380954152213 + -59.13391, + 16.80454 ], [ - -1.966552734375, - 49.930008124606886 + -62.64404, + 15.16228 ], [ - -0.3515625, - 49.69606181911566 + -59.43054, + 14.85985 ], [ - 2.5048828125, - 51.6180165487737 + -62.83081, + 13.64599 ], [ - 1.9116210937499998, - 61.19621314083867 + -61.80359, + 10.73752 + ], + [ + -62.08649, + 10.04729 + ], + [ + -61.06201, + 9.85522 + ], + [ + -59.81369, + 8.31274 + ], + [ + -59.8027, + 8.27469 + ], + [ + -59.83498, + 8.22712 + ], + [ + -59.94141, + 8.21149 + ], + [ + -59.99771, + 8.15576 + ], + [ + -59.97986, + 8.13265 + ], + [ + -59.99771, + 8.12041 + ], + [ + -60.00183, + 8.07147 + ], + [ + -60.05127, + 8.02524 + ], + [ + -60.09933, + 8.03747 + ], + [ + -60.12268, + 8.02388 + ], + [ + -60.14053, + 7.98988 + ], + [ + -60.36163, + 7.83345 + ], + [ + -60.53467, + 7.81713 + ], + [ + -60.5896, + 7.6375 + ], + [ + -60.72144, + 7.54493 + ], + [ + -60.5896, + 7.31888 + ], + [ + -60.63904, + 7.24532 + ], + [ + -60.54703, + 7.12542 + ], + [ + -60.46875, + 7.20309 + ], + [ + -60.37262, + 7.18401 + ], + [ + -60.29984, + 7.1445 + ], + [ + -60.2916, + 7.06819 + ], + [ + -60.39871, + 6.95097 + ], + [ + -60.66513, + 6.83235 + ], + [ + -60.71869, + 6.75053 + ], + [ + -60.91232, + 6.81735 + ], + [ + -60.94254, + 6.72053 + ], + [ + -61.14441, + 6.72326 + ], + [ + -61.23093, + 6.5773 + ], + [ + -61.1554, + 6.45314 + ], + [ + -61.14441, + 6.20199 + ], + [ + -61.39709, + 5.95619 + ], + [ + -60.71045, + 5.20036 + ], + [ + -60.21606, + 5.23319 + ], + [ + -59.99634, + 5.06906 + ], + [ + -60.13916, + 4.51071 + ], + [ + -59.69971, + 4.40118 + ], + [ + -59.5459, + 3.93002 + ], + [ + -59.87549, + 3.56825 + ], + [ + -59.7876, + 3.37086 + ], + [ + -60.01831, + 2.83332 + ], + [ + -59.90845, + 2.38335 + ], + [ + -59.69971, + 2.2626 + ], + [ + -59.77661, + 1.87833 + ], + [ + -59.65302, + 1.85087 + ], + [ + -59.69147, + 1.75754 + ], + [ + -59.61456, + 1.71361 + ], + [ + -59.55139, + 1.73283 + ], + [ + -59.36188, + 1.49123 + ], + [ + -59.26575, + 1.39238 + ], + [ + -58.92242, + 1.30726 + ], + [ + -58.83728, + 1.17271 + ], + [ + -58.71918, + 1.23037 + ], + [ + -58.71094, + 1.29902 + ], + [ + -58.49121, + 1.26058 + ], + [ + -58.461, + 1.37591 + ], + [ + -58.50494, + 1.38689 + ], + [ + -58.51044, + 1.46102 + ], + [ + -58.38135, + 1.4775 + ], + [ + -58.32642, + 1.57359 + ], + [ + -58.00507, + 1.49946 + ], + [ + -57.99133, + 1.65321 + ], + [ + -57.79907, + 1.69165 + ], + [ + -57.70844, + 1.71087 + ], + [ + -57.54364, + 1.68341 + ], + [ + -57.41455, + 1.94421 + ], + [ + -57.10693, + 1.97715 + ], + [ + -56.8103, + 1.85636 + ], + [ + -56.48071, + 1.92225 + ], + [ + -55.90942, + 1.81244 + ], + [ + -55.90942, + 2.04302 + ], + [ + -56.14014, + 2.26534 + ], + [ + -55.94788, + 2.53701 + ], + [ + -55.70892, + 2.39981 + ], + [ + -55.37933, + 2.43274 + ], + [ + -55.19257, + 2.53976 + ], + [ + -54.98108, + 2.57268 + ], + [ + -54.88495, + 2.43548 + ], + [ + -54.71191, + 2.46293 + ], + [ + -54.69543, + 2.34767 + ], + [ + -54.58832, + 2.32846 + ], + [ + -54.43451, + 2.43548 + ], + [ + -54.20654, + 2.76748 + ], + [ + -54.17358, + 3.12955 + ], + [ + -53.96484, + 3.57921 + ], + [ + -54.33838, + 4.00674 + ], + [ + -54.44412, + 4.52577 + ], + [ + -54.46884, + 4.91036 + ], + [ + -54.36653, + 5.13061 + ], + [ + -54.27727, + 5.26191 + ], + [ + -54.19968, + 5.3084 + ], + [ + -54.01222, + 5.54457 + ], + [ + -54.0239, + 5.64605 + ], + [ + -53.86322, + 5.94936 + ], + [ + -64.33594, + 32.86113 ] ] ] @@ -490,368 +790,736 @@ "coordinates": [ [ [ - 92.39501953125, - 21.514406720030294 + -14.5, + -6 ], [ - 92.74658203125, - 21.248422235627014 + 11.79657, + -17.27197 ], [ - 92.65869140625, - 22.06527806776582 + 12.03415, + -17.14866 ], [ - 93.1640625, - 22.30942584120019 + 12.38159, + -17.22213 ], [ - 93.2080078125, - 23.059516273509303 + 12.58484, + -17.22476 ], [ - 93.36181640625, - 24.066528197726857 + 13.01193, + -16.97405 ], [ - 94.21875, - 23.905926927314724 + 13.24951, + -17.00098 ], [ - 94.76806640624999, - 25.06569718553588 + 13.38135, + -16.98522 ], [ - 94.52636718749999, - 25.284437746983055 + 13.93341, + -17.38734 ], [ - 95.16357421875, - 26.13571361317392 + 18.42476, + -17.38996 ], [ - 95.1416015625, - 26.56887654795065 + 18.47763, + -17.46857 ], [ - 95.97656249999999, - 27.059125784374068 + 18.62663, + -17.64599 ], [ - 96.8115234375, - 27.332735136859146 + 18.79211, + -17.76177 ], [ - 97.18505859374999, - 27.15692045688088 + 18.92944, + -17.82061 ], [ - 96.92138671875, - 27.6251403350933 + 19.33044, + -17.84806 ], [ - 97.36083984375, - 27.955591004642553 + 19.66278, + -17.8644 ], [ - 97.3828125, - 28.285033294640684 + 19.74792, + -17.90557 ], [ - 96.7236328125, - 28.5941685062326 + 19.85161, + -17.87486 ], [ - 95.97656249999999, - 29.401319510041485 + 20.10361, + -17.90296 ], [ - 95.29541015625, - 29.075375179558346 + 20.18394, + -17.88401 ], [ - 94.7021484375, - 29.267232865200878 + 20.34737, + -17.88466 ], [ - 92.10937499999999, - 27.800209937418252 + 20.44693, + -17.91733 ], [ - 91.669921875, - 27.858503954841247 + 20.51697, + -17.96698 ], [ - 91.1865234375, - 28.110748760633534 + 20.83008, + -18.03032 ], [ - 90.4833984375, - 28.07198030177986 + 20.95711, + -17.97285 ], [ - 90.52734374999999, - 28.246327971048842 + 21.16997, + -17.93497 ], [ - 89.75830078125, - 28.323724553546015 + 21.42677, + -18.0264 ], [ - 88.9013671875, - 27.31321389856826 + 23.45032, + -17.63879 ], [ - 88.9013671875, - 27.89734922968426 + 22.00012, + -16.38866 ], [ - 88.5498046875, - 28.130127737874005 + 21.99944, + -13.00523 ], [ - 87.29736328125, - 27.877928333679495 + 24.03809, + -12.99118 ], [ - 85.14404296875, - 28.536274512989916 + 24.03809, + -10.91962 ], [ - 82.001953125, - 30.35391637229704 + 24.43359, + -11.09217 ], [ - 81.45263671875, - 30.41078179084589 + 24.45557, + -11.48002 ], [ - 81.18896484375, - 30.031055426540206 + 25.37842, + -11.19996 ], [ - 79.40917968749999, - 31.090574094954192 + 25.42236, + -11.60919 ], [ - 78.75, - 31.555133721172034 + 26.96045, + -11.97484 ], [ - 78.5357666015625, - 32.60698915452777 + 27.18018, + -11.60919 ], [ - 79.002685546875, - 32.33355894864106 + 28.125, + -12.42048 ], [ - 79.4146728515625, - 32.532920675187846 + 29.11377, + -13.36824 ], [ - 79.21142578125, - 33.18813395605041 + 29.1687, + -13.43771 ], [ - 78.8104248046875, - 33.829356907739296 + 29.55872, + -13.19716 ], [ - 79.024658203125, - 34.30260622622907 + 29.68506, + -13.2239 ], [ - 78.0908203125, - 34.912962495216966 + 29.62463, + -13.41099 ], [ - 78.134765625, - 35.505400093441324 + 29.80591, + -13.44305 ], [ - 76.761474609375, - 35.65729624809628 + 29.81415, + -12.14809 ], [ - 76.552734375, - 35.92464453144099 + 29.31152, + -12.55456 ], [ - 76.0693359375, - 35.97800618085566 + 28.41064, + -11.78133 ], [ - 75.69580078125, - 36.80928470205937 + 28.63037, + -10.70379 ], [ - 74.55322265625, - 37.10776507118514 + 28.65234, + -9.73071 ], [ - 73.10302734375, - 36.86204269508728 + 28.37219, + -9.24309 ], [ - 71.56494140625, - 36.38591277287651 + 28.89748, + -8.47916 ], [ - 71.2353515625, - 36.01356058518153 + 30.78644, + -8.26857 ], [ - 71.5869140625, - 35.15584570226544 + 29.39941, + -6.05316 ], [ - 70.9716796875, - 34.470335121217474 + 29.4873, + -4.45595 ], [ - 71.12548828125, - 34.27083595165 + 29.75922, + -4.46759 ], [ - 70.927734375, - 33.99802726234877 + 29.81415, + -4.36421 ], [ - 69.85107421874999, - 34.016241889667015 + 29.88007, + -4.36832 ], [ - 70.3125, - 33.32134852669881 + 30.04074, + -4.26699 ], [ - 69.521484375, - 33.063924198120645 + 30.07919, + -4.1629 ], [ - 69.23583984375, - 31.970803930433096 + 30.18356, + -4.08311 ], [ - 68.84033203125, - 31.541089879585808 + 30.1918, + -4.05126 ], [ - 68.48876953125, - 31.80289258670676 + 30.21566, + -4.04595 ], [ - 68.13720703125, - 31.82156451492074 + 30.22923, + -4.01136 ], [ - 67.5439453125, - 31.541089879585808 + 30.21326, + -3.99612 ], [ - 67.82958984375, - 31.372399104880525 + 30.25978, + -3.88755 ], [ - 67.12646484375, - 31.22219703210317 + 30.29274, + -3.86288 ], [ - 66.81884765625, - 31.297327991404266 + 30.34424, + -3.77245 ], [ - 66.4453125, - 30.939924331023445 + 30.39848, + -3.79095 ], [ - 66.3134765625, - 29.859701442126756 + 30.40878, + -3.76765 ], [ - 65.126953125, - 29.57345707301757 + 30.39548, + -3.7304 ], [ - 64.44580078125, - 29.592565403314087 + 30.39054, + -3.72821 ], [ - 64.072265625, - 29.401319510041485 + 30.3896, + -3.71918 ], [ - 62.4462890625, - 29.420460341013133 + 30.39093, + -3.7101 ], [ - 60.88623046875001, - 29.84064389983441 + 30.39514, + -3.70444 ], [ - 61.36962890625001, - 29.34387539941801 + 30.42028, + -3.64963 ], [ - 61.58935546875, - 28.9023972285585 + 30.46886, + -3.53501 ], [ - 61.89697265624999, - 28.51696944040106 + 30.67108, + -3.41335 ], [ - 62.77587890625, - 28.246327971048842 + 30.63297, + -3.34892 ], [ - 62.7978515625, - 27.254629577800063 + 30.84206, + -3.25535 ], [ - 63.25927734375, - 27.235094607795503 + 30.84549, + -3.16108 ], [ - 63.19335937499999, - 26.686729520004036 + 30.83485, + -3.09698 ], [ - 62.2705078125, - 26.509904531413927 + 30.7933, + -3.06235 ], [ - 62.24853515624999, - 26.31311263768267 + 30.82111, + -3.02258 ], [ - 61.85302734375001, - 26.27371402440643 + 30.84515, + -2.9739 ], [ - 61.58935546875, - 25.224820176765036 + 30.74764, + -2.99618 ], [ - 74.970703125, - 7.580327791330129 + 30.7037, + -2.97013 ], [ - 67.6318359375, - 4.521666342614804 + 30.66422, + -2.98967 ], [ - 72.4658203125, - -2.986927393334863 + 30.57632, + -2.90738 ], [ - 85.86914062500001, - 5.5941182188847876 + 30.49393, + -2.94441 ], [ - 92.39501953125, - 21.514406720030294 + 30.41016, + -2.87172 + ], + [ + 30.52002, + -2.39432 + ], + [ + 30.77545, + -2.38883 + ], + [ + 30.8606, + -2.31199 + ], + [ + 30.84961, + -2.19398 + ], + [ + 30.89081, + -2.07322 + ], + [ + 30.81116, + -1.96068 + ], + [ + 30.83862, + -1.6587 + ], + [ + 30.73425, + -1.4418 + ], + [ + 30.56259, + -1.33884 + ], + [ + 30.4541, + -1.05737 + ], + [ + 30.35797, + -1.06287 + ], + [ + 30.34149, + -1.13152 + ], + [ + 30.16571, + -1.34296 + ], + [ + 29.91852, + -1.48024 + ], + [ + 29.83887, + -1.31824 + ], + [ + 29.58344, + -1.39238 + ], + [ + 29.729, + 0.05493 + ], + [ + 29.96796, + 0.5136 + ], + [ + 29.9707, + 0.8569 + ], + [ + 30.22339, + 0.92281 + ], + [ + 30.24536, + 1.15349 + ], + [ + 30.47745, + 1.20772 + ], + [ + 31.30966, + 2.15693 + ], + [ + 31.20255, + 2.22211 + ], + [ + 31.20255, + 2.29278 + ], + [ + 31.16409, + 2.27906 + ], + [ + 31.13937, + 2.28318 + ], + [ + 31.13113, + 2.26534 + ], + [ + 31.07826, + 2.30033 + ], + [ + 31.0714, + 2.34767 + ], + [ + 31.00479, + 2.4005 + ], + [ + 30.97183, + 2.40461 + ], + [ + 30.94711, + 2.38746 + ], + [ + 30.94849, + 2.36276 + ], + [ + 30.9375, + 2.33532 + ], + [ + 30.88531, + 2.34012 + ], + [ + 30.83038, + 2.42176 + ], + [ + 30.74112, + 2.43274 + ], + [ + 30.76035, + 2.5864 + ], + [ + 30.90179, + 2.88132 + ], + [ + 30.76447, + 3.04178 + ], + [ + 30.93613, + 3.40239 + ], + [ + 30.94059, + 3.50588 + ], + [ + 30.85236, + 3.48601 + ], + [ + 30.90866, + 3.5936 + ], + [ + 30.95055, + 3.63918 + ], + [ + 30.94677, + 3.65391 + ], + [ + 30.9866, + 3.70187 + ], + [ + 31.00582, + 3.70701 + ], + [ + 31.02058, + 3.69708 + ], + [ + 31.16547, + 3.7954 + ], + [ + 31.28838, + 3.79643 + ], + [ + 31.52699, + 3.66282 + ], + [ + 31.7038, + 3.72449 + ], + [ + 31.82671, + 3.82794 + ], + [ + 31.96198, + 3.65596 + ], + [ + 31.95854, + 3.57099 + ], + [ + 32.04987, + 3.59155 + ], + [ + 32.07733, + 3.57099 + ], + [ + 32.0842, + 3.53672 + ], + [ + 32.20093, + 3.50657 + ], + [ + 32.21672, + 3.56448 + ], + [ + 32.19578, + 3.59977 + ], + [ + 32.41516, + 3.74504 + ], + [ + 32.72055, + 3.76782 + ], + [ + 32.89307, + 3.81219 + ], + [ + 33.02782, + 3.89371 + ], + [ + 33.18146, + 3.7793 + ], + [ + 33.51173, + 3.75258 + ], + [ + 33.98758, + 4.23309 + ], + [ + 34.05762, + 4.28342 + ], + [ + 34.38721, + 4.61065 + ], + [ + 35.94452, + 4.62023 + ], + [ + 35.95688, + 4.53467 + ], + [ + 36.04134, + 4.44568 + ], + [ + 36.89621, + 4.4491 + ], + [ + 38.14728, + 3.62992 + ], + [ + 38.55927, + 3.62033 + ], + [ + 38.92181, + 3.51068 + ], + [ + 39.56039, + 3.43392 + ], + [ + 39.87076, + 3.87522 + ], + [ + 40.76752, + 4.28753 + ], + [ + 41.16371, + 3.94372 + ], + [ + 41.89774, + 3.97797 + ], + [ + 41.31271, + 3.14463 + ], + [ + 40.98896, + 2.82869 + ], + [ + 40.99548, + -0.84042 + ], + [ + 41.7, + -1.8 + ], + [ + 41.7, + -49 + ], + [ + -27, + -60 + ], + [ + -65.7, + -52.5 + ], + [ + -14.5, + -6 ] ] ] @@ -867,272 +1535,20 @@ "coordinates": [ [ [ - 43.57177734375001, - -4.390228926463384 + 31.33301, + 35.47856 ], [ - 41.0009765625, - -0.8129610018708315 + 33.0249, + 33.75175 ], [ - 40.97900390625, - 2.7235830833483856 + 35.44189, + 36.02245 ], [ - 41.90185546875, - 3.995780512963038 - ], - [ - 41.15478515624999, - 3.9738609758391017 - ], - [ - 40.75927734375, - 4.3464112753331925 - ], - [ - 39.814453125, - 3.8423316311549156 - ], - [ - 39.55078125, - 3.447624666646865 - ], - [ - 38.14453125, - 3.6230713262356864 - ], - [ - 36.9580078125, - 4.477856485570586 - ], - [ - 35.9912109375, - 4.477856485570586 - ], - [ - 35.947265625, - 4.696879026871425 - ], - [ - 34.43115234375, - 4.631179340411012 - ], - [ - 33.94775390625, - 4.171115454867424 - ], - [ - 34.43115234375, - 3.6449998008920375 - ], - [ - 32.01416015625, - 3.601142320158735 - ], - [ - 31.81640625, - 3.8642546157214084 - ], - [ - 30.871582031249996, - 3.6230713262356864 - ], - [ - 30.78369140625, - 2.3943223575350774 - ], - [ - 31.289062500000004, - 2.152813583128846 - ], - [ - 30.454101562499996, - 1.1644706071806057 - ], - [ - 29.860839843749996, - 0.4833927027896987 - ], - [ - 29.553222656249996, - -1.2962761196418089 - ], - [ - 30.454101562499996, - -1.0546279422758742 - ], - [ - 30.91552734375, - -1.8014609294680355 - ], - [ - 30.871582031249996, - -2.3943223575350774 - ], - [ - 30.563964843750004, - -2.4162756547063857 - ], - [ - 30.43212890625, - -2.921097018708451 - ], - [ - 30.827636718749996, - -2.921097018708451 - ], - [ - 30.827636718749996, - -3.2502085616531686 - ], - [ - 30.322265625000004, - -3.864254615721396 - ], - [ - 29.970703124999996, - -4.3245014930191905 - ], - [ - 29.443359375, - -4.412136788910181 - ], - [ - 29.355468750000004, - -4.872047700241915 - ], - [ - 29.663085937499996, - -5.7690358661221355 - ], - [ - 29.729003906249996, - -6.620957270326323 - ], - [ - 31.09130859375, - -8.581021215641842 - ], - [ - 28.894042968749996, - -8.472372282909127 - ], - [ - 28.410644531249996, - -9.297306856327596 - ], - [ - 28.67431640625, - -9.925565912405494 - ], - [ - 28.652343749999996, - -10.703791711680724 - ], - [ - 28.36669921875, - -11.695272733029402 - ], - [ - 29.02587890625, - -12.340001834116316 - ], - [ - 29.77294921875, - -12.146745814539685 - ], - [ - 29.838867187500004, - -13.432366575813747 - ], - [ - 29.597167968750004, - -13.17577122442339 - ], - [ - 28.54248046875, - -12.790374787613588 - ], - [ - 27.9052734375, - -12.254127737657369 - ], - [ - 27.0703125, - -11.630715737981474 - ], - [ - 26.69677734375, - -11.953349393643416 - ], - [ - 25.356445312499996, - -11.566143767762844 - ], - [ - 25.356445312499996, - -11.199956869621811 - ], - [ - 24.41162109375, - -11.372338792141125 - ], - [ - 24.0380859375, - -10.898042159726009 - ], - [ - 23.994140624999996, - -12.961735843534306 - ], - [ - 21.97265625, - -13.025965926333539 - ], - [ - 21.9287109375, - -16.13026201203474 - ], - [ - 23.48876953125, - -17.644022027872712 - ], - [ - 21.4013671875, - -18.041421221891937 - ], - [ - 18.45703125, - -17.392579271057766 - ], - [ - 14.23828125, - -17.392579271057766 - ], - [ - 13.359375, - -16.951724234434423 - ], - [ - 12.5244140625, - -17.224758206624628 - ], - [ - 9.77783203125, - -17.245744208007117 - ], - [ - 13.359375, - -38.54816542304657 - ], - [ - 36.03515625, - -34.74161249883172 - ], - [ - 43.57177734375001, - -4.390228926463384 + 31.33301, + 35.47856 ] ] ] @@ -1148,24 +1564,20 @@ "coordinates": [ [ [ - 56.35986328125, - -21.125497636606266 + 14, + 36.5 ], [ - 59.23828124999999, - -21.125497636606266 + 15, + 36 ], [ - 59.23828124999999, - -19.642587534013032 + 14, + 35 ], [ - 56.35986328125, - -19.642587534013032 - ], - [ - 56.35986328125, - -21.125497636606266 + 14, + 36.5 ] ] ] @@ -1181,24 +1593,28 @@ "coordinates": [ [ [ - 70.42236328125, - -7.896029593273104 + 0, + 62 ], [ - 73.2623291015625, - -7.896029593273104 + 2.5, + 51.3 ], [ - 73.2623291015625, - -5.78543165536185 + -2, + 50 ], [ - 70.42236328125, - -5.78543165536185 + -1.9, + 49 ], [ - 70.42236328125, - -7.896029593273104 + -20, + 53 + ], + [ + 0, + 62 ] ] ] @@ -1214,24 +1630,1408 @@ "coordinates": [ [ [ - 49.39453125, - -8.146242825034385 + 180, + -35 ], [ - 60.6005859375, - -8.146242825034385 + 161, + -19 ], [ - 60.6005859375, - -2.67968661580376 + 167, + -12 ], [ - 49.39453125, - -2.67968661580376 + 180, + -22 ], [ - 49.39453125, - -8.146242825034385 + 180, + 4 + ], + [ + 170, + 3.7 + ], + [ + 127, + 5.7 + ], + [ + 118, + 2.7 + ], + [ + 119.5, + 5.4 + ], + [ + 117.2, + 7.5 + ], + [ + 102.6, + 8 + ], + [ + 102.9158, + 11.74099 + ], + [ + 102.76268, + 12.07357 + ], + [ + 102.70226, + 12.17158 + ], + [ + 102.74139, + 12.46474 + ], + [ + 102.53128, + 12.68857 + ], + [ + 102.49557, + 12.9256 + ], + [ + 102.49763, + 13.0064 + ], + [ + 102.4597, + 13.08199 + ], + [ + 102.43412, + 13.09026 + ], + [ + 102.39155, + 13.16407 + ], + [ + 102.35481, + 13.29341 + ], + [ + 102.35893, + 13.30945 + ], + [ + 102.34503, + 13.34837 + ], + [ + 102.35928, + 13.39797 + ], + [ + 102.3567, + 13.48095 + ], + [ + 102.36168, + 13.50582 + ], + [ + 102.33559, + 13.53787 + ], + [ + 102.33971, + 13.56023 + ], + [ + 102.35498, + 13.5649 + ], + [ + 102.36511, + 13.5785 + ], + [ + 102.40047, + 13.5679 + ], + [ + 102.42537, + 13.56891 + ], + [ + 102.44614, + 13.56123 + ], + [ + 102.48047, + 13.57091 + ], + [ + 102.53849, + 13.56757 + ], + [ + 102.5699, + 13.58526 + ], + [ + 102.57806, + 13.60486 + ], + [ + 102.62501, + 13.60845 + ], + [ + 102.62132, + 13.61295 + ], + [ + 102.60767, + 13.61562 + ], + [ + 102.57231, + 13.63331 + ], + [ + 102.56922, + 13.64082 + ], + [ + 102.54879, + 13.658 + ], + [ + 102.56252, + 13.68552 + ], + [ + 102.5972, + 13.70803 + ], + [ + 102.67084, + 13.74472 + ], + [ + 102.68818, + 13.75172 + ], + [ + 102.7014, + 13.7684 + ], + [ + 102.73161, + 13.77082 + ], + [ + 102.76543, + 13.85541 + ], + [ + 102.78397, + 13.93207 + ], + [ + 102.80388, + 13.94406 + ], + [ + 102.81607, + 13.96639 + ], + [ + 102.90705, + 14.02119 + ], + [ + 102.89726, + 14.0535 + ], + [ + 102.90095, + 14.0838 + ], + [ + 102.92421, + 14.10744 + ], + [ + 102.92378, + 14.12838 + ], + [ + 102.94147, + 14.15035 + ], + [ + 102.92953, + 14.17952 + ], + [ + 103.17535, + 14.33774 + ], + [ + 103.19939, + 14.32992 + ], + [ + 103.68553, + 14.44 + ], + [ + 103.94508, + 14.34157 + ], + [ + 104.05756, + 14.34589 + ], + [ + 104.06636, + 14.3419 + ], + [ + 104.26025, + 14.37749 + ], + [ + 104.50058, + 14.36984 + ], + [ + 104.57817, + 14.36019 + ], + [ + 104.6422, + 14.42387 + ], + [ + 104.66632, + 14.40234 + ], + [ + 104.68357, + 14.39877 + ], + [ + 104.71138, + 14.43169 + ], + [ + 104.72305, + 14.42188 + ], + [ + 104.71687, + 14.40043 + ], + [ + 104.75344, + 14.40459 + ], + [ + 104.80408, + 14.43867 + ], + [ + 104.83429, + 14.41573 + ], + [ + 104.99239, + 14.3838 + ], + [ + 105.05402, + 14.19783 + ], + [ + 105.47905, + 14.49186 + ], + [ + 105.60883, + 15.0005 + ], + [ + 105.46703, + 15.13005 + ], + [ + 105.48866, + 15.20237 + ], + [ + 105.59269, + 15.2716 + ], + [ + 105.58617, + 15.32823 + ], + [ + 105.50308, + 15.31912 + ], + [ + 105.46703, + 15.33948 + ], + [ + 105.49175, + 15.37921 + ], + [ + 105.59372, + 15.42869 + ], + [ + 105.59372, + 15.50927 + ], + [ + 105.60986, + 15.54871 + ], + [ + 105.62616, + 15.56492 + ], + [ + 105.62702, + 15.59129 + ], + [ + 105.63518, + 15.62742 + ], + [ + 105.63612, + 15.66056 + ], + [ + 105.5975, + 15.72088 + ], + [ + 105.49965, + 15.76681 + ], + [ + 105.46291, + 15.74517 + ], + [ + 105.43819, + 15.75459 + ], + [ + 105.40489, + 15.79424 + ], + [ + 105.34241, + 15.92039 + ], + [ + 105.37811, + 15.98344 + ], + [ + 105.39167, + 15.99136 + ], + [ + 105.41931, + 15.98608 + ], + [ + 105.42652, + 15.99764 + ], + [ + 105.41468, + 16.01661 + ], + [ + 105.21263, + 16.05076 + ], + [ + 105.04955, + 16.10552 + ], + [ + 105.01316, + 16.24401 + ], + [ + 104.88235, + 16.37812 + ], + [ + 104.8391, + 16.45782 + ], + [ + 104.77936, + 16.49041 + ], + [ + 104.73919, + 16.53287 + ], + [ + 104.74228, + 16.62205 + ], + [ + 104.76391, + 16.70953 + ], + [ + 104.73953, + 16.80323 + ], + [ + 104.76425, + 16.85088 + ], + [ + 104.73782, + 16.90968 + ], + [ + 104.744, + 17.0128 + ], + [ + 104.81266, + 17.21853 + ], + [ + 104.79841, + 17.39274 + ], + [ + 104.70348, + 17.52833 + ], + [ + 104.46384, + 17.65515 + ], + [ + 104.34368, + 17.83564 + ], + [ + 104.27776, + 17.8559 + ], + [ + 104.22661, + 17.98069 + ], + [ + 104.1116, + 18.10735 + ], + [ + 104.06525, + 18.21174 + ], + [ + 103.97392, + 18.33823 + ], + [ + 103.9286, + 18.33237 + ], + [ + 103.88809, + 18.29456 + ], + [ + 103.85582, + 18.28673 + ], + [ + 103.83659, + 18.32715 + ], + [ + 103.79128, + 18.3467 + ], + [ + 103.70201, + 18.34214 + ], + [ + 103.60931, + 18.40405 + ], + [ + 103.57292, + 18.40437 + ], + [ + 103.51593, + 18.42978 + ], + [ + 103.45963, + 18.42587 + ], + [ + 103.41568, + 18.44802 + ], + [ + 103.30479, + 18.43206 + ], + [ + 103.24265, + 18.37082 + ], + [ + 103.24333, + 18.34133 + ], + [ + 103.29123, + 18.32357 + ], + [ + 103.28899, + 18.29521 + ], + [ + 103.23595, + 18.28299 + ], + [ + 103.16608, + 18.25511 + ], + [ + 103.02429, + 17.98135 + ], + [ + 102.6535, + 17.83237 + ], + [ + 102.40631, + 17.99963 + ], + [ + 102.10968, + 18.22413 + ], + [ + 101.548, + 17.81538 + ], + [ + 101.30493, + 17.64991 + ], + [ + 101.14563, + 17.46595 + ], + [ + 100.95886, + 17.61654 + ], + [ + 101.01757, + 17.88858 + ], + [ + 101.18752, + 18.05121 + ], + [ + 101.16863, + 18.10409 + ], + [ + 101.18134, + 18.33595 + ], + [ + 101.08727, + 18.38287 + ], + [ + 101.05499, + 18.43988 + ], + [ + 101.23215, + 18.73015 + ], + [ + 101.35265, + 19.04524 + ], + [ + 101.25927, + 19.12733 + ], + [ + 101.2373, + 19.32637 + ], + [ + 101.25824, + 19.58438 + ], + [ + 101.11954, + 19.56836 + ], + [ + 101.08898, + 19.58777 + ], + [ + 101.08624, + 19.59715 + ], + [ + 101.03165, + 19.6185 + ], + [ + 100.89844, + 19.62125 + ], + [ + 100.77827, + 19.49249 + ], + [ + 100.63751, + 19.56432 + ], + [ + 100.58258, + 19.49313 + ], + [ + 100.47478, + 19.5944 + ], + [ + 100.42929, + 19.67152 + ], + [ + 100.43341, + 19.7024 + ], + [ + 100.4147, + 19.7255 + ], + [ + 100.40525, + 19.7646 + ], + [ + 100.43907, + 19.80345 + ], + [ + 100.45555, + 19.84843 + ], + [ + 100.50636, + 19.87264 + ], + [ + 100.51709, + 19.93027 + ], + [ + 100.58653, + 20.1599 + ], + [ + 100.56576, + 20.1757 + ], + [ + 100.54945, + 20.17473 + ], + [ + 100.52731, + 20.14379 + ], + [ + 100.51065, + 20.14895 + ], + [ + 100.48697, + 20.17956 + ], + [ + 100.46774, + 20.196 + ], + [ + 100.45246, + 20.20147 + ], + [ + 100.45521, + 20.22129 + ], + [ + 100.44783, + 20.23546 + ], + [ + 100.41607, + 20.25286 + ], + [ + 100.40594, + 20.28184 + ], + [ + 100.38397, + 20.31082 + ], + [ + 100.37556, + 20.35187 + ], + [ + 100.36165, + 20.35638 + ], + [ + 100.35736, + 20.37408 + ], + [ + 100.33195, + 20.39902 + ], + [ + 100.27805, + 20.40224 + ], + [ + 100.25917, + 20.39677 + ], + [ + 100.2475, + 20.37263 + ], + [ + 100.22535, + 20.35509 + ], + [ + 100.22346, + 20.31839 + ], + [ + 100.16579, + 20.29988 + ], + [ + 100.17162, + 20.24545 + ], + [ + 100.10845, + 20.25221 + ], + [ + 100.09266, + 20.2696 + ], + [ + 100.09798, + 20.31485 + ], + [ + 100.07961, + 20.3678 + ], + [ + 99.9567, + 20.46417 + ], + [ + 99.91636, + 20.44925 + ], + [ + 99.90765, + 20.44977 + ], + [ + 99.89121, + 20.44511 + ], + [ + 99.87276, + 20.44406 + ], + [ + 99.86212, + 20.44326 + ], + [ + 99.80186, + 20.33948 + ], + [ + 99.46472, + 20.3884 + ], + [ + 99.56085, + 20.20035 + ], + [ + 99.43691, + 20.08882 + ], + [ + 99.27727, + 20.11623 + ], + [ + 99.06921, + 20.1101 + ], + [ + 98.97789, + 19.74538 + ], + [ + 98.24387, + 19.68656 + ], + [ + 97.85934, + 19.57014 + ], + [ + 97.76733, + 18.57336 + ], + [ + 97.39655, + 18.47179 + ], + [ + 97.62451, + 18.30238 + ], + [ + 97.73849, + 17.97743 + ], + [ + 97.66502, + 17.87943 + ], + [ + 97.90947, + 17.56745 + ], + [ + 98.52951, + 16.82557 + ], + [ + 98.51303, + 16.69276 + ], + [ + 98.69293, + 16.26873 + ], + [ + 98.87421, + 16.43609 + ], + [ + 98.93394, + 16.3353 + ], + [ + 98.84743, + 16.13356 + ], + [ + 98.74512, + 16.12037 + ], + [ + 98.58307, + 16.07287 + ], + [ + 98.5762, + 15.79754 + ], + [ + 98.54736, + 15.37557 + ], + [ + 98.17383, + 15.15167 + ], + [ + 98.3606, + 14.63674 + ], + [ + 99.08295, + 13.89208 + ], + [ + 99.16534, + 13.72204 + ], + [ + 99.18182, + 13.00723 + ], + [ + 99.39331, + 12.56797 + ], + [ + 99.64153, + 11.78973 + ], + [ + 99.32156, + 11.30266 + ], + [ + 98.77859, + 10.67849 + ], + [ + 98.80597, + 10.47642 + ], + [ + 98.76657, + 10.40459 + ], + [ + 98.74924, + 10.34194 + ], + [ + 96.85547, + 6.40265 + ], + [ + 92.42523, + 20.54794 + ], + [ + 92.2728, + 20.96272 + ], + [ + 92.187, + 21.16 + ], + [ + 92.26, + 21.36 + ], + [ + 92.27, + 21.4328 + ], + [ + 92.62, + 21.43 + ], + [ + 92.6, + 22 + ], + [ + 93.22, + 22.25 + ], + [ + 93.4, + 23.7 + ], + [ + 93.34, + 23.95 + ], + [ + 94.155, + 23.847 + ], + [ + 94.17, + 23.92 + ], + [ + 94.25171, + 24.07405 + ], + [ + 94.28, + 24.23 + ], + [ + 94.30175, + 24.2371 + ], + [ + 94.3256, + 24.2731 + ], + [ + 94.6, + 24.7 + ], + [ + 94.78, + 25.47 + ], + [ + 95.2, + 26 + ], + [ + 95.1, + 26.6 + ], + [ + 97.3, + 27.9 + ], + [ + 96.14, + 29.38 + ], + [ + 95.4, + 29.1 + ], + [ + 94.8, + 29.2 + ], + [ + 92.5, + 27.8 + ], + [ + 91.64, + 27.76 + ], + [ + 91.4, + 28 + ], + [ + 89.58, + 28.18 + ], + [ + 88.9, + 27.32 + ], + [ + 88.74, + 27.47 + ], + [ + 88.9, + 27.86 + ], + [ + 88.7, + 28.1 + ], + [ + 88.1, + 27.87 + ], + [ + 85.93, + 27.942 + ], + [ + 81.6, + 30.5 + ], + [ + 81.2, + 30 + ], + [ + 78.73, + 31.5 + ], + [ + 78.77, + 31.99 + ], + [ + 78.4, + 32.5 + ], + [ + 79.3, + 32.5 + ], + [ + 79, + 34.3 + ], + [ + 78.3, + 34.6 + ], + [ + 78, + 35.5 + ], + [ + 76.1, + 35.8 + ], + [ + 76, + 36.55 + ], + [ + 75.15, + 37 + ], + [ + 72.5, + 36.9 + ], + [ + 71.1, + 36.1 + ], + [ + 71.65, + 35.44 + ], + [ + 71.45, + 35 + ], + [ + 70.985, + 34.54 + ], + [ + 71.18, + 34.36 + ], + [ + 71.092, + 34.118 + ], + [ + 70.88, + 33.97 + ], + [ + 70.5, + 33.94 + ], + [ + 69.908, + 34.04 + ], + [ + 69.869, + 33.96 + ], + [ + 70, + 33.75 + ], + [ + 70.13, + 33.73 + ], + [ + 70.34, + 33.34 + ], + [ + 70.013, + 33.14 + ], + [ + 69.57, + 33.09 + ], + [ + 69.24, + 32.45 + ], + [ + 69.3, + 31.9 + ], + [ + 68.1, + 31.6 + ], + [ + 66.393, + 30.934 + ], + [ + 66.2, + 29.8 + ], + [ + 62.5, + 29.4 + ], + [ + 60.87, + 29.86 + ], + [ + 61.53, + 29.0165 + ], + [ + 61.66, + 28.77 + ], + [ + 61.96, + 28.54 + ], + [ + 62.43, + 28.42 + ], + [ + 62.6, + 28.25 + ], + [ + 62.795, + 28.28 + ], + [ + 62.86, + 27.25 + ], + [ + 63.24, + 27.25 + ], + [ + 63.327, + 27.13 + ], + [ + 63.25, + 27.1 + ], + [ + 63.25, + 26.84 + ], + [ + 63.18, + 26.83 + ], + [ + 63.18, + 26.65 + ], + [ + 62.3, + 26.5 + ], + [ + 62.2, + 26.28 + ], + [ + 61.85, + 26.22 + ], + [ + 61.84, + 25.75 + ], + [ + 61.68, + 25.67 + ], + [ + 58.49, + -1.62 + ], + [ + 49.26, + -1.62 + ], + [ + 49.30, + -8.23 + ], + [ + 57.78, + -8.27 + ], + [ + 56.5, + -21 + ], + [ + 180, + -65 + ], + [ + 180, + -35 ] ] ] @@ -1247,152 +3047,32 @@ "coordinates": [ [ [ - -53.9208984375, - 6.096859818887948 + 138.7, + 46.7 ], [ - -55.72265625, - 7.863381805309173 + 145.5, + 44.5 ], [ - -60.13916015625, - 8.86336203355168 + 145.2, + 43.7 ], [ - -59.83154296874999, - 8.276727101164047 + 146, + 43.3 ], [ - -60.53466796874999, - 7.863381805309173 + 142, + 18 ], [ - -60.71044921875, - 7.558546606093156 + 122, + 24.3 ], [ - -60.57861328125, - 7.18810087117902 - ], - [ - -60.2490234375, - 7.18810087117902 - ], - [ - -60.5126953125, - 6.860985433763661 - ], - [ - -60.88623046875001, - 6.860985433763661 - ], - [ - -61.19384765625, - 6.68643125265198 - ], - [ - -61.10595703125, - 6.227933930268672 - ], - [ - -61.41357421874999, - 5.987606891658272 - ], - [ - -60.732421875, - 5.222246513227375 - ], - [ - -60.18310546874999, - 5.331644153439766 - ], - [ - -59.96337890624999, - 5.0690578267840465 - ], - [ - -60.20507812499999, - 4.54357027937176 - ], - [ - -59.61181640625, - 4.324501493019203 - ], - [ - -59.5458984375, - 3.9300201571114752 - ], - [ - -59.87548828125, - 3.5572827265412794 - ], - [ - -60.029296875, - 2.767477951092084 - ], - [ - -59.765625, - 2.2625953010152453 - ], - [ - -59.47998046874999, - 1.6037944300589855 - ], - [ - -58.86474609374999, - 1.1864386394452024 - ], - [ - -57.919921875, - 1.6477220517969353 - ], - [ - -57.1728515625, - 2.0210651187669897 - ], - [ - -56.5576171875, - 1.9771465537125772 - ], - [ - -55.8984375, - 1.8234225930141614 - ], - [ - -56.1181640625, - 2.3504147112508176 - ], - [ - -55.96435546875, - 2.5040852618529215 - ], - [ - -54.99755859375, - 2.591888984149953 - ], - [ - -54.51416015625, - 2.28455066023697 - ], - [ - -53.94287109375, - 3.5572827265412794 - ], - [ - -54.38232421875, - 4.039617826768437 - ], - [ - -54.4482421875, - 4.893940608902113 - ], - [ - -54.0087890625, - 5.506639674354886 - ], - [ - -53.9208984375, - 6.096859818887948 + 138.7, + 46.7 ] ] ] @@ -1408,24 +3088,36 @@ "coordinates": [ [ [ - -62.60009765624999, - -53.409531853086435 + -180, + 7 ], [ - -55.70068359375, - -53.409531853086435 + -148, + 7 ], [ - -55.70068359375, - -50.247204901392664 + -151, + -12 ], [ - -62.60009765624999, - -50.247204901392664 + -171.5, + -10.75 ], [ - -62.60009765624999, - -53.409531853086435 + -171, + -16 + ], + [ + -152, + -19 + ], + [ + -180, + -55 + ], + [ + -180, + 7 ] ] ] @@ -1441,776 +3133,24 @@ "coordinates": [ [ [ - -41.220703125, - -57.70414723434192 + -130.21, + -25.16 ], [ - -29.091796875, - -57.70414723434192 + -129.99, + -25.16 ], [ - -29.091796875, - -52.74959372674114 + -129.99, + -24.98 ], [ - -41.220703125, - -52.74959372674114 + -130.21, + -24.98 ], [ - -41.220703125, - -57.70414723434192 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -46.845703125, - -60.95444387929966 - ], - [ - -43.81347656249999, - -60.95444387929966 - ], - [ - -43.81347656249999, - -60.329667021005825 - ], - [ - -46.845703125, - -60.329667021005825 - ], - [ - -46.845703125, - -60.95444387929966 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -65.489501953125, - 31.840232667909365 - ], - [ - -64.00634765625, - 31.840232667909365 - ], - [ - -64.00634765625, - 32.76418137510082 - ], - [ - -65.489501953125, - 32.76418137510082 - ], - [ - -65.489501953125, - 31.840232667909365 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -78.90380859375, - 16.867633616803836 - ], - [ - -75.6298828125, - 16.867633616803836 - ], - [ - -75.6298828125, - 18.979025953255267 - ], - [ - -78.90380859375, - 18.979025953255267 - ], - [ - -78.90380859375, - 16.867633616803836 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -81.67236328125001, - 19.03875247795316 - ], - [ - -79.76898193359376, - 19.48989674307901 - ], - [ - -79.48333740234375, - 19.888140273126222 - ], - [ - -81.45263671875001, - 19.46400263520258 - ], - [ - -81.67236328125001, - 19.03875247795316 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - 13.90869140625, - 35.6126508187567 - ], - [ - 15.00732421875, - 35.505400093441324 - ], - [ - 15.029296875, - 36.32397712011264 - ], - [ - 13.831787109375, - 36.36822190085111 - ], - [ - 13.90869140625, - 35.6126508187567 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - 113.53256464004518, - 22.17096258989228 - ], - [ - 113.53754281997682, - 22.16047023983672 - ], - [ - 113.54106187820436, - 22.154587822430837 - ], - [ - 113.54878664016725, - 22.14703570986906 - ], - [ - 113.54990243911743, - 22.141947742446394 - ], - [ - 113.54792833328247, - 22.118731558535227 - ], - [ - 113.54852914810182, - 22.11006426296891 - ], - [ - 113.56088876724245, - 22.105531611874294 - ], - [ - 113.5914444923401, - 22.117300298747207 - ], - [ - 113.60217332839966, - 22.136303063467075 - ], - [ - 113.58766794204713, - 22.183520585503548 - ], - [ - 113.57015848159791, - 22.189083895743767 - ], - [ - 113.56621026992799, - 22.189163370008256 - ], - [ - 113.56406450271608, - 22.190514425625366 - ], - [ - 113.56380701065065, - 22.19941517306984 - ], - [ - 113.56191873550418, - 22.2050573189853 - ], - [ - 113.56088876724245, - 22.21260631441281 - ], - [ - 113.55256319046022, - 22.217294433458783 - ], - [ - 113.54850769042969, - 22.21683754739093 - ], - [ - 113.5441303253174, - 22.217056058304685 - ], - [ - 113.54318618774415, - 22.216479983343337 - ], - [ - 113.5415554046631, - 22.213242000752253 - ], - [ - 113.54114770889284, - 22.213003618712484 - ], - [ - 113.53824019432068, - 22.213659168347313 - ], - [ - 113.53728532791139, - 22.21367903343993 - ], - [ - 113.53571891784668, - 22.213559842841935 - ], - [ - 113.53435635566713, - 22.213182405280275 - ], - [ - 113.53312253952026, - 22.212367931293002 - ], - [ - 113.53496789932252, - 22.20616982803302 - ], - [ - 113.53222131729127, - 22.19401121511328 - ], - [ - 113.52681398391725, - 22.184792218694355 - ], - [ - 113.53256464004518, - 22.17096258989228 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - 114.1398811340332, - 22.298308554808454 - ], - [ - 114.1146469116211, - 22.295926164040363 - ], - [ - 114.10280227661133, - 22.2808367460213 - ], - [ - 114.1505241394043, - 22.226342457476385 - ], - [ - 114.20768737792969, - 22.188199741518677 - ], - [ - 114.26794052124023, - 22.199325771045544 - ], - [ - 114.26673889160155, - 22.257008033931445 - ], - [ - 114.24699783325194, - 22.278295210101668 - ], - [ - 114.22657012939453, - 22.29354373265189 - ], - [ - 114.20408248901367, - 22.29973796977008 - ], - [ - 114.184513092041, - 22.290843594643704 - ], - [ - 114.16563034057617, - 22.28925525380013 - ], - [ - 114.1398811340332, - 22.298308554808454 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -79.82666015625001, - 25.035838555635017 - ], - [ - -73.55346679687501, - 20.324023603422518 - ], - [ - -70.82336425781251, - 21.307287323905406 - ], - [ - -78.38745117187501, - 28.304380682962783 - ], - [ - -79.82666015625001, - 25.035838555635017 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -59.06250000000001, - 13.378931658431565 - ], - [ - -61.02905273437501, - 14.216463756160174 - ], - [ - -61.92443847656251, - 12.350734120814016 - ], - [ - -61.71569824218751, - 10.935798432254105 - ], - [ - -62.06176757812501, - 10.028357677443571 - ], - [ - -61.13891601562501, - 9.855216086088848 - ], - [ - -59.06250000000001, - 13.378931658431565 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -61.43829345703126, - 17.17228278169308 - ], - [ - -61.80358886718751, - 17.882045302279195 - ], - [ - -62.91870117187501, - 17.403062993328938 - ], - [ - -62.149658203125, - 16.52826534972986 - ], - [ - -61.43829345703126, - 17.17228278169308 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -61.33392333984376, - 15.731457491108594 - ], - [ - -61.63604736328126, - 15.570127852659427 - ], - [ - -61.36138916015626, - 15.10394633500913 - ], - [ - -61.13342285156251, - 15.257689080778713 - ], - [ - -61.33392333984376, - 15.731457491108594 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -63.46664428710938, - 18.672267305093758 - ], - [ - -64.5604705810547, - 18.78736737706614 - ], - [ - -64.8845672607422, - 18.40665471391907 - ], - [ - -64.6593475341797, - 18.365604299215338 - ], - [ - -64.61608886718751, - 18.114529138838503 - ], - [ - -63.30596923828126, - 18.108002884854656 - ], - [ - -62.79235839843751, - 18.231960055191504 - ], - [ - -63.46664428710938, - 18.672267305093758 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - 31.898803710937504, - 35.29943548054545 - ], - [ - 32.38220214843751, - 34.43409789359469 - ], - [ - 34.69482421875001, - 34.74161249883172 - ], - [ - 34.74975585937501, - 35.79999392988527 - ], - [ - 31.898803710937504, - 35.29943548054545 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - 166.53076171875003, - -0.7140928403610857 - ], - [ - 172.81494140625009, - 0.4751532449748611 - ], - [ - 176.50634765625003, - -17.245744208007117 - ], - [ - 177.82470703125009, - -19.36038488536514 - ], - [ - 180.0439453125002, - -19.67103928897615 - ], - [ - 180.1098632812502, - -13.333502655583224 - ], - [ - 189.00878906250003, - -9.760490714194388 - ], - [ - 189.931640625, - -4.726989319952657 - ], - [ - 199.62158203125003, - 2.583657640731887 - ], - [ - 201.04980468750003, - -0.6014904163878395 - ], - [ - 193.31542968750003, - -9.543874794137526 - ], - [ - 193.42529296875003, - -14.95274576245613 - ], - [ - 183.7353515625, - -14.846576365691352 - ], - [ - 180.3295898437502, - -24.27450874986185 - ], - [ - 203.46679687500003, - -22.662175307872086 - ], - [ - 203.2470703125, - -13.247966096402816 - ], - [ - 211.33300781250003, - -11.35887518924762 - ], - [ - 200.65429687500003, - 6.468151012664214 - ], - [ - 179.8461914062502, - -4.836470204221701 - ], - [ - 173.1445312500001, - 4.162897490667403 - ], - [ - 166.53076171875003, - -0.7140928403610857 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -127.33154296875001, - -24.166802085303225 - ], - [ - -131.17675781250003, - -23.60426184707018 - ], - [ - -130.34179687500003, - -25.324166525738384 - ], - [ - -123.49731445312501, - -24.716895455859337 - ], - [ - -127.33154296875001, - -24.166802085303225 - ] - ] - ] - } - }, - { - "type": "Feature", - "properties": { - "driving_side": "left" - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -5.976562500000001, - -15.728813770533979 - ], - [ - -5.949096679687501, - -16.13026201203474 - ], - [ - -5.482177734375001, - -16.156644815257152 - ], - [ - -5.465698242187501, - -15.760536148501288 - ], - [ - -5.976562500000001, - -15.728813770533979 + -130.21, + -25.16 ] ] ] diff --git a/docker/Dockerfile b/docker/Dockerfile index e0b668d60..056f8c7b6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,14 +1,14 @@ -FROM debian:buster-slim as builder +FROM debian:stretch-slim as builder ARG DOCKER_TAG +ARG BUILD_CONCURRENCY RUN mkdir -p /src && mkdir -p /opt COPY . /src WORKDIR /src -RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ +RUN NPROC=${BUILD_CONCURRENCY:-$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1)} && \ apt-get update && \ - apt-get -y --no-install-recommends install cmake make git gcc g++ libbz2-dev libstxxl-dev libstxxl1v5 libxml2-dev \ - libzip-dev libboost1.67-all-dev lua5.2 liblua5.2-dev libtbb-dev -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 && \ - NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ + apt-get -y --no-install-recommends install cmake make git gcc g++ libbz2-dev libxml2-dev \ + libzip-dev libboost1.62-all-dev lua5.2 liblua5.2-dev libtbb-dev -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 && \ echo "Building OSRM ${DOCKER_TAG}" && \ git show --format="%H" | head -n1 > /opt/OSRM_GITSHA && \ echo "Building OSRM gitsha $(cat /opt/OSRM_GITSHA)" && \ @@ -30,15 +30,20 @@ RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ # Multistage build to reduce image size - https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds # Only the content below ends up in the image, this helps remove /src from the image (which is large) -FROM debian:buster-slim as runstage +FROM debian:stretch-slim as runstage RUN mkdir -p /src && mkdir -p /opt RUN apt-get update && \ -apt-get install -y --no-install-recommends libboost-program-options1.67.0 libboost-regex1.67.0 \ -libboost-date-time1.67.0 libboost-chrono1.67.0 libboost-filesystem1.67.0 \ -libboost-iostreams1.67.0 libboost-thread1.67.0 expat liblua5.2-0 libtbb2 &&\ -rm -rf /var/lib/apt/lists/* + apt-get install -y --no-install-recommends libboost-program-options1.62.0 libboost-regex1.62.0 \ + libboost-date-time1.62.0 libboost-chrono1.62.0 libboost-filesystem1.62.0 \ + libboost-iostreams1.62.0 libboost-thread1.62.0 expat liblua5.2-0 libtbb2 &&\ + rm -rf /var/lib/apt/lists/* COPY --from=builder /usr/local /usr/local COPY --from=builder /opt /opt +RUN /usr/local/bin/osrm-extract --help && \ + /usr/local/bin/osrm-routed --help && \ + /usr/local/bin/osrm-contract --help && \ + /usr/local/bin/osrm-partition --help && \ + /usr/local/bin/osrm-customize --help WORKDIR /opt EXPOSE 5000 diff --git a/docker/hooks/build b/docker/hooks/build index d1eac8ab0..c27c851ad 100644 --- a/docker/hooks/build +++ b/docker/hooks/build @@ -6,4 +6,4 @@ # ensure that "COPY . /src" is referring to the repo root, not the directory # that contains the Dockerfile. # This script gets executed with a pwd of wherever the Dockerfile is. -docker build --build-arg DOCKER_TAG=${DOCKER_TAG} -t $IMAGE_NAME -f Dockerfile .. +docker build --build-arg BUILD_CONCURRENCY=${CONCURRENCY:-1} --build-arg DOCKER_TAG=${DOCKER_TAG} -t $IMAGE_NAME -f Dockerfile .. diff --git a/docs/http.md b/docs/http.md index fb7811c79..60149856b 100644 --- a/docs/http.md +++ b/docs/http.md @@ -1,3 +1,8 @@ +# OSRM HTTP server + +Built-in HTTP server is a basic HTTP/1.0 server that supports 'keep-alive' extension. Persistent connections are limited to 512 requests per +connection and allow no more then 5 seconds between requests. + ## General options All OSRM HTTP requests use a common structure. @@ -16,7 +21,7 @@ GET /{service}/{version}/{profile}/{coordinates}[.{format}]?option=value&option= | `version` | Version of the protocol implemented by the service. `v1` for all OSRM 5.x installations | | `profile` | Mode of transportation, is determined statically by the Lua profile that is used to prepare the data using `osrm-extract`. Typically `car`, `bike` or `foot` if using one of the supplied profiles. | | `coordinates`| String of format `{longitude},{latitude};{longitude},{latitude}[;{longitude},{latitude} ...]` or `polyline({polyline}) or polyline6({polyline6})`. | -| `format`| Only `json` is supported at the moment. This parameter is optional and defaults to `json`. | +| `format`| `json` or `flatbuffers`. This parameter is optional and defaults to `json`. | Passing any `option=value` is optional. `polyline` follows Google's polyline format with precision 5 by default and can be generated using [this package](https://www.npmjs.com/package/polyline). @@ -24,14 +29,16 @@ To pass parameters to each location some options support an array like encoding: **Request options** -| Option | Values | Description | -|----------------|--------------------------------------------------------|-------------------------------------------------------------------------------------------------------| -|bearings |`{bearing};{bearing}[;{bearing} ...]` |Limits the search to segments with given bearing in degrees towards true north in clockwise direction. | -|radiuses |`{radius};{radius}[;{radius} ...]` |Limits the search to given radius in meters. | -|generate\_hints |`true` (default), `false` |Adds a Hint to the response which can be used in subsequent requests, see `hints` parameter. | -|hints |`{hint};{hint}[;{hint} ...]` |Hint from previous request to derive position in street network. | -|approaches |`{approach};{approach}[;{approach} ...]` |Keep waypoints on curb side. | -|exclude |`{class}[,{class}]` |Additive list of classes to avoid, order does not matter. | +| Option | Values | Description | +|----------------|--------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +|bearings |`{bearing};{bearing}[;{bearing} ...]` |Limits the search to segments with given bearing in degrees towards true north in clockwise direction. | +|radiuses |`{radius};{radius}[;{radius} ...]` |Limits the search to given radius in meters. | +|generate\_hints |`true` (default), `false` |Adds a Hint to the response which can be used in subsequent requests, see `hints` parameter. | +|hints |`{hint};{hint}[;{hint} ...]` |Hint from previous request to derive position in street network. | +|approaches |`{approach};{approach}[;{approach} ...]` |Keep waypoints on curb side. | +|exclude |`{class}[,{class}]` |Additive list of classes to avoid, order does not matter. | +|snapping |`default` (default), `any` |Default snapping avoids is_startpoint (see profile) edges, `any` will snap to any edge in the graph | +|skip_waypoints |`true`, `false` (default) |Removes waypoints from the response. Waypoints are still calculated, but not serialized. Could be useful in case you are interested in some other part of response and do not want to transfer waste data. | Where the elements follow the following format: @@ -70,6 +77,8 @@ curl 'http://router.project-osrm.org/route/v1/driving/polyline(ofp_Ik_vpAilAyu@t ### Responses +#### Code + Every response object has a `code` property containing one of the strings below or a service dependent code: | Type | Description | @@ -87,12 +96,17 @@ Every response object has a `code` property containing one of the strings below - `message` is a **optional** human-readable error message. All other status types are service dependent. - In case of an error the HTTP status code will be `400`. Otherwise the HTTP status code will be `200` and `code` will be `Ok`. +#### Data version + +Every response object has a `data_version` propetry containing timestamp from the original OpenStreetMap file. This field is optional. It can be ommited if data_version parametr was not set on osrm-extract stage or OSM file has not `osmosis_replication_timestamp` section. + #### Example response ```json { "code": "Ok", -"message": "Everything worked" +"message": "Everything worked", +"data_version": "2017-11-17T21:43:02Z" } ``` @@ -115,6 +129,9 @@ In addition to the [general options](#general-options) the following options are |------------|------------------------------|----------------------------------------------------| |number |`integer >= 1` (default `1`) |Number of nearest segments that should be returned. | +As `waypoints` is a single thing, returned byt that service, using it with option `skip_waypoints` set to `true` is quite useless, but still +possible. In that case only `code` field will be returned. + **Response** - `code` if the request was successful `Ok` otherwise see the service dependent and general status codes. @@ -194,7 +211,8 @@ In addition to the [general options](#general-options) the following options are |annotations |`true`, `false` (default), `nodes`, `distance`, `duration`, `datasources`, `weight`, `speed` |Returns additional metadata for each coordinate along the route geometry. | |geometries |`polyline` (default), `polyline6`, `geojson` |Returned route geometry format (influences overview and per step) | |overview |`simplified` (default), `full`, `false` |Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all.| -|continue\_straight |`default` (default), `true`, `false` |Forces the route to keep going straight at waypoints constraining uturns there even if it would be faster. Default value depends on the profile. | +|continue\_straight |`default` (default), `true`, `false` |Forces the route to keep going straight at waypoints constraining uturns there even if it would be faster. Default value depends on the profile. | +|waypoints | `{index};{index};{index}...` |Treats input coordinates indicated by given indices as waypoints in returned Match object. Default is to treat all input coordinates as waypoints. | \* Please note that even if alternative routes are requested, a result cannot be guaranteed. @@ -243,6 +261,8 @@ In addition to the [general options](#general-options) the following options are Unlike other array encoded options, the length of `sources` and `destinations` can be **smaller or equal** to number of input locations; +With `skip_waypoints` set to `true`, both `sources` and `destinations` arrays will be skipped. + **Example:** ``` @@ -279,9 +299,9 @@ curl 'http://router.project-osrm.org/table/v1/driving/13.388860,52.517037;13.397 - `code` if the request was successful `Ok` otherwise see the service dependent and general status codes. - `durations` array of arrays that stores the matrix in row-major order. `durations[i][j]` gives the travel time from - the i-th waypoint to the j-th waypoint. Values are given in seconds. Can be `null` if no route between `i` and `j` can be found. + the i-th source to the j-th destination. Values are given in seconds. Can be `null` if no route between `i` and `j` can be found. - `distances` array of arrays that stores the matrix in row-major order. `distances[i][j]` gives the travel distance from - the i-th waypoint to the j-th waypoint. Values are given in meters. Can be `null` if no route between `i` and `j` can be found. Note that computing the `distances` table is currently only implemented for CH. If `annotations=distance` or `annotations=duration,distance` is requested when running a MLD router, a `NotImplemented` error will be returned. + the i-th source to the j-th destination. Values are given in meters. Can be `null` if no route between `i` and `j` can be found. - `sources` array of `Waypoint` objects describing all sources in order - `destinations` array of `Waypoint` objects describing all destinations in order - `fallback_speed_cells` (optional) array of arrays containing `i,j` pairs indicating which cells contain estimated values based on `fallback_speed`. Will be absent if `fallback_speed` is not used. @@ -742,8 +762,8 @@ step. { "bearings" : [ 10, 92, 184, 270 ], "lanes" : [ { "indications" : [ "left", "straight" ], - "valid" : "false" }, - { "valid" : "true", + "valid" : false }, + { "valid" : true, "indications" : [ "right" ] } ], "out" : 2, @@ -754,9 +774,9 @@ step. { "out" : 1, "lanes" : [ { "indications" : [ "straight" ], - "valid" : "true" }, + "valid" : true }, { "indications" : [ "right" ], - "valid" : "false" } + "valid" : false } ], "bearings" : [ 60, 240, 330 ], "in" : 0, @@ -864,7 +884,7 @@ A `Lane` represents a turn lane at the corresponding turn location. ```json { "indications": ["left", "straight"], - "valid": "false" + "valid": false } ``` @@ -899,7 +919,7 @@ location of the StepManeuver. Further intersections are listed for every cross-w "classes": ["toll", "restricted"], "lanes":{ "indications": ["left", "straight"], - "valid": "false" + "valid": false } } ``` @@ -930,3 +950,175 @@ Object used to describe waypoint on a route. ] } ``` + +## Flatbuffers format + +Default response format is `json`, but OSRM supports binary [`flatbuffers`](https://google.github.io/flatbuffers/) format, which +is much faster in serialization/deserialization, comparing to `json`. + +The format itself is described in message descriptors, located at `include/engine/api/flatbuffers directory`. Those descriptors could +be compiled to provide protocol parsers in Go/Javascript/Typescript/Java/Dart/C#/Python/Lobster/Lua/Rust/PHP/Kotlin. Precompiled +protocol parser for C++ is supplied with OSRM. + +`Flatbuffers` format provides exactly same data, as `json` format with a slightly different layout, which was optimized to minimize +in-transfer size. + +### Root object + +Root object is the only object, available from a 'raw' `flatbuffers` buffer. It can be constructed with a following call: + + auto osrm = osrm::engine::api::fbresult::GetFBResult(some_input_buffer); + +**Properties** + +- `error`: `bool` Marks response as erroneous. Erroneus response should include `code` field set, all the other field may not present. +- `code`: `Error` Error description object, only present, when `error` is `true` +- `waypoints`: `[Waypoint]` Array of `Waypoint` objects. Should present for every service call, unless `skip_waypoints` is set to `true`. Table service will put `sources` array here. +- `routes`: `[RouteObject]` Array of `RouteObject` objects. May be empty or absent. Should present for Route/Trip/Match services call. +- `table`: `Table` Table object, may absent. Should be present in case of Table service call. + +### Error object + +Contains error information. + +**Properties** + +- `code`: `string` Error code +- `message`: `string` Detailed error message + +### Waypoint object + +Almost same as `json` Waypoint object. The following properties differ: + +- `location`: `Position` Same as `json` location field, but different format. +- `nodes`: `Uint64Pair` Same as `json` nodes field, but different format. + +### RouteObject object + +Almost same as `json` Route object. The following properties differ: + +- `polyline`: `string` Same as `json` geometry.polyline or geometry.polyline6 fields. One field for both formats. +- `coordinates`: `[Position]` Same as `json` geometry.coordinates field, but different format. +- `legs`: `[Leg]` Array of `Leg` objects. + +### Leg object + +Almost same as `json` Leg object. The following properties differ: + +- `annotations`: `Annotation` Same as `json` annotation field, but different format. +- `steps`: `[Step]` Same as `step` annotation field, but different format. + +### Step object + +Almost same as `json` Step object. The following properties differ: + +- `polyline`: `string` Same as `json` geometry.polyline or geometry.polyline6 fields. One field for both formats. +- `coordinates`: `[Position]` Same as `json` geometry.coordinates field, but different format. +- `maneuver`: `StepManeuver` Same as `json` maneuver field, but different format. + +| `type` | Description | +|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `Turn` | a basic turn into direction of the `modifier` | +| `NewName` | no turn is taken/possible, but the road name changes. The road can take a turn itself, following `modifier`. | +| `Depart` | indicates the departure of the leg | +| `Arrive` | indicates the destination of the leg | +| `Merge` | merge onto a street (e.g. getting on the highway from a ramp, the `modifier specifies the direction of the merge`) | +| `OnRamp` | take a ramp to enter a highway (direction given my `modifier`) | +| `OffRamp` | take a ramp to exit a highway (direction given my `modifier`) | +| `Fork` | take the left/right side at a fork depending on `modifier` | +| `EndOfRoad` | road ends in a T intersection turn in direction of `modifier` | +| `Continue` | Turn in direction of `modifier` to stay on the same road | +| `Roundabout` | traverse roundabout, if the route leaves the roundabout there will be an additional property `exit` for exit counting. The modifier specifies the direction of entering the roundabout. | +| `Rotary` | a traffic circle. While very similar to a larger version of a roundabout, it does not necessarily follow roundabout rules for right of way. It can offer `rotary_name` and/or `rotary_pronunciation` parameters (located in the RouteStep object) in addition to the `exit` parameter (located on the StepManeuver object). | +| `RoundaboutTurn` | Describes a turn at a small roundabout that should be treated as normal turn. The `modifier` indicates the turn direciton. Example instruction: `At the roundabout turn left`. | +| `Notification` | not an actual turn but a change in the driving conditions. For example the travel mode or classes. If the road takes a turn itself, the `modifier` describes the direction | +| `ExitRoundabout` | Describes a maneuver exiting a roundabout (usually preceeded by a `roundabout` instruction) | +| `ExitRotary` | Describes the maneuver exiting a rotary (large named roundabout) | + +- `driving_side`: `bool` Ttrue stands for the left side driving. +- `intersections`: `[Intersection]` Same as `json` intersections field, but different format. + +### Intersection object + +Almost same as `json` Intersection object. The following properties differ: + +- `location`: `Position` Same as `json` location property, but in different format. +- `lanes`: `[Lane]` Array of `Lane` objects. + +### Lane object + +Almost same as `json` Lane object. The following properties differ: + +- `indications`: `Turn` Array of `Turn` enum values. + +| `value` | Description | +|------------------------|---------------------------------------------------------------------------------------------------------------------------| +| `None` | No dedicated indication is shown. | +| `UTurn` | An indication signaling the possibility to reverse (i.e. fully bend arrow). | +| `SharpRight` | An indication indicating a sharp right turn (i.e. strongly bend arrow). | +| `Right` | An indication indicating a right turn (i.e. bend arrow). | +| `SlightRight` | An indication indicating a slight right turn (i.e. slightly bend arrow). | +| `Straight` | No dedicated indication is shown (i.e. straight arrow). | +| `SlightLeft` | An indication indicating a slight left turn (i.e. slightly bend arrow). | +| `Left` | An indication indicating a left turn (i.e. bend arrow). | +| `SharpLeft` | An indication indicating a sharp left turn (i.e. strongly bend arrow). | + +### StepManeuver object + +Almost same as `json` StepManeuver object. The following properties differ: + +- `location`: `Position` Same as `json` location property, but in different format. +- `type`: `ManeuverType` Type of a maneuver (enum) + +| `type` | Description | +|------------------|--------------------------------------------------------------| +| `Turn` | a basic turn into direction of the `modifier` | +| `NewName` | no turn is taken/possible, but the road name changes. The road can take a turn itself, following `modifier`. | +| `Depart` | indicates the departure of the leg | +| `Arrive` | indicates the destination of the leg | +| `Merge` | merge onto a street (e.g. getting on the highway from a ramp, the `modifier specifies the direction of the merge`) | +| `OnRamp` | take a ramp to enter a highway (direction given my `modifier`) | +| `OffRamp` | take a ramp to exit a highway (direction given my `modifier`) | +| `Fork` | take the left/right side at a fork depending on `modifier` | +| `EndOfRoad` | road ends in a T intersection turn in direction of `modifier`| +| `Continue` | Turn in direction of `modifier` to stay on the same road | +| `Roundabout` | traverse roundabout, if the route leaves the roundabout there will be an additional property `exit` for exit counting. The modifier specifies the direction of entering the roundabout. | +| `Rotary` | a traffic circle. While very similar to a larger version of a roundabout, it does not necessarily follow roundabout rules for right of way. It can offer `rotary_name` and/or `rotary_pronunciation` parameters (located in the RouteStep object) in addition to the `exit` parameter (located on the StepManeuver object). | +| `RoundaboutTurn` | Describes a turn at a small roundabout that should be treated as normal turn. The `modifier` indicates the turn direciton. Example instruction: `At the roundabout turn left`. | +| `Notification` | not an actual turn but a change in the driving conditions. For example the travel mode or classes. If the road takes a turn itself, the `modifier` describes the direction | +| `ExitRoundabout` | Describes a maneuver exiting a roundabout (usually preceeded by a `roundabout` instruction) | +| `ExitRotary` | Describes the maneuver exiting a rotary (large named roundabout) | + +- `modifier`: `Turn` Maneuver turn (enum) + +### Annotation object + +Exactly same as `json` annotation object. + + +### Position object + +A point on Earth. + +***Properties*** +- `longitute`: `float` Point's longitude +- `latitude`: `float` Point's latitude + +### Uint64Pair + +A pair of long long integers. Used only by `Waypoint` object. + +***Properties*** +- `first`: `uint64` First pair value. +- `second`: `uint64` Second pair value. + +### Table object + +Almost same as `json` Table object. The main difference is that 'sources' field is absent and root's object 'waypoints' field is +used instead. All the other differences follow: + +- `durations`: `[float]` Flat representation of a durations matrix. Element at row;col can be adressed as [row * cols + col] +- `distances`: `[float]` Flat representation of a destinations matrix. Element at row;col can be adressed as [row * cols + col] +- `destinations`: `[Waypoint]` Array of `Waypoint` objects. Will be `null` if `skip_waypoints` will be set to `true` +- `rows`: `ushort` Number of rows in durations/destinations matrices. +- `cols`: `ushort` Number of cols in durations/destinations matrices. diff --git a/docs/nodejs/api.md b/docs/nodejs/api.md index ba3f18bd8..9bff3ada8 100644 --- a/docs/nodejs/api.md +++ b/docs/nodejs/api.md @@ -25,6 +25,8 @@ var osrm = new OSRM('network.osrm'); Make sure you prepared the dataset with the correct toolchain. - `options.shared_memory` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Connects to the persistent shared memory datastore. This requires you to run `osrm-datastore` prior to creating an `OSRM` object. + - `options.dataset_name` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Connects to the persistent shared memory datastore defined by `--dataset_name` option when running `osrm-datastore` + This requires you to run `osrm-datastore --dataset_name` prior to creating an `OSRM` object. - `options.memory_file` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** *DEPRECATED* Old behaviour: Path to a file on disk to store the memory using mmap. Current behaviour: setting this value is the same as setting `mmap_memory: true`. - `options.mmap_memory` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Map on-disk files to virtual memory addresses (mmap), rather than loading into RAM. @@ -48,6 +50,7 @@ Returns the fastest route between two or more coordinates while visiting the way Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`. - `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `null` (unlimited, default) or `double >= 0`. - `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings. + - `options.generate_hints` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`) - `options.alternatives` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Search for alternative routes. (optional, default `false`) - `options.alternatives` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Search for up to this many alternative routes. _Please note that even if alternative routes are requested, a result cannot be guaranteed._ (optional, default `0`) @@ -57,7 +60,9 @@ Returns the fastest route between two or more coordinates while visiting the way - `options.overview` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Add overview geometry either `full`, `simplified` according to highest zoom level it could be display on, or not at all (`false`). (optional, default `simplified`) - `options.continue_straight` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Forces the route to keep going straight at waypoints and don't do a uturn even if it would be faster. Default value depends on the profile. - `options.approaches` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`. + - `options.waypoints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Indices to coordinates to treat as waypoints. If not supplied, all coordinates are waypoints. Must include first and last coordinate index. `null`/`true`/`false` + - `options.snapping` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph. - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** **Examples** @@ -87,9 +92,11 @@ Note: `coordinates` in the general options only supports a single `{longitude},{ Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`. - `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `null` (unlimited, default) or `double >= 0`. - `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings. + - `options.generate_hints` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`) - `options.number` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number of nearest segments that should be returned. Must be an integer greater than or equal to `1`. (optional, default `1`) - `options.approaches` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`. + - `options.snapping` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph. - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** **Examples** @@ -123,6 +130,7 @@ tables. Optionally returns distance table. Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`. - `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `null` (unlimited, default) or `double >= 0`. - `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings. + - `options.generate_hints` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`) - `options.sources` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** An array of `index` elements (`0 <= integer < #coordinates`) to use location with given index as source. Default is to use all. @@ -132,6 +140,9 @@ tables. Optionally returns distance table. - `options.fallback_speed` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Replace `null` responses in result with as-the-crow-flies estimates based on `fallback_speed`. Value is in metres/second. - `options.fallback_coordinate` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Either `input` (default) or `snapped`. If using a `fallback_speed`, use either the user-supplied coordinate (`input`), or the snapped coordinate (`snapped`) for calculating the as-the-crow-flies diestance between two points. - `options.scale_factor` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Multiply the table duration values in the table by this number for more controlled input into a route optimization solver. + - `options.snapping` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph. + - `options.annotations` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Return the requested table or tables in response. Can be `['duration']` (return the duration matrix, default) or `['duration', distance']` (return both the duration matrix and the distance matrix). + - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** **Examples** @@ -202,6 +213,7 @@ if they can not be matched successfully. - `options.bearings` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the search to segments with given bearing in degrees towards true north in clockwise direction. Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`. - `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings. + - `options.generate_hints` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`) - `options.steps` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Return route steps for each route. (optional, default `false`) - `options.annotations` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (optional, default `false`) - `options.geometries` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`) @@ -210,6 +222,8 @@ if they can not be matched successfully. - `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Standard deviation of GPS precision used for map matching. If applicable use GPS accuracy. Can be `null` for default value `5` meters or `double >= 0`. - `options.gaps` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Allows the input track splitting based on huge timestamp gaps between points. Either `split` or `ignore` (optional, default `split`). - `options.tidy` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Allows the input track modification to obtain better matching quality for noisy tracks (optional, default `false`). + - `options.waypoints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Indices to coordinates to treat as waypoints. If not supplied, all coordinates are waypoints. Must include first and last coordinate index. + - `options.snapping` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph. - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** **Examples** @@ -266,6 +280,7 @@ Right now, the following combinations are possible: Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`. - `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `double >= 0` or `null` (unlimited, default). - `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings. + - `options.generate_hints` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`) - `options.steps` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Return route steps for each route. (optional, default `false`) - `options.annotations` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (optional, default `false`) - `options.geometries` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`) @@ -274,6 +289,7 @@ Right now, the following combinations are possible: - `options.source` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Return route starts at `any` or `first` coordinate. (optional, default `any`) - `options.destination` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Return route ends at `any` or `last` coordinate. (optional, default `any`) - `options.approaches` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`. + - `options.snapping` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph. - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** **Examples** diff --git a/docs/profiles.md b/docs/profiles.md index 090c5c36b..fa74b8780 100644 --- a/docs/profiles.md +++ b/docs/profiles.md @@ -89,7 +89,7 @@ They all return a table of functions when you use `require` to load them. You ca ### setup() The `setup` function is called once when the profile is loaded and must return a table of configurations. It's also where you can do other global setup, like loading data sources that are used during processing. -Note that processing of data is parallelized and several unconnected LUA interpreters will be running at the same time. The `setup` function will be called once for each. Each LUA iinterpreter will have its own set of globals. +Note that processing of data is parallelized and several unconnected LUA interpreters will be running at the same time. The `setup` function will be called once for each. Each LUA interpreter will have its own set of globals. The following global properties can be set under `properties` in the hash you return in the `setup` function: @@ -98,7 +98,7 @@ Attribute | Type | Notes weight_name | String | Name used in output for the routing weight property (default `'duration'`) weight_precision | Unsigned | Decimal precision of edge weights (default `1`) left_hand_driving | Boolean | Are vehicles assumed to drive on the left? (used in guidance, default `false`) -use_turn_restrictions | Boolean | Are turn instructions followed? (default `false`) +use_turn_restrictions | Boolean | Are turn restrictions followed? (default `false`) continue_straight_at_waypoint | Boolean | Must the route continue straight on at a via point, or are U-turns allowed? (default `true`) max_speed_for_map_matching | Float | Maximum vehicle speed to be assumed in matching (in m/s) max_turn_weight | Float | Maximum turn penalty weight @@ -178,7 +178,7 @@ exits | String | The ramp's exit numbers or pronunciation | String | Name pronunciation road_classification.motorway_class | Boolean | Guidance: way is a motorway road_classification.link_class | Boolean | Guidance: way is a slip/link road -road_classification.road_priority_class | Enum | Guidance: order in priority list. Defined in `include/extractor/guidance/road_classification.hpp` +road_classification.road_priority_class | Enum | Guidance: order in priority list. Defined in `include/extractor/road_classification.hpp` road_classification.may_be_ignored | Boolean | Guidance: way is non-highway road_classification.num_lanes | Unsigned | Guidance: total number of lanes in way @@ -223,7 +223,7 @@ source_number_of_lanes | Read | Integer | source_highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)) source_access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)) source_speed | Read | Integer | Speed on this source road in km/h -source_priority_class | Read | Enum | The type of road priority class of the source. Defined in `include/extractor/guidance/road_classification.hpp` +source_priority_class | Read | Enum | The type of road priority class of the source. Defined in `include/extractor/road_classification.hpp` target_restricted | Read | Boolean | Is the target a restricted access road? (See definition in `process_way`) target_mode | Read | Enum | Travel mode after the turn. Defined in `include/extractor/travel_mode.hpp` target_is_motorway | Read | Boolean | Is the target road a motorway? @@ -232,7 +232,7 @@ target_number_of_lanes | Read | Integer | target_highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)) target_access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)) target_speed | Read | Integer | Speed on this target road in km/h -target_priority_class | Read | Enum | The type of road priority class of the target. Defined in `include/extractor/guidance/road_classification.hpp` +target_priority_class | Read | Enum | The type of road priority class of the target. Defined in `include/extractor/road_classification.hpp` roads_on_the_right | Read | Vector | Vector with information about other roads on the right of the turn that are also connected at the intersection roads_on_the_left | Read | Vector | Vector with information about other roads on the left of the turn that are also connected at the intersection. If turn is a u turn, this is empty. weight | Read/write | Float | Penalty to be applied for this turn (routing weight) @@ -252,7 +252,7 @@ number_of_lanes | Read | Integer | How many lanes does th highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15) access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15) speed | Read | Integer | Speed on this road in km/h -priority_class | Read | Enum | The type of road priority class of the leg. Defined in `include/extractor/guidance/road_classification.hpp` +priority_class | Read | Enum | The type of road priority class of the leg. Defined in `include/extractor/road_classification.hpp` is_incoming | Read | Boolean | Is the road an incoming road of the intersection is_outgoing | Read | Boolean | Is the road an outgoing road of the intersection diff --git a/docs/windows-deps.md b/docs/windows-deps.md new file mode 100644 index 000000000..47fecc38a --- /dev/null +++ b/docs/windows-deps.md @@ -0,0 +1,97 @@ +# Building OSRM for Windows + +## Dependencies + +Get a decent Windows with decent Visual Studio (14 at least for C++11 support). The published binaries are build with +VS2019 and Windows SDK8.1. + +In case you are using [prepacked Windows VM with VS2019](https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/), you +have to install [Windows SDK 8.1](https://go.microsoft.com/fwlink/p/?LinkId=323507) + +Prepare directories for dependencies, build and target file location.Target directory ($target starting from that moment) should have /include and /lib subdirectories. + +### Bzip2 + +1. Download either from Wolt OSRM mirror or original distribution and unpack. + * https://project-osrm.wolt.com/deps/bzip2-1.0.8.tar.gz + * https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz + +2. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree. +3. Issue `nmake /f makefile.msc` +4. Copy bzlib.h to $target\include and libbz2.lib to $target\lib + +### ZLib + +1. Download either from Wolt OSRM mirror or original distribution and unpack. + * https://project-osrm.wolt.com/deps/zlib-1.2.11.tar.gz + * https://www.zlib.net/zlib-1.2.11.tar.gz + +2. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree. +3. Switch to `contrib\vstudio\vc14` +4. If needed, open `zlibvc.sln` with Visual Studio and retarget to your version of compiler and SDK. +5. Issue `msbuild zlibvc.sln /p:BuildInParallel=true /p:Configuration=Release /p:Platform=x64 /m:` +6. Copy x64\ZlibStatRelease\zlibstat.lib to $target\lib\libz.lib, copy zlib.h and zconf.h to $target\include + +### ICU + +1. Download either from Wolt OSRM mirror or original distribution and unpack. + * https://wolt-project.wolt.com/deps/icu4c-66_1-src.zip + * https://github.com/unicode-org/icu/releases/download/release-66-1/icu4c-66_1-src.zip + * https://wolt-project.wolt.com/deps/icu4c-66_1-data.zip + * https://github.com/unicode-org/icu/releases/download/release-66-1/icu4c-66_1-data.zip +2. Do retarget if neededby openinig .\source\allinone\allinone.sln and editing projects +3. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree. +4. Run build: + msbuild .\source\allinone\allinone.sln /nologo /p:BuildInParallel=true /p:Configuration=Release /p:Platform=x64 /m: +5. Copy lib64\*.lib to $target\lib, copy include contents to $target\include +6. Copy bin64\*dll to any dir withing your $PATH. At the same time copy them to $target\lib + +### Boost + +1. Download either from Wolt OSRM mirror or original distribution and unpack. + * https://project-osrm.wolt.com/deps/boost_1_73_0.zip + * https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.zip + +2. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree. +3. Build b2: + bootstrap.bat --with-toolset=msvc-14.2 +4. Build boost: + b2 -a -d release state --build-type=minimal toolset=msvc-14.2 -q runtime-link=shared link=static address-model=64 --with-iostreams --with-test --with-thread --with-filesystem --with-date_time --with-system --with-program_options --with-regex --disable-filesystem2 -sHAVE_ICU=1 include=\include library-path=\lib -sZLIB_SOURCE=/zlib -zBZIP2_BINARY=libbz2 -sBZIP2_INCLUDE=\include -sBZIP2_LIBPATH=\lib -sICU_ICUUC_NAME=icuuc -sICU_ICUDT_NAME=icudt -sICU_ICUIN_NAME=icuin -sBUILD=boost_unit_test_framework -j +5. Copy `boost` subdirectory to \include and contents of `stage` to \lib + +### Expat + +1. Download either from Wolt OSRM mirror or original distribution and unpack. + * https://project-osrm.wolt.com/deps/libexpat-2_2_9.zip + * https://github.com/libexpat/libexpat/archive/R_2_2_9.zip +2. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree. +3. Configure build my calling cmake: + mkdir expat\build + cd expat\build + cmake -G"Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release -DEXPAT_MSVC_STATIC_CRT=ON -DEXPAT_BUILD_EXAMPLES=OFF -DEXPAT_BUILD_TESTS=OFF -DEXPAT_SHARED_LIBS=OFF .. +4. Build expat: `msbuild expat.sln /nologo /p:Configuration=Release /p:Platform=x64` +5. Copy `Release\libexpat.*` to /lib. Copy `expat/lib/expat.h` and `expat/lib/expat_external.h` to /include + +### LUA + +1. Download either from Wolt OSRM mirror or original distribution and unpack. + * https://project-osrm.wolt.com/deps/lua-5.3.5.tar.gz + * https://www.lua.org/ftp/lua-5.3.5.tar.gz +2. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree. +3. Lua doesn't have native MSVC support, so you have to compile it by hand: + cd src + cl /MD /O2 /c /DLUA_COMPAT_5_2 *.c + ren lua.obj lua.o + ren luac.obj luac.o + link /LIB /OUT:lua5.3.5.dll *.obj +4. Copy `lua5.3.5.lib` to /lib. Copy `lua.h`,`lauxlib,h`,`lua.hpp`,`lualib.h`,`luaconf.h` to /include + +### TBB + +1. Download either from Wolt OSRM mirror or original distribution and unpack. + * https://project-osrm.wolt.com/deps/oneTBB-v2020.2.zip + * https://github.com/oneapi-src/oneTBB/archive/v2020.2.zip +2. Retarget by opening build\vs2013\makefile.sln +3. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree. +4. Switch to build\vs2013 and build: `msbuild makefle.sln /nologo /p:Configuration=Release /p:Platform=x64` +5. Copy x64/Release/*.{dll,lib} files to /lib and copy contents of include directory to /include diff --git a/example/example.cpp b/example/example.cpp index 6cd6eac82..108fc622e 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -52,14 +52,15 @@ int main(int argc, const char *argv[]) params.coordinates.push_back({util::FloatLongitude{7.419505}, util::FloatLatitude{43.736825}}); // Response is in JSON format - json::Object result; + engine::api::ResultT result = json::Object(); // Execute routing request, this does the heavy lifting const auto status = osrm.Route(params, result); + auto &json_result = result.get(); if (status == Status::Ok) { - auto &routes = result.values["routes"].get(); + auto &routes = json_result.values["routes"].get(); // Let's just use the first route auto &route = routes.values.at(0).get(); @@ -79,8 +80,8 @@ int main(int argc, const char *argv[]) } else if (status == Status::Error) { - const auto code = result.values["code"].get().value; - const auto message = result.values["message"].get().value; + const auto code = json_result.values["code"].get().value; + const auto message = json_result.values["message"].get().value; std::cout << "Code: " << code << "\n"; std::cout << "Message: " << code << "\n"; diff --git a/features/bicycle/access.feature b/features/bicycle/access.feature index df8baa757..787dd05e5 100644 --- a/features/bicycle/access.feature +++ b/features/bicycle/access.feature @@ -127,6 +127,7 @@ Feature: Bike - Access tags on ways | | | agricultural | | | | | forestry | | | | | delivery | | + | | | use_sidepath | | Scenario: Bike - Access tags on both node and way Then routability should be diff --git a/features/car/barrier.feature b/features/car/barrier.feature index 3f3220602..fd7e7f834 100644 --- a/features/car/barrier.feature +++ b/features/car/barrier.feature @@ -46,6 +46,18 @@ Feature: Car - Barriers | bollard | rising | x | | bollard | removable | | + # https://github.com/Project-OSRM/osrm-backend/issues/5996 + Scenario: Car - Kerb exception for barriers + Then routability should be + | node/barrier | node/highway | node/kerb | bothw | + | kerb | | | | + | kerb | crossing | | x | + | kerb | crossing | yes | x | + | kerb | | lowered | x | + | kerb | | flush | x | + | kerb | | raised | | + | kerb | | yes | | + Scenario: Car - Height restrictions Then routability should be | node/barrier | node/maxheight | bothw | diff --git a/features/car/conditional_restrictions.feature b/features/car/conditional_restrictions.feature index 23a9e1efe..c2311067c 100644 --- a/features/car/conditional_restrictions.feature +++ b/features/car/conditional_restrictions.feature @@ -387,217 +387,37 @@ Feature: Car - Turn restrictions | m | p | mj,jp,jp | @no_turning @conditionals - Scenario: Car - only_right_turn + Scenario: Car - Multiple conditional restrictions applicable to same turn Given the extract extra arguments "--parse-conditional-restrictions" # time stamp for 10am on Tues, 02 May 2017 GMT Given the contract extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" Given the customize extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" + Given the node map """ - a - d j b - c + j + | + k - l - m + | + n """ And the ways - | nodes | oneway | - | aj | no | - | jc | no | - | bj | yes | - | jd | yes | + | nodes | + | kl | + | jl | + | ln | + | lm | And the relations | type | way:from | way:to | node:via | restriction:conditional | - | restriction | bj | aj | j | only_right_turn @ (Mo-Su 07:00-14:00) | + | restriction | kl | lj | l | only_left_turn @ (Sa-Su 07:00-10:30) | + | restriction | kl | ln | l | only_right_turn @ (Mo-Fr 07:00-10:30) | When I route I should get | from | to | route | - | b | c | bj,aj,aj,jc,jc | - | b | a | bj,aj,aj | - | b | d | bj,aj,aj,jd,jd | + | k | m | kl,ln,ln,lm,lm | - @no_turning @conditionals - Scenario: Car - No right turn - Given the extract extra arguments "--parse-conditional-restrictions" - # time stamp for 10am on Tues, 02 May 2017 GMT - Given the contract extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" - Given the customize extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" - Given the node map - """ - a - d j b - c - """ - - And the ways - | nodes | oneway | - | aj | no | - | jc | no | - | bj | yes | - | jd | yes | - - And the relations - | type | way:from | way:to | node:via | restriction:conditional | - | restriction | bj | aj | j | no_right_turn @ (Mo-Fr 07:00-13:00) | - - When I route I should get - | from | to | route | # | - | b | c | bj,jc,jc | normal turn | - | b | a | bj,jc,jc,aj,aj | avoids right turn | - | b | d | bj,jd,jd | normal maneuver | - - @only_turning @conditionals - Scenario: Car - only_left_turn - Given the extract extra arguments "--parse-conditional-restrictions" - # time stamp for 10am on Tues, 02 May 2017 GMT - Given the contract extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" - Given the customize extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" - Given the node map - """ - a - d j b - c - """ - - And the ways - | nodes | oneway | - | aj | no | - | jc | no | - | bj | yes | - | jd | yes | - - And the relations - | type | way:from | way:to | node:via | restriction:conditional | - | restriction | bj | jc | j | only_left_turn @ (Mo-Fr 07:00-16:00) | - - When I route I should get - | from | to | route | - | b | c | bj,jc,jc | - | b | a | bj,jc,jc,aj,aj | - | b | d | bj,jc,jc,jd,jd | - - @no_turning @conditionals - Scenario: Car - No left turn - Given the extract extra arguments "--parse-conditional-restrictions" - # time stamp for 10am on Tues, 02 May 2017 GMT - Given the contract extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" - Given the customize extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" - Given the node map - """ - a - d j b - c - """ - - And the ways - | nodes | oneway | - | aj | no | - | jc | no | - | bj | yes | - | jd | yes | - - And the relations - | type | way:from | way:to | node:via | restriction:conditional | - | restriction | bj | jc | j | no_left_turn @ (Mo-Su 00:00-23:59) | - - When I route I should get - | from | to | route | - | b | c | bj,aj,aj,jc,jc | - | b | a | bj,aj,aj | - | b | d | bj,jd,jd | - - @no_turning @conditionals - Scenario: Car - Conditional restriction is off - Given the extract extra arguments "--parse-conditional-restrictions" - # time stamp for 10am on Tues, 02 May 2017 GMT - Given the contract extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" - Given the customize extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" - Given the node map - """ - a - d j b - c - """ - - And the ways - | nodes | oneway | - | aj | no | - | jc | no | - | bj | yes | - | jd | yes | - - And the relations - | type | way:from | way:to | node:via | restriction:conditional | - | restriction | bj | aj | j | no_right_turn @ (Mo-Su 16:00-20:00) | - - When I route I should get - | from | to | route | - | b | c | bj,jc,jc | - | b | a | bj,aj,aj | - | b | d | bj,jd,jd | - - @no_turning @conditionals - Scenario: Car - Conditional restriction is on - Given the extract extra arguments "--parse-conditional-restrictions" - # 10am utc, wed - Given the contract extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493805600" - Given the customize extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493805600" - Given the node map - """ - a - d j b - c - """ - - And the ways - | nodes | oneway | - | aj | no | - | jc | no | - | bj | yes | - | jd | yes | - - And the relations - | type | way:from | way:to | node:via | restriction:conditional | - | restriction | jb | aj | j | no_right_turn @ (Mo-Fr 07:00-14:00) | - - When I route I should get - | from | to | route | - | b | c | bj,jc,jc | - | b | a | bj,jc,jc,aj,aj | - | b | d | bj,jd,jd | - - @no_turning @conditionals - Scenario: Car - Conditional restriction with multiple time windows - Given the extract extra arguments "--parse-conditional-restrictions" - # 5pm Wed 02 May, 2017 GMT - Given the contract extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493744400" - Given the customize extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493744400" - - Given the node map - """ - a - p | - \ | - j - | \ - c m - """ - - And the ways - | nodes | oneway | - | aj | no | - | jc | no | - | jp | yes | - | mj | yes | - - And the relations - | type | way:from | way:to | node:via | restriction:conditional | - | restriction | aj | jp | j | no_right_turn @ (Mo-Fr 07:00-11:00,16:00-18:30) | - - When I route I should get - | from | to | route | - | a | p | aj,jc,jc,jp,jp | - | m | p | mj,jp,jp | @restriction-way Scenario: Car - prohibit turn @@ -719,7 +539,7 @@ Feature: Car - Turn restrictions When I route I should get | from | to | route | turns | | a | e | cap south,florida nw,florida nw,florida ne | depart,turn right,continue uturn,arrive | - | f | d | cap north,florida nw,florida nw | depart,turn left,arrive | + | f | d | cap north,florida nw,florida nw | depart,turn left,arrive | | e | c | florida ne,florida nw,cap south,cap south | depart,continue uturn,turn right,arrive | @no_turning @conditionals @@ -796,8 +616,8 @@ Feature: Car - Turn restrictions | nodes | name | | ab | albic | | bc | albic | - | db | dobe | - | be | dobe | + | db | dobe | + | be | dobe | And the relations | type | way:from | way:to | node:via | restriction:conditional | @@ -1047,7 +867,7 @@ Feature: Car - Turn restrictions | type | way:from | node:via | way:to | restriction:conditional | | restriction | be | e | de | no_right_turn @ (Mo-Fr 07:00-11:00) | - # node restrictino is off, way restriction is on + # node restriction is off, way restriction is on When I route I should get | from | to | route | turns | locations | | a | d | ab,be,ef,ef,de,de | depart,turn right,turn left,continue uturn,new name straight,arrive | a,b,e,f,e,d | diff --git a/features/car/multi_via_restrictions.feature b/features/car/multi_via_restrictions.feature new file mode 100644 index 000000000..42c6c6d42 --- /dev/null +++ b/features/car/multi_via_restrictions.feature @@ -0,0 +1,1033 @@ +@routing @car @restrictions + +Feature: Car - Multiple Via Turn restrictions + + Background: Use car routing + Given the profile "car" + Given a grid size of 200 meters + + + @restriction-way @no_turning @overlap + Scenario: Car - Node restriction inside multiple via restriction + Given the node map + """ + 1 2 3 4 5 + a---b---c---d---e---------f---------g + | | | + |7 |8 |9 + | | | + x---h---------i---------j + """ + + And the ways + | nodes | oneway | name | + | ab | yes | forward | + | bc | yes | forward | + | cd | yes | forward | + | de | yes | forward | + | ef | yes | forward | + | fg | yes | forward | + | eh | yes | first | + | fi | yes | second | + | gj | yes | third | + | ih | yes | back | + | ji | yes | back | + | hx | yes | back | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | ab | bc,cd,de,ef | fi | no_right_turn | + + And the relations + | type | way:from | node:via | way:to | restriction | + | restriction | de | e | eh | no_right_turn | + + When I route I should get + | from | to | route | + | 1 | x | forward,third,back,back | + | 2 | x | forward,second,back,back | + | 3 | x | forward,second,back,back | + | 4 | x | forward,second,back,back | + | 5 | x | forward,third,back,back | + | 7 | x | first,back,back | + | 8 | x | second,back,back | + | 9 | x | third,back,back | + + + @restriction-way @no_turning @overlap @conditionals + Scenario: Car - Conditional node restriction inside conditional multiple via restriction + Given the origin -9.2972,10.3811 + # coordinate in Guinée, a country that observes GMT year round + Given the extract extra arguments "--parse-conditional-restrictions" + # time stamp for 10am on Tues, 02 May 2017 GMT + Given the contract extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" + Given the customize extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" + Given the node map + """ + 1 2 3 4 5 + a---b---c---d---e---------f---------g + | | | + |7 |8 |9 + | | | + x---h---------i---------j + """ + + And the ways + | nodes | oneway | name | + | ab | yes | forward | + | bc | yes | forward | + | cd | yes | forward | + | de | yes | forward | + | ef | yes | forward | + | fg | yes | forward | + | eh | yes | first | + | fi | yes | second | + | gj | yes | third | + | ih | yes | back | + | ji | yes | back | + | hx | yes | back | + + And the relations + | type | way:from | way:via | way:to | restriction:conditional | + | restriction | ab | bc,cd,de,ef | fi | no_right_turn @ (Mo-Fr 07:00-10:30) | + + And the relations + | type | way:from | node:via | way:to | restriction:conditional | + | restriction | de | e | eh | no_right_turn @ (Mo-Fr 07:00-10:30) | + | restriction | de | e | eh | only_right_turn @ (Sa-Su 07:00-10:30) | + + When I route I should get + | from | to | route | + | 1 | x | forward,third,back,back | + | 2 | x | forward,second,back,back | + | 3 | x | forward,second,back,back | + | 4 | x | forward,second,back,back | + | 5 | x | forward,third,back,back | + | 7 | x | first,back,back | + | 8 | x | second,back,back | + | 9 | x | third,back,back | + + + @restriction-way @no_turning @overlap + Scenario: Car - Multiple via restriction inside multiple via restriction + Given the node map + """ + 1 2 3 4 5 + a---b---c---d---e---------f---------g + | | | + |7 |8 |9 + | | | + x---h---------i---------j + """ + + And the ways + | nodes | oneway | name | + | ab | yes | forward | + | bc | yes | forward | + | cd | yes | forward | + | de | yes | forward | + | ef | yes | forward | + | fg | yes | forward | + | eh | yes | first | + | fi | yes | second | + | gj | yes | third | + | ih | yes | back | + | ji | yes | back | + | hx | yes | back | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | ab | bc,cd,de,ef | fi | no_right_turn | + | restriction | bc | cd,de | eh | no_right_turn | + + When I route I should get + | from | to | route | + | 1 | x | forward,third,back,back | + | 2 | x | forward,second,back,back | + | 3 | x | forward,first,back,back | + | 4 | x | forward,second,back,back | + | 5 | x | forward,third,back,back | + | 7 | x | first,back,back | + | 8 | x | second,back,back | + | 9 | x | third,back,back | + + + @restriction-way @no_turning @overlap @conditionals + Scenario: Car - Conditional multiple via restriction inside conditional multiple via restriction + + Given a grid size of 200 meters + Given the origin -9.2972,10.3811 + # coordinate in Guinée, a country that observes GMT year round + Given the extract extra arguments "--parse-conditional-restrictions" + # time stamp for 10am on Tues, 02 May 2017 GMT + Given the contract extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" + Given the customize extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" + Given the node map + + """ + 1 2 3 4 5 + a---b---c---d---e---------f---------g + | | | + |7 |8 |9 + | | | + x---h---------i---------j + """ + + And the ways + | nodes | oneway | name | + | ab | yes | forward | + | bc | yes | forward | + | cd | yes | forward | + | de | yes | forward | + | ef | yes | forward | + | fg | yes | forward | + | eh | yes | first | + | fi | yes | second | + | gj | yes | third | + | ih | yes | back | + | ji | yes | back | + | hx | yes | back | + + And the relations + | type | way:from | way:via | way:to | restriction:conditional | + | restriction | ab | bc,cd,de,ef | fi | no_right_turn @ (Mo-Fr 07:00-10:30) | + | restriction | bc | cd,de | eh | no_right_turn @ (Mo-Fr 07:00-10:30) | + | restriction | bc | cd,de | eh | only_right_turn @ (Sa-Su 07:00-10:30) | + + When I route I should get + | from | to | route | + | 1 | x | forward,third,back,back | + | 2 | x | forward,second,back,back | + | 3 | x | forward,first,back,back | + | 4 | x | forward,second,back,back | + | 5 | x | forward,third,back,back | + | 7 | x | first,back,back | + | 8 | x | second,back,back | + | 9 | x | third,back,back | + + + @restriction-way @only_turning @overlap + Scenario: Car - Overlapping multiple via restrictions + Given the node map + """ + a f j + | | | + b---d---e---i---k----m + | | | + c g l + """ + + And the ways + | nodes | oneway | name | + | ab | yes | down | + | cb | yes | up | + | bd | yes | right | + | de | yes | right | + | ef | yes | up | + | eg | yes | down | + | ei | yes | right | + | ik | yes | right | + | kj | yes | up | + | kl | yes | down | + | km | yes | right | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | ab | bd,de | ei | only_straight_on | + | restriction | de | ei,ik | km | only_straight_on | + + When I route I should get + | from | to | route | + | a | f | | + | a | g | | + | a | j | | + | a | l | | + | a | m | down,right,right | + | c | f | up,right,up,up | + | c | g | up,right,down,down | + | c | j | | + | c | l | | + | c | m | up,right,right | + | i | j | right,up,up | + | i | l | right,down,down | + | i | m | right,right | + + + @restriction-way @only_turning @overlap @conditionals + Scenario: Car - Overlapping conditional multiple via restrictions + Given a grid size of 200 meters + Given the origin -9.2972,10.3811 + # coordinate in Guinée, a country that observes GMT year round + Given the extract extra arguments "--parse-conditional-restrictions" + # time stamp for 10am on Tues, 02 May 2017 GMT + Given the contract extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" + Given the customize extra arguments "--time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493719200" + Given the node map + """ + a f j + | | | + b---d---e---i---k----m + | | | + c g l + """ + + And the ways + | nodes | oneway | name | + | ab | yes | down | + | cb | yes | up | + | bd | yes | right | + | db | yes | left | + | de | yes | right | + | ed | yes | left | + | ef | yes | up | + | eg | yes | down | + | ei | yes | right | + | ie | yes | left | + | ik | yes | right | + | ki | yes | left | + | kj | yes | up | + | kl | yes | down | + | km | no | end | + + And the relations + | type | way:from | way:via | way:to | restriction:conditional | + | restriction | ab | bd,de | ei | only_straight_on @ (Mo-Fr 07:00-10:30) | + | restriction | ab | bd,de | ef | only_left_turn @ (Sa-Su 07:00-10:30) | + | restriction | de | ei,ik | km | only_straight_on @ (Mo-Fr 07:00-10:30) | + + When I route I should get + | from | to | route | + | a | f | down,right,end,end,left,up,up | + | a | g | down,right,end,end,left,down,down | + | a | j | down,right,end,end,up,up | + | a | l | down,right,end,end,down,down | + | a | m | down,right,end,end | + | c | f | up,right,up,up | + | c | g | up,right,down,down | + | c | j | up,right,end,end,up,up | + | c | l | up,right,end,end,down,down | + | c | m | up,right,end,end | + | i | j | right,up,up | + | i | l | right,down,down | + | i | m | right,end,end | + + + + @restriction-way @only_turning @geometry + Scenario: Car - Multiple via restriction with non-compressable via geometry + Given the node map + """ + a---b---c---d---e---f---g---h + | | | + i j k + """ + + And the ways + | nodes | oneway | name | + | ab | yes | right | + | bcd | yes | right | + | defg | yes | right | + | ci | yes | down | + | ej | yes | down | + | gh | yes | end | + | gk | yes | down | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | ab | bcd,defg | gh | only_straight_on | + + When I route I should get + | from | to | route | + | a | h | right,end,end | + | a | k | | + + @restriction-way @only_turning @geometry + Scenario: Car - Multiple via restriction with non-compressable from/to nodes + Given the node map + """ + a---b---c---d---e---f---g---h---i---j---k---l + | | | | | + m n o p q + """ + + And the ways + | nodes | oneway | name | + | abcdefg | yes | right | + | ghi | yes | right | + | ijkl | yes | end | + | cm | yes | down | + | en | yes | down | + | go | yes | down | + | ip | yes | down | + | kq | yes | down | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | abcdefg | ghi | ijkl | only_straight_on | + + When I route I should get + | from | to | route | + | a | l | right,end,end | + | a | p | | + + @restriction-way @no_turning + Scenario: Car - Long unrestricted route and short restricted route + Given the node map + """ + a------------------------------------b + | | + c--d--e--f--------------------------- + """ + + And the ways + | nodes | + | ac | + | ab | + | bf | + | cd | + | de | + | ef | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | ac | cd | de | no_straight_on | + + When I route I should get + | from | to | route | + | a | f | ab,bf,bf | + + + @restriction-way @overlap @no_turning + Scenario: Car - Junction with multiple via u-turn restrictions + # Example: https://www.openstreetmap.org/#map=19/52.07399/5.09724 + Given the node map + """ + a b + | | + c---d---e---f + | | + g---h---i---j + | | + k l + """ + + And the ways + | nodes | oneway | name | + | ad | yes | down | + | eb | yes | up | + | fe | yes | left | + | ij | yes | right | + | li | yes | up | + | hk | yes | down | + | gh | yes | right | + | dc | yes | left | + | dh | yes | down | + | hi | yes | right | + | ie | yes | up | + | ed | yes | left | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | ad | dh,hi | ie | no_u_turn | + | restriction | li | ie,ed | dh | no_u_turn | + + When I route I should get + | from | to | route | + | a | b | | + | a | c | down,left,left | + | a | k | down,down | + | a | j | down,right,right | + | f | b | left,up,up | + | f | c | left,left | + | f | k | left,down,down | + | f | j | left,down,right,right | + | l | b | up,up | + | l | c | up,left,left | + | l | k | | + | l | j | up,right,right | + | g | b | right,up,up | + | g | c | right,up,left,left | + | g | k | right,down,down | + | g | j | right,right | + + + @restriction-way @overlap @no_turning + Scenario: Car - Junction with multiple via u-turn restrictions, service roads + # Example: https://www.openstreetmap.org/#map=19/48.38566/10.88068 + Given the node map + """ + a b + | | + c---d--e--f---g + | _/| + h__/ | + |\ \ | + i---j-k-l-m---n + | | + o p + """ + + And the ways + | nodes | oneway | name | + | ad | yes | down | + | fb | yes | up | + | gf | yes | left | + | mn | yes | right | + | pm | yes | up | + | jo | yes | down | + | ij | yes | right | + | dc | yes | left | + | dh | yes | down | + | hj | yes | down | + | jkl | yes | right | + | lm | yes | right | + | mf | yes | up | + | fe | yes | left | + | ed | yes | left | + + And the ways + | nodes | oneway | name | highway | access | psv | + | kh | yes | service | service | no | yes | + | lh | no | service | service | no | yes | + | fh | yes | service | service | no | yes | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | hj | jkl,lm | mf | no_u_turn | + | restriction | lm | mf | fe | no_u_turn | + | restriction | mf | fe,ed | dh | no_u_turn | + | restriction | ed | dh,hj | jkl | no_u_turn | + + When I route I should get + | from | to | route | + | a | b | | + | a | c | down,left,left | + | a | o | down,down | + | a | n | down,right,right | + | i | b | right,up,up | + | i | c | | + | i | o | right,down,down | + | i | n | right,right | + | p | b | up,up | + | p | c | up,left,left | + | p | o | | + | p | n | up,right,right | + | g | b | left,up,up | + | g | c | left,left | + | g | o | left,down,down | + | g | n | | + + + @restriction-way @overlap @no_turning + Scenario: Car - Junction with overlapping and duplicate multiple via restrictions + # Example: https://www.openstreetmap.org/#map=19/34.66291/33.01711 + Given the profile file "car" initialized with + """ + profile.properties.left_hand_driving = true + """ + + And the node map + """ + a b + | | + c---d---e---f + | | + g---h---i---j + | | + k l + """ + + And the nodes + | node | highway | + | d | traffic_signals | + | e | traffic_signals | + | h | traffic_signals | + | i | traffic_signals | + + And the ways + | nodes | oneway | name | + | da | yes | up | + | be | yes | down | + | ef | yes | right | + | ji | yes | left | + | il | yes | down | + | kh | yes | up | + | hg | yes | left | + | cd | yes | right | + | hd | yes | up | + | ih | yes | left | + | ei | yes | down | + | de | yes | right | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | be | ei,ih | hd | no_u_turn | + | restriction | ji | ih,hd | de | no_u_turn | + | restriction | kh | hd,de | ei | no_u_turn | + | restriction | cd | de,ei | ih | no_u_turn | + | restriction | hd | de | ei | no_u_turn | + | restriction | de | ei | ih | no_u_turn | + | restriction | ei | ih | hd | no_u_turn | + | restriction | ei | ih,hd | de | no_u_turn | + | restriction | ih | hd | de | no_u_turn | + | restriction | ih | hd,de | ei | no_u_turn | + + When I route I should get + | from | to | route | + | b | a | | + | b | g | down,left,left | + | b | l | down,down | + | b | f | down,right,right | + | j | a | left,up,up | + | j | g | left,left | + | j | l | left,down,down | + | j | f | | + | k | a | up,up | + | k | g | up,left,left | + | k | l | | + | k | f | up,right,right | + | c | a | right,up,up | + | c | g | | + | c | l | right,down,down | + | c | f | right,right | + + + @restriction-way @no_turning + Scenario: Car - Junction with multiple via restriction to side road, traffic lights + # Example: https://www.openstreetmap.org/#map=19/48.23662/16.42545 + Given the node map + """ + e---d + | + f---c---g + | + h---b---i + | + a + """ + + And the nodes + | node | highway | + | c | traffic_signals | + | b | traffic_signals | + + And the ways + | nodes | oneway | name | + | ab | no | up | + | bc | no | up | + | cd | no | up | + | de | no | left | + | hb | yes | right | + | bi | yes | right | + | gc | yes | left | + | cf | yes | left | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | ab | bc,cd | de | no_left_turn | + + When I route I should get + | from | to | route | + | a | e | | + | a | f | up,left,left | + | a | g | | + | a | h | | + | a | i | up,right,right | + + + @restriction-way @overlap @no_turning + Scenario: Car - Many overlapping multiple via restrictions, traffic signals + # Example: https://www.openstreetmap.org/#map=19/48.76987/11.43410 + Given the node map + """ + 8 5 + p______a_______n________o__x + 1| | | + | \ / + r___q____b____ m + | \ \___ _/ 7 + \ c _l____k__w + s \ _/ _/ + \ _d/ __j + \ _/ \ _/ + | ___g e_____i + v__t__/ _/ \ 4 + 6 2/ 3\ + f h + """ + + And the nodes + | node | highway | + | n | traffic_signals | + | m | traffic_signals | + | q | traffic_signals | + + And the ways + | nodes | oneway | + | on | yes | + | na | yes | + | ap | yes | + | pr | yes | + | rqb | yes | + | bl | yes | + | oml | yes | + | ld | yes | + | lk | yes | + | ba | yes | + | bcd | no | + | de | no | + | eh | no | + | ei | no | + | ejk | yes | + | rst | yes | + | dgt | yes | + | fe | yes | + | xo | yes | + | tv | yes | + | kw | yes | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | pr | rqb,bcd | dgt | no_right_turn | + | restriction | rqb | bcd,de | ejk | no_left_turn | + | restriction | rqb | bcd | dgt | no_right_turn | + | restriction | fe | ed | dgt | no_u_turn | + | restriction | fe | ed,dcb | bl | no_right_turn | + | restriction | he | ed,dcb | bl | no_right_turn | + | restriction | oml | ld,de | ejk | no_u_turn | + + And the relations + | type | way:from | node:via | way:to | restriction | + | restriction | ap | p | pr | no_u_turn | + | restriction | rqb | b | ba | no_left_turn | + | restriction | ld | d | dcb | no_right_turn | + | restriction | oml | l | lk | no_left_turn | + | restriction | na | a | ab | no_left_turn | + | restriction | dcb | b | bl | no_right_turn | + | restriction | dcb | b | bcd | no_u_turn | + | restriction | bcd | d | dcb | no_u_turn | + | restriction | bl | l | ld | no_right_turn | + + # Additional relations to prevent u-turns on small roads polluting the results + And the relations + | type | way:from | node:via | way:to | restriction | + | restriction | eh | h | he | no_u_turn | + | restriction | ei | i | ie | no_u_turn | + + When I route I should get + | from | to | route | locations | + | 1 | 6 | pr,rst,tv,tv | _,r,t,_ | + | 1 | 3 | pr,rqb,bcd,de,eh,eh | _,r,b,d,e,_ | + | 1 | 4 | pr,rqb,bcd,de,ei,ei | _,r,b,d,e,_ | + | 1 | 7 | pr,rqb,bl,lk,kw,kw | _,r,b,l,k,_ | + | 1 | 8 | | | + | 2 | 6 | | | + | 2 | 3 | fe,eh,eh | _,e,_ | + | 2 | 4 | fe,ei,ei | _,e,_ | + | 2 | 7 | fe,ejk,kw,kw | _,e,k,_ | + | 2 | 8 | fe,de,bcd,ba,ap,ap | _,e,d,b,a,_ | + | 3 | 6 | eh,de,dgt,tv,tv | _,e,d,t,_ | + | 3 | 4 | eh,ei,ei | _,e,_ | + | 3 | 7 | eh,ejk,kw,kw | _,e,k,_ | + | 3 | 8 | eh,de,bcd,ba,ap,ap | _,e,d,b,a,_ | + | 4 | 6 | ei,de,dgt,tv,tv | _,e,d,t,_ | + | 4 | 3 | ei,eh,eh | _,e,_ | + | 4 | 7 | ei,ejk,kw,kw | _,e,k,_ | + | 4 | 8 | ei,de,bcd,ba,ap,ap | _,e,d,b,a,_ | + | 5 | 6 | xo,oml,ld,dgt,tv,tv | _,o,l,d,t,_ | + | 5 | 3 | xo,oml,ld,de,eh,eh | _,o,l,d,e,_ | + | 5 | 4 | xo,oml,ld,de,ei,ei | _,o,l,d,e,_ | + | 5 | 7 | | | + | 5 | 8 | xo,on,na,ap,ap | _,o,n,a,_ | + + + + @restriction-way @overlap @no_turning + Scenario: Car - Multiple via restriction with start and end on same node + # Example: https://www.openstreetmap.org/#map=19/52.41988/16.96088 + Given the node map + """ + |--g---f---e + a | | + |--b---c---d + + """ + + And the nodes + | node | highway | + | b | traffic_signals | + + And the ways + | nodes | oneway | name | + | abc | yes | enter | + | cd | yes | right | + | de | yes | up | + | ef | yes | left | + | fga | yes | exit | + | fc | yes | down | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | abc | cd,de,ef | fga | no_u_turn | + + When I route I should get + | from | to | route | locations | + | a | g | enter,right,up,left,down,right,up,left,exit,exit | a,c,d,e,f,c,d,e,f,g | + | b | a | enter,right,up,left,down,right,up,left,exit,exit | b,c,d,e,f,c,d,e,f,a | + # This is a correct but not within the spirit of the restriction. + # Does this indicate the restriction is not strong enough? + + + @restriction-way @no_turning + Scenario: Car - Multiple via restriction preventing bypassing main road + # Example: https://www.openstreetmap.org/#map=19/48.72429/21.25912 + Given the node map + """ + a--b--c--d--e--f + \ | + --g--h--i--j + | + k + """ + + And the nodes + | node | highway | + | d | traffic_signals | + | e | traffic_signals | + + And the ways + | nodes | oneway | name | + | ab | yes | main | + | bc | yes | main | + | cd | yes | main | + | de | yes | main | + | ef | yes | main | + | bg | yes | side | + | gh | yes | side | + | hi | yes | side | + | ij | yes | side | + | fj | yes | turn | + | jk | yes | turn | + + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | ab | bg,gh,hi,ij | jk | no_right_turn | + + When I route I should get + | from | to | route | + | a | k | main,turn,turn | + + + @restriction-way @overlap @no_turning @only_turning + Scenario: Car - Multiple via restriction with to,via,from sharing same node + # Example: https://www.openstreetmap.org/relation/3972923 + Given the node map + """ + e---d + | | + a---b---c + | + f + """ + + And the ways + | nodes | oneway | + | ab | yes | + | bc | yes | + | cd | yes | + | deb | yes | + | bf | yes | + + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | ab | bc,cd,deb | bf | no_u_turn | + + And the relations + | type | way:from | node:via | way:to | restriction | + | restriction | ab | b | bc | only_straight_on | + | restriction | deb | b | bc | no_left_turn | + + When I route I should get + | from | to | route | + | a | f | | + # The last restriction is missing from OSM. Without it, + # it produces the route: ab,bc,cd,deb,bc,cd,deb,bf,bf + + + @restriction-way @except + Scenario: Car - Multiple via restriction, exception applies + # Example: https://www.openstreetmap.org/#map=19/50.04920/19.93251 + Given the node map + """ + a---b---c---d--e + """ + + And the ways + | nodes | oneway | + | ab | yes | + | bc | yes | + | cd | yes | + | de | yes | + + + And the relations + | type | way:from | way:via | way:to | restriction | except | + | restriction | ab | bc,cd | de | no_straight_on | motorcar | + + When I route I should get + | from | to | route | + | a | e | ab,bc,cd,de,de | + + + @restriction-way @except @no_turning + Scenario: Car - Multiple via restriction, exception n/a + # Example: https://www.openstreetmap.org/#map=19/50.04920/19.93251 + Given the node map + """ + a---b---c---d--e + """ + + And the ways + | nodes | oneway | + | ab | yes | + | bc | yes | + | cd | yes | + | de | yes | + + + And the relations + | type | way:from | way:via | way:to | restriction | except | + | restriction | ab | bc,cd | de | no_straight_on | psv;emergency | + + When I route I should get + | from | to | route | + | a | e | | + + + @restriction-way @overlap @only_turning + Scenario: Car - Multiple via restriction overlapping single via restriction + Given the node map + """ + e + | + a---b---c---d + | + f - g + | + h + """ + + And the ways + | nodes | name | + | ab | abcd | + | bc | abcd | + | cd | abcd | + | hf | hfb | + | fb | hfb | + | gf | gf | + | ce | ce | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | ab | bc | ce | only_left_turn | + | restriction | gf | fb,bc | cd | only_u_turn | + + When I route I should get + | from | to | route | turns | locations | + | a | d | abcd,ce,ce,abcd,abcd | depart,turn left,continue uturn,turn left,arrive | a,c,e,c,d | + | a | e | abcd,ce,ce | depart,turn left,arrive | a,c,e | + | a | f | abcd,hfb,hfb | depart,turn right,arrive | a,b,f | + | g | e | gf,hfb,abcd,abcd,ce,ce | depart,turn right,turn right,continue uturn,turn right,arrive | g,f,b,d,c,e | + | g | d | gf,hfb,abcd,abcd | depart,turn right,turn right,arrive | g,f,b,d | + | h | e | hfb,abcd,ce,ce | depart,end of road right,turn left,arrive | h,b,c,e | + | h | d | hfb,abcd,abcd | depart,end of road right,arrive | h,b,d | + + + @restriction-way + Scenario: Ambiguous from/to ways + Given the node map + """ + a + | + b---d---e + | | + c f + """ + + And the ways + | nodes | + | abc | + | bd | + | de | + | ef | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | abc | bd,de | ef | no_right_turn | + | restriction | ef | de,bd | abc | no_right_turn | + + When I route I should get + | from | to | route | locations | + | a | f | abc,bd,de,ef,ef | a,b,d,e,f | + | f | a | ef,de,bd,abc,abc | f,e,d,b,a | + | c | f | abc,bd,de,ef,ef | c,b,d,e,f | + | f | c | ef,de,bd,abc,abc | f,e,d,b,c | + + + @restriction-way + Scenario: Ambiguous via ways + Given the node map + """ + a + | + b---d---e---c + | + f + """ + + And the ways + | nodes | + | ab | + | bd | + | dec | + | ef | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | ab | bd,dec | ef | no_right_turn | + | restriction | ef | dec,bd | ab | no_right_turn | + + When I route I should get + | from | to | route | locations | + | a | f | ab,bd,dec,ef,ef | a,b,d,e,f | + | f | a | ef,dec,bd,ab,ab | f,e,d,b,a | + + + @restriction-way @invalid + Scenario: Badly tagged restrictions + Given the node map + """ + a--b--c--d--e--f + """ + + And the ways + | nodes | oneway | + | ab | yes | + | bc | yes | + | cd | yes | + | de | yes | + | ef | yes | + + And the relations + | type | way:from | way:via | way:to | restriction | + | restriction | ab | cd,de | ef | no_straight_on | + | restriction | ab | bc,de | ef | no_straight_on | + | restriction | ab | bc,cd | ef | no_straight_on | + | restriction | ef | de,cd | bc | no_straight_on | + + When I route I should get + | from | to | route | locations | + | a | f | ab,bc,cd,de,ef,ef | a,b,c,d,e,f | + diff --git a/features/car/physical_limitation.feature b/features/car/physical_limitation.feature index 43eef90f8..ba7119c67 100644 --- a/features/car/physical_limitation.feature +++ b/features/car/physical_limitation.feature @@ -43,6 +43,7 @@ Feature: Car - Handle physical limitation | primary | 1 | | | | primary | 3 | | x | | primary | | 1 | | + | primary | | 8' | x | | primary | | 3 | x | | primary | | default | x | | primary | | none | x | @@ -62,6 +63,7 @@ Feature: Car - Handle physical limitation | highway | maxweight | bothw | | primary | | x | | primary | 1 | | + | primary | 2 | x | | primary | 3.5 | x | | primary | 35000 kg | x | | primary | 8.9t | x | diff --git a/features/car/restrictions.feature b/features/car/restrictions.feature index 80cb5b95e..da76f4ded 100644 --- a/features/car/restrictions.feature +++ b/features/car/restrictions.feature @@ -798,82 +798,6 @@ Feature: Car - Turn restrictions | from | to | route | | a | d | ab,be,de,de | - @restriction-way - Scenario: Multi Way restriction - Given the node map - """ - k j - | | - h - - g - f - - e - | | - | | - a - - b - c - - d - | | - l i - """ - - And the ways - | nodes | name | oneway | - | ab | horiz | yes | - | bc | horiz | yes | - | cd | horiz | yes | - | ef | horiz | yes | - | fg | horiz | yes | - | gh | horiz | yes | - | ic | vert | yes | - | cf | vert | yes | - | fj | vert | yes | - | kg | vert | yes | - | gb | vert | yes | - | bl | vert | yes | - - And the relations - | type | way:from | way:via | way:to | restriction | - | restriction | ab | bc,cf,fg | gh | no_u_turn | - - When I route I should get - | from | to | route | - | a | h | horiz,vert,horiz,horiz | - - @restriction-way - Scenario: Multi-Way overlapping single-way - Given the node map - """ - e - | - a - b - c - d - | - f - g - | - h - """ - - And the ways - | nodes | name | - | ab | abcd | - | bc | abcd | - | cd | abcd | - | hf | hfb | - | fb | hfb | - | gf | gf | - | ce | ce | - - And the relations - | type | way:from | way:via | way:to | restriction | - | restriction | ab | bc | ce | only_left_turn | - | restriction | gf | fb,bc | cd | only_u_turn | - - When I route I should get - | from | to | route | turns | locations | - | a | d | abcd,ce,ce,abcd,abcd | depart,turn left,continue uturn,turn left,arrive | a,c,e,c,d | - | a | e | abcd,ce,ce | depart,turn left,arrive | a,c,e | - | a | f | abcd,hfb,hfb | depart,turn right,arrive | a,b,f | - | g | e | gf,hfb,abcd,ce,ce | depart,turn right,turn right,turn left,arrive | g,f,b,c,e | - | g | d | gf,hfb,abcd,abcd | depart,turn right,turn right,arrive | g,f,b,d | - | h | e | hfb,abcd,ce,ce | depart,end of road right,turn left,arrive | h,b,c,e | - | h | d | hfb,abcd,abcd | depart,end of road right,arrive | h,b,d | - - @restriction-way Scenario: Car - prohibit turn, traffic lights Given the node map @@ -984,8 +908,6 @@ Feature: Car - Turn restrictions | restriction | ab | bge | de | no_right_turn | | restriction | bc | bge | ef | no_left_turn | - # this case is currently not handling the via-way restrictions and we need support for looking across traffic signals. - # It is mainly included to show limitations and to prove that we don't crash hard here When I route I should get | from | to | route | | a | d | ab,bge,ef,ef,de,de | diff --git a/features/car/startpoint.feature b/features/car/startpoint.feature index 965f57d43..9e753843b 100644 --- a/features/car/startpoint.feature +++ b/features/car/startpoint.feature @@ -35,3 +35,91 @@ Feature: Car - Allowed start/end modes | from | to | route | modes | | 1 | 2 | ab,ab | driving,driving | | 2 | 1 | ab,ab | driving,driving | + + Scenario: Car - URL override of non-startpoints + Given the node map + """ + a 1 b c 2 d + """ + + Given the query options + | snapping | any | + + And the ways + | nodes | highway | access | + | ab | service | private | + | bc | primary | | + | cd | service | private | + + When I request a travel time matrix I should get + | | 2 | c | + | 1 | 59.1 | 35.1 | + | b | 35.1 | 11.1 | + + When I route I should get + | from | to | route | + | 1 | 2 | ab,bc,cd | + | 2 | 1 | cd,bc,ab | + + Scenario: Car - URL override of non-startpoints + Given the node map + """ + a 1 b c 2 d + """ + + Given the query options + | snapping | any | + | bearings | 90,180; | + + And the ways + | nodes | highway | access | + | ab | service | private | + | bc | primary | | + | cd | service | private | + + When I route I should get + | from | to | route | + | 1 | 2 | ab,bc,cd | + | 2 | 1 | cd,bc,ab | + + Scenario: Car - URL override of non-startpoints + Given the node map + """ + a 1 b c 2 d + """ + + Given the query options + | snapping | any | + | radiuses | 100;unlimited | + + And the ways + | nodes | highway | access | + | ab | service | private | + | bc | primary | | + | cd | service | private | + + When I route I should get + | from | to | route | + | 1 | 2 | ab,bc,cd | + | 2 | 1 | cd,bc,ab | + + Scenario: Car - URL override of non-startpoints + Given the node map + """ + a 1 b c 2 d + """ + + Given the query options + | snapping | any | + | bearings | 90,180;0,180;; | + + And the ways + | nodes | highway | access | + | ab | service | private | + | bc | primary | | + | cd | service | private | + + When I request a travel time matrix I should get + | | 2 | c | + | 1 | 59.1 | 35.1 | + | b | 35.1 | 11.1 | \ No newline at end of file diff --git a/features/nearest/projection.feature b/features/nearest/projection.feature index 3d9e6aa30..dc3ba94c0 100644 --- a/features/nearest/projection.feature +++ b/features/nearest/projection.feature @@ -111,3 +111,28 @@ Feature: Locating Nearest node on a Way - basic projection onto way | 7 | b | | 8 | a | | 9 | b | + + Scenario: Nearest - easy-west way with flatbuffers + Given the node map + """ + 0 1 2 3 4 + a x b + 5 6 7 8 9 + """ + + And the ways + | nodes | + | ab | + + When I request nearest with flatbuffers I should get + | in | out | + | 0 | a | + | 1 | a | + | 2 | x | + | 3 | b | + | 4 | b | + | 5 | a | + | 6 | a | + | 7 | x | + | 8 | b | + | 9 | b | diff --git a/features/options/extract/turn_function.feature b/features/options/extract/turn_function.feature index a1db9339f..eecb29604 100644 --- a/features/options/extract/turn_function.feature +++ b/features/options/extract/turn_function.feature @@ -180,3 +180,30 @@ Feature: Turn Function Information And stdout should contain /roads_on_the_right \[1\] speed: [0-9]+, is_incoming: true, is_outgoing: false, highway_turn_classification: 3, access_turn_classification: 0/ # turning abc, give information about about db And stdout should contain /roads_on_the_left \[1\] speed: [0-9]+, is_incoming: true, is_outgoing: false, highway_turn_classification: 0, access_turn_classification: 1/ + + Scenario: Turns should have correct information of two-way roads at intersection + Given the node map + """ + b + | + a-c-d + | + e + """ + And the ways + | nodes | highway | oneway | + | ac | motorway | yes | + | cd | motorway_link | yes | + | bc | trunk | yes | + | cb | trunk_link | yes | + | ce | primary | yes | + | ec | primary_link | yes | + And the data has been saved to disk + + When I run "osrm-extract --profile {profile_file} {osm_file}" + Then it should exit successfully + # Turn acd + # on the left there should be cb (and bc) + And stdout should contain /roads_on_the_left \[1\] speed: [0-9]+, is_incoming: true, is_outgoing: true, highway_turn_classification: [0-9]+, access_turn_classification: 0, priority_class: 3/ + # on the right there should be ce and ec + And stdout should contain /roads_on_the_right \[1\] speed: [0-9]+, is_incoming: true, is_outgoing: true, highway_turn_classification: [0-9]+, access_turn_classification: 0, priority_class: 4/ diff --git a/features/step_definitions/distance_matrix.js b/features/step_definitions/distance_matrix.js index 594268d50..37de07a26 100644 --- a/features/step_definitions/distance_matrix.js +++ b/features/step_definitions/distance_matrix.js @@ -1,27 +1,38 @@ var util = require('util'); +var flatbuffers = require('../support/flatbuffers').flatbuffers; +var FBResult = require('../support/fbresult_generated').osrm.engine.api.fbresult.FBResult; + module.exports = function () { const durationsRegex = new RegExp(/^I request a travel time matrix I should get$/); const distancesRegex = new RegExp(/^I request a travel distance matrix I should get$/); const estimatesRegex = new RegExp(/^I request a travel time matrix I should get estimates for$/); + const durationsRegexFb = new RegExp(/^I request a travel time matrix with flatbuffers I should get$/); + const distancesRegexFb = new RegExp(/^I request a travel distance matrix with flatbuffers I should get$/); const DURATIONS_NO_ROUTE = 2147483647; // MAX_INT const DISTANCES_NO_ROUTE = 3.40282e+38; // MAX_FLOAT - this.When(durationsRegex, function(table, callback) {tableParse.call(this, table, DURATIONS_NO_ROUTE, 'durations', callback);}.bind(this)); - this.When(distancesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'distances', callback);}.bind(this)); - this.When(estimatesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'fallback_speed_cells', callback);}.bind(this)); + const FORMAT_JSON = 'json'; + const FORMAT_FB = 'flatbuffers'; + + this.When(durationsRegex, function(table, callback) {tableParse.call(this, table, DURATIONS_NO_ROUTE, 'durations', FORMAT_JSON, callback);}.bind(this)); + this.When(distancesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'distances', FORMAT_JSON, callback);}.bind(this)); + this.When(estimatesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'fallback_speed_cells', FORMAT_JSON, callback);}.bind(this)); + this.When(durationsRegexFb, function(table, callback) {tableParse.call(this, table, DURATIONS_NO_ROUTE, 'durations', FORMAT_FB, callback);}.bind(this)); + this.When(distancesRegexFb, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'distances', FORMAT_FB, callback);}.bind(this)); }; const durationsParse = function(v) { return isNaN(parseInt(v)); }; const distancesParse = function(v) { return isNaN(parseFloat(v)); }; const estimatesParse = function(v) { return isNaN(parseFloat(v)); }; -function tableParse(table, noRoute, annotation, callback) { +function tableParse(table, noRoute, annotation, format, callback) { const parse = annotation == 'distances' ? distancesParse : (annotation == 'durations' ? durationsParse : estimatesParse); const params = this.queryParams; params.annotations = ['durations','fallback_speed_cells'].indexOf(annotation) !== -1 ? 'duration' : 'distance'; + params.output = format; var tableRows = table.raw(); @@ -62,27 +73,53 @@ function tableParse(table, noRoute, annotation, callback) { if (err) return callback(err); if (!response.body.length) return callback(new Error('Invalid response body')); - var json = JSON.parse(response.body); + var result = []; + if (format === 'json') { + var json = JSON.parse(response.body); - var result = {}; - if (annotation === 'fallback_speed_cells') { - result = table.raw().map(row => row.map(() => '')); - json[annotation].forEach(pair => { - result[pair[0]+1][pair[1]+1] = 'Y'; - }); - result = result.slice(1).map(row => { - var hashes = {}; - row.slice(1).forEach((v,i) => { - hashes[tableRows[0][i+1]] = v; + if (annotation === 'fallback_speed_cells') { + result = table.raw().map(row => row.map(() => '')); + json[annotation].forEach(pair => { + result[pair[0]+1][pair[1]+1] = 'Y'; }); - return hashes; - }); - } else { - result = json[annotation].map(row => { - var hashes = {}; - row.forEach((v, i) => { hashes[tableRows[0][i+1]] = parse(v) ? '' : v; }); - return hashes; - }); + result = result.slice(1).map(row => { + var hashes = {}; + row.slice(1).forEach((v,i) => { + hashes[tableRows[0][i+1]] = v; + }); + return hashes; + }); + } else { + result = json[annotation].map(row => { + var hashes = {}; + row.forEach((v, i) => { hashes[tableRows[0][i+1]] = parse(v) ? '' : v; }); + return hashes; + }); + } + } else { //flatbuffers + var body = response.body; + var bytes = new Uint8Array(body.length); + for (var indx = 0; indx < body.length; ++indx) { + bytes[indx] = body.charCodeAt(indx); + } + var buf = new flatbuffers.ByteBuffer(bytes); + var fb = FBResult.getRootAsFBResult(buf); + + var matrix; + if (annotation === 'durations') { + matrix = fb.table().durationsArray(); + } + if (annotation === 'distances') { + matrix = fb.table().distancesArray(); + } + var cols = fb.table().cols(); + var rows = fb.table().rows(); + for (let r = 0; r < rows; ++r) { + result[r]={}; + for(let c=0; c < cols; ++c) { + result[r][tableRows[0][c+1]] = matrix[r*cols + c]; + } + } } var testRow = (row, ri, cb) => { diff --git a/features/step_definitions/nearest.js b/features/step_definitions/nearest.js index f5627b842..ae4079b8d 100644 --- a/features/step_definitions/nearest.js +++ b/features/step_definitions/nearest.js @@ -1,5 +1,8 @@ var util = require('util'); +var flatbuffers = require('../support/flatbuffers').flatbuffers; +var FBResult = require('../support/fbresult_generated').osrm.engine.api.fbresult.FBResult; + module.exports = function () { this.When(/^I request nearest I should get$/, (table, callback) => { this.reprocessAndLoadData((e) => { @@ -43,4 +46,55 @@ module.exports = function () { this.processRowsAndDiff(table, testRow, callback); }); }); + + this.When(/^I request nearest with flatbuffers I should get$/, (table, callback) => { + this.reprocessAndLoadData((e) => { + if (e) return callback(e); + 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.queryParams.output = 'flatbuffers'; + this.requestNearest(inNode, this.queryParams, (err, response) => { + if (err) return cb(err); + var coord; + + if (response.statusCode === 200 && response.body.length) { + var body = response.body; + var bytes = new Uint8Array(body.length); + for (var indx = 0; indx < body.length; ++indx) { + bytes[indx] = body.charCodeAt(indx); + } + var buf = new flatbuffers.ByteBuffer(bytes); + var fb = FBResult.getRootAsFBResult(buf); + var location = fb.waypoints(0).location(); + + coord = [location.longitude(), location.latitude()]; + + var got = { in: row.in, out: row.out }; + + 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); + } + } + }); + + cb(null, got); + } + else { + cb(); + } + }); + }; + + this.processRowsAndDiff(table, testRow, callback); + }); + }); }; diff --git a/features/step_definitions/routing.js b/features/step_definitions/routing.js index c3e679aa5..136add5ef 100644 --- a/features/step_definitions/routing.js +++ b/features/step_definitions/routing.js @@ -12,4 +12,9 @@ module.exports = function () { q.awaitAll(callback); }); + + this.Given(/^skip waypoints$/, (callback) => { + this.queryParams['skip_waypoints'] = true; + callback(); + }); }; diff --git a/features/support/env.js b/features/support/env.js index a76938c16..9b4c5acc9 100644 --- a/features/support/env.js +++ b/features/support/env.js @@ -22,14 +22,9 @@ module.exports = function () { this.PROFILES_PATH = path.resolve(this.ROOT_PATH, 'profiles'); this.FIXTURES_PATH = path.resolve(this.ROOT_PATH, 'unit_tests/fixtures'); this.BIN_PATH = process.env.OSRM_BUILD_DIR && process.env.OSRM_BUILD_DIR || path.resolve(this.ROOT_PATH, 'build'); - var stxxl_config = path.resolve(this.ROOT_PATH, 'test/.stxxl'); - if (!fs.existsSync(stxxl_config)) { - return callback(new Error('*** '+stxxl_config+ 'does not exist')); - } - this.DATASET_NAME = 'cucumber'; this.PLATFORM_WINDOWS = process.platform.match(/^win.*/); - this.DEFAULT_ENVIRONMENT = Object.assign({STXXLCFG: stxxl_config}, process.env); + this.DEFAULT_ENVIRONMENT = process.env; this.DEFAULT_PROFILE = 'bicycle'; this.DEFAULT_INPUT_FORMAT = 'osm'; this.DEFAULT_LOAD_METHOD = process.argv[process.argv.indexOf('-m') +1].match('mmap') ? 'mmap' : 'datastore'; diff --git a/features/support/fbresult_generated.js b/features/support/fbresult_generated.js new file mode 100644 index 000000000..d418e1bc4 --- /dev/null +++ b/features/support/fbresult_generated.js @@ -0,0 +1,3217 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @const + * @namespace + */ +var osrm = osrm || {}; + +/** + * @const + * @namespace + */ +osrm.engine = osrm.engine || {}; + +/** + * @const + * @namespace + */ +osrm.engine.api = osrm.engine.api || {}; + +/** + * @const + * @namespace + */ +osrm.engine.api.fbresult = osrm.engine.api.fbresult || {}; + +/** + * @enum {number} + */ +osrm.engine.api.fbresult.ManeuverType = { + Turn: 0, + NewName: 1, + Depart: 2, + Arrive: 3, + Merge: 4, + OnRamp: 5, + OffRamp: 6, + Fork: 7, + EndOfRoad: 8, + Continue: 9, + Roundabout: 10, + Rotary: 11, + RoundaboutTurn: 12, + Notification: 13, + ExitRoundabout: 14, + ExitRotary: 15 +}; + +/** + * @enum {string} + */ +osrm.engine.api.fbresult.ManeuverTypeName = { + 0: 'Turn', + 1: 'NewName', + 2: 'Depart', + 3: 'Arrive', + 4: 'Merge', + 5: 'OnRamp', + 6: 'OffRamp', + 7: 'Fork', + 8: 'EndOfRoad', + 9: 'Continue', + 10: 'Roundabout', + 11: 'Rotary', + 12: 'RoundaboutTurn', + 13: 'Notification', + 14: 'ExitRoundabout', + 15: 'ExitRotary' +}; + +/** + * @enum {number} + */ +osrm.engine.api.fbresult.Turn = { + None: 0, + UTurn: 1, + SharpRight: 2, + Right: 3, + SlightRight: 4, + Straight: 5, + SlightLeft: 6, + Left: 7, + SharpLeft: 8 +}; + +/** + * @enum {string} + */ +osrm.engine.api.fbresult.TurnName = { + 0: 'None', + 1: 'UTurn', + 2: 'SharpRight', + 3: 'Right', + 4: 'SlightRight', + 5: 'Straight', + 6: 'SlightLeft', + 7: 'Left', + 8: 'SharpLeft' +}; + +/** + * @constructor + */ +osrm.engine.api.fbresult.Position = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.Position} + */ +osrm.engine.api.fbresult.Position.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Position.prototype.longitude = function() { + return this.bb.readFloat32(this.bb_pos); +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Position.prototype.latitude = function() { + return this.bb.readFloat32(this.bb_pos + 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} longitude + * @param {number} latitude + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Position.createPosition = function(builder, longitude, latitude) { + builder.prep(4, 8); + builder.writeFloat32(latitude); + builder.writeFloat32(longitude); + return builder.offset(); +}; + +/** + * @constructor + */ +osrm.engine.api.fbresult.Uint64Pair = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.Uint64Pair} + */ +osrm.engine.api.fbresult.Uint64Pair.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @returns {flatbuffers.Long} + */ +osrm.engine.api.fbresult.Uint64Pair.prototype.first = function() { + return this.bb.readUint64(this.bb_pos); +}; + +/** + * @returns {flatbuffers.Long} + */ +osrm.engine.api.fbresult.Uint64Pair.prototype.second = function() { + return this.bb.readUint64(this.bb_pos + 8); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Long} first + * @param {flatbuffers.Long} second + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Uint64Pair.createUint64Pair = function(builder, first, second) { + builder.prep(8, 16); + builder.writeInt64(second); + builder.writeInt64(first); + return builder.offset(); +}; + +/** + * @constructor + */ +osrm.engine.api.fbresult.Waypoint = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.Waypoint} + */ +osrm.engine.api.fbresult.Waypoint.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Waypoint=} obj + * @returns {osrm.engine.api.fbresult.Waypoint} + */ +osrm.engine.api.fbresult.Waypoint.getRootAsWaypoint = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Waypoint).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Waypoint=} obj + * @returns {osrm.engine.api.fbresult.Waypoint} + */ +osrm.engine.api.fbresult.Waypoint.getSizePrefixedRootAsWaypoint = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Waypoint).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Waypoint.prototype.hint = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Waypoint.prototype.distance = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Waypoint.prototype.name = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {osrm.engine.api.fbresult.Position=} obj + * @returns {osrm.engine.api.fbresult.Position|null} + */ +osrm.engine.api.fbresult.Waypoint.prototype.location = function(obj) { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? (obj || new osrm.engine.api.fbresult.Position).__init(this.bb_pos + offset, this.bb) : null; +}; + +/** + * @param {osrm.engine.api.fbresult.Uint64Pair=} obj + * @returns {osrm.engine.api.fbresult.Uint64Pair|null} + */ +osrm.engine.api.fbresult.Waypoint.prototype.nodes = function(obj) { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? (obj || new osrm.engine.api.fbresult.Uint64Pair).__init(this.bb_pos + offset, this.bb) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Waypoint.prototype.matchingsIndex = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Waypoint.prototype.waypointIndex = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Waypoint.prototype.alternativesCount = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Waypoint.prototype.tripsIndex = function() { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +osrm.engine.api.fbresult.Waypoint.startWaypoint = function(builder) { + builder.startObject(9); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} hintOffset + */ +osrm.engine.api.fbresult.Waypoint.addHint = function(builder, hintOffset) { + builder.addFieldOffset(0, hintOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} distance + */ +osrm.engine.api.fbresult.Waypoint.addDistance = function(builder, distance) { + builder.addFieldFloat32(1, distance, 0.0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} nameOffset + */ +osrm.engine.api.fbresult.Waypoint.addName = function(builder, nameOffset) { + builder.addFieldOffset(2, nameOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} locationOffset + */ +osrm.engine.api.fbresult.Waypoint.addLocation = function(builder, locationOffset) { + builder.addFieldStruct(3, locationOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} nodesOffset + */ +osrm.engine.api.fbresult.Waypoint.addNodes = function(builder, nodesOffset) { + builder.addFieldStruct(4, nodesOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} matchingsIndex + */ +osrm.engine.api.fbresult.Waypoint.addMatchingsIndex = function(builder, matchingsIndex) { + builder.addFieldInt32(5, matchingsIndex, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} waypointIndex + */ +osrm.engine.api.fbresult.Waypoint.addWaypointIndex = function(builder, waypointIndex) { + builder.addFieldInt32(6, waypointIndex, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} alternativesCount + */ +osrm.engine.api.fbresult.Waypoint.addAlternativesCount = function(builder, alternativesCount) { + builder.addFieldInt32(7, alternativesCount, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} tripsIndex + */ +osrm.engine.api.fbresult.Waypoint.addTripsIndex = function(builder, tripsIndex) { + builder.addFieldInt32(8, tripsIndex, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Waypoint.endWaypoint = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} hintOffset + * @param {number} distance + * @param {flatbuffers.Offset} nameOffset + * @param {flatbuffers.Offset} locationOffset + * @param {flatbuffers.Offset} nodesOffset + * @param {number} matchingsIndex + * @param {number} waypointIndex + * @param {number} alternativesCount + * @param {number} tripsIndex + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Waypoint.createWaypoint = function(builder, hintOffset, distance, nameOffset, locationOffset, nodesOffset, matchingsIndex, waypointIndex, alternativesCount, tripsIndex) { + osrm.engine.api.fbresult.Waypoint.startWaypoint(builder); + osrm.engine.api.fbresult.Waypoint.addHint(builder, hintOffset); + osrm.engine.api.fbresult.Waypoint.addDistance(builder, distance); + osrm.engine.api.fbresult.Waypoint.addName(builder, nameOffset); + osrm.engine.api.fbresult.Waypoint.addLocation(builder, locationOffset); + osrm.engine.api.fbresult.Waypoint.addNodes(builder, nodesOffset); + osrm.engine.api.fbresult.Waypoint.addMatchingsIndex(builder, matchingsIndex); + osrm.engine.api.fbresult.Waypoint.addWaypointIndex(builder, waypointIndex); + osrm.engine.api.fbresult.Waypoint.addAlternativesCount(builder, alternativesCount); + osrm.engine.api.fbresult.Waypoint.addTripsIndex(builder, tripsIndex); + return osrm.engine.api.fbresult.Waypoint.endWaypoint(builder); +} + +/** + * @constructor + */ +osrm.engine.api.fbresult.Metadata = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.Metadata} + */ +osrm.engine.api.fbresult.Metadata.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Metadata=} obj + * @returns {osrm.engine.api.fbresult.Metadata} + */ +osrm.engine.api.fbresult.Metadata.getRootAsMetadata = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Metadata).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Metadata=} obj + * @returns {osrm.engine.api.fbresult.Metadata} + */ +osrm.engine.api.fbresult.Metadata.getSizePrefixedRootAsMetadata = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Metadata).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {number} index + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array} + */ +osrm.engine.api.fbresult.Metadata.prototype.datasourceNames = function(index, optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Metadata.prototype.datasourceNamesLength = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +osrm.engine.api.fbresult.Metadata.startMetadata = function(builder) { + builder.startObject(1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} datasourceNamesOffset + */ +osrm.engine.api.fbresult.Metadata.addDatasourceNames = function(builder, datasourceNamesOffset) { + builder.addFieldOffset(0, datasourceNamesOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Metadata.createDatasourceNamesVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Metadata.startDatasourceNamesVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Metadata.endMetadata = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} datasourceNamesOffset + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Metadata.createMetadata = function(builder, datasourceNamesOffset) { + osrm.engine.api.fbresult.Metadata.startMetadata(builder); + osrm.engine.api.fbresult.Metadata.addDatasourceNames(builder, datasourceNamesOffset); + return osrm.engine.api.fbresult.Metadata.endMetadata(builder); +} + +/** + * @constructor + */ +osrm.engine.api.fbresult.Annotation = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.Annotation} + */ +osrm.engine.api.fbresult.Annotation.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Annotation=} obj + * @returns {osrm.engine.api.fbresult.Annotation} + */ +osrm.engine.api.fbresult.Annotation.getRootAsAnnotation = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Annotation).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Annotation=} obj + * @returns {osrm.engine.api.fbresult.Annotation} + */ +osrm.engine.api.fbresult.Annotation.getSizePrefixedRootAsAnnotation = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Annotation).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {number} index + * @returns {number} + */ +osrm.engine.api.fbresult.Annotation.prototype.distance = function(index) { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Annotation.prototype.distanceLength = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +osrm.engine.api.fbresult.Annotation.prototype.distanceArray = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? new Uint32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; +}; + +/** + * @param {number} index + * @returns {number} + */ +osrm.engine.api.fbresult.Annotation.prototype.duration = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Annotation.prototype.durationLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +osrm.engine.api.fbresult.Annotation.prototype.durationArray = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? new Uint32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; +}; + +/** + * @param {number} index + * @returns {number} + */ +osrm.engine.api.fbresult.Annotation.prototype.datasources = function(index) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Annotation.prototype.datasourcesLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +osrm.engine.api.fbresult.Annotation.prototype.datasourcesArray = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? new Uint32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; +}; + +/** + * @param {number} index + * @returns {number} + */ +osrm.engine.api.fbresult.Annotation.prototype.nodes = function(index) { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Annotation.prototype.nodesLength = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +osrm.engine.api.fbresult.Annotation.prototype.nodesArray = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? new Uint32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; +}; + +/** + * @param {number} index + * @returns {number} + */ +osrm.engine.api.fbresult.Annotation.prototype.weight = function(index) { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Annotation.prototype.weightLength = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +osrm.engine.api.fbresult.Annotation.prototype.weightArray = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? new Uint32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; +}; + +/** + * @param {number} index + * @returns {number} + */ +osrm.engine.api.fbresult.Annotation.prototype.speed = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readFloat32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Annotation.prototype.speedLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Float32Array} + */ +osrm.engine.api.fbresult.Annotation.prototype.speedArray = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? new Float32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; +}; + +/** + * @param {osrm.engine.api.fbresult.Metadata=} obj + * @returns {osrm.engine.api.fbresult.Metadata|null} + */ +osrm.engine.api.fbresult.Annotation.prototype.metadata = function(obj) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? (obj || new osrm.engine.api.fbresult.Metadata).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +osrm.engine.api.fbresult.Annotation.startAnnotation = function(builder) { + builder.startObject(7); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} distanceOffset + */ +osrm.engine.api.fbresult.Annotation.addDistance = function(builder, distanceOffset) { + builder.addFieldOffset(0, distanceOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Annotation.createDistanceVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Annotation.startDistanceVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} durationOffset + */ +osrm.engine.api.fbresult.Annotation.addDuration = function(builder, durationOffset) { + builder.addFieldOffset(1, durationOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Annotation.createDurationVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Annotation.startDurationVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} datasourcesOffset + */ +osrm.engine.api.fbresult.Annotation.addDatasources = function(builder, datasourcesOffset) { + builder.addFieldOffset(2, datasourcesOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Annotation.createDatasourcesVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Annotation.startDatasourcesVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} nodesOffset + */ +osrm.engine.api.fbresult.Annotation.addNodes = function(builder, nodesOffset) { + builder.addFieldOffset(3, nodesOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Annotation.createNodesVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Annotation.startNodesVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} weightOffset + */ +osrm.engine.api.fbresult.Annotation.addWeight = function(builder, weightOffset) { + builder.addFieldOffset(4, weightOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Annotation.createWeightVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Annotation.startWeightVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} speedOffset + */ +osrm.engine.api.fbresult.Annotation.addSpeed = function(builder, speedOffset) { + builder.addFieldOffset(5, speedOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Annotation.createSpeedVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addFloat32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Annotation.startSpeedVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} metadataOffset + */ +osrm.engine.api.fbresult.Annotation.addMetadata = function(builder, metadataOffset) { + builder.addFieldOffset(6, metadataOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Annotation.endAnnotation = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} distanceOffset + * @param {flatbuffers.Offset} durationOffset + * @param {flatbuffers.Offset} datasourcesOffset + * @param {flatbuffers.Offset} nodesOffset + * @param {flatbuffers.Offset} weightOffset + * @param {flatbuffers.Offset} speedOffset + * @param {flatbuffers.Offset} metadataOffset + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Annotation.createAnnotation = function(builder, distanceOffset, durationOffset, datasourcesOffset, nodesOffset, weightOffset, speedOffset, metadataOffset) { + osrm.engine.api.fbresult.Annotation.startAnnotation(builder); + osrm.engine.api.fbresult.Annotation.addDistance(builder, distanceOffset); + osrm.engine.api.fbresult.Annotation.addDuration(builder, durationOffset); + osrm.engine.api.fbresult.Annotation.addDatasources(builder, datasourcesOffset); + osrm.engine.api.fbresult.Annotation.addNodes(builder, nodesOffset); + osrm.engine.api.fbresult.Annotation.addWeight(builder, weightOffset); + osrm.engine.api.fbresult.Annotation.addSpeed(builder, speedOffset); + osrm.engine.api.fbresult.Annotation.addMetadata(builder, metadataOffset); + return osrm.engine.api.fbresult.Annotation.endAnnotation(builder); +} + +/** + * @constructor + */ +osrm.engine.api.fbresult.StepManeuver = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.StepManeuver} + */ +osrm.engine.api.fbresult.StepManeuver.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.StepManeuver=} obj + * @returns {osrm.engine.api.fbresult.StepManeuver} + */ +osrm.engine.api.fbresult.StepManeuver.getRootAsStepManeuver = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.StepManeuver).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.StepManeuver=} obj + * @returns {osrm.engine.api.fbresult.StepManeuver} + */ +osrm.engine.api.fbresult.StepManeuver.getSizePrefixedRootAsStepManeuver = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.StepManeuver).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {osrm.engine.api.fbresult.Position=} obj + * @returns {osrm.engine.api.fbresult.Position|null} + */ +osrm.engine.api.fbresult.StepManeuver.prototype.location = function(obj) { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (obj || new osrm.engine.api.fbresult.Position).__init(this.bb_pos + offset, this.bb) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.StepManeuver.prototype.bearingBefore = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.StepManeuver.prototype.bearingAfter = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {osrm.engine.api.fbresult.ManeuverType} + */ +osrm.engine.api.fbresult.StepManeuver.prototype.type = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? /** @type {osrm.engine.api.fbresult.ManeuverType} */ (this.bb.readInt8(this.bb_pos + offset)) : osrm.engine.api.fbresult.ManeuverType.Turn; +}; + +/** + * @returns {osrm.engine.api.fbresult.Turn} + */ +osrm.engine.api.fbresult.StepManeuver.prototype.modifier = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? /** @type {osrm.engine.api.fbresult.Turn} */ (this.bb.readInt8(this.bb_pos + offset)) : osrm.engine.api.fbresult.Turn.None; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.StepManeuver.prototype.exit = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +osrm.engine.api.fbresult.StepManeuver.startStepManeuver = function(builder) { + builder.startObject(6); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} locationOffset + */ +osrm.engine.api.fbresult.StepManeuver.addLocation = function(builder, locationOffset) { + builder.addFieldStruct(0, locationOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} bearingBefore + */ +osrm.engine.api.fbresult.StepManeuver.addBearingBefore = function(builder, bearingBefore) { + builder.addFieldInt16(1, bearingBefore, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} bearingAfter + */ +osrm.engine.api.fbresult.StepManeuver.addBearingAfter = function(builder, bearingAfter) { + builder.addFieldInt16(2, bearingAfter, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {osrm.engine.api.fbresult.ManeuverType} type + */ +osrm.engine.api.fbresult.StepManeuver.addType = function(builder, type) { + builder.addFieldInt8(3, type, osrm.engine.api.fbresult.ManeuverType.Turn); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {osrm.engine.api.fbresult.Turn} modifier + */ +osrm.engine.api.fbresult.StepManeuver.addModifier = function(builder, modifier) { + builder.addFieldInt8(4, modifier, osrm.engine.api.fbresult.Turn.None); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} exit + */ +osrm.engine.api.fbresult.StepManeuver.addExit = function(builder, exit) { + builder.addFieldInt8(5, exit, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.StepManeuver.endStepManeuver = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} locationOffset + * @param {number} bearingBefore + * @param {number} bearingAfter + * @param {osrm.engine.api.fbresult.ManeuverType} type + * @param {osrm.engine.api.fbresult.Turn} modifier + * @param {number} exit + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.StepManeuver.createStepManeuver = function(builder, locationOffset, bearingBefore, bearingAfter, type, modifier, exit) { + osrm.engine.api.fbresult.StepManeuver.startStepManeuver(builder); + osrm.engine.api.fbresult.StepManeuver.addLocation(builder, locationOffset); + osrm.engine.api.fbresult.StepManeuver.addBearingBefore(builder, bearingBefore); + osrm.engine.api.fbresult.StepManeuver.addBearingAfter(builder, bearingAfter); + osrm.engine.api.fbresult.StepManeuver.addType(builder, type); + osrm.engine.api.fbresult.StepManeuver.addModifier(builder, modifier); + osrm.engine.api.fbresult.StepManeuver.addExit(builder, exit); + return osrm.engine.api.fbresult.StepManeuver.endStepManeuver(builder); +} + +/** + * @constructor + */ +osrm.engine.api.fbresult.Lane = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.Lane} + */ +osrm.engine.api.fbresult.Lane.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Lane=} obj + * @returns {osrm.engine.api.fbresult.Lane} + */ +osrm.engine.api.fbresult.Lane.getRootAsLane = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Lane).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Lane=} obj + * @returns {osrm.engine.api.fbresult.Lane} + */ +osrm.engine.api.fbresult.Lane.getSizePrefixedRootAsLane = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Lane).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {number} index + * @returns {osrm.engine.api.fbresult.Turn} + */ +osrm.engine.api.fbresult.Lane.prototype.indications = function(index) { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? /** @type {osrm.engine.api.fbresult.Turn} */ (this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index)) : /** @type {osrm.engine.api.fbresult.Turn} */ (0); +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Lane.prototype.indicationsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Int8Array} + */ +osrm.engine.api.fbresult.Lane.prototype.indicationsArray = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; +}; + +/** + * @returns {boolean} + */ +osrm.engine.api.fbresult.Lane.prototype.valid = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +osrm.engine.api.fbresult.Lane.startLane = function(builder) { + builder.startObject(2); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} indicationsOffset + */ +osrm.engine.api.fbresult.Lane.addIndications = function(builder, indicationsOffset) { + builder.addFieldOffset(0, indicationsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Lane.createIndicationsVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Lane.startIndicationsVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {boolean} valid + */ +osrm.engine.api.fbresult.Lane.addValid = function(builder, valid) { + builder.addFieldInt8(1, +valid, +false); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Lane.endLane = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} indicationsOffset + * @param {boolean} valid + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Lane.createLane = function(builder, indicationsOffset, valid) { + osrm.engine.api.fbresult.Lane.startLane(builder); + osrm.engine.api.fbresult.Lane.addIndications(builder, indicationsOffset); + osrm.engine.api.fbresult.Lane.addValid(builder, valid); + return osrm.engine.api.fbresult.Lane.endLane(builder); +} + +/** + * @constructor + */ +osrm.engine.api.fbresult.Intersection = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.Intersection} + */ +osrm.engine.api.fbresult.Intersection.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Intersection=} obj + * @returns {osrm.engine.api.fbresult.Intersection} + */ +osrm.engine.api.fbresult.Intersection.getRootAsIntersection = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Intersection).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Intersection=} obj + * @returns {osrm.engine.api.fbresult.Intersection} + */ +osrm.engine.api.fbresult.Intersection.getSizePrefixedRootAsIntersection = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Intersection).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {osrm.engine.api.fbresult.Position=} obj + * @returns {osrm.engine.api.fbresult.Position|null} + */ +osrm.engine.api.fbresult.Intersection.prototype.location = function(obj) { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (obj || new osrm.engine.api.fbresult.Position).__init(this.bb_pos + offset, this.bb) : null; +}; + +/** + * @param {number} index + * @returns {number} + */ +osrm.engine.api.fbresult.Intersection.prototype.bearings = function(index) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt16(this.bb.__vector(this.bb_pos + offset) + index * 2) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Intersection.prototype.bearingsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Int16Array} + */ +osrm.engine.api.fbresult.Intersection.prototype.bearingsArray = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? new Int16Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; +}; + +/** + * @param {number} index + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array} + */ +osrm.engine.api.fbresult.Intersection.prototype.classes = function(index, optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Intersection.prototype.classesLength = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {boolean} + */ +osrm.engine.api.fbresult.Intersection.prototype.entry = function(index) { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? !!this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : false; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Intersection.prototype.entryLength = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Int8Array} + */ +osrm.engine.api.fbresult.Intersection.prototype.entryArray = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Intersection.prototype.inBearing = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Intersection.prototype.outBearing = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @param {osrm.engine.api.fbresult.Lane=} obj + * @returns {osrm.engine.api.fbresult.Lane} + */ +osrm.engine.api.fbresult.Intersection.prototype.lanes = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? (obj || new osrm.engine.api.fbresult.Lane).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Intersection.prototype.lanesLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +osrm.engine.api.fbresult.Intersection.startIntersection = function(builder) { + builder.startObject(7); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} locationOffset + */ +osrm.engine.api.fbresult.Intersection.addLocation = function(builder, locationOffset) { + builder.addFieldStruct(0, locationOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} bearingsOffset + */ +osrm.engine.api.fbresult.Intersection.addBearings = function(builder, bearingsOffset) { + builder.addFieldOffset(1, bearingsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Intersection.createBearingsVector = function(builder, data) { + builder.startVector(2, data.length, 2); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt16(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Intersection.startBearingsVector = function(builder, numElems) { + builder.startVector(2, numElems, 2); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} classesOffset + */ +osrm.engine.api.fbresult.Intersection.addClasses = function(builder, classesOffset) { + builder.addFieldOffset(2, classesOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Intersection.createClassesVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Intersection.startClassesVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} entryOffset + */ +osrm.engine.api.fbresult.Intersection.addEntry = function(builder, entryOffset) { + builder.addFieldOffset(3, entryOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Intersection.createEntryVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(+data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Intersection.startEntryVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} inBearing + */ +osrm.engine.api.fbresult.Intersection.addInBearing = function(builder, inBearing) { + builder.addFieldInt32(4, inBearing, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} outBearing + */ +osrm.engine.api.fbresult.Intersection.addOutBearing = function(builder, outBearing) { + builder.addFieldInt32(5, outBearing, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} lanesOffset + */ +osrm.engine.api.fbresult.Intersection.addLanes = function(builder, lanesOffset) { + builder.addFieldOffset(6, lanesOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Intersection.createLanesVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Intersection.startLanesVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Intersection.endIntersection = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} locationOffset + * @param {flatbuffers.Offset} bearingsOffset + * @param {flatbuffers.Offset} classesOffset + * @param {flatbuffers.Offset} entryOffset + * @param {number} inBearing + * @param {number} outBearing + * @param {flatbuffers.Offset} lanesOffset + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Intersection.createIntersection = function(builder, locationOffset, bearingsOffset, classesOffset, entryOffset, inBearing, outBearing, lanesOffset) { + osrm.engine.api.fbresult.Intersection.startIntersection(builder); + osrm.engine.api.fbresult.Intersection.addLocation(builder, locationOffset); + osrm.engine.api.fbresult.Intersection.addBearings(builder, bearingsOffset); + osrm.engine.api.fbresult.Intersection.addClasses(builder, classesOffset); + osrm.engine.api.fbresult.Intersection.addEntry(builder, entryOffset); + osrm.engine.api.fbresult.Intersection.addInBearing(builder, inBearing); + osrm.engine.api.fbresult.Intersection.addOutBearing(builder, outBearing); + osrm.engine.api.fbresult.Intersection.addLanes(builder, lanesOffset); + return osrm.engine.api.fbresult.Intersection.endIntersection(builder); +} + +/** + * @constructor + */ +osrm.engine.api.fbresult.Step = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.Step} + */ +osrm.engine.api.fbresult.Step.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Step=} obj + * @returns {osrm.engine.api.fbresult.Step} + */ +osrm.engine.api.fbresult.Step.getRootAsStep = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Step).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Step=} obj + * @returns {osrm.engine.api.fbresult.Step} + */ +osrm.engine.api.fbresult.Step.getSizePrefixedRootAsStep = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Step).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Step.prototype.distance = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Step.prototype.duration = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Step.prototype.polyline = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {number} index + * @param {osrm.engine.api.fbresult.Position=} obj + * @returns {osrm.engine.api.fbresult.Position} + */ +osrm.engine.api.fbresult.Step.prototype.coordinates = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? (obj || new osrm.engine.api.fbresult.Position).__init(this.bb.__vector(this.bb_pos + offset) + index * 8, this.bb) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Step.prototype.coordinatesLength = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Step.prototype.weight = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Step.prototype.name = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Step.prototype.ref = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Step.prototype.pronunciation = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Step.prototype.destinations = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Step.prototype.exits = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Step.prototype.mode = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {osrm.engine.api.fbresult.StepManeuver=} obj + * @returns {osrm.engine.api.fbresult.StepManeuver|null} + */ +osrm.engine.api.fbresult.Step.prototype.maneuver = function(obj) { + var offset = this.bb.__offset(this.bb_pos, 26); + return offset ? (obj || new osrm.engine.api.fbresult.StepManeuver).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; +}; + +/** + * @param {number} index + * @param {osrm.engine.api.fbresult.Intersection=} obj + * @returns {osrm.engine.api.fbresult.Intersection} + */ +osrm.engine.api.fbresult.Step.prototype.intersections = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 28); + return offset ? (obj || new osrm.engine.api.fbresult.Intersection).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Step.prototype.intersectionsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 28); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Step.prototype.rotaryName = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 30); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Step.prototype.rotaryPronunciation = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 32); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @returns {boolean} + */ +osrm.engine.api.fbresult.Step.prototype.drivingSide = function() { + var offset = this.bb.__offset(this.bb_pos, 34); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +osrm.engine.api.fbresult.Step.startStep = function(builder) { + builder.startObject(16); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} distance + */ +osrm.engine.api.fbresult.Step.addDistance = function(builder, distance) { + builder.addFieldFloat32(0, distance, 0.0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} duration + */ +osrm.engine.api.fbresult.Step.addDuration = function(builder, duration) { + builder.addFieldFloat32(1, duration, 0.0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} polylineOffset + */ +osrm.engine.api.fbresult.Step.addPolyline = function(builder, polylineOffset) { + builder.addFieldOffset(2, polylineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} coordinatesOffset + */ +osrm.engine.api.fbresult.Step.addCoordinates = function(builder, coordinatesOffset) { + builder.addFieldOffset(3, coordinatesOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Step.startCoordinatesVector = function(builder, numElems) { + builder.startVector(8, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} weight + */ +osrm.engine.api.fbresult.Step.addWeight = function(builder, weight) { + builder.addFieldFloat32(4, weight, 0.0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} nameOffset + */ +osrm.engine.api.fbresult.Step.addName = function(builder, nameOffset) { + builder.addFieldOffset(5, nameOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} refOffset + */ +osrm.engine.api.fbresult.Step.addRef = function(builder, refOffset) { + builder.addFieldOffset(6, refOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} pronunciationOffset + */ +osrm.engine.api.fbresult.Step.addPronunciation = function(builder, pronunciationOffset) { + builder.addFieldOffset(7, pronunciationOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} destinationsOffset + */ +osrm.engine.api.fbresult.Step.addDestinations = function(builder, destinationsOffset) { + builder.addFieldOffset(8, destinationsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} exitsOffset + */ +osrm.engine.api.fbresult.Step.addExits = function(builder, exitsOffset) { + builder.addFieldOffset(9, exitsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} modeOffset + */ +osrm.engine.api.fbresult.Step.addMode = function(builder, modeOffset) { + builder.addFieldOffset(10, modeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} maneuverOffset + */ +osrm.engine.api.fbresult.Step.addManeuver = function(builder, maneuverOffset) { + builder.addFieldOffset(11, maneuverOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} intersectionsOffset + */ +osrm.engine.api.fbresult.Step.addIntersections = function(builder, intersectionsOffset) { + builder.addFieldOffset(12, intersectionsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Step.createIntersectionsVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Step.startIntersectionsVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} rotaryNameOffset + */ +osrm.engine.api.fbresult.Step.addRotaryName = function(builder, rotaryNameOffset) { + builder.addFieldOffset(13, rotaryNameOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} rotaryPronunciationOffset + */ +osrm.engine.api.fbresult.Step.addRotaryPronunciation = function(builder, rotaryPronunciationOffset) { + builder.addFieldOffset(14, rotaryPronunciationOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {boolean} drivingSide + */ +osrm.engine.api.fbresult.Step.addDrivingSide = function(builder, drivingSide) { + builder.addFieldInt8(15, +drivingSide, +false); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Step.endStep = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} distance + * @param {number} duration + * @param {flatbuffers.Offset} polylineOffset + * @param {flatbuffers.Offset} coordinatesOffset + * @param {number} weight + * @param {flatbuffers.Offset} nameOffset + * @param {flatbuffers.Offset} refOffset + * @param {flatbuffers.Offset} pronunciationOffset + * @param {flatbuffers.Offset} destinationsOffset + * @param {flatbuffers.Offset} exitsOffset + * @param {flatbuffers.Offset} modeOffset + * @param {flatbuffers.Offset} maneuverOffset + * @param {flatbuffers.Offset} intersectionsOffset + * @param {flatbuffers.Offset} rotaryNameOffset + * @param {flatbuffers.Offset} rotaryPronunciationOffset + * @param {boolean} drivingSide + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Step.createStep = function(builder, distance, duration, polylineOffset, coordinatesOffset, weight, nameOffset, refOffset, pronunciationOffset, destinationsOffset, exitsOffset, modeOffset, maneuverOffset, intersectionsOffset, rotaryNameOffset, rotaryPronunciationOffset, drivingSide) { + osrm.engine.api.fbresult.Step.startStep(builder); + osrm.engine.api.fbresult.Step.addDistance(builder, distance); + osrm.engine.api.fbresult.Step.addDuration(builder, duration); + osrm.engine.api.fbresult.Step.addPolyline(builder, polylineOffset); + osrm.engine.api.fbresult.Step.addCoordinates(builder, coordinatesOffset); + osrm.engine.api.fbresult.Step.addWeight(builder, weight); + osrm.engine.api.fbresult.Step.addName(builder, nameOffset); + osrm.engine.api.fbresult.Step.addRef(builder, refOffset); + osrm.engine.api.fbresult.Step.addPronunciation(builder, pronunciationOffset); + osrm.engine.api.fbresult.Step.addDestinations(builder, destinationsOffset); + osrm.engine.api.fbresult.Step.addExits(builder, exitsOffset); + osrm.engine.api.fbresult.Step.addMode(builder, modeOffset); + osrm.engine.api.fbresult.Step.addManeuver(builder, maneuverOffset); + osrm.engine.api.fbresult.Step.addIntersections(builder, intersectionsOffset); + osrm.engine.api.fbresult.Step.addRotaryName(builder, rotaryNameOffset); + osrm.engine.api.fbresult.Step.addRotaryPronunciation(builder, rotaryPronunciationOffset); + osrm.engine.api.fbresult.Step.addDrivingSide(builder, drivingSide); + return osrm.engine.api.fbresult.Step.endStep(builder); +} + +/** + * @constructor + */ +osrm.engine.api.fbresult.Leg = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.Leg} + */ +osrm.engine.api.fbresult.Leg.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Leg=} obj + * @returns {osrm.engine.api.fbresult.Leg} + */ +osrm.engine.api.fbresult.Leg.getRootAsLeg = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Leg).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Leg=} obj + * @returns {osrm.engine.api.fbresult.Leg} + */ +osrm.engine.api.fbresult.Leg.getSizePrefixedRootAsLeg = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Leg).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Leg.prototype.distance = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Leg.prototype.duration = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Leg.prototype.weight = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Leg.prototype.summary = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {osrm.engine.api.fbresult.Annotation=} obj + * @returns {osrm.engine.api.fbresult.Annotation|null} + */ +osrm.engine.api.fbresult.Leg.prototype.annotations = function(obj) { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? (obj || new osrm.engine.api.fbresult.Annotation).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; +}; + +/** + * @param {number} index + * @param {osrm.engine.api.fbresult.Step=} obj + * @returns {osrm.engine.api.fbresult.Step} + */ +osrm.engine.api.fbresult.Leg.prototype.steps = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? (obj || new osrm.engine.api.fbresult.Step).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Leg.prototype.stepsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +osrm.engine.api.fbresult.Leg.startLeg = function(builder) { + builder.startObject(6); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} distance + */ +osrm.engine.api.fbresult.Leg.addDistance = function(builder, distance) { + builder.addFieldFloat64(0, distance, 0.0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} duration + */ +osrm.engine.api.fbresult.Leg.addDuration = function(builder, duration) { + builder.addFieldFloat64(1, duration, 0.0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} weight + */ +osrm.engine.api.fbresult.Leg.addWeight = function(builder, weight) { + builder.addFieldFloat64(2, weight, 0.0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} summaryOffset + */ +osrm.engine.api.fbresult.Leg.addSummary = function(builder, summaryOffset) { + builder.addFieldOffset(3, summaryOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} annotationsOffset + */ +osrm.engine.api.fbresult.Leg.addAnnotations = function(builder, annotationsOffset) { + builder.addFieldOffset(4, annotationsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} stepsOffset + */ +osrm.engine.api.fbresult.Leg.addSteps = function(builder, stepsOffset) { + builder.addFieldOffset(5, stepsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Leg.createStepsVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Leg.startStepsVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Leg.endLeg = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} distance + * @param {number} duration + * @param {number} weight + * @param {flatbuffers.Offset} summaryOffset + * @param {flatbuffers.Offset} annotationsOffset + * @param {flatbuffers.Offset} stepsOffset + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Leg.createLeg = function(builder, distance, duration, weight, summaryOffset, annotationsOffset, stepsOffset) { + osrm.engine.api.fbresult.Leg.startLeg(builder); + osrm.engine.api.fbresult.Leg.addDistance(builder, distance); + osrm.engine.api.fbresult.Leg.addDuration(builder, duration); + osrm.engine.api.fbresult.Leg.addWeight(builder, weight); + osrm.engine.api.fbresult.Leg.addSummary(builder, summaryOffset); + osrm.engine.api.fbresult.Leg.addAnnotations(builder, annotationsOffset); + osrm.engine.api.fbresult.Leg.addSteps(builder, stepsOffset); + return osrm.engine.api.fbresult.Leg.endLeg(builder); +} + +/** + * @constructor + */ +osrm.engine.api.fbresult.RouteObject = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.RouteObject} + */ +osrm.engine.api.fbresult.RouteObject.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.RouteObject=} obj + * @returns {osrm.engine.api.fbresult.RouteObject} + */ +osrm.engine.api.fbresult.RouteObject.getRootAsRouteObject = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.RouteObject).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.RouteObject=} obj + * @returns {osrm.engine.api.fbresult.RouteObject} + */ +osrm.engine.api.fbresult.RouteObject.getSizePrefixedRootAsRouteObject = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.RouteObject).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.RouteObject.prototype.distance = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.RouteObject.prototype.duration = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.RouteObject.prototype.weight = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.RouteObject.prototype.weightName = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.RouteObject.prototype.confidence = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.RouteObject.prototype.polyline = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {number} index + * @param {osrm.engine.api.fbresult.Position=} obj + * @returns {osrm.engine.api.fbresult.Position} + */ +osrm.engine.api.fbresult.RouteObject.prototype.coordinates = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? (obj || new osrm.engine.api.fbresult.Position).__init(this.bb.__vector(this.bb_pos + offset) + index * 8, this.bb) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.RouteObject.prototype.coordinatesLength = function() { + var offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @param {osrm.engine.api.fbresult.Leg=} obj + * @returns {osrm.engine.api.fbresult.Leg} + */ +osrm.engine.api.fbresult.RouteObject.prototype.legs = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? (obj || new osrm.engine.api.fbresult.Leg).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.RouteObject.prototype.legsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +osrm.engine.api.fbresult.RouteObject.startRouteObject = function(builder) { + builder.startObject(8); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} distance + */ +osrm.engine.api.fbresult.RouteObject.addDistance = function(builder, distance) { + builder.addFieldFloat32(0, distance, 0.0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} duration + */ +osrm.engine.api.fbresult.RouteObject.addDuration = function(builder, duration) { + builder.addFieldFloat32(1, duration, 0.0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} weight + */ +osrm.engine.api.fbresult.RouteObject.addWeight = function(builder, weight) { + builder.addFieldFloat32(2, weight, 0.0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} weightNameOffset + */ +osrm.engine.api.fbresult.RouteObject.addWeightName = function(builder, weightNameOffset) { + builder.addFieldOffset(3, weightNameOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} confidence + */ +osrm.engine.api.fbresult.RouteObject.addConfidence = function(builder, confidence) { + builder.addFieldFloat32(4, confidence, 0.0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} polylineOffset + */ +osrm.engine.api.fbresult.RouteObject.addPolyline = function(builder, polylineOffset) { + builder.addFieldOffset(5, polylineOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} coordinatesOffset + */ +osrm.engine.api.fbresult.RouteObject.addCoordinates = function(builder, coordinatesOffset) { + builder.addFieldOffset(6, coordinatesOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.RouteObject.startCoordinatesVector = function(builder, numElems) { + builder.startVector(8, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} legsOffset + */ +osrm.engine.api.fbresult.RouteObject.addLegs = function(builder, legsOffset) { + builder.addFieldOffset(7, legsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.RouteObject.createLegsVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.RouteObject.startLegsVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.RouteObject.endRouteObject = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} distance + * @param {number} duration + * @param {number} weight + * @param {flatbuffers.Offset} weightNameOffset + * @param {number} confidence + * @param {flatbuffers.Offset} polylineOffset + * @param {flatbuffers.Offset} coordinatesOffset + * @param {flatbuffers.Offset} legsOffset + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.RouteObject.createRouteObject = function(builder, distance, duration, weight, weightNameOffset, confidence, polylineOffset, coordinatesOffset, legsOffset) { + osrm.engine.api.fbresult.RouteObject.startRouteObject(builder); + osrm.engine.api.fbresult.RouteObject.addDistance(builder, distance); + osrm.engine.api.fbresult.RouteObject.addDuration(builder, duration); + osrm.engine.api.fbresult.RouteObject.addWeight(builder, weight); + osrm.engine.api.fbresult.RouteObject.addWeightName(builder, weightNameOffset); + osrm.engine.api.fbresult.RouteObject.addConfidence(builder, confidence); + osrm.engine.api.fbresult.RouteObject.addPolyline(builder, polylineOffset); + osrm.engine.api.fbresult.RouteObject.addCoordinates(builder, coordinatesOffset); + osrm.engine.api.fbresult.RouteObject.addLegs(builder, legsOffset); + return osrm.engine.api.fbresult.RouteObject.endRouteObject(builder); +} + +/** + * @constructor + */ +osrm.engine.api.fbresult.Table = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.Table} + */ +osrm.engine.api.fbresult.Table.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Table=} obj + * @returns {osrm.engine.api.fbresult.Table} + */ +osrm.engine.api.fbresult.Table.getRootAsTable = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Table).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Table=} obj + * @returns {osrm.engine.api.fbresult.Table} + */ +osrm.engine.api.fbresult.Table.getSizePrefixedRootAsTable = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Table).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {number} index + * @returns {number} + */ +osrm.engine.api.fbresult.Table.prototype.durations = function(index) { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readFloat32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Table.prototype.durationsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Float32Array} + */ +osrm.engine.api.fbresult.Table.prototype.durationsArray = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? new Float32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Table.prototype.rows = function() { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Table.prototype.cols = function() { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +osrm.engine.api.fbresult.Table.prototype.distances = function(index) { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readFloat32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Table.prototype.distancesLength = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Float32Array} + */ +osrm.engine.api.fbresult.Table.prototype.distancesArray = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? new Float32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; +}; + +/** + * @param {number} index + * @param {osrm.engine.api.fbresult.Waypoint=} obj + * @returns {osrm.engine.api.fbresult.Waypoint} + */ +osrm.engine.api.fbresult.Table.prototype.destinations = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? (obj || new osrm.engine.api.fbresult.Waypoint).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Table.prototype.destinationsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @returns {number} + */ +osrm.engine.api.fbresult.Table.prototype.fallbackSpeedCells = function(index) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.Table.prototype.fallbackSpeedCellsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @returns {Uint32Array} + */ +osrm.engine.api.fbresult.Table.prototype.fallbackSpeedCellsArray = function() { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? new Uint32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +osrm.engine.api.fbresult.Table.startTable = function(builder) { + builder.startObject(6); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} durationsOffset + */ +osrm.engine.api.fbresult.Table.addDurations = function(builder, durationsOffset) { + builder.addFieldOffset(0, durationsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Table.createDurationsVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addFloat32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Table.startDurationsVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} rows + */ +osrm.engine.api.fbresult.Table.addRows = function(builder, rows) { + builder.addFieldInt16(1, rows, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} cols + */ +osrm.engine.api.fbresult.Table.addCols = function(builder, cols) { + builder.addFieldInt16(2, cols, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} distancesOffset + */ +osrm.engine.api.fbresult.Table.addDistances = function(builder, distancesOffset) { + builder.addFieldOffset(3, distancesOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Table.createDistancesVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addFloat32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Table.startDistancesVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} destinationsOffset + */ +osrm.engine.api.fbresult.Table.addDestinations = function(builder, destinationsOffset) { + builder.addFieldOffset(4, destinationsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Table.createDestinationsVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Table.startDestinationsVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} fallbackSpeedCellsOffset + */ +osrm.engine.api.fbresult.Table.addFallbackSpeedCells = function(builder, fallbackSpeedCellsOffset) { + builder.addFieldOffset(5, fallbackSpeedCellsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Table.createFallbackSpeedCellsVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt32(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.Table.startFallbackSpeedCellsVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Table.endTable = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} durationsOffset + * @param {number} rows + * @param {number} cols + * @param {flatbuffers.Offset} distancesOffset + * @param {flatbuffers.Offset} destinationsOffset + * @param {flatbuffers.Offset} fallbackSpeedCellsOffset + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Table.createTable = function(builder, durationsOffset, rows, cols, distancesOffset, destinationsOffset, fallbackSpeedCellsOffset) { + osrm.engine.api.fbresult.Table.startTable(builder); + osrm.engine.api.fbresult.Table.addDurations(builder, durationsOffset); + osrm.engine.api.fbresult.Table.addRows(builder, rows); + osrm.engine.api.fbresult.Table.addCols(builder, cols); + osrm.engine.api.fbresult.Table.addDistances(builder, distancesOffset); + osrm.engine.api.fbresult.Table.addDestinations(builder, destinationsOffset); + osrm.engine.api.fbresult.Table.addFallbackSpeedCells(builder, fallbackSpeedCellsOffset); + return osrm.engine.api.fbresult.Table.endTable(builder); +} + +/** + * @constructor + */ +osrm.engine.api.fbresult.Error = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.Error} + */ +osrm.engine.api.fbresult.Error.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Error=} obj + * @returns {osrm.engine.api.fbresult.Error} + */ +osrm.engine.api.fbresult.Error.getRootAsError = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Error).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.Error=} obj + * @returns {osrm.engine.api.fbresult.Error} + */ +osrm.engine.api.fbresult.Error.getSizePrefixedRootAsError = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.Error).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Error.prototype.code = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.Error.prototype.message = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +osrm.engine.api.fbresult.Error.startError = function(builder) { + builder.startObject(2); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} codeOffset + */ +osrm.engine.api.fbresult.Error.addCode = function(builder, codeOffset) { + builder.addFieldOffset(0, codeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} messageOffset + */ +osrm.engine.api.fbresult.Error.addMessage = function(builder, messageOffset) { + builder.addFieldOffset(1, messageOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Error.endError = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} codeOffset + * @param {flatbuffers.Offset} messageOffset + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.Error.createError = function(builder, codeOffset, messageOffset) { + osrm.engine.api.fbresult.Error.startError(builder); + osrm.engine.api.fbresult.Error.addCode(builder, codeOffset); + osrm.engine.api.fbresult.Error.addMessage(builder, messageOffset); + return osrm.engine.api.fbresult.Error.endError(builder); +} + +/** + * @constructor + */ +osrm.engine.api.fbresult.FBResult = function() { + /** + * @type {flatbuffers.ByteBuffer} + */ + this.bb = null; + + /** + * @type {number} + */ + this.bb_pos = 0; +}; + +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {osrm.engine.api.fbresult.FBResult} + */ +osrm.engine.api.fbresult.FBResult.prototype.__init = function(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.FBResult=} obj + * @returns {osrm.engine.api.fbresult.FBResult} + */ +osrm.engine.api.fbresult.FBResult.getRootAsFBResult = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.FBResult).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {osrm.engine.api.fbresult.FBResult=} obj + * @returns {osrm.engine.api.fbresult.FBResult} + */ +osrm.engine.api.fbresult.FBResult.getSizePrefixedRootAsFBResult = function(bb, obj) { + return (obj || new osrm.engine.api.fbresult.FBResult).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {boolean} + */ +osrm.engine.api.fbresult.FBResult.prototype.error = function() { + var offset = this.bb.__offset(this.bb_pos, 4); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; +}; + +/** + * @param {osrm.engine.api.fbresult.Error=} obj + * @returns {osrm.engine.api.fbresult.Error|null} + */ +osrm.engine.api.fbresult.FBResult.prototype.code = function(obj) { + var offset = this.bb.__offset(this.bb_pos, 6); + return offset ? (obj || new osrm.engine.api.fbresult.Error).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +osrm.engine.api.fbresult.FBResult.prototype.dataVersion = function(optionalEncoding) { + var offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {number} index + * @param {osrm.engine.api.fbresult.Waypoint=} obj + * @returns {osrm.engine.api.fbresult.Waypoint} + */ +osrm.engine.api.fbresult.FBResult.prototype.waypoints = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? (obj || new osrm.engine.api.fbresult.Waypoint).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.FBResult.prototype.waypointsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {number} index + * @param {osrm.engine.api.fbresult.RouteObject=} obj + * @returns {osrm.engine.api.fbresult.RouteObject} + */ +osrm.engine.api.fbresult.FBResult.prototype.routes = function(index, obj) { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? (obj || new osrm.engine.api.fbresult.RouteObject).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; +}; + +/** + * @returns {number} + */ +osrm.engine.api.fbresult.FBResult.prototype.routesLength = function() { + var offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {osrm.engine.api.fbresult.Table=} obj + * @returns {osrm.engine.api.fbresult.Table|null} + */ +osrm.engine.api.fbresult.FBResult.prototype.table = function(obj) { + var offset = this.bb.__offset(this.bb_pos, 14); + return offset ? (obj || new osrm.engine.api.fbresult.Table).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +osrm.engine.api.fbresult.FBResult.startFBResult = function(builder) { + builder.startObject(6); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {boolean} error + */ +osrm.engine.api.fbresult.FBResult.addError = function(builder, error) { + builder.addFieldInt8(0, +error, +false); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} codeOffset + */ +osrm.engine.api.fbresult.FBResult.addCode = function(builder, codeOffset) { + builder.addFieldOffset(1, codeOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} dataVersionOffset + */ +osrm.engine.api.fbresult.FBResult.addDataVersion = function(builder, dataVersionOffset) { + builder.addFieldOffset(2, dataVersionOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} waypointsOffset + */ +osrm.engine.api.fbresult.FBResult.addWaypoints = function(builder, waypointsOffset) { + builder.addFieldOffset(3, waypointsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.FBResult.createWaypointsVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.FBResult.startWaypointsVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} routesOffset + */ +osrm.engine.api.fbresult.FBResult.addRoutes = function(builder, routesOffset) { + builder.addFieldOffset(4, routesOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.FBResult.createRoutesVector = function(builder, data) { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +osrm.engine.api.fbresult.FBResult.startRoutesVector = function(builder, numElems) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} tableOffset + */ +osrm.engine.api.fbresult.FBResult.addTable = function(builder, tableOffset) { + builder.addFieldOffset(5, tableOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.FBResult.endFBResult = function(builder) { + var offset = builder.endObject(); + return offset; +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +osrm.engine.api.fbresult.FBResult.finishFBResultBuffer = function(builder, offset) { + builder.finish(offset); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} offset + */ +osrm.engine.api.fbresult.FBResult.finishSizePrefixedFBResultBuffer = function(builder, offset) { + builder.finish(offset, undefined, true); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {boolean} error + * @param {flatbuffers.Offset} codeOffset + * @param {flatbuffers.Offset} dataVersionOffset + * @param {flatbuffers.Offset} waypointsOffset + * @param {flatbuffers.Offset} routesOffset + * @param {flatbuffers.Offset} tableOffset + * @returns {flatbuffers.Offset} + */ +osrm.engine.api.fbresult.FBResult.createFBResult = function(builder, error, codeOffset, dataVersionOffset, waypointsOffset, routesOffset, tableOffset) { + osrm.engine.api.fbresult.FBResult.startFBResult(builder); + osrm.engine.api.fbresult.FBResult.addError(builder, error); + osrm.engine.api.fbresult.FBResult.addCode(builder, codeOffset); + osrm.engine.api.fbresult.FBResult.addDataVersion(builder, dataVersionOffset); + osrm.engine.api.fbresult.FBResult.addWaypoints(builder, waypointsOffset); + osrm.engine.api.fbresult.FBResult.addRoutes(builder, routesOffset); + osrm.engine.api.fbresult.FBResult.addTable(builder, tableOffset); + return osrm.engine.api.fbresult.FBResult.endFBResult(builder); +} + +// Exports for Node.js and RequireJS +this.osrm = osrm; diff --git a/features/support/flatbuffers.js b/features/support/flatbuffers.js new file mode 100644 index 000000000..461cd7af8 --- /dev/null +++ b/features/support/flatbuffers.js @@ -0,0 +1,1259 @@ +/// @file +/// @addtogroup flatbuffers_javascript_api +/// @{ +/// @cond FLATBUFFERS_INTERNAL + +/** + * @fileoverview + * + * Need to suppress 'global this' error so the Node.js export line doesn't cause + * closure compile to error out. + * @suppress {globalThis} + */ + +/** + * @const + * @namespace + */ +var flatbuffers = {}; + +/** + * @typedef {number} + */ +flatbuffers.Offset; + +/** + * @typedef {{ + * bb: flatbuffers.ByteBuffer, + * bb_pos: number + * }} + */ +flatbuffers.Table; + +/** + * @type {number} + * @const + */ +flatbuffers.SIZEOF_SHORT = 2; + +/** + * @type {number} + * @const + */ +flatbuffers.SIZEOF_INT = 4; + +/** + * @type {number} + * @const + */ +flatbuffers.FILE_IDENTIFIER_LENGTH = 4; + +/** + * @type {number} + * @const + */ +flatbuffers.SIZE_PREFIX_LENGTH = 4; + +/** + * @enum {number} + */ +flatbuffers.Encoding = { + UTF8_BYTES: 1, + UTF16_STRING: 2 +}; + +/** + * @type {Int32Array} + * @const + */ +flatbuffers.int32 = new Int32Array(2); + +/** + * @type {Float32Array} + * @const + */ +flatbuffers.float32 = new Float32Array(flatbuffers.int32.buffer); + +/** + * @type {Float64Array} + * @const + */ +flatbuffers.float64 = new Float64Array(flatbuffers.int32.buffer); + +/** + * @type {boolean} + * @const + */ +flatbuffers.isLittleEndian = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1; + +//////////////////////////////////////////////////////////////////////////////// + +/** + * @constructor + * @param {number} low + * @param {number} high + */ +flatbuffers.Long = function(low, high) { + /** + * @type {number} + * @const + */ + this.low = low | 0; + + /** + * @type {number} + * @const + */ + this.high = high | 0; +}; + +/** + * @param {number} low + * @param {number} high + * @returns {flatbuffers.Long} + */ +flatbuffers.Long.create = function(low, high) { + // Special-case zero to avoid GC overhead for default values + return low == 0 && high == 0 ? flatbuffers.Long.ZERO : new flatbuffers.Long(low, high); +}; + +/** + * @returns {number} + */ +flatbuffers.Long.prototype.toFloat64 = function() { + return (this.low >>> 0) + this.high * 0x100000000; +}; + +/** + * @param {flatbuffers.Long} other + * @returns {boolean} + */ +flatbuffers.Long.prototype.equals = function(other) { + return this.low == other.low && this.high == other.high; +}; + +/** + * @type {flatbuffers.Long} + * @const + */ +flatbuffers.Long.ZERO = new flatbuffers.Long(0, 0); + +/// @endcond +//////////////////////////////////////////////////////////////////////////////// +/** + * Create a FlatBufferBuilder. + * + * @constructor + * @param {number=} opt_initial_size + */ +flatbuffers.Builder = function(opt_initial_size) { + if (!opt_initial_size) { + var initial_size = 1024; + } else { + var initial_size = opt_initial_size; + } + + /** + * @type {flatbuffers.ByteBuffer} + * @private + */ + this.bb = flatbuffers.ByteBuffer.allocate(initial_size); + + /** + * Remaining space in the ByteBuffer. + * + * @type {number} + * @private + */ + this.space = initial_size; + + /** + * Minimum alignment encountered so far. + * + * @type {number} + * @private + */ + this.minalign = 1; + + /** + * The vtable for the current table. + * + * @type {Array.} + * @private + */ + this.vtable = null; + + /** + * The amount of fields we're actually using. + * + * @type {number} + * @private + */ + this.vtable_in_use = 0; + + /** + * Whether we are currently serializing a table. + * + * @type {boolean} + * @private + */ + this.isNested = false; + + /** + * Starting offset of the current struct/table. + * + * @type {number} + * @private + */ + this.object_start = 0; + + /** + * List of offsets of all vtables. + * + * @type {Array.} + * @private + */ + this.vtables = []; + + /** + * For the current vector being built. + * + * @type {number} + * @private + */ + this.vector_num_elems = 0; + + /** + * False omits default values from the serialized data + * + * @type {boolean} + * @private + */ + this.force_defaults = false; +}; + +flatbuffers.Builder.prototype.clear = function() { + this.bb.clear(); + this.space = this.bb.capacity(); + this.minalign = 1; + this.vtable = null; + this.vtable_in_use = 0; + this.isNested = false; + this.object_start = 0; + this.vtables = []; + this.vector_num_elems = 0; + this.force_defaults = false; +}; + +/** + * In order to save space, fields that are set to their default value + * don't get serialized into the buffer. Forcing defaults provides a + * way to manually disable this optimization. + * + * @param {boolean} forceDefaults true always serializes default values + */ +flatbuffers.Builder.prototype.forceDefaults = function(forceDefaults) { + this.force_defaults = forceDefaults; +}; + +/** + * Get the ByteBuffer representing the FlatBuffer. Only call this after you've + * called finish(). The actual data starts at the ByteBuffer's current position, + * not necessarily at 0. + * + * @returns {flatbuffers.ByteBuffer} + */ +flatbuffers.Builder.prototype.dataBuffer = function() { + return this.bb; +}; + +/** + * Get the bytes representing the FlatBuffer. Only call this after you've + * called finish(). + * + * @returns {Uint8Array} + */ +flatbuffers.Builder.prototype.asUint8Array = function() { + return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset()); +}; + +/// @cond FLATBUFFERS_INTERNAL +/** + * Prepare to write an element of `size` after `additional_bytes` have been + * written, e.g. if you write a string, you need to align such the int length + * field is aligned to 4 bytes, and the string data follows it directly. If all + * you need to do is alignment, `additional_bytes` will be 0. + * + * @param {number} size This is the of the new element to write + * @param {number} additional_bytes The padding size + */ +flatbuffers.Builder.prototype.prep = function(size, additional_bytes) { + // Track the biggest thing we've ever aligned to. + if (size > this.minalign) { + this.minalign = size; + } + + // Find the amount of alignment needed such that `size` is properly + // aligned after `additional_bytes` + var align_size = ((~(this.bb.capacity() - this.space + additional_bytes)) + 1) & (size - 1); + + // Reallocate the buffer if needed. + while (this.space < align_size + size + additional_bytes) { + var old_buf_size = this.bb.capacity(); + this.bb = flatbuffers.Builder.growByteBuffer(this.bb); + this.space += this.bb.capacity() - old_buf_size; + } + + this.pad(align_size); +}; + +/** + * @param {number} byte_size + */ +flatbuffers.Builder.prototype.pad = function(byte_size) { + for (var i = 0; i < byte_size; i++) { + this.bb.writeInt8(--this.space, 0); + } +}; + +/** + * @param {number} value + */ +flatbuffers.Builder.prototype.writeInt8 = function(value) { + this.bb.writeInt8(this.space -= 1, value); +}; + +/** + * @param {number} value + */ +flatbuffers.Builder.prototype.writeInt16 = function(value) { + this.bb.writeInt16(this.space -= 2, value); +}; + +/** + * @param {number} value + */ +flatbuffers.Builder.prototype.writeInt32 = function(value) { + this.bb.writeInt32(this.space -= 4, value); +}; + +/** + * @param {flatbuffers.Long} value + */ +flatbuffers.Builder.prototype.writeInt64 = function(value) { + this.bb.writeInt64(this.space -= 8, value); +}; + +/** + * @param {number} value + */ +flatbuffers.Builder.prototype.writeFloat32 = function(value) { + this.bb.writeFloat32(this.space -= 4, value); +}; + +/** + * @param {number} value + */ +flatbuffers.Builder.prototype.writeFloat64 = function(value) { + this.bb.writeFloat64(this.space -= 8, value); +}; +/// @endcond + +/** + * Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary). + * @param {number} value The `int8` to add the the buffer. + */ +flatbuffers.Builder.prototype.addInt8 = function(value) { + this.prep(1, 0); + this.writeInt8(value); +}; + +/** + * Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary). + * @param {number} value The `int16` to add the the buffer. + */ +flatbuffers.Builder.prototype.addInt16 = function(value) { + this.prep(2, 0); + this.writeInt16(value); +}; + +/** + * Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary). + * @param {number} value The `int32` to add the the buffer. + */ +flatbuffers.Builder.prototype.addInt32 = function(value) { + this.prep(4, 0); + this.writeInt32(value); +}; + +/** + * Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary). + * @param {flatbuffers.Long} value The `int64` to add the the buffer. + */ +flatbuffers.Builder.prototype.addInt64 = function(value) { + this.prep(8, 0); + this.writeInt64(value); +}; + +/** + * Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary). + * @param {number} value The `float32` to add the the buffer. + */ +flatbuffers.Builder.prototype.addFloat32 = function(value) { + this.prep(4, 0); + this.writeFloat32(value); +}; + +/** + * Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary). + * @param {number} value The `float64` to add the the buffer. + */ +flatbuffers.Builder.prototype.addFloat64 = function(value) { + this.prep(8, 0); + this.writeFloat64(value); +}; + +/// @cond FLATBUFFERS_INTERNAL +/** + * @param {number} voffset + * @param {number} value + * @param {number} defaultValue + */ +flatbuffers.Builder.prototype.addFieldInt8 = function(voffset, value, defaultValue) { + if (this.force_defaults || value != defaultValue) { + this.addInt8(value); + this.slot(voffset); + } +}; + +/** + * @param {number} voffset + * @param {number} value + * @param {number} defaultValue + */ +flatbuffers.Builder.prototype.addFieldInt16 = function(voffset, value, defaultValue) { + if (this.force_defaults || value != defaultValue) { + this.addInt16(value); + this.slot(voffset); + } +}; + +/** + * @param {number} voffset + * @param {number} value + * @param {number} defaultValue + */ +flatbuffers.Builder.prototype.addFieldInt32 = function(voffset, value, defaultValue) { + if (this.force_defaults || value != defaultValue) { + this.addInt32(value); + this.slot(voffset); + } +}; + +/** + * @param {number} voffset + * @param {flatbuffers.Long} value + * @param {flatbuffers.Long} defaultValue + */ +flatbuffers.Builder.prototype.addFieldInt64 = function(voffset, value, defaultValue) { + if (this.force_defaults || !value.equals(defaultValue)) { + this.addInt64(value); + this.slot(voffset); + } +}; + +/** + * @param {number} voffset + * @param {number} value + * @param {number} defaultValue + */ +flatbuffers.Builder.prototype.addFieldFloat32 = function(voffset, value, defaultValue) { + if (this.force_defaults || value != defaultValue) { + this.addFloat32(value); + this.slot(voffset); + } +}; + +/** + * @param {number} voffset + * @param {number} value + * @param {number} defaultValue + */ +flatbuffers.Builder.prototype.addFieldFloat64 = function(voffset, value, defaultValue) { + if (this.force_defaults || value != defaultValue) { + this.addFloat64(value); + this.slot(voffset); + } +}; + +/** + * @param {number} voffset + * @param {flatbuffers.Offset} value + * @param {flatbuffers.Offset} defaultValue + */ +flatbuffers.Builder.prototype.addFieldOffset = function(voffset, value, defaultValue) { + if (this.force_defaults || value != defaultValue) { + this.addOffset(value); + this.slot(voffset); + } +}; + +/** + * Structs are stored inline, so nothing additional is being added. `d` is always 0. + * + * @param {number} voffset + * @param {flatbuffers.Offset} value + * @param {flatbuffers.Offset} defaultValue + */ +flatbuffers.Builder.prototype.addFieldStruct = function(voffset, value, defaultValue) { + if (value != defaultValue) { + this.nested(value); + this.slot(voffset); + } +}; + +/** + * Structures are always stored inline, they need to be created right + * where they're used. You'll get this assertion failure if you + * created it elsewhere. + * + * @param {flatbuffers.Offset} obj The offset of the created object + */ +flatbuffers.Builder.prototype.nested = function(obj) { + if (obj != this.offset()) { + throw new Error('FlatBuffers: struct must be serialized inline.'); + } +}; + +/** + * Should not be creating any other object, string or vector + * while an object is being constructed + */ +flatbuffers.Builder.prototype.notNested = function() { + if (this.isNested) { + throw new Error('FlatBuffers: object serialization must not be nested.'); + } +}; + +/** + * Set the current vtable at `voffset` to the current location in the buffer. + * + * @param {number} voffset + */ +flatbuffers.Builder.prototype.slot = function(voffset) { + this.vtable[voffset] = this.offset(); +}; + +/** + * @returns {flatbuffers.Offset} Offset relative to the end of the buffer. + */ +flatbuffers.Builder.prototype.offset = function() { + return this.bb.capacity() - this.space; +}; + +/** + * Doubles the size of the backing ByteBuffer and copies the old data towards + * the end of the new buffer (since we build the buffer backwards). + * + * @param {flatbuffers.ByteBuffer} bb The current buffer with the existing data + * @returns {flatbuffers.ByteBuffer} A new byte buffer with the old data copied + * to it. The data is located at the end of the buffer. + * + * uint8Array.set() formally takes {Array|ArrayBufferView}, so to pass + * it a uint8Array we need to suppress the type check: + * @suppress {checkTypes} + */ +flatbuffers.Builder.growByteBuffer = function(bb) { + var old_buf_size = bb.capacity(); + + // Ensure we don't grow beyond what fits in an int. + if (old_buf_size & 0xC0000000) { + throw new Error('FlatBuffers: cannot grow buffer beyond 2 gigabytes.'); + } + + var new_buf_size = old_buf_size << 1; + var nbb = flatbuffers.ByteBuffer.allocate(new_buf_size); + nbb.setPosition(new_buf_size - old_buf_size); + nbb.bytes().set(bb.bytes(), new_buf_size - old_buf_size); + return nbb; +}; +/// @endcond + +/** + * Adds on offset, relative to where it will be written. + * + * @param {flatbuffers.Offset} offset The offset to add. + */ +flatbuffers.Builder.prototype.addOffset = function(offset) { + this.prep(flatbuffers.SIZEOF_INT, 0); // Ensure alignment is already done. + this.writeInt32(this.offset() - offset + flatbuffers.SIZEOF_INT); +}; + +/// @cond FLATBUFFERS_INTERNAL +/** + * Start encoding a new object in the buffer. Users will not usually need to + * call this directly. The FlatBuffers compiler will generate helper methods + * that call this method internally. + * + * @param {number} numfields + */ +flatbuffers.Builder.prototype.startObject = function(numfields) { + this.notNested(); + if (this.vtable == null) { + this.vtable = []; + } + this.vtable_in_use = numfields; + for (var i = 0; i < numfields; i++) { + this.vtable[i] = 0; // This will push additional elements as needed + } + this.isNested = true; + this.object_start = this.offset(); +}; + +/** + * Finish off writing the object that is under construction. + * + * @returns {flatbuffers.Offset} The offset to the object inside `dataBuffer` + */ +flatbuffers.Builder.prototype.endObject = function() { + if (this.vtable == null || !this.isNested) { + throw new Error('FlatBuffers: endObject called without startObject'); + } + + this.addInt32(0); + var vtableloc = this.offset(); + + // Trim trailing zeroes. + var i = this.vtable_in_use - 1; + for (; i >= 0 && this.vtable[i] == 0; i--) {} + var trimmed_size = i + 1; + + // Write out the current vtable. + for (; i >= 0; i--) { + // Offset relative to the start of the table. + this.addInt16(this.vtable[i] != 0 ? vtableloc - this.vtable[i] : 0); + } + + var standard_fields = 2; // The fields below: + this.addInt16(vtableloc - this.object_start); + var len = (trimmed_size + standard_fields) * flatbuffers.SIZEOF_SHORT; + this.addInt16(len); + + // Search for an existing vtable that matches the current one. + var existing_vtable = 0; + var vt1 = this.space; +outer_loop: + for (i = 0; i < this.vtables.length; i++) { + var vt2 = this.bb.capacity() - this.vtables[i]; + if (len == this.bb.readInt16(vt2)) { + for (var j = flatbuffers.SIZEOF_SHORT; j < len; j += flatbuffers.SIZEOF_SHORT) { + if (this.bb.readInt16(vt1 + j) != this.bb.readInt16(vt2 + j)) { + continue outer_loop; + } + } + existing_vtable = this.vtables[i]; + break; + } + } + + if (existing_vtable) { + // Found a match: + // Remove the current vtable. + this.space = this.bb.capacity() - vtableloc; + + // Point table to existing vtable. + this.bb.writeInt32(this.space, existing_vtable - vtableloc); + } else { + // No match: + // Add the location of the current vtable to the list of vtables. + this.vtables.push(this.offset()); + + // Point table to current vtable. + this.bb.writeInt32(this.bb.capacity() - vtableloc, this.offset() - vtableloc); + } + + this.isNested = false; + return vtableloc; +}; +/// @endcond + +/** + * Finalize a buffer, poiting to the given `root_table`. + * + * @param {flatbuffers.Offset} root_table + * @param {string=} opt_file_identifier + * @param {boolean=} opt_size_prefix + */ +flatbuffers.Builder.prototype.finish = function(root_table, opt_file_identifier, opt_size_prefix) { + var size_prefix = opt_size_prefix ? flatbuffers.SIZE_PREFIX_LENGTH : 0; + if (opt_file_identifier) { + var file_identifier = opt_file_identifier; + this.prep(this.minalign, flatbuffers.SIZEOF_INT + + flatbuffers.FILE_IDENTIFIER_LENGTH + size_prefix); + if (file_identifier.length != flatbuffers.FILE_IDENTIFIER_LENGTH) { + throw new Error('FlatBuffers: file identifier must be length ' + + flatbuffers.FILE_IDENTIFIER_LENGTH); + } + for (var i = flatbuffers.FILE_IDENTIFIER_LENGTH - 1; i >= 0; i--) { + this.writeInt8(file_identifier.charCodeAt(i)); + } + } + this.prep(this.minalign, flatbuffers.SIZEOF_INT + size_prefix); + this.addOffset(root_table); + if (size_prefix) { + this.addInt32(this.bb.capacity() - this.space); + } + this.bb.setPosition(this.space); +}; + +/** + * Finalize a size prefixed buffer, pointing to the given `root_table`. + * + * @param {flatbuffers.Offset} root_table + * @param {string=} opt_file_identifier + */ +flatbuffers.Builder.prototype.finishSizePrefixed = function (root_table, opt_file_identifier) { + this.finish(root_table, opt_file_identifier, true); +}; + +/// @cond FLATBUFFERS_INTERNAL +/** + * This checks a required field has been set in a given table that has + * just been constructed. + * + * @param {flatbuffers.Offset} table + * @param {number} field + */ +flatbuffers.Builder.prototype.requiredField = function(table, field) { + var table_start = this.bb.capacity() - table; + var vtable_start = table_start - this.bb.readInt32(table_start); + var ok = this.bb.readInt16(vtable_start + field) != 0; + + // If this fails, the caller will show what field needs to be set. + if (!ok) { + throw new Error('FlatBuffers: field ' + field + ' must be set'); + } +}; + +/** + * Start a new array/vector of objects. Users usually will not call + * this directly. The FlatBuffers compiler will create a start/end + * method for vector types in generated code. + * + * @param {number} elem_size The size of each element in the array + * @param {number} num_elems The number of elements in the array + * @param {number} alignment The alignment of the array + */ +flatbuffers.Builder.prototype.startVector = function(elem_size, num_elems, alignment) { + this.notNested(); + this.vector_num_elems = num_elems; + this.prep(flatbuffers.SIZEOF_INT, elem_size * num_elems); + this.prep(alignment, elem_size * num_elems); // Just in case alignment > int. +}; + +/** + * Finish off the creation of an array and all its elements. The array must be + * created with `startVector`. + * + * @returns {flatbuffers.Offset} The offset at which the newly created array + * starts. + */ +flatbuffers.Builder.prototype.endVector = function() { + this.writeInt32(this.vector_num_elems); + return this.offset(); +}; +/// @endcond + +/** + * Encode the string `s` in the buffer using UTF-8. If a Uint8Array is passed + * instead of a string, it is assumed to contain valid UTF-8 encoded data. + * + * @param {string|Uint8Array} s The string to encode + * @return {flatbuffers.Offset} The offset in the buffer where the encoded string starts + */ +flatbuffers.Builder.prototype.createString = function(s) { + if (s instanceof Uint8Array) { + var utf8 = s; + } else { + var utf8 = []; + var i = 0; + + while (i < s.length) { + var codePoint; + + // Decode UTF-16 + var a = s.charCodeAt(i++); + if (a < 0xD800 || a >= 0xDC00) { + codePoint = a; + } else { + var b = s.charCodeAt(i++); + codePoint = (a << 10) + b + (0x10000 - (0xD800 << 10) - 0xDC00); + } + + // Encode UTF-8 + if (codePoint < 0x80) { + utf8.push(codePoint); + } else { + if (codePoint < 0x800) { + utf8.push(((codePoint >> 6) & 0x1F) | 0xC0); + } else { + if (codePoint < 0x10000) { + utf8.push(((codePoint >> 12) & 0x0F) | 0xE0); + } else { + utf8.push( + ((codePoint >> 18) & 0x07) | 0xF0, + ((codePoint >> 12) & 0x3F) | 0x80); + } + utf8.push(((codePoint >> 6) & 0x3F) | 0x80); + } + utf8.push((codePoint & 0x3F) | 0x80); + } + } + } + + this.addInt8(0); + this.startVector(1, utf8.length, 1); + this.bb.setPosition(this.space -= utf8.length); + for (var i = 0, offset = this.space, bytes = this.bb.bytes(); i < utf8.length; i++) { + bytes[offset++] = utf8[i]; + } + return this.endVector(); +}; + +/** + * A helper function to avoid generated code depending on this file directly. + * + * @param {number} low + * @param {number} high + * @returns {flatbuffers.Long} + */ +flatbuffers.Builder.prototype.createLong = function(low, high) { + return flatbuffers.Long.create(low, high); +}; +//////////////////////////////////////////////////////////////////////////////// +/// @cond FLATBUFFERS_INTERNAL +/** + * Create a new ByteBuffer with a given array of bytes (`Uint8Array`). + * + * @constructor + * @param {Uint8Array} bytes + */ +flatbuffers.ByteBuffer = function(bytes) { + /** + * @type {Uint8Array} + * @private + */ + this.bytes_ = bytes; + + /** + * @type {number} + * @private + */ + this.position_ = 0; +}; + +/** + * Create and allocate a new ByteBuffer with a given size. + * + * @param {number} byte_size + * @returns {flatbuffers.ByteBuffer} + */ +flatbuffers.ByteBuffer.allocate = function(byte_size) { + return new flatbuffers.ByteBuffer(new Uint8Array(byte_size)); +}; + +flatbuffers.ByteBuffer.prototype.clear = function() { + this.position_ = 0; +}; + +/** + * Get the underlying `Uint8Array`. + * + * @returns {Uint8Array} + */ +flatbuffers.ByteBuffer.prototype.bytes = function() { + return this.bytes_; +}; + +/** + * Get the buffer's position. + * + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.position = function() { + return this.position_; +}; + +/** + * Set the buffer's position. + * + * @param {number} position + */ +flatbuffers.ByteBuffer.prototype.setPosition = function(position) { + this.position_ = position; +}; + +/** + * Get the buffer's capacity. + * + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.capacity = function() { + return this.bytes_.length; +}; + +/** + * @param {number} offset + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.readInt8 = function(offset) { + return this.readUint8(offset) << 24 >> 24; +}; + +/** + * @param {number} offset + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.readUint8 = function(offset) { + return this.bytes_[offset]; +}; + +/** + * @param {number} offset + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.readInt16 = function(offset) { + return this.readUint16(offset) << 16 >> 16; +}; + +/** + * @param {number} offset + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.readUint16 = function(offset) { + return this.bytes_[offset] | this.bytes_[offset + 1] << 8; +}; + +/** + * @param {number} offset + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.readInt32 = function(offset) { + return this.bytes_[offset] | this.bytes_[offset + 1] << 8 | this.bytes_[offset + 2] << 16 | this.bytes_[offset + 3] << 24; +}; + +/** + * @param {number} offset + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.readUint32 = function(offset) { + return this.readInt32(offset) >>> 0; +}; + +/** + * @param {number} offset + * @returns {flatbuffers.Long} + */ +flatbuffers.ByteBuffer.prototype.readInt64 = function(offset) { + return new flatbuffers.Long(this.readInt32(offset), this.readInt32(offset + 4)); +}; + +/** + * @param {number} offset + * @returns {flatbuffers.Long} + */ +flatbuffers.ByteBuffer.prototype.readUint64 = function(offset) { + return new flatbuffers.Long(this.readUint32(offset), this.readUint32(offset + 4)); +}; + +/** + * @param {number} offset + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.readFloat32 = function(offset) { + flatbuffers.int32[0] = this.readInt32(offset); + return flatbuffers.float32[0]; +}; + +/** + * @param {number} offset + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.readFloat64 = function(offset) { + flatbuffers.int32[flatbuffers.isLittleEndian ? 0 : 1] = this.readInt32(offset); + flatbuffers.int32[flatbuffers.isLittleEndian ? 1 : 0] = this.readInt32(offset + 4); + return flatbuffers.float64[0]; +}; + +/** + * @param {number} offset + * @param {number|boolean} value + */ +flatbuffers.ByteBuffer.prototype.writeInt8 = function(offset, value) { + this.bytes_[offset] = /** @type {number} */(value); +}; + +/** + * @param {number} offset + * @param {number} value + */ +flatbuffers.ByteBuffer.prototype.writeUint8 = function(offset, value) { + this.bytes_[offset] = value; +}; + +/** + * @param {number} offset + * @param {number} value + */ +flatbuffers.ByteBuffer.prototype.writeInt16 = function(offset, value) { + this.bytes_[offset] = value; + this.bytes_[offset + 1] = value >> 8; +}; + +/** + * @param {number} offset + * @param {number} value + */ +flatbuffers.ByteBuffer.prototype.writeUint16 = function(offset, value) { + this.bytes_[offset] = value; + this.bytes_[offset + 1] = value >> 8; +}; + +/** + * @param {number} offset + * @param {number} value + */ +flatbuffers.ByteBuffer.prototype.writeInt32 = function(offset, value) { + this.bytes_[offset] = value; + this.bytes_[offset + 1] = value >> 8; + this.bytes_[offset + 2] = value >> 16; + this.bytes_[offset + 3] = value >> 24; +}; + +/** + * @param {number} offset + * @param {number} value + */ +flatbuffers.ByteBuffer.prototype.writeUint32 = function(offset, value) { + this.bytes_[offset] = value; + this.bytes_[offset + 1] = value >> 8; + this.bytes_[offset + 2] = value >> 16; + this.bytes_[offset + 3] = value >> 24; +}; + +/** + * @param {number} offset + * @param {flatbuffers.Long} value + */ +flatbuffers.ByteBuffer.prototype.writeInt64 = function(offset, value) { + this.writeInt32(offset, value.low); + this.writeInt32(offset + 4, value.high); +}; + +/** + * @param {number} offset + * @param {flatbuffers.Long} value + */ +flatbuffers.ByteBuffer.prototype.writeUint64 = function(offset, value) { + this.writeUint32(offset, value.low); + this.writeUint32(offset + 4, value.high); +}; + +/** + * @param {number} offset + * @param {number} value + */ +flatbuffers.ByteBuffer.prototype.writeFloat32 = function(offset, value) { + flatbuffers.float32[0] = value; + this.writeInt32(offset, flatbuffers.int32[0]); +}; + +/** + * @param {number} offset + * @param {number} value + */ +flatbuffers.ByteBuffer.prototype.writeFloat64 = function(offset, value) { + flatbuffers.float64[0] = value; + this.writeInt32(offset, flatbuffers.int32[flatbuffers.isLittleEndian ? 0 : 1]); + this.writeInt32(offset + 4, flatbuffers.int32[flatbuffers.isLittleEndian ? 1 : 0]); +}; + +/** + * Return the file identifier. Behavior is undefined for FlatBuffers whose + * schema does not include a file_identifier (likely points at padding or the + * start of a the root vtable). + * @returns {string} + */ +flatbuffers.ByteBuffer.prototype.getBufferIdentifier = function() { + if (this.bytes_.length < this.position_ + flatbuffers.SIZEOF_INT + + flatbuffers.FILE_IDENTIFIER_LENGTH) { + throw new Error( + 'FlatBuffers: ByteBuffer is too short to contain an identifier.'); + } + var result = ""; + for (var i = 0; i < flatbuffers.FILE_IDENTIFIER_LENGTH; i++) { + result += String.fromCharCode( + this.readInt8(this.position_ + flatbuffers.SIZEOF_INT + i)); + } + return result; +}; + +/** + * Look up a field in the vtable, return an offset into the object, or 0 if the + * field is not present. + * + * @param {number} bb_pos + * @param {number} vtable_offset + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.__offset = function(bb_pos, vtable_offset) { + var vtable = bb_pos - this.readInt32(bb_pos); + return vtable_offset < this.readInt16(vtable) ? this.readInt16(vtable + vtable_offset) : 0; +}; + +/** + * Initialize any Table-derived type to point to the union at the given offset. + * + * @param {flatbuffers.Table} t + * @param {number} offset + * @returns {flatbuffers.Table} + */ +flatbuffers.ByteBuffer.prototype.__union = function(t, offset) { + t.bb_pos = offset + this.readInt32(offset); + t.bb = this; + return t; +}; + +/** + * Create a JavaScript string from UTF-8 data stored inside the FlatBuffer. + * This allocates a new string and converts to wide chars upon each access. + * + * To avoid the conversion to UTF-16, pass flatbuffers.Encoding.UTF8_BYTES as + * the "optionalEncoding" argument. This is useful for avoiding conversion to + * and from UTF-16 when the data will just be packaged back up in another + * FlatBuffer later on. + * + * @param {number} offset + * @param {flatbuffers.Encoding=} opt_encoding Defaults to UTF16_STRING + * @returns {string|Uint8Array} + */ +flatbuffers.ByteBuffer.prototype.__string = function(offset, opt_encoding) { + offset += this.readInt32(offset); + + var length = this.readInt32(offset); + var result = ''; + var i = 0; + + offset += flatbuffers.SIZEOF_INT; + + if (opt_encoding === flatbuffers.Encoding.UTF8_BYTES) { + return this.bytes_.subarray(offset, offset + length); + } + + while (i < length) { + var codePoint; + + // Decode UTF-8 + var a = this.readUint8(offset + i++); + if (a < 0xC0) { + codePoint = a; + } else { + var b = this.readUint8(offset + i++); + if (a < 0xE0) { + codePoint = + ((a & 0x1F) << 6) | + (b & 0x3F); + } else { + var c = this.readUint8(offset + i++); + if (a < 0xF0) { + codePoint = + ((a & 0x0F) << 12) | + ((b & 0x3F) << 6) | + (c & 0x3F); + } else { + var d = this.readUint8(offset + i++); + codePoint = + ((a & 0x07) << 18) | + ((b & 0x3F) << 12) | + ((c & 0x3F) << 6) | + (d & 0x3F); + } + } + } + + // Encode UTF-16 + if (codePoint < 0x10000) { + result += String.fromCharCode(codePoint); + } else { + codePoint -= 0x10000; + result += String.fromCharCode( + (codePoint >> 10) + 0xD800, + (codePoint & ((1 << 10) - 1)) + 0xDC00); + } + } + + return result; +}; + +/** + * Retrieve the relative offset stored at "offset" + * @param {number} offset + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.__indirect = function(offset) { + return offset + this.readInt32(offset); +}; + +/** + * Get the start of data of a vector whose offset is stored at "offset" in this object. + * + * @param {number} offset + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.__vector = function(offset) { + return offset + this.readInt32(offset) + flatbuffers.SIZEOF_INT; // data starts after the length +}; + +/** + * Get the length of a vector whose offset is stored at "offset" in this object. + * + * @param {number} offset + * @returns {number} + */ +flatbuffers.ByteBuffer.prototype.__vector_len = function(offset) { + return this.readInt32(offset + this.readInt32(offset)); +}; + +/** + * @param {string} ident + * @returns {boolean} + */ +flatbuffers.ByteBuffer.prototype.__has_identifier = function(ident) { + if (ident.length != flatbuffers.FILE_IDENTIFIER_LENGTH) { + throw new Error('FlatBuffers: file identifier must be length ' + + flatbuffers.FILE_IDENTIFIER_LENGTH); + } + for (var i = 0; i < flatbuffers.FILE_IDENTIFIER_LENGTH; i++) { + if (ident.charCodeAt(i) != this.readInt8(this.position_ + flatbuffers.SIZEOF_INT + i)) { + return false; + } + } + return true; +}; + +/** + * A helper function to avoid generated code depending on this file directly. + * + * @param {number} low + * @param {number} high + * @returns {flatbuffers.Long} + */ +flatbuffers.ByteBuffer.prototype.createLong = function(low, high) { + return flatbuffers.Long.create(low, high); +}; + +// Exports for Node.js and RequireJS +this.flatbuffers = flatbuffers; + +/// @endcond +/// @} diff --git a/features/support/shared_steps.js b/features/support/shared_steps.js index bd16542c7..0eeda2790 100644 --- a/features/support/shared_steps.js +++ b/features/support/shared_steps.js @@ -75,6 +75,10 @@ module.exports = function () { got.message = json.message || ''; } + if (headers.has('data_version')) { + got.data_version = json.data_version || ''; + } + if (headers.has('#')) { // comment column got['#'] = row['#']; @@ -151,6 +155,13 @@ module.exports = function () { if (headers.has('locations')){ got.locations = (locations || '').trim(); } + if (headers.has('waypoints_count')) { + if ('waypoints' in json) { + got.waypoints_count = json.waypoints.length; + } else{ + got.waypoints_count = 0; + } + } /* if (headers.has('approaches')){ got.approaches = (approaches || '').trim(); diff --git a/features/testbot/basic.feature b/features/testbot/basic.feature index c7da7b243..9224cd469 100644 --- a/features/testbot/basic.feature +++ b/features/testbot/basic.feature @@ -17,9 +17,43 @@ Feature: Basic Routing | ab | When I route I should get - | from | to | route | - | a | b | ab,ab | - | b | a | ab,ab | + | from | to | route | data_version | waypoints_count | + | a | b | ab,ab | | 2 | + | b | a | ab,ab | | 2 | + + Scenario: Data_version test + Given the node map + """ + a b + """ + + And the extract extra arguments "--data_version cucumber_data_version" + + And the ways + | nodes | + | ab | + + When I route I should get + | from | to | route | data_version | + | a | b | ab,ab | cucumber_data_version | + | b | a | ab,ab | cucumber_data_version | + + Scenario: Skip_waypoints test + Given the node map + """ + a b + """ + + And skip waypoints + + And the ways + | nodes | + | ab | + + When I route I should get + | from | to | route | waypoints_count | + | a | b | ab,ab | 0 | + | b | a | ab,ab | 0 | Scenario: Routing in between two nodes of way Given the node map diff --git a/features/testbot/duration_matrix.feature b/features/testbot/duration_matrix.feature index dce1b177c..94e0a6414 100644 --- a/features/testbot/duration_matrix.feature +++ b/features/testbot/duration_matrix.feature @@ -21,6 +21,21 @@ Feature: Basic Duration Matrix | a | 0 | 10 | | b | 10 | 0 | + Scenario: Testbot - Travel time matrix of minimal network requested with flatbuffer format + Given the node map + """ + a b + """ + + And the ways + | nodes | + | ab | + + When I request a travel time matrix with flatbuffers I should get + | | a | b | + | a | 0 | 10 | + | b | 10 | 0 | + @ch Scenario: Testbot - Travel time matrix of minimal network with toll exclude Given the query options diff --git a/features/testbot/nil.feature b/features/testbot/nil.feature index af8a0b988..521720af7 100644 --- a/features/testbot/nil.feature +++ b/features/testbot/nil.feature @@ -1,18 +1,18 @@ @routing @testbot @nil -Feature: Testbot - Check assigning nil values - Scenario: Assign nil values to all way strings +Feature: Testbot - Check assigning empty values + Scenario: Assign empty values to all way strings Given the profile file """ functions = require('testbot') function way_function(profile, way, result) - result.name = nil - result.ref = nil - result.destinations = nil - result.exits = nil - result.pronunciation = nil - result.turn_lanes_forward = nil - result.turn_lanes_backward = nil + result.name = "" + result.ref = "" + result.destinations = "" + result.exits = "" + result.pronunciation = "" + result.turn_lanes_forward = "" + result.turn_lanes_backward = "" result.forward_speed = 10 result.backward_speed = 10 diff --git a/features/testbot/oneway_phantom.feature b/features/testbot/oneway_phantom.feature new file mode 100644 index 000000000..9d728a507 --- /dev/null +++ b/features/testbot/oneway_phantom.feature @@ -0,0 +1,85 @@ +@routing @testbot @oneway +Feature: Handle multiple phantom nodes in one-way segment + +# Check we handle routes where source and destination are +# phantom nodes on the same one-way segment. +# See: https://github.com/Project-OSRM/osrm-backend/issues/5788 + + Background: + Given the profile "testbot" + + Scenario: One-way segment with adjacent phantom nodes + Given the node map + """ + d c + + a12b + """ + + And the ways + | nodes | oneway | + | ab | yes | + | bc | no | + | cd | no | + | da | no | + + When I route I should get + | from | to | route | time | distance | + | 1 | 2 | ab,ab | 5s +-0.1 | 50m ~1% | + | 1 | c | ab,bc,bc | 30s +-0.1 | 300m ~1% | + | 2 | 1 | ab,bc,cd,da,ab | 65s +-0.1 | 650m ~1% | + | 2 | c | ab,bc,bc | 25s +-0.1 | 250m ~1% | + | c | 1 | cd,da,ab | 40s +-0.1 | 400m ~1% | + | c | 2 | cd,da,ab | 45s +-0.1 | 450m ~1% | + + When I request a travel time matrix I should get + | | 1 | 2 | c | + | 1 | 0 | 5 +-0.1 | 30 +-0.1 | + | 2 | 65 +-0.1 | 0 | 25 +-0.1 | + | c | 40 +-0.1 | 45 +-0.1 | 0 | + + When I request a travel time matrix I should get + | | 1 | 2 | c | + | 1 | 0 | 5 +-0.1 | 30 +-0.1 | + + When I request a travel time matrix I should get + | | 1 | 2 | c | + | 2 | 65 +-0.1 | 0 | 25 +-0.1 | + + When I request a travel time matrix I should get + | | 1 | + | 1 | 0 | + | 2 | 65 +-0.1 | + | c | 40 +-0.1 | + + When I request a travel time matrix I should get + | | 2 | + | 1 | 5 +-0.1 | + | 2 | 0 | + | c | 45 +-0.1 | + + When I request a travel distance matrix I should get + | | 1 | 2 | c | + | 1 | 0 | 50 ~1% | 300 ~1% | + | 2 | 650 ~1% | 0 | 250 ~1% | + | c | 400 ~1% | 450 ~1% | 0 | + + When I request a travel distance matrix I should get + | | 1 | 2 | c | + | 1 | 0 | 50 ~1% | 300 ~1% | + + When I request a travel distance matrix I should get + | | 1 | 2 | c | + | 2 | 650 ~1% | 0 | 250 ~1% | + + When I request a travel distance matrix I should get + | | 1 | + | 1 | 0 | + | 2 | 650 ~1% | + | c | 400 ~1% | + + When I request a travel distance matrix I should get + | | 2 | + | 1 | 50 ~1% | + | 2 | 0 | + | c | 450 ~1% | diff --git a/features/testbot/via.feature b/features/testbot/via.feature index c851fb87c..017cc54e6 100644 --- a/features/testbot/via.feature +++ b/features/testbot/via.feature @@ -18,6 +18,53 @@ Feature: Via points | waypoints | route | | a,b,c | abc,abc,abc,abc | + Scenario: Simple via point with waypoints collapsing + Given the node map + """ + a + + b 1c d + 2 + + e + """ + + And the ways + | nodes | + | ace | + | bcd | + + Given the query options + | waypoints | 0;2 | + + When I route I should get + | waypoints | route | turns | + | b,1,e | bcd,ace,ace | depart,turn right,arrive | + | b,2,e | bcd,ace,ace | depart,turn right,arrive | + + Scenario: Simple via point with waypoints collapsing + Given the node map + """ + a 2 b + + c d + 1 3 + """ + + And the ways + | nodes | + | ab | + | bd | + | cd | + | ac | + + Given the query options + | waypoints | 0;2 | + + When I route I should get + | waypoints | route | turns | + | 1,2,3 | cd,ac,ab,bd,cd | depart,new name right,new name right,new name right,arrive | + Scenario: Simple via point with core factor Given the contract extra arguments "--core 0.8" Given the node map diff --git a/features/testbot/zero-speed-updates.feature b/features/testbot/zero-speed-updates.feature index 6acb2b0c8..c2bc82c94 100644 --- a/features/testbot/zero-speed-updates.feature +++ b/features/testbot/zero-speed-updates.feature @@ -93,6 +93,31 @@ Feature: Check zero speed updates | 1 | 2 | NoRoute | + Scenario: Routing with alternatives on restricted way + Given the node map + """ + a-1-b-2-c + """ + + And the ways + | nodes | oneway | + | abc | no | + And the contract extra arguments "--segment-speed-file {speeds_file}" + And the customize extra arguments "--segment-speed-file {speeds_file}" + And the speed file + """ + 1,2,0 + 2,1,0 + """ + And the query options + | alternatives | true | + + + When I route I should get + | from | to | code | alternative | + | 1 | 2 | NoRoute | | + + Scenario: Routing on restricted oneway Given the node map """ diff --git a/include/contractor/contract_excludable_graph.hpp b/include/contractor/contract_excludable_graph.hpp index 6ae29282a..74ea8373b 100644 --- a/include/contractor/contract_excludable_graph.hpp +++ b/include/contractor/contract_excludable_graph.hpp @@ -94,7 +94,7 @@ inline auto contractExcludableGraph(ContractorGraph contractor_graph_, return GraphAndFilter{QueryGraph{num_nodes, std::move(edge_container.edges)}, edge_container.MakeEdgeFilters()}; } -} -} +} // namespace contractor +} // namespace osrm #endif diff --git a/include/contractor/contracted_edge_container.hpp b/include/contractor/contracted_edge_container.hpp index 8b37f5d4a..db3ae5cc9 100644 --- a/include/contractor/contracted_edge_container.hpp +++ b/include/contractor/contracted_edge_container.hpp @@ -164,7 +164,7 @@ struct ContractedEdgeContainer std::vector flags; std::vector edges; }; -} -} +} // namespace contractor +} // namespace osrm #endif diff --git a/include/contractor/contracted_metric.hpp b/include/contractor/contracted_metric.hpp index f44f49e83..c795a139a 100644 --- a/include/contractor/contracted_metric.hpp +++ b/include/contractor/contracted_metric.hpp @@ -15,11 +15,11 @@ template struct ContractedMetric detail::QueryGraph graph; std::vector> edge_filter; }; -} +} // namespace detail using ContractedMetric = detail::ContractedMetric; using ContractedMetricView = detail::ContractedMetric; -} -} +} // namespace contractor +} // namespace osrm #endif diff --git a/include/contractor/contractor.hpp b/include/contractor/contractor.hpp index ee1d2dd42..a0335d8ea 100644 --- a/include/contractor/contractor.hpp +++ b/include/contractor/contractor.hpp @@ -49,7 +49,7 @@ class Contractor private: ContractorConfig config; }; -} -} +} // namespace contractor +} // namespace osrm #endif // PROCESSING_CHAIN_HPP diff --git a/include/contractor/contractor_config.hpp b/include/contractor/contractor_config.hpp index 8f1455cce..c93d2e63d 100644 --- a/include/contractor/contractor_config.hpp +++ b/include/contractor/contractor_config.hpp @@ -73,7 +73,7 @@ struct ContractorConfig final : storage::IOConfig //(e.g. 0.8 contracts 80 percent of the hierarchy, leaving a core of 20%) double core_factor; }; -} -} +} // namespace contractor +} // namespace osrm #endif // EXTRACTOR_OPTIONS_HPP diff --git a/include/contractor/crc32_processor.hpp b/include/contractor/crc32_processor.hpp index 4130ed583..a441ae576 100644 --- a/include/contractor/crc32_processor.hpp +++ b/include/contractor/crc32_processor.hpp @@ -125,7 +125,7 @@ struct RangebasedCRC32 private: IteratorbasedCRC32 crc32; }; -} -} +} // namespace contractor +} // namespace osrm #endif /* ITERATOR_BASED_CRC32_H */ diff --git a/include/contractor/files.hpp b/include/contractor/files.hpp index 8dcade795..39ffa5b54 100644 --- a/include/contractor/files.hpp +++ b/include/contractor/files.hpp @@ -52,8 +52,8 @@ inline void writeGraph(const boost::filesystem::path &path, serialization::write(writer, "/ch/metrics/" + pair.first, pair.second); } } -} -} -} +} // namespace files +} // namespace contractor +} // namespace osrm #endif diff --git a/include/contractor/query_edge.hpp b/include/contractor/query_edge.hpp index 74d38e79e..351ecee24 100644 --- a/include/contractor/query_edge.hpp +++ b/include/contractor/query_edge.hpp @@ -77,7 +77,7 @@ struct QueryEdge data.distance == right.data.distance); } }; -} -} +} // namespace contractor +} // namespace osrm #endif // QUERYEDGE_HPP diff --git a/include/contractor/query_graph.hpp b/include/contractor/query_graph.hpp index e5758dcfe..b312a5403 100644 --- a/include/contractor/query_graph.hpp +++ b/include/contractor/query_graph.hpp @@ -19,7 +19,7 @@ using QueryGraph = util::StaticGraph; using QueryGraph = detail::QueryGraph; using QueryGraphView = detail::QueryGraph; -} -} +} // namespace contractor +} // namespace osrm #endif // QUERYEDGE_HPP diff --git a/include/contractor/serialization.hpp b/include/contractor/serialization.hpp index aa8659274..693216d6a 100644 --- a/include/contractor/serialization.hpp +++ b/include/contractor/serialization.hpp @@ -46,8 +46,8 @@ void read(storage::tar::FileReader &reader, metric.edge_filter[index]); } } -} -} -} +} // namespace serialization +} // namespace contractor +} // namespace osrm #endif diff --git a/include/customizer/cell_customizer.hpp b/include/customizer/cell_customizer.hpp index df5499579..9e27236d0 100644 --- a/include/customizer/cell_customizer.hpp +++ b/include/customizer/cell_customizer.hpp @@ -212,9 +212,8 @@ class CellCustomizer } const auto &data = graph.GetEdgeData(edge); - if (data.forward && - (first_level || - partition.GetCell(level - 1, node) != partition.GetCell(level - 1, to))) + if (data.forward && (first_level || partition.GetCell(level - 1, node) != + partition.GetCell(level - 1, to))) { const EdgeWeight to_weight = weight + data.weight; const EdgeDuration to_duration = duration + data.duration; @@ -237,7 +236,7 @@ class CellCustomizer const partitioner::MultiLevelPartition &partition; }; -} -} +} // namespace customizer +} // namespace osrm #endif // OSRM_CELLS_CUSTOMIZER_HPP diff --git a/include/customizer/cell_metric.hpp b/include/customizer/cell_metric.hpp index 7674174fe..a522facc3 100644 --- a/include/customizer/cell_metric.hpp +++ b/include/customizer/cell_metric.hpp @@ -22,11 +22,11 @@ template struct CellMetricImpl Vector durations; Vector distances; }; -} +} // namespace detail using CellMetric = detail::CellMetricImpl; using CellMetricView = detail::CellMetricImpl; -} -} +} // namespace customizer +} // namespace osrm #endif diff --git a/include/customizer/customizer_config.hpp b/include/customizer/customizer_config.hpp index 35ab1a356..4df629de5 100644 --- a/include/customizer/customizer_config.hpp +++ b/include/customizer/customizer_config.hpp @@ -39,7 +39,7 @@ struct CustomizationConfig final : storage::IOConfig updater::UpdaterConfig updater_config; }; -} -} +} // namespace customizer +} // namespace osrm #endif // OSRM_CUSTOMIZE_CUSTOMIZER_CONFIG_HPP diff --git a/include/customizer/edge_based_graph.hpp b/include/customizer/edge_based_graph.hpp index 840a84299..5ef3277f9 100644 --- a/include/customizer/edge_based_graph.hpp +++ b/include/customizer/edge_based_graph.hpp @@ -34,7 +34,7 @@ template void write(storage::tar::FileWriter &writer, const std::string &name, const MultiLevelGraph &graph); -} +} // namespace serialization template class MultiLevelGraph : public partitioner::MultiLevelGraph @@ -126,7 +126,7 @@ using MultiLevelEdgeBasedGraph = MultiLevelGraph; using MultiLevelEdgeBasedGraphView = MultiLevelGraph; -} -} +} // namespace customizer +} // namespace osrm #endif diff --git a/include/customizer/files.hpp b/include/customizer/files.hpp index 364a2572d..335b77a30 100644 --- a/include/customizer/files.hpp +++ b/include/customizer/files.hpp @@ -106,8 +106,8 @@ inline void writeGraph(const boost::filesystem::path &path, writer.WriteFrom("/mld/connectivity_checksum", connectivity_checksum); serialization::write(writer, "/mld/multilevelgraph", graph); } -} -} -} +} // namespace files +} // namespace customizer +} // namespace osrm #endif diff --git a/include/customizer/serialization.hpp b/include/customizer/serialization.hpp index afe23cf9b..c242f8ba3 100644 --- a/include/customizer/serialization.hpp +++ b/include/customizer/serialization.hpp @@ -65,8 +65,8 @@ inline void write(storage::tar::FileWriter &writer, storage::serialization::write(writer, name + "/is_backward_edge", graph.is_backward_edge); storage::serialization::write(writer, name + "/node_to_edge_offset", graph.node_to_edge_offset); } -} -} -} +} // namespace serialization +} // namespace customizer +} // namespace osrm #endif diff --git a/include/engine/algorithm.hpp b/include/engine/algorithm.hpp index 760f78e80..1d65cac04 100644 --- a/include/engine/algorithm.hpp +++ b/include/engine/algorithm.hpp @@ -16,14 +16,14 @@ namespace ch struct Algorithm final { }; -} +} // namespace ch // Multi-Level Dijkstra namespace mld { struct Algorithm final { }; -} +} // namespace mld // Algorithm names template const char *name(); @@ -111,8 +111,8 @@ template <> struct HasGetTileTurns final : std::true_type template <> struct HasExcludeFlags final : std::true_type { }; -} -} -} +} // namespace routing_algorithms +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/api/base_api.hpp b/include/engine/api/base_api.hpp index e0c924348..6cd1a6e48 100644 --- a/include/engine/api/base_api.hpp +++ b/include/engine/api/base_api.hpp @@ -2,6 +2,7 @@ #define ENGINE_API_BASE_API_HPP #include "engine/api/base_parameters.hpp" +#include "engine/api/flatbuffers/fbresult_generated.h" #include "engine/datafacade/datafacade_base.hpp" #include "engine/api/json_factory.hpp" @@ -11,6 +12,7 @@ #include #include +#include #include namespace osrm @@ -71,12 +73,63 @@ class BaseAPI } } + flatbuffers::Offset>> + MakeWaypoints(flatbuffers::FlatBufferBuilder *builder, + const std::vector &segment_end_coordinates) const + { + BOOST_ASSERT(parameters.coordinates.size() > 0); + BOOST_ASSERT(parameters.coordinates.size() == segment_end_coordinates.size() + 1); + + std::vector> waypoints; + waypoints.resize(parameters.coordinates.size()); + waypoints[0] = + MakeWaypoint(builder, segment_end_coordinates.front().source_phantom)->Finish(); + + std::transform(segment_end_coordinates.begin(), + segment_end_coordinates.end(), + std::next(waypoints.begin()), + [this, builder](const PhantomNodes &phantom_pair) { + return MakeWaypoint(builder, phantom_pair.target_phantom)->Finish(); + }); + return builder->CreateVector(waypoints); + } + + // FIXME: gcc 4.9 does not like MakeWaypoints to be protected + // protected: + std::unique_ptr MakeWaypoint(flatbuffers::FlatBufferBuilder *builder, + const PhantomNode &phantom) const + { + + auto location = + fbresult::Position(static_cast(util::toFloating(phantom.location.lon)), + static_cast(util::toFloating(phantom.location.lat))); + auto name_string = builder->CreateString( + facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)).to_string()); + + flatbuffers::Offset hint_string; + if (parameters.generate_hints) + { + hint_string = builder->CreateString(Hint{phantom, facade.GetCheckSum()}.ToBase64()); + } + + auto waypoint = std::make_unique(*builder); + waypoint->add_location(&location); + waypoint->add_distance(util::coordinate_calculation::fccApproximateDistance( + phantom.location, phantom.input_location)); + waypoint->add_name(name_string); + if (parameters.generate_hints) + { + waypoint->add_hint(hint_string); + } + return waypoint; + } + const datafacade::BaseDataFacade &facade; const BaseParameters ¶meters; }; -} // ns api -} // ns engine -} // ns osrm +} // namespace api +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/api/base_parameters.hpp b/include/engine/api/base_parameters.hpp index 4693c67a1..e49f71157 100644 --- a/include/engine/api/base_parameters.hpp +++ b/include/engine/api/base_parameters.hpp @@ -63,29 +63,50 @@ namespace api */ struct BaseParameters { + + enum class SnappingType + { + Default, + Any + }; + + enum class OutputFormatType + { + JSON, + FLATBUFFERS + }; + std::vector coordinates; std::vector> hints; std::vector> radiuses; std::vector> bearings; std::vector> approaches; std::vector exclude; + boost::optional format = OutputFormatType::JSON; // Adds hints to response which can be included in subsequent requests, see `hints` above. bool generate_hints = true; - BaseParameters(const std::vector coordinates_ = {}, - const std::vector> hints_ = {}, + // Remove waypoints array from the response. + bool skip_waypoints = false; + + SnappingType snapping = SnappingType::Default; + + BaseParameters(std::vector coordinates_ = {}, + std::vector> hints_ = {}, std::vector> radiuses_ = {}, std::vector> bearings_ = {}, std::vector> approaches_ = {}, bool generate_hints_ = true, - std::vector exclude = {}) - : coordinates(coordinates_), hints(hints_), radiuses(radiuses_), bearings(bearings_), - approaches(approaches_), exclude(std::move(exclude)), generate_hints(generate_hints_) + std::vector exclude = {}, + const SnappingType snapping_ = SnappingType::Default) + : coordinates(std::move(coordinates_)), hints(std::move(hints_)), + radiuses(std::move(radiuses_)), bearings(std::move(bearings_)), + approaches(std::move(approaches_)), exclude(std::move(exclude)), + generate_hints(generate_hints_), snapping(snapping_) { } - // FIXME add validation for invalid bearing values bool IsValid() const { return (hints.empty() || hints.size() == coordinates.size()) && @@ -94,7 +115,7 @@ struct BaseParameters (approaches.empty() || approaches.size() == coordinates.size()) && std::all_of(bearings.begin(), bearings.end(), - [](const boost::optional bearing_and_range) { + [](const boost::optional &bearing_and_range) { if (bearing_and_range) { return bearing_and_range->IsValid(); @@ -103,8 +124,8 @@ struct BaseParameters }); } }; -} -} -} +} // namespace api +} // namespace engine +} // namespace osrm #endif // ROUTE_PARAMETERS_HPP diff --git a/include/engine/api/base_result.hpp b/include/engine/api/base_result.hpp new file mode 100644 index 000000000..5dd63e7a9 --- /dev/null +++ b/include/engine/api/base_result.hpp @@ -0,0 +1,23 @@ +#ifndef ENGINE_API_BASE_RESULT_HPP +#define ENGINE_API_BASE_RESULT_HPP + +#include +#include + +#include + +#include "util/json_container.hpp" + +namespace osrm +{ +namespace engine +{ +namespace api +{ +using ResultT = + mapbox::util::variant; +} // namespace api +} // namespace engine +} // namespace osrm + +#endif diff --git a/include/engine/api/flatbuffers/fbresult.fbs b/include/engine/api/flatbuffers/fbresult.fbs new file mode 100644 index 000000000..a587899a3 --- /dev/null +++ b/include/engine/api/flatbuffers/fbresult.fbs @@ -0,0 +1,20 @@ +include "route.fbs"; +include "table.fbs"; + +namespace osrm.engine.api.fbresult; + +table Error { + code: string; + message: string; +} + +table FBResult { + error: bool = false; + code: Error; + data_version: string; + waypoints: [Waypoint]; //Used as 'sources' waypoints for a 'Table' service + routes: [RouteObject]; + table: Table; +} + +root_type FBResult; \ No newline at end of file diff --git a/include/engine/api/flatbuffers/fbresult_generated.h b/include/engine/api/flatbuffers/fbresult_generated.h new file mode 100644 index 000000000..f3f05de4a --- /dev/null +++ b/include/engine/api/flatbuffers/fbresult_generated.h @@ -0,0 +1,2439 @@ +// automatically generated by the FlatBuffers compiler, do not modify + + +#ifndef FLATBUFFERS_GENERATED_FBRESULT_OSRM_ENGINE_API_FBRESULT_H_ +#define FLATBUFFERS_GENERATED_FBRESULT_OSRM_ENGINE_API_FBRESULT_H_ + +#include "flatbuffers/flatbuffers.h" + +namespace osrm { +namespace engine { +namespace api { +namespace fbresult { + +struct Position; + +struct Uint64Pair; + +struct Waypoint; +struct WaypointT; + +struct Metadata; +struct MetadataT; + +struct Annotation; +struct AnnotationT; + +struct StepManeuver; +struct StepManeuverT; + +struct Lane; +struct LaneT; + +struct Intersection; +struct IntersectionT; + +struct Step; +struct StepT; + +struct Leg; +struct LegT; + +struct RouteObject; +struct RouteObjectT; + +struct Table; +struct TableT; + +struct Error; +struct ErrorT; + +struct FBResult; +struct FBResultT; + +enum ManeuverType { + ManeuverType_Turn = 0, + ManeuverType_NewName = 1, + ManeuverType_Depart = 2, + ManeuverType_Arrive = 3, + ManeuverType_Merge = 4, + ManeuverType_OnRamp = 5, + ManeuverType_OffRamp = 6, + ManeuverType_Fork = 7, + ManeuverType_EndOfRoad = 8, + ManeuverType_Continue = 9, + ManeuverType_Roundabout = 10, + ManeuverType_Rotary = 11, + ManeuverType_RoundaboutTurn = 12, + ManeuverType_Notification = 13, + ManeuverType_ExitRoundabout = 14, + ManeuverType_ExitRotary = 15, + ManeuverType_MIN = ManeuverType_Turn, + ManeuverType_MAX = ManeuverType_ExitRotary +}; + +inline const ManeuverType (&EnumValuesManeuverType())[16] { + static const ManeuverType values[] = { + ManeuverType_Turn, + ManeuverType_NewName, + ManeuverType_Depart, + ManeuverType_Arrive, + ManeuverType_Merge, + ManeuverType_OnRamp, + ManeuverType_OffRamp, + ManeuverType_Fork, + ManeuverType_EndOfRoad, + ManeuverType_Continue, + ManeuverType_Roundabout, + ManeuverType_Rotary, + ManeuverType_RoundaboutTurn, + ManeuverType_Notification, + ManeuverType_ExitRoundabout, + ManeuverType_ExitRotary + }; + return values; +} + +inline const char * const *EnumNamesManeuverType() { + static const char * const names[17] = { + "Turn", + "NewName", + "Depart", + "Arrive", + "Merge", + "OnRamp", + "OffRamp", + "Fork", + "EndOfRoad", + "Continue", + "Roundabout", + "Rotary", + "RoundaboutTurn", + "Notification", + "ExitRoundabout", + "ExitRotary", + nullptr + }; + return names; +} + +inline const char *EnumNameManeuverType(ManeuverType e) { + if (e < ManeuverType_Turn || e > ManeuverType_ExitRotary) return ""; + const size_t index = static_cast(e); + return EnumNamesManeuverType()[index]; +} + +enum Turn { + Turn_None = 0, + Turn_UTurn = 1, + Turn_SharpRight = 2, + Turn_Right = 3, + Turn_SlightRight = 4, + Turn_Straight = 5, + Turn_SlightLeft = 6, + Turn_Left = 7, + Turn_SharpLeft = 8, + Turn_MIN = Turn_None, + Turn_MAX = Turn_SharpLeft +}; + +inline const Turn (&EnumValuesTurn())[9] { + static const Turn values[] = { + Turn_None, + Turn_UTurn, + Turn_SharpRight, + Turn_Right, + Turn_SlightRight, + Turn_Straight, + Turn_SlightLeft, + Turn_Left, + Turn_SharpLeft + }; + return values; +} + +inline const char * const *EnumNamesTurn() { + static const char * const names[10] = { + "None", + "UTurn", + "SharpRight", + "Right", + "SlightRight", + "Straight", + "SlightLeft", + "Left", + "SharpLeft", + nullptr + }; + return names; +} + +inline const char *EnumNameTurn(Turn e) { + if (e < Turn_None || e > Turn_SharpLeft) return ""; + const size_t index = static_cast(e); + return EnumNamesTurn()[index]; +} + +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Position FLATBUFFERS_FINAL_CLASS { + private: + float longitude_; + float latitude_; + + public: + Position() { + memset(static_cast(this), 0, sizeof(Position)); + } + Position(float _longitude, float _latitude) + : longitude_(flatbuffers::EndianScalar(_longitude)), + latitude_(flatbuffers::EndianScalar(_latitude)) { + } + float longitude() const { + return flatbuffers::EndianScalar(longitude_); + } + float latitude() const { + return flatbuffers::EndianScalar(latitude_); + } +}; +FLATBUFFERS_STRUCT_END(Position, 8); + +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Uint64Pair FLATBUFFERS_FINAL_CLASS { + private: + uint64_t first_; + uint64_t second_; + + public: + Uint64Pair() { + memset(static_cast(this), 0, sizeof(Uint64Pair)); + } + Uint64Pair(uint64_t _first, uint64_t _second) + : first_(flatbuffers::EndianScalar(_first)), + second_(flatbuffers::EndianScalar(_second)) { + } + uint64_t first() const { + return flatbuffers::EndianScalar(first_); + } + uint64_t second() const { + return flatbuffers::EndianScalar(second_); + } +}; +FLATBUFFERS_STRUCT_END(Uint64Pair, 16); + +struct WaypointT : public flatbuffers::NativeTable { + typedef Waypoint TableType; + std::string hint; + float distance; + std::string name; + std::unique_ptr location; + std::unique_ptr nodes; + uint32_t matchings_index; + uint32_t waypoint_index; + uint32_t alternatives_count; + uint32_t trips_index; + WaypointT() + : distance(0.0f), + matchings_index(0), + waypoint_index(0), + alternatives_count(0), + trips_index(0) { + } +}; + +struct Waypoint FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef WaypointT NativeTableType; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_HINT = 4, + VT_DISTANCE = 6, + VT_NAME = 8, + VT_LOCATION = 10, + VT_NODES = 12, + VT_MATCHINGS_INDEX = 14, + VT_WAYPOINT_INDEX = 16, + VT_ALTERNATIVES_COUNT = 18, + VT_TRIPS_INDEX = 20 + }; + const flatbuffers::String *hint() const { + return GetPointer(VT_HINT); + } + float distance() const { + return GetField(VT_DISTANCE, 0.0f); + } + const flatbuffers::String *name() const { + return GetPointer(VT_NAME); + } + const osrm::engine::api::fbresult::Position *location() const { + return GetStruct(VT_LOCATION); + } + const osrm::engine::api::fbresult::Uint64Pair *nodes() const { + return GetStruct(VT_NODES); + } + uint32_t matchings_index() const { + return GetField(VT_MATCHINGS_INDEX, 0); + } + uint32_t waypoint_index() const { + return GetField(VT_WAYPOINT_INDEX, 0); + } + uint32_t alternatives_count() const { + return GetField(VT_ALTERNATIVES_COUNT, 0); + } + uint32_t trips_index() const { + return GetField(VT_TRIPS_INDEX, 0); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_HINT) && + verifier.VerifyString(hint()) && + VerifyField(verifier, VT_DISTANCE) && + VerifyOffset(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyField(verifier, VT_LOCATION) && + VerifyField(verifier, VT_NODES) && + VerifyField(verifier, VT_MATCHINGS_INDEX) && + VerifyField(verifier, VT_WAYPOINT_INDEX) && + VerifyField(verifier, VT_ALTERNATIVES_COUNT) && + VerifyField(verifier, VT_TRIPS_INDEX) && + verifier.EndTable(); + } + WaypointT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(WaypointT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const WaypointT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct WaypointBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_hint(flatbuffers::Offset hint) { + fbb_.AddOffset(Waypoint::VT_HINT, hint); + } + void add_distance(float distance) { + fbb_.AddElement(Waypoint::VT_DISTANCE, distance, 0.0f); + } + void add_name(flatbuffers::Offset name) { + fbb_.AddOffset(Waypoint::VT_NAME, name); + } + void add_location(const osrm::engine::api::fbresult::Position *location) { + fbb_.AddStruct(Waypoint::VT_LOCATION, location); + } + void add_nodes(const osrm::engine::api::fbresult::Uint64Pair *nodes) { + fbb_.AddStruct(Waypoint::VT_NODES, nodes); + } + void add_matchings_index(uint32_t matchings_index) { + fbb_.AddElement(Waypoint::VT_MATCHINGS_INDEX, matchings_index, 0); + } + void add_waypoint_index(uint32_t waypoint_index) { + fbb_.AddElement(Waypoint::VT_WAYPOINT_INDEX, waypoint_index, 0); + } + void add_alternatives_count(uint32_t alternatives_count) { + fbb_.AddElement(Waypoint::VT_ALTERNATIVES_COUNT, alternatives_count, 0); + } + void add_trips_index(uint32_t trips_index) { + fbb_.AddElement(Waypoint::VT_TRIPS_INDEX, trips_index, 0); + } + explicit WaypointBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + WaypointBuilder &operator=(const WaypointBuilder &); + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateWaypoint( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset hint = 0, + float distance = 0.0f, + flatbuffers::Offset name = 0, + const osrm::engine::api::fbresult::Position *location = 0, + const osrm::engine::api::fbresult::Uint64Pair *nodes = 0, + uint32_t matchings_index = 0, + uint32_t waypoint_index = 0, + uint32_t alternatives_count = 0, + uint32_t trips_index = 0) { + WaypointBuilder builder_(_fbb); + builder_.add_trips_index(trips_index); + builder_.add_alternatives_count(alternatives_count); + builder_.add_waypoint_index(waypoint_index); + builder_.add_matchings_index(matchings_index); + builder_.add_nodes(nodes); + builder_.add_location(location); + builder_.add_name(name); + builder_.add_distance(distance); + builder_.add_hint(hint); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateWaypointDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *hint = nullptr, + float distance = 0.0f, + const char *name = nullptr, + const osrm::engine::api::fbresult::Position *location = 0, + const osrm::engine::api::fbresult::Uint64Pair *nodes = 0, + uint32_t matchings_index = 0, + uint32_t waypoint_index = 0, + uint32_t alternatives_count = 0, + uint32_t trips_index = 0) { + auto hint__ = hint ? _fbb.CreateString(hint) : 0; + auto name__ = name ? _fbb.CreateString(name) : 0; + return osrm::engine::api::fbresult::CreateWaypoint( + _fbb, + hint__, + distance, + name__, + location, + nodes, + matchings_index, + waypoint_index, + alternatives_count, + trips_index); +} + +flatbuffers::Offset CreateWaypoint(flatbuffers::FlatBufferBuilder &_fbb, const WaypointT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + +struct MetadataT : public flatbuffers::NativeTable { + typedef Metadata TableType; + std::vector datasource_names; + MetadataT() { + } +}; + +struct Metadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef MetadataT NativeTableType; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_DATASOURCE_NAMES = 4 + }; + const flatbuffers::Vector> *datasource_names() const { + return GetPointer> *>(VT_DATASOURCE_NAMES); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_DATASOURCE_NAMES) && + verifier.VerifyVector(datasource_names()) && + verifier.VerifyVectorOfStrings(datasource_names()) && + verifier.EndTable(); + } + MetadataT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(MetadataT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const MetadataT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct MetadataBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_datasource_names(flatbuffers::Offset>> datasource_names) { + fbb_.AddOffset(Metadata::VT_DATASOURCE_NAMES, datasource_names); + } + explicit MetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + MetadataBuilder &operator=(const MetadataBuilder &); + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateMetadata( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset>> datasource_names = 0) { + MetadataBuilder builder_(_fbb); + builder_.add_datasource_names(datasource_names); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateMetadataDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const std::vector> *datasource_names = nullptr) { + auto datasource_names__ = datasource_names ? _fbb.CreateVector>(*datasource_names) : 0; + return osrm::engine::api::fbresult::CreateMetadata( + _fbb, + datasource_names__); +} + +flatbuffers::Offset CreateMetadata(flatbuffers::FlatBufferBuilder &_fbb, const MetadataT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + +struct AnnotationT : public flatbuffers::NativeTable { + typedef Annotation TableType; + std::vector distance; + std::vector duration; + std::vector datasources; + std::vector nodes; + std::vector weight; + std::vector speed; + std::unique_ptr metadata; + AnnotationT() { + } +}; + +struct Annotation FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef AnnotationT NativeTableType; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_DISTANCE = 4, + VT_DURATION = 6, + VT_DATASOURCES = 8, + VT_NODES = 10, + VT_WEIGHT = 12, + VT_SPEED = 14, + VT_METADATA = 16 + }; + const flatbuffers::Vector *distance() const { + return GetPointer *>(VT_DISTANCE); + } + const flatbuffers::Vector *duration() const { + return GetPointer *>(VT_DURATION); + } + const flatbuffers::Vector *datasources() const { + return GetPointer *>(VT_DATASOURCES); + } + const flatbuffers::Vector *nodes() const { + return GetPointer *>(VT_NODES); + } + const flatbuffers::Vector *weight() const { + return GetPointer *>(VT_WEIGHT); + } + const flatbuffers::Vector *speed() const { + return GetPointer *>(VT_SPEED); + } + const osrm::engine::api::fbresult::Metadata *metadata() const { + return GetPointer(VT_METADATA); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_DISTANCE) && + verifier.VerifyVector(distance()) && + VerifyOffset(verifier, VT_DURATION) && + verifier.VerifyVector(duration()) && + VerifyOffset(verifier, VT_DATASOURCES) && + verifier.VerifyVector(datasources()) && + VerifyOffset(verifier, VT_NODES) && + verifier.VerifyVector(nodes()) && + VerifyOffset(verifier, VT_WEIGHT) && + verifier.VerifyVector(weight()) && + VerifyOffset(verifier, VT_SPEED) && + verifier.VerifyVector(speed()) && + VerifyOffset(verifier, VT_METADATA) && + verifier.VerifyTable(metadata()) && + verifier.EndTable(); + } + AnnotationT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(AnnotationT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const AnnotationT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct AnnotationBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_distance(flatbuffers::Offset> distance) { + fbb_.AddOffset(Annotation::VT_DISTANCE, distance); + } + void add_duration(flatbuffers::Offset> duration) { + fbb_.AddOffset(Annotation::VT_DURATION, duration); + } + void add_datasources(flatbuffers::Offset> datasources) { + fbb_.AddOffset(Annotation::VT_DATASOURCES, datasources); + } + void add_nodes(flatbuffers::Offset> nodes) { + fbb_.AddOffset(Annotation::VT_NODES, nodes); + } + void add_weight(flatbuffers::Offset> weight) { + fbb_.AddOffset(Annotation::VT_WEIGHT, weight); + } + void add_speed(flatbuffers::Offset> speed) { + fbb_.AddOffset(Annotation::VT_SPEED, speed); + } + void add_metadata(flatbuffers::Offset metadata) { + fbb_.AddOffset(Annotation::VT_METADATA, metadata); + } + explicit AnnotationBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + AnnotationBuilder &operator=(const AnnotationBuilder &); + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateAnnotation( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset> distance = 0, + flatbuffers::Offset> duration = 0, + flatbuffers::Offset> datasources = 0, + flatbuffers::Offset> nodes = 0, + flatbuffers::Offset> weight = 0, + flatbuffers::Offset> speed = 0, + flatbuffers::Offset metadata = 0) { + AnnotationBuilder builder_(_fbb); + builder_.add_metadata(metadata); + builder_.add_speed(speed); + builder_.add_weight(weight); + builder_.add_nodes(nodes); + builder_.add_datasources(datasources); + builder_.add_duration(duration); + builder_.add_distance(distance); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateAnnotationDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const std::vector *distance = nullptr, + const std::vector *duration = nullptr, + const std::vector *datasources = nullptr, + const std::vector *nodes = nullptr, + const std::vector *weight = nullptr, + const std::vector *speed = nullptr, + flatbuffers::Offset metadata = 0) { + auto distance__ = distance ? _fbb.CreateVector(*distance) : 0; + auto duration__ = duration ? _fbb.CreateVector(*duration) : 0; + auto datasources__ = datasources ? _fbb.CreateVector(*datasources) : 0; + auto nodes__ = nodes ? _fbb.CreateVector(*nodes) : 0; + auto weight__ = weight ? _fbb.CreateVector(*weight) : 0; + auto speed__ = speed ? _fbb.CreateVector(*speed) : 0; + return osrm::engine::api::fbresult::CreateAnnotation( + _fbb, + distance__, + duration__, + datasources__, + nodes__, + weight__, + speed__, + metadata); +} + +flatbuffers::Offset CreateAnnotation(flatbuffers::FlatBufferBuilder &_fbb, const AnnotationT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + +struct StepManeuverT : public flatbuffers::NativeTable { + typedef StepManeuver TableType; + std::unique_ptr location; + uint16_t bearing_before; + uint16_t bearing_after; + osrm::engine::api::fbresult::ManeuverType type; + osrm::engine::api::fbresult::Turn modifier; + uint8_t exit; + StepManeuverT() + : bearing_before(0), + bearing_after(0), + type(osrm::engine::api::fbresult::ManeuverType_Turn), + modifier(osrm::engine::api::fbresult::Turn_None), + exit(0) { + } +}; + +struct StepManeuver FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef StepManeuverT NativeTableType; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_LOCATION = 4, + VT_BEARING_BEFORE = 6, + VT_BEARING_AFTER = 8, + VT_TYPE = 10, + VT_MODIFIER = 12, + VT_EXIT = 14 + }; + const osrm::engine::api::fbresult::Position *location() const { + return GetStruct(VT_LOCATION); + } + uint16_t bearing_before() const { + return GetField(VT_BEARING_BEFORE, 0); + } + uint16_t bearing_after() const { + return GetField(VT_BEARING_AFTER, 0); + } + osrm::engine::api::fbresult::ManeuverType type() const { + return static_cast(GetField(VT_TYPE, 0)); + } + osrm::engine::api::fbresult::Turn modifier() const { + return static_cast(GetField(VT_MODIFIER, 0)); + } + uint8_t exit() const { + return GetField(VT_EXIT, 0); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_LOCATION) && + VerifyField(verifier, VT_BEARING_BEFORE) && + VerifyField(verifier, VT_BEARING_AFTER) && + VerifyField(verifier, VT_TYPE) && + VerifyField(verifier, VT_MODIFIER) && + VerifyField(verifier, VT_EXIT) && + verifier.EndTable(); + } + StepManeuverT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(StepManeuverT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const StepManeuverT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct StepManeuverBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_location(const osrm::engine::api::fbresult::Position *location) { + fbb_.AddStruct(StepManeuver::VT_LOCATION, location); + } + void add_bearing_before(uint16_t bearing_before) { + fbb_.AddElement(StepManeuver::VT_BEARING_BEFORE, bearing_before, 0); + } + void add_bearing_after(uint16_t bearing_after) { + fbb_.AddElement(StepManeuver::VT_BEARING_AFTER, bearing_after, 0); + } + void add_type(osrm::engine::api::fbresult::ManeuverType type) { + fbb_.AddElement(StepManeuver::VT_TYPE, static_cast(type), 0); + } + void add_modifier(osrm::engine::api::fbresult::Turn modifier) { + fbb_.AddElement(StepManeuver::VT_MODIFIER, static_cast(modifier), 0); + } + void add_exit(uint8_t exit) { + fbb_.AddElement(StepManeuver::VT_EXIT, exit, 0); + } + explicit StepManeuverBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + StepManeuverBuilder &operator=(const StepManeuverBuilder &); + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateStepManeuver( + flatbuffers::FlatBufferBuilder &_fbb, + const osrm::engine::api::fbresult::Position *location = 0, + uint16_t bearing_before = 0, + uint16_t bearing_after = 0, + osrm::engine::api::fbresult::ManeuverType type = osrm::engine::api::fbresult::ManeuverType_Turn, + osrm::engine::api::fbresult::Turn modifier = osrm::engine::api::fbresult::Turn_None, + uint8_t exit = 0) { + StepManeuverBuilder builder_(_fbb); + builder_.add_location(location); + builder_.add_bearing_after(bearing_after); + builder_.add_bearing_before(bearing_before); + builder_.add_exit(exit); + builder_.add_modifier(modifier); + builder_.add_type(type); + return builder_.Finish(); +} + +flatbuffers::Offset CreateStepManeuver(flatbuffers::FlatBufferBuilder &_fbb, const StepManeuverT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + +struct LaneT : public flatbuffers::NativeTable { + typedef Lane TableType; + std::vector indications; + bool valid; + LaneT() + : valid(false) { + } +}; + +struct Lane FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef LaneT NativeTableType; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_INDICATIONS = 4, + VT_VALID = 6 + }; + const flatbuffers::Vector *indications() const { + return GetPointer *>(VT_INDICATIONS); + } + bool valid() const { + return GetField(VT_VALID, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_INDICATIONS) && + verifier.VerifyVector(indications()) && + VerifyField(verifier, VT_VALID) && + verifier.EndTable(); + } + LaneT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(LaneT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const LaneT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct LaneBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_indications(flatbuffers::Offset> indications) { + fbb_.AddOffset(Lane::VT_INDICATIONS, indications); + } + void add_valid(bool valid) { + fbb_.AddElement(Lane::VT_VALID, static_cast(valid), 0); + } + explicit LaneBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + LaneBuilder &operator=(const LaneBuilder &); + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateLane( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset> indications = 0, + bool valid = false) { + LaneBuilder builder_(_fbb); + builder_.add_indications(indications); + builder_.add_valid(valid); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateLaneDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const std::vector *indications = nullptr, + bool valid = false) { + auto indications__ = indications ? _fbb.CreateVector(*indications) : 0; + return osrm::engine::api::fbresult::CreateLane( + _fbb, + indications__, + valid); +} + +flatbuffers::Offset CreateLane(flatbuffers::FlatBufferBuilder &_fbb, const LaneT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + +struct IntersectionT : public flatbuffers::NativeTable { + typedef Intersection TableType; + std::unique_ptr location; + std::vector bearings; + std::vector classes; + std::vector entry; + uint32_t in_bearing; + uint32_t out_bearing; + std::vector> lanes; + IntersectionT() + : in_bearing(0), + out_bearing(0) { + } +}; + +struct Intersection FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef IntersectionT NativeTableType; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_LOCATION = 4, + VT_BEARINGS = 6, + VT_CLASSES = 8, + VT_ENTRY = 10, + VT_IN_BEARING = 12, + VT_OUT_BEARING = 14, + VT_LANES = 16 + }; + const osrm::engine::api::fbresult::Position *location() const { + return GetStruct(VT_LOCATION); + } + const flatbuffers::Vector *bearings() const { + return GetPointer *>(VT_BEARINGS); + } + const flatbuffers::Vector> *classes() const { + return GetPointer> *>(VT_CLASSES); + } + const flatbuffers::Vector *entry() const { + return GetPointer *>(VT_ENTRY); + } + uint32_t in_bearing() const { + return GetField(VT_IN_BEARING, 0); + } + uint32_t out_bearing() const { + return GetField(VT_OUT_BEARING, 0); + } + const flatbuffers::Vector> *lanes() const { + return GetPointer> *>(VT_LANES); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_LOCATION) && + VerifyOffset(verifier, VT_BEARINGS) && + verifier.VerifyVector(bearings()) && + VerifyOffset(verifier, VT_CLASSES) && + verifier.VerifyVector(classes()) && + verifier.VerifyVectorOfStrings(classes()) && + VerifyOffset(verifier, VT_ENTRY) && + verifier.VerifyVector(entry()) && + VerifyField(verifier, VT_IN_BEARING) && + VerifyField(verifier, VT_OUT_BEARING) && + VerifyOffset(verifier, VT_LANES) && + verifier.VerifyVector(lanes()) && + verifier.VerifyVectorOfTables(lanes()) && + verifier.EndTable(); + } + IntersectionT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(IntersectionT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const IntersectionT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct IntersectionBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_location(const osrm::engine::api::fbresult::Position *location) { + fbb_.AddStruct(Intersection::VT_LOCATION, location); + } + void add_bearings(flatbuffers::Offset> bearings) { + fbb_.AddOffset(Intersection::VT_BEARINGS, bearings); + } + void add_classes(flatbuffers::Offset>> classes) { + fbb_.AddOffset(Intersection::VT_CLASSES, classes); + } + void add_entry(flatbuffers::Offset> entry) { + fbb_.AddOffset(Intersection::VT_ENTRY, entry); + } + void add_in_bearing(uint32_t in_bearing) { + fbb_.AddElement(Intersection::VT_IN_BEARING, in_bearing, 0); + } + void add_out_bearing(uint32_t out_bearing) { + fbb_.AddElement(Intersection::VT_OUT_BEARING, out_bearing, 0); + } + void add_lanes(flatbuffers::Offset>> lanes) { + fbb_.AddOffset(Intersection::VT_LANES, lanes); + } + explicit IntersectionBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + IntersectionBuilder &operator=(const IntersectionBuilder &); + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateIntersection( + flatbuffers::FlatBufferBuilder &_fbb, + const osrm::engine::api::fbresult::Position *location = 0, + flatbuffers::Offset> bearings = 0, + flatbuffers::Offset>> classes = 0, + flatbuffers::Offset> entry = 0, + uint32_t in_bearing = 0, + uint32_t out_bearing = 0, + flatbuffers::Offset>> lanes = 0) { + IntersectionBuilder builder_(_fbb); + builder_.add_lanes(lanes); + builder_.add_out_bearing(out_bearing); + builder_.add_in_bearing(in_bearing); + builder_.add_entry(entry); + builder_.add_classes(classes); + builder_.add_bearings(bearings); + builder_.add_location(location); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateIntersectionDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const osrm::engine::api::fbresult::Position *location = 0, + const std::vector *bearings = nullptr, + const std::vector> *classes = nullptr, + const std::vector *entry = nullptr, + uint32_t in_bearing = 0, + uint32_t out_bearing = 0, + const std::vector> *lanes = nullptr) { + auto bearings__ = bearings ? _fbb.CreateVector(*bearings) : 0; + auto classes__ = classes ? _fbb.CreateVector>(*classes) : 0; + auto entry__ = entry ? _fbb.CreateVector(*entry) : 0; + auto lanes__ = lanes ? _fbb.CreateVector>(*lanes) : 0; + return osrm::engine::api::fbresult::CreateIntersection( + _fbb, + location, + bearings__, + classes__, + entry__, + in_bearing, + out_bearing, + lanes__); +} + +flatbuffers::Offset CreateIntersection(flatbuffers::FlatBufferBuilder &_fbb, const IntersectionT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + +struct StepT : public flatbuffers::NativeTable { + typedef Step TableType; + float distance; + float duration; + std::string polyline; + std::vector coordinates; + float weight; + std::string name; + std::string ref; + std::string pronunciation; + std::string destinations; + std::string exits; + std::string mode; + std::unique_ptr maneuver; + std::vector> intersections; + std::string rotary_name; + std::string rotary_pronunciation; + bool driving_side; + StepT() + : distance(0.0f), + duration(0.0f), + weight(0.0f), + driving_side(false) { + } +}; + +struct Step FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef StepT NativeTableType; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_DISTANCE = 4, + VT_DURATION = 6, + VT_POLYLINE = 8, + VT_COORDINATES = 10, + VT_WEIGHT = 12, + VT_NAME = 14, + VT_REF = 16, + VT_PRONUNCIATION = 18, + VT_DESTINATIONS = 20, + VT_EXITS = 22, + VT_MODE = 24, + VT_MANEUVER = 26, + VT_INTERSECTIONS = 28, + VT_ROTARY_NAME = 30, + VT_ROTARY_PRONUNCIATION = 32, + VT_DRIVING_SIDE = 34 + }; + float distance() const { + return GetField(VT_DISTANCE, 0.0f); + } + float duration() const { + return GetField(VT_DURATION, 0.0f); + } + const flatbuffers::String *polyline() const { + return GetPointer(VT_POLYLINE); + } + const flatbuffers::Vector *coordinates() const { + return GetPointer *>(VT_COORDINATES); + } + float weight() const { + return GetField(VT_WEIGHT, 0.0f); + } + const flatbuffers::String *name() const { + return GetPointer(VT_NAME); + } + const flatbuffers::String *ref() const { + return GetPointer(VT_REF); + } + const flatbuffers::String *pronunciation() const { + return GetPointer(VT_PRONUNCIATION); + } + const flatbuffers::String *destinations() const { + return GetPointer(VT_DESTINATIONS); + } + const flatbuffers::String *exits() const { + return GetPointer(VT_EXITS); + } + const flatbuffers::String *mode() const { + return GetPointer(VT_MODE); + } + const osrm::engine::api::fbresult::StepManeuver *maneuver() const { + return GetPointer(VT_MANEUVER); + } + const flatbuffers::Vector> *intersections() const { + return GetPointer> *>(VT_INTERSECTIONS); + } + const flatbuffers::String *rotary_name() const { + return GetPointer(VT_ROTARY_NAME); + } + const flatbuffers::String *rotary_pronunciation() const { + return GetPointer(VT_ROTARY_PRONUNCIATION); + } + bool driving_side() const { + return GetField(VT_DRIVING_SIDE, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_DISTANCE) && + VerifyField(verifier, VT_DURATION) && + VerifyOffset(verifier, VT_POLYLINE) && + verifier.VerifyString(polyline()) && + VerifyOffset(verifier, VT_COORDINATES) && + verifier.VerifyVector(coordinates()) && + VerifyField(verifier, VT_WEIGHT) && + VerifyOffset(verifier, VT_NAME) && + verifier.VerifyString(name()) && + VerifyOffset(verifier, VT_REF) && + verifier.VerifyString(ref()) && + VerifyOffset(verifier, VT_PRONUNCIATION) && + verifier.VerifyString(pronunciation()) && + VerifyOffset(verifier, VT_DESTINATIONS) && + verifier.VerifyString(destinations()) && + VerifyOffset(verifier, VT_EXITS) && + verifier.VerifyString(exits()) && + VerifyOffset(verifier, VT_MODE) && + verifier.VerifyString(mode()) && + VerifyOffset(verifier, VT_MANEUVER) && + verifier.VerifyTable(maneuver()) && + VerifyOffset(verifier, VT_INTERSECTIONS) && + verifier.VerifyVector(intersections()) && + verifier.VerifyVectorOfTables(intersections()) && + VerifyOffset(verifier, VT_ROTARY_NAME) && + verifier.VerifyString(rotary_name()) && + VerifyOffset(verifier, VT_ROTARY_PRONUNCIATION) && + verifier.VerifyString(rotary_pronunciation()) && + VerifyField(verifier, VT_DRIVING_SIDE) && + verifier.EndTable(); + } + StepT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(StepT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const StepT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct StepBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_distance(float distance) { + fbb_.AddElement(Step::VT_DISTANCE, distance, 0.0f); + } + void add_duration(float duration) { + fbb_.AddElement(Step::VT_DURATION, duration, 0.0f); + } + void add_polyline(flatbuffers::Offset polyline) { + fbb_.AddOffset(Step::VT_POLYLINE, polyline); + } + void add_coordinates(flatbuffers::Offset> coordinates) { + fbb_.AddOffset(Step::VT_COORDINATES, coordinates); + } + void add_weight(float weight) { + fbb_.AddElement(Step::VT_WEIGHT, weight, 0.0f); + } + void add_name(flatbuffers::Offset name) { + fbb_.AddOffset(Step::VT_NAME, name); + } + void add_ref(flatbuffers::Offset ref) { + fbb_.AddOffset(Step::VT_REF, ref); + } + void add_pronunciation(flatbuffers::Offset pronunciation) { + fbb_.AddOffset(Step::VT_PRONUNCIATION, pronunciation); + } + void add_destinations(flatbuffers::Offset destinations) { + fbb_.AddOffset(Step::VT_DESTINATIONS, destinations); + } + void add_exits(flatbuffers::Offset exits) { + fbb_.AddOffset(Step::VT_EXITS, exits); + } + void add_mode(flatbuffers::Offset mode) { + fbb_.AddOffset(Step::VT_MODE, mode); + } + void add_maneuver(flatbuffers::Offset maneuver) { + fbb_.AddOffset(Step::VT_MANEUVER, maneuver); + } + void add_intersections(flatbuffers::Offset>> intersections) { + fbb_.AddOffset(Step::VT_INTERSECTIONS, intersections); + } + void add_rotary_name(flatbuffers::Offset rotary_name) { + fbb_.AddOffset(Step::VT_ROTARY_NAME, rotary_name); + } + void add_rotary_pronunciation(flatbuffers::Offset rotary_pronunciation) { + fbb_.AddOffset(Step::VT_ROTARY_PRONUNCIATION, rotary_pronunciation); + } + void add_driving_side(bool driving_side) { + fbb_.AddElement(Step::VT_DRIVING_SIDE, static_cast(driving_side), 0); + } + explicit StepBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + StepBuilder &operator=(const StepBuilder &); + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateStep( + flatbuffers::FlatBufferBuilder &_fbb, + float distance = 0.0f, + float duration = 0.0f, + flatbuffers::Offset polyline = 0, + flatbuffers::Offset> coordinates = 0, + float weight = 0.0f, + flatbuffers::Offset name = 0, + flatbuffers::Offset ref = 0, + flatbuffers::Offset pronunciation = 0, + flatbuffers::Offset destinations = 0, + flatbuffers::Offset exits = 0, + flatbuffers::Offset mode = 0, + flatbuffers::Offset maneuver = 0, + flatbuffers::Offset>> intersections = 0, + flatbuffers::Offset rotary_name = 0, + flatbuffers::Offset rotary_pronunciation = 0, + bool driving_side = false) { + StepBuilder builder_(_fbb); + builder_.add_rotary_pronunciation(rotary_pronunciation); + builder_.add_rotary_name(rotary_name); + builder_.add_intersections(intersections); + builder_.add_maneuver(maneuver); + builder_.add_mode(mode); + builder_.add_exits(exits); + builder_.add_destinations(destinations); + builder_.add_pronunciation(pronunciation); + builder_.add_ref(ref); + builder_.add_name(name); + builder_.add_weight(weight); + builder_.add_coordinates(coordinates); + builder_.add_polyline(polyline); + builder_.add_duration(duration); + builder_.add_distance(distance); + builder_.add_driving_side(driving_side); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateStepDirect( + flatbuffers::FlatBufferBuilder &_fbb, + float distance = 0.0f, + float duration = 0.0f, + const char *polyline = nullptr, + const std::vector *coordinates = nullptr, + float weight = 0.0f, + const char *name = nullptr, + const char *ref = nullptr, + const char *pronunciation = nullptr, + const char *destinations = nullptr, + const char *exits = nullptr, + const char *mode = nullptr, + flatbuffers::Offset maneuver = 0, + const std::vector> *intersections = nullptr, + const char *rotary_name = nullptr, + const char *rotary_pronunciation = nullptr, + bool driving_side = false) { + auto polyline__ = polyline ? _fbb.CreateString(polyline) : 0; + auto coordinates__ = coordinates ? _fbb.CreateVectorOfStructs(*coordinates) : 0; + auto name__ = name ? _fbb.CreateString(name) : 0; + auto ref__ = ref ? _fbb.CreateString(ref) : 0; + auto pronunciation__ = pronunciation ? _fbb.CreateString(pronunciation) : 0; + auto destinations__ = destinations ? _fbb.CreateString(destinations) : 0; + auto exits__ = exits ? _fbb.CreateString(exits) : 0; + auto mode__ = mode ? _fbb.CreateString(mode) : 0; + auto intersections__ = intersections ? _fbb.CreateVector>(*intersections) : 0; + auto rotary_name__ = rotary_name ? _fbb.CreateString(rotary_name) : 0; + auto rotary_pronunciation__ = rotary_pronunciation ? _fbb.CreateString(rotary_pronunciation) : 0; + return osrm::engine::api::fbresult::CreateStep( + _fbb, + distance, + duration, + polyline__, + coordinates__, + weight, + name__, + ref__, + pronunciation__, + destinations__, + exits__, + mode__, + maneuver, + intersections__, + rotary_name__, + rotary_pronunciation__, + driving_side); +} + +flatbuffers::Offset CreateStep(flatbuffers::FlatBufferBuilder &_fbb, const StepT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + +struct LegT : public flatbuffers::NativeTable { + typedef Leg TableType; + double distance; + double duration; + double weight; + std::string summary; + std::unique_ptr annotations; + std::vector> steps; + LegT() + : distance(0.0), + duration(0.0), + weight(0.0) { + } +}; + +struct Leg FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef LegT NativeTableType; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_DISTANCE = 4, + VT_DURATION = 6, + VT_WEIGHT = 8, + VT_SUMMARY = 10, + VT_ANNOTATIONS = 12, + VT_STEPS = 14 + }; + double distance() const { + return GetField(VT_DISTANCE, 0.0); + } + double duration() const { + return GetField(VT_DURATION, 0.0); + } + double weight() const { + return GetField(VT_WEIGHT, 0.0); + } + const flatbuffers::String *summary() const { + return GetPointer(VT_SUMMARY); + } + const osrm::engine::api::fbresult::Annotation *annotations() const { + return GetPointer(VT_ANNOTATIONS); + } + const flatbuffers::Vector> *steps() const { + return GetPointer> *>(VT_STEPS); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_DISTANCE) && + VerifyField(verifier, VT_DURATION) && + VerifyField(verifier, VT_WEIGHT) && + VerifyOffset(verifier, VT_SUMMARY) && + verifier.VerifyString(summary()) && + VerifyOffset(verifier, VT_ANNOTATIONS) && + verifier.VerifyTable(annotations()) && + VerifyOffset(verifier, VT_STEPS) && + verifier.VerifyVector(steps()) && + verifier.VerifyVectorOfTables(steps()) && + verifier.EndTable(); + } + LegT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(LegT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const LegT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct LegBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_distance(double distance) { + fbb_.AddElement(Leg::VT_DISTANCE, distance, 0.0); + } + void add_duration(double duration) { + fbb_.AddElement(Leg::VT_DURATION, duration, 0.0); + } + void add_weight(double weight) { + fbb_.AddElement(Leg::VT_WEIGHT, weight, 0.0); + } + void add_summary(flatbuffers::Offset summary) { + fbb_.AddOffset(Leg::VT_SUMMARY, summary); + } + void add_annotations(flatbuffers::Offset annotations) { + fbb_.AddOffset(Leg::VT_ANNOTATIONS, annotations); + } + void add_steps(flatbuffers::Offset>> steps) { + fbb_.AddOffset(Leg::VT_STEPS, steps); + } + explicit LegBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + LegBuilder &operator=(const LegBuilder &); + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateLeg( + flatbuffers::FlatBufferBuilder &_fbb, + double distance = 0.0, + double duration = 0.0, + double weight = 0.0, + flatbuffers::Offset summary = 0, + flatbuffers::Offset annotations = 0, + flatbuffers::Offset>> steps = 0) { + LegBuilder builder_(_fbb); + builder_.add_weight(weight); + builder_.add_duration(duration); + builder_.add_distance(distance); + builder_.add_steps(steps); + builder_.add_annotations(annotations); + builder_.add_summary(summary); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateLegDirect( + flatbuffers::FlatBufferBuilder &_fbb, + double distance = 0.0, + double duration = 0.0, + double weight = 0.0, + const char *summary = nullptr, + flatbuffers::Offset annotations = 0, + const std::vector> *steps = nullptr) { + auto summary__ = summary ? _fbb.CreateString(summary) : 0; + auto steps__ = steps ? _fbb.CreateVector>(*steps) : 0; + return osrm::engine::api::fbresult::CreateLeg( + _fbb, + distance, + duration, + weight, + summary__, + annotations, + steps__); +} + +flatbuffers::Offset CreateLeg(flatbuffers::FlatBufferBuilder &_fbb, const LegT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + +struct RouteObjectT : public flatbuffers::NativeTable { + typedef RouteObject TableType; + float distance; + float duration; + float weight; + std::string weight_name; + float confidence; + std::string polyline; + std::vector coordinates; + std::vector> legs; + RouteObjectT() + : distance(0.0f), + duration(0.0f), + weight(0.0f), + confidence(0.0f) { + } +}; + +struct RouteObject FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef RouteObjectT NativeTableType; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_DISTANCE = 4, + VT_DURATION = 6, + VT_WEIGHT = 8, + VT_WEIGHT_NAME = 10, + VT_CONFIDENCE = 12, + VT_POLYLINE = 14, + VT_COORDINATES = 16, + VT_LEGS = 18 + }; + float distance() const { + return GetField(VT_DISTANCE, 0.0f); + } + float duration() const { + return GetField(VT_DURATION, 0.0f); + } + float weight() const { + return GetField(VT_WEIGHT, 0.0f); + } + const flatbuffers::String *weight_name() const { + return GetPointer(VT_WEIGHT_NAME); + } + float confidence() const { + return GetField(VT_CONFIDENCE, 0.0f); + } + const flatbuffers::String *polyline() const { + return GetPointer(VT_POLYLINE); + } + const flatbuffers::Vector *coordinates() const { + return GetPointer *>(VT_COORDINATES); + } + const flatbuffers::Vector> *legs() const { + return GetPointer> *>(VT_LEGS); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_DISTANCE) && + VerifyField(verifier, VT_DURATION) && + VerifyField(verifier, VT_WEIGHT) && + VerifyOffset(verifier, VT_WEIGHT_NAME) && + verifier.VerifyString(weight_name()) && + VerifyField(verifier, VT_CONFIDENCE) && + VerifyOffset(verifier, VT_POLYLINE) && + verifier.VerifyString(polyline()) && + VerifyOffset(verifier, VT_COORDINATES) && + verifier.VerifyVector(coordinates()) && + VerifyOffset(verifier, VT_LEGS) && + verifier.VerifyVector(legs()) && + verifier.VerifyVectorOfTables(legs()) && + verifier.EndTable(); + } + RouteObjectT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(RouteObjectT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const RouteObjectT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct RouteObjectBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_distance(float distance) { + fbb_.AddElement(RouteObject::VT_DISTANCE, distance, 0.0f); + } + void add_duration(float duration) { + fbb_.AddElement(RouteObject::VT_DURATION, duration, 0.0f); + } + void add_weight(float weight) { + fbb_.AddElement(RouteObject::VT_WEIGHT, weight, 0.0f); + } + void add_weight_name(flatbuffers::Offset weight_name) { + fbb_.AddOffset(RouteObject::VT_WEIGHT_NAME, weight_name); + } + void add_confidence(float confidence) { + fbb_.AddElement(RouteObject::VT_CONFIDENCE, confidence, 0.0f); + } + void add_polyline(flatbuffers::Offset polyline) { + fbb_.AddOffset(RouteObject::VT_POLYLINE, polyline); + } + void add_coordinates(flatbuffers::Offset> coordinates) { + fbb_.AddOffset(RouteObject::VT_COORDINATES, coordinates); + } + void add_legs(flatbuffers::Offset>> legs) { + fbb_.AddOffset(RouteObject::VT_LEGS, legs); + } + explicit RouteObjectBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + RouteObjectBuilder &operator=(const RouteObjectBuilder &); + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateRouteObject( + flatbuffers::FlatBufferBuilder &_fbb, + float distance = 0.0f, + float duration = 0.0f, + float weight = 0.0f, + flatbuffers::Offset weight_name = 0, + float confidence = 0.0f, + flatbuffers::Offset polyline = 0, + flatbuffers::Offset> coordinates = 0, + flatbuffers::Offset>> legs = 0) { + RouteObjectBuilder builder_(_fbb); + builder_.add_legs(legs); + builder_.add_coordinates(coordinates); + builder_.add_polyline(polyline); + builder_.add_confidence(confidence); + builder_.add_weight_name(weight_name); + builder_.add_weight(weight); + builder_.add_duration(duration); + builder_.add_distance(distance); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateRouteObjectDirect( + flatbuffers::FlatBufferBuilder &_fbb, + float distance = 0.0f, + float duration = 0.0f, + float weight = 0.0f, + const char *weight_name = nullptr, + float confidence = 0.0f, + const char *polyline = nullptr, + const std::vector *coordinates = nullptr, + const std::vector> *legs = nullptr) { + auto weight_name__ = weight_name ? _fbb.CreateString(weight_name) : 0; + auto polyline__ = polyline ? _fbb.CreateString(polyline) : 0; + auto coordinates__ = coordinates ? _fbb.CreateVectorOfStructs(*coordinates) : 0; + auto legs__ = legs ? _fbb.CreateVector>(*legs) : 0; + return osrm::engine::api::fbresult::CreateRouteObject( + _fbb, + distance, + duration, + weight, + weight_name__, + confidence, + polyline__, + coordinates__, + legs__); +} + +flatbuffers::Offset CreateRouteObject(flatbuffers::FlatBufferBuilder &_fbb, const RouteObjectT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + +struct TableT : public flatbuffers::NativeTable { + typedef Table TableType; + std::vector durations; + uint16_t rows; + uint16_t cols; + std::vector distances; + std::vector> destinations; + std::vector fallback_speed_cells; + TableT() + : rows(0), + cols(0) { + } +}; + +struct Table FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef TableT NativeTableType; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_DURATIONS = 4, + VT_ROWS = 6, + VT_COLS = 8, + VT_DISTANCES = 10, + VT_DESTINATIONS = 12, + VT_FALLBACK_SPEED_CELLS = 14 + }; + const flatbuffers::Vector *durations() const { + return GetPointer *>(VT_DURATIONS); + } + uint16_t rows() const { + return GetField(VT_ROWS, 0); + } + uint16_t cols() const { + return GetField(VT_COLS, 0); + } + const flatbuffers::Vector *distances() const { + return GetPointer *>(VT_DISTANCES); + } + const flatbuffers::Vector> *destinations() const { + return GetPointer> *>(VT_DESTINATIONS); + } + const flatbuffers::Vector *fallback_speed_cells() const { + return GetPointer *>(VT_FALLBACK_SPEED_CELLS); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_DURATIONS) && + verifier.VerifyVector(durations()) && + VerifyField(verifier, VT_ROWS) && + VerifyField(verifier, VT_COLS) && + VerifyOffset(verifier, VT_DISTANCES) && + verifier.VerifyVector(distances()) && + VerifyOffset(verifier, VT_DESTINATIONS) && + verifier.VerifyVector(destinations()) && + verifier.VerifyVectorOfTables(destinations()) && + VerifyOffset(verifier, VT_FALLBACK_SPEED_CELLS) && + verifier.VerifyVector(fallback_speed_cells()) && + verifier.EndTable(); + } + TableT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(TableT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const TableT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct TableBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_durations(flatbuffers::Offset> durations) { + fbb_.AddOffset(Table::VT_DURATIONS, durations); + } + void add_rows(uint16_t rows) { + fbb_.AddElement(Table::VT_ROWS, rows, 0); + } + void add_cols(uint16_t cols) { + fbb_.AddElement(Table::VT_COLS, cols, 0); + } + void add_distances(flatbuffers::Offset> distances) { + fbb_.AddOffset(Table::VT_DISTANCES, distances); + } + void add_destinations(flatbuffers::Offset>> destinations) { + fbb_.AddOffset(Table::VT_DESTINATIONS, destinations); + } + void add_fallback_speed_cells(flatbuffers::Offset> fallback_speed_cells) { + fbb_.AddOffset(Table::VT_FALLBACK_SPEED_CELLS, fallback_speed_cells); + } + explicit TableBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + TableBuilder &operator=(const TableBuilder &); + flatbuffers::Offset
Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset
(end); + return o; + } +}; + +inline flatbuffers::Offset
CreateTable( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset> durations = 0, + uint16_t rows = 0, + uint16_t cols = 0, + flatbuffers::Offset> distances = 0, + flatbuffers::Offset>> destinations = 0, + flatbuffers::Offset> fallback_speed_cells = 0) { + TableBuilder builder_(_fbb); + builder_.add_fallback_speed_cells(fallback_speed_cells); + builder_.add_destinations(destinations); + builder_.add_distances(distances); + builder_.add_durations(durations); + builder_.add_cols(cols); + builder_.add_rows(rows); + return builder_.Finish(); +} + +inline flatbuffers::Offset
CreateTableDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const std::vector *durations = nullptr, + uint16_t rows = 0, + uint16_t cols = 0, + const std::vector *distances = nullptr, + const std::vector> *destinations = nullptr, + const std::vector *fallback_speed_cells = nullptr) { + auto durations__ = durations ? _fbb.CreateVector(*durations) : 0; + auto distances__ = distances ? _fbb.CreateVector(*distances) : 0; + auto destinations__ = destinations ? _fbb.CreateVector>(*destinations) : 0; + auto fallback_speed_cells__ = fallback_speed_cells ? _fbb.CreateVector(*fallback_speed_cells) : 0; + return osrm::engine::api::fbresult::CreateTable( + _fbb, + durations__, + rows, + cols, + distances__, + destinations__, + fallback_speed_cells__); +} + +flatbuffers::Offset
CreateTable(flatbuffers::FlatBufferBuilder &_fbb, const TableT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + +struct ErrorT : public flatbuffers::NativeTable { + typedef Error TableType; + std::string code; + std::string message; + ErrorT() { + } +}; + +struct Error FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ErrorT NativeTableType; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_CODE = 4, + VT_MESSAGE = 6 + }; + const flatbuffers::String *code() const { + return GetPointer(VT_CODE); + } + const flatbuffers::String *message() const { + return GetPointer(VT_MESSAGE); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_CODE) && + verifier.VerifyString(code()) && + VerifyOffset(verifier, VT_MESSAGE) && + verifier.VerifyString(message()) && + verifier.EndTable(); + } + ErrorT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(ErrorT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const ErrorT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct ErrorBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_code(flatbuffers::Offset code) { + fbb_.AddOffset(Error::VT_CODE, code); + } + void add_message(flatbuffers::Offset message) { + fbb_.AddOffset(Error::VT_MESSAGE, message); + } + explicit ErrorBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ErrorBuilder &operator=(const ErrorBuilder &); + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateError( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset code = 0, + flatbuffers::Offset message = 0) { + ErrorBuilder builder_(_fbb); + builder_.add_message(message); + builder_.add_code(code); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateErrorDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *code = nullptr, + const char *message = nullptr) { + auto code__ = code ? _fbb.CreateString(code) : 0; + auto message__ = message ? _fbb.CreateString(message) : 0; + return osrm::engine::api::fbresult::CreateError( + _fbb, + code__, + message__); +} + +flatbuffers::Offset CreateError(flatbuffers::FlatBufferBuilder &_fbb, const ErrorT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + +struct FBResultT : public flatbuffers::NativeTable { + typedef FBResult TableType; + bool error; + std::unique_ptr code; + std::string data_version; + std::vector> waypoints; + std::vector> routes; + std::unique_ptr table; + FBResultT() + : error(false) { + } +}; + +struct FBResult FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef FBResultT NativeTableType; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_ERROR = 4, + VT_CODE = 6, + VT_DATA_VERSION = 8, + VT_WAYPOINTS = 10, + VT_ROUTES = 12, + VT_TABLE = 14 + }; + bool error() const { + return GetField(VT_ERROR, 0) != 0; + } + const osrm::engine::api::fbresult::Error *code() const { + return GetPointer(VT_CODE); + } + const flatbuffers::String *data_version() const { + return GetPointer(VT_DATA_VERSION); + } + const flatbuffers::Vector> *waypoints() const { + return GetPointer> *>(VT_WAYPOINTS); + } + const flatbuffers::Vector> *routes() const { + return GetPointer> *>(VT_ROUTES); + } + const osrm::engine::api::fbresult::Table *table() const { + return GetPointer(VT_TABLE); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_ERROR) && + VerifyOffset(verifier, VT_CODE) && + verifier.VerifyTable(code()) && + VerifyOffset(verifier, VT_DATA_VERSION) && + verifier.VerifyString(data_version()) && + VerifyOffset(verifier, VT_WAYPOINTS) && + verifier.VerifyVector(waypoints()) && + verifier.VerifyVectorOfTables(waypoints()) && + VerifyOffset(verifier, VT_ROUTES) && + verifier.VerifyVector(routes()) && + verifier.VerifyVectorOfTables(routes()) && + VerifyOffset(verifier, VT_TABLE) && + verifier.VerifyTable(table()) && + verifier.EndTable(); + } + FBResultT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(FBResultT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const FBResultT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct FBResultBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_error(bool error) { + fbb_.AddElement(FBResult::VT_ERROR, static_cast(error), 0); + } + void add_code(flatbuffers::Offset code) { + fbb_.AddOffset(FBResult::VT_CODE, code); + } + void add_data_version(flatbuffers::Offset data_version) { + fbb_.AddOffset(FBResult::VT_DATA_VERSION, data_version); + } + void add_waypoints(flatbuffers::Offset>> waypoints) { + fbb_.AddOffset(FBResult::VT_WAYPOINTS, waypoints); + } + void add_routes(flatbuffers::Offset>> routes) { + fbb_.AddOffset(FBResult::VT_ROUTES, routes); + } + void add_table(flatbuffers::Offset table) { + fbb_.AddOffset(FBResult::VT_TABLE, table); + } + explicit FBResultBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + FBResultBuilder &operator=(const FBResultBuilder &); + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateFBResult( + flatbuffers::FlatBufferBuilder &_fbb, + bool error = false, + flatbuffers::Offset code = 0, + flatbuffers::Offset data_version = 0, + flatbuffers::Offset>> waypoints = 0, + flatbuffers::Offset>> routes = 0, + flatbuffers::Offset table = 0) { + FBResultBuilder builder_(_fbb); + builder_.add_table(table); + builder_.add_routes(routes); + builder_.add_waypoints(waypoints); + builder_.add_data_version(data_version); + builder_.add_code(code); + builder_.add_error(error); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateFBResultDirect( + flatbuffers::FlatBufferBuilder &_fbb, + bool error = false, + flatbuffers::Offset code = 0, + const char *data_version = nullptr, + const std::vector> *waypoints = nullptr, + const std::vector> *routes = nullptr, + flatbuffers::Offset table = 0) { + auto data_version__ = data_version ? _fbb.CreateString(data_version) : 0; + auto waypoints__ = waypoints ? _fbb.CreateVector>(*waypoints) : 0; + auto routes__ = routes ? _fbb.CreateVector>(*routes) : 0; + return osrm::engine::api::fbresult::CreateFBResult( + _fbb, + error, + code, + data_version__, + waypoints__, + routes__, + table); +} + +flatbuffers::Offset CreateFBResult(flatbuffers::FlatBufferBuilder &_fbb, const FBResultT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + +inline WaypointT *Waypoint::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = new WaypointT(); + UnPackTo(_o, _resolver); + return _o; +} + +inline void Waypoint::UnPackTo(WaypointT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = hint(); if (_e) _o->hint = _e->str(); }; + { auto _e = distance(); _o->distance = _e; }; + { auto _e = name(); if (_e) _o->name = _e->str(); }; + { auto _e = location(); if (_e) _o->location = std::unique_ptr(new osrm::engine::api::fbresult::Position(*_e)); }; + { auto _e = nodes(); if (_e) _o->nodes = std::unique_ptr(new osrm::engine::api::fbresult::Uint64Pair(*_e)); }; + { auto _e = matchings_index(); _o->matchings_index = _e; }; + { auto _e = waypoint_index(); _o->waypoint_index = _e; }; + { auto _e = alternatives_count(); _o->alternatives_count = _e; }; + { auto _e = trips_index(); _o->trips_index = _e; }; +} + +inline flatbuffers::Offset Waypoint::Pack(flatbuffers::FlatBufferBuilder &_fbb, const WaypointT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateWaypoint(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateWaypoint(flatbuffers::FlatBufferBuilder &_fbb, const WaypointT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const WaypointT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _hint = _o->hint.empty() ? 0 : _fbb.CreateString(_o->hint); + auto _distance = _o->distance; + auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name); + auto _location = _o->location ? _o->location.get() : 0; + auto _nodes = _o->nodes ? _o->nodes.get() : 0; + auto _matchings_index = _o->matchings_index; + auto _waypoint_index = _o->waypoint_index; + auto _alternatives_count = _o->alternatives_count; + auto _trips_index = _o->trips_index; + return osrm::engine::api::fbresult::CreateWaypoint( + _fbb, + _hint, + _distance, + _name, + _location, + _nodes, + _matchings_index, + _waypoint_index, + _alternatives_count, + _trips_index); +} + +inline MetadataT *Metadata::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = new MetadataT(); + UnPackTo(_o, _resolver); + return _o; +} + +inline void Metadata::UnPackTo(MetadataT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = datasource_names(); if (_e) { _o->datasource_names.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->datasource_names[_i] = _e->Get(_i)->str(); } } }; +} + +inline flatbuffers::Offset Metadata::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MetadataT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateMetadata(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateMetadata(flatbuffers::FlatBufferBuilder &_fbb, const MetadataT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MetadataT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _datasource_names = _o->datasource_names.size() ? _fbb.CreateVectorOfStrings(_o->datasource_names) : 0; + return osrm::engine::api::fbresult::CreateMetadata( + _fbb, + _datasource_names); +} + +inline AnnotationT *Annotation::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = new AnnotationT(); + UnPackTo(_o, _resolver); + return _o; +} + +inline void Annotation::UnPackTo(AnnotationT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = distance(); if (_e) { _o->distance.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->distance[_i] = _e->Get(_i); } } }; + { auto _e = duration(); if (_e) { _o->duration.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->duration[_i] = _e->Get(_i); } } }; + { auto _e = datasources(); if (_e) { _o->datasources.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->datasources[_i] = _e->Get(_i); } } }; + { auto _e = nodes(); if (_e) { _o->nodes.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->nodes[_i] = _e->Get(_i); } } }; + { auto _e = weight(); if (_e) { _o->weight.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->weight[_i] = _e->Get(_i); } } }; + { auto _e = speed(); if (_e) { _o->speed.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->speed[_i] = _e->Get(_i); } } }; + { auto _e = metadata(); if (_e) _o->metadata = std::unique_ptr(_e->UnPack(_resolver)); }; +} + +inline flatbuffers::Offset Annotation::Pack(flatbuffers::FlatBufferBuilder &_fbb, const AnnotationT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateAnnotation(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateAnnotation(flatbuffers::FlatBufferBuilder &_fbb, const AnnotationT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const AnnotationT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _distance = _o->distance.size() ? _fbb.CreateVector(_o->distance) : 0; + auto _duration = _o->duration.size() ? _fbb.CreateVector(_o->duration) : 0; + auto _datasources = _o->datasources.size() ? _fbb.CreateVector(_o->datasources) : 0; + auto _nodes = _o->nodes.size() ? _fbb.CreateVector(_o->nodes) : 0; + auto _weight = _o->weight.size() ? _fbb.CreateVector(_o->weight) : 0; + auto _speed = _o->speed.size() ? _fbb.CreateVector(_o->speed) : 0; + auto _metadata = _o->metadata ? CreateMetadata(_fbb, _o->metadata.get(), _rehasher) : 0; + return osrm::engine::api::fbresult::CreateAnnotation( + _fbb, + _distance, + _duration, + _datasources, + _nodes, + _weight, + _speed, + _metadata); +} + +inline StepManeuverT *StepManeuver::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = new StepManeuverT(); + UnPackTo(_o, _resolver); + return _o; +} + +inline void StepManeuver::UnPackTo(StepManeuverT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = location(); if (_e) _o->location = std::unique_ptr(new osrm::engine::api::fbresult::Position(*_e)); }; + { auto _e = bearing_before(); _o->bearing_before = _e; }; + { auto _e = bearing_after(); _o->bearing_after = _e; }; + { auto _e = type(); _o->type = _e; }; + { auto _e = modifier(); _o->modifier = _e; }; + { auto _e = exit(); _o->exit = _e; }; +} + +inline flatbuffers::Offset StepManeuver::Pack(flatbuffers::FlatBufferBuilder &_fbb, const StepManeuverT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateStepManeuver(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateStepManeuver(flatbuffers::FlatBufferBuilder &_fbb, const StepManeuverT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const StepManeuverT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _location = _o->location ? _o->location.get() : 0; + auto _bearing_before = _o->bearing_before; + auto _bearing_after = _o->bearing_after; + auto _type = _o->type; + auto _modifier = _o->modifier; + auto _exit = _o->exit; + return osrm::engine::api::fbresult::CreateStepManeuver( + _fbb, + _location, + _bearing_before, + _bearing_after, + _type, + _modifier, + _exit); +} + +inline LaneT *Lane::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = new LaneT(); + UnPackTo(_o, _resolver); + return _o; +} + +inline void Lane::UnPackTo(LaneT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = indications(); if (_e) { _o->indications.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->indications[_i] = static_cast(_e->Get(_i)); } } }; + { auto _e = valid(); _o->valid = _e; }; +} + +inline flatbuffers::Offset Lane::Pack(flatbuffers::FlatBufferBuilder &_fbb, const LaneT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateLane(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateLane(flatbuffers::FlatBufferBuilder &_fbb, const LaneT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const LaneT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _indications = _o->indications.size() ? _fbb.CreateVectorScalarCast(flatbuffers::data(_o->indications), _o->indications.size()) : 0; + auto _valid = _o->valid; + return osrm::engine::api::fbresult::CreateLane( + _fbb, + _indications, + _valid); +} + +inline IntersectionT *Intersection::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = new IntersectionT(); + UnPackTo(_o, _resolver); + return _o; +} + +inline void Intersection::UnPackTo(IntersectionT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = location(); if (_e) _o->location = std::unique_ptr(new osrm::engine::api::fbresult::Position(*_e)); }; + { auto _e = bearings(); if (_e) { _o->bearings.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->bearings[_i] = _e->Get(_i); } } }; + { auto _e = classes(); if (_e) { _o->classes.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->classes[_i] = _e->Get(_i)->str(); } } }; + { auto _e = entry(); if (_e) { _o->entry.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->entry[_i] = _e->Get(_i) != 0; } } }; + { auto _e = in_bearing(); _o->in_bearing = _e; }; + { auto _e = out_bearing(); _o->out_bearing = _e; }; + { auto _e = lanes(); if (_e) { _o->lanes.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->lanes[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } }; +} + +inline flatbuffers::Offset Intersection::Pack(flatbuffers::FlatBufferBuilder &_fbb, const IntersectionT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateIntersection(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateIntersection(flatbuffers::FlatBufferBuilder &_fbb, const IntersectionT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const IntersectionT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _location = _o->location ? _o->location.get() : 0; + auto _bearings = _o->bearings.size() ? _fbb.CreateVector(_o->bearings) : 0; + auto _classes = _o->classes.size() ? _fbb.CreateVectorOfStrings(_o->classes) : 0; + auto _entry = _o->entry.size() ? _fbb.CreateVector(_o->entry) : 0; + auto _in_bearing = _o->in_bearing; + auto _out_bearing = _o->out_bearing; + auto _lanes = _o->lanes.size() ? _fbb.CreateVector> (_o->lanes.size(), [](size_t i, _VectorArgs *__va) { return CreateLane(*__va->__fbb, __va->__o->lanes[i].get(), __va->__rehasher); }, &_va ) : 0; + return osrm::engine::api::fbresult::CreateIntersection( + _fbb, + _location, + _bearings, + _classes, + _entry, + _in_bearing, + _out_bearing, + _lanes); +} + +inline StepT *Step::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = new StepT(); + UnPackTo(_o, _resolver); + return _o; +} + +inline void Step::UnPackTo(StepT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = distance(); _o->distance = _e; }; + { auto _e = duration(); _o->duration = _e; }; + { auto _e = polyline(); if (_e) _o->polyline = _e->str(); }; + { auto _e = coordinates(); if (_e) { _o->coordinates.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->coordinates[_i] = *_e->Get(_i); } } }; + { auto _e = weight(); _o->weight = _e; }; + { auto _e = name(); if (_e) _o->name = _e->str(); }; + { auto _e = ref(); if (_e) _o->ref = _e->str(); }; + { auto _e = pronunciation(); if (_e) _o->pronunciation = _e->str(); }; + { auto _e = destinations(); if (_e) _o->destinations = _e->str(); }; + { auto _e = exits(); if (_e) _o->exits = _e->str(); }; + { auto _e = mode(); if (_e) _o->mode = _e->str(); }; + { auto _e = maneuver(); if (_e) _o->maneuver = std::unique_ptr(_e->UnPack(_resolver)); }; + { auto _e = intersections(); if (_e) { _o->intersections.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->intersections[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } }; + { auto _e = rotary_name(); if (_e) _o->rotary_name = _e->str(); }; + { auto _e = rotary_pronunciation(); if (_e) _o->rotary_pronunciation = _e->str(); }; + { auto _e = driving_side(); _o->driving_side = _e; }; +} + +inline flatbuffers::Offset Step::Pack(flatbuffers::FlatBufferBuilder &_fbb, const StepT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateStep(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateStep(flatbuffers::FlatBufferBuilder &_fbb, const StepT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const StepT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _distance = _o->distance; + auto _duration = _o->duration; + auto _polyline = _o->polyline.empty() ? 0 : _fbb.CreateString(_o->polyline); + auto _coordinates = _o->coordinates.size() ? _fbb.CreateVectorOfStructs(_o->coordinates) : 0; + auto _weight = _o->weight; + auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name); + auto _ref = _o->ref.empty() ? 0 : _fbb.CreateString(_o->ref); + auto _pronunciation = _o->pronunciation.empty() ? 0 : _fbb.CreateString(_o->pronunciation); + auto _destinations = _o->destinations.empty() ? 0 : _fbb.CreateString(_o->destinations); + auto _exits = _o->exits.empty() ? 0 : _fbb.CreateString(_o->exits); + auto _mode = _o->mode.empty() ? 0 : _fbb.CreateString(_o->mode); + auto _maneuver = _o->maneuver ? CreateStepManeuver(_fbb, _o->maneuver.get(), _rehasher) : 0; + auto _intersections = _o->intersections.size() ? _fbb.CreateVector> (_o->intersections.size(), [](size_t i, _VectorArgs *__va) { return CreateIntersection(*__va->__fbb, __va->__o->intersections[i].get(), __va->__rehasher); }, &_va ) : 0; + auto _rotary_name = _o->rotary_name.empty() ? 0 : _fbb.CreateString(_o->rotary_name); + auto _rotary_pronunciation = _o->rotary_pronunciation.empty() ? 0 : _fbb.CreateString(_o->rotary_pronunciation); + auto _driving_side = _o->driving_side; + return osrm::engine::api::fbresult::CreateStep( + _fbb, + _distance, + _duration, + _polyline, + _coordinates, + _weight, + _name, + _ref, + _pronunciation, + _destinations, + _exits, + _mode, + _maneuver, + _intersections, + _rotary_name, + _rotary_pronunciation, + _driving_side); +} + +inline LegT *Leg::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = new LegT(); + UnPackTo(_o, _resolver); + return _o; +} + +inline void Leg::UnPackTo(LegT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = distance(); _o->distance = _e; }; + { auto _e = duration(); _o->duration = _e; }; + { auto _e = weight(); _o->weight = _e; }; + { auto _e = summary(); if (_e) _o->summary = _e->str(); }; + { auto _e = annotations(); if (_e) _o->annotations = std::unique_ptr(_e->UnPack(_resolver)); }; + { auto _e = steps(); if (_e) { _o->steps.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->steps[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } }; +} + +inline flatbuffers::Offset Leg::Pack(flatbuffers::FlatBufferBuilder &_fbb, const LegT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateLeg(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateLeg(flatbuffers::FlatBufferBuilder &_fbb, const LegT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const LegT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _distance = _o->distance; + auto _duration = _o->duration; + auto _weight = _o->weight; + auto _summary = _o->summary.empty() ? 0 : _fbb.CreateString(_o->summary); + auto _annotations = _o->annotations ? CreateAnnotation(_fbb, _o->annotations.get(), _rehasher) : 0; + auto _steps = _o->steps.size() ? _fbb.CreateVector> (_o->steps.size(), [](size_t i, _VectorArgs *__va) { return CreateStep(*__va->__fbb, __va->__o->steps[i].get(), __va->__rehasher); }, &_va ) : 0; + return osrm::engine::api::fbresult::CreateLeg( + _fbb, + _distance, + _duration, + _weight, + _summary, + _annotations, + _steps); +} + +inline RouteObjectT *RouteObject::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = new RouteObjectT(); + UnPackTo(_o, _resolver); + return _o; +} + +inline void RouteObject::UnPackTo(RouteObjectT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = distance(); _o->distance = _e; }; + { auto _e = duration(); _o->duration = _e; }; + { auto _e = weight(); _o->weight = _e; }; + { auto _e = weight_name(); if (_e) _o->weight_name = _e->str(); }; + { auto _e = confidence(); _o->confidence = _e; }; + { auto _e = polyline(); if (_e) _o->polyline = _e->str(); }; + { auto _e = coordinates(); if (_e) { _o->coordinates.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->coordinates[_i] = *_e->Get(_i); } } }; + { auto _e = legs(); if (_e) { _o->legs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->legs[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } }; +} + +inline flatbuffers::Offset RouteObject::Pack(flatbuffers::FlatBufferBuilder &_fbb, const RouteObjectT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateRouteObject(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateRouteObject(flatbuffers::FlatBufferBuilder &_fbb, const RouteObjectT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const RouteObjectT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _distance = _o->distance; + auto _duration = _o->duration; + auto _weight = _o->weight; + auto _weight_name = _o->weight_name.empty() ? 0 : _fbb.CreateString(_o->weight_name); + auto _confidence = _o->confidence; + auto _polyline = _o->polyline.empty() ? 0 : _fbb.CreateString(_o->polyline); + auto _coordinates = _o->coordinates.size() ? _fbb.CreateVectorOfStructs(_o->coordinates) : 0; + auto _legs = _o->legs.size() ? _fbb.CreateVector> (_o->legs.size(), [](size_t i, _VectorArgs *__va) { return CreateLeg(*__va->__fbb, __va->__o->legs[i].get(), __va->__rehasher); }, &_va ) : 0; + return osrm::engine::api::fbresult::CreateRouteObject( + _fbb, + _distance, + _duration, + _weight, + _weight_name, + _confidence, + _polyline, + _coordinates, + _legs); +} + +inline TableT *Table::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = new TableT(); + UnPackTo(_o, _resolver); + return _o; +} + +inline void Table::UnPackTo(TableT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = durations(); if (_e) { _o->durations.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->durations[_i] = _e->Get(_i); } } }; + { auto _e = rows(); _o->rows = _e; }; + { auto _e = cols(); _o->cols = _e; }; + { auto _e = distances(); if (_e) { _o->distances.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->distances[_i] = _e->Get(_i); } } }; + { auto _e = destinations(); if (_e) { _o->destinations.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->destinations[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } }; + { auto _e = fallback_speed_cells(); if (_e) { _o->fallback_speed_cells.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->fallback_speed_cells[_i] = _e->Get(_i); } } }; +} + +inline flatbuffers::Offset
Table::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TableT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateTable(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset
CreateTable(flatbuffers::FlatBufferBuilder &_fbb, const TableT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TableT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _durations = _o->durations.size() ? _fbb.CreateVector(_o->durations) : 0; + auto _rows = _o->rows; + auto _cols = _o->cols; + auto _distances = _o->distances.size() ? _fbb.CreateVector(_o->distances) : 0; + auto _destinations = _o->destinations.size() ? _fbb.CreateVector> (_o->destinations.size(), [](size_t i, _VectorArgs *__va) { return CreateWaypoint(*__va->__fbb, __va->__o->destinations[i].get(), __va->__rehasher); }, &_va ) : 0; + auto _fallback_speed_cells = _o->fallback_speed_cells.size() ? _fbb.CreateVector(_o->fallback_speed_cells) : 0; + return osrm::engine::api::fbresult::CreateTable( + _fbb, + _durations, + _rows, + _cols, + _distances, + _destinations, + _fallback_speed_cells); +} + +inline ErrorT *Error::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = new ErrorT(); + UnPackTo(_o, _resolver); + return _o; +} + +inline void Error::UnPackTo(ErrorT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = code(); if (_e) _o->code = _e->str(); }; + { auto _e = message(); if (_e) _o->message = _e->str(); }; +} + +inline flatbuffers::Offset Error::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ErrorT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateError(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateError(flatbuffers::FlatBufferBuilder &_fbb, const ErrorT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ErrorT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _code = _o->code.empty() ? 0 : _fbb.CreateString(_o->code); + auto _message = _o->message.empty() ? 0 : _fbb.CreateString(_o->message); + return osrm::engine::api::fbresult::CreateError( + _fbb, + _code, + _message); +} + +inline FBResultT *FBResult::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = new FBResultT(); + UnPackTo(_o, _resolver); + return _o; +} + +inline void FBResult::UnPackTo(FBResultT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = error(); _o->error = _e; }; + { auto _e = code(); if (_e) _o->code = std::unique_ptr(_e->UnPack(_resolver)); }; + { auto _e = data_version(); if (_e) _o->data_version = _e->str(); }; + { auto _e = waypoints(); if (_e) { _o->waypoints.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->waypoints[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } }; + { auto _e = routes(); if (_e) { _o->routes.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->routes[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } }; + { auto _e = table(); if (_e) _o->table = std::unique_ptr(_e->UnPack(_resolver)); }; +} + +inline flatbuffers::Offset FBResult::Pack(flatbuffers::FlatBufferBuilder &_fbb, const FBResultT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateFBResult(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateFBResult(flatbuffers::FlatBufferBuilder &_fbb, const FBResultT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const FBResultT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _error = _o->error; + auto _code = _o->code ? CreateError(_fbb, _o->code.get(), _rehasher) : 0; + auto _data_version = _o->data_version.empty() ? 0 : _fbb.CreateString(_o->data_version); + auto _waypoints = _o->waypoints.size() ? _fbb.CreateVector> (_o->waypoints.size(), [](size_t i, _VectorArgs *__va) { return CreateWaypoint(*__va->__fbb, __va->__o->waypoints[i].get(), __va->__rehasher); }, &_va ) : 0; + auto _routes = _o->routes.size() ? _fbb.CreateVector> (_o->routes.size(), [](size_t i, _VectorArgs *__va) { return CreateRouteObject(*__va->__fbb, __va->__o->routes[i].get(), __va->__rehasher); }, &_va ) : 0; + auto _table = _o->table ? CreateTable(_fbb, _o->table.get(), _rehasher) : 0; + return osrm::engine::api::fbresult::CreateFBResult( + _fbb, + _error, + _code, + _data_version, + _waypoints, + _routes, + _table); +} + +inline const osrm::engine::api::fbresult::FBResult *GetFBResult(const void *buf) { + return flatbuffers::GetRoot(buf); +} + +inline const osrm::engine::api::fbresult::FBResult *GetSizePrefixedFBResult(const void *buf) { + return flatbuffers::GetSizePrefixedRoot(buf); +} + +inline bool VerifyFBResultBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifyBuffer(nullptr); +} + +inline bool VerifySizePrefixedFBResultBuffer( + flatbuffers::Verifier &verifier) { + return verifier.VerifySizePrefixedBuffer(nullptr); +} + +inline void FinishFBResultBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.Finish(root); +} + +inline void FinishSizePrefixedFBResultBuffer( + flatbuffers::FlatBufferBuilder &fbb, + flatbuffers::Offset root) { + fbb.FinishSizePrefixed(root); +} + +inline std::unique_ptr UnPackFBResult( + const void *buf, + const flatbuffers::resolver_function_t *res = nullptr) { + return std::unique_ptr(GetFBResult(buf)->UnPack(res)); +} + +inline std::unique_ptr UnPackSizePrefixedFBResult( + const void *buf, + const flatbuffers::resolver_function_t *res = nullptr) { + return std::unique_ptr(GetSizePrefixedFBResult(buf)->UnPack(res)); +} + +} // namespace fbresult +} // namespace api +} // namespace engine +} // namespace osrm + +#endif // FLATBUFFERS_GENERATED_FBRESULT_OSRM_ENGINE_API_FBRESULT_H_ diff --git a/include/engine/api/flatbuffers/position.fbs b/include/engine/api/flatbuffers/position.fbs new file mode 100644 index 000000000..e78f02c67 --- /dev/null +++ b/include/engine/api/flatbuffers/position.fbs @@ -0,0 +1,6 @@ +namespace osrm.engine.api.fbresult; + +struct Position { + longitude: float; + latitude: float; +} \ No newline at end of file diff --git a/include/engine/api/flatbuffers/route.fbs b/include/engine/api/flatbuffers/route.fbs new file mode 100644 index 000000000..902bfa199 --- /dev/null +++ b/include/engine/api/flatbuffers/route.fbs @@ -0,0 +1,110 @@ +include "waypoint.fbs"; +namespace osrm.engine.api.fbresult; + +table Metadata { + datasource_names: [string]; +} + +table Annotation { + distance: [uint]; + duration: [uint]; + datasources: [uint]; + nodes: [uint]; + weight: [uint]; + speed: [float]; + metadata: Metadata; +} + +enum ManeuverType: byte { + Turn, + NewName, + Depart, + Arrive, + Merge, + OnRamp, + OffRamp, + Fork, + EndOfRoad, + Continue, + Roundabout, + Rotary, + RoundaboutTurn, + Notification, + ExitRoundabout, + ExitRotary +} + +enum Turn: byte { + None, + UTurn, + SharpRight, + Right, + SlightRight, + Straight, + SlightLeft, + Left, + SharpLeft +} + +table StepManeuver { + location: Position; + bearing_before: ushort; + bearing_after: ushort; + type: ManeuverType; + modifier: Turn; + exit: ubyte; +} + +table Lane { + indications: [Turn]; + valid: bool; +} + +table Intersection { + location: Position; + bearings: [short]; + classes: [string]; + entry: [bool]; + in_bearing: uint; + out_bearing: uint; + lanes: [Lane]; +} + +table Step { + distance: float; + duration: float; + polyline: string; + coordinates: [Position]; + weight: float; + name: string; + ref: string; + pronunciation: string; + destinations: string; + exits: string; + mode: string; + maneuver: StepManeuver; + intersections: [Intersection]; + rotary_name: string; + rotary_pronunciation: string; + driving_side: bool; //Where true stands for the left side. +} + +table Leg { + distance: double; + duration: double; + weight: double; + summary: string; + annotations: Annotation; + steps: [Step]; +} + +table RouteObject { + distance: float; + duration: float; + weight: float; + weight_name: string; + confidence: float; //Used only by 'Match' service + polyline: string; + coordinates: [Position]; + legs: [Leg]; +} \ No newline at end of file diff --git a/include/engine/api/flatbuffers/table.fbs b/include/engine/api/flatbuffers/table.fbs new file mode 100644 index 000000000..caf1855e6 --- /dev/null +++ b/include/engine/api/flatbuffers/table.fbs @@ -0,0 +1,11 @@ +include "waypoint.fbs"; +namespace osrm.engine.api.fbresult; + +table Table { + durations: [float]; + rows: ushort; + cols: ushort; + distances: [float]; + destinations: [Waypoint]; + fallback_speed_cells: [uint]; +} \ No newline at end of file diff --git a/include/engine/api/flatbuffers/waypoint.fbs b/include/engine/api/flatbuffers/waypoint.fbs new file mode 100644 index 000000000..4991f72e6 --- /dev/null +++ b/include/engine/api/flatbuffers/waypoint.fbs @@ -0,0 +1,19 @@ +include "position.fbs"; +namespace osrm.engine.api.fbresult; + +struct Uint64Pair { + first: uint64; + second: uint64; +} + +table Waypoint { + hint: string; + distance: float; + name: string; + location: Position; + nodes: Uint64Pair; //Used only by 'Nearest' service + matchings_index: uint; //Used only by 'Match' service + waypoint_index: uint; //Used by 'Match' and 'Trip' services + alternatives_count: uint; //Used only by 'Match' service + trips_index: uint; //Used only by 'Trip' service +} \ No newline at end of file diff --git a/include/engine/api/json_factory.hpp b/include/engine/api/json_factory.hpp index db30ecc9e..f92dba16a 100644 --- a/include/engine/api/json_factory.hpp +++ b/include/engine/api/json_factory.hpp @@ -33,6 +33,18 @@ namespace json namespace detail { +// Check whether to include a modifier in the result of the API +inline bool isValidModifier(const guidance::StepManeuver maneuver) +{ + return (maneuver.waypoint_type == guidance::WaypointType::None || + maneuver.instruction.direction_modifier != osrm::guidance::DirectionModifier::UTurn); +} + +inline bool hasValidLanes(const guidance::IntermediateIntersection &intersection) +{ + return intersection.lanes.lanes_in_turn > 0; +} + util::json::Array coordinateToLonLat(const util::Coordinate &coordinate); /** @@ -100,8 +112,8 @@ util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps) util::json::Array makeRouteLegs(std::vector legs, std::vector step_geometries, std::vector annotations); -} -} +} // namespace json +} // namespace api } // namespace engine } // namespace osrm diff --git a/include/engine/api/match_api.hpp b/include/engine/api/match_api.hpp index 86a96c65b..a93e49710 100644 --- a/include/engine/api/match_api.hpp +++ b/include/engine/api/match_api.hpp @@ -29,6 +29,44 @@ class MatchAPI final : public RouteAPI { } + void MakeResponse(const std::vector &sub_matchings, + const std::vector &sub_routes, + osrm::engine::api::ResultT &response) const + { + BOOST_ASSERT(sub_matchings.size() == sub_routes.size()); + if (response.is()) + { + auto &fb_result = response.get(); + MakeResponse(sub_matchings, sub_routes, fb_result); + } + else + { + auto &json_result = response.get(); + MakeResponse(sub_matchings, sub_routes, json_result); + } + } + void MakeResponse(const std::vector &sub_matchings, + const std::vector &sub_routes, + flatbuffers::FlatBufferBuilder &fb_result) const + { + auto data_timestamp = facade.GetTimestamp(); + flatbuffers::Offset data_version_string; + if (!data_timestamp.empty()) + { + data_version_string = fb_result.CreateString(data_timestamp); + } + + auto response = MakeFBResponse(sub_routes, fb_result, [this, &fb_result, &sub_matchings]() { + return MakeTracepoints(fb_result, sub_matchings); + }); + + if (!data_timestamp.empty()) + { + response->add_data_version(data_version_string); + } + + fb_result.Finish(response->Finish()); + } void MakeResponse(const std::vector &sub_matchings, const std::vector &sub_routes, util::json::Object &response) const @@ -36,7 +74,6 @@ class MatchAPI final : public RouteAPI auto number_of_routes = sub_matchings.size(); util::json::Array routes; routes.values.reserve(number_of_routes); - BOOST_ASSERT(sub_matchings.size() == sub_routes.size()); for (auto index : util::irange(0UL, sub_matchings.size())) { auto route = MakeRoute(sub_routes[index].segment_end_coordinates, @@ -46,7 +83,10 @@ class MatchAPI final : public RouteAPI route.values["confidence"] = sub_matchings[index].confidence; routes.values.push_back(std::move(route)); } - response.values["tracepoints"] = MakeTracepoints(sub_matchings); + if (!parameters.skip_waypoints) + { + response.values["tracepoints"] = MakeTracepoints(sub_matchings); + } response.values["matchings"] = std::move(routes); response.values["code"] = "Ok"; } @@ -55,47 +95,87 @@ class MatchAPI final : public RouteAPI // FIXME this logic is a little backwards. We should change the output format of the // map_matching // routing algorithm to be easier to consume here. + struct MatchingIndex + { + MatchingIndex() = default; + MatchingIndex(unsigned sub_matching_index_, unsigned point_index_) + : sub_matching_index(sub_matching_index_), point_index(point_index_) + { + } + + unsigned sub_matching_index = std::numeric_limits::max(); + unsigned point_index = std::numeric_limits::max(); + + bool NotMatched() + { + return sub_matching_index == std::numeric_limits::max() && + point_index == std::numeric_limits::max(); + } + }; + + flatbuffers::Offset>> + MakeTracepoints(flatbuffers::FlatBufferBuilder &fb_result, + const std::vector &sub_matchings) const + { + std::vector> waypoints; + waypoints.reserve(parameters.coordinates.size()); + + auto trace_idx_to_matching_idx = MakeMatchingIndices(sub_matchings); + + BOOST_ASSERT(parameters.waypoints.empty() || sub_matchings.size() == 1); + + std::size_t was_waypoint_idx = 0; + for (auto trace_index : util::irange(0UL, parameters.coordinates.size())) + { + + if (tidy_result.can_be_removed[trace_index]) + { + waypoints.push_back(fbresult::WaypointBuilder(fb_result).Finish()); + continue; + } + auto matching_index = trace_idx_to_matching_idx[trace_index]; + if (matching_index.NotMatched()) + { + waypoints.push_back(fbresult::WaypointBuilder(fb_result).Finish()); + continue; + } + const auto &phantom = + sub_matchings[matching_index.sub_matching_index].nodes[matching_index.point_index]; + auto waypoint = BaseAPI::MakeWaypoint(&fb_result, phantom); + waypoint->add_matchings_index(matching_index.sub_matching_index); + waypoint->add_alternatives_count(sub_matchings[matching_index.sub_matching_index] + .alternatives_count[matching_index.point_index]); + // waypoint indices need to be adjusted if route legs were collapsed + // waypoint parameter assumes there is only one match object + if (!parameters.waypoints.empty()) + { + if (tidy_result.was_waypoint[trace_index]) + { + waypoint->add_waypoint_index(was_waypoint_idx); + was_waypoint_idx++; + } + else + { + waypoint->add_waypoint_index(0); + } + } + else + { + waypoint->add_waypoint_index(matching_index.point_index); + } + waypoints.push_back(waypoint->Finish()); + } + + return fb_result.CreateVector(waypoints); + } + util::json::Array MakeTracepoints(const std::vector &sub_matchings) const { util::json::Array waypoints; waypoints.values.reserve(parameters.coordinates.size()); - struct MatchingIndex - { - MatchingIndex() = default; - MatchingIndex(unsigned sub_matching_index_, unsigned point_index_) - : sub_matching_index(sub_matching_index_), point_index(point_index_) - { - } - - unsigned sub_matching_index = std::numeric_limits::max(); - unsigned point_index = std::numeric_limits::max(); - - bool NotMatched() - { - return sub_matching_index == std::numeric_limits::max() && - point_index == std::numeric_limits::max(); - } - }; - - std::vector trace_idx_to_matching_idx(parameters.coordinates.size()); - for (auto sub_matching_index : - util::irange(0u, static_cast(sub_matchings.size()))) - { - for (auto point_index : util::irange( - 0u, static_cast(sub_matchings[sub_matching_index].indices.size()))) - { - // tidied_to_original: index of the input coordinate that a tidied coordinate - // corresponds to. - // sub_matching indices: index of the coordinate passed to map matching plugin that - // a matched node corresponds to. - trace_idx_to_matching_idx[tidy_result - .tidied_to_original[sub_matchings[sub_matching_index] - .indices[point_index]]] = - MatchingIndex{sub_matching_index, point_index}; - } - } + auto trace_idx_to_matching_idx = MakeMatchingIndices(sub_matchings); BOOST_ASSERT(parameters.waypoints.empty() || sub_matchings.size() == 1); @@ -141,12 +221,35 @@ class MatchAPI final : public RouteAPI return waypoints; } + std::vector + MakeMatchingIndices(const std::vector &sub_matchings) const + { + std::vector trace_idx_to_matching_idx(parameters.coordinates.size()); + for (auto sub_matching_index : + util::irange(0u, static_cast(sub_matchings.size()))) + { + for (auto point_index : util::irange( + 0u, static_cast(sub_matchings[sub_matching_index].indices.size()))) + { + // tidied_to_original: index of the input coordinate that a tidied coordinate + // corresponds to. + // sub_matching indices: index of the coordinate passed to map matching plugin that + // a matched node corresponds to. + trace_idx_to_matching_idx[tidy_result + .tidied_to_original[sub_matchings[sub_matching_index] + .indices[point_index]]] = + MatchingIndex{sub_matching_index, point_index}; + } + } + return trace_idx_to_matching_idx; + } + const MatchParameters ¶meters; const tidy::Result &tidy_result; }; -} // ns api -} // ns engine -} // ns osrm +} // namespace api +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/api/match_parameters.hpp b/include/engine/api/match_parameters.hpp index 79ce84c55..774a2c09d 100644 --- a/include/engine/api/match_parameters.hpp +++ b/include/engine/api/match_parameters.hpp @@ -63,13 +63,16 @@ struct MatchParameters : public RouteParameters RouteParameters::GeometriesType::Polyline, RouteParameters::OverviewType::Simplified, {}), - gaps(GapsType::Split), tidy(false), waypoints() + gaps(GapsType::Split), tidy(false) { } template - MatchParameters(std::vector timestamps_, GapsType gaps_, bool tidy_, Args... args_) - : MatchParameters(std::move(timestamps_), gaps_, tidy_, {}, std::forward(args_)...) + MatchParameters(const std::vector ×tamps_, + GapsType gaps_, + bool tidy_, + Args &&... args_) + : MatchParameters(timestamps_, gaps_, tidy_, {}, std::forward(args_)...) { } @@ -77,30 +80,26 @@ struct MatchParameters : public RouteParameters MatchParameters(std::vector timestamps_, GapsType gaps_, bool tidy_, - std::vector waypoints_, - Args... args_) - : RouteParameters{std::forward(args_)...}, timestamps{std::move(timestamps_)}, - gaps(gaps_), tidy(tidy_), waypoints{std::move(waypoints_)} + const std::vector &waypoints_, + Args &&... args_) + : RouteParameters{std::forward(args_)..., waypoints_}, timestamps{std::move( + timestamps_)}, + gaps(gaps_), tidy(tidy_) { } std::vector timestamps; GapsType gaps; bool tidy; - std::vector waypoints; bool IsValid() const { - const auto valid_waypoints = - std::all_of(waypoints.begin(), waypoints.end(), [this](const auto &w) { - return w < coordinates.size(); - }); return RouteParameters::IsValid() && - (timestamps.empty() || timestamps.size() == coordinates.size()) && valid_waypoints; + (timestamps.empty() || timestamps.size() == coordinates.size()); } }; -} -} -} +} // namespace api +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/api/match_parameters_tidy.hpp b/include/engine/api/match_parameters_tidy.hpp index ab4610c4f..198740afa 100644 --- a/include/engine/api/match_parameters_tidy.hpp +++ b/include/engine/api/match_parameters_tidy.hpp @@ -200,9 +200,9 @@ inline Result tidy(const MatchParameters ¶ms, Thresholds cfg = {15., 5}) return result; } -} // ns tidy -} // ns api -} // ns engine -} // ns osrm +} // namespace tidy +} // namespace api +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/api/nearest_api.hpp b/include/engine/api/nearest_api.hpp index bb55b0634..aff3c57dc 100644 --- a/include/engine/api/nearest_api.hpp +++ b/include/engine/api/nearest_api.hpp @@ -2,6 +2,7 @@ #define ENGINE_API_NEAREST_API_HPP #include "engine/api/base_api.hpp" +#include "engine/api/base_result.hpp" #include "engine/api/nearest_parameters.hpp" #include "engine/api/json_factory.hpp" @@ -27,71 +28,139 @@ class NearestAPI final : public BaseAPI } void MakeResponse(const std::vector> &phantom_nodes, - util::json::Object &response) const + osrm::engine::api::ResultT &response) const { BOOST_ASSERT(phantom_nodes.size() == 1); BOOST_ASSERT(parameters.coordinates.size() == 1); - util::json::Array waypoints; - waypoints.values.resize(phantom_nodes.front().size()); - std::transform( - phantom_nodes.front().begin(), - phantom_nodes.front().end(), - waypoints.values.begin(), - [this](const PhantomNodeWithDistance &phantom_with_distance) { - auto &phantom_node = phantom_with_distance.phantom_node; - auto waypoint = MakeWaypoint(phantom_node); + if (response.is()) + { + auto &fb_result = response.get(); + MakeResponse(phantom_nodes, fb_result); + } + else + { + auto &json_result = response.get(); + MakeResponse(phantom_nodes, json_result); + } + } - util::json::Array nodes; + void MakeResponse(const std::vector> &phantom_nodes, + flatbuffers::FlatBufferBuilder &fb_result) const + { + auto data_timestamp = facade.GetTimestamp(); + boost::optional> data_version_string = boost::none; + if (!data_timestamp.empty()) + { + data_version_string = fb_result.CreateString(data_timestamp); + } - std::uint64_t from_node = 0; - std::uint64_t to_node = 0; + flatbuffers::Offset>> + waypoints_vector; + if (!parameters.skip_waypoints) + { + std::vector> waypoints; + waypoints.resize(phantom_nodes.front().size()); + std::transform( + phantom_nodes.front().begin(), + phantom_nodes.front().end(), + waypoints.begin(), + [this, &fb_result](const PhantomNodeWithDistance &phantom_with_distance) { + auto &phantom_node = phantom_with_distance.phantom_node; - datafacade::BaseDataFacade::NodeForwardRange forward_geometry; - if (phantom_node.forward_segment_id.enabled) - { - auto segment_id = phantom_node.forward_segment_id.id; - const auto geometry_id = facade.GetGeometryIndex(segment_id).id; - forward_geometry = facade.GetUncompressedForwardGeometry(geometry_id); + auto node_values = MakeNodes(phantom_node); + fbresult::Uint64Pair nodes{node_values.first, node_values.second}; - auto osm_node_id = facade.GetOSMNodeIDOfNode( - forward_geometry(phantom_node.fwd_segment_position)); - to_node = static_cast(osm_node_id); - } + auto waypoint = MakeWaypoint(&fb_result, phantom_node); + waypoint->add_nodes(&nodes); + return waypoint->Finish(); + }); - if (phantom_node.reverse_segment_id.enabled) - { - auto segment_id = phantom_node.reverse_segment_id.id; - const auto geometry_id = facade.GetGeometryIndex(segment_id).id; - const auto geometry = facade.GetUncompressedForwardGeometry(geometry_id); - auto osm_node_id = - facade.GetOSMNodeIDOfNode(geometry(phantom_node.fwd_segment_position + 1)); - from_node = static_cast(osm_node_id); - } - else if (phantom_node.forward_segment_id.enabled && - phantom_node.fwd_segment_position > 0) - { - // In the case of one way, rely on forward segment only - auto osm_node_id = facade.GetOSMNodeIDOfNode( - forward_geometry(phantom_node.fwd_segment_position - 1)); - from_node = static_cast(osm_node_id); - } - nodes.values.push_back(from_node); - nodes.values.push_back(to_node); - waypoint.values["nodes"] = std::move(nodes); + waypoints_vector = fb_result.CreateVector(waypoints); + } - return waypoint; - }); + fbresult::FBResultBuilder response(fb_result); + + response.add_waypoints(waypoints_vector); + if (data_version_string) + { + response.add_data_version(*data_version_string); + } + fb_result.Finish(response.Finish()); + } + void MakeResponse(const std::vector> &phantom_nodes, + util::json::Object &response) const + { + if (!parameters.skip_waypoints) + { + util::json::Array waypoints; + waypoints.values.resize(phantom_nodes.front().size()); + std::transform(phantom_nodes.front().begin(), + phantom_nodes.front().end(), + waypoints.values.begin(), + [this](const PhantomNodeWithDistance &phantom_with_distance) { + auto &phantom_node = phantom_with_distance.phantom_node; + auto waypoint = MakeWaypoint(phantom_node); + + util::json::Array nodes; + + auto node_values = MakeNodes(phantom_node); + + nodes.values.push_back(node_values.first); + nodes.values.push_back(node_values.second); + waypoint.values["nodes"] = std::move(nodes); + + return waypoint; + }); + response.values["waypoints"] = std::move(waypoints); + } response.values["code"] = "Ok"; - response.values["waypoints"] = std::move(waypoints); } const NearestParameters ¶meters; + + protected: + std::pair MakeNodes(const PhantomNode &phantom_node) const + { + std::uint64_t from_node = 0; + std::uint64_t to_node = 0; + + datafacade::BaseDataFacade::NodeForwardRange forward_geometry; + if (phantom_node.forward_segment_id.enabled) + { + auto segment_id = phantom_node.forward_segment_id.id; + const auto geometry_id = facade.GetGeometryIndex(segment_id).id; + forward_geometry = facade.GetUncompressedForwardGeometry(geometry_id); + + auto osm_node_id = + facade.GetOSMNodeIDOfNode(forward_geometry(phantom_node.fwd_segment_position)); + to_node = static_cast(osm_node_id); + } + + if (phantom_node.reverse_segment_id.enabled) + { + auto segment_id = phantom_node.reverse_segment_id.id; + const auto geometry_id = facade.GetGeometryIndex(segment_id).id; + const auto geometry = facade.GetUncompressedForwardGeometry(geometry_id); + auto osm_node_id = + facade.GetOSMNodeIDOfNode(geometry(phantom_node.fwd_segment_position + 1)); + from_node = static_cast(osm_node_id); + } + else if (phantom_node.forward_segment_id.enabled && phantom_node.fwd_segment_position > 0) + { + // In the case of one way, rely on forward segment only + auto osm_node_id = + facade.GetOSMNodeIDOfNode(forward_geometry(phantom_node.fwd_segment_position - 1)); + from_node = static_cast(osm_node_id); + } + + return std::make_pair(from_node, to_node); + } }; -} // ns api -} // ns engine -} // ns osrm +} // namespace api +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/api/nearest_parameters.hpp b/include/engine/api/nearest_parameters.hpp index f24251b8c..576e75352 100644 --- a/include/engine/api/nearest_parameters.hpp +++ b/include/engine/api/nearest_parameters.hpp @@ -52,8 +52,8 @@ struct NearestParameters : public BaseParameters bool IsValid() const { return BaseParameters::IsValid() && number_of_results >= 1; } }; -} -} -} +} // namespace api +} // namespace engine +} // namespace osrm #endif // ENGINE_API_NEAREST_PARAMETERS_HPP diff --git a/include/engine/api/route_api.hpp b/include/engine/api/route_api.hpp index a24277901..4990d37c9 100644 --- a/include/engine/api/route_api.hpp +++ b/include/engine/api/route_api.hpp @@ -3,6 +3,7 @@ #include "extractor/maneuver_override.hpp" #include "engine/api/base_api.hpp" +#include "engine/api/base_result.hpp" #include "engine/api/json_factory.hpp" #include "engine/api/route_parameters.hpp" @@ -44,11 +45,58 @@ class RouteAPI : public BaseAPI { } - void MakeResponse(const InternalManyRoutesResult &raw_routes, - util::json::Object &response) const + void + MakeResponse(const InternalManyRoutesResult &raw_routes, + const std::vector + &all_start_end_points, // all used coordinates, ignoring waypoints= parameter + osrm::engine::api::ResultT &response) const { BOOST_ASSERT(!raw_routes.routes.empty()); + if (response.is()) + { + auto &fb_result = response.get(); + MakeResponse(raw_routes, all_start_end_points, fb_result); + } + else + { + auto &json_result = response.get(); + MakeResponse(raw_routes, all_start_end_points, json_result); + } + } + + void + MakeResponse(const InternalManyRoutesResult &raw_routes, + const std::vector + &all_start_end_points, // all used coordinates, ignoring waypoints= parameter + flatbuffers::FlatBufferBuilder &fb_result) const + { + + auto data_timestamp = facade.GetTimestamp(); + flatbuffers::Offset data_version_string; + if (!data_timestamp.empty()) + { + data_version_string = fb_result.CreateString(data_timestamp); + } + + auto response = + MakeFBResponse(raw_routes, fb_result, [this, &all_start_end_points, &fb_result]() { + return BaseAPI::MakeWaypoints(&fb_result, all_start_end_points); + }); + + if (!data_timestamp.empty()) + { + response->add_data_version(data_version_string); + } + fb_result.Finish(response->Finish()); + } + + void + MakeResponse(const InternalManyRoutesResult &raw_routes, + const std::vector + &all_start_end_points, // all used coordinates, ignoring waypoints= parameter + util::json::Object &response) const + { util::json::Array jsRoutes; for (const auto &route : raw_routes.routes) @@ -62,28 +110,115 @@ class RouteAPI : public BaseAPI route.target_traversed_in_reverse)); } - response.values["waypoints"] = - BaseAPI::MakeWaypoints(raw_routes.routes[0].segment_end_coordinates); + if (!parameters.skip_waypoints) + { + response.values["waypoints"] = BaseAPI::MakeWaypoints(all_start_end_points); + } response.values["routes"] = std::move(jsRoutes); response.values["code"] = "Ok"; + auto data_timestamp = facade.GetTimestamp(); + if (!data_timestamp.empty()) + { + response.values["data_version"] = data_timestamp; + } } protected: + template + std::unique_ptr + MakeFBResponse(const InternalManyRoutesResult &raw_routes, + flatbuffers::FlatBufferBuilder &fb_result, + GetWptsFn getWaypoints) const + { + + std::vector> routes; + for (const auto &raw_route : raw_routes.routes) + { + if (!raw_route.is_valid()) + continue; + + routes.push_back(MakeRoute(fb_result, + raw_route.segment_end_coordinates, + raw_route.unpacked_path_segments, + raw_route.source_traversed_in_reverse, + raw_route.target_traversed_in_reverse)); + } + + auto routes_vector = fb_result.CreateVector(routes); + flatbuffers::Offset>> + waypoints_vector; + if (!parameters.skip_waypoints) + { + waypoints_vector = getWaypoints(); + } + + auto response = std::make_unique(fb_result); + response->add_routes(routes_vector); + response->add_waypoints(waypoints_vector); + + return response; + } + template - util::json::Value MakeGeometry(ForwardIter begin, ForwardIter end) const + mapbox::util::variant, + flatbuffers::Offset>> + MakeGeometry(flatbuffers::FlatBufferBuilder &builder, ForwardIter begin, ForwardIter end) const { if (parameters.geometries == RouteParameters::GeometriesType::Polyline) { - return json::makePolyline<100000>(begin, end); + return builder.CreateString(encodePolyline<100000>(begin, end)); } - - if (parameters.geometries == RouteParameters::GeometriesType::Polyline6) + else if (parameters.geometries == RouteParameters::GeometriesType::Polyline6) { - return json::makePolyline<1000000>(begin, end); + return builder.CreateString(encodePolyline<1000000>(begin, end)); + } + std::vector coordinates; + coordinates.resize(std::distance(begin, end)); + std::transform(begin, end, coordinates.begin(), [](const Coordinate &c) { + return fbresult::Position{static_cast(util::toFloating(c.lon).__value), + static_cast(util::toFloating(c.lat).__value)}; + }); + return builder.CreateVectorOfStructs(coordinates); + } + + boost::optional + MakeGeometry(boost::optional> &&annotations) const + { + boost::optional json_geometry; + if (annotations) + { + auto begin = annotations->begin(); + auto end = annotations->end(); + if (parameters.geometries == RouteParameters::GeometriesType::Polyline) + { + json_geometry = json::makePolyline<100000>(begin, end); + } + else if (parameters.geometries == RouteParameters::GeometriesType::Polyline6) + { + json_geometry = json::makePolyline<1000000>(begin, end); + } + else + { + BOOST_ASSERT(parameters.geometries == RouteParameters::GeometriesType::GeoJSON); + json_geometry = json::makeGeoJSONGeometry(begin, end); + } + } + return json_geometry; + } + + template + flatbuffers::Offset> GetAnnotations( + flatbuffers::FlatBufferBuilder &fb_result, guidance::LegGeometry &leg, GetFn Get) const + { + std::vector annotations_store; + annotations_store.reserve(leg.annotations.size()); + + for (const auto &step : leg.annotations) + { + annotations_store.push_back(Get(step)); } - BOOST_ASSERT(parameters.geometries == RouteParameters::GeometriesType::GeoJSON); - return json::makeGeoJSONGeometry(begin, end); + return fb_result.CreateVector(annotations_store); } template @@ -100,118 +235,491 @@ class RouteAPI : public BaseAPI return annotations_store; } + fbresult::ManeuverType WaypointTypeToFB(guidance::WaypointType type) const + { + switch (type) + { + case guidance::WaypointType::Arrive: + return fbresult::ManeuverType_Arrive; + case guidance::WaypointType::Depart: + return fbresult::ManeuverType_Depart; + default: + return fbresult::ManeuverType_Notification; + } + } + + fbresult::ManeuverType TurnTypeToFB(osrm::guidance::TurnType::Enum turn) const + { + static std::map mappings = { + {osrm::guidance::TurnType::Invalid, fbresult::ManeuverType_Notification}, + {osrm::guidance::TurnType::NewName, fbresult::ManeuverType_NewName}, + {osrm::guidance::TurnType::Continue, fbresult::ManeuverType_Continue}, + {osrm::guidance::TurnType::Turn, fbresult::ManeuverType_Turn}, + {osrm::guidance::TurnType::Merge, fbresult::ManeuverType_Merge}, + {osrm::guidance::TurnType::OnRamp, fbresult::ManeuverType_OnRamp}, + {osrm::guidance::TurnType::OffRamp, fbresult::ManeuverType_OffRamp}, + {osrm::guidance::TurnType::Fork, fbresult::ManeuverType_Fork}, + {osrm::guidance::TurnType::EndOfRoad, fbresult::ManeuverType_EndOfRoad}, + {osrm::guidance::TurnType::Notification, fbresult::ManeuverType_Notification}, + {osrm::guidance::TurnType::EnterRoundabout, fbresult::ManeuverType_Roundabout}, + {osrm::guidance::TurnType::EnterAndExitRoundabout, + fbresult::ManeuverType_ExitRoundabout}, + {osrm::guidance::TurnType::EnterRotary, fbresult::ManeuverType_Rotary}, + {osrm::guidance::TurnType::EnterAndExitRotary, fbresult::ManeuverType_ExitRotary}, + {osrm::guidance::TurnType::EnterRoundaboutIntersection, + fbresult::ManeuverType_Roundabout}, + {osrm::guidance::TurnType::EnterAndExitRoundaboutIntersection, + fbresult::ManeuverType_ExitRoundabout}, + {osrm::guidance::TurnType::NoTurn, fbresult::ManeuverType_Notification}, + {osrm::guidance::TurnType::Suppressed, fbresult::ManeuverType_Notification}, + {osrm::guidance::TurnType::EnterRoundaboutAtExit, fbresult::ManeuverType_Roundabout}, + {osrm::guidance::TurnType::ExitRoundabout, fbresult::ManeuverType_ExitRoundabout}, + {osrm::guidance::TurnType::EnterRotaryAtExit, fbresult::ManeuverType_Rotary}, + {osrm::guidance::TurnType::ExitRotary, fbresult::ManeuverType_ExitRotary}, + {osrm::guidance::TurnType::EnterRoundaboutIntersectionAtExit, + fbresult::ManeuverType_Roundabout}, + {osrm::guidance::TurnType::ExitRoundaboutIntersection, + fbresult::ManeuverType_ExitRoundabout}, + {osrm::guidance::TurnType::StayOnRoundabout, fbresult::ManeuverType_RoundaboutTurn}, + {osrm::guidance::TurnType::Sliproad, fbresult::ManeuverType_Notification}, + {osrm::guidance::TurnType::MaxTurnType, fbresult::ManeuverType_Notification}}; + return mappings[turn]; + } + + fbresult::Turn TurnModifierToFB(osrm::guidance::DirectionModifier::Enum modifier) const + { + static std::map mappings = { + {osrm::guidance::DirectionModifier::UTurn, fbresult::Turn_UTurn}, + {osrm::guidance::DirectionModifier::SharpRight, fbresult::Turn_SharpRight}, + {osrm::guidance::DirectionModifier::Right, fbresult::Turn_Right}, + {osrm::guidance::DirectionModifier::SlightRight, fbresult::Turn_SlightRight}, + {osrm::guidance::DirectionModifier::Straight, fbresult::Turn_Straight}, + {osrm::guidance::DirectionModifier::SlightLeft, fbresult::Turn_SlightLeft}, + {osrm::guidance::DirectionModifier::Left, fbresult::Turn_Left}, + {osrm::guidance::DirectionModifier::SharpLeft, fbresult::Turn_SharpLeft}, + }; + return mappings[modifier]; + } + + std::vector TurnLaneTypeToFB(const extractor::TurnLaneType::Mask lane_type) const + { + const static fbresult::Turn mapping[] = {fbresult::Turn_None, + fbresult::Turn_Straight, + fbresult::Turn_SharpLeft, + fbresult::Turn_Left, + fbresult::Turn_SlightLeft, + fbresult::Turn_SlightRight, + fbresult::Turn_Right, + fbresult::Turn_SharpRight, + fbresult::Turn_UTurn, + fbresult::Turn_SlightLeft, + fbresult::Turn_SlightRight}; + std::vector result; + std::bitset<8 * sizeof(extractor::TurnLaneType::Mask)> mask(lane_type); + for (auto index : util::irange(0, extractor::TurnLaneType::NUM_TYPES)) + { + if (mask[index]) + { + result.push_back(mapping[index]); + } + } + return result; + } + + flatbuffers::Offset + MakeRoute(flatbuffers::FlatBufferBuilder &fb_result, + const std::vector &segment_end_coordinates, + const std::vector> &unpacked_path_segments, + const std::vector &source_traversed_in_reverse, + const std::vector &target_traversed_in_reverse) const + { + auto legs_info = MakeLegs(segment_end_coordinates, + unpacked_path_segments, + source_traversed_in_reverse, + target_traversed_in_reverse); + std::vector legs = legs_info.first; + std::vector leg_geometries = legs_info.second; + auto route = guidance::assembleRoute(legs); + + // Fill legs + std::vector> routeLegs; + routeLegs.reserve(legs.size()); + for (const auto idx : util::irange(0UL, legs.size())) + { + auto leg = legs[idx]; + auto &leg_geometry = leg_geometries[idx]; + + // Fill steps + std::vector> legSteps; + if (!leg.steps.empty()) + { + legSteps.resize(leg.steps.size()); + std::transform(leg.steps.begin(), + leg.steps.end(), + legSteps.begin(), + [this, &fb_result, &leg_geometry](auto &step) { + return this->MakeFBStep(fb_result, leg_geometry, step); + }); + } + auto steps_vector = fb_result.CreateVector(legSteps); + + // Fill annotations + // To maintain support for uses of the old default constructors, we check + // if annotations property was set manually after default construction + auto requested_annotations = parameters.annotations_type; + if ((parameters.annotations == true) && + (parameters.annotations_type == RouteParameters::AnnotationsType::None)) + { + requested_annotations = RouteParameters::AnnotationsType::All; + } + + flatbuffers::Offset annotation_buffer; + if (requested_annotations != RouteParameters::AnnotationsType::None) + { + annotation_buffer = + MakeFBAnnotations(fb_result, leg_geometry, requested_annotations); + } + + flatbuffers::Offset summary_string; + if (!leg.summary.empty()) + { + summary_string = fb_result.CreateString(leg.summary); + } + + fbresult::LegBuilder legBuilder(fb_result); + legBuilder.add_distance(leg.distance); + legBuilder.add_duration(leg.duration); + legBuilder.add_weight(leg.weight); + if (!leg.summary.empty()) + { + legBuilder.add_summary(summary_string); + } + legBuilder.add_steps(steps_vector); + + if (requested_annotations != RouteParameters::AnnotationsType::None) + { + legBuilder.add_annotations(annotation_buffer); + } + routeLegs.emplace_back(legBuilder.Finish()); + } + auto legs_vector = fb_result.CreateVector(routeLegs); + + // Fill geometry + auto overview = MakeOverview(leg_geometries); + mapbox::util::variant, + flatbuffers::Offset>> + geometry; + if (overview) + { + geometry = MakeGeometry(fb_result, overview->begin(), overview->end()); + } + + auto weight_name_string = fb_result.CreateString(facade.GetWeightName()); + + fbresult::RouteObjectBuilder routeObject(fb_result); + routeObject.add_distance(route.distance); + routeObject.add_duration(route.duration); + routeObject.add_weight(route.weight); + routeObject.add_weight_name(weight_name_string); + routeObject.add_legs(legs_vector); + if (overview) + { + mapbox::util::apply_visitor(GeometryVisitor(routeObject), + geometry); + } + + return routeObject.Finish(); + } + + flatbuffers::Offset + MakeFBAnnotations(flatbuffers::FlatBufferBuilder &fb_result, + guidance::LegGeometry &leg_geometry, + const RouteParameters::AnnotationsType &requested_annotations) const + { + // AnnotationsType uses bit flags, & operator checks if a property is set + flatbuffers::Offset> speed; + if (parameters.annotations_type & RouteParameters::AnnotationsType::Speed) + { + double prev_speed = 0; + speed = + GetAnnotations(fb_result, + leg_geometry, + [&prev_speed](const guidance::LegGeometry::Annotation &anno) { + if (anno.duration < std::numeric_limits::min()) + { + return prev_speed; + } + else + { + auto speed = + round(anno.distance / anno.duration * 10.) / 10.; + prev_speed = speed; + return util::json::clamp_float(speed); + } + }); + } + + flatbuffers::Offset> duration; + if (requested_annotations & RouteParameters::AnnotationsType::Duration) + { + duration = GetAnnotations( + fb_result, leg_geometry, [](const guidance::LegGeometry::Annotation &anno) { + return anno.duration; + }); + } + + flatbuffers::Offset> distance; + if (requested_annotations & RouteParameters::AnnotationsType::Distance) + { + distance = GetAnnotations( + fb_result, leg_geometry, [](const guidance::LegGeometry::Annotation &anno) { + return anno.distance; + }); + } + + flatbuffers::Offset> weight; + if (requested_annotations & RouteParameters::AnnotationsType::Weight) + { + weight = GetAnnotations( + fb_result, leg_geometry, [](const guidance::LegGeometry::Annotation &anno) { + return anno.weight; + }); + } + + flatbuffers::Offset> datasources; + if (requested_annotations & RouteParameters::AnnotationsType::Datasources) + { + datasources = GetAnnotations( + fb_result, leg_geometry, [](const guidance::LegGeometry::Annotation &anno) { + return anno.datasource; + }); + } + std::vector nodes; + if (requested_annotations & RouteParameters::AnnotationsType::Nodes) + { + nodes.reserve(leg_geometry.osm_node_ids.size()); + for (const auto node_id : leg_geometry.osm_node_ids) + { + nodes.emplace_back(static_cast(node_id)); + } + } + auto nodes_vector = fb_result.CreateVector(nodes); + // Add any supporting metadata, if needed + bool use_metadata = requested_annotations & RouteParameters::AnnotationsType::Datasources; + flatbuffers::Offset metadata_buffer; + if (use_metadata) + { + const auto MAX_DATASOURCE_ID = 255u; + std::vector> names; + for (auto i = 0u; i < MAX_DATASOURCE_ID; i++) + { + const auto name = facade.GetDatasourceName(i); + // Length of 0 indicates the first empty name, so we can stop here + if (name.size() == 0) + break; + names.emplace_back( + fb_result.CreateString(std::string(facade.GetDatasourceName(i)))); + } + metadata_buffer = fbresult::CreateMetadataDirect(fb_result, &names); + } + fbresult::AnnotationBuilder annotation(fb_result); + annotation.add_speed(speed); + annotation.add_duration(duration); + annotation.add_distance(distance); + annotation.add_weight(weight); + annotation.add_datasources(datasources); + annotation.add_nodes(nodes_vector); + if (use_metadata) + { + annotation.add_metadata(metadata_buffer); + } + + return annotation.Finish(); + } + + template class GeometryVisitor + { + public: + GeometryVisitor(Builder &builder) : builder(builder) {} + + void operator()(const flatbuffers::Offset &value) + { + builder.add_polyline(value); + } + void operator()( + const flatbuffers::Offset> &value) + { + builder.add_coordinates(value); + } + + private: + Builder &builder; + }; + + flatbuffers::Offset MakeFBStep(flatbuffers::FlatBufferBuilder &builder, + const guidance::LegGeometry &leg_geometry, + const guidance::RouteStep &step) const + { + auto name_string = builder.CreateString(step.name); + + flatbuffers::Offset ref_string; + if (!step.ref.empty()) + { + ref_string = builder.CreateString(step.ref); + } + + flatbuffers::Offset pronunciation_string; + if (!step.pronunciation.empty()) + { + pronunciation_string = builder.CreateString(step.pronunciation); + } + + flatbuffers::Offset destinations_string; + if (!step.destinations.empty()) + { + destinations_string = builder.CreateString(step.destinations); + } + + flatbuffers::Offset exists_string; + if (!step.exits.empty()) + { + exists_string = builder.CreateString(step.exits); + } + + flatbuffers::Offset rotary_name_string; + flatbuffers::Offset rotary_pronunciation_string; + if (!step.rotary_name.empty()) + { + rotary_name_string = builder.CreateString(step.rotary_name); + if (!step.rotary_pronunciation.empty()) + { + rotary_pronunciation_string = builder.CreateString(step.rotary_pronunciation); + } + } + auto mode_string = builder.CreateString(extractor::travelModeToString(step.mode)); + + // Geometry + auto geometry = MakeGeometry(builder, + leg_geometry.locations.begin() + step.geometry_begin, + leg_geometry.locations.begin() + step.geometry_end); + // Maneuver + fbresult::StepManeuverBuilder maneuver(builder); + fbresult::Position maneuverPosition{ + static_cast(util::toFloating(step.maneuver.location.lon).__value), + static_cast(util::toFloating(step.maneuver.location.lat).__value)}; + maneuver.add_location(&maneuverPosition); + maneuver.add_bearing_before(step.maneuver.bearing_before); + maneuver.add_bearing_after(step.maneuver.bearing_after); + if (step.maneuver.waypoint_type == guidance::WaypointType::None) + maneuver.add_type(TurnTypeToFB(step.maneuver.instruction.type)); + else + maneuver.add_type(WaypointTypeToFB(step.maneuver.waypoint_type)); + if (osrm::engine::api::json::detail::isValidModifier(step.maneuver)) + { + maneuver.add_modifier(TurnModifierToFB(step.maneuver.instruction.direction_modifier)); + } + if (step.maneuver.exit != 0) + { + maneuver.add_exit(step.maneuver.exit); + } + auto maneuver_buffer = maneuver.Finish(); + + // intersections + auto intersections_vector = MakeFBIntersections(builder, step); + + fbresult::StepBuilder stepBuilder(builder); + stepBuilder.add_duration(step.duration); + stepBuilder.add_distance(step.distance); + stepBuilder.add_weight(step.weight); + stepBuilder.add_name(name_string); + stepBuilder.add_mode(mode_string); + stepBuilder.add_driving_side(step.is_left_hand_driving); + stepBuilder.add_ref(ref_string); + stepBuilder.add_pronunciation(pronunciation_string); + stepBuilder.add_destinations(destinations_string); + stepBuilder.add_exits(exists_string); + stepBuilder.add_rotary_name(rotary_name_string); + stepBuilder.add_rotary_pronunciation(rotary_pronunciation_string); + stepBuilder.add_intersections(intersections_vector); + stepBuilder.add_maneuver(maneuver_buffer); + mapbox::util::apply_visitor(GeometryVisitor(stepBuilder), geometry); + return stepBuilder.Finish(); + }; + + flatbuffers::Offset>> + MakeFBIntersections(flatbuffers::FlatBufferBuilder &fb_result, + const guidance::RouteStep &step) const + { + std::vector> intersections; + intersections.resize(step.intersections.size()); + std::transform( + step.intersections.begin(), + step.intersections.end(), + intersections.begin(), + [&fb_result, this](const guidance::IntermediateIntersection &intersection) { + std::vector> lanes; + if (json::detail::hasValidLanes(intersection)) + { + BOOST_ASSERT(intersection.lanes.lanes_in_turn >= 1); + lanes.reserve(intersection.lane_description.size()); + LaneID lane_id = intersection.lane_description.size(); + + for (const auto &lane_desc : intersection.lane_description) + { + --lane_id; + auto indications = TurnLaneTypeToFB(lane_desc); + + auto lane_valid = lane_id >= intersection.lanes.first_lane_from_the_right && + lane_id < intersection.lanes.first_lane_from_the_right + + intersection.lanes.lanes_in_turn; + lanes.push_back( + fbresult::CreateLaneDirect(fb_result, &indications, lane_valid)); + } + } + auto lanes_vector = fb_result.CreateVector(lanes); + + fbresult::Position maneuverPosition{ + static_cast(util::toFloating(intersection.location.lon).__value), + static_cast(util::toFloating(intersection.location.lat).__value)}; + auto bearings_vector = fb_result.CreateVector(intersection.bearings); + std::vector> classes; + classes.resize(intersection.classes.size()); + std::transform( + intersection.classes.begin(), + intersection.classes.end(), + classes.begin(), + [&fb_result](const std::string cls) { return fb_result.CreateString(cls); }); + auto classes_vector = fb_result.CreateVector(classes); + auto entry_vector = fb_result.CreateVector(intersection.entry); + + fbresult::IntersectionBuilder intersectionBuilder(fb_result); + intersectionBuilder.add_location(&maneuverPosition); + intersectionBuilder.add_bearings(bearings_vector); + intersectionBuilder.add_classes(classes_vector); + intersectionBuilder.add_entry(entry_vector); + intersectionBuilder.add_in_bearing(intersection.in); + intersectionBuilder.add_out_bearing(intersection.out); + intersectionBuilder.add_lanes(lanes_vector); + return intersectionBuilder.Finish(); + }); + return fb_result.CreateVector(intersections); + } + util::json::Object MakeRoute(const std::vector &segment_end_coordinates, const std::vector> &unpacked_path_segments, const std::vector &source_traversed_in_reverse, const std::vector &target_traversed_in_reverse) const { - std::vector legs; - std::vector leg_geometries; - auto number_of_legs = segment_end_coordinates.size(); - legs.reserve(number_of_legs); - leg_geometries.reserve(number_of_legs); - - for (auto idx : util::irange(0UL, number_of_legs)) - { - const auto &phantoms = segment_end_coordinates[idx]; - const auto &path_data = unpacked_path_segments[idx]; - - const bool reversed_source = source_traversed_in_reverse[idx]; - const bool reversed_target = target_traversed_in_reverse[idx]; - - auto leg_geometry = guidance::assembleGeometry(BaseAPI::facade, - path_data, - phantoms.source_phantom, - phantoms.target_phantom, - reversed_source, - reversed_target); - auto leg = guidance::assembleLeg(facade, - path_data, - leg_geometry, - phantoms.source_phantom, - phantoms.target_phantom, - reversed_target, - parameters.steps); - - util::Log(logDEBUG) << "Assembling steps " << std::endl; - if (parameters.steps) - { - auto steps = guidance::assembleSteps(BaseAPI::facade, - path_data, - leg_geometry, - phantoms.source_phantom, - phantoms.target_phantom, - reversed_source, - reversed_target); - - // Apply maneuver overrides before any other post - // processing is performed - guidance::applyOverrides(BaseAPI::facade, steps, leg_geometry); - - // Collapse segregated steps before others - steps = guidance::collapseSegregatedTurnInstructions(std::move(steps)); - - /* Perform step-based post-processing. - * - * Using post-processing on basis of route-steps for a single leg at a time - * comes at the cost that we cannot count the correct exit for roundabouts. - * We can only emit the exit nr/intersections up to/starting at a part of the leg. - * If a roundabout is not terminated in a leg, we will end up with a - *enter-roundabout - * and exit-roundabout-nr where the exit nr is out of sync with the previous enter. - * - * | S | - * * * - * ----* * ---- - * T - * ----* * ---- - * V * * - * | | - * | | - * - * Coming from S via V to T, we end up with the legs S->V and V->T. V-T will say to - *take - * the second exit, even though counting from S it would be the third. - * For S, we only emit `roundabout` without an exit number, showing that we enter a - *roundabout - * to find a via point. - * The same exit will be emitted, though, if we should start routing at S, making - * the overall response consistent. - * - * ⚠ CAUTION: order of post-processing steps is important - * - handleRoundabouts must be called before collapseTurnInstructions that - * expects post-processed roundabouts - */ - - guidance::trimShortSegments(steps, leg_geometry); - leg.steps = guidance::handleRoundabouts(std::move(steps)); - leg.steps = guidance::collapseTurnInstructions(std::move(leg.steps)); - leg.steps = guidance::anticipateLaneChange(std::move(leg.steps)); - leg.steps = guidance::buildIntersections(std::move(leg.steps)); - leg.steps = guidance::suppressShortNameSegments(std::move(leg.steps)); - leg.steps = guidance::assignRelativeLocations(std::move(leg.steps), - leg_geometry, - phantoms.source_phantom, - phantoms.target_phantom); - leg_geometry = guidance::resyncGeometry(std::move(leg_geometry), leg.steps); - } - - leg_geometries.push_back(std::move(leg_geometry)); - legs.push_back(std::move(leg)); - } + auto legs_info = MakeLegs(segment_end_coordinates, + unpacked_path_segments, + source_traversed_in_reverse, + target_traversed_in_reverse); + std::vector legs = legs_info.first; + std::vector leg_geometries = legs_info.second; auto route = guidance::assembleRoute(legs); - boost::optional json_overview; - if (parameters.overview != RouteParameters::OverviewType::False) - { - const auto use_simplification = - parameters.overview == RouteParameters::OverviewType::Simplified; - BOOST_ASSERT(use_simplification || - parameters.overview == RouteParameters::OverviewType::Full); - - auto overview = guidance::assembleOverview(leg_geometries, use_simplification); - json_overview = MakeGeometry(overview.begin(), overview.end()); - } + boost::optional json_overview = + MakeGeometry(MakeOverview(leg_geometries)); std::vector step_geometries; const auto total_step_count = @@ -357,10 +865,131 @@ class RouteAPI : public BaseAPI } const RouteParameters ¶meters; + + std::pair, std::vector> + MakeLegs(const std::vector &segment_end_coordinates, + const std::vector> &unpacked_path_segments, + const std::vector &source_traversed_in_reverse, + const std::vector &target_traversed_in_reverse) const + { + auto result = + std::make_pair(std::vector(), std::vector()); + auto &legs = result.first; + auto &leg_geometries = result.second; + auto number_of_legs = segment_end_coordinates.size(); + legs.reserve(number_of_legs); + leg_geometries.reserve(number_of_legs); + + for (auto idx : util::irange(0UL, number_of_legs)) + { + const auto &phantoms = segment_end_coordinates[idx]; + const auto &path_data = unpacked_path_segments[idx]; + + const bool reversed_source = source_traversed_in_reverse[idx]; + const bool reversed_target = target_traversed_in_reverse[idx]; + + auto leg_geometry = guidance::assembleGeometry(BaseAPI::facade, + path_data, + phantoms.source_phantom, + phantoms.target_phantom, + reversed_source, + reversed_target); + auto leg = guidance::assembleLeg(facade, + path_data, + leg_geometry, + phantoms.source_phantom, + phantoms.target_phantom, + reversed_target, + parameters.steps); + + util::Log(logDEBUG) << "Assembling steps " << std::endl; + if (parameters.steps) + { + auto steps = guidance::assembleSteps(BaseAPI::facade, + path_data, + leg_geometry, + phantoms.source_phantom, + phantoms.target_phantom, + reversed_source, + reversed_target); + + // Apply maneuver overrides before any other post + // processing is performed + guidance::applyOverrides(BaseAPI::facade, steps, leg_geometry); + + // Collapse segregated steps before others + steps = guidance::collapseSegregatedTurnInstructions(std::move(steps)); + + /* Perform step-based post-processing. + * + * Using post-processing on basis of route-steps for a single leg at a time + * comes at the cost that we cannot count the correct exit for roundabouts. + * We can only emit the exit nr/intersections up to/starting at a part of the leg. + * If a roundabout is not terminated in a leg, we will end up with a + *enter-roundabout + * and exit-roundabout-nr where the exit nr is out of sync with the previous enter. + * + * | S | + * * * + * ----* * ---- + * T + * ----* * ---- + * V * * + * | | + * | | + * + * Coming from S via V to T, we end up with the legs S->V and V->T. V-T will say to + *take + * the second exit, even though counting from S it would be the third. + * For S, we only emit `roundabout` without an exit number, showing that we enter a + *roundabout + * to find a via point. + * The same exit will be emitted, though, if we should start routing at S, making + * the overall response consistent. + * + * ⚠ CAUTION: order of post-processing steps is important + * - handleRoundabouts must be called before collapseTurnInstructions that + * expects post-processed roundabouts + */ + + guidance::trimShortSegments(steps, leg_geometry); + leg.steps = guidance::handleRoundabouts(std::move(steps)); + leg.steps = guidance::collapseTurnInstructions(std::move(leg.steps)); + leg.steps = guidance::anticipateLaneChange(std::move(leg.steps)); + leg.steps = guidance::buildIntersections(std::move(leg.steps)); + leg.steps = guidance::suppressShortNameSegments(std::move(leg.steps)); + leg.steps = guidance::assignRelativeLocations(std::move(leg.steps), + leg_geometry, + phantoms.source_phantom, + phantoms.target_phantom); + leg_geometry = guidance::resyncGeometry(std::move(leg_geometry), leg.steps); + } + + leg_geometries.push_back(std::move(leg_geometry)); + legs.push_back(std::move(leg)); + } + return result; + } + + boost::optional> + MakeOverview(const std::vector &leg_geometries) const + { + boost::optional> overview; + if (parameters.overview != RouteParameters::OverviewType::False) + { + const auto use_simplification = + parameters.overview == RouteParameters::OverviewType::Simplified; + BOOST_ASSERT(use_simplification || + parameters.overview == RouteParameters::OverviewType::Full); + + overview = guidance::assembleOverview(leg_geometries, use_simplification); + } + return overview; + } }; -} // ns api -} // ns engine -} // ns osrm +} // namespace api +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/api/route_parameters.hpp b/include/engine/api/route_parameters.hpp index c78ec70ea..8d5dd9ae4 100644 --- a/include/engine/api/route_parameters.hpp +++ b/include/engine/api/route_parameters.hpp @@ -87,18 +87,13 @@ struct RouteParameters : public BaseParameters const GeometriesType geometries_, const OverviewType overview_, const boost::optional continue_straight_, - Args... args_) + Args &&... args_) // Once we perfectly-forward `args` (see #2990) this constructor can delegate to the one // below. - : BaseParameters{std::forward(args_)...}, - steps{steps_}, - alternatives{alternatives_}, - number_of_alternatives{alternatives_ ? 1u : 0u}, - annotations{false}, - annotations_type{AnnotationsType::None}, - geometries{geometries_}, - overview{overview_}, - continue_straight{continue_straight_} + : BaseParameters{std::forward(args_)...}, steps{steps_}, alternatives{alternatives_}, + number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{false}, + annotations_type{AnnotationsType::None}, geometries{geometries_}, overview{overview_}, + continue_straight{continue_straight_}, waypoints() { } @@ -110,11 +105,13 @@ struct RouteParameters : public BaseParameters const GeometriesType geometries_, const OverviewType overview_, const boost::optional continue_straight_, - Args... args_) + Args &&... args_) : BaseParameters{std::forward(args_)...}, steps{steps_}, alternatives{alternatives_}, number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_}, annotations_type{annotations_ ? AnnotationsType::All : AnnotationsType::None}, - geometries{geometries_}, overview{overview_}, continue_straight{continue_straight_} + geometries{geometries_}, overview{overview_}, continue_straight{continue_straight_}, + waypoints() + { } @@ -126,12 +123,48 @@ struct RouteParameters : public BaseParameters const GeometriesType geometries_, const OverviewType overview_, const boost::optional continue_straight_, - Args... args_) + Args &&... args_) : BaseParameters{std::forward(args_)...}, steps{steps_}, alternatives{alternatives_}, number_of_alternatives{alternatives_ ? 1u : 0u}, - annotations{annotations_ == AnnotationsType::None ? false : true}, + annotations{annotations_ != AnnotationsType::None}, annotations_type{annotations_}, + geometries{geometries_}, overview{overview_}, continue_straight{continue_straight_}, + waypoints() + { + } + + // RouteParameters constructor adding the `waypoints` parameter + template + RouteParameters(const bool steps_, + const bool alternatives_, + const bool annotations_, + const GeometriesType geometries_, + const OverviewType overview_, + const boost::optional continue_straight_, + std::vector waypoints_, + const Args &&... args_) + : BaseParameters{std::forward(args_)...}, steps{steps_}, alternatives{alternatives_}, + number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_}, + annotations_type{annotations_ ? AnnotationsType::All : AnnotationsType::None}, + geometries{geometries_}, overview{overview_}, + continue_straight{continue_straight_}, waypoints{std::move(waypoints_)} + { + } + + // RouteParameters constructor adding the `waypoints` parameter + template + RouteParameters(const bool steps_, + const bool alternatives_, + const AnnotationsType annotations_, + const GeometriesType geometries_, + const OverviewType overview_, + const boost::optional continue_straight_, + std::vector waypoints_, + Args &&... args_) + : BaseParameters{std::forward(args_)...}, steps{steps_}, alternatives{alternatives_}, + number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_ != + AnnotationsType::None}, annotations_type{annotations_}, geometries{geometries_}, overview{overview_}, - continue_straight{continue_straight_} + continue_straight{continue_straight_}, waypoints{std::move(waypoints_)} { } @@ -144,12 +177,17 @@ struct RouteParameters : public BaseParameters GeometriesType geometries = GeometriesType::Polyline; OverviewType overview = OverviewType::Simplified; boost::optional continue_straight; + std::vector waypoints; bool IsValid() const { const auto coordinates_ok = coordinates.size() >= 2; const auto base_params_ok = BaseParameters::IsValid(); - return coordinates_ok && base_params_ok; + const auto valid_waypoints = + std::all_of(waypoints.begin(), waypoints.end(), [this](const auto &w) { + return w < coordinates.size(); + }); + return coordinates_ok && base_params_ok && valid_waypoints; } }; @@ -173,8 +211,8 @@ inline RouteParameters::AnnotationsType operator|=(RouteParameters::AnnotationsT { return lhs = lhs | rhs; } -} -} -} +} // namespace api +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/api/table_api.hpp b/include/engine/api/table_api.hpp index 7f94bfbe0..72cdea4e6 100644 --- a/include/engine/api/table_api.hpp +++ b/include/engine/api/table_api.hpp @@ -2,6 +2,7 @@ #define ENGINE_API_TABLE_HPP #include "engine/api/base_api.hpp" +#include "engine/api/base_result.hpp" #include "engine/api/json_factory.hpp" #include "engine/api/table_parameters.hpp" @@ -45,6 +46,126 @@ class TableAPI final : public BaseAPI { } + virtual void + MakeResponse(const std::pair, std::vector> &tables, + const std::vector &phantoms, + const std::vector &fallback_speed_cells, + osrm::engine::api::ResultT &response) const + { + if (response.is()) + { + auto &fb_result = response.get(); + MakeResponse(tables, phantoms, fallback_speed_cells, fb_result); + } + else + { + auto &json_result = response.get(); + MakeResponse(tables, phantoms, fallback_speed_cells, json_result); + } + } + + virtual void + MakeResponse(const std::pair, std::vector> &tables, + const std::vector &phantoms, + const std::vector &fallback_speed_cells, + flatbuffers::FlatBufferBuilder &fb_result) const + { + auto number_of_sources = parameters.sources.size(); + auto number_of_destinations = parameters.destinations.size(); + + auto data_timestamp = facade.GetTimestamp(); + flatbuffers::Offset data_version_string; + if (!data_timestamp.empty()) + { + data_version_string = fb_result.CreateString(data_timestamp); + } + + // symmetric case + flatbuffers::Offset>> sources; + if (parameters.sources.empty()) + { + if (!parameters.skip_waypoints) + { + sources = MakeWaypoints(fb_result, phantoms); + } + number_of_sources = phantoms.size(); + } + else + { + if (!parameters.skip_waypoints) + { + sources = MakeWaypoints(fb_result, phantoms, parameters.sources); + } + } + + flatbuffers::Offset>> + destinations; + if (parameters.destinations.empty()) + { + if (!parameters.skip_waypoints) + { + destinations = MakeWaypoints(fb_result, phantoms); + } + number_of_destinations = phantoms.size(); + } + else + { + if (!parameters.skip_waypoints) + { + destinations = MakeWaypoints(fb_result, phantoms, parameters.destinations); + } + } + + bool use_durations = parameters.annotations & TableParameters::AnnotationsType::Duration; + flatbuffers::Offset> durations; + if (use_durations) + { + durations = MakeDurationTable(fb_result, tables.first); + } + + bool use_distances = parameters.annotations & TableParameters::AnnotationsType::Distance; + flatbuffers::Offset> distances; + if (use_distances) + { + distances = MakeDistanceTable(fb_result, tables.second); + } + + bool have_speed_cells = + parameters.fallback_speed != INVALID_FALLBACK_SPEED && parameters.fallback_speed > 0; + flatbuffers::Offset> speed_cells; + if (have_speed_cells) + { + speed_cells = MakeEstimatesTable(fb_result, fallback_speed_cells); + } + + fbresult::TableBuilder table(fb_result); + table.add_destinations(destinations); + table.add_rows(number_of_sources); + table.add_cols(number_of_destinations); + if (use_durations) + { + table.add_durations(durations); + } + if (use_distances) + { + table.add_distances(distances); + } + if (have_speed_cells) + { + table.add_fallback_speed_cells(speed_cells); + } + auto table_buffer = table.Finish(); + + fbresult::FBResultBuilder response(fb_result); + if (!data_timestamp.empty()) + { + response.add_data_version(data_version_string); + } + response.add_table(table_buffer); + response.add_waypoints(sources); + fb_result.Finish(response.Finish()); + } + virtual void MakeResponse(const std::pair, std::vector> &tables, const std::vector &phantoms, @@ -57,22 +178,34 @@ class TableAPI final : public BaseAPI // symmetric case if (parameters.sources.empty()) { - response.values["sources"] = MakeWaypoints(phantoms); + if (!parameters.skip_waypoints) + { + response.values["sources"] = MakeWaypoints(phantoms); + } number_of_sources = phantoms.size(); } else { - response.values["sources"] = MakeWaypoints(phantoms, parameters.sources); + if (!parameters.skip_waypoints) + { + response.values["sources"] = MakeWaypoints(phantoms, parameters.sources); + } } if (parameters.destinations.empty()) { - response.values["destinations"] = MakeWaypoints(phantoms); + if (!parameters.skip_waypoints) + { + response.values["destinations"] = MakeWaypoints(phantoms); + } number_of_destinations = phantoms.size(); } else { - response.values["destinations"] = MakeWaypoints(phantoms, parameters.destinations); + if (!parameters.skip_waypoints) + { + response.values["destinations"] = MakeWaypoints(phantoms, parameters.destinations); + } } if (parameters.annotations & TableParameters::AnnotationsType::Duration) @@ -96,6 +229,85 @@ class TableAPI final : public BaseAPI } protected: + virtual flatbuffers::Offset>> + MakeWaypoints(flatbuffers::FlatBufferBuilder &builder, + const std::vector &phantoms) const + { + std::vector> waypoints; + waypoints.reserve(phantoms.size()); + BOOST_ASSERT(phantoms.size() == parameters.coordinates.size()); + + boost::range::transform( + phantoms, std::back_inserter(waypoints), [this, &builder](const PhantomNode &phantom) { + return BaseAPI::MakeWaypoint(&builder, phantom)->Finish(); + }); + return builder.CreateVector(waypoints); + } + + virtual flatbuffers::Offset>> + MakeWaypoints(flatbuffers::FlatBufferBuilder &builder, + const std::vector &phantoms, + const std::vector &indices) const + { + std::vector> waypoints; + waypoints.reserve(indices.size()); + boost::range::transform(indices, + std::back_inserter(waypoints), + [this, &builder, phantoms](const std::size_t idx) { + BOOST_ASSERT(idx < phantoms.size()); + return BaseAPI::MakeWaypoint(&builder, phantoms[idx])->Finish(); + }); + return builder.CreateVector(waypoints); + } + + virtual flatbuffers::Offset> + MakeDurationTable(flatbuffers::FlatBufferBuilder &builder, + const std::vector &values) const + { + std::vector distance_table; + distance_table.resize(values.size()); + std::transform( + values.begin(), values.end(), distance_table.begin(), [](const EdgeWeight duration) { + if (duration == MAXIMAL_EDGE_DURATION) + { + return 0.; + } + return duration / 10.; + }); + return builder.CreateVector(distance_table); + } + + virtual flatbuffers::Offset> + MakeDistanceTable(flatbuffers::FlatBufferBuilder &builder, + const std::vector &values) const + { + std::vector duration_table; + duration_table.resize(values.size()); + std::transform( + values.begin(), values.end(), duration_table.begin(), [](const EdgeDistance distance) { + if (distance == INVALID_EDGE_DISTANCE) + { + return 0.; + } + return std::round(distance * 10) / 10.; + }); + return builder.CreateVector(duration_table); + } + + virtual flatbuffers::Offset> + MakeEstimatesTable(flatbuffers::FlatBufferBuilder &builder, + const std::vector &fallback_speed_cells) const + { + std::vector fb_table; + fb_table.reserve(fallback_speed_cells.size()); + std::for_each( + fallback_speed_cells.begin(), fallback_speed_cells.end(), [&](const auto &cell) { + fb_table.push_back(cell.row); + fb_table.push_back(cell.column); + }); + return builder.CreateVector(fb_table); + } + virtual util::json::Array MakeWaypoints(const std::vector &phantoms) const { util::json::Array json_waypoints; @@ -195,8 +407,8 @@ class TableAPI final : public BaseAPI const TableParameters ¶meters; }; -} // ns api -} // ns engine -} // ns osrm +} // namespace api +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/api/table_parameters.hpp b/include/engine/api/table_parameters.hpp index fbbf6831e..30e17900b 100644 --- a/include/engine/api/table_parameters.hpp +++ b/include/engine/api/table_parameters.hpp @@ -85,7 +85,7 @@ struct TableParameters : public BaseParameters template TableParameters(std::vector sources_, std::vector destinations_, - Args... args_) + Args &&... args_) : BaseParameters{std::forward(args_)...}, sources{std::move(sources_)}, destinations{std::move(destinations_)} { @@ -95,7 +95,7 @@ struct TableParameters : public BaseParameters TableParameters(std::vector sources_, std::vector destinations_, const AnnotationsType annotations_, - Args... args_) + Args &&... args_) : BaseParameters{std::forward(args_)...}, sources{std::move(sources_)}, destinations{std::move(destinations_)}, annotations{annotations_} { @@ -108,7 +108,7 @@ struct TableParameters : public BaseParameters double fallback_speed_, FallbackCoordinateType fallback_coordinate_type_, double scale_factor_, - Args... args_) + Args &&... args_) : BaseParameters{std::forward(args_)...}, sources{std::move(sources_)}, destinations{std::move(destinations_)}, fallback_speed{fallback_speed_}, fallback_coordinate_type{fallback_coordinate_type_}, annotations{annotations_}, @@ -122,7 +122,7 @@ struct TableParameters : public BaseParameters if (!BaseParameters::IsValid()) return false; - // Distance Table makes only sense with 2+ coodinates + // Distance Table makes only sense with 2+ coordinates if (coordinates.size() < 2) return false; @@ -166,8 +166,8 @@ inline TableParameters::AnnotationsType &operator|=(TableParameters::Annotations { return lhs = lhs | rhs; } -} -} -} +} // namespace api +} // namespace engine +} // namespace osrm #endif // ENGINE_API_TABLE_PARAMETERS_HPP diff --git a/include/engine/api/tile_parameters.hpp b/include/engine/api/tile_parameters.hpp index 137c4dac3..e5328e7c7 100644 --- a/include/engine/api/tile_parameters.hpp +++ b/include/engine/api/tile_parameters.hpp @@ -70,8 +70,8 @@ struct TileParameters final return valid_x && valid_y && valid_z; } }; -} -} -} +} // namespace api +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/api/trip_api.hpp b/include/engine/api/trip_api.hpp index b65ac1970..90e5e1391 100644 --- a/include/engine/api/trip_api.hpp +++ b/include/engine/api/trip_api.hpp @@ -24,7 +24,47 @@ class TripAPI final : public RouteAPI : RouteAPI(facade_, parameters_), parameters(parameters_) { } + void MakeResponse(const std::vector> &sub_trips, + const std::vector &sub_routes, + const std::vector &phantoms, + osrm::engine::api::ResultT &response) const + { + BOOST_ASSERT(sub_trips.size() == sub_routes.size()); + if (response.is()) + { + auto &fb_result = response.get(); + MakeResponse(sub_trips, sub_routes, phantoms, fb_result); + } + else + { + auto &json_result = response.get(); + MakeResponse(sub_trips, sub_routes, phantoms, json_result); + } + } + void MakeResponse(const std::vector> &sub_trips, + const std::vector &sub_routes, + const std::vector &phantoms, + flatbuffers::FlatBufferBuilder &fb_result) const + { + auto data_timestamp = facade.GetTimestamp(); + flatbuffers::Offset data_version_string; + if (!data_timestamp.empty()) + { + data_version_string = fb_result.CreateString(data_timestamp); + } + + auto response = + MakeFBResponse(sub_routes, fb_result, [this, &fb_result, &sub_trips, &phantoms]() { + return MakeWaypoints(fb_result, sub_trips, phantoms); + }); + + if (!data_timestamp.empty()) + { + response->add_data_version(data_version_string); + } + fb_result.Finish(response->Finish()); + } void MakeResponse(const std::vector> &sub_trips, const std::vector &sub_routes, const std::vector &phantoms, @@ -33,7 +73,6 @@ class TripAPI final : public RouteAPI auto number_of_routes = sub_trips.size(); util::json::Array routes; routes.values.reserve(number_of_routes); - BOOST_ASSERT(sub_trips.size() == sub_routes.size()); for (auto index : util::irange(0UL, sub_trips.size())) { auto route = MakeRoute(sub_routes[index].segment_end_coordinates, @@ -42,7 +81,10 @@ class TripAPI final : public RouteAPI sub_routes[index].target_traversed_in_reverse); routes.values.push_back(std::move(route)); } - response.values["waypoints"] = MakeWaypoints(sub_trips, phantoms); + if (!parameters.skip_waypoints) + { + response.values["waypoints"] = MakeWaypoints(sub_trips, phantoms); + } response.values["trips"] = std::move(routes); response.values["code"] = "Ok"; } @@ -50,39 +92,57 @@ class TripAPI final : public RouteAPI protected: // FIXME this logic is a little backwards. We should change the output format of the // trip plugin routing algorithm to be easier to consume here. + + struct TripIndex + { + TripIndex() = default; + + TripIndex(unsigned sub_trip_index_, unsigned point_index_) + : sub_trip_index(sub_trip_index_), point_index(point_index_) + { + } + + unsigned sub_trip_index = std::numeric_limits::max(); + unsigned point_index = std::numeric_limits::max(); + + bool NotUsed() + { + return sub_trip_index == std::numeric_limits::max() && + point_index == std::numeric_limits::max(); + } + }; + + flatbuffers::Offset>> + MakeWaypoints(flatbuffers::FlatBufferBuilder &fb_result, + const std::vector> &sub_trips, + const std::vector &phantoms) const + { + std::vector> waypoints; + waypoints.reserve(parameters.coordinates.size()); + + auto input_idx_to_trip_idx = MakeTripIndices(sub_trips); + + for (auto input_index : util::irange(0UL, parameters.coordinates.size())) + { + auto trip_index = input_idx_to_trip_idx[input_index]; + BOOST_ASSERT(!trip_index.NotUsed()); + + auto waypoint = BaseAPI::MakeWaypoint(&fb_result, phantoms[input_index]); + waypoint->add_waypoint_index(trip_index.point_index); + waypoint->add_trips_index(trip_index.sub_trip_index); + waypoints.push_back(waypoint->Finish()); + } + + return fb_result.CreateVector(waypoints); + } + util::json::Array MakeWaypoints(const std::vector> &sub_trips, const std::vector &phantoms) const { util::json::Array waypoints; waypoints.values.reserve(parameters.coordinates.size()); - struct TripIndex - { - TripIndex() = default; - TripIndex(unsigned sub_trip_index_, unsigned point_index_) - : sub_trip_index(sub_trip_index_), point_index(point_index_) - { - } - - unsigned sub_trip_index = std::numeric_limits::max(); - unsigned point_index = std::numeric_limits::max(); - - bool NotUsed() - { - return sub_trip_index == std::numeric_limits::max() && - point_index == std::numeric_limits::max(); - } - }; - - std::vector input_idx_to_trip_idx(parameters.coordinates.size()); - for (auto sub_trip_index : util::irange(0u, sub_trips.size())) - { - for (auto point_index : util::irange(0u, sub_trips[sub_trip_index].size())) - { - input_idx_to_trip_idx[sub_trips[sub_trip_index][point_index]] = - TripIndex{sub_trip_index, point_index}; - } - } + auto input_idx_to_trip_idx = MakeTripIndices(sub_trips); for (auto input_index : util::irange(0UL, parameters.coordinates.size())) { @@ -98,11 +158,25 @@ class TripAPI final : public RouteAPI return waypoints; } + std::vector MakeTripIndices(const std::vector> &sub_trips) const + { + std::vector input_idx_to_trip_idx(parameters.coordinates.size()); + for (auto sub_trip_index : util::irange(0u, sub_trips.size())) + { + for (auto point_index : util::irange(0u, sub_trips[sub_trip_index].size())) + { + input_idx_to_trip_idx[sub_trips[sub_trip_index][point_index]] = + TripIndex{sub_trip_index, point_index}; + } + } + return input_idx_to_trip_idx; + } + const TripParameters ¶meters; }; -} // ns api -} // ns engine -} // ns osrm +} // namespace api +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/api/trip_parameters.hpp b/include/engine/api/trip_parameters.hpp index 0df38d6c9..84d6b861a 100644 --- a/include/engine/api/trip_parameters.hpp +++ b/include/engine/api/trip_parameters.hpp @@ -65,8 +65,8 @@ struct TripParameters : public RouteParameters DestinationType destination_, bool roundtrip_, Args &&... args_) - : RouteParameters{std::forward(args_)...}, source{source_}, destination{destination_}, - roundtrip{roundtrip_} + : RouteParameters{std::forward(args_)...}, source{source_}, + destination{destination_}, roundtrip{roundtrip_} { } @@ -76,8 +76,8 @@ struct TripParameters : public RouteParameters bool IsValid() const { return RouteParameters::IsValid(); } }; -} -} -} +} // namespace api +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/approach.hpp b/include/engine/approach.hpp index 5c6787f27..f7d671a9c 100644 --- a/include/engine/approach.hpp +++ b/include/engine/approach.hpp @@ -42,5 +42,5 @@ enum class Approach : std::uint8_t }; } -} +} // namespace osrm #endif diff --git a/include/engine/base64.hpp b/include/engine/base64.hpp index 024d04b29..d1fa8753c 100644 --- a/include/engine/base64.hpp +++ b/include/engine/base64.hpp @@ -38,7 +38,7 @@ using BinaryFromBase64 = boost::archive::iterators::transform_width< 8, // get a view of 8 bit 6 // from a sequence of 6 bit >; -} // ns detail +} // namespace detail namespace engine { @@ -135,7 +135,7 @@ template T decodeBase64Bytewise(const std::string &encoded) return x; } -} // ns engine -} // ns osrm +} // namespace engine +} // namespace osrm #endif /* OSRM_BASE64_HPP */ diff --git a/include/engine/bearing.hpp b/include/engine/bearing.hpp index eaabae781..54e24f57f 100644 --- a/include/engine/bearing.hpp +++ b/include/engine/bearing.hpp @@ -46,7 +46,7 @@ inline bool operator==(const Bearing lhs, const Bearing rhs) return lhs.bearing == rhs.bearing && lhs.range == rhs.range; } inline bool operator!=(const Bearing lhs, const Bearing rhs) { return !(lhs == rhs); } -} -} +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/data_watchdog.hpp b/include/engine/data_watchdog.hpp index b44274545..29fb93443 100644 --- a/include/engine/data_watchdog.hpp +++ b/include/engine/data_watchdog.hpp @@ -56,11 +56,14 @@ class DataWatchdogImpl( - std::make_shared( - std::vector{ - static_region.shm_key, updatable_region.shm_key})); + { + boost::unique_lock swap_lock(factory_mutex); + facade_factory = + DataFacadeFactory( + std::make_shared( + std::vector{ + static_region.shm_key, updatable_region.shm_key})); + } } watcher = std::thread(&DataWatchdogImpl::Run, this); @@ -75,10 +78,14 @@ class DataWatchdogImpl Get(const api::BaseParameters ¶ms) const { + // make sure facade_factory stays stable while we call Get() + boost::shared_lock swap_lock(factory_mutex); return facade_factory.Get(params); } std::shared_ptr Get(const api::TileParameters ¶ms) const { + // make sure facade_factory stays stable while we call Get() + boost::shared_lock swap_lock(factory_mutex); return facade_factory.Get(params); } @@ -111,16 +118,20 @@ class DataWatchdogImpl( - std::make_shared( - std::vector{ - static_region.shm_key, updatable_region.shm_key})); + { + boost::unique_lock swap_lock(factory_mutex); + facade_factory = + DataFacadeFactory( + std::make_shared( + std::vector{ + static_region.shm_key, updatable_region.shm_key})); + } } util::Log() << "DataWatchdog thread stopped"; } + mutable boost::shared_mutex factory_mutex; const std::string dataset_name; storage::SharedMonitor barrier; std::thread watcher; @@ -131,14 +142,14 @@ class DataWatchdogImpl facade_factory; }; -} +} // namespace detail // This class monitors the shared memory region that contains the pointers to // the data and layout regions that should be used. This region is updated // once a new dataset arrives. template class FacadeT> using DataWatchdog = detail::DataWatchdogImpl>; -} -} +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/datafacade.hpp b/include/engine/datafacade.hpp index 76068a472..f0f8e9e5b 100644 --- a/include/engine/datafacade.hpp +++ b/include/engine/datafacade.hpp @@ -11,7 +11,7 @@ namespace engine using DataFacadeBase = datafacade::ContiguousInternalMemoryDataFacadeBase; template using DataFacade = datafacade::ContiguousInternalMemoryDataFacade; -} -} +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/datafacade/algorithm_datafacade.hpp b/include/engine/datafacade/algorithm_datafacade.hpp index a83a5340c..38030511c 100644 --- a/include/engine/datafacade/algorithm_datafacade.hpp +++ b/include/engine/datafacade/algorithm_datafacade.hpp @@ -99,8 +99,8 @@ template <> class AlgorithmDataFacade // searches for a specific edge virtual EdgeID FindEdge(const NodeID from, const NodeID to) const = 0; }; -} -} -} +} // namespace datafacade +} // namespace engine +} // namespace osrm #endif diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index 7aabc704e..988678331 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -137,6 +137,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade extractor::Datasources *m_datasources; std::uint32_t m_check_sum; + StringView m_data_timestamp; util::vector_view m_coordinate_list; extractor::PackedOSMIDsView m_osmnodeid_list; util::vector_view m_lane_description_offsets; @@ -183,6 +184,8 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade m_check_sum = *index.GetBlockPtr("/common/connectivity_checksum"); + m_data_timestamp = make_timestamp_view(index, "/common/timestamp"); + std::tie(m_coordinate_list, m_osmnodeid_list) = make_nbn_data_view(index, "/common/nbn_data"); @@ -386,23 +389,25 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, - const Approach approach) const override final + const Approach approach, + const bool use_all_edges) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( - input_coordinate, approach); + input_coordinate, approach, use_all_edges); } std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const double max_distance, - const Approach approach) const override final + const Approach approach, + const bool use_all_edges) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( - input_coordinate, max_distance, approach); + input_coordinate, max_distance, approach, use_all_edges); } std::pair @@ -410,28 +415,35 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade const double max_distance, const int bearing, const int bearing_range, - const Approach approach) const override final + const Approach approach, + const bool use_all_edges) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( - input_coordinate, max_distance, bearing, bearing_range, approach); + input_coordinate, max_distance, bearing, bearing_range, approach, use_all_edges); } std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const int bearing, const int bearing_range, - const Approach approach) const override final + const Approach approach, + const bool use_all_edges) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( - input_coordinate, bearing, bearing_range, approach); + input_coordinate, bearing, bearing_range, approach, use_all_edges); } std::uint32_t GetCheckSum() const override final { return m_check_sum; } + std::string GetTimestamp() const override final + { + return std::string(m_data_timestamp.begin(), m_data_timestamp.end()); + } + GeometryID GetGeometryIndex(const NodeID id) const override final { return edge_based_node_data.GetGeometryID(id); @@ -597,7 +609,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade auto found_range = std::equal_range( m_maneuver_overrides.begin(), m_maneuver_overrides.end(), edge_based_node_id, Comp{}); - std::for_each(found_range.first, found_range.second, [&](const auto & override) { + std::for_each(found_range.first, found_range.second, [&](const auto &override) { std::vector sequence( m_maneuver_override_node_sequences.begin() + override.node_sequence_offset_begin, m_maneuver_override_node_sequences.begin() + override.node_sequence_offset_end); @@ -748,8 +760,8 @@ class ContiguousInternalMemoryDataFacade final { } }; -} -} -} +} // namespace datafacade +} // namespace engine +} // namespace osrm #endif // CONTIGUOUS_INTERNALMEM_DATAFACADE_HPP diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index 23b2bdae7..b80c93b18 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -74,6 +74,8 @@ class BaseDataFacade virtual std::uint32_t GetCheckSum() const = 0; + virtual std::string GetTimestamp() const = 0; + // node and edge information access virtual util::Coordinate GetCoordinateOfNode(const NodeID id) const = 0; @@ -159,22 +161,26 @@ class BaseDataFacade virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, - const Approach approach) const = 0; + const Approach approach, + const bool use_all_edges) const = 0; virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const double max_distance, - const Approach approach) const = 0; + const Approach approach, + const bool use_all_edges) const = 0; virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const double max_distance, const int bearing, const int bearing_range, - const Approach approach) const = 0; + const Approach approach, + const bool use_all_edges) const = 0; virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const int bearing, const int bearing_range, - const Approach approach) const = 0; + const Approach approach, + const bool use_all_edges = false) const = 0; virtual bool HasLaneData(const EdgeID id) const = 0; virtual util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const = 0; @@ -217,8 +223,8 @@ class BaseDataFacade virtual std::vector GetOverridesThatStartAt(const NodeID edge_based_node_id) const = 0; }; -} -} -} +} // namespace datafacade +} // namespace engine +} // namespace osrm #endif // DATAFACADE_BASE_HPP diff --git a/include/engine/datafacade/mmap_memory_allocator.hpp b/include/engine/datafacade/mmap_memory_allocator.hpp index 60df71e90..fc4b4e24a 100644 --- a/include/engine/datafacade/mmap_memory_allocator.hpp +++ b/include/engine/datafacade/mmap_memory_allocator.hpp @@ -33,7 +33,7 @@ class MMapMemoryAllocator : public ContiguousBlockAllocator private: storage::SharedDataIndex index; - std::vector mapped_memory_files; + std::vector mapped_memory_files; std::string rtree_filename; }; diff --git a/include/engine/datafacade_factory.hpp b/include/engine/datafacade_factory.hpp index a4ff57f38..853716be9 100644 --- a/include/engine/datafacade_factory.hpp +++ b/include/engine/datafacade_factory.hpp @@ -70,7 +70,7 @@ template