Compare commits
	
		
			9 Commits
		
	
	
		
			sf-get-rid
			...
			master
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 6ab6564d42 | |||
| 513966056b | |||
| 2c91c0c259 | |||
|  | c59ad69d6a | ||
|  | 61464fc2bd | ||
|  | 6f235cca15 | ||
|  | 3614af7f64 | ||
|  | 48e8382785 | ||
|  | becfd8a56d | 
							
								
								
									
										65
									
								
								.gitea/workflows/publish-container.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								.gitea/workflows/publish-container.yaml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,65 @@ | |||||||
|  | name: Build and Publish Docker Image | ||||||
|  | 
 | ||||||
|  | on: | ||||||
|  |   release: | ||||||
|  |     types: [published, prereleased] | ||||||
|  | 
 | ||||||
|  | env: | ||||||
|  |   IMAGE_NAME: openharbor/osrm-backend | ||||||
|  | 
 | ||||||
|  | jobs: | ||||||
|  |   publish: | ||||||
|  |     strategy: | ||||||
|  |       matrix: | ||||||
|  |         docker-base-image: ["debian", "alpine"] | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |     steps: | ||||||
|  |       - name: Check out the repo | ||||||
|  |         uses: actions/checkout@v3 | ||||||
|  | 
 | ||||||
|  |       - name: Set up QEMU | ||||||
|  |         uses: docker/setup-qemu-action@v2 | ||||||
|  | 
 | ||||||
|  |       - name: Set up Docker Buildx | ||||||
|  |         uses: docker/setup-buildx-action@v2 | ||||||
|  | 
 | ||||||
|  |       - name: Docker meta | ||||||
|  |         id: meta | ||||||
|  |         uses: docker/metadata-action@v4 | ||||||
|  |         with: | ||||||
|  |           images: ${{ env.IMAGE_NAME }} | ||||||
|  | 
 | ||||||
|  |       - name: Docker meta - debug | ||||||
|  |         id: metadebug | ||||||
|  |         uses: docker/metadata-action@v4 | ||||||
|  |         with: | ||||||
|  |           images: ${{ env.IMAGE_NAME }} | ||||||
|  |           flavor: | | ||||||
|  |             latest=true | ||||||
|  |             suffix=-debug,onlatest=true | ||||||
|  | 
 | ||||||
|  |       - name: Log in to DockerHub | ||||||
|  |         uses: docker/login-action@v2 | ||||||
|  |         with: | ||||||
|  |           username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||||
|  |           password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} | ||||||
|  | 
 | ||||||
|  |       - name: Build and push debug image | ||||||
|  |         uses: docker/build-push-action@v4 | ||||||
|  |         with: | ||||||
|  |           push: true | ||||||
|  |           platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/riscv64 | ||||||
|  |           file: ./docker/Dockerfile-${{ matrix.docker-base-image }} | ||||||
|  |           tags: ${{ steps.metadebug.outputs.tags }} | ||||||
|  |           build-args: | | ||||||
|  |             DOCKER_TAG=${{ join(steps.metadebug.outputs.tags) }}-${{ matrix.docker-base-image }} | ||||||
|  | 
 | ||||||
|  |       - name: Build and push normal image | ||||||
|  |         uses: docker/build-push-action@v4 | ||||||
|  |         with: | ||||||
|  |           push: true | ||||||
|  |           platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/riscv64 | ||||||
|  |           file: ./docker/Dockerfile-${{ matrix.docker-base-image }} | ||||||
|  |           tags: ${{ steps.meta.outputs.tags }} | ||||||
|  |           build-args: | | ||||||
|  |             DOCKER_TAG=${{ join(steps.meta.outputs.tags) }}-${{ matrix.docker-base-image }} | ||||||
							
								
								
									
										17
									
								
								.github/workflows/osrm-backend.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								.github/workflows/osrm-backend.yml
									
									
									
									
										vendored
									
									
								
							| @ -446,14 +446,14 @@ jobs: | |||||||
|       if: steps.cache-boost.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ENABLE_CONAN != 'ON' |       if: steps.cache-boost.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ENABLE_CONAN != 'ON' | ||||||
|       run: | |       run: | | ||||||
|         BOOST_VERSION="1.85.0" |         BOOST_VERSION="1.85.0" | ||||||
|         BOOST_VERSION_UNDERSCORE="${BOOST_VERSION//./_}" |         BOOST_VERSION_FLAVOR="${BOOST_VERSION}-b2-nodocs" | ||||||
|         wget -q https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_UNDERSCORE}.tar.gz |         wget -q https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION_FLAVOR}.tar.gz | ||||||
|         tar xzf boost_${BOOST_VERSION_UNDERSCORE}.tar.gz |         tar xzf boost-${BOOST_VERSION_FLAVOR}.tar.gz | ||||||
|         cd boost_${BOOST_VERSION_UNDERSCORE} |         cd boost-${BOOST_VERSION} | ||||||
|         sudo ./bootstrap.sh |         sudo ./bootstrap.sh | ||||||
|         sudo ./b2 install |         sudo ./b2 install | ||||||
|         cd .. |         cd .. | ||||||
|         sudo rm -rf boost_${BOOST_VERSION_UNDERSCORE}* |         sudo rm -rf boost-${BOOST_VERSION}* | ||||||
|      |      | ||||||
|     - name: Install dev dependencies |     - name: Install dev dependencies | ||||||
|       run: | |       run: | | ||||||
| @ -502,6 +502,13 @@ jobs: | |||||||
| 
 | 
 | ||||||
