Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07746de667 | |||
| feb8da25cd | |||
| 150c792f76 | |||
| dbc52728c3 |
+409
-422
@@ -23,218 +23,218 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
# windows-release-node:
|
||||
# needs: format-taginfo-docs
|
||||
# runs-on: windows-2022
|
||||
# continue-on-error: false
|
||||
# env:
|
||||
# BUILD_TYPE: Release
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# - run: pip install "conan<2.0.0"
|
||||
# - run: conan --version
|
||||
# - run: cmake --version
|
||||
# - uses: actions/setup-node@v4
|
||||
# with:
|
||||
# node-version: 18
|
||||
# - run: node --version
|
||||
# - run: npm --version
|
||||
# - name: Prepare environment
|
||||
# shell: bash
|
||||
# run: |
|
||||
# PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
|
||||
# echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
|
||||
# - run: npm install --ignore-scripts
|
||||
# - run: npm link --ignore-scripts
|
||||
# - name: Build
|
||||
# shell: bash
|
||||
# run: |
|
||||
# mkdir build
|
||||
# cd build
|
||||
# cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CONAN=ON -DENABLE_NODE_BINDINGS=ON ..
|
||||
# cmake --build . --config Release
|
||||
windows-release-node:
|
||||
needs: format-taginfo-docs
|
||||
runs-on: windows-2022
|
||||
continue-on-error: false
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: pip install "conan<2.0.0"
|
||||
- run: conan --version
|
||||
- run: cmake --version
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
- run: node --version
|
||||
- run: npm --version
|
||||
- name: Prepare environment
|
||||
shell: bash
|
||||
run: |
|
||||
PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
|
||||
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
|
||||
- run: npm install --ignore-scripts
|
||||
- run: npm link --ignore-scripts
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CONAN=ON -DENABLE_NODE_BINDINGS=ON ..
|
||||
cmake --build . --config Release
|
||||
|
||||
# # TODO: MSVC goes out of memory when building our tests
|
||||
# # - name: Run tests
|
||||
# # shell: bash
|
||||
# # run: |
|
||||
# # cd build
|
||||
# # cmake --build . --config Release --target tests
|
||||
# # # TODO: run tests
|
||||
# # - name: Run node tests
|
||||
# # shell: bash
|
||||
# # run: |
|
||||
# # ./lib/binding/osrm-extract.exe -p profiles/car.lua test/data/monaco.osm.pbf
|
||||
# TODO: MSVC goes out of memory when building our tests
|
||||
# - name: Run tests
|
||||
# shell: bash
|
||||
# run: |
|
||||
# cd build
|
||||
# cmake --build . --config Release --target tests
|
||||
# # TODO: run tests
|
||||
# - name: Run node tests
|
||||
# shell: bash
|
||||
# run: |
|
||||
# ./lib/binding/osrm-extract.exe -p profiles/car.lua test/data/monaco.osm.pbf
|
||||
|
||||
# # mkdir -p test/data/ch
|
||||
# # cp test/data/monaco.osrm* test/data/ch/
|
||||
# # ./lib/binding/osrm-contract.exe test/data/ch/monaco.osrm
|
||||
# mkdir -p test/data/ch
|
||||
# cp test/data/monaco.osrm* test/data/ch/
|
||||
# ./lib/binding/osrm-contract.exe test/data/ch/monaco.osrm
|
||||
|
||||
# # ./lib/binding/osrm-datastore.exe test/data/ch/monaco.osrm
|
||||
# # node test/nodejs/index.js
|
||||
# - name: Build Node package
|
||||
# shell: bash
|
||||
# run: ./scripts/ci/node_package.sh
|
||||
# - name: Publish Node package
|
||||
# if: ${{ env.PUBLISH == 'On' }}
|
||||
# uses: ncipollo/release-action@v1
|
||||
# with:
|
||||
# allowUpdates: true
|
||||
# artifactErrorsFailBuild: true
|
||||
# artifacts: build/stage/**/*.tar.gz
|
||||
# omitBody: true
|
||||
# omitBodyDuringUpdate: true
|
||||
# omitName: true
|
||||
# omitNameDuringUpdate: true
|
||||
# replacesArtifacts: true
|
||||
# token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# ./lib/binding/osrm-datastore.exe test/data/ch/monaco.osrm
|
||||
# node test/nodejs/index.js
|
||||
- name: Build Node package
|
||||
shell: bash
|
||||
run: ./scripts/ci/node_package.sh
|
||||
- name: Publish Node package
|
||||
if: ${{ env.PUBLISH == 'On' }}
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
allowUpdates: true
|
||||
artifactErrorsFailBuild: true
|
||||
artifacts: build/stage/**/*.tar.gz
|
||||
omitBody: true
|
||||
omitBodyDuringUpdate: true
|
||||
omitName: true
|
||||
omitNameDuringUpdate: true
|
||||
replacesArtifacts: true
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# format-taginfo-docs:
|
||||
# runs-on: ubuntu-22.04
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# - name: Use Node.js
|
||||
# uses: actions/setup-node@v4
|
||||
# with:
|
||||
# node-version: 18
|
||||
# - name: Enable Node.js cache
|
||||
# uses: actions/cache@v4
|
||||
# with:
|
||||
# path: ~/.npm
|
||||
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
# restore-keys: |
|
||||
# ${{ runner.os }}-node-
|
||||
# - name: Prepare environment
|
||||
# run: |
|
||||
# npm ci --ignore-scripts
|
||||
# clang-format-15 --version
|
||||
# - name: Run checks
|
||||
# run: |
|
||||
# ./scripts/check_taginfo.py taginfo.json profiles/car.lua
|
||||
# ./scripts/format.sh && ./scripts/error_on_dirty.sh
|
||||
# node ./scripts/validate_changelog.js
|
||||
# npm run docs && ./scripts/error_on_dirty.sh
|
||||
# npm audit --production
|
||||
format-taginfo-docs:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
- name: Enable Node.js cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
- name: Prepare environment
|
||||
run: |
|
||||
npm ci --ignore-scripts
|
||||
clang-format-15 --version
|
||||
- name: Run checks
|
||||
run: |
|
||||
./scripts/check_taginfo.py taginfo.json profiles/car.lua
|
||||
./scripts/format.sh && ./scripts/error_on_dirty.sh
|
||||
node ./scripts/validate_changelog.js
|
||||
npm run docs && ./scripts/error_on_dirty.sh
|
||||
npm audit --production
|
||||
|
||||
# docker-image-matrix:
|
||||
# strategy:
|
||||
# matrix:
|
||||
# docker-base-image: ["debian", "alpine"]
|
||||
# needs: format-taginfo-docs
|
||||
# runs-on: ubuntu-22.04
|
||||
# continue-on-error: false
|
||||
# steps:
|
||||
# - name: Check out the repo
|
||||
# uses: actions/checkout@v4
|
||||
# - name: Enable osm.pbf cache
|
||||
# uses: actions/cache@v4
|
||||
# with:
|
||||
# path: berlin-latest.osm.pbf
|
||||
# key: v1-berlin-osm-pbf
|
||||
# restore-keys: |
|
||||
# v1-berlin-osm-pbf
|
||||
# - name: Docker build
|
||||
# run: |
|
||||
# docker build -t osrm-backend-local -f docker/Dockerfile-${{ matrix.docker-base-image }} .
|
||||
# - name: Test Docker image
|
||||
# run: |
|
||||
# if [ ! -f "${PWD}/berlin-latest.osm.pbf" ]; then
|
||||
# wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
|
||||
# fi
|
||||
# TAG=osrm-backend-local
|
||||
# # when `--memory-swap` value equals `--memory` it means container won't use swap
|
||||
# # see https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details
|
||||
# MEMORY_ARGS="--memory=1g --memory-swap=1g"
|
||||
# docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-extract --dump-nbg-graph -p /opt/car.lua /data/berlin-latest.osm.pbf
|
||||
# docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-components /data/berlin-latest.osrm.nbg /data/berlin-latest.geojson
|
||||
# if [ ! -s "${PWD}/berlin-latest.geojson" ]
|
||||
# then
|
||||
# >&2 echo "No berlin-latest.geojson found"
|
||||
# exit 1
|
||||
# fi
|
||||
# # removing `.osrm.nbg` to check that whole pipeline works without it
|
||||
# rm -rf "${PWD}/berlin-latest.osrm.nbg"
|
||||
docker-image-matrix:
|
||||
strategy:
|
||||
matrix:
|
||||
docker-base-image: ["debian", "alpine"]
|
||||
needs: format-taginfo-docs
|
||||
runs-on: ubuntu-22.04
|
||||
continue-on-error: false
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v4
|
||||
- name: Enable osm.pbf cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: berlin-latest.osm.pbf
|
||||
key: v1-berlin-osm-pbf
|
||||
restore-keys: |
|
||||
v1-berlin-osm-pbf
|
||||
- name: Docker build
|
||||
run: |
|
||||
docker build -t osrm-backend-local -f docker/Dockerfile-${{ matrix.docker-base-image }} .
|
||||
- name: Test Docker image
|
||||
run: |
|
||||
if [ ! -f "${PWD}/berlin-latest.osm.pbf" ]; then
|
||||
wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
|
||||
fi
|
||||
TAG=osrm-backend-local
|
||||
# when `--memory-swap` value equals `--memory` it means container won't use swap
|
||||
# see https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details
|
||||
MEMORY_ARGS="--memory=1g --memory-swap=1g"
|
||||
docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-extract --dump-nbg-graph -p /opt/car.lua /data/berlin-latest.osm.pbf
|
||||
docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-components /data/berlin-latest.osrm.nbg /data/berlin-latest.geojson
|
||||
if [ ! -s "${PWD}/berlin-latest.geojson" ]
|
||||
then
|
||||
>&2 echo "No berlin-latest.geojson found"
|
||||
exit 1
|
||||
fi
|
||||
# removing `.osrm.nbg` to check that whole pipeline works without it
|
||||
rm -rf "${PWD}/berlin-latest.osrm.nbg"
|
||||
|
||||
# docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-partition /data/berlin-latest.osrm
|
||||
# docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-customize /data/berlin-latest.osrm
|
||||
# docker run $MEMORY_ARGS --name=osrm-container -t -p 5000:5000 -v "${PWD}:/data" "${TAG}" osrm-routed --algorithm mld /data/berlin-latest.osrm &
|
||||
# curl --retry-delay 3 --retry 10 --retry-all-errors "http://127.0.0.1:5000/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true"
|
||||
# docker stop osrm-container
|
||||
docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-partition /data/berlin-latest.osrm
|
||||
docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-customize /data/berlin-latest.osrm
|
||||
docker run $MEMORY_ARGS --name=osrm-container -t -p 5000:5000 -v "${PWD}:/data" "${TAG}" osrm-routed --algorithm mld /data/berlin-latest.osrm &
|
||||
curl --retry-delay 3 --retry 10 --retry-all-errors "http://127.0.0.1:5000/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true"
|
||||
docker stop osrm-container
|
||||
|
||||
build-test-publish:
|
||||
#needs: format-taginfo-docs
|
||||
needs: format-taginfo-docs
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# - name: gcc-13-debug-cov
|
||||
# continue-on-error: false
|
||||
# node: 20
|
||||
# runs-on: ubuntu-24.04
|
||||
# BUILD_TOOLS: ON
|
||||
# BUILD_TYPE: Debug
|
||||
# CCOMPILER: gcc-13
|
||||
# CUCUMBER_TIMEOUT: 20000
|
||||
# CXXCOMPILER: g++-13
|
||||
# ENABLE_COVERAGE: ON
|
||||
- name: gcc-13-debug-cov
|
||||
continue-on-error: false
|
||||
node: 20
|
||||
runs-on: ubuntu-24.04
|
||||
BUILD_TOOLS: ON
|
||||
BUILD_TYPE: Debug
|
||||
CCOMPILER: gcc-13
|
||||
CUCUMBER_TIMEOUT: 20000
|
||||
CXXCOMPILER: g++-13
|
||||
ENABLE_COVERAGE: ON
|
||||
|
||||
# - name: clang-18-debug-asan-ubsan
|
||||
# continue-on-error: false
|
||||
# node: 20
|
||||
# runs-on: ubuntu-24.04
|
||||
# BUILD_TOOLS: ON
|
||||
# BUILD_TYPE: Debug
|
||||
# CCOMPILER: clang-18
|
||||
# CUCUMBER_TIMEOUT: 20000
|
||||
# CXXCOMPILER: clang++-18
|
||||
# ENABLE_SANITIZER: ON
|
||||
# TARGET_ARCH: x86_64-asan-ubsan
|
||||
# OSRM_CONNECTION_RETRIES: 10
|
||||
# OSRM_CONNECTION_EXP_BACKOFF_COEF: 1.5
|
||||
- name: clang-18-debug-asan-ubsan
|
||||
continue-on-error: false
|
||||
node: 20
|
||||
runs-on: ubuntu-24.04
|
||||
BUILD_TOOLS: ON
|
||||
BUILD_TYPE: Debug
|
||||
CCOMPILER: clang-18
|
||||
CUCUMBER_TIMEOUT: 20000
|
||||
CXXCOMPILER: clang++-18
|
||||
ENABLE_SANITIZER: ON
|
||||
TARGET_ARCH: x86_64-asan-ubsan
|
||||
OSRM_CONNECTION_RETRIES: 10
|
||||
OSRM_CONNECTION_EXP_BACKOFF_COEF: 1.5
|
||||
|
||||
# - name: clang-18-release
|
||||
# continue-on-error: false
|
||||
# node: 18
|
||||
# runs-on: ubuntu-24.04
|
||||
# BUILD_TOOLS: ON
|
||||
# BUILD_TYPE: Release
|
||||
# CCOMPILER: clang-18
|
||||
# CXXCOMPILER: clang++-18
|
||||
# CUCUMBER_TIMEOUT: 60000
|
||||
# ENABLE_LTO: OFF
|
||||
- name: clang-18-release
|
||||
continue-on-error: false
|
||||
node: 18
|
||||
runs-on: ubuntu-24.04
|
||||
BUILD_TOOLS: ON
|
||||
BUILD_TYPE: Release
|
||||
CCOMPILER: clang-18
|
||||
CXXCOMPILER: clang++-18
|
||||
CUCUMBER_TIMEOUT: 60000
|
||||
ENABLE_LTO: OFF
|
||||
|
||||
# - name: clang-18-debug
|
||||
# continue-on-error: false
|
||||
# node: 18
|
||||
# runs-on: ubuntu-24.04
|
||||
# BUILD_TOOLS: ON
|
||||
# BUILD_TYPE: Debug
|
||||
# CCOMPILER: clang-18
|
||||
# CXXCOMPILER: clang++-18
|
||||
# CUCUMBER_TIMEOUT: 60000
|
||||
# ENABLE_LTO: OFF
|
||||
- name: clang-18-debug
|
||||
continue-on-error: false
|
||||
node: 18
|
||||
runs-on: ubuntu-24.04
|
||||
BUILD_TOOLS: ON
|
||||
BUILD_TYPE: Debug
|
||||
CCOMPILER: clang-18
|
||||
CXXCOMPILER: clang++-18
|
||||
CUCUMBER_TIMEOUT: 60000
|
||||
ENABLE_LTO: OFF
|
||||
|
||||
# - name: clang-18-debug-clang-tidy
|
||||
# continue-on-error: false
|
||||
# node: 18
|
||||
# runs-on: ubuntu-24.04
|
||||
# BUILD_TOOLS: ON
|
||||
# BUILD_TYPE: Debug
|
||||
# CCOMPILER: clang-18
|
||||
# CXXCOMPILER: clang++-18
|
||||
# CUCUMBER_TIMEOUT: 60000
|
||||
# ENABLE_CLANG_TIDY: ON
|
||||
- name: clang-18-debug-clang-tidy
|
||||
continue-on-error: false
|
||||
node: 18
|
||||
runs-on: ubuntu-24.04
|
||||
BUILD_TOOLS: ON
|
||||
BUILD_TYPE: Debug
|
||||
CCOMPILER: clang-18
|
||||
CXXCOMPILER: clang++-18
|
||||
CUCUMBER_TIMEOUT: 60000
|
||||
ENABLE_CLANG_TIDY: ON
|
||||
|
||||
|
||||
# - name: clang-17-release
|
||||
# continue-on-error: false
|
||||
# node: 18
|
||||
# runs-on: ubuntu-24.04
|
||||
# BUILD_TOOLS: ON
|
||||
# BUILD_TYPE: Release
|
||||
# CCOMPILER: clang-17
|
||||
# CXXCOMPILER: clang++-17
|
||||
# CUCUMBER_TIMEOUT: 60000
|
||||
# ENABLE_LTO: OFF
|
||||
- name: clang-17-release
|
||||
continue-on-error: false
|
||||
node: 18
|
||||
runs-on: ubuntu-24.04
|
||||
BUILD_TOOLS: ON
|
||||
BUILD_TYPE: Release
|
||||
CCOMPILER: clang-17
|
||||
CXXCOMPILER: clang++-17
|
||||
CUCUMBER_TIMEOUT: 60000
|
||||
ENABLE_LTO: OFF
|
||||
|
||||
- name: clang-16-release
|
||||
continue-on-error: false
|
||||
@@ -247,104 +247,104 @@ jobs:
|
||||
CUCUMBER_TIMEOUT: 60000
|
||||
ENABLE_LTO: OFF
|
||||
|
||||
# - name: conan-linux-debug-asan-ubsan
|
||||
# continue-on-error: false
|
||||
# node: 18
|
||||
# runs-on: ubuntu-24.04
|
||||
# BUILD_TOOLS: ON
|
||||
# BUILD_TYPE: Release
|
||||
# CCOMPILER: clang-18
|
||||
# CXXCOMPILER: clang++-18
|
||||
# ENABLE_CONAN: ON
|
||||
# ENABLE_SANITIZER: ON
|
||||
# ENABLE_LTO: OFF
|
||||
- name: conan-linux-debug-asan-ubsan
|
||||
continue-on-error: false
|
||||
node: 18
|
||||
runs-on: ubuntu-24.04
|
||||
BUILD_TOOLS: ON
|
||||
BUILD_TYPE: Release
|
||||
CCOMPILER: clang-18
|
||||
CXXCOMPILER: clang++-18
|
||||
ENABLE_CONAN: ON
|
||||
ENABLE_SANITIZER: ON
|
||||
ENABLE_LTO: OFF
|
||||
|
||||
# - name: conan-linux-release
|
||||
# continue-on-error: false
|
||||
# node: 18
|
||||
# runs-on: ubuntu-24.04
|
||||
# BUILD_TOOLS: ON
|
||||
# BUILD_TYPE: Release
|
||||
# CCOMPILER: clang-18
|
||||
# CXXCOMPILER: clang++-18
|
||||
# ENABLE_CONAN: ON
|
||||
# ENABLE_LTO: OFF
|
||||
- name: conan-linux-release
|
||||
continue-on-error: false
|
||||
node: 18
|
||||
runs-on: ubuntu-24.04
|
||||
BUILD_TOOLS: ON
|
||||
BUILD_TYPE: Release
|
||||
CCOMPILER: clang-18
|
||||
CXXCOMPILER: clang++-18
|
||||
ENABLE_CONAN: ON
|
||||
ENABLE_LTO: OFF
|
||||
|
||||
# - name: gcc-14-release
|
||||
# continue-on-error: false
|
||||
# node: 20
|
||||
# runs-on: ubuntu-24.04
|
||||
# BUILD_TOOLS: ON
|
||||
# BUILD_TYPE: Release
|
||||
# CCOMPILER: gcc-14
|
||||
# CXXCOMPILER: g++-14
|
||||
# CXXFLAGS: '-Wno-array-bounds -Wno-uninitialized'
|
||||
- name: gcc-14-release
|
||||
continue-on-error: false
|
||||
node: 20
|
||||
runs-on: ubuntu-24.04
|
||||
BUILD_TOOLS: ON
|
||||
BUILD_TYPE: Release
|
||||
CCOMPILER: gcc-14
|
||||
CXXCOMPILER: g++-14
|
||||
CXXFLAGS: '-Wno-array-bounds -Wno-uninitialized'
|
||||
|
||||
# - name: gcc-13-release
|
||||
# continue-on-error: false
|
||||
# node: 20
|
||||
# runs-on: ubuntu-24.04
|
||||
# BUILD_TOOLS: ON
|
||||
# BUILD_TYPE: Release
|
||||
# CCOMPILER: gcc-13
|
||||
# CXXCOMPILER: g++-13
|
||||
# CXXFLAGS: '-Wno-array-bounds -Wno-uninitialized'
|
||||
- name: gcc-13-release
|
||||
continue-on-error: false
|
||||
node: 20
|
||||
runs-on: ubuntu-24.04
|
||||
BUILD_TOOLS: ON
|
||||
BUILD_TYPE: Release
|
||||
CCOMPILER: gcc-13
|
||||
CXXCOMPILER: g++-13
|
||||
CXXFLAGS: '-Wno-array-bounds -Wno-uninitialized'
|
||||
|
||||
# - name: gcc-12-release
|
||||
# continue-on-error: false
|
||||
# node: 20
|
||||
# runs-on: ubuntu-22.04
|
||||
# BUILD_TOOLS: ON
|
||||
# BUILD_TYPE: Release
|
||||
# CCOMPILER: gcc-12
|
||||
# CXXCOMPILER: g++-12
|
||||
# CXXFLAGS: '-Wno-array-bounds -Wno-uninitialized'
|
||||
- name: gcc-12-release
|
||||
continue-on-error: false
|
||||
node: 20
|
||||
runs-on: ubuntu-22.04
|
||||
BUILD_TOOLS: ON
|
||||
BUILD_TYPE: Release
|
||||
CCOMPILER: gcc-12
|
||||
CXXCOMPILER: g++-12
|
||||
CXXFLAGS: '-Wno-array-bounds -Wno-uninitialized'
|
||||
|
||||
# - name: conan-linux-release-node
|
||||
# build_node_package: true
|
||||
# continue-on-error: false
|
||||
# node: 20
|
||||
# runs-on: ubuntu-24.04
|
||||
# BUILD_TYPE: Release
|
||||
# CCOMPILER: clang-16
|
||||
# CXXCOMPILER: clang++-16
|
||||
# ENABLE_CONAN: ON
|
||||
# NODE_PACKAGE_TESTS_ONLY: ON
|
||||
- name: conan-linux-release-node
|
||||
build_node_package: true
|
||||
continue-on-error: false
|
||||
node: 20
|
||||
runs-on: ubuntu-24.04
|
||||
BUILD_TYPE: Release
|
||||
CCOMPILER: clang-16
|
||||
CXXCOMPILER: clang++-16
|
||||
ENABLE_CONAN: ON
|
||||
NODE_PACKAGE_TESTS_ONLY: ON
|
||||
|
||||
# - name: conan-linux-debug-node
|
||||
# build_node_package: true
|
||||
# continue-on-error: false
|
||||
# node: 20
|
||||
# runs-on: ubuntu-24.04
|
||||
# BUILD_TYPE: Debug
|
||||
# CCOMPILER: clang-16
|
||||
# CXXCOMPILER: clang++-16
|
||||
# ENABLE_CONAN: ON
|
||||
# NODE_PACKAGE_TESTS_ONLY: ON
|
||||
- name: conan-linux-debug-node
|
||||
build_node_package: true
|
||||
continue-on-error: false
|
||||
node: 20
|
||||
runs-on: ubuntu-24.04
|
||||
BUILD_TYPE: Debug
|
||||
CCOMPILER: clang-16
|
||||
CXXCOMPILER: clang++-16
|
||||
ENABLE_CONAN: ON
|
||||
NODE_PACKAGE_TESTS_ONLY: ON
|
||||
|
||||
# - name: conan-macos-x64-release-node
|
||||
# build_node_package: true
|
||||
# continue-on-error: true
|
||||
# node: 20
|
||||
# runs-on: macos-13 # x86_64
|
||||
# BUILD_TYPE: Release
|
||||
# CCOMPILER: clang
|
||||
# CXXCOMPILER: clang++
|
||||
# CUCUMBER_TIMEOUT: 60000
|
||||
# ENABLE_ASSERTIONS: ON
|
||||
# ENABLE_CONAN: ON
|
||||
- name: conan-macos-x64-release-node
|
||||
build_node_package: true
|
||||
continue-on-error: true
|
||||
node: 20
|
||||
runs-on: macos-13 # x86_64
|
||||
BUILD_TYPE: Release
|
||||
CCOMPILER: clang
|
||||
CXXCOMPILER: clang++
|
||||
CUCUMBER_TIMEOUT: 60000
|
||||
ENABLE_ASSERTIONS: ON
|
||||
ENABLE_CONAN: ON
|
||||
|
||||
# - name: conan-macos-arm64-release-node
|
||||
# build_node_package: true
|
||||
# continue-on-error: true
|
||||
# node: 20
|
||||
# runs-on: macos-14 # arm64
|
||||
# BUILD_TYPE: Release
|
||||
# CCOMPILER: clang
|
||||
# CXXCOMPILER: clang++
|
||||
# CUCUMBER_TIMEOUT: 60000
|
||||
# ENABLE_ASSERTIONS: ON
|
||||
# ENABLE_CONAN: ON
|
||||
- name: conan-macos-arm64-release-node
|
||||
build_node_package: true
|
||||
continue-on-error: true
|
||||
node: 20
|
||||
runs-on: macos-14 # arm64
|
||||
BUILD_TYPE: Release
|
||||
CCOMPILER: clang
|
||||
CXXCOMPILER: clang++
|
||||
CUCUMBER_TIMEOUT: 60000
|
||||
ENABLE_ASSERTIONS: ON
|
||||
ENABLE_CONAN: ON
|
||||
|
||||
name: ${{ matrix.name}}
|
||||
continue-on-error: ${{ matrix.continue-on-error }}
|
||||
@@ -502,13 +502,6 @@ jobs:
|
||||
|
||||
conan config init
|
||||
yq eval '.compiler.clang.version += ["18"]' -i "$HOME/.conan/settings.yml"
|
||||
- name: Add Apple-clang 16 to list of Conan compilers # workaround for the issue that Conan 1.x doesn't know about Apple-clang 16
|
||||
if: ${{ matrix.ENABLE_CONAN == 'ON' && matrix.runs-on == 'macos-14' }}
|
||||
run: |
|
||||
sudo wget https://github.com/mikefarah/yq/releases/download/v4.9.6/yq_darwin_arm64 -O /usr/local/bin/yq && sudo chmod +x /usr/local/bin/yq
|
||||
|
||||
conan config init
|
||||
yq eval '.compiler.apple-clang.version += ["16.0"]' -i "$HOME/.conan/settings.yml"
|
||||
- name: Prepare build
|
||||
run: |
|
||||
mkdir ${OSRM_BUILD_DIR}
|
||||
@@ -575,13 +568,7 @@ jobs:
|
||||
|
||||
# All tests assume to be run from the build directory
|
||||
pushd ${OSRM_BUILD_DIR}
|
||||
for i in $(seq 1 100); do
|
||||
echo "Iteration $i"
|
||||
for test in ./unit_tests/*-tests; do
|
||||
echo "Running $test"
|
||||
$test
|
||||
done
|
||||
done
|
||||
for i in ./unit_tests/*-tests ; do echo Running $i ; $i ; done
|
||||
if [ -z "${ENABLE_SANITIZER}" ]; then
|
||||
npm run nodejs-tests
|
||||
fi
|
||||
@@ -663,130 +650,130 @@ jobs:
|
||||
ccache -p
|
||||
ccache -s
|
||||
|
||||
# benchmarks:
|
||||
# if: github.event_name == 'pull_request'
|
||||
# needs: [format-taginfo-docs]
|
||||
# runs-on: self-hosted
|
||||
# env:
|
||||
# CCOMPILER: clang-16
|
||||
# CXXCOMPILER: clang++-16
|
||||
# CC: clang-16
|
||||
# CXX: clang++-16
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
# GITHUB_REPOSITORY: ${{ github.repository }}
|
||||
# RUN_BIG_BENCHMARK: ${{ contains(github.event.pull_request.labels.*.name, 'Performance') }}
|
||||
# steps:
|
||||
# - name: Checkout PR Branch
|
||||
# uses: actions/checkout@v4
|
||||
# with:
|
||||
# ref: ${{ github.head_ref }}
|
||||
# path: pr
|
||||
# - name: Activate virtualenv
|
||||
# run: |
|
||||
# python3 -m venv .venv
|
||||
# source .venv/bin/activate
|
||||
# echo PATH=$PATH >> $GITHUB_ENV
|
||||
# pip install "conan<2.0.0" "requests==2.31.0" "numpy==1.26.4"
|
||||
# - name: Prepare data
|
||||
# run: |
|
||||
# if [ "$RUN_BIG_BENCHMARK" = "true" ]; then
|
||||
# rm -rf ~/data.osm.pbf
|
||||
# wget http://download.geofabrik.de/europe/poland-latest.osm.pbf -O ~/data.osm.pbf --quiet
|
||||
# gunzip -c ./pr/test/data/poland_gps_traces.csv.gz > ~/gps_traces.csv
|
||||
# else
|
||||
# if [ ! -f "~/data.osm.pbf" ]; then
|
||||
# wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf -O ~/data.osm.pbf
|
||||
# else
|
||||
# echo "Using cached data.osm.pbf"
|
||||
# fi
|
||||
# gunzip -c ./pr/test/data/berlin_gps_traces.csv.gz > ~/gps_traces.csv
|
||||
# fi
|
||||
# - name: Prepare environment
|
||||
# run: |
|
||||
# echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
|
||||
# mkdir -p $HOME/.ccache
|
||||
# ccache --zero-stats
|
||||
# ccache --max-size=256M
|
||||
# - name: Checkout Base Branch
|
||||
# uses: actions/checkout@v4
|
||||
# with:
|
||||
# ref: ${{ github.event.pull_request.base.ref }}
|
||||
# path: base
|
||||
# - name: Build Base Branch
|
||||
# run: |
|
||||
# cd base
|
||||
# npm ci --ignore-scripts
|
||||
# cd ..
|
||||
# mkdir base/build
|
||||
# cd base/build
|
||||
# cmake -DENABLE_CONAN=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_NODE_BINDINGS=ON ..
|
||||
# make -j$(nproc)
|
||||
# make -j$(nproc) benchmarks
|
||||
# cd ..
|
||||
# make -C test/data
|
||||
# - name: Build PR Branch
|
||||
# run: |
|
||||
# cd pr
|
||||
# npm ci --ignore-scripts
|
||||
# cd ..
|
||||
# mkdir -p pr/build
|
||||
# cd pr/build
|
||||
# cmake -DENABLE_CONAN=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_NODE_BINDINGS=ON ..
|
||||
# make -j$(nproc)
|
||||
# make -j$(nproc) benchmarks
|
||||
# cd ..
|
||||
# make -C test/data
|
||||
# # we run benchmarks in tmpfs to avoid impact of disk IO
|
||||
# - name: Create folder for tmpfs
|
||||
# run: |
|
||||
# # if by any chance it was mounted before(e.g. due to previous job failed), unmount it
|
||||
# sudo umount ~/benchmarks | true
|
||||
# rm -rf ~/benchmarks
|
||||
# mkdir -p ~/benchmarks
|
||||
# # see https://llvm.org/docs/Benchmarking.html
|
||||
# - name: Run PR Benchmarks
|
||||
# run: |
|
||||
# sudo cset shield -c 2-3 -k on
|
||||
# sudo mount -t tmpfs -o size=4g none ~/benchmarks
|
||||
# cp -rf pr/build ~/benchmarks/build
|
||||
# cp -rf pr/lib ~/benchmarks/lib
|
||||
# mkdir -p ~/benchmarks/test
|
||||
# cp -rf pr/test/data ~/benchmarks/test/data
|
||||
# cp -rf pr/profiles ~/benchmarks/profiles
|
||||
benchmarks:
|
||||
if: github.event_name == 'pull_request'
|
||||
needs: [format-taginfo-docs]
|
||||
runs-on: self-hosted
|
||||
env:
|
||||
CCOMPILER: clang-16
|
||||
CXXCOMPILER: clang++-16
|
||||
CC: clang-16
|
||||
CXX: clang++-16
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
||||
RUN_BIG_BENCHMARK: ${{ contains(github.event.pull_request.labels.*.name, 'Performance') }}
|
||||
steps:
|
||||
- name: Checkout PR Branch
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
path: pr
|
||||
- name: Activate virtualenv
|
||||
run: |
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
echo PATH=$PATH >> $GITHUB_ENV
|
||||
pip install "conan<2.0.0" "requests==2.31.0" "numpy==1.26.4"
|
||||
- name: Prepare data
|
||||
run: |
|
||||
if [ "$RUN_BIG_BENCHMARK" = "true" ]; then
|
||||
rm -rf ~/data.osm.pbf
|
||||
wget http://download.geofabrik.de/europe/poland-latest.osm.pbf -O ~/data.osm.pbf --quiet
|
||||
gunzip -c ./pr/test/data/poland_gps_traces.csv.gz > ~/gps_traces.csv
|
||||
else
|
||||
if [ ! -f "~/data.osm.pbf" ]; then
|
||||
wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf -O ~/data.osm.pbf
|
||||
else
|
||||
echo "Using cached data.osm.pbf"
|
||||
fi
|
||||
gunzip -c ./pr/test/data/berlin_gps_traces.csv.gz > ~/gps_traces.csv
|
||||
fi
|
||||
- name: Prepare environment
|
||||
run: |
|
||||
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
|
||||
mkdir -p $HOME/.ccache
|
||||
ccache --zero-stats
|
||||
ccache --max-size=256M
|
||||
- name: Checkout Base Branch
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.base.ref }}
|
||||
path: base
|
||||
- name: Build Base Branch
|
||||
run: |
|
||||
cd base
|
||||
npm ci --ignore-scripts
|
||||
cd ..
|
||||
mkdir base/build
|
||||
cd base/build
|
||||
cmake -DENABLE_CONAN=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_NODE_BINDINGS=ON ..
|
||||
make -j$(nproc)
|
||||
make -j$(nproc) benchmarks
|
||||
cd ..
|
||||
make -C test/data
|
||||
- name: Build PR Branch
|
||||
run: |
|
||||
cd pr
|
||||
npm ci --ignore-scripts
|
||||
cd ..
|
||||
mkdir -p pr/build
|
||||
cd pr/build
|
||||
cmake -DENABLE_CONAN=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_NODE_BINDINGS=ON ..
|
||||
make -j$(nproc)
|
||||
make -j$(nproc) benchmarks
|
||||
cd ..
|
||||
make -C test/data
|
||||
# we run benchmarks in tmpfs to avoid impact of disk IO
|
||||
- name: Create folder for tmpfs
|
||||
run: |
|
||||
# if by any chance it was mounted before(e.g. due to previous job failed), unmount it
|
||||
sudo umount ~/benchmarks | true
|
||||
rm -rf ~/benchmarks
|
||||
mkdir -p ~/benchmarks
|
||||
# see https://llvm.org/docs/Benchmarking.html
|
||||
- name: Run PR Benchmarks
|
||||
run: |
|
||||
sudo cset shield -c 2-3 -k on
|
||||
sudo mount -t tmpfs -o size=4g none ~/benchmarks
|
||||
cp -rf pr/build ~/benchmarks/build
|
||||
cp -rf pr/lib ~/benchmarks/lib
|
||||
mkdir -p ~/benchmarks/test
|
||||
cp -rf pr/test/data ~/benchmarks/test/data
|
||||
cp -rf pr/profiles ~/benchmarks/profiles
|
||||
|
||||
# sudo cset shield --exec -- ./pr/scripts/ci/run_benchmarks.sh -f ~/benchmarks -r $(pwd)/pr_results -s $(pwd)/pr -b ~/benchmarks/build -o ~/data.osm.pbf -g ~/gps_traces.csv
|
||||
# sudo umount ~/benchmarks
|
||||
# sudo cset shield --reset
|
||||
# - name: Run Base Benchmarks
|
||||
# run: |
|
||||
# sudo cset shield -c 2-3 -k on
|
||||
# sudo mount -t tmpfs -o size=4g none ~/benchmarks
|
||||
# cp -rf base/build ~/benchmarks/build
|
||||
# cp -rf base/lib ~/benchmarks/lib
|
||||
# mkdir -p ~/benchmarks/test
|
||||
# cp -rf base/test/data ~/benchmarks/test/data
|
||||
# cp -rf base/profiles ~/benchmarks/profiles
|
||||
sudo cset shield --exec -- ./pr/scripts/ci/run_benchmarks.sh -f ~/benchmarks -r $(pwd)/pr_results -s $(pwd)/pr -b ~/benchmarks/build -o ~/data.osm.pbf -g ~/gps_traces.csv
|
||||
sudo umount ~/benchmarks
|
||||
sudo cset shield --reset
|
||||
- name: Run Base Benchmarks
|
||||
run: |
|
||||
sudo cset shield -c 2-3 -k on
|
||||
sudo mount -t tmpfs -o size=4g none ~/benchmarks
|
||||
cp -rf base/build ~/benchmarks/build
|
||||
cp -rf base/lib ~/benchmarks/lib
|
||||
mkdir -p ~/benchmarks/test
|
||||
cp -rf base/test/data ~/benchmarks/test/data
|
||||
cp -rf base/profiles ~/benchmarks/profiles
|
||||
|
||||
# # TODO: remove it when base branch will have this file at needed location
|
||||
# if [ ! -f ~/benchmarks/test/data/portugal_to_korea.json ]; then
|
||||
# cp base/src/benchmarks/portugal_to_korea.json ~/benchmarks/test/data/portugal_to_korea.json
|
||||
# fi
|
||||
# # we intentionally use scripts from PR branch to be able to update them and see results in the same PR
|
||||
# sudo cset shield --exec -- cset shield --exec -- ./pr/scripts/ci/run_benchmarks.sh -f ~/benchmarks -r $(pwd)/base_results -s $(pwd)/pr -b ~/benchmarks/build -o ~/data.osm.pbf -g ~/gps_traces.csv
|
||||
# sudo umount ~/benchmarks
|
||||
# sudo cset shield --reset
|
||||
# - name: Post Benchmark Results
|
||||
# run: |
|
||||
# python3 pr/scripts/ci/post_benchmark_results.py base_results pr_results
|
||||
# - name: Show CCache statistics
|
||||
# run: |
|
||||
# ccache -p
|
||||
# ccache -s
|
||||
# TODO: remove it when base branch will have this file at needed location
|
||||
if [ ! -f ~/benchmarks/test/data/portugal_to_korea.json ]; then
|
||||
cp base/src/benchmarks/portugal_to_korea.json ~/benchmarks/test/data/portugal_to_korea.json
|
||||
fi
|
||||
# we intentionally use scripts from PR branch to be able to update them and see results in the same PR
|
||||
sudo cset shield --exec -- cset shield --exec -- ./pr/scripts/ci/run_benchmarks.sh -f ~/benchmarks -r $(pwd)/base_results -s $(pwd)/pr -b ~/benchmarks/build -o ~/data.osm.pbf -g ~/gps_traces.csv
|
||||
sudo umount ~/benchmarks
|
||||
sudo cset shield --reset
|
||||
- name: Post Benchmark Results
|
||||
run: |
|
||||
python3 pr/scripts/ci/post_benchmark_results.py base_results pr_results
|
||||
- name: Show CCache statistics
|
||||
run: |
|
||||
ccache -p
|
||||
ccache -s
|
||||
|
||||
# ci-complete:
|
||||
# runs-on: ubuntu-22.04
|
||||
# needs: [build-test-publish, docker-image-matrix, windows-release-node, benchmarks]
|
||||
# steps:
|
||||
# - run: echo "CI complete"
|
||||
ci-complete:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: [build-test-publish, docker-image-matrix, windows-release-node, benchmarks]
|
||||
steps:
|
||||
- run: echo "CI complete"
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
- NodeJS:
|
||||
- CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452)
|
||||
- Misc:
|
||||
- CHANGED: Use std::string_view for key type in json::Object. [#7062](https://github.com/Project-OSRM/osrm-backend/pull/7062)
|
||||
- CHANGED: Use thread_local instead of boost::thread_specific_ptr. [#6991](https://github.com/Project-OSRM/osrm-backend/pull/6991)
|
||||
- CHANGED: Bump flatbuffers to v24.3.25 version. [#6988](https://github.com/Project-OSRM/osrm-backend/pull/6988)
|
||||
- CHANGED: Add .reserve(...) to assembleGeometry function. [#6983](https://github.com/Project-OSRM/osrm-backend/pull/6983)
|
||||
@@ -80,7 +79,6 @@
|
||||
- ADDED: Extract prerelease/build information from package semver [#6839](https://github.com/Project-OSRM/osrm-backend/pull/6839)
|
||||
- Profiles:
|
||||
- FIXED: Bicycle and foot profiles now don't route on proposed ways [#6615](https://github.com/Project-OSRM/osrm-backend/pull/6615)
|
||||
- ADDED: Add optional support of cargo bike exclusion and width to bicyle profile [#7044](https://github.com/Project-OSRM/osrm-backend/pull/7044)
|
||||
- Routing:
|
||||
- FIXED: Fix adding traffic signal penalties during compression [#6419](https://github.com/Project-OSRM/osrm-backend/pull/6419)
|
||||
- FIXED: Correctly handle compressed traffic signals. [#6724](https://github.com/Project-OSRM/osrm-backend/pull/6724)
|
||||
|
||||
@@ -30,7 +30,7 @@ struct V8Renderer
|
||||
{
|
||||
Napi::Value child;
|
||||
std::visit(V8Renderer(env, child), keyValue.second);
|
||||
obj.Set(keyValue.first.data(), child);
|
||||
obj.Set(keyValue.first, child);
|
||||
}
|
||||
out = obj;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,46 @@ namespace osrm::util
|
||||
namespace bearing
|
||||
{
|
||||
|
||||
inline std::string get(const double heading)
|
||||
{
|
||||
BOOST_ASSERT(heading >= 0);
|
||||
BOOST_ASSERT(heading <= 360);
|
||||
|
||||
if (heading <= 22.5)
|
||||
{
|
||||
return "N";
|
||||
}
|
||||
if (heading <= 67.5)
|
||||
{
|
||||
return "NE";
|
||||
}
|
||||
if (heading <= 112.5)
|
||||
{
|
||||
return "E";
|
||||
}
|
||||
if (heading <= 157.5)
|
||||
{
|
||||
return "SE";
|
||||
}
|
||||
if (heading <= 202.5)
|
||||
{
|
||||
return "S";
|
||||
}
|
||||
if (heading <= 247.5)
|
||||
{
|
||||
return "SW";
|
||||
}
|
||||
if (heading <= 292.5)
|
||||
{
|
||||
return "W";
|
||||
}
|
||||
if (heading <= 337.5)
|
||||
{
|
||||
return "NW";
|
||||
}
|
||||
return "N";
|
||||
}
|
||||
|
||||
// Checks whether A is between B-range and B+range, all modulo 360
|
||||
// e.g. A = 5, B = 5, range = 10 == true
|
||||
// A = -6, B = 5, range = 10 == false
|
||||
|
||||
+142
-11
@@ -90,33 +90,164 @@ struct Null
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* Typed Value sum-type implemented as a variant able to represent tree-like JSON structures.
|
||||
*
|
||||
* Dispatch on its type by either by using apply_visitor or its get function.
|
||||
*/
|
||||
using Value = std::variant<String, Number, Object, Array, True, False, Null>;
|
||||
|
||||
/**
|
||||
* Typed Object.
|
||||
*
|
||||
* Unwrap the key-value pairs holding type via its values member attribute.
|
||||
*/
|
||||
struct Object
|
||||
{
|
||||
std::unordered_map<std::string_view, Value> values;
|
||||
};
|
||||
struct Object;
|
||||
|
||||
/**
|
||||
* Typed Array.
|
||||
*
|
||||
* Unwrap the Value holding type via its values member attribute.
|
||||
*/
|
||||
struct Array;
|
||||
|
||||
struct Value;
|
||||
|
||||
// Definitions of Object and Array (must come after Value is defined)
|
||||
struct Object
|
||||
{
|
||||
std::unordered_map<std::string, Value> values;
|
||||
};
|
||||
|
||||
struct Array
|
||||
{
|
||||
std::vector<Value> values;
|
||||
};
|
||||
|
||||
struct Value
|
||||
{
|
||||
enum class Type
|
||||
{
|
||||
Invalid,
|
||||
String,
|
||||
Number,
|
||||
Object,
|
||||
Array,
|
||||
True,
|
||||
False,
|
||||
Null
|
||||
};
|
||||
String string;
|
||||
Number number;
|
||||
Object object;
|
||||
Array array;
|
||||
Type type;
|
||||
|
||||
Value() noexcept : type(Type::Invalid) {}
|
||||
Value(const Null &) noexcept : type(Type::Null) {}
|
||||
Value(const True &) noexcept : type(Type::True) {}
|
||||
Value(const False &) noexcept : type(Type::False) {}
|
||||
Value(String &&string_) noexcept : string(std::move(string_)), type(Type::String) {}
|
||||
Value(Number &&number_) noexcept : number(number_), type(Type::Number) {}
|
||||
Value(Object &&object_) noexcept : object(std::move(object_)), type(Type::Object) {}
|
||||
Value(Array &&array_) noexcept : array(std::move(array_)), type(Type::Array) {}
|
||||
Value(const String &string_) noexcept : string(string_), type(Type::String) {}
|
||||
Value(const Number &number_) noexcept : number(number_), type(Type::Number) {}
|
||||
Value(const Object &object_) noexcept : object(object_), type(Type::Object) {}
|
||||
Value(const Array &array_) noexcept : array(array_), type(Type::Array) {}
|
||||
|
||||
Value(double number) noexcept : number(number), type(Type::Number) {}
|
||||
Value(std::string string) noexcept : string(std::move(string)), type(Type::String) {}
|
||||
Value(const char *string) noexcept : string(string), type(Type::String) {}
|
||||
};
|
||||
|
||||
} // namespace osrm::util::json
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <typename T> inline T &get(osrm::util::json::Value &value) noexcept;
|
||||
|
||||
template <>
|
||||
inline osrm::util::json::String &
|
||||
get<osrm::util::json::String>(osrm::util::json::Value &value) noexcept
|
||||
{
|
||||
return value.string;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline osrm::util::json::Number &
|
||||
get<osrm::util::json::Number>(osrm::util::json::Value &value) noexcept
|
||||
{
|
||||
return value.number;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline osrm::util::json::Object &
|
||||
get<osrm::util::json::Object>(osrm::util::json::Value &value) noexcept
|
||||
{
|
||||
return value.object;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline osrm::util::json::Array &
|
||||
get<osrm::util::json::Array>(osrm::util::json::Value &value) noexcept
|
||||
{
|
||||
return value.array;
|
||||
}
|
||||
|
||||
template <typename T> inline const T &get(const osrm::util::json::Value &value) noexcept;
|
||||
|
||||
template <>
|
||||
inline const osrm::util::json::String &
|
||||
get<osrm::util::json::String>(const osrm::util::json::Value &value) noexcept
|
||||
{
|
||||
return value.string;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline const osrm::util::json::Number &
|
||||
get<osrm::util::json::Number>(const osrm::util::json::Value &value) noexcept
|
||||
{
|
||||
return value.number;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline const osrm::util::json::Object &
|
||||
get<osrm::util::json::Object>(const osrm::util::json::Value &value) noexcept
|
||||
{
|
||||
return value.object;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline const osrm::util::json::Array &
|
||||
get<osrm::util::json::Array>(const osrm::util::json::Value &value) noexcept
|
||||
{
|
||||
return value.array;
|
||||
}
|
||||
|
||||
template <typename Visitor>
|
||||
inline void visit(Visitor &&visitor, const osrm::util::json::Value &value)
|
||||
{
|
||||
switch (value.type)
|
||||
{
|
||||
case osrm::util::json::Value::Type::String:
|
||||
visitor(value.string);
|
||||
break;
|
||||
case osrm::util::json::Value::Type::Number:
|
||||
visitor(value.number);
|
||||
break;
|
||||
case osrm::util::json::Value::Type::Object:
|
||||
visitor(value.object);
|
||||
break;
|
||||
case osrm::util::json::Value::Type::Array:
|
||||
visitor(value.array);
|
||||
break;
|
||||
case osrm::util::json::Value::Type::True:
|
||||
visitor(osrm::util::json::True{});
|
||||
break;
|
||||
case osrm::util::json::Value::Type::False:
|
||||
visitor(osrm::util::json::False{});
|
||||
break;
|
||||
case osrm::util::json::Value::Type::Null:
|
||||
visitor(osrm::util::json::Null{});
|
||||
break;
|
||||
case osrm::util::json::Value::Type::Invalid:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
#endif // JSON_CONTAINER_HPP
|
||||
|
||||
+137
-136
@@ -1,158 +1,159 @@
|
||||
#ifndef UTIL_JSON_DEEP_COMPARE_HPP
|
||||
#define UTIL_JSON_DEEP_COMPARE_HPP
|
||||
// #ifndef UTIL_JSON_DEEP_COMPARE_HPP
|
||||
// #define UTIL_JSON_DEEP_COMPARE_HPP
|
||||
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/json_container.hpp"
|
||||
// #include "util/integer_range.hpp"
|
||||
// #include "util/json_container.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
// #include <boost/assert.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <set>
|
||||
// #include <algorithm>
|
||||
// #include <functional>
|
||||
// #include <set>
|
||||
|
||||
namespace osrm::util::json
|
||||
{
|
||||
// namespace osrm::util::json
|
||||
// {
|
||||
|
||||
struct Comparator
|
||||
{
|
||||
Comparator(std::string &reason_, const std::string &lhs_path_, const std::string &rhs_path_)
|
||||
: reason(reason_), lhs_path(lhs_path_), rhs_path(rhs_path_)
|
||||
{
|
||||
}
|
||||
// struct Comparator
|
||||
// {
|
||||
// Comparator(std::string &reason_, const std::string &lhs_path_, const std::string &rhs_path_)
|
||||
// : reason(reason_), lhs_path(lhs_path_), rhs_path(rhs_path_)
|
||||
// {
|
||||
// }
|
||||
|
||||
bool operator()(const String &lhs, const String &rhs) const
|
||||
{
|
||||
bool is_same = lhs.value == rhs.value;
|
||||
if (!is_same)
|
||||
{
|
||||
reason = lhs_path + " (= \"" + lhs.value + "\") != " + rhs_path + " (= \"" + rhs.value +
|
||||
"\")";
|
||||
}
|
||||
return is_same;
|
||||
}
|
||||
// bool operator()(const String &lhs, const String &rhs) const
|
||||
// {
|
||||
// bool is_same = lhs.value == rhs.value;
|
||||
// if (!is_same)
|
||||
// {
|
||||
// reason = lhs_path + " (= \"" + lhs.value + "\") != " + rhs_path + " (= \"" +
|
||||
// rhs.value +
|
||||
// "\")";
|
||||
// }
|
||||
// return is_same;
|
||||
// }
|
||||
|
||||
bool operator()(const Number &lhs, const Number &rhs) const
|
||||
{
|
||||
bool is_same = lhs.value == rhs.value;
|
||||
if (!is_same)
|
||||
{
|
||||
reason = lhs_path + " (= " + std::to_string(lhs.value) + ") != " + rhs_path +
|
||||
" (= " + std::to_string(rhs.value) + ")";
|
||||
}
|
||||
return is_same;
|
||||
}
|
||||
// bool operator()(const Number &lhs, const Number &rhs) const
|
||||
// {
|
||||
// bool is_same = lhs.value == rhs.value;
|
||||
// if (!is_same)
|
||||
// {
|
||||
// reason = lhs_path + " (= " + std::to_string(lhs.value) + ") != " + rhs_path +
|
||||
// " (= " + std::to_string(rhs.value) + ")";
|
||||
// }
|
||||
// return is_same;
|
||||
// }
|
||||
|
||||
bool operator()(const Object &lhs, const Object &rhs) const
|
||||
{
|
||||
std::set<std::string_view> lhs_keys;
|
||||
for (const auto &key_value : lhs.values)
|
||||
{
|
||||
lhs_keys.insert(key_value.first);
|
||||
}
|
||||
// bool operator()(const Object &lhs, const Object &rhs) const
|
||||
// {
|
||||
// std::set<std::string> lhs_keys;
|
||||
// for (const auto &key_value : lhs.values)
|
||||
// {
|
||||
// lhs_keys.insert(key_value.first);
|
||||
// }
|
||||
|
||||
std::set<std::string_view> rhs_keys;
|
||||
for (const auto &key_value : rhs.values)
|
||||
{
|
||||
rhs_keys.insert(key_value.first);
|
||||
}
|
||||
// std::set<std::string> rhs_keys;
|
||||
// for (const auto &key_value : rhs.values)
|
||||
// {
|
||||
// rhs_keys.insert(key_value.first);
|
||||
// }
|
||||
|
||||
for (const auto &key : lhs_keys)
|
||||
{
|
||||
if (rhs_keys.find(key) == rhs_keys.end())
|
||||
{
|
||||
reason = rhs_path + " doesn't have key \"" + std::string(key) + "\"";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// for (const auto &key : lhs_keys)
|
||||
// {
|
||||
// if (rhs_keys.find(key) == rhs_keys.end())
|
||||
// {
|
||||
// reason = rhs_path + " doesn't have key \"" + key + "\"";
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
for (const auto &key : rhs_keys)
|
||||
{
|
||||
if (lhs_keys.find(key) == lhs_keys.end())
|
||||
{
|
||||
reason = lhs_path + " doesn't have key \"" + std::string(key) + "\"";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// for (const auto &key : rhs_keys)
|
||||
// {
|
||||
// if (lhs_keys.find(key) == lhs_keys.end())
|
||||
// {
|
||||
// reason = lhs_path + " doesn't have key \"" + key + "\"";
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
for (const auto &key : lhs_keys)
|
||||
{
|
||||
BOOST_ASSERT(rhs.values.find(key) != rhs.values.end());
|
||||
BOOST_ASSERT(lhs.values.find(key) != lhs.values.end());
|
||||
// for (const auto &key : lhs_keys)
|
||||
// {
|
||||
// BOOST_ASSERT(rhs.values.find(key) != rhs.values.end());
|
||||
// BOOST_ASSERT(lhs.values.find(key) != lhs.values.end());
|
||||
|
||||
const auto &rhs_child = rhs.values.find(key)->second;
|
||||
const auto &lhs_child = lhs.values.find(key)->second;
|
||||
auto is_same = std::visit(Comparator(reason,
|
||||
lhs_path + "." + std::string(key),
|
||||
rhs_path + "." + std::string(key)),
|
||||
lhs_child,
|
||||
rhs_child);
|
||||
if (!is_same)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// const auto &rhs_child = rhs.values.find(key)->second;
|
||||
// const auto &lhs_child = lhs.values.find(key)->second;
|
||||
// auto is_same =
|
||||
// std::visit(Comparator(reason, lhs_path + "." + key, rhs_path + "." + key),
|
||||
// lhs_child,
|
||||
// rhs_child);
|
||||
// if (!is_same)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
bool operator()(const Array &lhs, const Array &rhs) const
|
||||
{
|
||||
if (lhs.values.size() != rhs.values.size())
|
||||
{
|
||||
reason = lhs_path + ".length " + std::to_string(lhs.values.size()) + " != " + rhs_path +
|
||||
".length " + std::to_string(rhs.values.size());
|
||||
return false;
|
||||
}
|
||||
// bool operator()(const Array &lhs, const Array &rhs) const
|
||||
// {
|
||||
// if (lhs.values.size() != rhs.values.size())
|
||||
// {
|
||||
// reason = lhs_path + ".length " + std::to_string(lhs.values.size()) + " != " +
|
||||
// rhs_path +
|
||||
// ".length " + std::to_string(rhs.values.size());
|
||||
// return false;
|
||||
// }
|
||||
|
||||
for (auto i = 0UL; i < lhs.values.size(); ++i)
|
||||
{
|
||||
auto is_same = std::visit(Comparator(reason,
|
||||
lhs_path + "[" + std::to_string(i) + "]",
|
||||
rhs_path + "[" + std::to_string(i) + "]"),
|
||||
lhs.values[i],
|
||||
rhs.values[i]);
|
||||
if (!is_same)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// for (auto i = 0UL; i < lhs.values.size(); ++i)
|
||||
// {
|
||||
// auto is_same = std::visit(Comparator(reason,
|
||||
// lhs_path + "[" + std::to_string(i) + "]",
|
||||
// rhs_path + "[" + std::to_string(i) + "]"),
|
||||
// lhs.values[i],
|
||||
// rhs.values[i]);
|
||||
// if (!is_same)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
// return true;
|
||||
// }
|
||||
|
||||
bool operator()(const True &, const True &) const { return true; }
|
||||
bool operator()(const False &, const False &) const { return true; }
|
||||
bool operator()(const Null &, const Null &) const { return true; }
|
||||
// bool operator()(const True &, const True &) const { return true; }
|
||||
// bool operator()(const False &, const False &) const { return true; }
|
||||
// bool operator()(const Null &, const Null &) const { return true; }
|
||||
|
||||
bool operator()(const False &, const True &) const
|
||||
{
|
||||
reason = lhs_path + " is false but " + rhs_path + " is true";
|
||||
return false;
|
||||
}
|
||||
bool operator()(const True &, const False &) const
|
||||
{
|
||||
reason = lhs_path + " is true but " + rhs_path + " is false";
|
||||
return false;
|
||||
}
|
||||
// bool operator()(const False &, const True &) const
|
||||
// {
|
||||
// reason = lhs_path + " is false but " + rhs_path + " is true";
|
||||
// return false;
|
||||
// }
|
||||
// bool operator()(const True &, const False &) const
|
||||
// {
|
||||
// reason = lhs_path + " is true but " + rhs_path + " is false";
|
||||
// return false;
|
||||
// }
|
||||
|
||||
template <typename T1,
|
||||
typename T2,
|
||||
typename = typename std::enable_if<!std::is_same<T1, T2>::value>::type>
|
||||
bool operator()(const T1 &, const T2 &)
|
||||
{
|
||||
reason = lhs_path + " and " + rhs_path + " have different types";
|
||||
return false;
|
||||
}
|
||||
// template <typename T1,
|
||||
// typename T2,
|
||||
// typename = typename std::enable_if<!std::is_same<T1, T2>::value>::type>
|
||||
// bool operator()(const T1 &, const T2 &)
|
||||
// {
|
||||
// reason = lhs_path + " and " + rhs_path + " have different types";
|
||||
// return false;
|
||||
// }
|
||||
|
||||
private:
|
||||
std::string &reason;
|
||||
const std::string &lhs_path;
|
||||
const std::string &rhs_path;
|
||||
};
|
||||
// private:
|
||||
// std::string &reason;
|
||||
// const std::string &lhs_path;
|
||||
// const std::string &rhs_path;
|
||||
// };
|
||||
|
||||
inline bool compare(const Value &reference, const Value &result, std::string &reason)
|
||||
{
|
||||
return std::visit(Comparator(reason, "reference", "result"), reference, result);
|
||||
}
|
||||
} // namespace osrm::util::json
|
||||
// inline bool compare(const Value &reference, const Value &result, std::string &reason)
|
||||
// {
|
||||
// return std::visit(Comparator(reason, "reference", "result"), reference, result);
|
||||
// }
|
||||
// } // namespace osrm::util::json
|
||||
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
@@ -97,7 +97,7 @@ template <typename Out> struct Renderer
|
||||
void operator()(const Null &) { write<>("null"); }
|
||||
|
||||
private:
|
||||
void write(std::string_view str);
|
||||
void write(const std::string &str);
|
||||
void write(const char *str, size_t size);
|
||||
void write(char ch);
|
||||
|
||||
@@ -110,7 +110,7 @@ template <typename Out> struct Renderer
|
||||
Out &out;
|
||||
};
|
||||
|
||||
template <> void Renderer<std::vector<char>>::write(std::string_view str)
|
||||
template <> void Renderer<std::vector<char>>::write(const std::string &str)
|
||||
{
|
||||
out.insert(out.end(), str.begin(), str.end());
|
||||
}
|
||||
@@ -122,7 +122,7 @@ template <> void Renderer<std::vector<char>>::write(const char *str, size_t size
|
||||
|
||||
template <> void Renderer<std::vector<char>>::write(char ch) { out.push_back(ch); }
|
||||
|
||||
template <> void Renderer<std::ostream>::write(std::string_view str) { out << str; }
|
||||
template <> void Renderer<std::ostream>::write(const std::string &str) { out << str; }
|
||||
|
||||
template <> void Renderer<std::ostream>::write(const char *str, size_t size)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ template <> void Renderer<std::ostream>::write(const char *str, size_t size)
|
||||
|
||||
template <> void Renderer<std::ostream>::write(char ch) { out << ch; }
|
||||
|
||||
template <> void Renderer<std::string>::write(std::string_view str) { out += str; }
|
||||
template <> void Renderer<std::string>::write(const std::string &str) { out += str; }
|
||||
|
||||
template <> void Renderer<std::string>::write(const char *str, size_t size)
|
||||
{
|
||||
|
||||
@@ -35,10 +35,6 @@ function setup()
|
||||
turn_bias = 1.4,
|
||||
use_public_transport = true,
|
||||
|
||||
-- Exclude narrow ways, in particular to route with cargo bike
|
||||
width = nil, -- Cargo bike could 0.5 width, in meters
|
||||
exclude_cargo_bike = false,
|
||||
|
||||
allowed_start_modes = Set {
|
||||
mode.cycling,
|
||||
mode.pushing_bike
|
||||
@@ -247,27 +243,6 @@ function process_node(profile, node, result)
|
||||
end
|
||||
end
|
||||
|
||||
if profile.exclude_cargo_bike then
|
||||
local cargo_bike = node:get_value_by_key("cargo_bike")
|
||||
if cargo_bike and cargo_bike == "no" then
|
||||
result.barrier = true
|
||||
end
|
||||
end
|
||||
|
||||
-- width
|
||||
if profile.width then
|
||||
-- From barrier=cycle_barrier or other barriers
|
||||
local maxwidth_physical = node:get_value_by_key("maxwidth:physical")
|
||||
local maxwidth_physical_meter = maxwidth_physical and Measure.parse_value_meters(maxwidth_physical) or 99
|
||||
local opening = node:get_value_by_key("opening")
|
||||
local opening_meter = opening and Measure.parse_value_meters(opening) or 99
|
||||
local width_meter = math.min(maxwidth_physical_meter, opening_meter)
|
||||
|
||||
if width_meter and width_meter < profile.width then
|
||||
result.barrier = true
|
||||
end
|
||||
end
|
||||
|
||||
-- check if node is a traffic light
|
||||
result.traffic_lights = TrafficSignal.get_value(node)
|
||||
end
|
||||
@@ -324,8 +299,6 @@ function handle_bicycle_tags(profile,way,result,data)
|
||||
|
||||
bike_push_handler(profile,way,result,data)
|
||||
|
||||
-- width should be after bike_push
|
||||
width_handler(profile,way,result,data)
|
||||
|
||||
-- maxspeed
|
||||
limit( result, data.maxspeed, data.maxspeed_forward, data.maxspeed_backward )
|
||||
@@ -480,27 +453,6 @@ function cycleway_handler(profile,way,result,data)
|
||||
end
|
||||
end
|
||||
|
||||
function width_handler(profile,way,result,data)
|
||||
if profile.exclude_cargo_bike then
|
||||
local cargo_bike = way:get_value_by_key("cargo_bike")
|
||||
if cargo_bike and cargo_bike == "no" then
|
||||
result.forward_mode = mode.inaccessible
|
||||
result.backward_mode = mode.inaccessible
|
||||
end
|
||||
end
|
||||
|
||||
if profile.width then
|
||||
local width = way:get_value_by_key("width")
|
||||
if width then
|
||||
local width_meter = Measure.parse_value_meters(width)
|
||||
if width_meter and width_meter < profile.width then
|
||||
result.forward_mode = mode.inaccessible
|
||||
result.backward_mode = mode.inaccessible
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function bike_push_handler(profile,way,result,data)
|
||||
-- pushing bikes - if no other mode found
|
||||
if result.forward_mode == mode.inaccessible or result.backward_mode == mode.inaccessible or
|
||||
|
||||
@@ -93,7 +93,7 @@ function run_benchmarks_for_folder {
|
||||
echo "Took: ${DIFF}s"
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
for ALGORITHM in ch mld; do
|
||||
for BENCH in nearest table trip route match; do
|
||||
echo "Running random $BENCH $ALGORITHM"
|
||||
|
||||
@@ -9,17 +9,12 @@
|
||||
#include <rapidjson/document.h>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <unordered_set>
|
||||
|
||||
using namespace osrm;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// we use std::string_view as a key in the object, so since here we have dynamic keys we have to
|
||||
// "hold" them somewhere okay for tests...
|
||||
static std::unordered_set<std::string> gKeysHolder;
|
||||
|
||||
void convert(const rapidjson::Value &value, json::Value &result)
|
||||
{
|
||||
if (value.IsString())
|
||||
@@ -37,8 +32,7 @@ void convert(const rapidjson::Value &value, json::Value &result)
|
||||
{
|
||||
json::Value member;
|
||||
convert(itr->value, member);
|
||||
auto keyItr = gKeysHolder.emplace(itr->name.GetString()).first;
|
||||
object.values.emplace(*keyItr, std::move(member));
|
||||
object.values.emplace(itr->name.GetString(), std::move(member));
|
||||
}
|
||||
result = std::move(object);
|
||||
}
|
||||
@@ -128,7 +122,6 @@ int main(int argc, char **argv)
|
||||
|
||||
if (std::string{out_vec.begin(), out_vec.end()} != out_str || out_str != out_ss_str)
|
||||
{
|
||||
std::cerr << "Vector/string results are not equal\n";
|
||||
throw std::logic_error("Vector/stringstream/string results are not equal");
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -143,8 +143,8 @@ util::json::Object makeIntersection(const guidance::IntermediateIntersection &in
|
||||
});
|
||||
|
||||
result.values.emplace("location", detail::coordinateToLonLat(intersection.location));
|
||||
result.values.emplace("bearings", bearings);
|
||||
result.values.emplace("entry", entry);
|
||||
result.values.emplace("bearings", std::move(bearings));
|
||||
result.values.emplace("entry", std::move(entry));
|
||||
if (intersection.in != guidance::IntermediateIntersection::NO_INDEX)
|
||||
result.values.emplace("in", intersection.in);
|
||||
if (intersection.out != guidance::IntermediateIntersection::NO_INDEX)
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
#ifndef UNIT_TESTS_JSON_EQUAL
|
||||
#define UNIT_TESTS_JSON_EQUAL
|
||||
// #ifndef UNIT_TESTS_JSON_EQUAL
|
||||
// #define UNIT_TESTS_JSON_EQUAL
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
// #include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "osrm/json_container.hpp"
|
||||
#include "util/json_deep_compare.hpp"
|
||||
// #include "osrm/json_container.hpp"
|
||||
// #include "util/json_deep_compare.hpp"
|
||||
|
||||
inline boost::test_tools::predicate_result compareJSON(const osrm::util::json::Value &reference,
|
||||
const osrm::util::json::Value &result)
|
||||
{
|
||||
std::string reason;
|
||||
auto is_same = osrm::util::json::compare(reference, result, reason);
|
||||
if (!is_same)
|
||||
{
|
||||
boost::test_tools::predicate_result res(false);
|
||||
// inline boost::test_tools::predicate_result compareJSON(const osrm::util::json::Value &reference,
|
||||
// const osrm::util::json::Value &result)
|
||||
// {
|
||||
// std::string reason;
|
||||
// auto is_same = osrm::util::json::compare(reference, result, reason);
|
||||
// if (!is_same)
|
||||
// {
|
||||
// boost::test_tools::predicate_result res(false);
|
||||
|
||||
res.message() << reason;
|
||||
// res.message() << reason;
|
||||
|
||||
return res;
|
||||
}
|
||||
// return res;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
// return true;
|
||||
// }
|
||||
|
||||
#define CHECK_EQUAL_JSON(reference, result) BOOST_CHECK(compareJSON(reference, result));
|
||||
// #define CHECK_EQUAL_JSON(reference, result) BOOST_CHECK(compareJSON(reference, result));
|
||||
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
+90
-112
@@ -5,9 +5,6 @@
|
||||
#include "osrm/extractor_config.hpp"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <oneapi/tbb/global_control.h>
|
||||
#include <oneapi/tbb/parallel_for.h>
|
||||
#include <tbb/flow_graph.h>
|
||||
#include <thread>
|
||||
|
||||
// utility class to redirect stderr so we can test it
|
||||
@@ -32,24 +29,16 @@ class redirect_stderr
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(library_extract)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(dummy)
|
||||
{
|
||||
BOOST_CHECK(true);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_extract_with_invalid_config)
|
||||
{
|
||||
oneapi::tbb::task_scheduler_handle handle{tbb::attach{}};
|
||||
osrm::ExtractorConfig config;
|
||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
BOOST_CHECK_THROW(osrm::extract(config),
|
||||
std::exception); // including osrm::util::exception, osmium::io_error, etc.
|
||||
oneapi::tbb::finalize(handle);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_extract_with_valid_config)
|
||||
{
|
||||
oneapi::tbb::task_scheduler_handle handle{tbb::attach{}};
|
||||
osrm::ExtractorConfig config;
|
||||
config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
@@ -57,127 +46,116 @@ BOOST_AUTO_TEST_CASE(test_extract_with_valid_config)
|
||||
config.small_component_size = 1000;
|
||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
BOOST_CHECK_NO_THROW(osrm::extract(config));
|
||||
oneapi::tbb::finalize(handle);
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(test_setup_runtime_error)
|
||||
// {
|
||||
// oneapi::tbb::task_scheduler_handle handle{tbb::attach{}};
|
||||
// osrm::ExtractorConfig config;
|
||||
// config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
// config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
// config.profile_path = OSRM_TEST_DATA_DIR "/profiles/bad_setup.lua";
|
||||
// config.small_component_size = 1000;
|
||||
// config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
BOOST_AUTO_TEST_CASE(test_setup_runtime_error)
|
||||
{
|
||||
osrm::ExtractorConfig config;
|
||||
config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
config.profile_path = OSRM_TEST_DATA_DIR "/profiles/bad_setup.lua";
|
||||
config.small_component_size = 1000;
|
||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
|
||||
// std::stringstream output;
|
||||
std::stringstream output;
|
||||
|
||||
// {
|
||||
// redirect_stderr redir(output.rdbuf());
|
||||
// BOOST_CHECK_THROW(osrm::extract(config), osrm::util::exception);
|
||||
// }
|
||||
{
|
||||
redirect_stderr redir(output.rdbuf());
|
||||
BOOST_CHECK_THROW(osrm::extract(config), osrm::util::exception);
|
||||
}
|
||||
|
||||
// // We just look for the line number, file name, and error message. This avoids portability
|
||||
// // issues since the output contains the full path to the file, which may change between systems
|
||||
// BOOST_CHECK(boost::algorithm::contains(output.str(),
|
||||
// "bad_setup.lua:6: attempt to compare number with nil"));
|
||||
// oneapi::tbb::finalize(handle);
|
||||
// }
|
||||
// We just look for the line number, file name, and error message. This avoids portability
|
||||
// issues since the output contains the full path to the file, which may change between systems
|
||||
BOOST_CHECK(boost::algorithm::contains(output.str(),
|
||||
"bad_setup.lua:6: attempt to compare number with nil"));
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(test_way_runtime_error)
|
||||
// {
|
||||
// oneapi::tbb::task_scheduler_handle handle{tbb::attach{}};
|
||||
// osrm::ExtractorConfig config;
|
||||
// config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
// config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
// config.profile_path = OSRM_TEST_DATA_DIR "/profiles/bad_way.lua";
|
||||
// config.small_component_size = 1000;
|
||||
// config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
BOOST_AUTO_TEST_CASE(test_way_runtime_error)
|
||||
{
|
||||
osrm::ExtractorConfig config;
|
||||
config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
config.profile_path = OSRM_TEST_DATA_DIR "/profiles/bad_way.lua";
|
||||
config.small_component_size = 1000;
|
||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
|
||||
// std::stringstream output;
|
||||
std::stringstream output;
|
||||
|
||||
// {
|
||||
// redirect_stderr redir(output.rdbuf());
|
||||
// BOOST_CHECK_THROW(osrm::extract(config), osrm::util::exception);
|
||||
// }
|
||||
{
|
||||
redirect_stderr redir(output.rdbuf());
|
||||
BOOST_CHECK_THROW(osrm::extract(config), osrm::util::exception);
|
||||
}
|
||||
|
||||
// // We just look for the line number, file name, and error message. This avoids portability
|
||||
// // issues since the output contains the full path to the file, which may change between systems
|
||||
// BOOST_CHECK(boost::algorithm::contains(output.str(),
|
||||
// "bad_way.lua:41: attempt to compare number with nil"));
|
||||
// oneapi::tbb::finalize(handle);
|
||||
// }
|
||||
// We just look for the line number, file name, and error message. This avoids portability
|
||||
// issues since the output contains the full path to the file, which may change between systems
|
||||
BOOST_CHECK(boost::algorithm::contains(output.str(),
|
||||
"bad_way.lua:41: attempt to compare number with nil"));
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(test_node_runtime_error)
|
||||
// {
|
||||
// oneapi::tbb::task_scheduler_handle handle{tbb::attach{}};
|
||||
// osrm::ExtractorConfig config;
|
||||
// config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
// config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
// config.profile_path = OSRM_TEST_DATA_DIR "/profiles/bad_node.lua";
|
||||
// config.small_component_size = 1000;
|
||||
// config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
BOOST_AUTO_TEST_CASE(test_node_runtime_error)
|
||||
{
|
||||
osrm::ExtractorConfig config;
|
||||
config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
config.profile_path = OSRM_TEST_DATA_DIR "/profiles/bad_node.lua";
|
||||
config.small_component_size = 1000;
|
||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
|
||||
// std::stringstream output;
|
||||
std::stringstream output;
|
||||
|
||||
// {
|
||||
// redirect_stderr redir(output.rdbuf());
|
||||
// BOOST_CHECK_THROW(osrm::extract(config), osrm::util::exception);
|
||||
// }
|
||||
{
|
||||
redirect_stderr redir(output.rdbuf());
|
||||
BOOST_CHECK_THROW(osrm::extract(config), osrm::util::exception);
|
||||
}
|
||||
|
||||
// // We just look for the line number, file name, and error message. This avoids portability
|
||||
// // issues since the output contains the full path to the file, which may change between systems
|
||||
// BOOST_CHECK(boost::algorithm::contains(output.str(),
|
||||
// "bad_node.lua:36: attempt to compare number with nil"));
|
||||
// oneapi::tbb::finalize(handle);
|
||||
// }
|
||||
// We just look for the line number, file name, and error message. This avoids portability
|
||||
// issues since the output contains the full path to the file, which may change between systems
|
||||
BOOST_CHECK(boost::algorithm::contains(output.str(),
|
||||
"bad_node.lua:36: attempt to compare number with nil"));
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(test_segment_runtime_error)
|
||||
// {
|
||||
// oneapi::tbb::task_scheduler_handle handle{tbb::attach{}};
|
||||
// osrm::ExtractorConfig config;
|
||||
// config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
// config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
// config.profile_path = OSRM_TEST_DATA_DIR "/profiles/bad_segment.lua";
|
||||
// config.small_component_size = 1000;
|
||||
// config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
BOOST_AUTO_TEST_CASE(test_segment_runtime_error)
|
||||
{
|
||||
osrm::ExtractorConfig config;
|
||||
config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
config.profile_path = OSRM_TEST_DATA_DIR "/profiles/bad_segment.lua";
|
||||
config.small_component_size = 1000;
|
||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
|
||||
// std::stringstream output;
|
||||
std::stringstream output;
|
||||
|
||||
// {
|
||||
// redirect_stderr redir(output.rdbuf());
|
||||
// BOOST_CHECK_THROW(osrm::extract(config), osrm::util::exception);
|
||||
// }
|
||||
{
|
||||
redirect_stderr redir(output.rdbuf());
|
||||
BOOST_CHECK_THROW(osrm::extract(config), osrm::util::exception);
|
||||
}
|
||||
|
||||
// // We just look for the line number, file name, and error message. This avoids portability
|
||||
// // issues since the output contains the full path to the file, which may change between systems
|
||||
// BOOST_CHECK(boost::algorithm::contains(
|
||||
// output.str(), "bad_segment.lua:132: attempt to compare number with nil"));
|
||||
// oneapi::tbb::finalize(handle);
|
||||
// }
|
||||
// We just look for the line number, file name, and error message. This avoids portability
|
||||
// issues since the output contains the full path to the file, which may change between systems
|
||||
BOOST_CHECK(boost::algorithm::contains(
|
||||
output.str(), "bad_segment.lua:132: attempt to compare number with nil"));
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(test_turn_runtime_error)
|
||||
// {
|
||||
// oneapi::tbb::task_scheduler_handle handle{tbb::attach{}};
|
||||
// osrm::ExtractorConfig config;
|
||||
// config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
// config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
// config.profile_path = OSRM_TEST_DATA_DIR "/profiles/bad_turn.lua";
|
||||
// config.small_component_size = 1000;
|
||||
// config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
BOOST_AUTO_TEST_CASE(test_turn_runtime_error)
|
||||
{
|
||||
osrm::ExtractorConfig config;
|
||||
config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
config.profile_path = OSRM_TEST_DATA_DIR "/profiles/bad_turn.lua";
|
||||
config.small_component_size = 1000;
|
||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
|
||||
// std::stringstream output;
|
||||
std::stringstream output;
|
||||
|
||||
// {
|
||||
// redirect_stderr redir(output.rdbuf());
|
||||
// BOOST_CHECK_THROW(osrm::extract(config), osrm::util::exception);
|
||||
// }
|
||||
{
|
||||
redirect_stderr redir(output.rdbuf());
|
||||
BOOST_CHECK_THROW(osrm::extract(config), osrm::util::exception);
|
||||
}
|
||||
|
||||
// // We just look for the line number, file name, and error message. This avoids portability
|
||||
// // issues since the output contains the full path to the file, which may change between systems
|
||||
// BOOST_CHECK(boost::algorithm::contains(output.str(),
|
||||
// "bad_turn.lua:122: attempt to compare number with nil"));
|
||||
// oneapi::tbb::finalize(handle);
|
||||
// }
|
||||
// We just look for the line number, file name, and error message. This avoids portability
|
||||
// issues since the output contains the full path to the file, which may change between systems
|
||||
BOOST_CHECK(boost::algorithm::contains(output.str(),
|
||||
"bad_turn.lua:122: attempt to compare number with nil"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
+177
-177
@@ -1,226 +1,226 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <variant>
|
||||
// #include <boost/test/unit_test.hpp>
|
||||
// #include <variant>
|
||||
|
||||
#include "coordinates.hpp"
|
||||
#include "fixture.hpp"
|
||||
#include "waypoint_check.hpp"
|
||||
// #include "coordinates.hpp"
|
||||
// #include "fixture.hpp"
|
||||
// #include "waypoint_check.hpp"
|
||||
|
||||
#include "osrm/match_parameters.hpp"
|
||||
// #include "osrm/match_parameters.hpp"
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "osrm/json_container.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
#include "osrm/status.hpp"
|
||||
// #include "osrm/coordinate.hpp"
|
||||
// #include "osrm/json_container.hpp"
|
||||
// #include "osrm/osrm.hpp"
|
||||
// #include "osrm/status.hpp"
|
||||
|
||||
osrm::Status run_match_json(const osrm::OSRM &osrm,
|
||||
const osrm::MatchParameters ¶ms,
|
||||
osrm::json::Object &json_result,
|
||||
bool use_json_only_api)
|
||||
{
|
||||
using namespace osrm;
|
||||
// osrm::Status run_match_json(const osrm::OSRM &osrm,
|
||||
// const osrm::MatchParameters ¶ms,
|
||||
// osrm::json::Object &json_result,
|
||||
// bool use_json_only_api)
|
||||
// {
|
||||
// using namespace osrm;
|
||||
|
||||
if (use_json_only_api)
|
||||
{
|
||||
return osrm.Match(params, json_result);
|
||||
}
|
||||
engine::api::ResultT result = json::Object();
|
||||
auto rc = osrm.Match(params, result);
|
||||
json_result = std::get<json::Object>(result);
|
||||
return rc;
|
||||
}
|
||||
// if (use_json_only_api)
|
||||
// {
|
||||
// return osrm.Match(params, json_result);
|
||||
// }
|
||||
// engine::api::ResultT result = json::Object();
|
||||
// auto rc = osrm.Match(params, result);
|
||||
// json_result = std::get<json::Object>(result);
|
||||
// return rc;
|
||||
// }
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(match)
|
||||
// BOOST_AUTO_TEST_SUITE(match)
|
||||
|
||||
void test_match(bool use_json_only_api)
|
||||
{
|
||||
using namespace osrm;
|
||||
// void test_match(bool use_json_only_api)
|
||||
// {
|
||||
// using namespace osrm;
|
||||
|
||||
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
||||
// auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
||||
|
||||
MatchParameters params;
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
// MatchParameters params;
|
||||
// params.coordinates.push_back(get_dummy_location());
|
||||
// params.coordinates.push_back(get_dummy_location());
|
||||
// params.coordinates.push_back(get_dummy_location());
|
||||
|
||||
json::Object json_result;
|
||||
const auto rc = run_match_json(osrm, params, json_result, use_json_only_api);
|
||||
// json::Object json_result;
|
||||
// const auto rc = run_match_json(osrm, params, json_result, use_json_only_api);
|
||||
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
const auto code = std::get<json::String>(json_result.values.at("code")).value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
// BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
// const auto code = std::get<json::String>(json_result.values.at("code")).value;
|
||||
// BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &tracepoints = std::get<json::Array>(json_result.values.at("tracepoints")).values;
|
||||
BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size());
|
||||
// const auto &tracepoints = std::get<json::Array>(json_result.values.at("tracepoints")).values;
|
||||
// BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size());
|
||||
|
||||
const auto &matchings = std::get<json::Array>(json_result.values.at("matchings")).values;
|
||||
const auto &number_of_matchings = matchings.size();
|
||||
for (const auto &waypoint : tracepoints)
|
||||
{
|
||||
if (std::holds_alternative<util::json::Object>(waypoint))
|
||||
{
|
||||
BOOST_CHECK(waypoint_check(waypoint));
|
||||
const auto &waypoint_object = std::get<json::Object>(waypoint);
|
||||
const auto matchings_index =
|
||||
std::get<json::Number>(waypoint_object.values.at("matchings_index")).value;
|
||||
const auto waypoint_index =
|
||||
std::get<json::Number>(waypoint_object.values.at("waypoint_index")).value;
|
||||
const auto &route_legs =
|
||||
std::get<json::Array>(
|
||||
std::get<json::Object>(matchings[matchings_index]).values.at("legs"))
|
||||
.values;
|
||||
BOOST_CHECK_LT(waypoint_index, route_legs.size() + 1);
|
||||
BOOST_CHECK_LT(matchings_index, number_of_matchings);
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_CHECK(std::holds_alternative<json::Null>(waypoint));
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOST_AUTO_TEST_CASE(test_match_new_api) { test_match(false); }
|
||||
BOOST_AUTO_TEST_CASE(test_match_old_api) { test_match(true); }
|
||||
// const auto &matchings = std::get<json::Array>(json_result.values.at("matchings")).values;
|
||||
// const auto &number_of_matchings = matchings.size();
|
||||
// for (const auto &waypoint : tracepoints)
|
||||
// {
|
||||
// if (std::holds_alternative<util::json::Object>(waypoint))
|
||||
// {
|
||||
// BOOST_CHECK(waypoint_check(waypoint));
|
||||
// const auto &waypoint_object = std::get<json::Object>(waypoint);
|
||||
// const auto matchings_index =
|
||||
// std::get<json::Number>(waypoint_object.values.at("matchings_index")).value;
|
||||
// const auto waypoint_index =
|
||||
// std::get<json::Number>(waypoint_object.values.at("waypoint_index")).value;
|
||||
// const auto &route_legs =
|
||||
// std::get<json::Array>(
|
||||
// std::get<json::Object>(matchings[matchings_index]).values.at("legs"))
|
||||
// .values;
|
||||
// BOOST_CHECK_LT(waypoint_index, route_legs.size() + 1);
|
||||
// BOOST_CHECK_LT(matchings_index, number_of_matchings);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// BOOST_CHECK(std::holds_alternative<json::Null>(waypoint));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// BOOST_AUTO_TEST_CASE(test_match_new_api) { test_match(false); }
|
||||
// BOOST_AUTO_TEST_CASE(test_match_old_api) { test_match(true); }
|
||||
|
||||
void test_match_skip_waypoints(bool use_json_only_api)
|
||||
{
|
||||
using namespace osrm;
|
||||
// void test_match_skip_waypoints(bool use_json_only_api)
|
||||
// {
|
||||
// using namespace osrm;
|
||||
|
||||
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
||||
// auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
||||
|
||||
MatchParameters params;
|
||||
params.skip_waypoints = true;
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
// MatchParameters params;
|
||||
// params.skip_waypoints = true;
|
||||
// params.coordinates.push_back(get_dummy_location());
|
||||
// params.coordinates.push_back(get_dummy_location());
|
||||
// params.coordinates.push_back(get_dummy_location());
|
||||
|
||||
json::Object json_result;
|
||||
const auto rc = run_match_json(osrm, params, json_result, use_json_only_api);
|
||||
// json::Object json_result;
|
||||
// const auto rc = run_match_json(osrm, params, json_result, use_json_only_api);
|
||||
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
const auto code = std::get<json::String>(json_result.values.at("code")).value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
// BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
// const auto code = std::get<json::String>(json_result.values.at("code")).value;
|
||||
// BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
BOOST_CHECK(json_result.values.find("tracepoints") == json_result.values.end());
|
||||
}
|
||||
BOOST_AUTO_TEST_CASE(test_match_skip_waypoints_old_api) { test_match_skip_waypoints(true); }
|
||||
BOOST_AUTO_TEST_CASE(test_match_skip_waypoints_new_api) { test_match_skip_waypoints(false); }
|
||||
// BOOST_CHECK(json_result.values.find("tracepoints") == json_result.values.end());
|
||||
// }
|
||||
// BOOST_AUTO_TEST_CASE(test_match_skip_waypoints_old_api) { test_match_skip_waypoints(true); }
|
||||
// BOOST_AUTO_TEST_CASE(test_match_skip_waypoints_new_api) { test_match_skip_waypoints(false); }
|
||||
|
||||
void test_match_split(bool use_json_only_api)
|
||||
{
|
||||
using namespace osrm;
|
||||
// void test_match_split(bool use_json_only_api)
|
||||
// {
|
||||
// using namespace osrm;
|
||||
|
||||
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
||||
// auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
||||
|
||||
MatchParameters params;
|
||||
params.coordinates = get_split_trace_locations();
|
||||
params.timestamps = {1, 2, 1700, 1800};
|
||||
// MatchParameters params;
|
||||
// params.coordinates = get_split_trace_locations();
|
||||
// params.timestamps = {1, 2, 1700, 1800};
|
||||
|
||||
json::Object json_result;
|
||||
const auto rc = run_match_json(osrm, params, json_result, use_json_only_api);
|
||||
// json::Object json_result;
|
||||
// const auto rc = run_match_json(osrm, params, json_result, use_json_only_api);
|
||||
|
||||
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
const auto code = std::get<json::String>(json_result.values.at("code")).value;
|
||||
BOOST_CHECK_EQUAL(code, "Ok");
|
||||
// BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
|
||||
// const auto code = std::get<json::String>(json_result.values.at("code")).value;
|
||||
// BOOST_CHECK_EQUAL(code, "Ok");
|
||||
|
||||
const auto &tracepoints = std::get<json::Array>(json_result.values.at("tracepoints")).values;
|
||||
BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size());
|
||||
// const auto &tracepoints = std::get<json::Array>(json_result.values.at("tracepoints")).values;
|
||||
// BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size());
|
||||
|
||||
const auto &matchings = std::get<json::Array>(json_result.values.at("matchings")).values;
|
||||
const auto &number_of_matchings = matchings.size();
|
||||
BOOST_CHECK_EQUAL(number_of_matchings, 2);
|
||||
std::size_t current_matchings_index = 0, expected_waypoint_index = 0;
|
||||
for (const auto &waypoint : tracepoints)
|
||||
{
|
||||
if (std::holds_alternative<util::json::Object>(waypoint))
|
||||
{
|
||||
BOOST_CHECK(waypoint_check(waypoint));
|
||||
const auto &waypoint_object = std::get<json::Object>(waypoint);
|
||||
const auto matchings_index =
|
||||
std::get<json::Number>(waypoint_object.values.at("matchings_index")).value;
|
||||
const auto waypoint_index =
|
||||
std::get<json::Number>(waypoint_object.values.at("waypoint_index")).value;
|
||||
// const auto &matchings = std::get<json::Array>(json_result.values.at("matchings")).values;
|
||||
// const auto &number_of_matchings = matchings.size();
|
||||
// BOOST_CHECK_EQUAL(number_of_matchings, 2);
|
||||
// std::size_t current_matchings_index = 0, expected_waypoint_index = 0;
|
||||
// for (const auto &waypoint : tracepoints)
|
||||
// {
|
||||
// if (std::holds_alternative<util::json::Object>(waypoint))
|
||||
// {
|
||||
// BOOST_CHECK(waypoint_check(waypoint));
|
||||
// const auto &waypoint_object = std::get<json::Object>(waypoint);
|
||||
// const auto matchings_index =
|
||||
// std::get<json::Number>(waypoint_object.values.at("matchings_index")).value;
|
||||
// const auto waypoint_index =
|
||||
// std::get<json::Number>(waypoint_object.values.at("waypoint_index")).value;
|
||||
|
||||
BOOST_CHECK_LT(matchings_index, number_of_matchings);
|
||||
// BOOST_CHECK_LT(matchings_index, number_of_matchings);
|
||||
|
||||
expected_waypoint_index =
|
||||
(current_matchings_index != matchings_index) ? 0 : expected_waypoint_index;
|
||||
BOOST_CHECK_EQUAL(waypoint_index, expected_waypoint_index);
|
||||
// expected_waypoint_index =
|
||||
// (current_matchings_index != matchings_index) ? 0 : expected_waypoint_index;
|
||||
// BOOST_CHECK_EQUAL(waypoint_index, expected_waypoint_index);
|
||||
|
||||
current_matchings_index = matchings_index;
|
||||
++expected_waypoint_index;
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_CHECK(std::holds_alternative<json::Null>(waypoint));
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOST_AUTO_TEST_CASE(test_match_split_old_api) { test_match_split(true); }
|
||||
BOOST_AUTO_TEST_CASE(test_match_split_new_api) { test_match_split(false); }
|
||||
// current_matchings_index = matchings_index;
|
||||
// ++expected_waypoint_index;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// BOOST_CHECK(std::holds_alternative<json::Null>(waypoint));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// BOOST_AUTO_TEST_CASE(test_match_split_old_api) { test_match_split(true); }
|
||||
// BOOST_AUTO_TEST_CASE(test_match_split_new_api) { test_match_split(false); }
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_match_fb_serialization)
|
||||
{
|
||||
using namespace osrm;
|
||||
// BOOST_AUTO_TEST_CASE(test_match_fb_serialization)
|
||||
// {
|
||||
// using namespace osrm;
|
||||
|
||||
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
||||
// auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
||||
|
||||
MatchParameters params;
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
// MatchParameters params;
|
||||
// params.coordinates.push_back(get_dummy_location());
|
||||
// params.coordinates.push_back(get_dummy_location());
|
||||
// params.coordinates.push_back(get_dummy_location());
|
||||
|
||||
engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
|
||||
// engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
|
||||
|
||||
const auto rc = osrm.Match(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
// const auto rc = osrm.Match(params, result);
|
||||
// BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
|
||||
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
|
||||
// auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
|
||||
// auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
|
||||
|
||||
BOOST_CHECK(!fb->error());
|
||||
// BOOST_CHECK(!fb->error());
|
||||
|
||||
BOOST_CHECK(fb->waypoints() != nullptr);
|
||||
const auto waypoints = fb->waypoints();
|
||||
BOOST_CHECK(waypoints->size() == params.coordinates.size());
|
||||
// BOOST_CHECK(fb->waypoints() != nullptr);
|
||||
// const auto waypoints = fb->waypoints();
|
||||
// BOOST_CHECK(waypoints->size() == params.coordinates.size());
|
||||
|
||||
BOOST_CHECK(fb->routes() != nullptr);
|
||||
const auto matchings = fb->routes();
|
||||
const auto &number_of_matchings = matchings->size();
|
||||
// BOOST_CHECK(fb->routes() != nullptr);
|
||||
// const auto matchings = fb->routes();
|
||||
// const auto &number_of_matchings = matchings->size();
|
||||
|
||||
for (const auto waypoint : *waypoints)
|
||||
{
|
||||
BOOST_CHECK(waypoint_check(waypoint));
|
||||
const auto matchings_index = waypoint->matchings_index();
|
||||
const auto waypoint_index = waypoint->waypoint_index();
|
||||
const auto &route_legs = matchings->operator[](matchings_index)->legs();
|
||||
// for (const auto waypoint : *waypoints)
|
||||
// {
|
||||
// BOOST_CHECK(waypoint_check(waypoint));
|
||||
// const auto matchings_index = waypoint->matchings_index();
|
||||
// const auto waypoint_index = waypoint->waypoint_index();
|
||||
// const auto &route_legs = matchings->operator[](matchings_index)->legs();
|
||||
|
||||
BOOST_CHECK_LT(waypoint_index, route_legs->size() + 1);
|
||||
BOOST_CHECK_LT(matchings_index, number_of_matchings);
|
||||
}
|
||||
}
|
||||
// BOOST_CHECK_LT(waypoint_index, route_legs->size() + 1);
|
||||
// BOOST_CHECK_LT(matchings_index, number_of_matchings);
|
||||
// }
|
||||
// }
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_match_fb_serialization_skip_waypoints)
|
||||
{
|
||||
using namespace osrm;
|
||||
// BOOST_AUTO_TEST_CASE(test_match_fb_serialization_skip_waypoints)
|
||||
// {
|
||||
// using namespace osrm;
|
||||
|
||||
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
||||
// auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
||||
|
||||
MatchParameters params;
|
||||
params.skip_waypoints = true;
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
// MatchParameters params;
|
||||
// params.skip_waypoints = true;
|
||||
// params.coordinates.push_back(get_dummy_location());
|
||||
// params.coordinates.push_back(get_dummy_location());
|
||||
// params.coordinates.push_back(get_dummy_location());
|
||||
|
||||
engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
|
||||
// engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
|
||||
|
||||
const auto rc = osrm.Match(params, result);
|
||||
BOOST_CHECK(rc == Status::Ok);
|
||||
// const auto rc = osrm.Match(params, result);
|
||||
// BOOST_CHECK(rc == Status::Ok);
|
||||
|
||||
auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
|
||||
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
|
||||
// auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
|
||||
// auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
|
||||
|
||||
BOOST_CHECK(!fb->error());
|
||||
// BOOST_CHECK(!fb->error());
|
||||
|
||||
BOOST_CHECK(fb->waypoints() == nullptr);
|
||||
}
|
||||
// BOOST_CHECK(fb->waypoints() == nullptr);
|
||||
// }
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
// BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -127,7 +127,7 @@ void test_route_same_coordinates_fixture(bool use_json_only_api)
|
||||
|
||||
}}}}}}}}}}}}}}}}};
|
||||
|
||||
CHECK_EQUAL_JSON(reference, json_result);
|
||||
// CHECK_EQUAL_JSON(reference, json_result);
|
||||
}
|
||||
BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture_old_api)
|
||||
{
|
||||
|
||||
@@ -11,10 +11,10 @@ inline bool waypoint_check(osrm::json::Value waypoint)
|
||||
{
|
||||
using namespace osrm;
|
||||
|
||||
if (!std::holds_alternative<util::json::Object>(waypoint))
|
||||
{
|
||||
throw util::exception("Must pass in a waypoint object");
|
||||
}
|
||||
// if (!std::holds_alternative<util::json::Object>(waypoint))
|
||||
// {
|
||||
// throw util::exception("Must pass in a waypoint object");
|
||||
// }
|
||||
const auto waypoint_object = std::get<json::Object>(waypoint);
|
||||
const auto waypoint_location =
|
||||
std::get<json::Array>(waypoint_object.values.at("location")).values;
|
||||
|
||||
@@ -17,6 +17,7 @@ const static std::string IO_TOO_SMALL_FILE = "file_too_small_test_io.tmp";
|
||||
const static std::string IO_CORRUPT_FINGERPRINT_FILE = "corrupt_fingerprint_file_test_io.tmp";
|
||||
const static std::string IO_INCOMPATIBLE_FINGERPRINT_FILE =
|
||||
"incompatible_fingerprint_file_test_io.tmp";
|
||||
const static std::string IO_TEXT_FILE = "plain_text_file.tmp";
|
||||
|
||||
using namespace osrm;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user