|         conan config init |         conan config init | ||||||
|         yq eval '.compiler.clang.version += ["18"]' -i "$HOME/.conan/settings.yml" |         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 |     - name: Prepare build | ||||||
|       run: | |       run: | | ||||||
|         mkdir ${OSRM_BUILD_DIR} |         mkdir ${OSRM_BUILD_DIR} | ||||||
|  | |||||||
| @ -25,6 +25,7 @@ | |||||||
|     - NodeJS: |     - NodeJS: | ||||||
|       - CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452) |       - CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452) | ||||||
|     - Misc: |     - 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: 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: 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) |       - CHANGED: Add .reserve(...) to assembleGeometry function. [#6983](https://github.com/Project-OSRM/osrm-backend/pull/6983) | ||||||
| @ -79,6 +80,7 @@ | |||||||
|       - ADDED: Extract prerelease/build information from package semver [#6839](https://github.com/Project-OSRM/osrm-backend/pull/6839) |       - ADDED: Extract prerelease/build information from package semver [#6839](https://github.com/Project-OSRM/osrm-backend/pull/6839) | ||||||
|     - Profiles: |     - Profiles: | ||||||
|       - FIXED: Bicycle and foot profiles now don't route on proposed ways [#6615](https://github.com/Project-OSRM/osrm-backend/pull/6615) |       - 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: |     - Routing: | ||||||
|       - FIXED: Fix adding traffic signal penalties during compression [#6419](https://github.com/Project-OSRM/osrm-backend/pull/6419) |       - 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) |       - FIXED: Correctly handle compressed traffic signals. [#6724](https://github.com/Project-OSRM/osrm-backend/pull/6724) | ||||||
|  | |||||||
| @ -56,6 +56,9 @@ endif() | |||||||
| if (POLICY CMP0074) | if (POLICY CMP0074) | ||||||
|   cmake_policy(SET CMP0074 NEW) |   cmake_policy(SET CMP0074 NEW) | ||||||
| endif() | endif() | ||||||
|  | if (POLICY CMP0167) | ||||||
|  |   cmake_policy(SET CMP0167 NEW) | ||||||
|  | endif() | ||||||
| project(OSRM C CXX) | project(OSRM C CXX) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,20 +1,34 @@ | |||||||
| FROM alpine:3.20.0 as alpine-mimalloc | FROM alpine:3.21.2 AS alpine-mimalloc | ||||||
| 
 | 
 | ||||||
| RUN apk add --no-cache mimalloc | RUN apk update && \ | ||||||
|  |     apk upgrade && \ | ||||||
|  |     apk add --no-cache \ | ||||||
|  |         boost-iostreams \ | ||||||
|  |         boost-program_options \ | ||||||
|  |         boost-thread \ | ||||||
|  |         mimalloc | ||||||
| 
 | 
 | ||||||
| ENV LD_PRELOAD=/usr/lib/libmimalloc.so.2 | ENV LD_PRELOAD=/usr/lib/libmimalloc.so.2 | ||||||
| ENV MIMALLOC_LARGE_OS_PAGES=1 | ENV MIMALLOC_LARGE_OS_PAGES=1 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| FROM alpine-mimalloc as builder | FROM alpine-mimalloc AS builder | ||||||
| ARG DOCKER_TAG | ARG DOCKER_TAG | ||||||
| ARG BUILD_CONCURRENCY | ARG BUILD_CONCURRENCY | ||||||
| RUN mkdir -p /src  && mkdir -p /opt |  | ||||||
| 
 | 
 | ||||||
| RUN apk add --no-cache \ | RUN mkdir -p /src /opt && \ | ||||||
|     cmake make git clang libbz2 libxml2 \ |     apk add --no-cache \ | ||||||
|     boost-dev boost-program_options boost-filesystem boost-iostreams boost-thread \ |     boost-dev \ | ||||||
|     lua5.4-dev onetbb-dev expat-dev |     boost-filesystem \ | ||||||
|  |     clang \ | ||||||
|  |     cmake \ | ||||||
|  |     expat-dev \ | ||||||
|  |     git \ | ||||||
|  |     libbz2 \ | ||||||
|  |     libxml2 \ | ||||||
|  |     lua5.4-dev \ | ||||||
|  |     make \ | ||||||
|  |     onetbb-dev | ||||||
| 
 | 
 | ||||||
| COPY . /src | COPY . /src | ||||||
| WORKDIR /src | WORKDIR /src | ||||||
| @ -39,16 +53,18 @@ RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \ | |||||||
|     rm -rf /src |     rm -rf /src | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # Multistage build to reduce image size - https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds | # Multistage build to reduce image size - https://docs.docker.com/build/building/multi-stage/#use-multi-stage-builds | ||||||
| # Only the content below ends up in the image, this helps remove /src from the image (which is large) | # Only the content below ends up in the image, this helps remove /src from the image (which is large) | ||||||
| FROM alpine-mimalloc as runstage | FROM alpine-mimalloc AS runstage | ||||||
| 
 | 
 | ||||||
| COPY --from=builder /usr/local /usr/local | COPY --from=builder /usr/local /usr/local | ||||||
| COPY --from=builder /opt /opt | COPY --from=builder /opt /opt | ||||||
| 
 | 
 | ||||||
| RUN apk add --no-cache \ | RUN apk add --no-cache \ | ||||||
|     boost-program_options boost-date_time boost-iostreams boost-thread \ |     boost-date_time \ | ||||||
|     expat lua5.4 onetbb && \ |     expat \ | ||||||
|  |     lua5.4 \ | ||||||
|  |     onetbb && \ | ||||||
|     ldconfig /usr/local/lib |     ldconfig /usr/local/lib | ||||||
| 
 | 
 | ||||||
| RUN /usr/local/bin/osrm-extract --help && \ | RUN /usr/local/bin/osrm-extract --help && \ | ||||||
| @ -60,3 +76,4 @@ RUN /usr/local/bin/osrm-extract --help && \ | |||||||
| WORKDIR /opt | WORKDIR /opt | ||||||
| 
 | 
 | ||||||
| EXPOSE 5000 | EXPOSE 5000 | ||||||
|  | 
 | ||||||
|  | |||||||
| @ -1,21 +1,24 @@ | |||||||
| FROM debian:bookworm-slim as builder | FROM debian:bookworm-slim AS builder | ||||||
| ARG DOCKER_TAG | ARG DOCKER_TAG | ||||||
| ARG BUILD_CONCURRENCY | ARG BUILD_CONCURRENCY | ||||||
| RUN mkdir -p /src  && mkdir -p /opt |  | ||||||
| 
 | 
 | ||||||
| RUN apt-get update && \ | RUN mkdir -p /src /opt && \ | ||||||
|     apt-get -y --no-install-recommends install ca-certificates cmake make git gcc g++ libbz2-dev libxml2-dev wget \ |     apt-get update && \ | ||||||
|     libzip-dev libboost1.81-all-dev lua5.4 liblua5.4-dev pkg-config -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 |     apt-get -y --no-install-recommends --no-install-suggests install \ | ||||||
| 
 |         ca-certificates \ | ||||||
| RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \ |         cmake \ | ||||||
|     ldconfig /usr/local/lib && \ |         g++ \ | ||||||
|     git clone --branch v2021.12.0 --single-branch https://github.com/oneapi-src/oneTBB.git && \ |         gcc \ | ||||||
|     cd oneTBB && \ |         git \ | ||||||
|     mkdir build && \ |         libboost1.81-all-dev \ | ||||||
|     cd build && \ |         libbz2-dev \ | ||||||
|     cmake -DTBB_TEST=OFF -DCMAKE_BUILD_TYPE=Release ..  && \ |         liblua5.4-dev \ | ||||||
|     cmake --build . && \ |         libtbb-dev \ | ||||||
|     cmake --install . |         libxml2-dev \ | ||||||
|  |         libzip-dev \ | ||||||
|  |         lua5.4 \ | ||||||
|  |         make \ | ||||||
|  |         pkg-config | ||||||
| 
 | 
 | ||||||
| COPY . /src | COPY . /src | ||||||
| WORKDIR /src | WORKDIR /src | ||||||
| @ -41,19 +44,24 @@ RUN NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \ | |||||||
|     rm -rf /src |     rm -rf /src | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # Multistage build to reduce image size - https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds | # Multistage build to reduce image size - https://docs.docker.com/build/building/multi-stage/#use-multi-stage-builds | ||||||
| # Only the content below ends up in the image, this helps remove /src from the image (which is large) | # Only the content below ends up in the image, this helps remove /src from the image (which is large) | ||||||
| FROM debian:bookworm-slim as runstage | FROM debian:bookworm-slim AS runstage | ||||||
| 
 | 
 | ||||||
| COPY --from=builder /usr/local /usr/local | COPY --from=builder /usr/local /usr/local | ||||||
| COPY --from=builder /opt /opt | COPY --from=builder /opt /opt | ||||||
| 
 | 
 | ||||||
| RUN apt-get update && \ | RUN apt-get update && \ | ||||||
|     apt-get install -y --no-install-recommends \ |     apt-get install -y --no-install-recommends --no-install-suggests \ | ||||||
|         libboost-program-options1.81.0 libboost-date-time1.81.0 libboost-iostreams1.81.0 libboost-thread1.81.0 \ |         expat \ | ||||||
|         expat liblua5.4-0 && \ |         libboost-date-time1.81.0 \ | ||||||
|  |         libboost-iostreams1.81.0 \ | ||||||
|  |         libboost-program-options1.81.0 \ | ||||||
|  |         libboost-thread1.81.0 \ | ||||||
|  |         liblua5.4-0 \ | ||||||
|  |         libtbb12 && \ | ||||||
|     rm -rf /var/lib/apt/lists/* && \ |     rm -rf /var/lib/apt/lists/* && \ | ||||||
| # add /usr/local/lib to ldconfig to allow loading libraries from there | # Add /usr/local/lib to ldconfig to allow loading libraries from there | ||||||
|     ldconfig /usr/local/lib |     ldconfig /usr/local/lib | ||||||
| 
 | 
 | ||||||
| RUN /usr/local/bin/osrm-extract --help && \ | RUN /usr/local/bin/osrm-extract --help && \ | ||||||
| @ -65,3 +73,4 @@ RUN /usr/local/bin/osrm-extract --help && \ | |||||||
| WORKDIR /opt | WORKDIR /opt | ||||||
| 
 | 
 | ||||||
| EXPOSE 5000 | EXPOSE 5000 | ||||||
|  | 
 | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ struct V8Renderer | |||||||
|         { |         { | ||||||
|             Napi::Value child; |             Napi::Value child; | ||||||
|             std::visit(V8Renderer(env, child), keyValue.second); |             std::visit(V8Renderer(env, child), keyValue.second); | ||||||
|             obj.Set(keyValue.first, child); |             obj.Set(keyValue.first.data(), child); | ||||||
|         } |         } | ||||||
|         out = obj; |         out = obj; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -11,46 +11,6 @@ namespace osrm::util | |||||||
| namespace bearing | 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
 | // Checks whether A is between B-range and B+range, all modulo 360
 | ||||||
| // e.g. A = 5, B = 5, range = 10 == true
 | // e.g. A = 5, B = 5, range = 10 == true
 | ||||||
| //      A = -6, B = 5, range = 10 == false
 | //      A = -6, B = 5, range = 10 == false
 | ||||||
|  | |||||||
| @ -90,164 +90,33 @@ 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. |  * Typed Object. | ||||||
|  * |  * | ||||||
|  * Unwrap the key-value pairs holding type via its values member attribute. |  * Unwrap the key-value pairs holding type via its values member attribute. | ||||||
|  */ |  */ | ||||||
| struct Object; | struct Object | ||||||
|  | { | ||||||
|  |     std::unordered_map<std::string_view, Value> values; | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  * Typed Array. |  * Typed Array. | ||||||
|  * |  * | ||||||
|  * Unwrap the Value holding type via its values member attribute. |  * 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 | struct Array | ||||||
| { | { | ||||||
|     std::vector<Value> values; |     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 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
 | #endif // JSON_CONTAINER_HPP
 | ||||||
|  | |||||||
| @ -1,159 +1,158 @@ | |||||||
| // #ifndef UTIL_JSON_DEEP_COMPARE_HPP
 | #ifndef UTIL_JSON_DEEP_COMPARE_HPP | ||||||
| // #define UTIL_JSON_DEEP_COMPARE_HPP
 | #define UTIL_JSON_DEEP_COMPARE_HPP | ||||||
| 
 | 
 | ||||||
| // #include "util/integer_range.hpp"
 | #include "util/integer_range.hpp" | ||||||
| // #include "util/json_container.hpp"
 | #include "util/json_container.hpp" | ||||||
| 
 | 
 | ||||||
| // #include <boost/assert.hpp>
 | #include <boost/assert.hpp> | ||||||
| 
 | 
 | ||||||
| // #include <algorithm>
 | #include <algorithm> | ||||||
| // #include <functional>
 | #include <functional> | ||||||
| // #include <set>
 | #include <set> | ||||||
| 
 | 
 | ||||||
| // namespace osrm::util::json
 | namespace osrm::util::json | ||||||
| // {
 | { | ||||||
| 
 | 
 | ||||||
| // struct Comparator
 | struct Comparator | ||||||
| // {
 | { | ||||||
| //     Comparator(std::string &reason_, const std::string &lhs_path_, const std::string &rhs_path_)
 |     Comparator(std::string &reason_, const std::string &lhs_path_, const std::string &rhs_path_) | ||||||
| //         : reason(reason_), lhs_path(lhs_path_), rhs_path(rhs_path_)
 |         : reason(reason_), lhs_path(lhs_path_), rhs_path(rhs_path_) | ||||||
| //     {
 |     { | ||||||
| //     }
 |     } | ||||||
| 
 | 
 | ||||||
| //     bool operator()(const String &lhs, const String &rhs) const
 |     bool operator()(const String &lhs, const String &rhs) const | ||||||
| //     {
 |     { | ||||||
| //         bool is_same = lhs.value == rhs.value;
 |         bool is_same = lhs.value == rhs.value; | ||||||
| //         if (!is_same)
 |         if (!is_same) | ||||||
| //         {
 |         { | ||||||
| //             reason = lhs_path + " (= \"" + lhs.value + "\") != " + rhs_path + " (= \"" +
 |             reason = lhs_path + " (= \"" + lhs.value + "\") != " + rhs_path + " (= \"" + rhs.value + | ||||||
| //             rhs.value +
 |                      "\")"; | ||||||
| //                      "\")";
 |         } | ||||||
| //         }
 |         return is_same; | ||||||
| //         return is_same;
 |     } | ||||||
| //     }
 |  | ||||||
| 
 | 
 | ||||||
| //     bool operator()(const Number &lhs, const Number &rhs) const
 |     bool operator()(const Number &lhs, const Number &rhs) const | ||||||
| //     {
 |     { | ||||||
| //         bool is_same = lhs.value == rhs.value;
 |         bool is_same = lhs.value == rhs.value; | ||||||
| //         if (!is_same)
 |         if (!is_same) | ||||||
| //         {
 |         { | ||||||
| //             reason = lhs_path + " (= " + std::to_string(lhs.value) + ") != " + rhs_path +
 |             reason = lhs_path + " (= " + std::to_string(lhs.value) + ") != " + rhs_path + | ||||||
| //                      " (= " + std::to_string(rhs.value) + ")";
 |                      " (= " + std::to_string(rhs.value) + ")"; | ||||||
| //         }
 |         } | ||||||
| //         return is_same;
 |         return is_same; | ||||||
| //     }
 |     } | ||||||
| 
 | 
 | ||||||
| //     bool operator()(const Object &lhs, const Object &rhs) const
 |     bool operator()(const Object &lhs, const Object &rhs) const | ||||||
| //     {
 |     { | ||||||
| //         std::set<std::string> lhs_keys;
 |         std::set<std::string_view> lhs_keys; | ||||||
| //         for (const auto &key_value : lhs.values)
 |         for (const auto &key_value : lhs.values) | ||||||
| //         {
 |         { | ||||||
| //             lhs_keys.insert(key_value.first);
 |             lhs_keys.insert(key_value.first); | ||||||
| //         }
 |         } | ||||||
| 
 | 
 | ||||||
| //         std::set<std::string> rhs_keys;
 |         std::set<std::string_view> rhs_keys; | ||||||
| //         for (const auto &key_value : rhs.values)
 |         for (const auto &key_value : rhs.values) | ||||||
| //         {
 |         { | ||||||
| //             rhs_keys.insert(key_value.first);
 |             rhs_keys.insert(key_value.first); | ||||||
| //         }
 |         } | ||||||
| 
 | 
 | ||||||
| //         for (const auto &key : lhs_keys)
 |         for (const auto &key : lhs_keys) | ||||||
| //         {
 |         { | ||||||
| //             if (rhs_keys.find(key) == rhs_keys.end())
 |             if (rhs_keys.find(key) == rhs_keys.end()) | ||||||
| //             {
 |             { | ||||||
| //                 reason = rhs_path + " doesn't have key \"" + key + "\"";
 |                 reason = rhs_path + " doesn't have key \"" + std::string(key) + "\""; | ||||||
| //                 return false;
 |                 return false; | ||||||
| //             }
 |             } | ||||||
| //         }
 |         } | ||||||
| 
 | 
 | ||||||
| //         for (const auto &key : rhs_keys)
 |         for (const auto &key : rhs_keys) | ||||||
| //         {
 |         { | ||||||
| //             if (lhs_keys.find(key) == lhs_keys.end())
 |             if (lhs_keys.find(key) == lhs_keys.end()) | ||||||
| //             {
 |             { | ||||||
| //                 reason = lhs_path + " doesn't have key \"" + key + "\"";
 |                 reason = lhs_path + " doesn't have key \"" + std::string(key) + "\""; | ||||||
| //                 return false;
 |                 return false; | ||||||
| //             }
 |             } | ||||||
| //         }
 |         } | ||||||
| 
 | 
 | ||||||
| //         for (const auto &key : lhs_keys)
 |         for (const auto &key : lhs_keys) | ||||||
| //         {
 |         { | ||||||
| //             BOOST_ASSERT(rhs.values.find(key) != rhs.values.end());
 |             BOOST_ASSERT(rhs.values.find(key) != rhs.values.end()); | ||||||
| //             BOOST_ASSERT(lhs.values.find(key) != lhs.values.end());
 |             BOOST_ASSERT(lhs.values.find(key) != lhs.values.end()); | ||||||
| 
 | 
 | ||||||
| //             const auto &rhs_child = rhs.values.find(key)->second;
 |             const auto &rhs_child = rhs.values.find(key)->second; | ||||||
| //             const auto &lhs_child = lhs.values.find(key)->second;
 |             const auto &lhs_child = lhs.values.find(key)->second; | ||||||
| //             auto is_same =
 |             auto is_same = std::visit(Comparator(reason, | ||||||
| //                 std::visit(Comparator(reason, lhs_path + "." + key, rhs_path + "." + key),
 |                                                  lhs_path + "." + std::string(key), | ||||||
| //                            lhs_child,
 |                                                  rhs_path + "." + std::string(key)), | ||||||
| //                            rhs_child);
 |                                       lhs_child, | ||||||
| //             if (!is_same)
 |                                       rhs_child); | ||||||
| //             {
 |             if (!is_same) | ||||||
| //                 return false;
 |             { | ||||||
| //             }
 |                 return false; | ||||||
| //         }
 |             } | ||||||
| //         return true;
 |         } | ||||||
| //     }
 |         return true; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| //     bool operator()(const Array &lhs, const Array &rhs) const
 |     bool operator()(const Array &lhs, const Array &rhs) const | ||||||
| //     {
 |     { | ||||||
| //         if (lhs.values.size() != rhs.values.size())
 |         if (lhs.values.size() != rhs.values.size()) | ||||||
| //         {
 |         { | ||||||
| //             reason = lhs_path + ".length " + std::to_string(lhs.values.size()) + " != " +
 |             reason = lhs_path + ".length " + std::to_string(lhs.values.size()) + " != " + rhs_path + | ||||||
| //             rhs_path +
 |                      ".length " + std::to_string(rhs.values.size()); | ||||||
| //                      ".length " + std::to_string(rhs.values.size());
 |             return false; | ||||||
| //             return false;
 |         } | ||||||
| //         }
 |  | ||||||
| 
 | 
 | ||||||
| //         for (auto i = 0UL; i < lhs.values.size(); ++i)
 |         for (auto i = 0UL; i < lhs.values.size(); ++i) | ||||||
| //         {
 |         { | ||||||
| //             auto is_same = std::visit(Comparator(reason,
 |             auto is_same = std::visit(Comparator(reason, | ||||||
| //                                                  lhs_path + "[" + std::to_string(i) + "]",
 |                                                  lhs_path + "[" + std::to_string(i) + "]", | ||||||
| //                                                  rhs_path + "[" + std::to_string(i) + "]"),
 |                                                  rhs_path + "[" + std::to_string(i) + "]"), | ||||||
| //                                       lhs.values[i],
 |                                       lhs.values[i], | ||||||
| //                                       rhs.values[i]);
 |                                       rhs.values[i]); | ||||||
| //             if (!is_same)
 |             if (!is_same) | ||||||
| //             {
 |             { | ||||||
| //                 return false;
 |                 return false; | ||||||
| //             }
 |             } | ||||||
| //         }
 |         } | ||||||
| 
 | 
 | ||||||
| //         return true;
 |         return true; | ||||||
| //     }
 |     } | ||||||
| 
 | 
 | ||||||
| //     bool operator()(const True &, const True &) const { return true; }
 |     bool operator()(const True &, const True &) const { return true; } | ||||||
| //     bool operator()(const False &, const False &) const { return true; }
 |     bool operator()(const False &, const False &) const { return true; } | ||||||
| //     bool operator()(const Null &, const Null &) const { return true; }
 |     bool operator()(const Null &, const Null &) const { return true; } | ||||||
| 
 | 
 | ||||||
| //     bool operator()(const False &, const True &) const
 |     bool operator()(const False &, const True &) const | ||||||
| //     {
 |     { | ||||||
| //         reason = lhs_path + " is false but " + rhs_path + " is true";
 |         reason = lhs_path + " is false but " + rhs_path + " is true"; | ||||||
| //         return false;
 |         return false; | ||||||
| //     }
 |     } | ||||||
| //     bool operator()(const True &, const False &) const
 |     bool operator()(const True &, const False &) const | ||||||
| //     {
 |     { | ||||||
| //         reason = lhs_path + " is true but " + rhs_path + " is false";
 |         reason = lhs_path + " is true but " + rhs_path + " is false"; | ||||||
| //         return false;
 |         return false; | ||||||
| //     }
 |     } | ||||||
| 
 | 
 | ||||||
| //     template <typename T1,
 |     template <typename T1, | ||||||
| //               typename T2,
 |               typename T2, | ||||||
| //               typename = typename std::enable_if<!std::is_same<T1, T2>::value>::type>
 |               typename = typename std::enable_if<!std::is_same<T1, T2>::value>::type> | ||||||
| //     bool operator()(const T1 &, const T2 &)
 |     bool operator()(const T1 &, const T2 &) | ||||||
| //     {
 |     { | ||||||
| //         reason = lhs_path + " and " + rhs_path + " have different types";
 |         reason = lhs_path + " and " + rhs_path + " have different types"; | ||||||
| //         return false;
 |         return false; | ||||||
| //     }
 |     } | ||||||
| 
 | 
 | ||||||
| //   private:
 |   private: | ||||||
| //     std::string &reason;
 |     std::string &reason; | ||||||
| //     const std::string &lhs_path;
 |     const std::string &lhs_path; | ||||||
| //     const std::string &rhs_path;
 |     const std::string &rhs_path; | ||||||
| // };
 | }; | ||||||
| 
 | 
 | ||||||
| // inline bool compare(const Value &reference, const Value &result, std::string &reason)
 | inline bool compare(const Value &reference, const Value &result, std::string &reason) | ||||||
| // {
 | { | ||||||
| //     return std::visit(Comparator(reason, "reference", "result"), reference, result);
 |     return std::visit(Comparator(reason, "reference", "result"), reference, result); | ||||||
| // }
 | } | ||||||
| // } // namespace osrm::util::json
 | } // namespace osrm::util::json
 | ||||||
| 
 | 
 | ||||||
| // #endif
 | #endif | ||||||
|  | |||||||
| @ -97,7 +97,7 @@ template <typename Out> struct Renderer | |||||||
|     void operator()(const Null &) { write<>("null"); } |     void operator()(const Null &) { write<>("null"); } | ||||||
| 
 | 
 | ||||||
|   private: |   private: | ||||||
|     void write(const std::string &str); |     void write(std::string_view str); | ||||||
|     void write(const char *str, size_t size); |     void write(const char *str, size_t size); | ||||||
|     void write(char ch); |     void write(char ch); | ||||||
| 
 | 
 | ||||||
| @ -110,7 +110,7 @@ template <typename Out> struct Renderer | |||||||
|     Out &out; |     Out &out; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template <> void Renderer<std::vector<char>>::write(const std::string &str) | template <> void Renderer<std::vector<char>>::write(std::string_view str) | ||||||
| { | { | ||||||
|     out.insert(out.end(), str.begin(), str.end()); |     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::vector<char>>::write(char ch) { out.push_back(ch); } | ||||||
| 
 | 
 | ||||||
| template <> void Renderer<std::ostream>::write(const std::string &str) { out << str; } | template <> void Renderer<std::ostream>::write(std::string_view str) { out << str; } | ||||||
| 
 | 
 | ||||||
| template <> void Renderer<std::ostream>::write(const char *str, size_t size) | 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::ostream>::write(char ch) { out << ch; } | ||||||
| 
 | 
 | ||||||
| template <> void Renderer<std::string>::write(const std::string &str) { out += str; } | template <> void Renderer<std::string>::write(std::string_view str) { out += str; } | ||||||
| 
 | 
 | ||||||
| template <> void Renderer<std::string>::write(const char *str, size_t size) | template <> void Renderer<std::string>::write(const char *str, size_t size) | ||||||
| { | { | ||||||
|  | |||||||
| @ -35,6 +35,10 @@ function setup() | |||||||
|     turn_bias                 = 1.4, |     turn_bias                 = 1.4, | ||||||
|     use_public_transport      = true, |     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 { |     allowed_start_modes = Set { | ||||||
|       mode.cycling, |       mode.cycling, | ||||||
|       mode.pushing_bike |       mode.pushing_bike | ||||||
| @ -243,6 +247,27 @@ function process_node(profile, node, result) | |||||||
|     end |     end | ||||||
|   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 |   -- check if node is a traffic light | ||||||
|   result.traffic_lights = TrafficSignal.get_value(node) |   result.traffic_lights = TrafficSignal.get_value(node) | ||||||
| end | end | ||||||
| @ -299,6 +324,8 @@ function handle_bicycle_tags(profile,way,result,data) | |||||||
| 
 | 
 | ||||||
|   bike_push_handler(profile,way,result,data) |   bike_push_handler(profile,way,result,data) | ||||||
| 
 | 
 | ||||||
|  |   -- width should be after bike_push | ||||||
|  |   width_handler(profile,way,result,data) | ||||||
| 
 | 
 | ||||||
|   -- maxspeed |   -- maxspeed | ||||||
|   limit( result, data.maxspeed, data.maxspeed_forward, data.maxspeed_backward ) |   limit( result, data.maxspeed, data.maxspeed_forward, data.maxspeed_backward ) | ||||||
| @ -453,6 +480,27 @@ function cycleway_handler(profile,way,result,data) | |||||||
|   end |   end | ||||||
| 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) | function bike_push_handler(profile,way,result,data) | ||||||
|   -- pushing bikes - if no other mode found |   -- pushing bikes - if no other mode found | ||||||
|   if result.forward_mode == mode.inaccessible or result.backward_mode == mode.inaccessible or |   if result.forward_mode == mode.inaccessible or result.backward_mode == mode.inaccessible or | ||||||
|  | |||||||
| @ -9,12 +9,17 @@ | |||||||
| #include <rapidjson/document.h> | #include <rapidjson/document.h> | ||||||
| #include <sstream> | #include <sstream> | ||||||
| #include <stdexcept> | #include <stdexcept> | ||||||
|  | #include <unordered_set> | ||||||
| 
 | 
 | ||||||
| using namespace osrm; | using namespace osrm; | ||||||
| 
 | 
 | ||||||
| namespace | 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) | void convert(const rapidjson::Value &value, json::Value &result) | ||||||
| { | { | ||||||
|     if (value.IsString()) |     if (value.IsString()) | ||||||
| @ -32,7 +37,8 @@ void convert(const rapidjson::Value &value, json::Value &result) | |||||||
|         { |         { | ||||||
|             json::Value member; |             json::Value member; | ||||||
|             convert(itr->value, member); |             convert(itr->value, member); | ||||||
|             object.values.emplace(itr->name.GetString(), std::move(member)); |             auto keyItr = gKeysHolder.emplace(itr->name.GetString()).first; | ||||||
|  |             object.values.emplace(*keyItr, std::move(member)); | ||||||
|         } |         } | ||||||
|         result = std::move(object); |         result = std::move(object); | ||||||
|     } |     } | ||||||
| @ -122,6 +128,7 @@ int main(int argc, char **argv) | |||||||
| 
 | 
 | ||||||
|     if (std::string{out_vec.begin(), out_vec.end()} != out_str || out_str != out_ss_str) |     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"); |         throw std::logic_error("Vector/stringstream/string results are not equal"); | ||||||
|     } |     } | ||||||
|     return EXIT_SUCCESS; |     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("location", detail::coordinateToLonLat(intersection.location)); | ||||||
|     result.values.emplace("bearings", std::move(bearings)); |     result.values.emplace("bearings", bearings); | ||||||
|     result.values.emplace("entry", std::move(entry)); |     result.values.emplace("entry", entry); | ||||||
|     if (intersection.in != guidance::IntermediateIntersection::NO_INDEX) |     if (intersection.in != guidance::IntermediateIntersection::NO_INDEX) | ||||||
|         result.values.emplace("in", intersection.in); |         result.values.emplace("in", intersection.in); | ||||||
|     if (intersection.out != guidance::IntermediateIntersection::NO_INDEX) |     if (intersection.out != guidance::IntermediateIntersection::NO_INDEX) | ||||||
|  | |||||||
							
								
								
									
										3
									
								
								third_party/sol2/include/sol/sol.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								third_party/sol2/include/sol/sol.hpp
									
									
									
									
										vendored
									
									
								
							| @ -6752,7 +6752,8 @@ namespace sol { | |||||||
| 			static_assert(std::is_constructible<T, Args&&...>::value, "T must be constructible with Args"); | 			static_assert(std::is_constructible<T, Args&&...>::value, "T must be constructible with Args"); | ||||||
| 
 | 
 | ||||||
| 			*this = nullopt; | 			*this = nullopt; | ||||||
| 			this->construct(std::forward<Args>(args)...); | 			new (static_cast<void*>(this)) optional(std::in_place, std::forward<Args>(args)...); | ||||||
|  | 			return **this; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/// Swaps this optional with the other.
 | 		/// Swaps this optional with the other.
 | ||||||
|  | |||||||
| @ -1,28 +1,28 @@ | |||||||
| // #ifndef UNIT_TESTS_JSON_EQUAL
 | #ifndef UNIT_TESTS_JSON_EQUAL | ||||||
| // #define 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 "osrm/json_container.hpp" | ||||||
| // #include "util/json_deep_compare.hpp"
 | #include "util/json_deep_compare.hpp" | ||||||
| 
 | 
 | ||||||
| // inline boost::test_tools::predicate_result compareJSON(const osrm::util::json::Value &reference,
 | inline boost::test_tools::predicate_result compareJSON(const osrm::util::json::Value &reference, | ||||||
| //                                                        const osrm::util::json::Value &result)
 |                                                        const osrm::util::json::Value &result) | ||||||
| // {
 | { | ||||||
| //     std::string reason;
 |     std::string reason; | ||||||
| //     auto is_same = osrm::util::json::compare(reference, result, reason);
 |     auto is_same = osrm::util::json::compare(reference, result, reason); | ||||||
| //     if (!is_same)
 |     if (!is_same) | ||||||
| //     {
 |     { | ||||||
| //         boost::test_tools::predicate_result res(false);
 |         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 | ||||||
|  | |||||||
| @ -1,226 +1,226 @@ | |||||||
| // #include <boost/test/unit_test.hpp>
 | #include <boost/test/unit_test.hpp> | ||||||
| // #include <variant>
 | #include <variant> | ||||||
| 
 | 
 | ||||||
| // #include "coordinates.hpp"
 | #include "coordinates.hpp" | ||||||
| // #include "fixture.hpp"
 | #include "fixture.hpp" | ||||||
| // #include "waypoint_check.hpp"
 | #include "waypoint_check.hpp" | ||||||
| 
 | 
 | ||||||
| // #include "osrm/match_parameters.hpp"
 | #include "osrm/match_parameters.hpp" | ||||||
| 
 | 
 | ||||||
| // #include "osrm/coordinate.hpp"
 | #include "osrm/coordinate.hpp" | ||||||
| // #include "osrm/json_container.hpp"
 | #include "osrm/json_container.hpp" | ||||||
| // #include "osrm/osrm.hpp"
 | #include "osrm/osrm.hpp" | ||||||
| // #include "osrm/status.hpp"
 | #include "osrm/status.hpp" | ||||||
| 
 | 
 | ||||||
| // osrm::Status run_match_json(const osrm::OSRM &osrm,
 | osrm::Status run_match_json(const osrm::OSRM &osrm, | ||||||
| //                             const osrm::MatchParameters ¶ms,
 |                             const osrm::MatchParameters ¶ms, | ||||||
| //                             osrm::json::Object &json_result,
 |                             osrm::json::Object &json_result, | ||||||
| //                             bool use_json_only_api)
 |                             bool use_json_only_api) | ||||||
| // {
 | { | ||||||
| //     using namespace osrm;
 |     using namespace osrm; | ||||||
| 
 | 
 | ||||||
| //     if (use_json_only_api)
 |     if (use_json_only_api) | ||||||
| //     {
 |     { | ||||||
| //         return osrm.Match(params, json_result);
 |         return osrm.Match(params, json_result); | ||||||
| //     }
 |     } | ||||||
| //     engine::api::ResultT result = json::Object();
 |     engine::api::ResultT result = json::Object(); | ||||||
| //     auto rc = osrm.Match(params, result);
 |     auto rc = osrm.Match(params, result); | ||||||
| //     json_result = std::get<json::Object>(result);
 |     json_result = std::get<json::Object>(result); | ||||||
| //     return rc;
 |     return rc; | ||||||
| // }
 | } | ||||||
| 
 | 
 | ||||||
| // BOOST_AUTO_TEST_SUITE(match)
 | BOOST_AUTO_TEST_SUITE(match) | ||||||
| 
 | 
 | ||||||
| // void test_match(bool use_json_only_api)
 | void test_match(bool use_json_only_api) | ||||||
| // {
 | { | ||||||
| //     using namespace osrm;
 |     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;
 |     MatchParameters params; | ||||||
| //     params.coordinates.push_back(get_dummy_location());
 |     params.coordinates.push_back(get_dummy_location()); | ||||||
| //     params.coordinates.push_back(get_dummy_location());
 |     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;
 |     json::Object json_result; | ||||||
| //     const auto rc = run_match_json(osrm, params, json_result, use_json_only_api);
 |     const auto rc = run_match_json(osrm, params, json_result, use_json_only_api); | ||||||
| 
 | 
 | ||||||
| //     BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
 |     BOOST_CHECK(rc == Status::Ok || rc == Status::Error); | ||||||
| //     const auto code = std::get<json::String>(json_result.values.at("code")).value;
 |     const auto code = std::get<json::String>(json_result.values.at("code")).value; | ||||||
| //     BOOST_CHECK_EQUAL(code, "Ok");
 |     BOOST_CHECK_EQUAL(code, "Ok"); | ||||||
| 
 | 
 | ||||||
| //     const auto &tracepoints = std::get<json::Array>(json_result.values.at("tracepoints")).values;
 |     const auto &tracepoints = std::get<json::Array>(json_result.values.at("tracepoints")).values; | ||||||
| //     BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size());
 |     BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size()); | ||||||
| 
 | 
 | ||||||
| //     const auto &matchings = std::get<json::Array>(json_result.values.at("matchings")).values;
 |     const auto &matchings = std::get<json::Array>(json_result.values.at("matchings")).values; | ||||||
| //     const auto &number_of_matchings = matchings.size();
 |     const auto &number_of_matchings = matchings.size(); | ||||||
| //     for (const auto &waypoint : tracepoints)
 |     for (const auto &waypoint : tracepoints) | ||||||
| //     {
 |     { | ||||||
| //         if (std::holds_alternative<util::json::Object>(waypoint))
 |         if (std::holds_alternative<util::json::Object>(waypoint)) | ||||||
| //         {
 |         { | ||||||
| //             BOOST_CHECK(waypoint_check(waypoint));
 |             BOOST_CHECK(waypoint_check(waypoint)); | ||||||
| //             const auto &waypoint_object = std::get<json::Object>(waypoint);
 |             const auto &waypoint_object = std::get<json::Object>(waypoint); | ||||||
| //             const auto matchings_index =
 |             const auto matchings_index = | ||||||
| //                 std::get<json::Number>(waypoint_object.values.at("matchings_index")).value;
 |                 std::get<json::Number>(waypoint_object.values.at("matchings_index")).value; | ||||||
| //             const auto waypoint_index =
 |             const auto waypoint_index = | ||||||
| //                 std::get<json::Number>(waypoint_object.values.at("waypoint_index")).value;
 |                 std::get<json::Number>(waypoint_object.values.at("waypoint_index")).value; | ||||||
| //             const auto &route_legs =
 |             const auto &route_legs = | ||||||
| //                 std::get<json::Array>(
 |                 std::get<json::Array>( | ||||||
| //                     std::get<json::Object>(matchings[matchings_index]).values.at("legs"))
 |                     std::get<json::Object>(matchings[matchings_index]).values.at("legs")) | ||||||
| //                     .values;
 |                     .values; | ||||||
| //             BOOST_CHECK_LT(waypoint_index, route_legs.size() + 1);
 |             BOOST_CHECK_LT(waypoint_index, route_legs.size() + 1); | ||||||
| //             BOOST_CHECK_LT(matchings_index, number_of_matchings);
 |             BOOST_CHECK_LT(matchings_index, number_of_matchings); | ||||||
| //         }
 |         } | ||||||
| //         else
 |         else | ||||||
| //         {
 |         { | ||||||
| //             BOOST_CHECK(std::holds_alternative<json::Null>(waypoint));
 |             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_new_api) { test_match(false); } | ||||||
| // BOOST_AUTO_TEST_CASE(test_match_old_api) { test_match(true); }
 | BOOST_AUTO_TEST_CASE(test_match_old_api) { test_match(true); } | ||||||
| 
 | 
 | ||||||
| // void test_match_skip_waypoints(bool use_json_only_api)
 | void test_match_skip_waypoints(bool use_json_only_api) | ||||||
| // {
 | { | ||||||
| //     using namespace osrm;
 |     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;
 |     MatchParameters params; | ||||||
| //     params.skip_waypoints = true;
 |     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());
 |     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;
 |     json::Object json_result; | ||||||
| //     const auto rc = run_match_json(osrm, params, json_result, use_json_only_api);
 |     const auto rc = run_match_json(osrm, params, json_result, use_json_only_api); | ||||||
| 
 | 
 | ||||||
| //     BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
 |     BOOST_CHECK(rc == Status::Ok || rc == Status::Error); | ||||||
| //     const auto code = std::get<json::String>(json_result.values.at("code")).value;
 |     const auto code = std::get<json::String>(json_result.values.at("code")).value; | ||||||
| //     BOOST_CHECK_EQUAL(code, "Ok");
 |     BOOST_CHECK_EQUAL(code, "Ok"); | ||||||
| 
 | 
 | ||||||
| //     BOOST_CHECK(json_result.values.find("tracepoints") == json_result.values.end());
 |     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_old_api) { test_match_skip_waypoints(true); } | ||||||
| // BOOST_AUTO_TEST_CASE(test_match_skip_waypoints_new_api) { test_match_skip_waypoints(false); }
 | BOOST_AUTO_TEST_CASE(test_match_skip_waypoints_new_api) { test_match_skip_waypoints(false); } | ||||||
| 
 | 
 | ||||||
| // void test_match_split(bool use_json_only_api)
 | void test_match_split(bool use_json_only_api) | ||||||
| // {
 | { | ||||||
| //     using namespace osrm;
 |     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;
 |     MatchParameters params; | ||||||
| //     params.coordinates = get_split_trace_locations();
 |     params.coordinates = get_split_trace_locations(); | ||||||
| //     params.timestamps = {1, 2, 1700, 1800};
 |     params.timestamps = {1, 2, 1700, 1800}; | ||||||
| 
 | 
 | ||||||
| //     json::Object json_result;
 |     json::Object json_result; | ||||||
| //     const auto rc = run_match_json(osrm, params, json_result, use_json_only_api);
 |     const auto rc = run_match_json(osrm, params, json_result, use_json_only_api); | ||||||
| 
 | 
 | ||||||
| //     BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
 |     BOOST_CHECK(rc == Status::Ok || rc == Status::Error); | ||||||
| //     const auto code = std::get<json::String>(json_result.values.at("code")).value;
 |     const auto code = std::get<json::String>(json_result.values.at("code")).value; | ||||||
| //     BOOST_CHECK_EQUAL(code, "Ok");
 |     BOOST_CHECK_EQUAL(code, "Ok"); | ||||||
| 
 | 
 | ||||||
| //     const auto &tracepoints = std::get<json::Array>(json_result.values.at("tracepoints")).values;
 |     const auto &tracepoints = std::get<json::Array>(json_result.values.at("tracepoints")).values; | ||||||
| //     BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size());
 |     BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size()); | ||||||
| 
 | 
 | ||||||
| //     const auto &matchings = std::get<json::Array>(json_result.values.at("matchings")).values;
 |     const auto &matchings = std::get<json::Array>(json_result.values.at("matchings")).values; | ||||||
| //     const auto &number_of_matchings = matchings.size();
 |     const auto &number_of_matchings = matchings.size(); | ||||||
| //     BOOST_CHECK_EQUAL(number_of_matchings, 2);
 |     BOOST_CHECK_EQUAL(number_of_matchings, 2); | ||||||
| //     std::size_t current_matchings_index = 0, expected_waypoint_index = 0;
 |     std::size_t current_matchings_index = 0, expected_waypoint_index = 0; | ||||||
| //     for (const auto &waypoint : tracepoints)
 |     for (const auto &waypoint : tracepoints) | ||||||
| //     {
 |     { | ||||||
| //         if (std::holds_alternative<util::json::Object>(waypoint))
 |         if (std::holds_alternative<util::json::Object>(waypoint)) | ||||||
| //         {
 |         { | ||||||
| //             BOOST_CHECK(waypoint_check(waypoint));
 |             BOOST_CHECK(waypoint_check(waypoint)); | ||||||
| //             const auto &waypoint_object = std::get<json::Object>(waypoint);
 |             const auto &waypoint_object = std::get<json::Object>(waypoint); | ||||||
| //             const auto matchings_index =
 |             const auto matchings_index = | ||||||
| //                 std::get<json::Number>(waypoint_object.values.at("matchings_index")).value;
 |                 std::get<json::Number>(waypoint_object.values.at("matchings_index")).value; | ||||||
| //             const auto waypoint_index =
 |             const auto waypoint_index = | ||||||
| //                 std::get<json::Number>(waypoint_object.values.at("waypoint_index")).value;
 |                 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 =
 |             expected_waypoint_index = | ||||||
| //                 (current_matchings_index != matchings_index) ? 0 : expected_waypoint_index;
 |                 (current_matchings_index != matchings_index) ? 0 : expected_waypoint_index; | ||||||
| //             BOOST_CHECK_EQUAL(waypoint_index, expected_waypoint_index);
 |             BOOST_CHECK_EQUAL(waypoint_index, expected_waypoint_index); | ||||||
| 
 | 
 | ||||||
| //             current_matchings_index = matchings_index;
 |             current_matchings_index = matchings_index; | ||||||
| //             ++expected_waypoint_index;
 |             ++expected_waypoint_index; | ||||||
| //         }
 |         } | ||||||
| //         else
 |         else | ||||||
| //         {
 |         { | ||||||
| //             BOOST_CHECK(std::holds_alternative<json::Null>(waypoint));
 |             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_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_split_new_api) { test_match_split(false); } | ||||||
| 
 | 
 | ||||||
| // BOOST_AUTO_TEST_CASE(test_match_fb_serialization)
 | BOOST_AUTO_TEST_CASE(test_match_fb_serialization) | ||||||
| // {
 | { | ||||||
| //     using namespace osrm;
 |     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;
 |     MatchParameters params; | ||||||
| //     params.coordinates.push_back(get_dummy_location());
 |     params.coordinates.push_back(get_dummy_location()); | ||||||
| //     params.coordinates.push_back(get_dummy_location());
 |     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);
 |     const auto rc = osrm.Match(params, result); | ||||||
| //     BOOST_CHECK(rc == Status::Ok);
 |     BOOST_CHECK(rc == Status::Ok); | ||||||
| 
 | 
 | ||||||
| //     auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
 |     auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result); | ||||||
| //     auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
 |     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); | ||||||
| //     const auto waypoints = fb->waypoints();
 |     const auto waypoints = fb->waypoints(); | ||||||
| //     BOOST_CHECK(waypoints->size() == params.coordinates.size());
 |     BOOST_CHECK(waypoints->size() == params.coordinates.size()); | ||||||
| 
 | 
 | ||||||
| //     BOOST_CHECK(fb->routes() != nullptr);
 |     BOOST_CHECK(fb->routes() != nullptr); | ||||||
| //     const auto matchings = fb->routes();
 |     const auto matchings = fb->routes(); | ||||||
| //     const auto &number_of_matchings = matchings->size();
 |     const auto &number_of_matchings = matchings->size(); | ||||||
| 
 | 
 | ||||||
| //     for (const auto waypoint : *waypoints)
 |     for (const auto waypoint : *waypoints) | ||||||
| //     {
 |     { | ||||||
| //         BOOST_CHECK(waypoint_check(waypoint));
 |         BOOST_CHECK(waypoint_check(waypoint)); | ||||||
| //         const auto matchings_index = waypoint->matchings_index();
 |         const auto matchings_index = waypoint->matchings_index(); | ||||||
| //         const auto waypoint_index = waypoint->waypoint_index();
 |         const auto waypoint_index = waypoint->waypoint_index(); | ||||||
| //         const auto &route_legs = matchings->operator[](matchings_index)->legs();
 |         const auto &route_legs = matchings->operator[](matchings_index)->legs(); | ||||||
| 
 | 
 | ||||||
| //         BOOST_CHECK_LT(waypoint_index, route_legs->size() + 1);
 |         BOOST_CHECK_LT(waypoint_index, route_legs->size() + 1); | ||||||
| //         BOOST_CHECK_LT(matchings_index, number_of_matchings);
 |         BOOST_CHECK_LT(matchings_index, number_of_matchings); | ||||||
| //     }
 |     } | ||||||
| // }
 | } | ||||||
| 
 | 
 | ||||||
| // BOOST_AUTO_TEST_CASE(test_match_fb_serialization_skip_waypoints)
 | BOOST_AUTO_TEST_CASE(test_match_fb_serialization_skip_waypoints) | ||||||
| // {
 | { | ||||||
| //     using namespace osrm;
 |     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;
 |     MatchParameters params; | ||||||
| //     params.skip_waypoints = true;
 |     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());
 |     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);
 |     const auto rc = osrm.Match(params, result); | ||||||
| //     BOOST_CHECK(rc == Status::Ok);
 |     BOOST_CHECK(rc == Status::Ok); | ||||||
| 
 | 
 | ||||||
| //     auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
 |     auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result); | ||||||
| //     auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
 |     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) | 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; |     using namespace osrm; | ||||||
| 
 | 
 | ||||||
|     // if (!std::holds_alternative<util::json::Object>(waypoint))
 |     if (!std::holds_alternative<util::json::Object>(waypoint)) | ||||||
|     // {
 |     { | ||||||
|     //     throw util::exception("Must pass in a waypoint object");
 |         throw util::exception("Must pass in a waypoint object"); | ||||||
|     // }
 |     } | ||||||
|     const auto waypoint_object = std::get<json::Object>(waypoint); |     const auto waypoint_object = std::get<json::Object>(waypoint); | ||||||
|     const auto waypoint_location = |     const auto waypoint_location = | ||||||
|         std::get<json::Array>(waypoint_object.values.at("location")).values; |         std::get<json::Array>(waypoint_object.values.at("location")).values; | ||||||
|  | |||||||
| @ -17,7 +17,6 @@ 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_CORRUPT_FINGERPRINT_FILE = "corrupt_fingerprint_file_test_io.tmp"; | ||||||
| const static std::string IO_INCOMPATIBLE_FINGERPRINT_FILE = | const static std::string IO_INCOMPATIBLE_FINGERPRINT_FILE = | ||||||
|     "incompatible_fingerprint_file_test_io.tmp"; |     "incompatible_fingerprint_file_test_io.tmp"; | ||||||
| const static std::string IO_TEXT_FILE = "plain_text_file.tmp"; |  | ||||||
| 
 | 
 | ||||||
| using namespace osrm; | using namespace osrm; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user